PageSourceSearch

https://sabhia.ai/assets/book-hub-DcnlqgjJ.js

js sabhia.ai collected 2026-10-05 12:32:29 UTC 107,913 bytes, 1 lines download raw bytes

1import{j as e,A as ot,m as L}from"./vendor-motion-CPxq9Xvn.js";import{a3 as le,ai as it,av as nt,Y as je,K as Je,X as oe,a7 as B,A as ee,C as we,aw as Ie,S as W,ax as St,a2 as lt,u as q,P as Re,ap as xe,ac as Pt,ay as Ht,G as Ye,Z as $t,a as ie,B as At,az as Et,a1 as Lt,am as Tt,aA as It,a6 as qe,ar as ve,I as Ze,e as qt,z as dt,E as ct,aB as Gt,aC as mt,h as ut,aD as _t,l as Ae,f as Ge,U as et,J as Ee,T as tt,aE as Dt,aF as ne,an as _e,aG as Rt,aa as Ot,k as Bt}from"./index-CFAvyuXu.js";import{r as g,u as Oe}from"./vendor-i18n-CO3kK2bH.js";import{U as De}from"./upload-BKNIN1AN.js";import{F as z}from"./file-text-DjkUcFVd.js";import{E as xt}from"./eye-BcGCsLne.js";import{R as pt}from"./rotate-ccw-yv6DhBa4.js";import{S as zt,F as Kt,P as Ft}from"./publication-pipeline-DFwPsRBR.js";import"./pix-qr-image-D45mJvPS.js";import{P as Mt,a as Ut,B as Wt}from"./pricing-CEwbcjb3.js";import{u as Vt}from"./useFeatureFlags-C-5VjyV0.js";import{L as Qt,G as Xt}from"./generation-services-showcase-9mGH4LZB.js";import{C as Jt}from"./checkout-dialog-CtPFKUrs.js";import{d as Le}from"./editorialDownload-CShCKB7l.js";import{A as Yt}from"./arrow-left-DY50GvQQ.js";import{T as Be}from"./trophy-Bk4C1tet.js";import{G as ht}from"./globe-D0MKCb1Y.js";import{M as ze}from"./megaphone-CJoAWoYP.js";import{B as at}from"./book-marked-3-KNVwiq.js";import{H as Zt}from"./heart-CzKl5jvQ.js";import{F as ea}from"./flame-BHmbROUi.js";import{M as ta}from"./mail-B6oT_qrq.js";import{T as aa}from"./trash-2-BF2rPJAw.js";import{D as bt}from"./download-B7FtiUYJ.js";import"./vendor-react-CQmBMThG.js";import"./alert-dialog-C9feqA9b.js";import"./stamp-BZO_gJDT.js";import"./select-B26x0xAv.js";import"./index-BdQq_4o_.js";import"./barcode-DlYH0ciP.js";import"./pen-line-CUCmRVJi.js";import"./circle-pause-B5v17gJf.js";import"./feather-BNvr0Xjc.js";import"./list-checks-EUoF5j-U.js";import"./wand-sparkles-BFRdHggN.js";import"./badge-B9GAfHbC.js";import"./wifi-BvXiCCFP.js";function sa({open:a,onClose:t,bookId:o,bookTitle:x}){const[r,m]=g.useState("upload"),[i,p]=g.useState(""),[d,H]=g.useState(null),[h,y]=g.useState({}),[A,w]=g.useState(!0),[f,k]=g.useState(null),[K,C]=g.useState(0),[S,j]=g.useState(0),[F,J]=g.useState([]),[te,Y]=g.useState({}),V=g.useRef(null),E=g.useRef(!1),[ae,u]=g.useState(!1),{toast:_}=le(),l=it(),D=g.useCallback(()=>{m("upload"),p(""),H(null),y({}),k(null),C(0),j(0),J([]),Y({}),w(!0),V.current&&(V.current.value="")},[]),Q=g.useCallback(()=>{r==="analyzing"||r==="applying"||(D(),t())},[r,D,t]),G=g.useCallback(async n=>{if(!n.name.toLowerCase().endsWith(".docx")){p("Apenas arquivos .docx são aceitos. Salve seu documento como Word (.docx) e tente novamente."),m("error");return}if(n.size>50*1024*1024){p("Arquivo maior que 50 MB. Reduza imagens ou divida o documento."),m("error");return}m("analyzing"),p("");try{const b=new FormData;b.append("file",n);const $=await fetch(`/api/books/${o}/docx-reupload/preview`,{method:"POST",body:b,credentials:"include"}),R=await $.json();if(!$.ok)throw new Error(R?.message||"Erro ao analisar o DOCX");H(R);const Z={};for(const ke of R.matches)Z[ke.existingChapterId]=!0;y(Z),m("preview")}catch(b){p(b?.message||"Falha ao analisar o arquivo"),m("error")}},[o]),v=n=>{const b=n.target.files?.[0];b&&G(b)},X=n=>{n.preventDefault(),n.stopPropagation(),E.current=!1,u(!1);const b=n.dataTransfer.files?.[0];b&&G(b)},pe=async()=>{if(!d)return;const n=d.matches.filter(b=>h[b.existingChapterId]).map(b=>({chapterId:b.existingChapterId,newContent:b.sourceContent,newTitle:A&&b.titleChanged?b.sourceTitle:void 0,images:b.sourceImages&&b.sourceImages.length>0?b.sourceImages:void 0}));if(n.length===0){_({title:"Nenhum capítulo selecionado",description:"Marque pelo menos um capítulo para atualizar.",variant:"destructive"});return}m("applying");try{const b=await fetch(`/api/books/${o}/docx-reupload/apply`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({updates:n})}),$=await b.json();if(!b.ok)throw new Error($?.message||"Erro ao aplicar as alterações");k($.snapshotId||null),C(n.length),j(typeof $.imagesAdded=="number"?$.imagesAdded:0),J(Array.isArray($.skippedForSafety)?$.skippedForSafety:[]),m("success"),l.invali
1dateQueries({queryKey:[`/api/books/${o}`]}),l.invalidateQueries({queryKey:[`/api/books/${o}/chapters`]}),l.invalidateQueries({queryKey:[`/api/books/${o}/hub-summary`]}),l.invalidateQueries({queryKey:["/api/books"]})}catch(b){p(b?.message||"Falha ao aplicar mudanças"),m("error")}},Ne=async()=>{if(f&&confirm("Restaurar a versão anterior? Isso desfará as alterações que você acabou de aplicar.")){m("applying");try{const n=await fetch(`/api/books/${o}/docx-reupload/restore/${f}`,{method:"POST",credentials:"include"}),b=await n.json();if(!n.ok)throw new Error(b?.message||"Erro ao restaurar");_({title:"Versão restaurada",description:"Seu livro voltou ao estado anterior ao envio."}),l.invalidateQueries({queryKey:[`/api/books/${o}`]}),l.invalidateQueries({queryKey:[`/api/books/${o}/chapters`]}),l.invalidateQueries({queryKey:[`/api/books/${o}/hub-summary`]}),l.invalidateQueries({queryKey:["/api/books"]}),Q()}catch(n){p(n?.message||"Falha ao restaurar"),m("error")}}},se=Object.values(h).filter(Boolean).length,ye=d?.matches.length||0,he=n=>n<20?"text-emerald-400 bg-emerald-500/10 border-emerald-500/30":n<50?"text-amber-400 bg-amber-500/10 border-amber-500/30":"text-rose-400 bg-rose-500/10 border-rose-500/30";return a?nt.createPortal(e.jsx(ot,{children:e.jsx(L.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[10000] bg-black/70 backdrop-blur-sm flex items-center justify-center p-4",onClick:Q,"data-testid":"modal-docx-reupload",children:e.jsxs(L.div,{initial:{opacity:0,scale:.96,y:12},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:12},transition:{duration:.22,ease:"easeOut"},className:"relative w-full max-w-3xl max-h-[88vh] overflow-hidden rounded-2xl bg-[#13132b] border border-white/15 shadow-2xl flex flex-col",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/10 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/15 border border-primary/30 flex items-center justify-center flex-shrink-0",children:e.jsx(De,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-bold text-white truncate",children:"Enviar versão editada"}),e.jsx("p",{className:"text-xs text-white/50 truncate",children:x})]})]}),e.jsx("button",{onClick:Q,disabled:r==="analyzing"||r==="applying",className:"w-9 h-9 rounded-lg bg-white/5 hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center transition-colors","data-testid":"btn-close-modal",children:e.jsx(je,{className:"w-4 h-4 text-white/70"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:[r==="upload"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-xl bg-blue-500/10 border border-blue-500/20 p-4 flex gap-3",children:[e.jsx(Je,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-100/90",children:[e.jsx("p",{className:"font-semibold mb-1 text-blue-200",children:"Como funciona"}),e.jsxs("ol",{className:"list-decimal pl-4 space-y-1 text-blue-100/80",children:[e.jsx("li",{children:"Envie o DOCX que você editou no Word."}),e.jsx("li",{children:"Mostraremos uma pré-visualização com tudo que vai mudar."}),e.jsx("li",{children:"Você confirma o que aplicar — uma cópia da versão atual é salva automaticamente."})]})]})]}),e.jsxs("div",{onDragOver:n=>{n.preventDefault(),E.current||(E.current=!0,u(!0))},onDragLeave:n=>{n.preventDefault(),E.current=!1,u(!1)},onDrop:X,onClick:()=>V.current?.click(),className:`relative cursor-pointer rounded-2xl border-2 border-dashed transition-all p-10 text-center ${ae?"border-primary bg-primary/10":"border-white/15 bg-white/[0.02] hover:bg-white/[0.04] hover:border-white/25"}`,"data-testid":"dropzone-docx",children:[e.jsx("input",{ref:V,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",onChange:v,className:"hidden","data-testid":"input-docx-file"}),e.jsx(z,{className:"w-12 h-12 text-primary/70 mx-auto mb-3"}),e.jsx("p",{className:"text-base font-semibold text-white mb-1",children:"Arraste o arquivo .docx aqui"}),e.jsx("p",{className:"text-sm text-white/50 mb-4",children:"ou clique para selecionar"}),e.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-black font-semibold text-sm",children:[e.jsx(De,{className:"w-4 h-4"})," Escolher arquivo"]}),e.jsx("p",{className:"text-xs text-white/40 mt-4",children:"Tamanho máximo: 50 MB"})]}),e.jsxs("div",{className:"rounded-xl bg-amber-500/10 border border-amber-500/20 p-4 flex gap-3",children:[e.jsx(oe,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-100/90",children:[e.jsx("p",{className:"font-semibold mb-1 text-amber-200",children:"Boas práticas"}),e.jsxs("ul",{className:"list-disc pl-4 space-y-1 text-amber-100/80",children:[e.jsxs("li",{children:["Mantenha os títulos dos capítulos formatados como ",e.jsx("strong",{children:"Título 1 (Heading 1)"})," no Word."]}),e.jsx("li",{children:"Imagens incorporadas no Word são detectadas e adicionadas ao capítulo correspondente, sem custo — imagens que já existem no livro não são duplicadas nem substituídas."}
1),e.jsx("li",{children:"Tabelas complexas serão convertidas em texto simples."})]})]})]})]}),r==="analyzing"&&e.jsxs("div",{className:"py-16 flex flex-col items-center justify-center text-center",children:[e.jsx(B,{className:"w-12 h-12 text-primary animate-spin mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-white mb-1",children:"Analisando seu DOCX…"}),e.jsx("p",{className:"text-sm text-white/50",children:"Lendo capítulos e comparando com a versão atual."})]}),r==="applying"&&e.jsxs("div",{className:"py-16 flex flex-col items-center justify-center text-center",children:[e.jsx(B,{className:"w-12 h-12 text-primary animate-spin mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-white mb-1",children:"Aplicando mudanças…"}),e.jsx("p",{className:"text-sm text-white/50",children:"Salvando snapshot e atualizando capítulos."})]}),r==="preview"&&d&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-emerald-500/10 border border-emerald-500/20 p-4 flex gap-3",children:[e.jsx(Je,{className:"w-5 h-5 text-emerald-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-emerald-100/90",children:[e.jsx("p",{className:"font-semibold text-emerald-200 mb-0.5",children:"Snapshot automático ativado"}),e.jsx("p",{className:"text-emerald-100/80",children:"Antes de aplicar, salvamos uma cópia completa da versão atual. Você pode restaurar com 1 clique se algo der errado."})]})]}),d.warnings.length>0&&e.jsxs("div",{className:"rounded-xl bg-amber-500/10 border border-amber-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{className:"w-4 h-4 text-amber-400"}),e.jsx("p",{className:"text-sm font-semibold text-amber-200",children:"Avisos da análise"})]}),e.jsx("ul",{className:"list-disc pl-5 space-y-1 text-sm text-amber-100/80",children:d.warnings.map((n,b)=>e.jsx("li",{children:n},b))})]}),d.unmatchedExisting.length>0&&e.jsxs("div",{className:"rounded-xl bg-rose-500/10 border border-rose-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{className:"w-4 h-4 text-rose-400"}),e.jsxs("p",{className:"text-sm font-semibold text-rose-200",children:[d.unmatchedExisting.length," capítulo(s) da plataforma não foram encontrados no DOCX"]})]}),e.jsxs("p",{className:"text-xs text-rose-100/80 mb-2",children:["Esses capítulos serão ",e.jsx("strong",{children:"mantidos como estão"})," (não vamos apagar nada). Se você os removeu de propósito, edite manualmente depois."]}),e.jsxs("ul",{className:"text-xs text-rose-100/70 space-y-0.5 pl-4",children:[d.unmatchedExisting.slice(0,5).map(n=>e.jsxs("li",{className:"truncate",children:["• Capítulo ",n.orderIndex+1,": ",n.title]},n.id)),d.unmatchedExisting.length>5&&e.jsxs("li",{className:"opacity-60",children:["+ ",d.unmatchedExisting.length-5," outros…"]})]})]}),d.auxiliaryTitles&&d.auxiliaryTitles.length>0&&e.jsxs("div",{className:"rounded-xl bg-blue-500/10 border border-blue-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(z,{className:"w-4 h-4 text-blue-400"}),e.jsx("p",{className:"text-sm font-semibold text-blue-200",children:"Seções especiais encontradas no arquivo"})]}),e.jsxs("p",{className:"text-xs text-blue-100/80 mb-2",children:[d.auxiliaryTitles.join(", ")," — não fazem parte da atualização automática de capítulos. Se você editou algum desses trechos no Word, atualize-o manualmente na página do livro depois."]})]}),d.unmatchedSource.length>0&&e.jsxs("div",{className:"rounded-xl bg-blue-500/10 border border-blue-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(z,{className:"w-4 h-4 text-blue-400"}),e.jsxs("p",{className:"text-sm font-semibold text-blue-200",children:[d.unmatchedSource.length," seção(ões) do DOCX sem correspondência"]})]}),e.jsx("p",{className:"text-xs text-blue-100/80 mb-2",children:"Essas seções não serão importadas (sumário, prefácio, agradecimentos ou capítulos novos não são adicionados automaticamente)."}),e.jsxs("ul",{className:"text-xs text-blue-100/70 space-y-0.5 pl-4",children:[d.unmatchedSource.slice(0,5).map((n,b)=>e.jsxs("li",{className:"truncate",children:["• ",n.title]},b)),d.unmatchedSource.length>5&&e.jsxs("li",{className:"opacity-60",children:["+ ",d.unmatchedSource.length-5," outras…"]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-white",children:["Capítulos a atualizar (",se," de ",ye," selecionados)"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-white/70 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:n=>w(n.target.checked),className:"w-4 h-4 rounded accent-primary","data-testid":"checkbox-update-titles"}),"Atualizar também títulos alterados"]})]}),e.jsx("div",{className:"space-y-2",children:d.matches.map(n=>{const b=!!te[n.existingChapterId],$=!!h[n.existingChapterId];return e.jsxs("div",{className:`rounded-xl border transition-all overflow-hidden ${$?"border-white/20 bg-white/[0.04]":"border-white/10 bg-white/[0.01] opacity-60"}`,"data-testid":`row-chapter-${n.existingChapterId}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:R=>y(Z=>({...Z,[n.existingChapterId]:R.target.checked})),className:"w-5 h-5 rounded accent-primary flex-shrink-0","data-testid":`checkbox-chapter-${n.existingChapterId}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs text-white/40 font-mono",children:["Cap. ",n.existingOrderIndex+1]}),e.jsx("span",{className:"text-sm font-semibold text-white truncate",children:n.existingTitle}),n.titleChanged&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-amber-500/15 border border-amber-500/30 text-amber-300",children:[e.jsx(ee,{className:"w-3 h-3"})," ",n.sourceTitle]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full border ${he(n.changePercent)}`,children:[n.changePercent,"% alterado"]}),e.jsxs("span",{className:"text-xs text-white/40",children:[n.existingContentLength.toLocaleStr
1ing("pt-BR")," → ",n.sourceContentLength.toLocaleString("pt-BR")," caracteres"]})]})]}),e.jsx("button",{onClick:()=>Y(R=>({...R,[n.existingChapterId]:!b})),className:"p-2 rounded-lg hover:bg-white/10 text-white/60 hover:text-white transition-colors flex-shrink-0","data-testid":`btn-preview-chapter-${n.existingChapterId}`,title:"Pré-visualizar",children:e.jsx(xt,{className:"w-4 h-4"})})]}),b&&e.jsxs("div",{className:"px-3 pb-3 border-t border-white/5 pt-3 mt-1",children:[e.jsx("p",{className:"text-xs text-white/40 mb-1.5 font-mono",children:"PRÉVIA DA NOVA VERSÃO"}),e.jsxs("div",{className:"text-xs text-white/70 bg-black/30 rounded-lg p-3 max-h-48 overflow-y-auto whitespace-pre-wrap font-mono leading-relaxed",children:[n.sourceContent.slice(0,1500)||"(vazio)",n.sourceContent.length>1500&&e.jsxs("span",{className:"text-white/30",children:["… (+ ",n.sourceContent.length-1500," caracteres)"]})]})]})]},n.existingChapterId)})})]})]}),r==="success"&&e.jsxs("div",{className:"py-12 flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-500/15 border border-emerald-500/30 flex items-center justify-center mb-4",children:e.jsx(we,{className:"w-8 h-8 text-emerald-400"})}),e.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:"Versão aplicada com sucesso"}),e.jsxs("p",{className:"text-sm text-white/60 mb-6",children:[K-F.length," capítulo(s) atualizado(s)",S>0&&e.jsxs(e.Fragment,{children:[" · ",S," imagem(ns) preservada(s)"]}),". Os créditos não foram consumidos."]}),F.length>0&&e.jsxs("div",{className:"rounded-xl bg-amber-500/10 border border-amber-500/20 p-4 mb-4 max-w-md text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsxs("p",{className:"text-sm font-semibold text-amber-200",children:[F.length," capítulo(s) mantido(s) sem alteração por segurança"]})]}),e.jsx("p",{className:"text-xs text-amber-100/80 mb-2",children:"O novo conteúdo era muito menor que o atual, o que costuma indicar perda acidental de texto — por precaução, não substituímos o conteúdo desses capítulos:"}),e.jsxs("ul",{className:"text-xs text-amber-100/70 space-y-0.5 pl-4",children:[F.slice(0,5).map(n=>e.jsxs("li",{className:"truncate",children:["• ",n.title," (",n.oldLength.toLocaleString("pt-BR")," → ",n.newLength.toLocaleString("pt-BR")," caracteres)"]},n.chapterId)),F.length>5&&e.jsxs("li",{className:"opacity-60",children:["+ ",F.length-5," outro(s)…"]})]}),e.jsx("p",{className:"text-xs text-amber-100/60 mt-2",children:"Se a redução foi intencional, edite o capítulo manualmente na página do livro."})]}),f&&e.jsxs("div",{className:"rounded-xl bg-white/[0.04] border border-white/10 p-4 mb-4 max-w-md",children:[e.jsx("p",{className:"text-xs text-white/50 mb-2",children:"Mudou de ideia? Você pode restaurar a ver
1são anterior ao envio."}),e.jsxs("button",{onClick:Ne,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-white/10 hover:bg-white/15 text-white text-sm font-medium transition-colors","data-testid":"btn-restore-snapshot",children:[e.jsx(pt,{className:"w-4 h-4"})," Restaurar versão anterior"]})]}),e.jsx("button",{onClick:Q,className:"px-5 py-2.5 rounded-lg bg-primary text-black font-semibold text-sm","data-testid":"btn-success-close",children:"Fechar"})]}),r==="error"&&e.jsxs("div",{className:"py-10 flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-rose-500/15 border border-rose-500/30 flex items-center justify-center mb-4",children:e.jsx(oe,{className:"w-8 h-8 text-rose-400"})}),e.jsx("h3",{className:"text-lg font-bold text-white mb-2",children:"Não foi possível processar"}),e.jsx("p",{className:"text-sm text-white/70 mb-6 max-w-md",children:i}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:D,className:"px-4 py-2 rounded-lg bg-white/10 hover:bg-white/15 text-white text-sm font-medium","data-testid":"btn-error-retry",children:"Tentar novamente"}),e.jsx("button",{onClick:Q,className:"px-4 py-2 rounded-lg bg-white/5 hover:bg-white/10 text-white/70 text-sm font-medium","data-testid":"btn-error-close",children:"Fechar"})]})]})]}),r==="preview"&&d&&e.jsxs("div",{className:"px-6 py-4 border-t border-white/10 flex-shrink-0 flex items-center justify-between gap-3 bg-[#0e0e22]",children:[e.jsx("button",{onClick:D,className:"px-4 py-2 rounded-lg bg-white/5 hover:bg-white/10 text-white/70 text-sm font-medium","data-testid":"btn-preview-cancel",children:"Enviar outro arquivo"}),e.jsxs("button",{onClick:pe,disabled:se===0,className:"px-5 py-2.5 rounded-lg bg-primary text-black font-bold text-sm flex items-center gap-2 hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed transition-opacity","data-testid":"btn-apply-changes",children:["Aplicar em ",se," capítulo(s) ",e.jsx(ee,{className:"w-4 h-4"})]})]})]},"docx-reupload-card")},"docx-reupload-backdrop")}),document.body):null}const Te=[{id:"paid",label:"Pagamento confirmado",icon:we},{id:"queue",label:"Na fila de produção",hint:"Aguardando a IA começar",icon:Ie},{id:"writing",label:"Escrevendo capítulos",icon:z},{id:"extras",label:"Revisão final & extras",hint:"Prefácio, agradecimentos, bibliografia",icon:W},{id:"ready",label:"Pronto pra baixar",icon:St}];function ra(a,t,o){const x=!!a.isPaid,r=(a.status||"").toLowerCase(),m=o>0&&t>=o,i={paid:"pending",queue:"pending",writing:"pending",extras:"pending",ready:"pending"};return x?(i.paid="done",r==="paid"||r==="planning"&&x?(i.queue="current",i):(i.queue="done",r==="needs_review"&&!m?(i.writing="current",i):m||r==="completed"||r==="ready"||r==="writing"||r==="needs_review"?(i.writing="done",r==="completed"||r==="ready"?(i.extras="done",i.ready="current"):i.extras="current",i):r==="generating"?(i.writing="current",i):(i.queue="current",i))):(i.paid="current",i)}function oa({book:a,chaptersWritten:t,totalChapters:o}){const x=ra(a,t,o),r=x.writing==="current"&&o>0?`Escrevendo capítulos (${t}/${o})`:"Escrevendo capítulos",m=x.ready!=="current"&&(x.queue==="current"||x.writing==="current"||x.extras==="current");return e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-gradient-to-br from-slate-900/40 to-slate-900/10 backdrop-blur-sm p-4 md:p-5","data-testid":"book-status-timeline",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-white/60",children:"Acompanhe seu livro"}),x.ready==="current"&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded-full bg-emerald-500/15 text-emerald-300 border border-emerald-400/30",children:"Concluído"})]}),e.jsx("div",{className:"hidden md:flex items-start gap-2",children:Te.map((i,p)=>{const d=x[i.id],H=i.id==="writing"?r:i.label,h=d==="current"?i.id==="writing"||i.id==="extras"?B:i.icon:d==="done"?we:Ie;return e.jsxs("div",{className:"flex-1 flex flex-col items-center text-center",children:[e.jsxs("div",{className:"w-full flex items-center",children:[e.jsx("div",{className:`flex-1 h-0.5 ${p===0?"opacity-0":d!=="pending"?"bg-emerald-400/50":"bg-white/10"}`}),e.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center shrink-0 transition-all ${d==="done"?"bg-emerald-500/20 border border-emerald-400/50 text-emerald-300":d==="current"?"bg-blue-500/20 border border-blue-400/60 text-blue-200 shadow-[0_0_18px_rgba(59,130,246,0.35)]":"bg-white/5 border border-white/10 text-white/40"}`,"data-testid":`timeline-step-${i.id}-${d}`,children:e.jsx(h,{className:`w-4 h-4 ${d==="current"&&(i.id==="writing"||i.id==="extras")?"animate-spin":""}`})}),e.jsx("div",{className:`flex-1 h-0.5 ${p===Te.length-1?"opacity-0":d==="done"?"bg-emerald-400/50":"bg-white/10"}`})]}),e.jsxs("div",{className:"mt-2 px-1",children:[e.jsx("div",{className:`text-xs font-medium leading-tight ${d==="current"?"text-white":d==="done"?"text-emerald-200/80":"text-white/50"}`,children:H}),d==="current"&&i.hint&&e.jsx("div",{className:"text-[10px] text-white/40 mt-0.5 leading-tight",children:i.hint})]})]},i.id)})}),e.jsx("div",{className:"md:hidden flex flex-col gap-2",children:Te.map(i=>{const p=x[i.id],d=i.id==="writing"?r:i.label,H=p==="current"?i.id==="writing"||i.id==="extras"?B:i.icon:p==="done"?we:Ie;return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${p==="current"?"bg-blue-500/10 border border-blue-400/30":"bg-white/[0.02]"}`,"data-testid":`timeline-step-mobile-${i.id}-${p}`,children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center shrink-0 ${p==="done"?"bg-emerald-500/20 text-emerald-300":p==="current"?"bg-blue-500/30 text-blue-200":"bg-white/5 text-white/40"}`,children:e.jsx(H,{className:`w-3.5 h-3.5 ${p==="current"&&(i.id==="writing"||i.id==="extras")?"animate-spin":""}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm font-medium ${p==="current"?"text-white":p==="done"?"text-emerald-200/80":"text-white/50"}`,children:d}),p==="current"&&i.hint&&e.jsx("div",{className:"text-[10px] text-white/50 mt-0.5",children:i.hint})]})]},i.id)})}),m&&e.jsxs("div",{className:"mt-4 flex items-start gap-2.5 rounded-xl border border-blue-400/20 bg-blue-500/[0.07] px-3.5 py-3","data-testid":"book-status-reassurance",children:[e.jsx(W,{className:"w-4 h-4 text-blue-300 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs leading-relaxed text-white/70",children:["A escrita com qual
1idade leva tempo — em geral"," ",e.jsx("span",{className:"font-semibold text-white/90",children:"de 1 a 2 horas"}),". Pode fechar esta página tranquilamente: ",e.jsx("span",{className:"font-semibold text-white/90",children:"avisamos você por e-mail"})," ","assim que o livro ficar pronto. 📩"]})]})]})}const st=a=>`sb_cover_upsell_dismissed_${a}`;function ia(){return!1}function na({book:a,publishOriented:t=!1}){const{toast:o}=le(),{user:x}=lt(),r=x?.market==="es",m=r?(x?.country||"").toUpperCase()==="ES"?"ES":"US":"BR",i=it(),[p,d]=g.useState(!1),[H,h]=g.useState(()=>{try{return sessionStorage.getItem(st(a.id))==="1"}catch{return!1}}),{data:y,isLoading:A}=q({queryKey:[`/api/books/${a.id}/next-upsell`],staleTime:1e4}),w=!!y?.pipeline?.find(S=>S.step==="cover")?.purchased;if(H||A||w)return null;const f=Mt.cover,k={title:"Capa Profissional",price:f,subtitle:"Pronta em minutos",description:"Capa exclusiva criada por IA a partir do conteúdo do seu livro — você recebe variações para escolher a sua favorita.",features:["4 variações exclusivas pra você escolher","Alta resolução, pronta pra KDP, Amazon e e-book","Título e nome do autor já no design","Ajustes inclusos se quiser refinar"]},K=()=>{try{sessionStorage.setItem(st(a.id),"1")}catch{}h(!0)},C=()=>{i.invalidateQueries({queryKey:[`/api/books/${a.id}/hub-summary`]}),i.invalidateQueries({queryKey:[`/api/books/${a.id}`]}),o({title:"Pagamento confirmado!",description:"Sua capa profissional já está sendo criada. Em alguns minutos ela aparece aqui."}),d(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(L.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"relative rounded-2xl border border-purple-400/30 bg-gradient-to-br from-purple-500/[0.12] via-pink-500/[0.06] to-transparent p-5 md:p-6 overflow-hidden shadow-lg shadow-purple-500/10","data-testid":"card-cover-upsell",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_left,_rgba(192,132,252,0.16)_0%,_transparent_60%)] opacity-80 pointer-events-none"}),e.jsx("div",{className:"absolute -top-px left-6 right-6 h-px bg-gradient-to-r from-transparent via-purple-400/50 to-transparent"}),e.jsx("button",{onClick:K,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/5 hover:bg-white/10 text-muted-foreground hover:text-white flex items-center justify-center transition-colors z-20","aria-label":"Agora não","data-testid":"button-cover-upsell-dismiss",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-purple-500/30 to-pink-600/20 ring-1 ring-purple-400/40 flex items-center justify-center flex-shrink-0 shadow-md shadow-purple-500/25",children:e.jsx(Re,{className:"w-7 h-7 text-purple-200",strokeWidth:2.2})}),e.jsxs("div",{className:"flex-1 min-w-0 pr-6",children:[e.jsxs("p",{className:"text-xs font-bold text-purple-300 uppercase tracking-[0.12em] mb-1 flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5"}),t?"Seu livro pode começar a vender":"Dê a cara certa pro seu livro"]}),e.jsx("h3",{className:"text-xl md:text-2xl font-heading font-bold text-white leading-tight",children:t?"Faça a capa e publique seu livro para começar a vender":"Seu livro está pronto — falta a capa profissional"}),e.jsx("p",{className:"text-sm md:text-base text-white/75 mt-1.5 leading-snug",children:t?"Só falta a capa: com ela pronta, você publica na Loja Sábhia quando quiser — a decisão é sempre sua.":"A capa é a primeira coisa que o leitor vê. Crie a sua agora, exclusiva e pronta pra publicar."})]})]}),e.jsx("ul",{className:"grid sm:grid-cols-2 gap-x-5 gap-y-1.5 mt-4",children:k.features?.map(S=>e.jsxs("li",{className:"flex items-center gap-2 text-sm text-white/80",children:[e.jsx(xe,{className:"w-4 h-4 text-purple-300 flex-shrink-0",strokeWidth:2.5}),S]},S))}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mt-5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-2xl md:text-3xl font-heading font-bold text-white",children:Pt(Math.round(f*100),m)}),!r&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-emerald-300 bg-emerald-500/10 border border-emerald-400/30 rounded-full px-2 py-0.5",children:[e.jsx(Ht,{className:"w-3 h-3"}),"PIX na hora"]})]}),e.jsxs("button",{onClick:()=>d(!0),className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-gradient-to-r from-purple-500 to-pink-600 hover:from-purple-400 hover:to-pink-500 text-white font-bold text-sm md:text-base transition-all duration-300 shadow-lg shadow-purple-500/40 hover:shadow-
1purple-500/60 hover:-translate-y-0.5","data-testid":"button-cover-upsell-buy",children:["Criar minha capa agora",e.jsx(ee,{className:"w-5 h-5",strokeWidth:2.5})]})]})]})]}),e.jsx(Jt,{open:p,onOpenChange:d,product:k,orderType:"cover_ebook",bookId:a.id,bookTitle:a.title,onConfirm:C})]})}function la(){const{t:a}=Oe("pages"),[t,o]=g.useState(()=>{try{return sessionStorage.getItem("referral_banner_dismissed")==="true"}catch{return!1}}),{data:x}=q({queryKey:["/api/referrals/me"]});return t?null:e.jsxs(L.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.5,type:"spring"},className:"relative overflow-hidden rounded-2xl border border-amber-500/30","data-testid":"banner-referral-reward",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-amber-900/40 via-yellow-900/30 to-amber-900/40"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_var(--tw-gradient-stops))] from-amber-400/10 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-0 left-0 w-full h-[1px] bg-gradient-to-r from-transparent via-amber-400/60 to-transparent"}),e.jsx("div",{className:"absolute -top-24 -right-24 w-48 h-48 rounded-full bg-amber-500/5 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-24 -left-24 w-48 h-48 rounded-full bg-yellow-500/5 blur-3xl"}),e.jsxs("div",{className:"relative p-4 md:p-5",children:[e.jsx("button",{onClick:()=>{o(!0);try{sessionStorage.setItem("referral_banner_dismissed","true")}catch{}},className:"absolute top-2.5 right-2.5 text-amber-400/40 hover:text-amber-300 transition-colors z-10","data-testid":"button-dismiss-referral-banner",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(L.div,{animate:{rotate:[0,-10,10,-5,0]},transition:{repeat:1/0,duration:3,repeatDelay:4},className:"w-11 h-11 md:w-12 md:h-12 rounded-xl bg-gradient-to-br from-amber-400/20 to-yellow-600/20 flex items-center justify-center ring-2 ring-amber-500/30 shrink-0",children:e.jsx(Ye,{className:"w-5 h-5 md:w-6 md:h-6 text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("h3",{className:"text-sm md:text-base font-black text-white",children:a("referralBanner.title")}),e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-amber-500/15 border border-amber-500/20 text-amber-400 text-[9px] font-bold uppercase",children:[e.jsx($t,{className:"w-2.5 h-2.5"})," ",a("referralBanner.unlimited")]})]}),e.jsx("p",{className:"text-xs text-amber-100/50 leading-relaxed line-clamp-2",children:a("referralBanner.desc")})]}),e.jsx(ie,{href:"/indicar",className:"shrink-0",children:e.jsxs(At,{size:"sm",className:"h-9 px-4 rounded-lg bg-gradient-to-r from-amber-500 to-yellow-500 hover:from-amber-400 hover:to-yellow-400 text-black font-bold text-xs shadow-md shadow-amber-500/20 gap-1","data-testid":"button-go-referral",children:[e.jsx(Ye,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:a("referralBanner.cta")}),e.jsx(ee,{className:"w-3.5 h-3.5"})]})})]})]})]})}function da({book:a,summary:t}){const{data:o}=q({queryKey:[`/api/books/${a.id}/chapters`],enabled:!!a.id,staleTime:3e4,refetchInterval:t.textStatus==="generating"?3e4:!1}),r=(Array.isArray(a.plannedChapters)?a.plannedChapters:[]).length||o?.length||0,m=(o||[]).filter(i=>i?.content&&String(i.content).length>200).length;return e.jsx(oa,{book:a,chaptersWritten:m,totalChapters:r})}function ca({kit:a,t}){const{toast:o}=le(),x=async()=>{if(a.publicUrl)try{await navigator.clipboard.writeText(a.publicUrl),o({title:t("bookHub.apiceKit.copied","Link público copiado")})}catch{o({title:t("bookHub.apiceKit.copyError","Não foi possível copiar o link"),variant:"destructive"})}};return e.jsxs("section",{className:"rounded-2xl border border-amber-400/30 bg-gradient-to-br from-amber-500/[0.10] via-orange-500/[0.04] to-transparent p-5 md:p-6","data-testid":"card-apice-commercial-kit",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-start md:justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-5 h-5 text-amber-300 shrink-0"}),e.jsx("h2",{className:"text-lg md:text-xl font-bold text-white",children:t("bookHub.apiceKit.title","Seu kit comercial ÁPICE")})]}),e.jsx("p",{className:"mt-1 text-sm text-white/65",children:a.state==="ready"?t("bookHub.apiceKit.ready","Acesse e compartilhe a entrega a qualquer momento — ela não depende do e-mail."):t("bookHub.apiceKit.preparing","Seu kit está sendo preparado. Os acessos aparecem aqui assim que a publicação ficar pública.")})]}),e.jsx("span",{className:`self-start rounded-full border px-2.5 py-1 text-xs font-semibold ${a.state==="ready"?"border-emerald-400/30 bg-emerald-500/10 text-emerald-300":"border-amber-400/30 bg-amber-500/10 text-amber-200"}`,children:a.state==="ready"?t("bookHub.apiceKit.available","Disponível"):t("bookHub.apiceKit.inProgress","Em preparação")})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[a.publicUrl?e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("a",{href:a.publicUrl,target:"_blank",rel:"noopener noreferrer",className:"flex-1 inline-flex min-h-11 items-center justify-center rounded-lg bg-amber-500 px-3 text-sm font-semibold text-white hover:bg-amber-600","data-testid":"link-apice-public-page",children:[e.jsx(Rt,{className:"w-4 h-4 mr-1.5"})," ",t("bookHub.apiceKit.openPage","Página pública")]}),e.jsx("button",{type:"button",onClick:x,"aria-label":t("bookHub.apiceKit.copy","Copiar link público"),className:"min-h-11 min-w-11 inline-flex items-center justify-center rounded-lg border border-amber-400/30 text-amber-200 hover:bg-amber-500/10","data-testid":"button-copy-apice-public-url",children:e.jsx(Ot,{className:"w-4 h-4"})})]}):e.jsx("button",{disabled:!0,className:"min-h-11 rounded-lg border border-white/10 bg-white/5 px-3 text-sm text-white/40",children:t("bookHub.apiceKit.pageWaiting","Página aguardando publicação")}),a.readerUrl?e.jsxs("a",{href:a.readerUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-h-11 items-center justify-center rounded-lg border border-white/15 px-3 text-sm font-semibold text-white hover:bg-white/10","data-testid":"link-apice-author-reading",children:[e.jsx(Ge,{className:"w-4 h-4 mr-1.5"})," ",t("bookHub.apiceKit.read","Ler meu livro")]}):e.jsxs("button",{disabled:!0,className:"min-h-11 rounded-lg border border-white/10 bg-white/5 px-3 text-sm text-white/40",title:a.readerState==="unavailable"?t("bookHub.apiceKit.readerUnavailableHelp","O acesso não pôde ser confirmado. Tente novamente mais tarde."):void 0,children:[e.jsx(Ge,{className:"inline w-4 h-4 mr-1.5"})," ",a.readerState==="unavailable"?t("bookHub.apiceKit.readerUnavailable","Leitura indisponível"):t("bookHub.apiceKit.readerWaiting","Leitura em preparação")]}),e.jsxs(ie,{href:a.manageUrl,className:"inline-flex min-h-11 w-full items-center justify-center rounded-lg border border-white/15 px-3 text-sm font-semibold text-white hover:bg-white/10","data-testid":"link-apice-manage",children:[e.jsx(mt,{className:"w-4 h-4 mr-1.5"})," ",t("bookHub.apiceKit.manage","Gerenciar na loja")]})]}),e.jsxs("details",{className:"mt-4 rounded-xl border border-white/10 bg-black/15 px-4 py-3","data-testid":"details-apice-guide",children:[e.jsxs("summary",{className:"cursor-pointer list-none flex items-center justify-between gap-2 text-sm font-semibold text-amber-200",children:[a.guide.title,e.jsx(Bt,{className:"w-4 h-4"})]}),e.jsxs("div",{className:"pt-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-white/50",children:a.guide.disclaimer}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:a.guide.sections.map((r,m)=>e.jsxs("div",{className:"rounded-lg bg-white/[0.04] p-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-white",children:[m+1,". ",r.title]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-white/60",children:r.body})]},`${r.title}-${m}`))})]})]})]})}function ma(a,t){switch(a){case"completed":return{label:t("bookHub.status.textCompleted","Texto completo"),color:"text-emerald-400"};case"generating":return{label:t("bookHub.status.textGenerating","Gerando..."),color:"text-amber-400"};case"paid":return{label:t("bookHub.status.textPaid","Pago — aguardando geração"),color:"text-blue-400"};case"planned":return{label:t("bookHub.status.textPlanned","Plano pronto"),color:"text-blue-400"};default:return{label:t("bookHub.status.textDraft","Rascunho"),color:"text-muted-foreground"}}}function ua(a,t){switch(a){case"published":return{label:t("bookHub.status.published","Publicado"),color:"text-emerald-400"};case"ready":return{label:t("bookHub.status.metaReady","Metadados prontos"),color:"text-blue-400"};case"started":return{label:t("bookHub.status.inPrep","Em preparação"),color:"text-amber-400"};default:return{label:t("bookHub.status.notStarted","Não iniciado"),color:"text-muted-foreground"}}}function xa(a,t){switch(a){case"completed":return{label:t("bookHub.status.audioReady","Audiobook pronto"),color:"text-emerald-400"};case"generating":return{label:t("bookHub.status.audioGenerating","Gerando narração..."),color:"text-amber-400"};case"preview_ready":return{label:t("bookHub.status.previewReady","Preview gerado"),color:"text-blue-400"};case"failed":return{label:t("bookHub.status.audioFailed","Falhou — tentar novamente"),color:"text-red-400"};default:return{label:t("bookHub.status.noAudiobook","Nenhum audiobook"),color:"text-muted-foreground"}}}function pa(a,t){return a.textStatus!=="completed"&&a.textStatus!=="generating"?{title:t("bookHub.nextStep.write.title","Escreva seu livro"),description:t("bookHub.nextStep.write.desc","Continue escrevendo o conteúdo do seu livro"),href:o=>`/book/${o}/editor`,icon:z}:a.coversCount===0?{title:t("bookHub.nextStep.cover.title","Crie sua capa"),description:t("bookHub.nextStep.cover.desc","Gere uma capa profissional exclusiva"),href:o=>`/capas/${o}`,icon:Re}:a.illustrationsCount===0?{title:t("bookHub.nextStep.illustrations.title","Adicione ilustrações"),description:t("bookHub.nextStep.illustrations.desc","Ilustre os capítulos do seu livro com arte exclusiva"),href:o=>`/ilustrar/${o}`,icon:dt}:a.publishingStatus==="none"?{title:t("bookHub.nextStep.publication.title","Prepare sua publicação"),description:t("bookHub.nextStep.publication.desc","Textos, metadados e arquivos prontos para você publicar"),href:o=>`/publicar/${o}`,icon:ht}:a.marketingCount===0?{title:t("bookHub.nextStep.marketing.title","Pegue seus materiais de divulgação"),description:t("bookHub.nextStep.marketing.desc","Posts prontos, e-mails e banners — só copiar e postar"),href:o=>`/marketing/${o}`,icon:ze}:a.launchPlanReady?!a.audiobookStatus||a.audiobookStatus==="none"?{title:t("bookHub.nextStep.audiobook.title","Crie seu audiobook"),description:t("bookHub.nextStep.audiobook.desc","Transforme seu livro em audiobook em voz natural"),href:o=>`/audiobook/${o}`,icon:ct}:a.translationsCount===0?{title:t("bookHub.nextStep.translation.title","Traduza seu livro"),description:t("bookHub.nextStep.translation.desc","Alcance leitores em outros idiomas"),href:o=>`/tradutor/${o}`,icon:ut}:null:{title:t("bookHub.nextStep.launchPlan.title","Planeje o lançamento do seu livro"),description:t("bookHub.nextStep.launchPlan.desc","Estratégia best-seller dia-a-dia: D-30 até o dia 0, com posts, KDP, imprensa e influenciad
1ores"),href:o=>`/livro/${o}/lancamento`,icon:Be}}function ha(a,t){switch(a){case"text":return t.textStatus==="completed";case"covers":return t.coversCount>0;case"illustrations":return t.illustrationsCount>0;case"publication":return t.publishingStatus!=="none";case"marketing":return t.marketingCount>0;case"launch_plan":return!!t.launchPlanReady;case"translation":return t.translationsCount>0;case"audiobook":return t.audiobookStatus==="completed";case"isbn":return!!t.isbnReady;case"barcode":return!!t.barcodeReady;default:return!1}}function ba(a,t){switch(a){case"text":return t.textStatus==="generating"||t.textStatus==="paid"||t.textStatus==="planned";case"publication":return t.publishingStatus==="started";case"marketing":return!!t.marketingPending;case"audiobook":return t.audiobookStatus==="generating";default:return!1}}function ga(a,t,o){switch(a){case"covers":return t.coverImageUrl||o.coverImage||null;case"illustrations":return t.sampleIllustrationUrl;case"marketing":return t.sampleMarketingUrl;default:return null}}function fa(a,t){switch(a){case"text":return{cta:t("bookHub.motivation.text.cta","Começar a escrever"),motivation:t("bookHub.motivation.text.text","Seu livro está esperando para nascer!")};case"covers":return{cta:t("bookHub.motivation.covers.cta","Criar minha capa"),motivation:t("bookHub.motivation.covers.text","Uma capa profissional atrai mais leitores!")};case"illustrations":return{cta:t("bookHub.motivation.illustrations.cta","Ilustrar capítulos"),motivation:t("bookHub.motivation.illustrations.text","Ilustrações dão vida à sua história!")};case"publication":return{cta:t("bookHub.motivation.publication.cta","Preparar publicação"),motivation:t("bookHub.motivation.publication.text","Prepare tudo para publicar seu livro!")};case"marketing":return{cta:t("bookHub.motivation.marketing.cta","Pegar meus materiais"),motivation:t("bookHub.motivation.marketing.text","Posts prontos pra Instagram, e-mails e banners — só copiar e postar.")};case"launch_plan":return{cta:t("bookHub.motivation.launchPlan.cta","Planejar meu lançamento"),motivation:t("bookHub.motivation.launchPlan.text","Plano dia-a-dia D-30 → D-0: posts, Amazon KDP, imprensa, influenciadores da sua cidade.")};case"translation":return{cta:t("bookHub.motivation.translation.cta","Traduzir agora"),motivation:t("bookHub.motivation.translation.text","Leitores do mundo inteiro podem ler seu livro!")};case"audiobook":return{cta:t("bookHub.motivation.audiobook.cta","Criar audiobook"),motivation:t("bookHub.motivation.audiobook.text","Alcance leitores que preferem ouvir histórias!")};default:return{cta:t("bookHub.motivation.default.cta","Começar"),motivation:t("bookHub.motivation.default.text","Complete esta etapa!")}}}const rt={text:{solid:"from-blue-500 to-cyan-500",iconGrad:"from-blue-500/30 to-cyan-500/30",hoverGlow:"hover:shadow-blue-500/30",ctaGlow:"shadow-blue-500/40",ring:"hover:border-blue-400/50"},covers:{solid:"from-purple-500 to-pink-500",iconGrad:"from-purple-500/30 to-pink-500/30",hoverGlow:"hover:shadow-purple-500/30",ctaGlow:"shadow-purple-500/40",ring:"hover:border-purple-400/50"},illustrations:{solid:"from-amber-500 to-orange-500",iconGrad:"from-amber-500/30 to-orange-500/30",hoverGlow:"hover:shadow-amber-500/30",ctaGlow:"shadow-amber-500/40",ring:"hover:border-amber-400/50"},publication:{solid:"from-emerald-500 to-teal-500",iconGrad:"from-emerald-500/30 to-teal-500/30",hoverGlow:"hover:shadow-emerald-500/30",ctaGlow:"shadow-emerald-500/40",ring:"hover:border-emerald-400/50"},marketing:{solid:"from-rose-500 to-red-500",iconGrad:"from-rose-500/30 to-red-500/30",hoverGlow:"hover:shadow-rose-500/30",ctaGlow:"shadow-rose-500/40",ring:"hover:border-rose-400/50"},launch_plan:{solid:"from-yellow-500 to-amber-500",iconGrad:"from-yellow-500/30 to-amber-500/30",hoverGlow:"hover:shadow-yellow-500/30",ctaGlow:"shadow-yellow-500/40",ring:"hover:border-yellow-400/50"},audiobook:{solid:"from-cyan-500 to-sky-500",iconGrad:"from-cyan-500/30 to-sky-500/30",hoverGlow:"hover:shadow-cyan-500/30",ctaGlow:"shadow-cyan-500/40",ring:"hover:border-cyan-400/50"},store:{solid:"from-emerald-500 to-green-500",iconGrad:"from-emerald-500/30 to-green-500/30",hoverGlow:"hover:shadow-emerald-500/30",ctaGlow:"shadow-emerald-500/40",ring:"hover:border-emerald-400/50"},translation:{solid:"from-indigo-500 to-violet-500",iconGrad:"from-indigo-500/30 to-violet-500/30",hoverGlow:"hover:shadow-indigo-500/30",ctaGlow:"shadow-indigo-500/40",ring:"hover:border-indigo-400/50"},isbn:{solid:"from-amber-500 to-yellow-500",iconGrad:"from-amber-500/30 to-yellow-500/30",hoverGlow:"hover:shadow-amber-500/30",ctaGlow:"shadow-amber-500/40",ring:"hover:border-amber-400/50"},ficha:{solid:"from-indigo-500 to-violet-500",iconGrad:"from-indigo-500/30 to-violet-500/30",hoverGlow:"hover:shadow-indigo-500/30",ctaGlow:"shadow-indigo-500/40",ring:"hover:border-indigo-400/50"},direitoAutoral:{solid:"from-violet-500 to-purple-500",iconGrad:"from-violet-500/30 to-purple-500/30",hoverGlow:"hover:shadow-violet-500/30",ctaGlow:"shadow-violet-500/40",ring:"hover:border-violet-400/50"},booktrailers:{solid:"from-violet-500 to-indigo-500",iconGrad:"from-violet-500/30 to-indigo-500/30",hoverGlow:"hover:shadow-violet-500/30",ctaGlow:"shadow-violet-500/40",ring:"hover:border-violet-400/50"},barcode:{solid:"from-blue-700 to-blue-900",iconGrad:"from-blue-700/30 to-blue-900/30",hoverGlow:"hover:shadow-blue-700/30",ctaGlow:"shadow-blue-700/40",ring:"hover:border-blue-600/50"}},va=[{id:"text",icon:z,title:"Texto",description:"Escreva e edite o conteúdo do seu livro",actionLabel:"Abrir Editor",getHref:a=>`/book/${a}/editor`,getStatus:(a,t)=>ma(a.textStatus,t),gradient:"from-blue-500/20 to-cyan-500/20",iconColor:"text-blue-400",iconBg:"bg-blue-500/10",completedGlow:"shadow-blue-500/20"}
1,{id:"covers",icon:Re,title:"Capas",description:"Crie capas profissionais exclusivas",actionLabel:"Criar Capa",getHref:a=>`/capas/${a}`,getStatus:(a,t)=>({label:a.coversCount>0?`${a.coversCount} ${a.coversCount===1?t("bookHub.status.coverOne","capa gerada"):t("bookHub.status.coverMany","capas geradas")}`:t("bookHub.status.coverNone","Nenhuma capa"),color:a.coversCount>0?"text-emerald-400":"text-muted-foreground"}),gradient:"from-purple-500/20 to-pink-500/20",iconColor:"text-purple-400",iconBg:"bg-purple-500/10",completedGlow:"shadow-purple-500/20"},{id:"illustrations",icon:dt,title:"Ilustrações",description:"Ilustre seus capítulos com arte exclusiva",actionLabel:"Ilustrar",getHref:a=>`/ilustrar/${a}`,getStatus:(a,t)=>({label:a.illustrationsCount>0?`${a.illustrationsCount} ${a.illustrationsCount===1?t("bookHub.status.illustrationOne","ilustração"):t("bookHub.status.illustrationMany","ilustrações")}`:t("bookHub.status.illustrationNone","Nenhuma ilustração"),color:a.illustrationsCount>0?"text-emerald-400":"text-muted-foreground"}),gradient:"from-amber-500/20 to-orange-500/20",iconColor:"text-amber-400",iconBg:"bg-amber-500/10",completedGlow:"shadow-amber-500/20"},{id:"publication",icon:ht,title:"Publicação",description:"Textos, metadados e arquivos para publicar",actionLabel:"Preparar",getHref:a=>`/publicar/${a}`,getStatus:(a,t)=>ua(a.publishingStatus,t),gradient:"from-emerald-500/20 to-teal-500/20",iconColor:"text-emerald-400",iconBg:"bg-emerald-500/10",completedGlow:"shadow-emerald-500/20"},{id:"marketing",icon:ze,title:"Kit de Marketing",description:"Posts prontos pra Instagram, e-mails e banners",actionLabel:"Pegar meu kit",getHref:a=>`/marketing/${a}`,getStatus:(a,t)=>a.marketingCount>0?{label:`${a.marketingCount} ${a.marketingCount===1?t("bookHub.status.marketingOne","material criado"):t("bookHub.status.marketingMany","materiais criados")}`,color:"text-emerald-400"}:a.marketingPending?{label:t("bookHub.status.marketingPending","Gerando seu kit..."),color:"text-amber-400"}:{label:t("bookHub.status.marketingNone","Nenhum material"),color:"text-muted-foreground"},gradient:"from-rose-500/20 to-red-500/20",iconColor:"text-rose-400",iconBg:"bg-rose-500/10",completedGlow:"shadow-rose-500/20"},{id:"launch_plan",icon:Be,title:"Plano de Lançamento",description:"Estratégia best-seller dia-a-dia: D-30 → lançamento",actionLabel:"Planejar meu lançamento",getHref:a=>`/livro/${a}/lancamento`,getStatus:(a,t)=>({label:a.launchPlanReady?t("bookHub.status.launchPlanReady","Plano de 31 dias pronto"):t("bookHub.status.notStarted","Não iniciado"),color:a.launchPlanReady?"text-emerald-400":"text-muted-foreground"}),gradient:"from-yellow-500/20 to-amber-500/20",iconColor:"text-amber-400",iconBg:"bg-amber-500/10",completedGlow:"shadow-amber-500/20"},{id:"audiobook",icon:ct,title:"Audiobook",description:"Narração profissional do seu livro",actionLabel:"Audiolivro Profissional",getHref:a=>`/audiobook/${a}`,getStatus:(a,t)=>xa(a.audiobookStatus,t),gradient:"from-cyan-500/20 to-sky-500/20",iconColor:"text-cyan-400",iconBg:"bg-cyan-500/10",completedGlow:"shadow-cyan-500/20"},{id:"booktrailers",icon:Gt,title:"Book Trailer",description:"Trailer cinematográfico 9:16 do seu livro gerado por IA",actionLabel:"Criar meu Book Trailer",getHref:a=>`/book-trailers/livro/${a}`,getStatus:(a,t)=>({label:t("bookHub.status.bookTrailersNew","Trailer cinematográfico com IA"),color:"text-violet-300"}),gradient:"from-violet-500/20 to-indigo-500/20",iconColor:"text-violet-400",iconBg:"bg-violet-500/10",completedGlow:"shadow-violet-500/20",isNew:!0},{id:"store",icon:mt,title:"Vender",description:"Coloque seu livro à venda na Loja Sábhia",actionLabel:"Vender meu Livro",getHref:a=>"#store-modal",getStatus:(a,t)=>({label:t("bookHub.status.notStarted","Não iniciado"),color:"text-muted-foreground"}),gradient:"from-emerald-500/20 to-green-500/20",iconColor:"text-emerald-400",iconBg:"bg-emerald-500/10",completedGlow:"shadow-emerald-500/20"},{id:"translation",icon:ut,title:"Tradução",description:"Traduza para outros idiomas",actionLabel:"Traduzir",getHref:a=>`/tradutor/${a}`,getStatus:(a,t)=>({label:a.translationsCount>0?`${a.translationsCount} ${a.translationsCount===1?t("bookHub.status.translationOne","tradução"):t("bookHub.status.translationMany","traduções")}`:t("bookHub.status.translationNone","Nenhuma tradução"),color:a.translationsCount>0?"text-emerald-400":"text-muted-foreground"}),gradient:"from-indigo-500/20 to-violet-500/20",iconColor:"text-indigo-400",iconBg:"bg-indigo-500/10",completedGlow:"shadow-indigo-500/20"},{id:"isbn",icon:at,title:"Registro de ISBN",description:"Registro oficial feito por agente literário especializado",actionLabel:"Contratar Registro",getHref:a=>`/isbn/${a}`,getStatus:(a,t)=>a.isbnReady?{label:t("bookHub.status.isbnRegistered","ISBN registrado"),color:"text-emerald-400"}:{label:t("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-amber-300"}
1,gradient:"from-amber-500/20 to-yellow-500/20",iconColor:"text-amber-400",iconBg:"bg-amber-500/10",completedGlow:"shadow-amber-500/20"},{id:"ficha",icon:_t,title:"Ficha Catalográfica",description:"Documento oficial assinado pela bibliotecária CRB da Sábhia",actionLabel:"Fazer Ficha",getHref:a=>`/ficha/${a}`,getStatus:(a,t)=>({label:t("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-indigo-300"}),gradient:"from-indigo-500/20 to-violet-500/20",iconColor:"text-indigo-400",iconBg:"bg-indigo-500/10",completedGlow:"shadow-indigo-500/20"},{id:"direitoAutoral",icon:zt,title:"Registro de Direito Autoral",description:"Proteção legal da obra junto à Biblioteca Nacional (FBN/EDA)",actionLabel:"Registrar Autoria",getHref:a=>`/direito-autoral/${a}`,getStatus:(a,t)=>({label:t("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-violet-300"}),gradient:"from-violet-500/20 to-purple-500/20",iconColor:"text-violet-400",iconBg:"bg-violet-500/10",completedGlow:"shadow-violet-500/20"},{id:"barcode",icon:at,title:"Código de Barras ISBN",description:"EAN-13 em alta resolução para contracapa — entrega imediata",actionLabel:"Gerar Código de Barras",getHref:a=>`/codigo-barras/${a}`,getStatus:(a,t)=>a.barcodeReady?{label:t("bookHub.status.barcodeDelivered","Código de barras entregue"),color:"text-emerald-400"}:{label:t("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-blue-300"},gradient:"from-blue-700/20 to-blue-900/20",iconColor:"text-blue-400",iconBg:"bg-blue-700/10",completedGlow:"shadow-blue-700/20"}],wa={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.08}}},ja={hidden:{opacity:0,y:20},show:{opacity:1,y:0,transition:{duration:.4,ease:"easeOut"}}};function Na({bookId:a,onUploadClick:t}){const{toast:o}=le(),[x,r]=g.useState(!1),m=g.useRef(null),[i,p]=g.useState({top:0,left:0}),d=g.useCallback(()=>{if(!m.current)return{top:0,left:0};const h=m.current.getBoundingClientRect(),y=180,A=150;let w=h.left,f=h.bottom+6;return w+y>window.innerWidth-8&&(w=window.innerWidth-y-8),w<8&&(w=8),f+A>window.innerHeight-8&&(f=h.top-A-6),f<8&&(f=8),{top:f,left:w}},[]);g.useEffect(()=>{if(!x)return;const h=A=>{m.current?.contains(A.target)||r(!1)},y=()=>r(!1);return document.addEventListener("mousedown",h,!0),document.addEventListener("touchstart",h,!0),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",h,!0),document.removeEventListener("touchstart",h,!0),window.removeEventListener("scroll",y,!0)}},[x]);const H=nt.createPortal(e.jsx(ot,{children:x&&e.jsxs(L.div,{initial:{opacity:0,scale:.95,y:-4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-4},transition:{duration:.15,ease:"easeOut"},className:"fixed z-[9999] min-w-[180px] rounded-xl bg-[#1a1a2e] border border-white/15 shadow-2xl shadow-black/60 overflow-hidden",style:{top:i.top,left:i.left},onMouseDown:h=>h.stopPropagation(),onTouchStart:h=>h.stopPropagation(),children:[e.jsxs("button",{type:"button",onClick:()=>{r(!1),Le(a,"pdf").catch(h=>o({title:"Download indisponível",description:h.message,variant:"destructive"}))},className:"flex items-center gap-3 px-4 py-3 hover:bg-white/10 transition-colors min-h-[44px]","data-testid":"download-pdf",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(z,{className:"w-4 h-4 text-red-400"})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:"PDF"}),e.jsx("span",{className:"text-[10px] text-emerald-300/90 font-medium uppercase tracking-wide",children:"Inclui a capa"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{r(!1),Le(a,"epub").catch(h=>o({title:"Download indisponível",description:h.message,variant:"destructive"}))},className:"flex items-center gap-3 px-4 py-3 hover:bg-white/10 transition-colors border-t border-white/5 min-h-[44px]","data-testid":"download-epub",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-green-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(z,{className:"w-4 h-4 text-green-400"})}),e.jsx("span",{className:"text-sm font-medium text-white",children:"EPUB"})]}),e.jsxs("button",{type:"button",onClick:()=>{r(!1),Le(a,"docx").catch(h=>o({title:"Download indisponível",description:h.message,variant:"destructive"}))},className:"flex items-center gap-3 px-4 py-3 hover:bg-white/10 transition-colors border-t border-white/5 min-h-[44px]","data-testid":"download-docx",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(z,{className:"w-4 h-4 text-blue-400"})}),e.jsx("span",{className:"text-sm font-medium text-white",children:"DOCX"})]}),e.jsxs("button",{onClick:h=>{h.preventDefault(),h.stopPropagation(),r(!1),t?.()},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-white/10 transition-colors border-t border-white/10 min-h-[44px] bg-primary/5","data-testid":"btn-upload-edited-docx",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/20 flex items-center justify-center flex-shrink-0",children:e.jsx(De,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"text-left flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Enviar versão editada"}),e.jsx("div",{className:"text-[10px] text-white/50",children:"Re-upload do DOCX que você editou"})]})]})]},"text-download-menu")}),document.body);return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:m,onClick:h=>{h.preventDefault(),h.stopPropagation(),p(d()),r(y=>!y)},className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-primary/15 hover:bg-primary/25 border border-primary/30 text-primary text-sm font-semibold transition-all hover:scale-105 active:scale-95 min-h-[44px]","data-testid":"btn-download-text",title:"Baixar livro",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Baixar"})]}),H]})}function ya({coverUrl:a,title:t}){return e.jsxs("a",{href:a,download:`${t}-capa.jpg`,target:"_blank",rel:"noopener noreferrer",onClick:o=>o.stopPropagation(),className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-primary/15 hover:bg-primary/25 border border-primary/30 text-primary text-sm font-semibold transition-all hover:scale-105 active:scale-95 min-h-[44px]","data-testid":"btn-download-cover",title:"Baixar capa",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Baixar"})]})}function ka({book:a}){const{toast:t}=le(),[o,x]=g.useState({}),[r,m]=g.useState(!1),[i,p]=g.useState(!1),{data:d,refetch:H}=q({queryKey:[`/api/books/${a.id}/intake`],enabled:!!a.id&&!!a.isPaid,refetchInterval:f=>f.state.data?.state==="awaiting_intake"?6e4:!1});if(d?.state!=="awaiting_intake"||!d.questions?.length)return null;const h=d.questions.filter(f=>(o[f.id]||"").trim().length>0).length,y=()=>{H(),ne.invalidateQueries({queryKey:[`/api/books/${a.id}`]}),ne.invalidateQueries({queryKey:[`/api/books/${a.id}/hub-summary`]})},A=async()=>
1{if(!(r||i)){if(h===0){t({title:"Responda pelo menos uma pergunta",description:'Ou clique em "Pular e criar agora" para começar sem elas.',variant:"destructive"});return}m(!0);try{const k=await(await _e("POST",`/api/books/${a.id}/intake`,{answers:o})).json();t({title:"Respostas recebidas! 🎉",description:k.message||"A criação do seu livro está começando agora."}),y()}catch(f){t({title:"Erro ao enviar",description:f.message||"Tente novamente.",variant:"destructive"})}finally{m(!1)}}},w=async()=>{if(!(r||i)){p(!0);try{const k=await(await _e("POST",`/api/books/${a.id}/intake/skip`)).json();t({title:"Criação iniciada!",description:k.message||"Seu livro está sendo criado agora."}),y()}catch(f){t({title:"Erro",description:f.message||"Tente novamente.",variant:"destructive"})}finally{p(!1)}}};return e.jsx(L.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"rounded-2xl border-2 border-primary/40 bg-primary/10 p-4 md:p-6","data-testid":"banner-intake-gate",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/20 flex items-center justify-center flex-shrink-0",children:e.jsx(W,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-heading font-bold","data-testid":"text-intake-title",children:"Antes de escrever: 4 perguntas rápidas (2 min)"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Suas respostas fazem TODA a diferença na qualidade final. Se preferir, pule — a criação começa sozinha em algumas horas."})]}),e.jsx("div",{className:"space-y-3",children:d.questions.map((f,k)=>e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium block mb-1",children:[k+1,". ",f.question]}),e.jsx("textarea",{value:o[f.id]||"",onChange:K=>x(C=>({...C,[f.id]:K.target.value})),placeholder:f.placeholder||"",rows:2,maxLength:4e3,disabled:r||i,className:"w-full rounded-xl bg-white/5 border border-white/10 px-3 py-2 text-sm placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/50 resize-y","data-testid":`textarea-intake-${f.id}`})]},f.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[e.jsxs("button",{onClick:A,disabled:r||i,className:"px-5 py-2.5 rounded-xl bg-primary text-primary-foreground text-sm font-semibold hover:bg-primary/90 transition-colors disabled:opacity-60 inline-flex items-center gap-2","data-testid":"button-intake-submit",children:[r?e.jsx(B,{className:"w-4 h-4 animate-spin"}):e.jsx(xe,{className:"w-4 h-4"}),"Enviar e criar meu livro"]}),e.jsxs("button",{onClick:w,disabled:r||i,className:"px-4 py-2.5 rounded-xl text-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-60 inline-flex items-center gap-2","data-testid":"button-intake-skip",children:[i?e.jsx(B,{className:"w-4 h-4 animate-spin"}):null,"Pular e criar agora"]})]})]})]})})}const Ca=[/fallback/i,/conting[êe]ncia/i,/\bmodelo\b/i,/\bmodel\b/i,/provedor/i,/provider/i,/\bgpt[- ]?\d/i,/claude/i,/gemini/i,/anthropic/i,/openai/i,/\bllm\b/i,/token(s)?\b/i,/rate[- ]?limit/i,/timeout/i,/retry|retentativa/i];function Sa(a){try{if(typeof a!="string")return null;const t=a.trim();return!t||Ca.some(o=>o.test(t))?null:t}catch{return null}}function Pa({book:a}){const t=a.generationNotice,o=Sa(t),x=o?`book-notice-dismissed:${a.id}:${o}`:null,[r,m]=g.useState(()=>{if(!x)return!1;try{return localStorage.getItem(x)==="1"}catch{return!1}});if(g.useEffect(()=>{if(!x){m(!1);return}try{m(localStorage.getItem(x)==="1")}catch{m(!1)}},[x]),!o||r)return null;const i="Aviso sobre a geração do seu livro",p=()=>{if(x)try{localStorage.setItem(x,"1")}catch{}m(!0)};return e.jsxs(L.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"rounded-2xl border-2 border-amber-400/40 bg-amber-500/10 p-4 md:p-5 relative","data-testid":"banner-generation-notice",children:[e.jsx("button",{onClick:p,className:"absolute top-3 right-3 w-8 h-8 rounded-lg hover:bg-white/10 flex items-center justify-center text-muted-foreground hover:text-white transition-colors","data-testid":"button-dismiss-generation-notice","aria-label":"Dispensar aviso",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx(oe,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("h3",{className:"text-base md:text-lg font-heading font-bold text-amber-100","data-testid":"text-generation-notice-title",children:i}),e.jsx("p",{className:"text-sm text-amber-50/90 leading-relaxed whitespace-pre-line","data-testid":"text-generation-notice-message",children:o})]})]})]})}function Ha({book:a,paidBundle:t,bookStatus:o,summary:x}){const{t:r}=Oe("pages"),m=x.textStatus==="completed",i=t.includesCover&&x.coversCount===0,{toast:p}=le(),d=qe({mutationFn:async()=>(await _e("POST",`/api/books/${a.id}/recover-delivery`)).json(),onSuccess:E=>{if(E?.resumeStarted||E?.alreadyRunning){p({title:E?.alreadyRunning?"Seu livro já está sendo gerado":"Geração liberada",description:E?.alreadyRunning?"A escrita jÃ
1¡ está em andamento. Os capítulos aparecerão aqui conforme forem concluídos.":"Pronto! A escrita foi retomada do ponto seguro, preservando tudo o que já estava concluído."}),ne.invalidateQueries({queryKey:[`/api/books/${a.id}/hub-summary`]}),ne.invalidateQueries({queryKey:[`/api/books/${a.id}`,"light"]});return}const ae=(E?.results||[]).flatMap(_=>_.actions||[]).filter(_=>!!_),u=(E?.results||[]).every(_=>_.alreadyOk);ae.length>0?p({title:"Recuperação disparada",description:`Tomamos as ações: ${ae.join(", ")}. Em até 2 minutos você verá o resultado aqui.`}):p(u?{title:"Tudo certo no servidor",description:"Nenhuma ação necessária — só atualizamos a página pra você ver."}:{title:"Sem novidades agora",description:"Nossa equipe foi notificada. Se preferir, fale com a gente no chat.",variant:"default"}),ne.invalidateQueries({queryKey:[`/api/books/${a.id}/hub-summary`]}),ne.invalidateQueries({queryKey:[`/api/books/${a.id}`,"light"]})},onError:E=>{p({title:o==="needs_review"?"Não foi possível gerar agora":"Não consegui verificar agora",description:E?.message||"Tenta de novo em alguns segundos.",variant:"destructive"})}}),H=t.type==="publish_bundle"?"Pacote Completo":t.type==="book_and_cover"?"Livro + Capa":"Geração do Livro",h=t.paidAt?Date.now()-new Date(t.paidAt).getTime():0,y=Math.floor(h/(3600*1e3)),A=t.recovery?.attempts||0,w=!!t.recovery?.needsAdmin,f=o==="generating",k=o==="needs_review",K=a.planStatus==="ready";let C,S,j;k?(C="Seu livro está pronto para continuar",S="Parte do seu livro já foi escrita e todo o conteúdo concluído foi preservado. Clique em “Gerar agora” para continuar pelo próximo checkpoint seguro até concluir o livro integralmente. Você não precisa revisar, corrigir nem pagar nada de novo.",j="warn"):m&&i?(C=w?"Sua capa está com a nossa equipe":"Vamos preparar sua capa profissional agora",S=w?"O texto do seu livro já está pronto. Identificamos um atraso na geração da capa e nossa equipe foi notificada — não precisa pagar de novo.":"Seu texto está completo. Sua capa, que faz parte do pacote pago, ainda não foi gerada. Clique em 'Verificar agora' pra darmos o próximo passo automático.",j=w?"alert":"warn"):f?(C="Estamos escrevendo seu livro agora",S="A SÁBHIA está cuidando de cada capítulo. Esse processo costuma levar alguns minutos. Você pode fechar essa página — quando voltar, o livro estará pronto pra ler.",j="ok"):w?(C="Nossa equipe já está investigando seu pedido",S="Já recebemos seu pagamento e identificamos um atraso na geração. Um membro do time foi notificado e vai resolver pra você o quanto antes. Você não precisa pagar de novo.",j="alert"):y>=1||A>0?(C="Seu livro está na fila — vamos acelerar agora",S="Pagamento confirmado! A geração já deveria ter começado. Clique abaixo pra darmos um empurrão. Se mesmo assim não resolver, nossa equipe é avisada automaticamente.",j="warn"):K?(C="Pagamento confirmado · preparando seu livro",S="Vamos começar a gerar o texto completo do seu livro a partir do plano que você aprovou. Em alguns minutos os capítulos começam a aparecer aqui.",j="ok"):(C="Pagamento confirmado · aguardando o plano do livro",S="Seu pacote está garantido. Assim que você terminar o planejamento do livro, a geração começa automaticamente — sem precisar pagar nada de novo.",j="ok");const F=j==="alert"?"border-rose-500/40":j==="warn"?"border-amber-500/40":"border-emerald-500/30",J=j==="alert"?"bg-rose-500/15":j==="warn"?"bg-amber-500/15":"bg-emerald-500/10",te=j==="alert"?"text-rose-300":j==="warn"?"text-amber-300":"text-emerald-300",Y=j==="alert"?"bg-rose-500/20 border-rose-500/30 text-rose-300":j==="warn"?"bg-amber-500/20 border-amber-500/30 text-amber-300":"bg-emerald-500/20 border-emerald-500/30 text-emerald-300",V=j==="alert"?"bg-rose-500 hover:bg-rose-400 shadow-rose-500/30":j==="warn"?"bg-amber-400 hover:bg-amber-300 shadow-amber-400/30":"bg-emerald-500 hover:bg-emerald-400 shadow-emerald-500/30";return e.jsx(L.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},"data-testid":"hero-bundle-paid-generating",children:e.jsxs("div",{className:`relative overflow-hidden rounded-3xl border-2 ${F}
1 bg-gradient-to-br from-white/[0.04] via-transparent to-transparent p-6 md:p-8`,children:[e.jsx("div",{className:`absolute -top-20 -right-20 w-64 h-64 rounded-full ${J} blur-3xl pointer-events-none`}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full border text-xs font-bold uppercase tracking-wider ${Y}`,children:[e.jsx(xe,{className:"w-3.5 h-3.5"}),H," pago · entrega em andamento"]}),e.jsx("h2",{className:"mt-3 text-2xl md:text-3xl font-heading font-bold text-white leading-tight","data-testid":"text-bundle-status-title",children:C}),e.jsx("p",{className:"mt-2 text-base text-white/80 leading-relaxed","data-testid":"text-bundle-status-body",children:S}),e.jsxs("div",{className:"mt-5 grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-white/[0.04] border border-white/10 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-white/50 font-semibold",children:r("bookHub.hero.paymentLabel","Pagamento")}),e.jsx("p",{className:`text-sm font-bold ${te}`,children:r("bookHub.hero.paymentConfirmed","Confirmado")}),t.paidAt&&e.jsx("p",{className:"text-[11px] text-white/60 mt-0.5",children:new Date(t.paidAt).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})})]}),e.jsxs("div",{className:"rounded-xl bg-white/[0.04] border border-white/10 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-white/50 font-semibold",children:r("bookHub.hero.textLabel","Texto do livro")}),e.jsx("p",{className:`text-sm font-bold ${m?"text-emerald-300":k||f?"text-amber-300":te}`,"data-testid":"text-hero-text-progress",children:m?r("bookHub.hero.done","Concluído"):k?"Pronto para gerar":f?r("bookHub.hero.generating","Gerando agora..."):K?r("bookHub.hero.queued","Na fila"):r("bookHub.hero.awaitingPlan","Aguardando plano")})]}),e.jsxs("div",{className:"rounded-xl bg-white/[0.04] border border-white/10 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-white/50 font-semibold",children:r("bookHub.hero.coverLabel","Capa profissional")}),e.jsx("p",{className:`text-sm font-bold ${t.includesCover?i?"text-amber-300":"text-emerald-300":"text-white/50"}`,children:t.includesCover?i?r("bookHub.hero.coverPreparing","Em preparação"):r("bookHub.hero.coverReady","Pronta"):r("bookHub.hero.coverNotIncluded","Não inclusa")})]})]}),A>0&&!w&&e.jsxs("p",{className:"mt-4 text-xs text-white/60","data-testid":"text-recovery-attempts",children:["Tentativas automáticas de recuperação: ",e.jsx("span",{className:"font-semibold text-white/80",children:A})]}),e.jsxs("div",{className:"mt-6 flex flex-col sm:flex-row gap-3",children:[e.jsx("button",{onClick:()=>d.mutate(),disabled:d.isPending,className:`inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-2xl ${V} disabled:opacity-60 disabled:cursor-wait text-black font-bold text-sm shadow-lg transition-all hover:scale-[1.01] active:scale-[0.99]`,"data-testid":"button-recover-delivery",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 animate-spin"})," ",k?"Iniciando geração...":"Verificando agora..."]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"w-4 h-4"})," ",k?"Gerar agora":"Verificar agora"]})}),w&&!k&&e.jsx("a",{href:"https://wa.me/5521959149454",target:"_blank",rel:"noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-2xl border border-white/15 bg-white/[0.03] hover:bg-white/[0.08] text-white text-sm font-semibold transition-all","data-testid":"link-whatsapp-support",children:"Falar no WhatsApp"})]}),e.jsx("p",{className:"mt-4 text-xs text-white/50","data-testid":"text-no-pay-again",children:"Você não precisa pagar nada de novo — seu pacote já está garantido na nossa base."})]})]})})}function $a(a){const t=new Set;a.coversCount>0&&t.add("cover"),a.illustrationsCount>0&&t.add("illustrate"),a.marketingCount>0&&t.add("marketing"),a.translationsCount>0&&t.add("translate"),a.publishingStatus&&a.publishingStatus!=="none"&&t.add("publish"),a.launchPlanReady&&t.add("launch_plan"),a.isbnReady&&t.add("isbn"),["generating","completed","failed"].includes(a.audiobookStatus)&&t.add("audiobook");const o=a.paidBundle?.type;if(o==="publish_bundle"||o==="book_and_cover"){const x=o==="publish_bundle"?Ut:Wt,r={cover_ebook:"cover",illustration_pack:"illustrate",publication_prep:"publish",marketing_
1kit:"marketing",launch_plan:"launch_plan"};for(const m of x){const i=r[m];i&&t.add(i)}}else a.paidBundle?.includesCover&&t.add("cover");return Array.from(t)}function hs(){const[,a]=Et("/book/:id"),t=a?.id||"",[,o]=Lt(),{user:x}=lt(),{t:r,i18n:m}=Oe("pages"),[i,p]=g.useState(!1),[d,H]=g.useState(!1),[h,y]=g.useState(!1),w=Tt().gated,f=Vt(),{data:k}=It(),K=!!k?.esStoreEnabled,{data:C,isLoading:S,isError:j}=q({queryKey:["/api/launch-plan/access"],staleTime:6e4}),F=S||j||(C?!C.hasAccess:!0),{data:J}=q({queryKey:["/api/audiobook/access"],staleTime:6e4}),te=!!(J&&!J.hasAccess),{data:Y,isLoading:V,isError:E}=q({queryKey:["/api/human-services/access?slug=ficha_catalografica"],staleTime:6e4}),ae=V||E||(Y?!Y.hasAccess:!0),{data:u,isLoading:_}=q({queryKey:[`/api/books/${t}`,"light"],queryFn:async()=>{const s=await fetch(`/api/books/${t}?light=1`,{credentials:"include"});if(!s.ok){let c=`Erro ${s.status}`;try{const O=await s.json();O?.message&&(c=O.message)}catch{}throw new Error(c)}return s.json()},enabled:!!t}),{data:l,isLoading:D}=q({queryKey:[`/api/books/${t}/hub-summary`],enabled:!!t,refetchInterval:s=>{const c=s.state.data;return c&&(c.textStatus==="generating"||u?.isPaid&&c.textStatus!=="completed")?15e3:!1}}),{data:Q}=q({queryKey:[`/api/books/${t}/apice-commercial-kit`,m.language],queryFn:async()=>{const s=await fetch(`/api/books/${t}/apice-commercial-kit?locale=${encodeURIComponent(m.language||"pt-BR")}`,{credentials:"include"});if(s.status===404)return null;if(!s.ok)throw new Error("apice_commercial_kit_unavailable");return s.json()},enabled:!!t,staleTime:3e4,retry:!1}),{data:G}=q({queryKey:[`/api/store/listings/by-book/${t}`],enabled:!!t,refetchInterval:s=>{const c=s.state.data;return!!(c&&(c.id||c.status))?!1:15e3}}),{data:v}=q({queryKey:[`/api/books/${t}/community-stats`],enabled:G?.status==="live",staleTime:25e3,refetchInterval:3e4}),[X,pe]=g.useState(""),[Ne,se]=g.useState(!1),{data:ye,refetch:he}=q({queryKey:["/api/author/announcements"],queryFn:async()=>{const s=await fetch("/api/author/announcements",{credentials:"include"});return s.ok?s.json():[]},staleTime:3e4}),n=(ye??[]).filter(s=>!G?.id||s.listingId===G.id),b=qe({mutationFn:async s=>{const c=await fetch(`/api/author/announcements/${s}`,{method:"DELETE",credentials:"include"});if(!c.ok)throw new Error("delete_failed");return c.json()},onSuccess:()=>{he()}}),$=qe({mutationFn:async s=>{const c=await fetch("/api/author/announcements",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:s,listingId:G?.id})});if(!c.ok)throw new Error("post_failed");return c.json()},onSuccess:()=>{pe(""),se(!0),setTimeout(()=>se(!1),4e3),he()}}),[R,Z]=g.useState(!1);async function ke(){if(!(R||!t)){Z(!0);try{const s=await fetch("/api/reader/author-book-access",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({bookId:t})});if(s.ok){const c=await s.json();window.location.href=`/loja/ler/${c.orderId}`}else window.location.href="/loja/ir-biblioteca"}catch{window.location.href="/loja/ir-biblioteca"}finally{Z(!1)}}}const{data:Ke}=q({queryKey:["/api/human-services"],enabled:!!t,staleTime:3e4}),M=(Ke||[]).find(s=>s?.bookId===t&&s?.serviceSlug==="ficha_catalografica"),Ce=!!(M&&(M.status==="completed"||M.status==="delivered"||Array.isArray(M.deliverables)&&M.deliverables.length>0)),Fe=!!(M&&!Ce&&M.status&&M.status!=="pending_payment"&&M.status!=="cancelled"&&M.status!=="refunded"),U=(Ke||[]).find(s=>s?.bookId===t&&s?.serviceSlug==="direito_autoral"),Se=!!(U&&(U.status==="completed"||U.status==="delivered"||U.input?.registrationNumber||U.metadata?.daRegistrationNumber)),Me=!!(U&&!Se&&U.status&&U.status!=="pending_payment"&&U.status!=="cancelled"&&U.status!=="refunded");if(g.useEffect(()=>{!_&&u&&u.planStatus==="ready"&&!u.isPaid&&o(`/book/${t}/editor`,{replace:!0})},[u,_,t,o]),_)return e.jsx(ve,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(B,{className:"w-8 h-8 animate-spin text-primary"})})});if(!u)return e.jsx(ve,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-lg text-muted-foreground",children:"Livro não encontrado"}),e.jsx(ie,{href:"/dashboard",children:e.jsx("button",{className:"text-primary hover:underline text-base font-medium","data-testid":"link-back-dashboard",children:"Voltar ao painel"})})]})})});if(u.planStatus==="ready"&&!u.isPaid)return e.jsx(ve,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(B,{className:"w-8 h-8 animate-spin text-primary"})})});const de=l?pa(l,r):null,gt=l?$a(l):[],be=l?.textStatus==="completed",ce=l?[l.textStatus==="completed",l.coversCount>0,l.illustrationsCount>0,l.publishingStatus!=="none",l.marketingCount>0,l.translationsCount>
10].filter(Boolean).length:0,Pe=ce>0?ce-(be?1:0):0,Ue=Math.round(ce/6*100),ge=ce===6;return e.jsxs(ve,{children:[e.jsxs("div",{className:"min-h-screen lg:pr-[316px]",children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/10 bg-background/90 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>o("/dashboard"),className:"flex items-center gap-2 text-base md:text-sm text-muted-foreground hover:text-white transition-colors py-2","data-testid":"link-back-dashboard",children:[e.jsx(Yt,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{children:"Meus Livros"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Hub do Livro"})]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-4 md:px-6 py-6 md:py-8 space-y-6 md:space-y-8",children:[e.jsxs(L.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"flex items-start gap-4 md:gap-5","data-testid":"section-book-header",children:[e.jsx("div",{className:"w-20 h-28 md:w-24 md:h-32 rounded-xl shadow-xl flex-shrink-0 overflow-hidden border-2 border-white/15 bg-gradient-to-b from-[#1a1a2e] to-[#0f0f1a] relative",children:u.coverImage?e.jsx(Ze,{src:u.coverImage,alt:u.title,className:"w-full h-full object-cover",widths:[96,128,192,256],sizes:"(max-width: 768px) 80px, 96px","data-testid":"img-book-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(W,{className:"w-8 h-8 text-primary/40"})})}),e.jsxs("div",{className:"flex-1 min-w-0 pt-1",children:[e.jsx("h1",{className:"text-xl md:text-3xl font-heading font-bold text-white leading-tight line-clamp-2","data-testid":"text-book-title",children:u.title}),u.author&&e.jsx("p",{className:"text-base text-muted-foreground mt-1","data-testid":"text-book-author",children:u.author}),(u.actualPagesEbook||u.actualPagesPaperback)&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap","data-testid":"section-page-counts",children:[u.actualPagesEbook&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-blue-500/15 border border-blue-500/25 text-xs font-medium text-blue-300","data-testid":`text-pages-ebook-${t}`,children:[e.jsx(z,{className:"w-3 h-3"}),u.actualPagesEbook," pág. (ebook)"]}),u.actualPagesPaperback&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-violet-500/15 border border-violet-500/25 text-xs font-medium text-violet-300","data-testid":`text-pages-paperback-${t}`,children:[e.jsx(z,{className:"w-3 h-3"}),u.actualPagesPaperback," pág. (paperback)"]})]}),l&&e.jsxs("div",{className:"mt-3 space-y-2","data-testid":"section-overall-progress",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm md:text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:be?"Livro pronto!":"Progresso geral"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[ge&&e.jsx(Be,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:`font-semibold ${be?"text-green-400":ge?"text-amber-400":"text-white/70"}`,children:be?Pe>0?`✅ Texto completo + ${Pe} extra${Pe>1?"s":""}`:"✅ Texto completo":`${ce}/6 etapas`})]})]}),e.jsxs("div",{className:"relative h-3 md:h-2 w-full bg-white/10 rounded-full overflow-hidden",children:[e.jsx(L.div,{className:`h-full rounded-full ${ge?"bg-gradient-to-r from-amber-400 to-yellow-300":"bg-primary"}`,initial:{width:0},animate:{width:`${Ue}%`},transition:{duration:1,ease:"easeOut",delay:.3},"data-testid":"progress-bar-overall"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-between px-0",children:[1,2,3,4,5].map(s=>e.jsx("div",{className:`w-0.5 h-full ${s*(100/6)<Ue?"bg-white/10":"bg-white/5"}`,style:{marginLeft:`${s/6*100}%`,position:"absolute"}},s))})]}),ge&&e.jsxs(L.p,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"text-xs text-amber-400 font-semibold flex items-center gap-1",children:[e.jsx(qt,{className:"w-3 h-3 fill-amber-400"}),"Livro 100% completo! Parabéns!"]})]})]})]}),e.jsx(ka,{book:u}),e.jsx(Pa,{book:u}),l?.paidBundle&&!D&&(()=>{const s=l.paidBundle,c=l.textStatus!=="completed",O=s.includesCover&&l.coversCount===0,N=!!s.recovery?.needsAdmin;return c||O||N?e.jsx(Ha,{book:u,paidBundle:s,bookStatus:l.bookStatus,summary:l}):null})(),Q&&e.jsx(ca,{kit:Q,t:r}),u&&u.isPaid&&l&&l.textStatus!=="completed"&&!D&&(l.textStatus==="generating"?e.jsx(Qt,{book:u}):e.jsx(da,{book:u,summary:l})),u&&u.isPaid&&l&&l.textStatus!=="completed"&&!D&&e.jsx(L.div,{initial:{opacity:0,y:12}
1,animate:{opacity:1,y:0},transition:{delay:.15},className:"pt-2",children:e.jsx(Xt,{bookId:t,ownedServiceIds:gt})}),de&&!D&&l?.textStatus!=="planned"&&!l?.paidBundle&&e.jsx(L.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(ie,{href:de.href(t),className:"block",children:e.jsxs("div",{className:"relative rounded-2xl border border-emerald-400/30 bg-gradient-to-br from-emerald-500/[0.10] via-teal-500/[0.05] to-transparent p-5 md:p-6 overflow-hidden group hover:border-emerald-300/60 transition-all duration-300 cursor-pointer shadow-lg hover:shadow-2xl hover:shadow-emerald-500/20 hover:-translate-y-0.5","data-testid":"banner-next-step",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_left,_rgba(45,212,191,0.15)_0%,_transparent_60%)] opacity-70 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"absolute -top-px left-6 right-6 h-px bg-gradient-to-r from-transparent via-emerald-400/50 to-transparent"}),e.jsxs("div",{className:"relative z-10 flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 md:w-14 md:h-14 rounded-2xl bg-gradient-to-br from-emerald-500/30 to-teal-600/20 ring-1 ring-emerald-400/40 flex items-center justify-center flex-shrink-0 shadow-md shadow-emerald-500/25 group-hover:scale-110 group-hover:-rotate-3 transition-all duration-300",children:e.jsx(de.icon,{className:"w-7 h-7 text-emerald-300",strokeWidth:2.2})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs md:text-sm font-bold text-emerald-300 uppercase tracking-[0.12em] mb-1",children:r("bookHub.nextStepLabel","Próximo passo")}),e.jsx("h3",{className:"text-xl md:text-xl font-heading font-bold text-white leading-tight",children:de.title}),e.jsx("p",{className:"text-sm md:text-base text-white/75 mt-1 hidden sm:block leading-snug",children:de.description})]}),e.jsx("div",{className:"w-12 h-12 md:w-12 md:h-12 rounded-full bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center flex-shrink-0 group-hover:scale-110 transition-all duration-300 shadow-lg shadow-emerald-500/40 group-hover:shadow-emerald-500/60",children:e.jsx(ee,{className:"w-6 h-6 md:w-5 md:h-5 text-white group-hover:translate-x-0.5 transition-transform",strokeWidth:2.5})})]})]})})}),l?.textStatus==="completed"&&!D&&e.jsx("div",{className:"mt-4",children:e.jsx(la,{})}),!D&&u.isPaid&&l?.paidBundle&&!l.paidBundle.includesCover&&l.coversCount===0&&l.textStatus==="completed"&&e.jsx(na,{book:u}),ia(),D?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(B,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-emerald-400/30 to-transparent max-w-[40px]"}),e.jsx("h2",{className:"text-xl md:text-2xl font-heading font-bold text-white tracking-tight",children:r("bookHub.servicesTitle","Serviços")}),e.jsx("div",{className:"h-px flex-1 bg-gradient-to-l from-transparent via-emerald-400/20 to-transparent"})]}),e.jsx(L.div,{variants:wa,initial:"hidden",animate:"show",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-5","data-testid":"section-service-cards",children:va.map(s=>{if(s.id==="barcode"&&!f.barcodeService||x?.market==="es"&&["isbn","barcode","ficha","direitoAutoral"].includes(s.id)||x?.market==="es"&&s.id==="store"&&!K)return null;let c=l?s.getStatus(l,r):{label:"..."};const O=s.getHref(t);let N=l?ha(s.id,l):!1,P=l?ba(s.id,l):!1;const We=l?ga(s.id,l,u):null,Ve=fa(s.id,r),ft=r(`bookHub.cards.${s.id}.title`,s.title),vt=r(`bookHub.cards.${s.id}.description`,s.description),Qe=r(`bookHub.cards.${s.id}.actionLabel`,s.actionLabel),me=rt[s.id]??rt.text,wt=s.id==="text"&&l?.textStatus==="completed"||s.id==="covers"&&l&&l.coversCount>0&&(l.coverImageUrl||u.coverImage),ue=s.id==="store",I=ue&&w,He=s.id==="launch_plan"&&F,$e=s.id==="audiobook"&&te,Xe=s.id==="ficha",fe=Xe&&ae;if(ue&&!w){const T=G?.status;G&&(N=!0,P=!1,T==="live"?c={label:"À venda na loja",color:"text-emerald-400"}:T==="pending_moderation"?c={label:"Em moderação",color:"text-amber-400"}:T==="flag_human"?c={label:"Em revisão humana",color:"text-amber-400"}:T==="rejected"?c={label:"Rejeitado — ajuste e reenvie",color:"text-red-400"}:T==="paused"?c={label:"Pausado pelo autor",color:"text-amber-400"}:T==="taken_down"?c={label:"Removido da loja",color:"text-red-400"}:T==="draft"?c={label:"Configure preço e descrição",color:"text-amber-400"}:c={label:"Na loja",color:"text-emerald-400"})}I&&(N=!1,P=!1,c={label:"Em breve",color:"text-orange-300"}),He&&(N=!1,P=!1,c={label:r("bookHub.status.comingSoon","Em breve"),color:"text-orange-300"}),$e&&(N=!1,P=!1,c={label:r("bookHub.status.comingSoon","Em breve"),color:"text-orange-300"}),fe&&(N=!1,P=!1,c={label:"Em breve",color:"text-orange-300"});let re;
1const jt=s.id==="direitoAutoral";Xe&&!fe&&(N=Ce,P=Fe,Ce?(c={label:r("bookHub.status.fichaDelivered","Ficha entregue"),color:"text-emerald-400"},re=r("bookHub.cards.ficha.actionLabelDelivered","Ver Ficha")):Fe?(c={label:r("bookHub.status.fichaInProgress","Bibliotecária elaborando"),color:"text-amber-400"},re=r("bookHub.cards.ficha.actionLabelInProgress","Acompanhar")):c={label:r("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-indigo-300"}),jt&&(N=Se,P=Me,Se?(c={label:r("bookHub.status.daCompleted","Registro concluído"),color:"text-emerald-400"},re=r("bookHub.cards.direitoAutoral.actionLabelDelivered","Ver Certificado")):Me?(c={label:r("bookHub.status.daInProgress","Em processamento"),color:"text-amber-400"},re=r("bookHub.cards.direitoAutoral.actionLabelInProgress","Acompanhar")):c={label:r("bookHub.status.serviceOnDemand","Serviço sob demanda"),color:"text-violet-300"});const Nt=ue&&!w&&G?.status==="live",yt=ue&&!w&&!!G,kt=`/loja/painel?publish=${t}`;s.id;const Ct=({children:T})=>He?e.jsx("div",{className:"block h-full cursor-not-allowed","data-testid":"card-launch-plan-gated",children:T}):$e?e.jsx("div",{className:"block h-full cursor-not-allowed","data-testid":"card-audiobook-gated",children:T}):fe?e.jsx("button",{type:"button",onClick:()=>y(!0),className:"block h-full w-full text-left cursor-pointer","data-testid":"card-ficha-gated",children:T}):ue?I?e.jsx("div",{className:"block h-full cursor-not-allowed","data-testid":"card-store-gated",children:T}):yt?e.jsx(ie,{href:kt,className:"block h-full","data-testid":"link-view-store-listing",children:T}):e.jsx("button",{type:"button",onClick:()=>H(!0),className:"block h-full w-full text-left","data-testid":"button-open-store-card",children:T}):e.jsx(ie,{href:O,className:"block h-full",children:T});return e.jsx(L.div,{variants:ja,children:e.jsx(Ct,{children:e.jsxs("div",{className:`group relative h-full rounded-2xl p-5 md:p-6 transition-all duration-300 cursor-pointer overflow-hidden hover:-translate-y-1 ${N?`border-2 border-emerald-500/50 shadow-xl ${s.completedGlow} hover:border-emerald-400/80 hover:shadow-2xl hover:shadow-emerald-500/30`:P?"border-2 border-amber-500/60 shadow-xl shadow-amber-500/20 hover:border-amber-400/90 hover:shadow-2xl hover:shadow-amber-500/40":I?"border-2 border-white/10 bg-zinc-950/60":`border-2 border-white/10 shadow-lg ${me.ring} hover:shadow-2xl ${me.hoverGlow}`}`,"data-testid":`card-service-${s.id}`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${s.gradient} transition-opacity duration-500 ${N?"opacity-100":P?"opacity-60":I?"opacity-20":"opacity-40 group-hover:opacity-70"}`}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-zinc-950/80 via-zinc-900/60 to-zinc-950/90"}),e.jsx("div",{className:"absolute top-3 right-3 z-20",children:s.comingSoon||I||He||$e||fe?e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-orange-500 text-orange-950 text-[10px] font-black uppercase tracking-wider shadow-lg shadow-orange-500/40","data-testid":`badge-coming-soon-${s.id}`,children:[e.jsx(Ae,{className:"w-3 h-3",strokeWidth:3}),"Em breve"]}):N?e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-emerald-500 text-emerald-950 text-[10px] font-black uppercase tracking-wider shadow-lg shadow-emerald-500/50",children:[e.jsx(xe,{className:"w-3 h-3",strokeWidth:3.5}),"Pronto"]}):P?e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-amber-400 text-amber-950 text-[10px] font-black uppercase tracking-wider shadow-lg shadow-amber-500/50 animate-pulse",children:[e.jsx(B,{className:"w-3 h-3 animate-spin",strokeWidth:3}),"Fazendo"]}):s.isNew?e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-gradient-to-r from-violet-500 to-indigo-500 text-white text-[10px] font-black uppercase tracking-wider shadow-lg shadow-violet-500/50 ring-1 ring-violet-300/40 animate-pulse","data-testid":`badge-new-${s.id}`,children:[e.jsx(W,{className:"w-3 h-3",strokeWidth:3}),"Novidade"]}):e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-gradient-to-r from-cyan-500/90 to-teal-500/90 text-cyan-950 text-[10px] font-black uppercase tracking-wider shadow-lg shadow-cyan-500/40 ring-1 ring-cyan-300/50","data-testid":`badge-todo-${s.id}`,children:[e.jsx(W,{className:"w-3 h-3",strokeWidth:3}),"A fazer"]})}),e.jsxs("div",{className:"relative z-10 flex flex-col h-full min-h-[210px] md:min-
1h-[200px]",children:[e.jsx("div",{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl flex items-center justify-center mb-4 border border-white/15 shadow-lg transition-all duration-300 group-hover:scale-110 group-hover:-rotate-3 bg-gradient-to-br ${I?"from-white/5 to-white/[0.02]":me.iconGrad}`,children:e.jsx(s.icon,{className:`w-7 h-7 md:w-8 md:h-8 ${I?"text-white/30":s.iconColor} drop-shadow-lg`,strokeWidth:2.2})}),e.jsx("h3",{className:`text-xl md:text-[1.35rem] font-heading font-bold mb-2 leading-tight flex items-center gap-2 flex-wrap ${I?"text-white/50":"text-white"}`,children:e.jsx("span",{children:ft})}),e.jsx("p",{className:`text-sm mb-5 flex-1 leading-relaxed ${I?"text-white/30":N?"text-white/70":P?"text-white/75":"text-white/70"}`,children:!N&&!P?Ve.motivation:vt}),wt?e.jsxs("div",{className:"flex flex-col gap-2.5 mt-auto","data-testid":`status-${s.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[We&&e.jsx("div",{className:"w-11 h-11 rounded-lg overflow-hidden border-2 border-emerald-400/50 shadow-md shadow-emerald-500/30 flex-shrink-0",children:e.jsx(Ze,{src:We,alt:s.title,className:"w-full h-full object-cover",widths:[44,88,132],sizes:"44px","data-testid":`thumbnail-${s.id}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[s.id==="text"&&e.jsx(Na,{bookId:t,onUploadClick:()=>p(!0)}),s.id==="covers"&&e.jsx(ya,{coverUrl:l?.coverImageUrl||u.coverImage,title:u.title})]})]}),e.jsxs("div",{className:"inline-flex items-center justify-center gap-2 w-full px-4 py-2.5 rounded-xl font-bold text-sm shadow-lg transition-all duration-200 group-hover:gap-3 min-h-[44px] border bg-white/10 text-white border-white/25 backdrop-blur-sm group-hover:bg-white/20 group-hover:border-white/40",children:[e.jsx("span",{className:"whitespace-nowrap truncate",children:Qe}),e.jsx(ee,{className:"w-4 h-4 flex-shrink-0 transition-transform duration-200 group-hover:translate-x-1",strokeWidth:2.5})]})]}):e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-auto flex-wrap",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-bold min-w-0 ${N?"text-emerald-300":P?"text-amber-200":I?"text-orange-300":"text-white/70"}`,"data-testid":`status-${s.id}`,children:[N?e.jsx(xe,{className:"w-4 h-4 flex-shrink-0",strokeWidth:3}):P?e.jsx(Ae,{className:"w-4 h-4 flex-shrink-0"}):e.jsx(W,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:N||P?c.label:I?"Aguarde liberação":r("bookHub.status.notStarted","Não iniciado")})]}),e.jsxs("div",{className:`inline-flex items-center gap-2 px-4 py-2.5 rounded-xl font-bold text-sm shadow-lg transition-all duration-200 group-hover:gap-3 min-h-[44px] border flex-shrink-0 max-w-full ${I?"bg-white/5 text-white/30 border-white/10":N?"bg-white/10 text-white border-white/25 backdrop-blur-sm group-hover:bg-white/20 group-hover:border-white/40":P?"bg-gradient-to-r from-amber-500 to-orange-500 text-white border-amber-300/40 shadow-amber-500/40 group-hover:shadow-2xl group-hover:shadow-amber-500/60":`bg-gradient-to-r ${me.solid} text-white border-white/30 ${me.ctaGlow} group-hover:shadow-2xl group-hover:brightness-110`}`,children:[e.jsx("span",{className:"hidden sm:inline whitespace-nowrap truncate max-w-[180px]",children:I?"Em breve":Nt?"Ver meu livro à venda":!N&&!P?Ve.cta:re??Qe}),e.jsx("span",{className:"sm:hidden whitespace-nowrap",children:I?"Em breve":!N&&!P?r("bookHub.ctaStart","Começar"):re??r("bookHub.ctaOpen","Abrir")}),e.jsx(ee,{className:"w-4 h-4 flex-shrink-0 transition-transform duration-200 group-hover:translate-x-1",strokeWidth:2.5})]})]})]})]})})},s.id)})}),G?.status==="live"&&e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"p-4 md:p-5 rounded-2xl border border-emerald-500/30 bg-emerald-950/20 flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-white text-sm md:text-base",children:"📖 Quer ver seu livro como leitor?"}),e.jsx("p",{className:"text-xs md:text-sm text-white/60 mt-0.5",children:"Acesse a experiência de leitura exatamente como seus leitores veem."})]}),e.jsxs("button",{type:"button",onClick:ke,disabled:R,"data-testid":"button-read-own-book",className:"flex-shrink-0 inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-emerald-500 hover:bg-emerald-400 disabled:opacity-60 text-emerald-950 font-bold text-sm transition-colors shadow-lg shadow-emerald-500/30",children:[R?e.jsx("span",{className:"w-4 h-4 border-2 border-emerald-900 border-t-transparent roun
1ded-full animate-spin"}):e.jsx(Ge,{className:"w-4 h-4"}),"Ler meu livro"]})]})}),G?.status==="live"&&e.jsxs("div",{className:"mt-8","data-testid":"section-community-studio",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-gradient-to-br from-violet-500/20 to-indigo-500/20",children:e.jsx(et,{className:"w-5 h-5 text-violet-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-white text-base leading-tight",children:"👥 Minha Comunidade"}),e.jsx("p",{className:"text-xs text-white/50",children:"Leitores ativos, comentários e engajamento ao vivo"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-violet-400",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-400 animate-pulse"}),e.jsx("span",{children:"Ao vivo"})]})]}),e.jsxs("div",{className:"mb-4 bg-white/[0.03] border border-white/10 rounded-2xl p-3.5","data-testid":"panel-announcement-compose",children:[e.jsx("label",{className:"text-[10px] uppercase tracking-[0.3em] text-violet-300/70 font-semibold block mb-2",children:"📢 Nota para seguidores"}),e.jsx("textarea",{className:"w-full bg-white/5 rounded-xl text-sm text-white/80 placeholder:text-white/25 px-3 py-2 resize-none focus:outline-none focus:ring-1 focus:ring-violet-500/50 transition",rows:3,maxLength:2e3,placeholder:"Escreva uma nota para seus leitores… (até 2000 caracteres)",value:X,onChange:s=>pe(s.target.value),disabled:$.isPending,"data-testid":"textarea-announcement-draft"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:`text-[11px] ${X.length>1900?"text-amber-400":"text-white/30"}`,children:[X.length,"/2000"]}),Ne?e.jsx("span",{className:"text-[11px] text-emerald-400 font-medium",children:"✓ Publicada!"}):e.jsx("button",{onClick:()=>{X.trim()&&$.mutate(X.trim())},disabled:!X.trim()||$.isPending,className:"text-[12px] font-semibold bg-violet-600 hover:bg-violet-500 disabled:opacity-40 text-white px-3.5 py-1.5 rounded-lg transition","data-testid":"button-publish-announcement",children:$.isPending?"Publicando…":"Publicar nota"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"p-3 rounded-2xl border border-white/10 bg-white/[0.03] text-center","data-testid":"community-stat-followers",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:e.jsx(et,{className:"w-3.5 h-3.5 text-violet-400"})}),e.jsx("p",{className:"text-lg font-bold text-white leading-none",children:v?v.totalFollowers:e.jsx("span",{className:"w-8 h-4 bg-white/10 rounded animate-pulse inline-block"})}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"seguidores"}),v&&v.followersThisWeek>0&&e.jsxs("p",{className:"text-xs text-violet-400 mt-0.5 font-medium",children:["+",v.followersThisWeek," essa semana"]})]}),e.jsxs("div",{className:"p-3 rounded-2xl border border-white/10 bg-white/[0.03] text-center","data-testid":"community-stat-readers",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:e.jsx(xt,{className:"w-3.5 h-3.5 text-sky-400"})}),e.jsx("p",{className:"text-lg font-bold text-white leading-none",children:v?v.activeReadersToday:e.jsx("span",{className:"w-8 h-4 bg-white/10 rounded animate-pulse inline-block"})}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"leitores hoje"})]}),e.jsxs("div",{className:"p-3 rounded-2xl border border-white/10 bg-white/[0.03] text-center","data-testid":"community-stat-comments",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:e.jsx(Ee,{className:"w-3.5 h-3.5 text-amber-400"})}),e.jsx("p",{className:"text-lg font-bold text-white leading-none",children:v?v.recentComments.length===0?"0":v.heatmap.reduce((s,c)=>s+c.commentCount,0):e.jsx("span",{className:"w-8 h-4 bg-white/10 rounded animate-pulse inline-block"})}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"comentários"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl border border-white/10 bg-white/[0.03]","data-testid":"community-card-comments",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ee,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Comentários recentes"})]}),v?v.recentComments.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx(Ee,{className:"w-8 h-8 text-white/20 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-white/40",children:"Nenhum comentário ainda"}),e.jsx("p",{className:"text-xs text-white/30 mt-0.5",children:"Os leitores poderão comentar capítulos ao ler"})]}):e.jsx("div",{className:"space-y-2 max-h-56 overflow-y-auto pr-1",children:v.recentComments.map(s=>e.jsxs("div",{className:"p-2.5 rounded-xl bg-white/[0.04] border border-white/[0.06]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-violet-300 truncate",children:s.readerEmail}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.likeCount>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-rose-400",children:[e.jsx(Zt,{className:"w-2.5 h-2.5"}),s.likeCount]}),e.jsxs("span",{className:"text-[10px] text-white/30",children:["Cap.",s.chapterIndex+1,s.paragraphAnchor!=null?` ¶${s.paragraphAnchor}`:""]})]})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed line-clamp-2",children:s.body})]},s.id))}):e.jsx("div",{className:"space-y-2",children:[1,2,3].map(s=>e.jsx("div",{className:"h-12 bg-white/5 rounded-xl animate-pulse"},s))})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl border border-white/10 bg-white/[0.03]","data-testid":"community-card-heatmap",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(tt,{className:"w-4 h-4 text-sky-400"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Engajamento por capítulo"})]}),v?v.heatmap.length===0?e.jsxs("div",{className:"text-center py-4",children:[e.jsx(tt,{className:"w-7 h-7 text-white/20 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-white/40",children:"Ainda sem interações por capítulo"})]}):e.jsx("div",{className:"space-y-1.5",children:(()=>{const s=Math.max(...v.heatmap.map(c=>c.commentCount+c.voteCount),1);return v.heatmap.slice(0,8).map(c=>{const O=c.commentCount+c.voteCount,N=Math.max(8,Math.round(O/s*100));return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-white/40 w-14 flex-shrink-0",children:["Cap. ",c.chapterIndex+1]}),e.jsx("div",{className:"flex-1 h-4 rounded-full bg-white/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-sky-500/70 to-violet-500/70 transition-all duration-700",style:{width:`${N}%`}})}),e.jsx("span",{className:"text-[10px] text-white/40 w-8 text-right flex-shrink-0",children:O>0?O:"—"})]},c.chapterIndex)})})()}):e.jsx("div",{className:"space-y-1.5",children:[1,2,3,4].map(s=>e.jsx("div",{className:"h-6 bg-white/5 rounded animate-pulse",style:{width:`${50+s*10}%`}},s))})]}),v?.topParagraph&&e.jsxs("div",{className:"p-4 rounded-2xl border border-amber-500/20 bg-amber-950/10","data-testid":"community-card-top-paragraph",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ea,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Trecho mais comentado"})]}),e.jsxs("p",{className:"text-xs text-white/60",children:["Capítulo ",v.topParagraph.chapterIndex+1,", parágrafo ",v.topParagraph.paragraphAnchor+1]}),e.jsxs("p",{className:"text-xs text-amber-400 mt-1 font-medium",children:[v.topParagraph.count," ",v.topParagraph.count===1?"comentário":"comentários"," esta semana"]})]})]})]}),e.jsxs("div",{className:"mt-4","data-testid":"panel-announcements-history",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ta,{className:"w-3.5 h-3.5 text-violet-400"}),e.jsx("span",{className:"text-xs font-semibold text-white/60 uppercase tracking-widest",children:"Notas publicadas"})]}),n.length===0?e.jsx("div",{className:"p-4 rounded-2xl border border-dashed border-white/10 bg-white/[0.02] text-center",children:e.jsxs("p",{className:"text-xs text-white/30",children:["Nenhuma nota publicada ainda.",e.jsx("br",{}),"Use o campo acima para escrever para seus leitores."]})}):e.jsx("div",{className:"space-y-2",children:n.map(s=>e.jsxs("div",{className:"p-3 rounded-2xl border border-white/10 bg-white/[0.03] flex gap-3 items-start","data-testid":`announcement-item-${s.id}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-white/80 leading-relaxed whitespace-pre-wrap break-words",children:s.body}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsxs("span",{className:"text-[11px] text-white/30 flex items-center gap-1",children:[e.jsx(Ae,{className:"w-3 h-3"}),new Date(s.createdAt).toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})]}),s.reachCount>0&&e.jsxs("span",{className:"text-[11px] text-violet-400 font-medium",children:[s.reachCount," ",s.reachCount===1?"leitor notificado":"leitores n
1otificados"]})]})]}),e.jsx("button",{type:"button",onClick:()=>{confirm("Remover esta nota?")&&b.mutate(s.id)},disabled:b.isPending,className:"flex-shrink-0 p-1.5 rounded-lg text-white/20 hover:text-red-400 hover:bg-red-400/10 transition","data-testid":`button-delete-announcement-${s.id}`,title:"Remover nota",children:e.jsx(aa,{className:"w-3.5 h-3.5"})})]},s.id))})]})]})]})]})]}),e.jsx(sa,{open:i,onClose:()=>p(!1),bookId:t,bookTitle:u.title}),e.jsx(Dt,{bookId:t,bookTitle:u.title,open:d,onClose:()=>H(!1)}),e.jsx(Kt,{open:h,onOpenChange:y,bookTitle:u.title}),e.jsx("div",{className:"hidden lg:block fixed right-4 top-20 w-[300px] max-h-[calc(100vh-6rem)] overflow-y-auto z-30",children:e.jsx(Ft,{bookId:t,currentStep:"write",inProgressSteps:{write:l?.textStatus==="generating"}})})]})}export{hs as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.