1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9480],{21975:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(78340).A)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},38285:(e,s,a)=>{"use strict";a.d(s,{q:()=>d});var t=a(95155),r=a(39092),l=a.n(r),i=a(12115),n=a(33210),c=a(47650),o=a(26401);function d({magazine:e,isOpen:s,onClose:a,initialPage:r}){let[m,x]=(0,i.useState)(!1);return((0,i.useEffect)(()=>(x(!0),()=>x(!1)),[]),(0,i.useEffect)(()=>(s?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[s]),(0,i.useEffect)(()=>{let e=e=>{"Escape"===e.key&&s&&a()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s,a]),m&&s&&e)?(0,c.createPortal)((0,t.jsxs)("div",{onClick:e=>{e.target===e.currentTarget&&a()},className:"jsx-c2efb22beaff2959 fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:[(0,t.jsxs)("div",{style:{animation:s?"bookOpen 0.6s ease-out":"bookClose 0.3s ease-in"},className:`jsx-c2efb22beaff2959 2 relative w-full h-full max-w-7xl max-h-[90vh] 3 bg-white rounded-lg shadow-2xl overflow-hidden 4 transform transition-all duration-500 ease-out 5 ${s?"scale-100 opacity-100":"scale-95 opacity-0"} 6 `,children:[(0,t.jsx)("button",{onClick:a,"aria-label":"Fechar",className:"jsx-c2efb22beaff2959 absolute top-4 right-4 z-30 p-2 rounded-full bg-black/50 hover:bg-black/70 text-white transition-colors",children:(0,t.jsx)(n.A,{className:"h-6 w-6"})}),(0,t.jsx)(o.b,{pdfUrl:e.pdfUrl,magazineId:e.id,title:e.title,coverUrl:e.coverUrl,editionNumber:e.editionNumber,publishDate:e.publishDate,initialPage:r,className:"w-full h-full"},e.id)]}),(0,t.jsx)(l(),{id:"c2efb22beaff2959",children:"@keyframes bookOpen{0%{transform:perspective(1e3px)rotatey(-45deg)scale(.9);opacity:0}50%{transform:perspective(1e3px)rotatey(-15deg)scale(.95);opacity:.7}100%{transform:perspective(1e3px)rotatey(0deg)scale(1);opacity:1}}@keyframes bookClose{0%{transform:perspective(1e3px)rotatey(0deg)scale(1);opacity:1}100%{transform:perspective(1e3px)rotatey(-30deg)scale(.9);opacity:0}}"})]}),document.body):null}},51632:(e,s,a)=>{"use strict";a.d(s,{MagazinesClientContent:()=>M});var t=a(95155),r=a(12115),l=a(5772),i=a(98500),n=a.n(i),c=a(97810),o=a(89823),d=a(57420),m=a(81477),x=a(45160),u=a(40980);function g(e){let[s,a]=(0,r.useState)(void 0);return(0,r.useEffect)(()=>{e?a(e):a(void 0)},[e]),s}var p=a(48375),h=a(79118);function b({magazines:e,onMagazineClick:s,onIndexClick:a,onEditClick:r,onArticlesClick:l,useDirectLink:i=!1,className:n,lastElementRef:c}){return(0,t.jsx)("div",{className:(0,u.cn)("grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 md:gap-6",n),children:e.map((n,o)=>(0,t.jsx)(f,{magazine:n,onClick:i?void 0:()=>s?.(n),onIndexClick:a,onEditClick:r,onArticlesClick:l,useDirectLink:i,ref:o===e.length-1?c:void 0},n.id))})}let f=(0,r.forwardRef)(({magazine:e,onClick:s,onIndexClick:a,onEditClick:r,onArticlesClick:i,useDirectLink:u=!1},b)=>{let f=g(e.coverUrl),j=(0,p.A)(),v=j?.isAdmin||!1,N=(0,t.jsx)(m.Zp,{ref:b,className:"group overflow-hidden transition-all hover:shadow-xl",children:(0,t.jsxs)(m.Wu,{className:"p-0",children:[(0,t.jsxs)("div",{className:"relative aspect-[3/4] overflow-hidden bg-gray-100",children:[(0,t.jsx)(l.default,{src:f||e.coverUrl,alt:e.title,fill:!0,className:"object-cover transition-transform group-hover:scale-110",sizes:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",onError:s=>{console.error(`Erro ao carregar capa da revista ${e.title}:`,e.coverUrl)}}),(0,t.jsx)("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center gap-4",children:(0,t.jsxs)("button",{onClick:e=>{e.stopPropagation(),!u&&s&&s()},className:"text-center text-white hover:scale-110 transition-transform cursor-pointer",children:[(0,t.jsx)(c.A,{className:"h-12 w-12 mx-auto mb-2"}),(0,t.jsx)("p",{className:"font-semibold",children:"Ler Revista"})]})}),v&&!1===e.published&&(0,t.jsx)(x.E,{variant:"secondary",className:"absolute top-2 left-2 z-10 bg-amber-500 text-white hover:bg-amber-500",children:"N\xe3o publicada"}),v&&r&&(0,t.jsx)("button",{onClick:s=>{s.stopPropagation(),r(e)},className:"absolute top-2 right-2 bg-blue-600 hover:bg-blue-700 text-white p-2 rounded-md transition-colors shadow-lg z-10",title:"Editar revista",children:(0,t.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsx)("h3",{className:"font-semibold text-lg mb-2 line-clamp-2",style:{textWrap:"balance"},children:e.title}),(0,t.jsx)("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(d.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:(0,h.QR)(e)??""})]})})]})]})});if(u){let s=null!=e.editionNumber?`/revistas/${e.editionNumber}`:`/revista/${e.id}`;return(0,t.jsx)(n(),{href:s,prefetch:!1,children:N})}return N});f.displayName="MagazineCard";var j=a(38285),v=a(62522),N=a(16626),y=a(42763),w=a(6296),k=a(52530);function A({isOpen:e,onClose:s,magazineId:a,magazineTitle:l}){let[i,n]=(0,r.useState)([]),[o,d]=(0,r.useState)(!1),[m,x]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&a&&u()},[e,a]);let u=async()=>{d(!0),x(null);try{let e=await fetch(`/api/magazines/${a}/articles`),s=await e.json();s.success?n(s.articles||[]):x(s.error||"Erro ao carregar artigos")}catch(e){console.error("Erro ao buscar artigos:",e),x("Erro ao carregar artigos")}finally{d(!1)}};return(0,t.jsx)(y.lG,{open:e,onOpenChange:s,children:(0,t.jsxs)(y.Cf,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[(0,t.jsxs)(y.c7,{children:[(0,t.jsx)(y.L3,{children:"Artigos da Revista"}),(0,t.jsx)(y.rr,{children:l})]}),(0,t.jsxs)("div",{className:"mt-4",children:[o&&(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(w.A,{className:"h-8 w-8 animate-spin text-primary"})}),m&&(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-800",children:m}),!o&&!m&&0===i.length&&(0,t.jsxs)("div",{className:"text-center py-12 text-muted-foreground",children:[(0,t.jsx)(c.A,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,t.jsx)("p",{className:"text-lg font-semibold mb-2",children:"Nenhum artigo encontrado"}),(0,t.jsx)("p",{className:"text-sm",children:"Esta revista ainda n\xe3o teve seus artigos extra\xeddos."})]}),!o&&!m&&i.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground mb-4",children:[i.length," ",1===i.length?"artigo encontrado":"artigos encontrados"]}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.map(e=>(0,t.jsx)(E,{article:e},e.id))})]})]})]})})}function E({article:e}){let s=g(e.coverImage?.url||"");return(0,t.jsx)(n(),{href:`/noticias/${e.slug}`,className:"block group",children:(0,t.jsx)(m.Zp,{className:"overflow-hidden transition-all hover:shadow-lg hover:scale-[1.02]",children:(0,t.jsx)(m.Wu,{className:"p-0",children:(0,t.jsxs)("div",{className:"flex gap-3",children:[e.coverImage?.url&&(0,t.jsx)("div",{className:"relative w-24 h-24 flex-shrink-0 bg-gray-100",children:(0,t.jsx)(l.default,{src:s||e.coverImage.url,alt:e.coverImage.alt||e.title,fill:!0,className:"object-cover",sizes:"96px"})}),(0,t.jsxs)("div",{className:"flex-1 p-3 min-w-0",children:[e.category&&(0,t.jsx)(x.E,{variant:"secondary",className:"mb-2 text-xs",children:e.category}),(0,t.jsx)("h3",{className:"font-semibold text-sm line-clamp-2 group-hover:text-primary transition-colors mb-1",children:e.title}),e.excerpt&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-2",children:e.excerpt}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.pages&&e.pages.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(c.A,{className:"h-3 w-3"}),(0,t.jsxs)("span",{children:["P\xe1g. ",e.pages[0],e.pages.length>1&&`-${e.pages[e.pages.length-1]}`]})]}),e.tags&&e.tags.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(k.A,{className:"h-3 w-3"}),(0,t.jsxs)("span",{children:[e.tags.length," tags"]})]})]}),"draft"===e.status&&(0,t.jsx)(x.E,{variant:"outline",className:"mt-2 text-xs",children:"Rascunho"})]})]})})})})}var C=a(52484),S=a(13545),z=a(21975),D=a(33210),P=a(48368),I=a(17243);function U({onUploadComplete:e}){let{user:s}=(0,p.A)(),[a,l]=(0,r.useState)(!1),[i,n]=(0,r.useState)(null),[c,o]=(0,r.useState)(""),[d,m]=(0,r.useState)(!1),[x,u]=(0,r.useState)(""),[g,h]=(0,r.useState)(""),[b,f]=(0,r.useState)(""),[j,v]=(0,r.useState)({stage:"idle",progress:0,message:""}),[N,y]=(0,r.useState)(null),[k,A]=(0,r.useState)(!1),E=(0,r.useCallback)(e=>{e.preventDefault(),A(!0)},[]),$=(0,r.useCallback)(e=>{e.preventDefault(),A(!1)},[]),M=(0,r.useCallback)(e=>{e.preventDefault(),A(!1);let s=e.dataTransfer.files[0];if(s&&"application/pdf"===s.type){n(s);let e=s.name.match(/BM[_-]?(\d+)/i);e&&o(e[1])}},[]),O=()=>{n(null),o(""),m(!1),u(""),h(""),f(""),v({stage:"idle",progress:0,message:""}),y(null)},T=x.trim().toLowerCase().normalize("NFD").replace(/[Ì-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),B=async()=>
6{if(i&&(d?T:c))try{let a=new FormData;a.append("pdf",i),d?a.append("customSlug",T):a.append("editionNumber",c),g&&a.append("title",g),b&&a.append("publishDate",b),v({stage:"uploading",progress:10,message:"Enviando PDF para o servidor..."});let t=await s?.getIdToken(),r=await fetch("/api/admin/magazines/upload",{method:"POST",headers:t?{Authorization:`Bearer ${t}`}:void 0,body:a});if(!r.ok){let e=await r.json();throw Error(e.error||"Erro no upload")}let n=await r.json();if(n.success)y({success:!0,editionNumber:d?void 0:parseInt(c),slug:d?T:void 0,coverUrl:n.data.coverUrl,coverGenerated:n.data.coverGenerated,tocItems:n.data.tocItems,toc:n.data.toc,detectedEdition:n.data.detectedEdition,detectedDate:n.data.detectedDate,detectedYear:n.data.detectedYear,detectedMonth:n.data.detectedMonth}),v({stage:"complete",progress:100,message:"â
Revista processada com sucesso!"}),setTimeout(()=>{l(!1),O(),e&&e()},1500);else throw Error(n.error||"Erro no processamento")}catch(e){console.error("[Upload] Error:",e),v({stage:"error",progress:0,message:e instanceof Error?e.message:"Erro desconhecido"}),y({success:!1,error:e instanceof Error?e.message:"Erro desconhecido"})}};return a?(0,t.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:(0,t.jsxs)("div",{className:"bg-gray-900 rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-gray-800",children:[(0,t.jsxs)("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[(0,t.jsx)(z.A,{className:"h-6 w-6"}),"Upload Nova Revista"]}),(0,t.jsx)("button",{onClick:()=>{l(!1),O()},className:"p-2 hover:bg-gray-800 rounded-lg transition-colors",children:(0,t.jsx)(D.A,{className:"h-5 w-5 text-gray-400"})})]}),(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsx)("div",{onDragOver:E,onDragLeave:$,onDrop:M,className:`border-2 border-dashed rounded-lg p-8 transition-all ${k?"border-blue-500 bg-blue-500/10":i?"border-green-500 bg-green-500/10":"border-gray-700 hover:border-gray-600"}`,children:i?(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)(P.A,{className:"h-12 w-12 text-green-400"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-white font-medium",children:i.name}),(0,t.jsxs)("p",{className:"text-sm text-gray-400",children:[(i.size/1024/1024).toFixed(2)," MB"]})]}),(0,t.jsx)("button",{onClick:()=>n(null),className:"p-2 hover:bg-gray-800 rounded-lg transition-colors",children:(0,t.jsx)(D.A,{className:"h-5 w-5 text-gray-400"})})]}):(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(z.A,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),(0,t.jsx)("p",{className:"text-gray-300 mb-2",children:"Arraste o PDF aqui ou clique para selecionar"}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"Formato: PDF ⢠Tamanho m\xe1ximo: 100MB"}),(0,t.jsx)("input",{type:"file",accept:"application/pdf",onChange:e=>{let s=e.target.files?.[0];if(s){n(s);let e=s.name.match(/BM[_-]?(\d+)/i);e&&o(e[1])}},className:"hidden",id:"file-upload"}),(0,t.jsx)("label",{htmlFor:"file-upload",className:"inline-block mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg cursor-pointer transition-colors",children:"Selecionar Arquivo"})]})}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:d,onChange:e=>m(e.target.checked),className:"rounded border-gray-700 bg-gray-800"}),"Edi\xe7\xe3o especial (sem n\xfamero sequencial â ex.: parceria com uma empresa)"]}),d?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Nome customizado *"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>u(e.target.value),placeholder:"Ex: alcoa-ufpa",className:"w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent",required:!0}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["Vira o link da revista: brasilmineral.com.br/revista/",T||"nome-customizado"]})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"N\xfamero da Edi\xe7\xe3o *"}),(0,t.jsx)("input",{type:"number",value:c,onChange:e=>o(e.target.value),placeholder:"Ex: 450",className:"w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent",required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"T\xedtulo (opcional)"}),(0,t.jsx)("input",{type:"text",value:g,onChange:e=>h(e.target.value),placeholder:"Ex: Brasil Mineral - Edi\xe7\xe3o 450",className:"w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Data de Publica\xe7\xe3o (opcional)"}),(0,t.jsx)("input",{type:"date",value:b,onChange:e=>f(e.target.value),className:"w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),"idle"!==j.stage&&(0,t.jsxs)("div",{className:"bg-gray-800 rounded-lg p-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(()=>{switch(j.stage){case"complete":return(0,t.jsx)(C.A,{className:"h-5 w-5 text-green-400"});case"error":return(0,t.jsx)(S.A,{className:"h-5 w-5 text-red-400"});case"idle":return(0,t.jsx)(z.A,{className:"h-5 w-5"});default:return(0,t.jsx)(w.A,{className:"h-5 w-5 animate-spin text-blue-400"})}})(),(0,t.jsx)("span",{className:`font-medium ${(()=>{switch(j.stage){case"complete":return"text-green-400";case"error":return"text-red-400";case"idle":return"text-gray-400";default:return"text-blue-400"}})()}`,children:j.message})]}),"complete"!==j.stage&&"error"!==j.stage&&(0,t.jsx)("div",{className:"w-full bg-gray-700 rounded-full h-2",children:(0,t.jsx)("div",{className:"bg-blue-500 h-2 rounded-full transition-all duration-300",style:{width:`${j.progress}%`}})}),"idle"!==j.stage&&(0,t.jsxs)("div",{className:"text-sm text-gray-400 space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(I.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:"\uD83D\uDCC4 Gerando imagem da capa (p\xe1gina 1)"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(w.A,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)("span",{children:"\uD83E\uDD16 Analisando capa com IA (data, edi\xe7\xe3o)"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(P.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:"\uD83D\uDCCB Extraindo \xedndice (p\xe1gina 4)"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(w.A,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)("span",{children:"\uD83D\uDD0D Processando \xedndice com IA (Gemini)"})]})]})]}),N&&N.success&&(0,t.jsxs)("div",{className:"bg-green-900/20 border border-green-500/50 rounded-lg p-4",children:[(0,t.jsxs)("h3",{className:"text-green-400 font-semibold mb-3 flex items-center gap-2",children:[(0,t.jsx)(C.A,{className:"h-5 w-5"}),"Processamento Conclu\xeddo!"]}),(0,t.jsxs)("div",{className:"text-sm text-gray-300 space-y-2",children:[(0,t.jsxs)("p",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-gray-400",children:"\uD83D\uDCD6 Edi\xe7\xe3o:"}),(0,t.jsx)("span",{className:"font-medium",children:N.slug?`Especial: ${N.slug}`:`BM ${N.editionNumber}`})]}),(N.detectedEdition||N.detectedDate)&&(0,t.jsxs)("div",{className:"mt-2 p-2 bg-blue-900/20 border border-blue-500/30 rounded",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-blue-400 mb-1",children:"\uD83E\uDD16 Detectado pela IA na capa:"}),N.detectedEdition&&(0,t.jsxs)("p",{className:"text-xs text-gray-300",children:["⢠Edi\xe7\xe3o: ",(0,t.jsxs)("span",{className:"font-medium",children:["#",N.detectedEdition]}),N.detectedEdition!==N.editionNumber&&(0,t.jsx)("span",{className:"text-yellow-400 ml-1",children:"(diferente do informado)"})]}),N.detectedDate&&(0,t.jsxs)("p",{className:"text-xs text-gray-300",children:["⢠Data: ",(0,t.jsx)("span",{className:"font-medium",children:N.detectedDate})]}),N.detectedYear&&(0,t.jsxs)("p",{className:"text-xs text-gray-300",children:["⢠Ano: ",(0,t.jsx)("span",{className:"font-medium",children:N.detectedYear})]})]}),(0,t.jsxs)("p",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-gray-400",children:"\uD83D\uDDBCï¸ Capa:"}),(0,t.jsx)("span",{className:N.coverGenerated?"text-green-400":"text-yellow-400",children:N.coverGenerated?"Gerada automaticamente":"N\xe3o gerada"})]}),(0,t.jsxs)("p",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-gray-400",children:"\uD83D\uDCCB \xcdndice:"}),(0,t.jsxs)("span",{className:"text-green-400 font-medium",children:[N.tocItems," itens extra\xeddos por IA"]})]}),N.toc&&N.toc.length>0&&(0,t.jsxs)("div",{className:"mt-3 p-3 bg-gray-800/50 rounded border border-gray-700",children:[(0,t.jsxs)("h4",{className:"text-sm font-medium text-gray-300 mb-2 flex items-center gap-2",children:[(0,t.jsx)(P.A,{className:"h-4 w-4"}),"Preview do \xcdndice"]}),(0,t.jsxs)("div",{className:"max-h-32 overflow-y-auto space-y-1",children:[N.toc.slice(0,8).map((e,s)=>(0,t.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,t.jsx)("span",{className:"text-gray-300 truncate flex-1 mr-2",children:e.title}),(0,t.jsxs)("span",{className:"text-gray-500 flex-shrink-0",children:["p.",e.dest]})]},s)),N.toc.length>8&&(0,t.jsxs)("div",{className:"text-xs text-gray-500 text-center pt-1 border-t border-gray-700",children:["... e mais ",N.toc.length-8," itens"]})]})]})]}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-gray-400 text-center flex items-center justify-center gap-2",children:[(0,t.jsx)(w.A,{className:"h-4 w-4 animate-spin"}),"Retornando \xe0 galeria..."]})]}),N&&!N.success&&(0,t.jsxs)("div",{className:"bg-red-900/20 border border-red-500/50 rounded-lg p-4",children:[(0,t.jsxs)("h3",{className:"text-red-400 font-semibold mb-2 flex items-center gap-2",children:[(0,t.jsx)(S.A,{className:"h-5 w-5"}),"Erro no Processamento"]}),(0,t.jsx)("p",{className:"text-sm text-gray-300",children:N.error})]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{onClick:()=>{l(!1),O()},className:"flex-1 px-4 py-2 bg-gray-800 hover:bg-gray-700 text-white rounded-lg transition-colors",children:"Cancelar"}),(0,t.jsx)("button",{onClick:B,disabled:!i||(d?!T:!c)||"idle"!==j.stage&&"complete"!==j.stage&&"error"!==j.stage,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-700 disabled:cursor-not-allowed text-white rounded-lg transition-colors font-medium",children:"idle"===j.stage||"error"===j.stage||"complete"===j.stage?"Salvar":"Processando..."})]})]})]})}):(0,t.jsx)("button",{onClick:()=>l(!0),className:"fixed bottom-6 right-6 bg-blue-600 hover:bg-blue-700 text-white rounded-full p-4 shadow-lg transition-all hover:scale-110 z-50",children:(0,t.jsx)(z.A,{className:"h-6 w-6"})})}var $=a(73321);function M({initialMagazines:e,isAdmin:s=!1}){let a=(0,$.useRouter)(),{user:l,isAdmin:i}=(0,p.A)(),n=i||l?.email==="[email protected]"||s,[c,o]=(0,r.useState)([]);(0,r.useEffect)(()=>
6{if(!n||!l)return void o([]);let e=!1;return(async()=>{try{let s=await l.getIdToken(),a=await fetch("/api/admin/magazines/unpublished",{headers:{Authorization:`Bearer ${s}`}});if(!a.ok)return;let t=await a.json();e||o(t.magazines||[])}catch(e){console.error("Erro ao buscar revistas n\xe3o publicadas:",e)}})(),()=>{e=!0}},[n,l]);let d=n?[...e,...c].sort((e,s)=>"number"==typeof e.editionNumber&&"number"==typeof s.editionNumber?s.editionNumber-e.editionNumber:0):e,[m,x]=(0,r.useState)(null),[u,g]=(0,r.useState)(!1),[h,f]=(0,r.useState)(void 0),[y,w]=(0,r.useState)(null),[k,E]=(0,r.useState)(!1),[C,S]=(0,r.useState)(null),[z,D]=(0,r.useState)(!1),[P,I]=(0,r.useState)(null),[O,T]=(0,r.useState)(!1),B=(e,s)=>{x(e),f(s),g(!0)},F=async()=>{try{let e=await l?.getIdToken();await fetch("/api/admin/revalidate",{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify({paths:["/revistas"]})})}catch(e){console.error("Erro ao revalidar /revistas:",e)}a.refresh()},R=async()=>{D(!1),await F()},q=async()=>{D(!1),await F()};return(0,t.jsxs)(t.Fragment,{children:[n&&(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(U,{onUploadComplete:F})}),(0,t.jsxs)("div",{className:"mb-8",children:[(0,t.jsx)("h1",{className:"text-3xl md:text-4xl font-bold mb-2 text-gray-900",children:"Revistas Brasil Mineral"}),(0,t.jsx)("p",{className:"text-muted-foreground text-base md:text-lg",children:"Acesse todas as edi\xe7\xf5es da revista em formato digital"})]}),(0,t.jsx)(b,{magazines:d,onMagazineClick:B,onIndexClick:e=>{w(e),E(!0)},onEditClick:e=>{S(e),D(!0)},onArticlesClick:e=>{I(e),T(!0)},useDirectLink:!0}),(0,t.jsx)(j.q,{magazine:m,isOpen:u,onClose:()=>g(!1),initialPage:h}),(0,t.jsx)(v.W,{magazine:y?{id:y.id,title:y.title,coverUrl:y.coverUrl,publishDate:y.publishDate,edition:y.edition}:{id:"",title:"",coverUrl:""},isOpen:k,onClose:()=>E(!1),onArticleClick:e=>{E(!1),y&&B(y,e)}}),(0,t.jsx)(N.m,{magazine:C,isOpen:z,onClose:()=>D(!1),onSave:R,onDelete:q}),(0,t.jsx)(A,{magazine:P,isOpen:O,onClose:()=>T(!1)})]})}},52530:(e,s,a)=>{"use strict";a.d(s,{A:()=>t});let t=(0,a(78340).A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]])},89691:(e,s,a)=>{Promise.resolve().then(a.bind(a,59652)),Promise.resolve().then(a.bind(a,51632))}},e=>{e.O(0,[76521,62992,47416,23309,18409,49304,16511,98500,38437,91798,58495,37051,35887,33727,72750,76634,26401,5789,28441,93794,77358],()=>e(e.s=89691)),_N_E=e.O()}]);
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.