PageSourceSearch

https://crppr.org.br/assets/AnaiViewPublica-D-y0PE3B.js

js crppr.org.br collected 2026-09-25 02:54:10 UTC 7,798 bytes, 1 lines download raw bytes

1import{j as e,o as Z,A as C}from"./index-BCp-6lKF.js";import{h as ee,f as ae,r,L as te}from"./vendor-react-CpRvMXaC.js";import{H as re,p as y}from"./vendor-pdf-CLXYJc0c.js";import{a as se}from"./anaiService-DClb6Kwg.js";import{F as D}from"./ArrowLeftIcon-BRwFpEWC.js";import{F as ne}from"./ChevronLeftIcon-BvZhC08K.js";import"./vendor-ui-5rZvml82.js";import"./vendor-editor-DoAMYjM7.js";y.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${y.version}/build/pdf.worker.min.js`;function xe(){const{id:p}=ee(),v=ae(),[d,R]=r.useState(null),[U,j]=r.useState(!0),[N,F]=r.useState(null),[g,B]=r.useState(null),[P,$]=r.useState(null),[m,z]=r.useState([]),[f,H]=r.useState(0),[q,b]=r.useState(!1),[V,k]=r.useState(0),[S,E]=r.useState(!1),[T,W]=r.useState(!1),u=r.useRef(null),A=r.useRef(null);r.useEffect(()=>{p&&(async()=>{try{j(!0),F(null);const t=await se.buscarPublico(p);R(t);let s=null,n=null;if(t.arquivo_url||t.arquivo){const i=t.arquivo_url||t.arquivo;if(i.startsWith("http")){n=i;try{const o=new URL(i).pathname.replace(/^\//,"");s=`${C.BASE_URL}/storage/${o}`}catch{s=i}}else s=`${C.BASE_URL}/storage/${i}`,n=s}else throw new Error("Arquivo PDF não encontrado");B(s),$(n),E(!1),await _(s,n)}catch(t){console.error("Erro ao carregar anais:",t),F(t.message||"Anais não encontrado")}finally{j(!1)}})()},[p]);const _=async(a,t=null)=>{try{b(!0),k(0);const s=async l=>{const c=await fetch(l,{method:"GET",cache:"no-store",credentials:"omit"});if(!c.ok)throw new Error(`Falha ao buscar PDF (HTTP ${c.status})`);return c};let n;try{n=await s(a)}catch{if(t&&t!==a)n=await s(t);else throw new Error("Falha ao buscar PDF")}const i=await n.arrayBuffer(),o=await y.getDocument({data:new Uint8Array(i),disableStream:!0,disableRange:!0,disableAutoFetch:!0}).promise,X=o.numPages,L=[];for(let l=1;l<=X;l++){const c=await o.getPage(l),w=c.getViewport({scale:1.6}),x=document.createElement("canvas"),Y=x.getContext("2d");x.height=w.height,x.width=w.width,await c.render({canvasContext:Y,viewport:w}).promise,L.push(x.toDataURL("image/png")),k(l)}z(L),b(!1)}catch(s){console.error("Erro ao carregar PDF:",s),E(!0),b(!1)}},M=()=>{if(u.current){const a=u.current.pageFlip();a&&a.flipNext()}},I=()=>{if(u.current){const a=u.current.pageFlip();a&&a.flipPrev()}},[O,G]=r.useState({width:500,height:707});r.useEffect(()=>{const a=()=>{const n=window.innerWidth-8,i=window.innerHeight-64;let h=Math.floor(n/2),o=Math.floor(h*1.414);o>i&&(o=i,h=Math.floor(o/1.414)),G({width:h,height:o})};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),r.useEffect(()=>{const a=()=>{W(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]);const J=async()=>{var a;try{document.fullscreenElement?await document.exitFullscreen():await((a=A.current)==null?void 0:a.requestFullscreen())}catch(t){console.warn("Fullscreen não disponível:",t)}},{width:K,height:Q}=O;return U?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 anais..."})]})}):N||!d||!g?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:()=>v("/publicacoes/materiais/anais"),className:"flex items-center gap-2 text-primary hover:text-primary-700 mb-6 transition-colors",children:[e.jsx(D,{className:"h-5 w-5"}),e.jsx("span",{children:"Voltar para Anais"})]}),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:"Anais não encontrado"}),e.jsx("p",{className:"text-texto mb-6",children:N||"O anais que você está procurando não existe ou foi removido."}),e.jsx(te,{to:"/publicacoes/materiais/anais",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 todos os anais"})]})]})})}):e.jsxs("div",{ref:A,className:"h-screen w-screen overflow-hidden flex flex-col bg-gray-900",children:[e.jsxs("div",{className:"flex-shrink-0 flex flex-wrap items-center justify-between gap-2 px-3 py-2 bg-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("button",{onClick:()=>v("/publicacoes/materiais/anais"),className:"inline-flex items-center gap-2 px-3 py-1.5 bg-gray-700 text-gray-200 rounded-lg hover:bg-gray-600 transition-colors text-sm flex-shrink-0",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx("span",{children:"Voltar"})]}),e.jsx("h1",{className:"text-sm font-bold text-white truncate",children:d.titulo})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.length>0&&!S&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:I,disabled:f===0,className:"inline-flex items-center gap-1 px-3 py-1.5 bg-gray-700 text-gray-200 rounded-lg hover:bg-gray-600 disabled:opacity-40 disabled:cursor-not-allowed text-sm",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),e.jsxs("span",{className:"px-3 py-1.5 bg-gray-700 text-gray-200 rounded-lg text-sm",children:["Pág ",f+1," / ",m.length]}),e.jsxs("button",{onClick:M,disabled:f>=m.length-1,className:"inline-flex items-center gap-1 px-3 py-1.5 bg-gray-700 text-gray-200 rounded-lg hover:bg-gray-600 disabled:opacity-40 disabled:cursor-not-allowed text-sm",children:[e.jsx("span",{className:"hidden sm:inline",children:"Próxima"}),e.jsx(Z,{className:"h-4 w-4"})]})]}),e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center px-3 py-1.5 text-sm font-medium bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors",children:T?"Sair da tela cheia":"Tela cheia"})]})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:S?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-shrink-0 px-4 py-2 bg-gray-800 border-t border-gray-700 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm text-gray-300",children:"Modo de leitura alternativo ativado para garantir a abertura do PDF."}),e.jsx("a",{href:P||g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-3 py-1.5 text-sm font-medium text-white bg-primary-600 rounded-lg hover:bg-primary-700 transition-colors",children:"Abrir em nova aba"})]}),e.jsx("iframe",{src:P||g,title:(d==null?void 0:d.titulo)||"Visualizador de PDF",className:"flex-1 w-full border-0"})]}):m.length>0?e.jsx("div",{className:"flex-1 flex items-center justify-center overflow-hidden",children:e.jsx(re,{ref:u,width:K,height:Q,size:"fixed",minWidth:200,maxWidth:2e3,minHeight:300,maxHeight:4e3,maxShadowOpacity:.45,showCover:!0,mobileScrollSupport:!0,onFlip:a=>H((a==null?void 0:a.data)||0),className:"flipbook-container",children:m.map((a,t)=>e.jsx("div",{className:"page bg-white flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:a,alt:`Página ${t+1}`,style:{width:"100%",height:"100%",objectFit:"contain",display:"block"},draggable:!1})},t))})}):e.jsx("div",{className:"flex-1 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-400 mb-4"}),e.jsx("p",{className:"text-gray-300 font-medium",children:q?`Processando páginas... (${V} processadas)`:"Aguardando processamento do PDF..."})]})})})]})}export{xe 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.