1import{O as J,ax as de,r as n,a9 as ue,j as e,P as he,Q as me,ay as pe,U as fe,az as Q,al as xe,at as we,aA as ge}from"./index-CMfIf9m3.js";import{_ as be,a as ve,Z as je,D as X,p as Ne,c as ye,b as Se}from"./pdf-vVqOHKOQ.js";const Pe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ke=J("chevron-up",Pe);const _e=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Ce=J("printer",_e),ee=new URL("/assets/pdf.worker.min-yatZIOMy.mjs",import.meta.url);ee.searchParams.set("cb","1");Se.workerSrc=ee.toString();let Y=null;const Le=()=>(globalThis.pdfjsLib=Ne,Y??=ge(()=>import("./pdf_viewer-CqpT9I3y.js"),[]),Y),Ee=new Set(["auto","page-width","page-fit","page-actual"]),Re=P=>{try{return decodeURIComponent(new URL(P).pathname.split("/").pop()||"").replace(/-[0-9a-f]{8}(\.pdf)$/i,"$1")||"Document"}catch{return"Document"}},Me=()=>{const[P]=de(),i=P.get("src")||"",x=P.get("embed")==="1",w=n.useMemo(()=>ue(i),[i]),k=n.useMemo(()=>Re(i),[i]),T=n.useRef(null),A=n.useRef(null),p=n.useRef(null),I=n.useRef(null),_=n.useRef(null),[f,C]=n.useState("loading"),[Z,z]=n.useState(0),[L,te]=n.useState(0),[g,ae]=n.useState(1),[B,E]=n.useState("1"),[ne,se]=n.useState(1),[h,re]=n.useState(""),[M,F]=n.useState({current:0,total:0}),[K,G]=n.useState(!1),[v,W]=n.useState([]),[j,V]=n.useState(null),O=n.useRef(null);n.useEffect(()=>{x||(document.title=`${k} | ICSI`)},[k,x]),n.useEffect(()=>{if(!w){C("error");return}const t=T.current,a=A.current;if(!t||!a)return;let o=!1,s=null,c=null;return C("loading"),z(0),(async()=>{const{EventBus:y,FindState:m,LinkTarget:b,PDFFindController:R,PDFLinkService:$,PDFViewer:oe}=await Le();if(o)return;const u=new y,D=new $({eventBus:u,externalLinkTarget:b.BLANK,externalLinkRel:"noopener noreferrer nofollow"}),ce=new R({eventBus:u,linkService:D});c=new oe({container:t,viewer:a,eventBus:u,linkService:D,findController:ce}),D.setViewer(c),p.current=c,I.current=u,u.on("pagesinit",()=>{c&&(c.currentScaleValue=t.clientWidth<768?"page-width":"auto")}),u.on("pagechanging",r=>{ae(r.pageNumber),E(String(r.pageNumber))}),u.on("scalechanging",r=>se(r.scale)),u.on("updatefindmatchescount",r=>F(r.matchesCount)),u.on("updatefindcontrolstate",r=>{F(r.matchesCount),G(r.state===m.NOT_FOUND)}),s=be({url:i,withCredentials:!1,isEvalSupported:!1,enableXfa:!1}),s.onProgress=({loaded:r,total:H})=>{H&&z(Math.min(100,Math.round(r/H*100)))};const S=await s.promise;if(o){S.destroy();return}_.current=S,c.setDocument(S),D.setDocument(S,null),te(S.numPages),C("ready")})().catch(()=>{o||C("error")}),()=>{o=!0,s?.destroy(),c?.setDocument(null),_.current?.destroy(),_.current=null,p.current=null,I.current=null}},[i,w]),n.useEffect(()=>{const t=()=>{const a=p.current;a&&Ee.has(a.currentScaleValue)&&(a.currentScaleValue=a.currentScaleValue)};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const N=n.useCallback((t,a=!1)=>{I.current?.dispatch("find",{source:null,type:t,query:h,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:a,matchDiacritics:!1})},[h]);n.useEffect(()=>{f==="ready"&&(h||(F({current:0,total:0}),G(!1)),N(""))},[h,f,N]),n.useEffect(()=>{const t=a=>{(a.ctrlKey||a.metaKey)&&a.key.toLowerCase()==="f"&&f==="ready"&&(a.preventDefault(),O.current?.focus(),O.current?.select())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[f]);const U=t=>{const a=p.current;!a||!L||(a.currentPageNumber=Math.min(Math.max(1,t),L))},q=t=>{const a=p.current;a&&(t>0?a.increaseScale():a.decreaseScale())},ie=t=>{p.current&&(p.current.currentScaleValue=t)},le=async()=>{const t=_.current;if(!t||j)return;const a=t.numPages>100?1.5:2,o=[];try{for(let s=1;s<=t.numPages;s++){V(`Preparing page ${s} of ${t.numPages}â¦`);const c=await t.getPage(s),y=c.getViewport({scale:a}),m=document.createElement("canvas");m.width=Math.ceil(y.width),m.height=Math.ceil(y.height);const b=m.getContext("2d");if(!b)continue;b.fillStyle="#fff",b.fillRect(0,0,m.width,m.height),await c.render({canvasContext:b,viewport:y,intent:"print",annotationMode:ye.ENABLE_STORAGE}).promise;const R=await new Promise($=>m.toBlob($,"image/jpeg",.92));R&&o.push(URL.createObjectURL(R))}}catch{o.forEach(s=>URL.revokeObjectURL(s)),V(null);return}V(null),W(o)};n.useEffect(()=>{if(!v.length)return;let t=!1;const a=()=>{t||(t=!0,v.forEach(s=>URL.revokeObjectURL(s)),W([]))},o=Array.from(document.querySelectorAll(".pdf-print-pages img"));return Promise.all(o.map(s=>s.decode().catch(()=>{}))).then(()=>{window.addEventListener("afterprint",a,{once:!0}),window.print(),window.setTimeout(a,6e4)}),()=>window.removeEventListener("afterprint",a)},[v]);const d="inline-flex h-8 min-w-8 items-center justify-center rounded px-1.5 text-white hover:bg-white/15 disabled:opacity-40 disabled:hover:bg-transparent",l=f==="ready";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`pdf-viewer-screen flex flex-col bg-[#525659] ${x?"h-full min-h-[400px]":"h-dvh"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 bg-[#0b4173] px-2 py-1.5 text-sm text-white sm:px-3",children:[e.jsxs("div",{className:"flex min-w-0 basis-full items-center gap-2 sm:basis-auto sm:flex-1",children:[!x&&e.jsx("a",{href:"/",className:"shrink-0 font-semibold tracking-wide hover:underline","aria-label":"ICSI home",children:"ICSI"}),e.jsx("h1",{className:"min-w-0 truncate text-sm font-medium",title:k,children:k})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",className:d,onClick:()=>U(g-1),disabled:!l||g<=1,"aria-label":"Previous page",children:e.jsx(he,{className:"h-4 w-4"})}),e.jsxs("form",{onSubmit:t=>{t.preventDefault();const a=parseInt(B,10);Number.isFinite(a)?U(a):E(String(g))},className:"flex items-center gap-1",children:[e.jsx("input",{value:B,onChange:t=>E(t.target.value.replace(/\D/g,"")),onBlur:()=>E(String(g)),inputMode:"numeric","aria-label":"Page number",disabled:!l,className:"w-10 rounded bg-white/15 px-1 py-0.5 text-center text-white outline-none focus:bg-white/25"}),e.jsxs("span",{className:"whitespace-nowrap text-white/80",children:["/ ",L||"â"]})]}),e.jsx("button",{type:"button",className:d,onClick:()=>U(g+1),disabled:!l||g>=L,"aria-label":"Next page",children:e.jsx(me,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",className:d,onClick:()=>q(-1),disabled:!l,"aria-label":"Zoom out",children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsxs("select",{value:"",onChange:t=>ie(t.target.value),disabled:!l,"aria-label":"Zoom",className:"rounded bg-white/15 px-1 py-0.5 text-white outline-none [&>option]:text-black",children:[e.jsxs("option",{value:"",disabled:!0,hidden:!0,children:[Math.round(ne*100),"%"]}),e.jsx("option",{value:"page-width",children:"Fit width"}),e.jsx("option",{value:"page-fit",children:"Fit page"}),e.jsx("option",{value:"1",children:"100%"}),e.jsx("option",{value:"1.5",children:"150%"}),e.jsx("option",{value:"2",children:"200%"})]}),e.jsx("button",{type:"button",className:d,onClick:()=>q(1),disabled:!l,"aria-label":"Zoom in",children:e.jsx(je,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("label",{className:"flex items-center gap-1 rounded bg-white/15 px-1.5 py-0.5 focus-within:bg-white/25",children:[e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0 text-white/80","aria-hidden":"true"}),e.jsx("input",{ref:O,type:"search",value:h,onChange:t=>re(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),N("again",t.shiftKey))},placeholder:"Search","aria-label":"Search in document",disabled:!l,className:"w-24 bg-transparent text-white placeholder:text-white/60 outline-none sm:w-36"})]}),h&&e.jsx("span",{className:`whitespace-nowrap text-xs ${K?"text-red-200":"text-white/80"}`,"aria-live":"polite",children:K?"No matches":M.total?`${M.current}/${M.total}`:""}),e.jsx("button",{type:"button",className:d,onClick:()=>N("again",!0),disabled:!l||!h,"aria-label":"Previous match",children:e.jsx(ke,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",className:d,onClick:()=>N("again"),disabled:!l||!h,"aria-label":"Next match",children:e.jsx(fe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[!x&&e.jsx("button",{type:"button",className:d,onClick:()=>{le()},disabled:!l||!!j,"aria-label":"Print",children:j?e.jsx(Q,{className:"h-4 w-4 animate-spin"}):e.jsx(Ce,{className:"h-4 w-4"})}),w&&e.jsx("a",{href:i,download:!0,target:"_blank",rel:"noopener noreferrer",className:d,"aria-label":"Download PDF",title:"Download",children:e.jsx(X,{className:"h-4 w-4"})}),x&&w&&e.jsx("a",{href:we(i),target:"_blank",rel:"noopener noreferrer",className:d,"aria-label":"Open in a new tab",title:"Open in a new tab",children:e.jsx(xe,{className:"h-4 w-4"})})]})]}),j&&e.jsx("div",{className:"bg-[#093458] px-3 py-1 text-xs text-white",role:"status",children:j}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("div",{ref:T,className:"pdf-viewer-container absolute inset-0 overflow-auto",children:e.jsx("div",{ref:A,className:"pdfViewer"})}),f==="loading"&&w&&e.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 text-white",role:"status",children:[e.jsx(Q,{className:"h-8 w-8 animate-spin","aria-hidden":"true"}),e.jsxs("span",{className:"text-sm",children:["Loading document",Z?` · ${Z}%`:"â¦"]})]}),f==="error"&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-md rounded-lg bg-white p-6 text-center text-sm text-gray-700 shadow-lg",role:"alert",children:w?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"This document could not be shown here."}),e.jsx("p",{className:"mt-2",children:"You can still download it and open it on your device."}),e.jsxs("a",{href:i,download:!0,target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-flex items-center gap-2 rounded-full bg-[#0b4173] px-5 py-2 font-medium text-white hover:bg-[#093458]",children:[e.jsx(X,{className:"h-4 w-4"})," Download PDF"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-gray-900",children:"This document cannot be opened in the ICSI viewer."}),e.jsx("a",{href:"/",className:"mt-4 inline-block text-[#0b4173] underline",children:"Go to the ICSI homepage"})]})})})]})]}),v.length>0&&e.jsx("div",{className:"pdf-print-pages","aria-hidden":"true",children:v.map((t,a)=>e.jsx("img",{src:t,alt:`Page ${a+1}`},t))})]})};export{Me 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.