(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[409],{3523:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});/**
 * @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 a=(0,n(2898).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},7216:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});/**
 * @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 a=(0,n(2898).Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]])},9670:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});/**
 * @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 a=(0,n(2898).Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},4280:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});/**
 * @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 a=(0,n(2898).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},6641:function(e,t,n){Promise.resolve().then(n.bind(n,9588))},9588:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return Z}});var a=n(7437),r=n(2265),s=n(4033),o=n(2167),l=n(5251),i=n(3067),c=n(9865),d=n(3008),m=n(7216),p=n(9670),h=n(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 u=(0,h.Z)("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),x=(0,h.Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);var f=n(3523),y=n(4280);/**
 * @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 g=(0,h.Z)("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",key:"ymcmye"}]]),b=(0,h.Z)("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);var v=n(7393),j=n(5925),w=n(4691);function k(e){return e.replace(/^#### (.+)$/gm,"<h4>$1</h4>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/^---$/gm,"<hr>").replace(/\n\n/g,"</p><p>").replace(/^(?!<[h|h])/gm,"").split("\n").map(e=>e.startsWith("<")?e:"<p>".concat(e,"</p>")).join("\n")}function N(e,t){let n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}var C=n(3248),S=n(8013);let D=[{label:"PDF",value:"pdf",icon:"\uD83D\uDCC4"},{label:"Word Doc",value:"doc",icon:"\uD83D\uDCDD"},{label:"Markdown",value:"md",icon:"⬇️"},{label:"Plain Text",value:"txt",icon:"\uD83D\uDCC3"}],T={1:"#6366f1",2:"#a855f7",3:"#f59e0b",4:"#10b981"};function O(e){let{bookDraft:t,client:n,clientId:s,onBack:h}=e,[O,Z]=(0,r.useState)(t),[z,E]=(0,r.useState)(!1),[M,F]=(0,r.useState)(0),[L,R]=(0,r.useState)(!1),[B,$]=(0,r.useState)(""),[J,U]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[I,A]=(0,r.useState)(!1),[G,H]=(0,r.useState)(!1),W=(0,r.useRef)(null),Y=(0,r.useMemo)(()=>{let e=O.split("\n"),t=[],a=null,r=1;for(let n of e)if(/^## PART (\d)/.test(n)){let e=n.match(/^## PART (\d)/);e&&(r=parseInt(e[1]))}else if(/^### Chapter (\d+):/.test(n)){a&&t.push({title:a.title,content:a.lines.join("\n").trim(),num:a.num,part:a.part});let e=n.match(/^### Chapter (\d+): (.+)/);a={title:e?e[2]:n.replace(/^###\s*/,""),lines:[],num:e?parseInt(e[1]):t.length+1,part:r}}else/^### /.test(n)&&!a?a={title:n.replace(/^###\s*/,""),lines:[],num:t.length+1,part:r}:a&&a.lines.push(n);return a&&a.lines.length>0&&t.push({title:a.title,content:a.lines.join("\n").trim(),num:a.num,part:a.part}),t.length>0?t:[{title:n.bookTitle,content:O,num:1,part:1}]},[O,n.bookTitle]),V=Y[M],K=e=>{$(e),q(!1),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>Q(e),3e3)},Q=(0,r.useCallback)(async e=>{if(!V)return;let t=O.replace(V.content,e);try{await S.s9.save(s,t),Z(t),q(!0),setTimeout(()=>q(!1),3e3)}catch(e){}},[O,s,V]),X=async()=>{if(!V)return;U(!0);let e=O.replace(V.content,B);try{await S.s9.save(s,e),Z(e),R(!1),j.default.success("Chapter saved!")}catch(e){j.default.error("Failed to save")}finally{U(!1)}},ee=async()=>{if(V){A(!0);try{let e=await S.s9.regenerateChapter(s,V.num),t=O.replace(V.content,e.content);await S.s9.save(s,t),Z(t),R(!1),j.default.success("Chapter regenerated from your interview!")}catch(e){j.default.error(e.message||"Failed to regenerate")}finally{A(!1)}}},et=e=>{E(!1);try{switch(e){case"pdf":!function(e,t,n){let a=window.open("","_blank");if(!a)return;let r='<!DOCTYPE html>\n<html>\n<head>\n  <meta charset="UTF-8">\n  <title>'.concat(t,"</title>\n  <style>\n    @import url('https://fonts.googleapis.com/css2?family=Georgia&family=Inter:wght@400;600;700&display=swap');\n    * { margin: 0; padding: 0; box-sizing: border-box; }\n    body { font-family: Georgia, serif; font-size: 12pt; line-height: 1.8; color: #1a1a1a; }\n    .cover { display: flex; flex-direction: column; align-items: center; justify-content: center;\n      height: 100vh; background: linear-gradient(135deg, #6366f1, #a855f7); color: white;\n      text-align: center; page-break-after: always; }\n    .cover h1 { font-size: 36pt; font-weight: 700; margin-bottom: 16px; }\n    .cover h2 { font-size: 18pt; font-weight: 400; opacity: 0.9; }\n    .content { max-width: 680px; margin: 0 auto; padding: 60px 40px; }\n    h1 { font-size: 28pt; margin: 40px 0 16px; color: #4f46e5; page-break-before: always; }\n    h2 { font-size: 20pt; margin: 32px 0 12px; color: #6366f1; }\n    h3 { font-size: 14pt; margin: 24px 0 8px; color: #374151; }\n    p { margin-bottom: 14px; text-align: justify; }\n    hr { border: none; border-top: 1px solid #e5e7eb; margin: 32px 0; }\n    @page { margin: 2.5cm; }\n    @media print { .cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }\n  </style>\n</head>\n<body>\n  <div class=\"cover\">\n    <h1>").concat(t,"</h1>\n    <h2>By ").concat(n,'</h2>\n  </div>\n  <div class="content">\n    ').concat(k(e),"\n  </div>\n  <script>window.onload = () => { window.print(); }</script>\n</body>\n</html>");a.document.write(r),a.document.close()}(O,n.bookTitle,n.name);break;case"doc":!function(e,t,n){let a='<!DOCTYPE html>\n<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word">\n<head>\n  <meta charset="UTF-8">\n  <title>'.concat(t,"</title>\n  <style>\n    body { font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 1.8; }\n    h1 { font-size: 24pt; color: #4f46e5; page-break-before: always; }\n    h2 { font-size: 18pt; color: #6366f1; }\n    h3 { font-size: 14pt; }\n    p { margin-bottom: 12px; }\n    .cover { text-align: center; margin-bottom: 60px; }\n    .cover h1 { font-size: 32pt; color: #4f46e5; }\n  </style>\n</head>\n<body>\n  <div class=\"cover\"><h1>").concat(t,"</h1><p>By ").concat(n,"</p></div>\n  ").concat(k(e),"\n</body>\n</html>");N(new Blob([a],{type:"application/msword"}),"".concat(t.replace(/\s+/g,"_"),".doc"))}(O,n.bookTitle,n.name);break;case"md":!function(e,t,n){let a="# ".concat(t,"\n\n**By ").concat(n,"**\n\n---\n\n").concat(e);N(new Blob([a],{type:"text/markdown"}),"".concat(t.replace(/\s+/g,"_"),".md"))}(O,n.bookTitle,n.name);break;case"txt":!function(e,t,n){let a=e.replace(/#{1,6}\s/g,"").replace(/\*\*(.+?)\*\*/g,"$1").replace(/\*(.+?)\*/g,"$1").replace(/---/g,"─".repeat(60)),r="".concat("═".repeat(60),"\n").concat(t.toUpperCase(),"\nBy ").concat(n,"\n").concat("═".repeat(60),"\n\n").concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:80;return e.split("\n").map(e=>{var n,a;return e.length<=t?e:null!==(a=null===(n=e.match(RegExp(".{1,".concat(t,"}(\\s|$)"),"g")))||void 0===n?void 0:n.join("\n"))&&void 0!==a?a:e}).join("\n")}(a));N(new Blob([r],{type:"text/plain"}),"".concat(t.replace(/\s+/g,"_"),".txt"))}(O,n.bookTitle,n.name)}j.default.success("Exporting as ".concat(e.toUpperCase(),"..."))}catch(e){j.default.error("Export failed")}},en=O.split(/\s+/).filter(Boolean).length,ea=T[(null==V?void 0:V.part)||1];return(0,a.jsxs)("div",{className:"h-screen flex flex-col",style:{background:"var(--bg-secondary)"},children:[(0,a.jsxs)("header",{className:"flex-shrink-0 border-b px-4 py-3 flex items-center gap-3",style:{background:"var(--bg-card)",borderColor:"var(--border)"},children:[(0,a.jsx)("button",{onClick:h,className:"btn-ghost p-2 rounded-lg","aria-label":"Go back",children:(0,a.jsx)(i.Z,{className:"w-4 h-4"})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,a.jsx)(c.Z,{className:"w-4 h-4 flex-shrink-0",style:{color:"#6366f1"}}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"font-bold text-sm truncate block",style:{color:"var(--text-primary)"},children:n.bookTitle}),(0,a.jsxs)("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[Y.length," chapters \xb7 ",en.toLocaleString()," words"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(o.M,{children:_&&(0,a.jsxs)(l.E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-xs text-green-500 flex items-center gap-1",children:[(0,a.jsx)(d.Z,{className:"w-3 h-3"})," Saved"]})}),(0,a.jsxs)("button",{onClick:()=>H(!G),className:"btn-ghost flex items-center gap-1.5 text-xs py-2",children:[G?(0,a.jsx)(m.Z,{className:"w-3.5 h-3.5"}):(0,a.jsx)(p.Z,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:G?"Chapter view":"Full book"})]}),(0,a.jsx)("button",{onClick:()=>navigator.clipboard.writeText(window.location.href).then(()=>j.default.success("Link copied!")),className:"btn-secondary flex items-center gap-1.5 text-xs py-2",children:(0,a.jsx)(u,{className:"w-3.5 h-3.5"})}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{onClick:()=>E(!z),className:"btn-primary flex items-center gap-1.5 text-xs py-2",children:[(0,a.jsx)(x,{className:"w-3.5 h-3.5"})," Export",(0,a.jsx)(f.Z,{className:"w-3 h-3 transition-transform ".concat(z?"rotate-180":"")})]}),z&&(0,a.jsx)("div",{className:"absolute right-0 top-full mt-1 w-40 rounded-xl shadow-xl border overflow-hidden z-50",style:{background:"var(--bg-card)",borderColor:"var(--border)"},children:D.map(e=>(0,a.jsxs)("button",{onClick:()=>et(e.value),className:"w-full px-4 py-2.5 text-left text-xs flex items-center gap-2 transition-colors hover:bg-indigo-50 dark:hover:bg-indigo-900/20",style:{color:"var(--text-primary)"},children:[(0,a.jsx)("span",{children:e.icon}),e.label]},e.value))})]})]})]}),(0,a.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[!G&&(0,a.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,a.jsxs)("div",{className:"m-3 rounded-xl p-4 text-white text-center",style:{background:"linear-gradient(135deg, #6366f1, #a855f7)"},children:[(0,a.jsx)("div",{className:"text-3xl mb-2",children:(0,C.w2)(n.sport)}),(0,a.jsx)("p",{className:"font-bold text-xs leading-tight",children:n.bookTitle}),(0,a.jsxs)("p",{className:"text-xs opacity-75 mt-1",children:["By ",n.name]}),(0,a.jsxs)("div",{className:"mt-2 text-xs opacity-60",children:[en.toLocaleString()," words"]})]}),(0,a.jsxs)("div",{className:"px-3 pb-3",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-secondary)"},children:"Contents"}),Y.map((e,t)=>(0,a.jsxs)("button",{onClick:()=>{F(t),R(!1)},className:"w-full text-left px-2.5 py-2 rounded-lg mb-0.5 flex items-center gap-2 transition-all text-xs",style:M===t?{background:"".concat(T[e.part],"15"),color:T[e.part],fontWeight:600}:{color:"var(--text-secondary)"},children:[(0,a.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs flex-shrink-0 font-bold",style:{background:M===t?"".concat(T[e.part],"20"):"var(--bg-secondary)",color:T[e.part]},children:e.num}),(0,a.jsx)("span",{className:"truncate",children:e.title})]},t))]})]}),(0,a.jsx)("main",{className:"flex-1 overflow-y-auto",children:G?(0,a.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-8",children:(0,a.jsx)("div",{className:"card p-8",children:(0,a.jsx)(v.UG,{components:P,children:O})})}):(0,a.jsx)("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-6",children:V&&(0,a.jsxs)(l.E.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-xs font-bold",style:{color:ea},children:["Chapter ",V.num," of ",Y.length]}),(0,a.jsx)("h2",{className:"text-xl font-bold mt-0.5",style:{color:"var(--text-primary)"},children:V.title})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[!L&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{onClick:ee,disabled:I,className:"btn-ghost flex items-center gap-1.5 text-xs py-2",title:"Regenerate from interview",children:[I?(0,a.jsx)(w.Z,{size:"sm"}):(0,a.jsx)(y.Z,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Regenerate"})]}),(0,a.jsxs)("button",{onClick:()=>{$((null==V?void 0:V.content)||""),R(!0)},className:"btn-secondary flex items-center gap-1.5 text-xs py-2",children:[(0,a.jsx)(g,{className:"w-3.5 h-3.5"})," Edit"]})]}),L&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>R(!1),className:"btn-ghost text-xs py-2",children:"Cancel"}),(0,a.jsxs)("button",{onClick:X,disabled:J,className:"btn-primary flex items-center gap-1.5 text-xs py-2",children:[J?(0,a.jsx)(w.Z,{size:"sm"}):(0,a.jsx)(b,{className:"w-3.5 h-3.5"}),"Save"]})]})]})]}),(0,a.jsx)("div",{className:"card p-6 sm:p-8",children:L?(0,a.jsx)("textarea",{value:B,onChange:e=>K(e.target.value),className:"w-full text-sm leading-relaxed outline-none resize-none",style:{minHeight:"500px",background:"transparent",color:"var(--text-primary)",fontFamily:"Georgia, serif",lineHeight:"1.9"}}):(0,a.jsx)("div",{className:"prose prose-lg max-w-none",children:(0,a.jsx)(v.UG,{components:P,children:V.content})})}),(0,a.jsxs)("div",{className:"flex justify-between mt-4",children:[(0,a.jsx)("button",{onClick:()=>{F(Math.max(0,M-1)),R(!1)},disabled:0===M,className:"btn-secondary disabled:opacity-40 text-sm",children:"← Previous"}),(0,a.jsxs)("span",{className:"text-xs self-center",style:{color:"var(--text-secondary)"},children:[M+1," / ",Y.length]}),(0,a.jsx)("button",{onClick:()=>{F(Math.min(Y.length-1,M+1)),R(!1)},disabled:M===Y.length-1,className:"btn-secondary disabled:opacity-40 text-sm",children:"Next →"})]})]},M)})})]})]})}let P={h1:e=>{let{children:t}=e;return(0,a.jsx)("h1",{className:"text-3xl font-bold mb-3 gradient-text",children:t})},h2:e=>{let{children:t}=e;return(0,a.jsx)("h2",{className:"text-xl font-bold mt-10 mb-3 pt-6 border-t",style:{borderColor:"var(--border)",color:"#6366f1"},children:t})},h3:e=>{let{children:t}=e;return(0,a.jsx)("h3",{className:"text-lg font-bold mt-8 mb-3",style:{color:"var(--text-primary)"},children:t})},p:e=>{let{children:t}=e;return(0,a.jsx)("p",{className:"mb-5 leading-relaxed",style:{color:"var(--text-primary)",fontFamily:"Georgia, serif",fontSize:"1.05rem",lineHeight:"1.9"},children:t})},blockquote:e=>{let{children:t}=e;return(0,a.jsx)("blockquote",{className:"border-l-4 pl-4 my-4 italic",style:{borderColor:"#6366f1",color:"var(--text-secondary)"},children:t})},hr:()=>(0,a.jsx)("hr",{className:"my-8",style:{borderColor:"var(--border)"}}),em:e=>{let{children:t}=e;return(0,a.jsx)("em",{style:{color:"var(--text-primary)"},children:t})},strong:e=>{let{children:t}=e;return(0,a.jsx)("strong",{style:{color:"var(--text-primary)"},children:t})}};function Z(){let{bookId:e}=(0,s.useParams)(),t=(0,s.useRouter)(),[n,o]=(0,r.useState)(null),[l,i]=(0,r.useState)(!0);return((0,r.useEffect)(()=>{(async()=>{try{if(!localStorage.getItem("muse_token")){t.push("/");return}await S.I8.verify();let n=await S.s9.get(e);o(n)}catch(e){j.default.error(e.message||"Failed to load book"),t.push("/")}finally{i(!1)}})()},[e,t]),l)?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center",style:{background:"var(--bg-primary)"},children:(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)("div",{className:"typing-dot"}),(0,a.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.2s"}}),(0,a.jsx)("div",{className:"typing-dot",style:{animationDelay:"0.4s"}})]})}):n?(0,a.jsx)(O,{bookDraft:n.bookDraft,client:n.client,clientId:e,onBack:()=>window.location.href="/"}):null}},4691:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var a=n(7437);function r(e){let{size:t="md"}=e;return(0,a.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"}})}},3248:function(e,t,n){"use strict";function a(e){return e>=1e3?"".concat((e/1e3).toFixed(1),"k"):e.toString()}function r(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 s(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 n=Math.floor(t/60);return n<24?"".concat(n,"h ago"):"".concat(Math.floor(n/24),"d ago")}n.d(t,{CJ:function(){return a},pi:function(){return s},w2:function(){return r}})},8013:function(e,t,n){"use strict";n.d(t,{I8:function(){return s},T6:function(){return l},co:function(){return c},s9:function(){return i},yj:function(){return o}});let a=()=>localStorage.getItem("muse_token");async function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a(),r={"Content-Type":"application/json",...t.headers};n&&(r.Authorization="Bearer ".concat(n));let s=await fetch("".concat("https://api.wailmehmood.com").concat(e),{...t,headers:r}),o=await s.json();if(!s.ok)throw Error(o.error||"Request failed: ".concat(s.status));return o}let s={register:e=>r("/api/auth/register",{method:"POST",body:JSON.stringify(e)}),login:e=>r("/api/auth/login",{method:"POST",body:JSON.stringify(e)}),verify:()=>r("/api/auth/verify"),logout:()=>r("/api/auth/logout",{method:"POST"})},o={create:e=>r("/api/clients",{method:"POST",body:JSON.stringify(e)}),list:e=>{let t=e?"?"+new URLSearchParams(e).toString():"";return r("/api/clients".concat(t))},get:e=>r("/api/clients/".concat(e)),update:(e,t)=>r("/api/clients/".concat(e),{method:"PUT",body:JSON.stringify(t)}),delete:e=>r("/api/clients/".concat(e),{method:"DELETE"}),getByLink:e=>r("/api/interview/link/".concat(e)),reset:e=>r("/api/clients/".concat(e,"/reset"),{method:"POST"}),regenerateLink:e=>r("/api/clients/".concat(e,"/regenerate-link"),{method:"POST"}),getStats:e=>r("/api/clients/".concat(e,"/stats"))},l={getState:e=>r("/api/interview/state/".concat(e)),startChapter:e=>r("/api/interview/chapter/start",{method:"POST",body:JSON.stringify(e)}),sendMessage:e=>r("/api/interview/message",{method:"POST",body:JSON.stringify(e)}),completeChapter:e=>r("/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())}},i={generate:e=>r("/api/book/generate",{method:"POST",body:JSON.stringify({clientId:e})}),get:e=>r("/api/book/".concat(e)),save:(e,t)=>r("/api/book/".concat(e),{method:"PUT",body:JSON.stringify({bookDraft:t})}),export:(e,t)=>r("/api/book/export",{method:"POST",body:JSON.stringify({clientId:e,format:t})}),regenerateChapter:(e,t)=>r("/api/book/regenerate-chapter",{method:"POST",body:JSON.stringify({clientId:e,chapterNum:t})}),preview:(e,t)=>r("/api/interview/preview",{method:"POST",body:JSON.stringify({clientId:e,chapterNum:t})})},c={get:()=>r("/api/analytics")}}},function(e){e.O(0,[114,666,971,938,744],function(){return e(e.s=6641)}),_N_E=e.O()}]);