"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[922],{5589:function(e,t,s){s.d(t,{Z:function(){return i}});/**
 * @license lucide-react v0.309.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let i=(0,s(2898).Z)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]])},2549:function(e,t,s){s.d(t,{Z:function(){return i}});/**
 * @license lucide-react v0.309.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let i=(0,s(2898).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},3922:function(e,t,s){s.d(t,{Z:function(){return P}});var i=s(7437),a=s(2265),n=s(2167),r=s(5251),l=s(3067),c=s(9865),o=s(3008),d=s(5589),u=s(2898);/**
 * @license lucide-react v0.309.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let h=(0,u.Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),m=(0,u.Z)("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),x=(0,u.Z)("Volume2",[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]]),p=(0,u.Z)("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),g=(0,u.Z)("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);var f=s(7393),y=s(5925),v=s(3395),b=s(4691);/**
 * @license lucide-react v0.309.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let j=(0,u.Z)("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]);function k(e){let{isActive:t,audioLevel:s=0,color:n="#6366f1",barCount:r=20}=e,l=(0,a.useRef)([]);(0,a.useEffect)(()=>{if(!t){l.current.forEach(e=>{e&&(e.style.transform="scaleY(0.15)")});return}let e=setInterval(()=>{l.current.forEach((e,t)=>{if(!e)return;let i=s/100,a=.3*Math.sin(Date.now()/200+.5*t);e.style.transform="scaleY(".concat(Math.max(.15,Math.min(1,.7*i+a+.2*Math.random())),")")})},50);return()=>clearInterval(e)},[t,s]);let c=["#6366f1","#7c3aed","#8b5cf6","#a855f7","#c026d3","#db2777","#ec4899","#db2777","#c026d3","#a855f7","#8b5cf6","#7c3aed","#6366f1","#4f46e5","#4338ca","#6366f1","#7c3aed","#a855f7","#c026d3","#6366f1"];return(0,i.jsx)("div",{className:"flex items-end justify-center gap-0.5",style:{height:"40px"},children:Array.from({length:r}).map((e,t)=>(0,i.jsx)("div",{ref:e=>{l.current[t]=e},className:"wave-bar",style:{height:"40px",background:c[t%c.length],animationDelay:"".concat(.05*t,"s"),animationDuration:"".concat(.4+.3*Math.random(),"s"),transform:"scaleY(0.15)",transition:"transform 0.05s ease"}},t))})}let N={idle:{bg:"linear-gradient(135deg, #6366f1, #a855f7)",label:"Tap to speak",icon:p,glow:"rgba(99,102,241,0.4)"},listening:{bg:"linear-gradient(135deg, #ef4444, #dc2626)",label:"Listening...",icon:p,glow:"rgba(239,68,68,0.5)"},thinking:{bg:"linear-gradient(135deg, #f59e0b, #d97706)",label:"Thinking...",icon:j,glow:"rgba(245,158,11,0.4)"},speaking:{bg:"linear-gradient(135deg, #3b82f6, #2563eb)",label:"Speaking...",icon:x,glow:"rgba(59,130,246,0.4)"}},w={sm:{button:56,icon:20,fontSize:11},md:{button:72,icon:24,fontSize:12},lg:{button:80,icon:28,fontSize:13}};function S(e){let{state:t,audioLevel:s=0,onTap:l,onLongPress:c,disabled:o,size:d="lg"}=e,[u,h]=(0,a.useState)(!1),m=(0,a.useRef)(null),x=N[t],p=w[d],g=(0,a.useCallback)(()=>{h(!0),"vibrate"in navigator&&navigator.vibrate(50),c&&(m.current=setTimeout(()=>{"vibrate"in navigator&&navigator.vibrate([50,100,50]),c()},600))},[c]),f=(0,a.useCallback)(()=>{h(!1),m.current&&(clearTimeout(m.current),m.current=null)},[]),y=(0,a.useCallback)(()=>{o||("vibrate"in navigator&&navigator.vibrate(50),l())},[o,l]);return(0,i.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,i.jsx)(n.M,{children:("listening"===t||"speaking"===t)&&(0,i.jsx)(r.E.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},children:(0,i.jsx)(k,{isActive:!0,audioLevel:s,barCount:20})})}),(0,i.jsxs)("div",{className:"relative flex items-center justify-center",children:["listening"===t&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.E.div,{className:"absolute rounded-full",style:{width:p.button+32,height:p.button+32,background:"rgba(239,68,68,0.15)"},animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:1.5,repeat:1/0}}),(0,i.jsx)(r.E.div,{className:"absolute rounded-full",style:{width:p.button+16,height:p.button+16,background:"rgba(239,68,68,0.2)"},animate:{scale:[1,1.2,1],opacity:[.8,.2,.8]},transition:{duration:1.5,repeat:1/0,delay:.3}})]}),"thinking"===t&&(0,i.jsx)(r.E.div,{className:"absolute rounded-full border-2 border-amber-400",style:{width:p.button+20,height:p.button+20,borderStyle:"dashed"},animate:{rotate:360},transition:{duration:3,repeat:1/0,ease:"linear"}}),(0,i.jsx)(r.E.button,{onClick:y,onPointerDown:g,onPointerUp:f,onPointerLeave:f,disabled:o,whileTap:{scale:.92},animate:{scale:u?.95:1},className:"relative flex items-center justify-center rounded-full cursor-pointer select-none",style:{width:p.button,height:p.button,background:x.bg,boxShadow:"0 8px 32px ".concat(x.glow,", 0 4px 16px rgba(0,0,0,0.2)"),border:"none",outline:"none"},"aria-label":x.label,children:(0,i.jsx)(r.E.div,{initial:{scale:0,rotate:-90},animate:{scale:1,rotate:0},transition:{type:"spring",stiffness:400,damping:20},children:(0,i.jsx)(x.icon,{size:p.icon,color:"white",className:"thinking"===t?"animate-sparkle":"listening"===t?"animate-voice-pulse":""})},t)})]}),(0,i.jsx)(r.E.p,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"text-xs font-semibold",style:{color:"var(--text-secondary)",fontSize:p.fontSize},children:x.label},t)]})}var C=s(2549);let T={idle:"#6366f1",listening:"#ef4444",thinking:"#f59e0b",speaking:"#3b82f6"},E={idle:"Tap mic to speak",listening:"Listening...",thinking:"James is thinking...",speaking:"James is speaking..."},L={idle:(0,i.jsx)(p,{className:"w-5 h-5"}),listening:(0,i.jsx)(p,{className:"w-5 h-5"}),thinking:(0,i.jsx)(j,{className:"w-5 h-5"}),speaking:(0,i.jsx)(x,{className:"w-5 h-5"})};function D(e){let{isOpen:t,voiceState:s,transcript:l,interimTranscript:c,audioLevel:o,recentMessages:d,onClose:u,onTap:h,clientName:m="You"}=e,x=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=x.current;if(!e)return;let t=0,s=e=>{t=e.touches[0].clientY},i=e=>{e.changedTouches[0].clientY-t>80&&u()};return e.addEventListener("touchstart",s,{passive:!0}),e.addEventListener("touchend",i,{passive:!0}),()=>{e.removeEventListener("touchstart",s),e.removeEventListener("touchend",i)}},[u]),(0,a.useEffect)(()=>{var e;null===(e=p.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[d,l,c]);let g=T[s],f=d.slice(-6);return(0,i.jsx)(n.M,{children:t&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},onClick:u}),(0,i.jsxs)(r.E.div,{ref:x,initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",stiffness:320,damping:32},className:"fixed bottom-0 left-0 right-0 z-50 flex flex-col",style:{maxHeight:"80vh",borderRadius:"24px 24px 0 0",background:"var(--bg-card)",boxShadow:"0 -8px 40px rgba(0,0,0,0.25)"},children:[(0,i.jsx)("div",{className:"flex justify-center pt-3 pb-1 flex-shrink-0",children:(0,i.jsx)("div",{className:"w-10 h-1 rounded-full",style:{background:"var(--border)"}})}),(0,i.jsxs)("div",{className:"flex items-center justify-between px-5 py-2 flex-shrink-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(r.E.div,{animate:{background:g},transition:{duration:.3},className:"w-9 h-9 rounded-full flex items-center justify-center text-white",children:L[s]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-bold",style:{color:"var(--text-primary)"},children:"James Cole"}),(0,i.jsx)(r.E.p,{initial:{opacity:0},animate:{opacity:1},className:"text-xs font-medium",style:{color:g},children:E[s]},s)]})]}),(0,i.jsx)("button",{onClick:u,className:"w-8 h-8 rounded-full flex items-center justify-center",style:{background:"var(--bg-secondary)"},children:(0,i.jsx)(C.Z,{className:"w-4 h-4",style:{color:"var(--text-secondary)"}})})]}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-2 space-y-3 min-h-0",children:[f.map((e,t)=>(0,i.jsxs)(r.E.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"flex ".concat("user"===e.role?"justify-end":"justify-start"," gap-2"),children:["assistant"===e.role&&(0,i.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",style:{background:"linear-gradient(135deg, #6366f1, #a855f7)"},children:"J"}),(0,i.jsx)("div",{className:"user"===e.role?"msg-user text-sm":"msg-ai text-sm",style:{maxWidth:"80%",padding:"8px 12px"},children:e.content})]},t)),(0,i.jsx)(n.M,{children:(l||c)&&(0,i.jsx)(r.E.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},className:"flex justify-end",children:(0,i.jsxs)("div",{className:"rounded-2xl px-3 py-2 text-sm text-white",style:{background:"rgba(99,102,241,0.6)",maxWidth:"80%"},children:[l||c,c&&(0,i.jsx)("span",{className:"inline-block w-0.5 h-3.5 ml-0.5 bg-white animate-pulse"})]})})}),"thinking"===s&&(0,i.jsxs)(r.E.div,{initial:{opacity:0},animate:{opacity:1},className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-bold",style:{background:"linear-gradient(135deg, #6366f1, #a855f7)"},children:"J"}),(0,i.jsxs)("div",{className:"msg-ai flex items-center gap-1.5 py-2 px-3",children:[(0,i.jsx)("div",{className:"typing-dot"}),(0,i.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.2s"}}),(0,i.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.4s"}})]})]}),(0,i.jsx)("div",{ref:p})]}),(0,i.jsxs)("div",{className:"flex-shrink-0 flex flex-col items-center py-4 gap-3",style:{borderTop:"1px solid var(--border)"},children:[(0,i.jsx)(n.M,{children:("listening"===s||"speaking"===s)&&(0,i.jsx)(r.E.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},children:(0,i.jsx)(k,{isActive:!0,audioLevel:o,barCount:24})})}),(0,i.jsxs)(r.E.button,{onClick:h,whileTap:{scale:.92},className:"relative flex items-center justify-center rounded-full text-white",style:{width:72,height:72,background:"linear-gradient(135deg, ".concat(g,", ").concat(g,"cc)"),boxShadow:"0 8px 32px ".concat(g,"60")},children:["listening"===s&&(0,i.jsx)(r.E.div,{className:"absolute inset-0 rounded-full",animate:{scale:[1,1.4],opacity:[.5,0]},transition:{duration:1.2,repeat:1/0},style:{background:g}}),(0,i.jsx)(r.E.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:400,damping:20},children:L[s]},s)]}),(0,i.jsx)("p",{className:"text-xs font-medium",style:{color:"var(--text-secondary)"},children:"listening"===s?"Tap to stop • Swipe down to close":E[s]})]}),(0,i.jsx)("div",{className:"safe-bottom flex-shrink-0"})]})]})})}var M=s(1671);class R{setupRecognitionHandlers(){this.recognition&&(this.recognition.onresult=e=>{var t,s;let i="",a="";for(let t=e.resultIndex;t<e.results.length;t++){let s=e.results[t][0].transcript;e.results[t].isFinal?a+=s:i+=s}i&&(null===(t=this.onTranscript)||void 0===t||t.call(this,i)),a&&(null===(s=this.onFinalTranscript)||void 0===s||s.call(this,a.trim()),this.resetSilenceTimer())},this.recognition.onerror=e=>{var t;"no-speech"!==e.error&&(null===(t=this.onError)||void 0===t||t.call(this,"Speech recognition error: ".concat(e.error)),this.active&&this.retryCount<this.MAX_RETRIES&&(this.retryCount++,setTimeout(()=>this.startListening(),500)))},this.recognition.onend=()=>{this.setListening(!1),this.active&&!this.isSpeaking&&setTimeout(()=>this.startListening(),300)})}resetSilenceTimer(){this.silenceTimer&&clearTimeout(this.silenceTimer),this.silenceTimer=setTimeout(()=>{this.isListening&&this.stopListening()},this.silenceMs)}setListening(e){var t;this.isListening=e,null===(t=this.onListeningChange)||void 0===t||t.call(this,e)}setSpeakingState(e){var t;this.isSpeaking=e,null===(t=this.onSpeakingChange)||void 0===t||t.call(this,e)}start(){this.active=!0,this.startListening()}stop(){var e;this.active=!1,this.stopListening(),null===(e=this.synthesis)||void 0===e||e.cancel(),this.speakQueue=[]}startListening(){if(this.recognition&&!this.isListening&&!this.isSpeaking)try{this.recognition.start(),this.setListening(!0),this.retryCount=0}catch(e){}}stopListening(){if(this.recognition&&this.isListening){try{this.recognition.stop()}catch(e){}this.setListening(!1),this.silenceTimer&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}speak(e){if(!this.synthesis)return;let t=this.cleanText(e);if(!t)return;this.stopListening(),this.setSpeakingState(!0);let s=new SpeechSynthesisUtterance(t);s.rate=this.rate,s.pitch=this.pitch,s.volume=this.volume,s.lang=this.language,s.onend=()=>{this.setSpeakingState(!1),this.active&&setTimeout(()=>this.startListening(),400)},s.onerror=()=>{this.setSpeakingState(!1),this.active&&setTimeout(()=>this.startListening(),400)},this.synthesis.speak(s)}enqueueSpeak(e){this.speakQueue.push(e),this.isSpeaking||this.processQueue()}processQueue(){0!==this.speakQueue.length&&this.speak(this.speakQueue.shift())}completeProcessing(){this.processQueue()}isVoiceActive(){return this.active}setSilenceMs(e){this.silenceMs=e}setLanguage(e){this.language=e,this.recognition&&(this.recognition.lang=e)}cleanText(e){return e.replace(/[#*_`~>]/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ").trim()}constructor(e={}){var t,s,i,a,n;this.recognition=null,this.synthesis=null,this.speakQueue=[],this.isSpeaking=!1,this.isListening=!1,this.active=!1,this.silenceTimer=null,this.retryCount=0,this.MAX_RETRIES=3,this.rate=null!==(t=e.rate)&&void 0!==t?t:.92,this.pitch=null!==(s=e.pitch)&&void 0!==s?s:1.05,this.volume=null!==(i=e.volume)&&void 0!==i?i:1,this.language=null!==(a=e.language)&&void 0!==a?a:"en-US",this.silenceMs=null!==(n=e.silenceMs)&&void 0!==n?n:2e3,this.onListeningChange=e.onListeningChange,this.onSpeakingChange=e.onSpeakingChange,this.onTranscript=e.onTranscript,this.onFinalTranscript=e.onFinalTranscript,this.onError=e.onError;{let e=window.SpeechRecognition||window.webkitSpeechRecognition;e&&(this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang=this.language,this.setupRecognitionHandlers()),"speechSynthesis"in window&&(this.synthesis=window.speechSynthesis)}}}var O=s(8013),Z=s(3248),F=s(4033);let z={1:"#6366f1",2:"#a855f7",3:"#f59e0b",4:"#10b981"},_={1:"ROOTS",2:"THE JOURNEY",3:"GLORY",4:"LEGACY"};function P(e){var t,s;let{client:u,onBack:j}=e,k=(0,F.useRouter)(),N=function(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=()=>t(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}(),[w,C]=(0,a.useState)("loading"),[T,E]=(0,a.useState)([]),[L,P]=(0,a.useState)(null),[J,I]=(0,a.useState)(null),[A,Y]=(0,a.useState)([]),[U,B]=(0,a.useState)(""),[G,H]=(0,a.useState)(!1),[Q,V]=(0,a.useState)(!1),[q,W]=(0,a.useState)(0),[K,X]=(0,a.useState)(!1),[$,ee]=(0,a.useState)(!1),[et,es]=(0,a.useState)(!1),[ei,ea]=(0,a.useState)("idle"),[en,er]=(0,a.useState)(!1),[el,ec]=(0,a.useState)(""),[eo,ed]=(0,a.useState)(""),[eu,eh]=(0,a.useState)(0),em=(0,a.useRef)(null),ex=(0,a.useRef)(null),ep=(0,a.useRef)(null),eg=(0,a.useRef)(!1),ef=(0,a.useRef)(null),ey=(0,a.useRef)(null),ev=(0,a.useRef)(null),eb=(0,a.useRef)(null),ej={recognition:"SpeechRecognition"in window||"webkitSpeechRecognition"in window,synthesis:"speechSynthesis"in window},ek=(0,a.useRef)(()=>{}),eN=(0,a.useRef)(!1);(0,a.useRef)(e=>{eN.current=e(eN.current),er(eN.current)}),(0,a.useEffect)(()=>{ew()},[]);let ew=async()=>{try{let e=await O.T6.getState(u.id);E(e.chapters),P(e.state),Y(Array.isArray(u.messages)?u.messages:[]),C(12===e.state.completedChapters?"all_done":"chapter_select")}catch(e){C("chapter_select"),E([])}};(0,a.useEffect)(()=>{var e;null===(e=em.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[A,Q]),(0,a.useEffect)(()=>{if(!ej.recognition)return;let e=new R({rate:.88,pitch:1,onListeningChange:e=>{ea(t=>"thinking"===t||"speaking"===t?t:e?"listening":"idle"),e?eS():eC()},onSpeakingChange:t=>{t?ea("speaking"):(ea("idle"),eN.current&&setTimeout(()=>{ea("listening"),e.startListening()},600))},onTranscript:e=>ed(e),onFinalTranscript:t=>{ec(t),ed(""),ea("thinking"),e.stopListening(),eC(),ek.current(t,!0)},onError:e=>{console.warn("Voice error:",e),ea("idle")}});return ep.current=e,()=>{e.stop(),eC()}},[]);let eS=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});ey.current=new AudioContext,ev.current=ey.current.createAnalyser(),ev.current.fftSize=256,ey.current.createMediaStreamSource(e).connect(ev.current);let t=new Uint8Array(ev.current.frequencyBinCount);eb.current=setInterval(()=>{var e;null===(e=ev.current)||void 0===e||e.getByteFrequencyData(t);let s=t.reduce((e,t)=>e+t,0)/t.length;eh(Math.min(100,2*s))},50)}catch(e){}},eC=()=>{eb.current&&(clearInterval(eb.current),eb.current=null),ey.current&&(ey.current.close(),ey.current=null),eh(0)},eT=async e=>{I(e),H(!0),V(!0),C("interviewing");try{let t=await O.T6.startChapter({clientId:u.id,chapterNum:e.num});P(t.state),Y(s=>[...s,{role:"assistant",content:t.response,chapterNum:e.num,timestamp:new Date().toISOString()}]),W(0),X(!1),eN.current&&ep.current&&(ea("speaking"),ep.current.speak(t.response))}catch(e){y.default.error(e.message||"Failed to start chapter"),C("chapter_select")}finally{H(!1),V(!1)}},eE=(0,a.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!eg.current&&e.trim()&&J){eg.current=!0,H(!0),V(!0),ea("thinking"),Y(t=>[...t,{role:"user",content:e,chapterNum:J.num,timestamp:new Date().toISOString()}]),B(""),ec("");try{let s=await O.T6.sendMessage({clientId:u.id,message:e,chapterNum:J.num,isVoice:t});V(!1),Y(e=>[...e,{role:"assistant",content:s.response,chapterNum:J.num,timestamp:new Date().toISOString()}]),W(s.chapterUserResponses),X(s.canComplete),P(s.state),"vibrate"in navigator&&navigator.vibrate([30,50,30]),eN.current&&ep.current?(ea("speaking"),ep.current.speak(s.response)):ea("idle"),ef.current&&clearTimeout(ef.current),es(!1),ef.current=setTimeout(()=>{es(!0),setTimeout(()=>es(!1),3e3)},1500)}catch(e){V(!1),ea("idle"),y.default.error(e.message||"Failed to send"),Y(e=>e.slice(0,-1))}finally{H(!1),eg.current=!1}}},[J,u.id]);(0,a.useEffect)(()=>{ek.current=eE},[eE]);let eL=async()=>{if(J){H(!0);try{let e=await O.T6.completeChapter({clientId:u.id,chapterNum:J.num});P(e.state),Y(t=>[...t,{role:"assistant",content:e.closingMessage,chapterNum:J.num,type:"chapter_closing",timestamp:new Date().toISOString()}]),"vibrate"in navigator&&navigator.vibrate([50,100,50,100,50]),C(e.isAllDone?"all_done":"chapter_complete")}catch(e){y.default.error(e.message||"Failed to complete chapter")}finally{H(!1)}}},eD=(0,a.useCallback)(()=>{if(!ep.current){y.default.error("Voice not supported in this browser");return}"listening"===ei?(ep.current.stopListening(),ea("idle")):"idle"===ei&&(eN.current=!0,er(!0),ea("listening"),ep.current.startListening())},[ei]),eM=async()=>{ee(!0);try{await O.s9.generate(u.id),y.default.success("Book generated!"),k.push("/book/".concat(u.id))}catch(e){y.default.error(e.message||"Failed to generate book")}finally{ee(!1)}},eR=e=>{if("speechSynthesis"in window){window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e.replace(/[#*_`]/g,""));t.rate=.92,t.pitch=1.05,window.speechSynthesis.speak(t)}},eO=A.filter(e=>e.chapterNum===(null==J?void 0:J.num)&&"system"!==e.role&&e.content),eZ=null!==(t=null==L?void 0:L.completedChapters)&&void 0!==t?t:0,eF=null!==(s=null==L?void 0:L.progress)&&void 0!==s?s:0,ez=z[(null==J?void 0:J.part)||1],[e_,eP]=(0,a.useState)(null),[eJ,eI]=(0,a.useState)(!1),eA=(0,a.useRef)(null);return(0,a.useEffect)(()=>{J&&!(q<3)&&q%3==0&&(eA.current&&clearTimeout(eA.current),eA.current=setTimeout(async()=>{eI(!0);try{let e=await O.s9.preview(u.id,J.num);e.preview&&eP(e.preview)}catch(e){}finally{eI(!1)}},1e3))},[q,J,u.id]),(0,i.jsxs)("div",{className:"h-screen flex flex-col",style:{background:"var(--bg-secondary)"},children:[(0,i.jsxs)("header",{className:"flex-shrink-0 border-b px-4 py-3 flex items-center gap-3 safe-top",style:{background:"var(--bg-card)",borderColor:"var(--border)"},children:[(0,i.jsx)("button",{onClick:j,className:"btn-ghost p-2 rounded-lg touch-target","aria-label":"Go back to dashboard",children:(0,i.jsx)(l.Z,{className:"w-4 h-4"})}),(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,i.jsx)("span",{className:"text-xl",children:(0,Z.w2)(u.sport)}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("h1",{className:"font-bold text-sm truncate",style:{color:"var(--text-primary)"},children:u.name}),(0,i.jsx)("p",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:u.bookTitle})]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,i.jsxs)("div",{className:"hidden sm:flex items-center gap-2",children:[(0,i.jsxs)("span",{className:"text-xs font-semibold",style:{color:"var(--text-secondary)"},children:[eZ,"/12"]}),(0,i.jsx)("div",{className:"w-20",children:(0,i.jsx)(v.Z,{value:eF})})]}),(0,i.jsx)(n.M,{children:et&&(0,i.jsx)(r.E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-xs text-green-500 hidden sm:block",children:"✓"})}),eZ>=3&&(0,i.jsxs)("button",{onClick:eM,disabled:$,className:"btn-primary flex items-center gap-1.5 text-xs py-2",children:[$?(0,i.jsx)(b.Z,{size:"sm"}):(0,i.jsx)(c.Z,{className:"w-3.5 h-3.5"}),(0,i.jsx)("span",{className:"hidden sm:inline",children:"Generate Book"})]})]})]}),(0,i.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,i.jsxs)("aside",{className:"hidden lg:flex flex-col w-64 border-r flex-shrink-0 overflow-y-auto",style:{borderColor:"var(--border)",background:"var(--bg-card)"},children:[(0,i.jsxs)("div",{className:"p-3",children:[(0,i.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-secondary)"},children:"Book Chapters"}),[1,2,3,4].map(e=>(0,i.jsxs)("div",{className:"mb-3",children:[(0,i.jsxs)("p",{className:"text-xs font-bold mb-1.5 px-1",style:{color:z[e]},children:["Part ",e,": ",_[e]]}),T.filter(t=>t.part===e).map(t=>{var s;let a=null==L?void 0:L.chapterData[t.num],n=null==a?void 0:a.isComplete,r=(null==J?void 0:J.num)===t.num&&"interviewing"===w,l=t.num>1&&!(null==L?void 0:null===(s=L.chapterData[t.num-1])||void 0===s?void 0:s.isComplete);return(0,i.jsxs)("button",{onClick:()=>!l&&!n&&"interviewing"!==w&&eT(t),disabled:l||"interviewing"===w&&!r,className:"w-full text-left px-2 py-2 rounded-lg mb-0.5 flex items-center gap-2 transition-all text-xs",style:r?{background:"".concat(z[e],"18"),color:z[e],fontWeight:600}:n?{color:"#10b981"}:l?{color:"var(--text-secondary)",opacity:.4}:{color:"var(--text-secondary)"},children:[(0,i.jsx)("span",{className:"flex-shrink-0",children:n?(0,i.jsx)(o.Z,{className:"w-3.5 h-3.5 text-green-500"}):l?(0,i.jsx)(d.Z,{className:"w-3.5 h-3.5"}):r?(0,i.jsx)(h,{className:"w-3.5 h-3.5",style:{color:z[e]}}):(0,i.jsx)(m,{className:"w-3.5 h-3.5"})}),(0,i.jsxs)("span",{className:"truncate",children:[t.num,". ",t.title]})]},t.num)})]},e))]}),(e_||eJ)&&J&&(0,i.jsxs)("div",{className:"mx-3 mb-3 p-3 rounded-xl border",style:{background:"".concat(z[J.part],"08"),borderColor:"".concat(z[J.part],"30")},children:[(0,i.jsx)("p",{className:"text-xs font-semibold mb-2 flex items-center gap-1",style:{color:z[J.part]},children:"✍️ Live Preview"}),eJ?(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("div",{className:"skeleton h-3 w-full rounded"}),(0,i.jsx)("div",{className:"skeleton h-3 w-4/5 rounded"}),(0,i.jsx)("div",{className:"skeleton h-3 w-3/4 rounded"})]}):(0,i.jsxs)("p",{className:"text-xs leading-relaxed italic",style:{color:"var(--text-secondary)"},children:['"',null==e_?void 0:e_.slice(0,200),'..."']})]})]}),(0,i.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:["loading"===w&&(0,i.jsx)("div",{className:"flex-1 p-4 space-y-4",children:[1,2,3].map(e=>(0,i.jsx)(M.tz,{isUser:e%2==0},e))}),"chapter_select"===w&&(0,i.jsx)("div",{className:"flex-1 overflow-y-auto p-4 pb-safe",children:(0,i.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,i.jsxs)(r.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-6",children:[(0,i.jsx)("div",{className:"text-5xl mb-3",children:(0,Z.w2)(u.sport)}),(0,i.jsx)("h2",{className:"text-xl font-bold mb-1",style:{color:"var(--text-primary)"},children:0===eZ?"Welcome, ".concat(u.name,"!"):"Continue Your Story"}),(0,i.jsx)("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:0===eZ?"Your biography will be built chapter by chapter.":"".concat(eZ," of 12 chapters complete.")}),eZ>0&&(0,i.jsxs)("div",{className:"mt-3 max-w-xs mx-auto",children:[(0,i.jsx)(v.Z,{value:eF}),(0,i.jsxs)("p",{className:"text-xs mt-1",style:{color:"var(--text-secondary)"},children:[eF,"% complete"]})]})]}),[1,2,3,4].map(e=>(0,i.jsxs)("div",{className:"mb-5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,i.jsx)("div",{className:"h-px flex-1",style:{background:z[e]+"40"}}),(0,i.jsxs)("span",{className:"text-xs font-bold px-2",style:{color:z[e]},children:["PART ",e,": ",_[e]]}),(0,i.jsx)("div",{className:"h-px flex-1",style:{background:z[e]+"40"}})]}),(0,i.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:T.filter(t=>t.part===e).map((t,s)=>{var a;let n=null==L?void 0:L.chapterData[t.num],l=null==n?void 0:n.isComplete,c=t.num>1&&!(null==L?void 0:null===(a=L.chapterData[t.num-1])||void 0===a?void 0:a.isComplete);return(0,i.jsxs)(r.E.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05*s},onClick:()=>!c&&!l&&eT(t),disabled:c||l,whileTap:{scale:c||l?1:.97},className:"p-4 rounded-xl text-left border touch-target",style:l?{background:"rgba(16,185,129,0.08)",borderColor:"#10b981",cursor:"default"}:c?{background:"var(--bg-secondary)",borderColor:"var(--border)",opacity:.5,cursor:"not-allowed"}:{background:"".concat(z[e],"08"),borderColor:"".concat(z[e],"40"),cursor:"pointer"},children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,i.jsxs)("span",{className:"text-xs font-bold",style:{color:l?"#10b981":c?"var(--text-secondary)":z[e]},children:["Ch. ",t.num]}),l?(0,i.jsx)(o.Z,{className:"w-4 h-4 text-green-500"}):c?(0,i.jsx)(d.Z,{className:"w-4 h-4",style:{color:"var(--text-secondary)"}}):(0,i.jsx)(h,{className:"w-4 h-4",style:{color:z[e]}})]}),(0,i.jsx)("p",{className:"text-sm font-semibold mb-1",style:{color:"var(--text-primary)"},children:t.title}),(0,i.jsx)("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:t.theme.split(",").slice(0,2).join(", ")})]},t.num)})})]},e)),eZ>=3&&(0,i.jsxs)(r.E.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-4 rounded-xl text-center",style:{background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.2)"},children:[(0,i.jsxs)("p",{className:"text-sm font-semibold mb-2",style:{color:"var(--text-primary)"},children:["\uD83C\uDF89 ",eZ," chapters ready!"]}),(0,i.jsx)("button",{onClick:eM,disabled:$,className:"btn-primary",children:$?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.Z,{size:"sm"})," Generating..."]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.Z,{className:"w-4 h-4 inline mr-1"})," Generate Book"]})})]})]})}),("interviewing"===w||"chapter_complete"===w)&&J&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex-shrink-0 px-4 py-2 flex items-center justify-between",style:{background:"".concat(ez,"12"),borderBottom:"1px solid ".concat(ez,"30")},children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("span",{className:"text-xs font-bold",style:{color:ez},children:["Ch. ",J.num,": ",J.title]}),(0,i.jsx)("span",{className:"text-xs ml-2 hidden sm:inline",style:{color:"var(--text-secondary)"},children:_[J.part]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,i.jsxs)("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[q,"/",J.minResponses]}),"interviewing"===w&&K&&(0,i.jsxs)(r.E.button,{initial:{scale:.9},animate:{scale:1},onClick:eL,disabled:G,className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-semibold text-white touch-target",style:{background:ez},children:[(0,i.jsx)(o.Z,{className:"w-3 h-3"})," Complete"]}),"chapter_complete"===w&&(0,i.jsx)("button",{onClick:()=>C("chapter_select"),className:"px-2.5 py-1.5 rounded-lg text-xs font-semibold text-white touch-target",style:{background:"#10b981"},children:"Next →"})]})]}),(0,i.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 ".concat(N?"mobile-voice-space":""),children:[(0,i.jsx)(n.M,{initial:!1,children:eO.map((e,t)=>(0,i.jsxs)(r.E.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:"flex ".concat("user"===e.role?"justify-end":"justify-start"," gap-2"),children:["assistant"===e.role&&(0,i.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-1",style:{background:"linear-gradient(135deg, ".concat(ez,", #a855f7)")},children:"J"}),(0,i.jsxs)("div",{className:"user"===e.role?"msg-user":"msg-ai",children:[(0,i.jsx)("div",{className:"text-sm leading-relaxed",children:(0,i.jsx)(f.UG,{children:e.content||""})}),"assistant"===e.role&&(0,i.jsxs)("button",{onClick:()=>eR(e.content||""),className:"mt-1 flex items-center gap-1 text-xs opacity-40 hover:opacity-80 transition-opacity",style:{color:"var(--text-secondary)"},children:[(0,i.jsx)(x,{className:"w-3 h-3"})," Read aloud"]})]}),"user"===e.role&&(0,i.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-1",style:{background:"linear-gradient(135deg, #a855f7, #6366f1)"},children:u.name[0].toUpperCase()})]},t))}),Q&&(0,i.jsxs)(r.E.div,{initial:{opacity:0},animate:{opacity:1},className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-white text-xs font-bold",style:{background:"linear-gradient(135deg, ".concat(ez,", #a855f7)")},children:"J"}),(0,i.jsxs)("div",{className:"msg-ai flex items-center gap-1.5 py-3 px-4",children:[(0,i.jsx)("div",{className:"typing-dot"}),(0,i.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.2s"}}),(0,i.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.4s"}})]})]}),(0,i.jsx)("div",{ref:em})]}),"interviewing"===w&&!N&&(0,i.jsxs)("div",{className:"flex-shrink-0 p-4 border-t",style:{borderColor:"var(--border)",background:"var(--bg-card)"},children:[K&&(0,i.jsx)(r.E.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},className:"mb-2 px-3 py-2 rounded-lg text-xs",style:{background:"".concat(ez,"12"),border:"1px solid ".concat(ez,"30"),color:ez},children:"✓ Great coverage! You can complete this chapter or keep going."}),(0,i.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,i.jsx)("button",{onClick:()=>{er(!0),eD()},className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 transition-all",style:{background:"idle"!==ei?"linear-gradient(135deg, #ef4444, #dc2626)":"var(--bg-secondary)",border:"1.5px solid var(--border)"},children:(0,i.jsx)(p,{className:"w-4 h-4",style:{color:"idle"!==ei?"white":"var(--text-secondary)"}})}),(0,i.jsx)("textarea",{ref:ex,value:U,onChange:e=>{B(e.target.value),e.target.style.height="auto",e.target.style.height=Math.min(e.target.scrollHeight,120)+"px"},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eE(U))},placeholder:G?"James is thinking...":"Share your story...",disabled:G,rows:1,className:"input-field flex-1 resize-none",style:{minHeight:"44px",maxHeight:"120px"}}),(0,i.jsx)("button",{onClick:()=>eE(U),disabled:G||!U.trim(),className:"btn-primary w-10 h-10 p-0 flex items-center justify-center flex-shrink-0 disabled:opacity-40",children:G?(0,i.jsx)(b.Z,{size:"sm"}):(0,i.jsx)(g,{className:"w-4 h-4"})})]})]}),"interviewing"===w&&N&&(0,i.jsxs)("div",{className:"fixed bottom-0 left-0 right-0 z-30 safe-bottom",children:[(0,i.jsxs)("div",{className:"px-4 py-2 flex gap-2 items-end",style:{background:"var(--bg-card)",borderTop:"1px solid var(--border)"},children:[(0,i.jsx)("textarea",{value:U,onChange:e=>B(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eE(U))},placeholder:"Type or use voice...",disabled:G,rows:1,className:"input-field flex-1 resize-none text-sm",style:{minHeight:"40px",maxHeight:"80px"}}),(0,i.jsx)("button",{onClick:()=>eE(U),disabled:G||!U.trim(),className:"btn-primary w-10 h-10 p-0 flex items-center justify-center flex-shrink-0 disabled:opacity-40",children:G?(0,i.jsx)(b.Z,{size:"sm"}):(0,i.jsx)(g,{className:"w-4 h-4"})})]}),(0,i.jsx)("div",{className:"flex justify-center pb-4 pt-2",style:{background:"var(--bg-card)"},children:(0,i.jsx)(S,{state:ei,audioLevel:eu,onTap:()=>{er(!0),eD()},size:"md"})})]}),"chapter_complete"===w&&(0,i.jsxs)("div",{className:"flex-shrink-0 p-4 border-t text-center safe-bottom",style:{borderColor:"var(--border)",background:"var(--bg-card)"},children:[(0,i.jsxs)("p",{className:"text-sm font-semibold mb-3",style:{color:"var(--text-primary)"},children:["✅ Chapter ",J.num," complete!"]}),(0,i.jsxs)("div",{className:"flex gap-3 justify-center",children:[(0,i.jsx)("button",{onClick:()=>C("chapter_select"),className:"btn-secondary",children:"← Chapters"}),J.num<12&&(0,i.jsxs)("button",{onClick:()=>{let e=T.find(e=>e.num===J.num+1);e&&eT(e)},className:"btn-primary flex items-center gap-1.5",children:["Chapter ",J.num+1," ",(0,i.jsx)(h,{className:"w-4 h-4"})]})]})]})]}),"all_done"===w&&(0,i.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,i.jsxs)(r.E.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"text-center max-w-md",children:[(0,i.jsx)("div",{className:"text-6xl mb-4",children:"\uD83C\uDFC6"}),(0,i.jsx)("h2",{className:"text-2xl font-bold mb-2",style:{color:"var(--text-primary)"},children:"All 12 Chapters Complete!"}),(0,i.jsx)("p",{className:"text-sm mb-6",style:{color:"var(--text-secondary)"},children:"Time to generate the book."}),(0,i.jsx)("button",{onClick:eM,disabled:$,className:"btn-primary text-base px-8 py-3",children:$?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.Z,{size:"sm"})," Generating..."]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.Z,{className:"w-5 h-5 inline mr-2"})," Generate Full Book"]})})]})})]})]}),(0,i.jsx)(D,{isOpen:en,voiceState:ei,transcript:el,interimTranscript:eo,audioLevel:eu,recentMessages:eO.slice(-8),onClose:()=>{var e;null===(e=ep.current)||void 0===e||e.stop(),eN.current=!1,er(!1),ea("idle"),ec(""),ed(""),eC()},onTap:eD,clientName:u.name})]})}},4691:function(e,t,s){s.d(t,{Z:function(){return a}});var i=s(7437);function a(e){let{size:t="md"}=e;return(0,i.jsx)("div",{className:"".concat({sm:"w-4 h-4",md:"w-6 h-6",lg:"w-10 h-10"}[t]," border-2 rounded-full animate-spin"),style:{borderColor:"rgba(99,102,241,0.2)",borderTopColor:"#6366f1"}})}},3395:function(e,t,s){s.d(t,{Z:function(){return a}});var i=s(7437);function a(e){let{value:t,className:s=""}=e,a=Math.min(Math.max(t,0),100);return(0,i.jsx)("div",{className:"progress-bar ".concat(s),role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,children:(0,i.jsx)("div",{className:"progress-fill",style:{width:"".concat(a,"%")}})})}},1671:function(e,t,s){s.d(t,{ZT:function(){return n},bG:function(){return a},tz:function(){return r}});var i=s(7437);function a(){return(0,i.jsxs)("div",{className:"card p-5 flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"skeleton w-11 h-11 rounded-xl"}),(0,i.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,i.jsx)("div",{className:"skeleton h-4 w-32 rounded"}),(0,i.jsx)("div",{className:"skeleton h-3 w-24 rounded"})]}),(0,i.jsx)("div",{className:"skeleton h-5 w-16 rounded-full"})]}),(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsx)("div",{className:"skeleton h-3 w-20 rounded"}),(0,i.jsx)("div",{className:"skeleton h-3 w-16 rounded"})]}),(0,i.jsx)("div",{className:"skeleton h-1.5 w-full rounded-full"})]}),(0,i.jsx)("div",{className:"skeleton h-3 w-28 rounded"}),(0,i.jsx)("div",{className:"skeleton h-8 w-full rounded-xl"})]})}function n(){return(0,i.jsxs)("div",{className:"card p-5 flex items-center gap-4",children:[(0,i.jsx)("div",{className:"skeleton w-12 h-12 rounded-xl"}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("div",{className:"skeleton h-6 w-16 rounded"}),(0,i.jsx)("div",{className:"skeleton h-3 w-24 rounded"})]})]})}function r(e){let{isUser:t=!1}=e;return(0,i.jsxs)("div",{className:"flex ".concat(t?"justify-end":"justify-start"," gap-2"),children:[!t&&(0,i.jsx)("div",{className:"skeleton w-7 h-7 rounded-full flex-shrink-0"}),(0,i.jsx)("div",{className:"skeleton rounded-2xl ".concat(t?"w-48 h-12":"w-64 h-16")})]})}},3248:function(e,t,s){function i(e){return e>=1e3?"".concat((e/1e3).toFixed(1),"k"):e.toString()}function a(e){var t;return null!==(t=({baseball:"⚾",football:"\uD83C\uDFC8",basketball:"\uD83C\uDFC0",cricket:"\uD83C\uDFCF",boxing:"\uD83E\uDD4A",athletics:"\uD83C\uDFC3",tennis:"\uD83C\uDFBE",soccer:"⚽"})[e])&&void 0!==t?t:"\uD83C\uDFC5"}function n(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return"".concat(t,"m ago");let s=Math.floor(t/60);return s<24?"".concat(s,"h ago"):"".concat(Math.floor(s/24),"d ago")}s.d(t,{CJ:function(){return i},pi:function(){return n},w2:function(){return a}})},8013:function(e,t,s){s.d(t,{I8:function(){return n},T6:function(){return l},co:function(){return o},s9:function(){return c},yj:function(){return r}});let i=()=>localStorage.getItem("muse_token");async function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=i(),a={"Content-Type":"application/json",...t.headers};s&&(a.Authorization="Bearer ".concat(s));let n=await fetch("".concat("https://api.wailmehmood.com").concat(e),{...t,headers:a}),r=await n.json();if(!n.ok)throw Error(r.error||"Request failed: ".concat(n.status));return r}let n={register:e=>a("/api/auth/register",{method:"POST",body:JSON.stringify(e)}),login:e=>a("/api/auth/login",{method:"POST",body:JSON.stringify(e)}),verify:()=>a("/api/auth/verify"),logout:()=>a("/api/auth/logout",{method:"POST"})},r={create:e=>a("/api/clients",{method:"POST",body:JSON.stringify(e)}),list:e=>{let t=e?"?"+new URLSearchParams(e).toString():"";return a("/api/clients".concat(t))},get:e=>a("/api/clients/".concat(e)),update:(e,t)=>a("/api/clients/".concat(e),{method:"PUT",body:JSON.stringify(t)}),delete:e=>a("/api/clients/".concat(e),{method:"DELETE"}),getByLink:e=>a("/api/interview/link/".concat(e)),reset:e=>a("/api/clients/".concat(e,"/reset"),{method:"POST"}),regenerateLink:e=>a("/api/clients/".concat(e,"/regenerate-link"),{method:"POST"}),getStats:e=>a("/api/clients/".concat(e,"/stats"))},l={getState:e=>a("/api/interview/state/".concat(e)),startChapter:e=>a("/api/interview/chapter/start",{method:"POST",body:JSON.stringify(e)}),sendMessage:e=>a("/api/interview/message",{method:"POST",body:JSON.stringify(e)}),completeChapter:e=>a("/api/interview/chapter/complete",{method:"POST",body:JSON.stringify(e)}),getInsights:e=>{let t=localStorage.getItem("muse_token");return fetch("".concat("https://api.wailmehmood.com","/api/interview/insights/").concat(e),{headers:{Authorization:"Bearer ".concat(t)}}).then(e=>e.json())}},c={generate:e=>a("/api/book/generate",{method:"POST",body:JSON.stringify({clientId:e})}),get:e=>a("/api/book/".concat(e)),save:(e,t)=>a("/api/book/".concat(e),{method:"PUT",body:JSON.stringify({bookDraft:t})}),export:(e,t)=>a("/api/book/export",{method:"POST",body:JSON.stringify({clientId:e,format:t})}),regenerateChapter:(e,t)=>a("/api/book/regenerate-chapter",{method:"POST",body:JSON.stringify({clientId:e,chapterNum:t})}),preview:(e,t)=>a("/api/interview/preview",{method:"POST",body:JSON.stringify({clientId:e,chapterNum:t})})},o={get:()=>a("/api/analytics")}}}]);