1import{g as V,G as $}from"./pdf-DkPqwpy7.js";$.workerSrc=new URL("/assets/pdf.worker.min-B_fnEKel.mjs",import.meta.url).toString();function G(t){const l=t.getContext("2d");if(!l)return!0;const o=20,n=Math.max(0,Math.floor(t.width/2)-o/2),h=Math.max(0,Math.floor(t.height/2)-o/2),i=Math.min(o,t.width),u=Math.min(o,t.height),a=l.getImageData(n,h,i,u).data,g=a[0],f=a[1],s=a[2];let r=!0;for(let c=4;c<a.length;c+=4)if(a[c]!==g||a[c+1]!==f||a[c+2]!==s){r=!1;break}return r}async function L(t,l){const o=await new Promise(h=>{t.toBlob(i=>h(i),"image/jpeg",l)});if(o&&o.size>0)return{blob:o,ext:"jpg"};console.warn("JPEG conversion failed, falling back to PNG");const n=await new Promise(h=>{t.toBlob(i=>h(i),"image/png")});if(n&&n.size>0)return{blob:n,ext:"png"};throw new Error("Canvas to Blob conversion failed for both JPEG and PNG")}async function D(t,l={},o){const{scale:n=2.5,quality:h=.95,maxWidth:i=3e3}=l,u=await t.arrayBuffer(),p=await V({data:u,cMapUrl:"/cmaps/",cMapPacked:!0,standardFontDataUrl:"/standard_fonts/",disableFontFace:!1}).promise,a=p.numPages,g=[],f=t.name.replace(/\.pdf$/i,"");for(let s=1;s<=a;s++){o?.({currentPage:s,totalPages:a});const r=await p.getPage(s),c=r.getViewport({scale:n});let w=n;c.width>i&&(w=i/c.width*n);const b=w!==n?r.getViewport({scale:w}):c,e=document.createElement("canvas"),P=Math.floor(b.width),v=Math.floor(b.height);e.width=P,e.height=v;const y=e.getContext("2d",{alpha:!1,willReadFrequently:!0});if(y.fillStyle="#FFFFFF",y.fillRect(0,0,P,v),await r.render({canvas:e,canvasContext:y,viewport:b}).promise,G(e)){console.warn(`Page ${s}: rendered canvas appears blank, retrying with higher scale...`);const k=w*1.5,d=r.getViewport({scale:k}),m=Math.min(Math.floor(d.width),i),B=Math.floor(d.height*(m/d.width));e.width=m,e.height=B;const x=e.getContext("2d",{alpha:!1});x.fillStyle="#FFFFFF",x.fillRect(0,0,m,B);const j=r.getViewport({scale:k*(m/d.width)});await r.render({canvas:e,canvasContext:x,viewport:j}).promise}const{blob:M,ext:F}=await L(e,h),C=a===1?`${f}.${F}`:`${f}_p${s}.${F}`,U=F==="png"?"image/png":"image/jpeg",R=new File([M],C,{type:U}),S=URL.createObjectURL(M);g.push({pageNumber:s,file:R,previewUrl:S}),r.cleanup(),e.width=0,e.height=0}return p.destroy(),g}function E(t){return t.type==="application/pdf"||t.name.toLowerCase().endsWith(".pdf")}function W(t){for(const l of t)URL.revokeObjectURL(l.previewUrl)}export{D as convertPdfToImages,E as isPdfFile,W as revokePdfPreviews};
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.