PageSourceSearch

https://crppr.org.br/assets/RevistaViewPublica-ffhZHvYD.js

js crppr.org.br collected 2026-09-25 02:53:53 UTC 9,122 bytes, 44 lines download raw bytes

1import{j as e,o as T}from"./index-BCp-6lKF.js";import{h as X,f as G,r as n,L as _}from"./vendor-react-CpRvMXaC.js";import{H as J,p as N}from"./vendor-pdf-CLXYJc0c.js";import{r as K}from"./revistaService-J-C4bRA3.js";import{r as Q}from"./pdfReader-C724x6d1.js";import{F as R}from"./ArrowLeftIcon-BRwFpEWC.js";import{F as Y}from"./ChevronLeftIcon-BvZhC08K.js";import"./vendor-ui-5rZvml82.js";import"./vendor-editor-DoAMYjM7.js";N.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${N.version}/build/pdf.worker.min.js`;function le(){const{id:w}=X(),P=G(),[k,W]=n.useState(null),[D,F]=n.useState(!0),[S,f]=n.useState(null),[$,C]=n.useState(null),[s,E]=n.useState([]),[b,L]=n.useState(0),[H,v]=n.useState(!1),[j,M]=n.useState(0),p=n.useRef(null);n.useEffect(()=>{w&&(async()=>{try{F(!0),f(null);const t=await K.buscarPublica(w);W(t);const i=t.arquivo_url||t.arquivo;if(!i)throw new Error("Arquivo PDF não encontrado");const o=Q(i);C(o),await B(o)}catch(t){console.error("Erro ao carregar revista:",t),f(t.message||"Revista não encontrada")}finally{F(!1)}})()},[w]);const B=async a=>{try{v(!0),M(0),console.log("Iniciando carregamento do PDF:",a);const i=await N.getDocument(a).promise,o=i.numPages;console.log(`PDF carregado: ${o} páginas encontradas`);const r=(await i.getPage(1)).getViewport({scale:1}),x=r.height>r.width;console.log(`Orientação detectada: ${x?"Retrato (Portrait)":"Paisagem (Landscape)"}`);const u=[];let h;if(x){const l=window.innerHeight-300,d=Math.min(window.innerWidth-100,800),m=l/r.height,g=d/r.width;h=Math.min(m,g,2)}else h=window.innerWidth>1200?2:window.innerWidth>768?1.5:1.2;console.log(`Escala calculada: ${h.toFixed(2)}`);for(let l=1;l<=o;l++){const d=await i.getPage(l),m=d.getViewport({scale:h}),g=document.createElement("canvas"),z=g.getContext("2d");g.height=m.height,g.width=m.width,await d.render({canvasContext:z,viewport:m}).promise;const O=g.toDataURL("image/png");u.push(O),M(l),console.log(`Página ${l}/${o} convertida (${m.width}x${m.height})`)}console.log(`PDF carregado: ${o} páginas convertidas`),E(u),v(!1)}catch(t){console.error("Erro ao carregar PDF:",t),f("Erro ao processar o PDF: "+t.message),v(!1)}},V=()=>{if(p.current){const a=p.current.pageFlip();a&&a.flipNext()}},q=()=>{if(p.current){const a=p.current.pageFlip();a&&a.flipPrev()}},[A,y]=n.useState({width:800,height:1131});n.useEffect(()=>{if(s.length===0){const t=Math.min(window.innerWidth-80,800),i=Math.min(t*1.414,window.innerHeight-250);y({width:t,height:i});return}const a=new Image;a.src=s[0],a.onload=()=>{const t=a.width,i=a.height,o=i>t;let c,r;if(o){const x=window.innerHeight-300,u=Math.min(window.innerWidth-100,800),h=x/i,l=u/t,d=Math.min(h,l,1);c=t*d,r=i*d}else c=Math.min(window.innerWidth-80,1e3),r=c*i/t,r>window.innerHeight-250&&(r=window.innerHeight-250,c=r*t/i);y({width:Math.round(c),height:Math.round(r)}),console.log("Dimensões do flipbook calculadas:",{width:Math.round(c),height:Math.round(r),isPortrait:o})},a.onerror=()=>{const t=Math.min(window.innerWidth-80,800),i=Math.min(t*1.414,window.innerHeight-250);y({width:t,height:i})}},[s]);const{width:I,height:U}=A;return D?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-primary mb-4"}),e.jsx("p",{className:"text-texto",children:"Carregando revista..."})]})}):S||!k||!$?e.jsx("div",{className:"min-h-screen bg-gray-50 py-12",children:e.jsx("div",{className:"container mx-auto px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("button",{onClick:()=>P("/publicacoes/materiais/revista-contato"),className:"flex items-center gap-2 text-primary hover:text-primary-700 mb-6 transition-colors",children:[e.jsx(R,{className:"h-5 w-5"}),e.jsx("span",{children:"Voltar para Revistas"})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 p-8 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-titulos mb-4",children:"Revista não encontrada"}),e.jsx("p",{className:"text-texto mb-6",children:S||"A revista que você está procurando não existe ou foi removida."}),e.jsx(_,{to:"/publicacoes/materiais/revista-contato",className:"inline-flex items-center px-6 py-3 bg-primary text-white font-semibold rounded-lg hover:bg-primary-700 transition-colors",children:"Ver todas as revistas"})]})]})})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-gray-100 to-gray-200 py-8",children:[e.jsx("div",{className:"container mx-auto px-6 mb-6",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>P("/publicacoes/materiais/revista-contato"),className:"flex items-center gap-2 text-gray-700 hover:text-primary transition-colors bg-white px-4 py-2 rounded-lg shadow-sm",children:[e.jsx(R,{className:"h-5 w-5"}),e.jsx("span",{children:"Voltar"})]}),e.jsx("h1",{className:"text-xl md:text-2xl font-bold text-titulos",children:k.titulo})]}),s.length>0&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:q,disabled:b===0,className:"flex items-center gap-2 px-4 py-2 bg-white text-gray-700 rounded-lg shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Y,{className:"h-5 w-5"}),e.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),e.jsxs("span",{className:"px-4 py-2 bg-white text-gray-700 rounded-lg shadow-sm text-sm",children:["Página ",b+1," de ",s.length]}),e.jsxs("button",{onClick:V,disabled:b>=s.length-1,className:"flex items-center gap-2 px-4 py-2 bg-white text-gray-700 rounded-lg shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx("span",{className:"hidden sm:inline",children:"Próxima"}),e.jsx(T,{className:"h-5 w-5"})]})]})]})}),e.jsx("div",{className:"flex justify-center px-4",children:s.length>0?e.jsx("div",{className:"shadow-2xl rounded-lg overflow-hidden bg-white p-2",children:e.jsx(J,{ref:p,width:I,height:U,minWidth:300,maxWidth:1e3,minHeight:400,maxHeight:1400,size:"fixed",maxShadowOpacity:.5,showCover:!0,mobileScrollSupport:!0,onFlip:a=>{const t=(a==null?void 0:a.data)||0;L(t)},className:"flipbook-container",children:s.map((a,t)=>e.jsx("div",{className:"page",style:{backgroundColor:"white",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",margin:"0"},children:e.jsx("img",{src:a,alt:`Página ${t+1}`,style:{width:"100%",height:"100%",objectFit:"contain",userSelect:"none",display:"block"},draggable:!1})},t))})}):e.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-8 text-center max-w-md mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-primary mb-4"}),e.jsx("p",{className:"text-texto font-medium mb-4",children:H?"Processando páginas do PDF...":"Aguardando processamento do PDF..."})]}),H&&s.length>0&&e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Página ",j," de ",s.length]}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[Math.round(j/s.length*100),"%"]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-primary-500 to-primary-700 h-full rounded-full transition-all duration-300 ease-out",style:{width:`${j/s.length*100}%`},children:e.jsx("div",{className:"h-full bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})})}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Convertendo páginas em imagens..."})]})]})}),e.jsx("style",{children:`
2        .flipbook-container {
3          box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
4        }
5        
6        .flipbook-container .page {
7          background: white !important;
8          width: 100% !important;
9          height: 100% !important;
10          display: flex !important;
11          align-items: center !important;
12          justify-content: center !important;
13          padding: 0 !important;
14          margin: 0 !important;
15          overflow: hidden !important;
16        }
17        
18        .flipbook-container .page img {
19          width: 100% !important;
20          height: 100% !important;
21          object-fit: contain !important;
22          display: block !important;
23        }
24        
25        @keyframes shimmer {
26          0% {
27            transform: translateX(-100%);
28          }
29          100% {
30            transform: translateX(100%);
31          }
32        }
33        
34        .animate-shimmer {
35          animation: shimmer 2s infinite;
36        }
37        
38        @media (max-width: 768px) {
39          .flipbook-container {
40            width: 100% !important;
41            height: auto !important;
42          }
43        }
44      `})]})}
44export{le 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.