1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`f071606d256de3b2e5001e8c91951dd823c43bd6`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`be6d8842-6b24-4892-b4b7-83ddaa4e58c1`,e._sentryDebugIdIdentifier=`sentry-dbid-be6d8842-6b24-4892-b4b7-83ddaa4e58c1`)}catch{}})();import{o as e,r as t}from"./5v_HMQ8i.js";import{Gn as n,Kn as r,Ru as i,zu as a}from"./BikK9A2q.js";import{a as o}from"./wL3AHm3v.js";import{$i as s,Ji as c,_r as l,in as u,nr as d,vn as f}from"./D_H8ZTso.js";import{t as p}from"./CPV9fQTj.js";import{b as m}from"./D6cG3fmh.js";import"./BA1tyIjY.js";import{f as h}from"./DHJ1wkje.js";import{t as g}from"./z7kLMC6R.js";import{f as _}from"./B6Brq3f8.js";import{l as v}from"./BV7Hly_O2.js";import{t as y}from"./C6Tg0h2_2.js";import{t as b}from"./CGNTf29z2.js";import{i as x}from"./C9A_aJcr2.js";import{t as S}from"./DdBXt_cZ.js";var C=e(a(),1),w=e(h(),1);function T(e,t){return Number.isInteger(e)&&e>0&&(t===void 0||e<=t)}function E({width:e,height:t,maxPixels:n,maxDimension:r}){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||r!==void 0&&(e>r||t>r)?!1:n===void 0||e*t<=n}function D(e,t,n){return Math.min(n,Math.max(t,e))}function O({containerWidth:e,containerHeight:t,contentWidth:n,contentHeight:r,pageHeights:i,padding:a=50}){if(e===0||t===0||n===0)return null;let o=e-a,s=t-a,c=o/n,l,u=i[0];if(i.length===1){let e=s/u;l=Math.min(c,e)}else{let e=(s-30)/u;l=Math.min(c,e)}l=Math.min(5,Math.max(.5,l));let d=n*l,f=r*l,p=(e-d)/2,m=f<=t?(t-f)/2:16;return{scale:l,centerX:p,centerY:m}}function k(e){let t=e.getBoundingClientRect(),n=Math.max(0,t.top),r=Math.min(window.innerHeight,t.bottom);return{width:t.width,height:Math.max(0,r-n)}}function A({canvasDimensions:e,containerHeight:t,containerWidth:n,region:r}){if(n<=0||t<=0||e.width<=0||e.pageHeights.length===0||r.width<=0||r.height<=0)return null;let i=D(Math.round(r.page??1)-1,0,e.pageHeights.length-1),a=e.pageHeights[i];if(!a)return null;let o=D(r.x,0,1),s=D(r.y,0,1),c=Math.min(r.width,1-o),l=Math.min(r.height,1-s),u=e.width*c,d=a*l;if(u<=0||d<=0)return null;let f=e.pageHeights.slice(0,i).reduce((e,t)=>e+t+10,0),p=e.width*(o+c/2),m=f+a*(s+l/2),h=Math.max(0,r.padding??32),g=Math.max(1,n-h*2),_=Math.max(1,t-h*2),v=D(r.minScale??.5,.5,5),y=D(Math.max(r.maxScale??3,v),v,5),b=D(Math.min(g/u,_/d,y),v,y),x=e.width*o,S=x+u;return{scale:b,positionX:r.horizontalAlignment===`start`?h-x*b:r.horizontalAlignment===`end`?n-h-S*b:n/2-p*b,positionY:t/2-m*b}}var j=!1;function M(){j||typeof window>`u`||(w.GlobalWorkerOptions&&(w.GlobalWorkerOptions.workerSrc=_.pdfjsWorkerUrl??``),j=!0)}function N(){return{canvasRef:(0,C.useRef)(null),textLayerContainerRef:(0,C.useRef)(null),pdfDocRef:(0,C.useRef)(null),transformRef:(0,C.useRef)(null),hasManuallyZoomedRef:(0,C.useRef)(!1)}}function P({pdfData:e,canvasRef:t,textLayerContainerRef:n,enableTextSelection:r,mode:i,maxPages:a,maxCanvasPixels:o,maxCanvasDimension:s}){let c=(0,C.useRef)(null),[l,u]=(0,C.useState)(1),[d,f]=(0,C.useState)({width:0,height:0,pageHeights:[]}),[p,m]=(0,C.useState)(!1),h=b(l,300),_=(0,C.useCallback)(async(c=1)=>{if(!t.current||!e||e.byteLength===0||r&&!n.current)return null;let l=t.current,u=n.current,d=l.getContext(`2d`);if(!d)return null;m(!1);try{M();let t=await w.getDocument({data:new Uint8Array(e),isEvalSupported:!1}).promise,n=t.numPages;if(!T(n,a))throw await t.destroy(),Error(`PDF exceeds the preview page limit`);let p=window.devicePixelRatio||1,m=Math.min(5,Math.max(2,p)*c),h=0,g=0,_=[];for(let e=0;e<n;e++){let n=(await t.getPage(e+1)).getViewport({scale:1});g=Math.max(g,Math.round(n.width));let r=Math.round(n.height);_.push(r),h+=r+10}let v=Math.round(g*m),y=Math.round(h*m);if(!E({width:v,height:y,maxPixels:o,maxDimension:s}))throw await t.destroy(),Error(`PDF exceeds the preview canvas limit`);let b=new OffscreenCanvas(v,y),x=b.getContext(`2d`);if(!x)return null;let S=[],C=0;for(let e=0;e<n;e++){let n=await t.getPage(e+1),i=n.getViewport({scale:1}),a=n.getViewport({scale:m}),o=Math.round(i.width),s=Math.round(i.height),c=Math.round(a.width),l=Math.round(a.height),u=new OffscreenCanvas(c,l),d=u.getContext(`2d`);
1if(d){if(await n.render({canvasContext:d,viewport:a}).promise,x.drawImage(u,0,Math.round(C*m),c,l),r){let e=await n.getTextContent(),t=document.createElement(`div`);t.className=`textLayer`,t.style.width=`${o}px`,t.style.height=`${s}px`,t.style.top=`${C}px`,t.style.left=`0`,t.style.position=`absolute`;let r=w.renderTextLayer({textContent:e,container:t,viewport:i,textDivs:[],enhanceTextSelection:!0});await r.promise,r.expandTextDivs(!0),S.push(t)}C+=s+10}}return l.width=b.width,l.height=b.height,i!==`sticky`&&(l.style.width=`${g}px`,l.style.height=`${h}px`),d.drawImage(b,0,0),u&&(u.innerHTML=``,S.forEach(e=>u.appendChild(e))),f({width:g,height:h,pageHeights:_}),t}catch(e){return g.error(`Error rendering PDF:`,e),m(!0),null}},[e,r,t,n,i,a,o,s]);return(0,C.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{if(t)return;c.current?.destroy(),c.current=null;let e=await _(Math.min(5,Math.max(1,h)));if(t){e?.destroy();return}c.current=e})(),()=>{t=!0,c.current?.destroy()}},[e,h,_]),{scale:l,setScale:u,canvasDimensions:d,renderError:p,debouncedScale:h}}function F({transformRef:e,canvasDimensions:t,hasManuallyZoomedRef:n,setScale:r,enabled:i=!0}){let a=(0,C.useCallback)(()=>{if(!e.current)return;let{wrapperComponent:n}=e.current.instance;if(!n||t.width===0||t.pageHeights.length===0)return;let{width:i,height:a}=k(n),o=O({containerWidth:i,containerHeight:a,contentWidth:t.width,contentHeight:t.height,pageHeights:t.pageHeights});o&&(e.current.setTransform(o.centerX,o.centerY,o.scale,200),r(o.scale))},[t,r,e]),o=(0,C.useCallback)(i=>{if(!e.current)return;let{wrapperComponent:a}=e.current.instance;if(!a)return;let{width:o,height:s}=k(a),c=A({canvasDimensions:t,containerHeight:s,containerWidth:o,region:i});c&&(n.current=!0,e.current.setTransform(c.positionX,c.positionY,c.scale,200),r(c.scale))},[t,n,r,e]),s=(0,C.useCallback)(()=>{n.current=!1,a()},[a,n]);return(0,C.useEffect)(()=>{if(!i)return;let t=e.current?.instance.wrapperComponent;if(!t)return;let r=null,o=new ResizeObserver(()=>{r&&clearTimeout(r),r=setTimeout(()=>{n.current||a()},150)});return o.observe(t),()=>{r&&clearTimeout(r),o.disconnect()}},[i,a,n,e]),{fit:s,fitToContainer:a,focusRegion:o}}var I=i(),L={"top-left":`top-2 left-2`,"top-right":`top-2 right-2`,"bottom-left":`bottom-2 left-2`,"bottom-right":`bottom-2 right-2`},R={DOWNLOAD_PDF:`DOWNLOAD_PDF`,OPEN_PDF_IN_NEW_TAB:`OPEN_PDF_IN_NEW_TAB`,ZOOM_CONTROLS:`ZOOM_CONTROLS`,RESET_ZOOM:`RESET_ZOOM`,FIT_TO_WIDTH:`FIT_TO_WIDTH`},z=(e,t)=>({position:e,component:t}),B={[R.ZOOM_CONTROLS]:z(`top-left`,({scale:e,zoomIn:t,zoomOut:n})=>(0,I.jsxs)(`div`,{className:`flex flex-row items-center gap-2`,children:[(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>n(),className:`h-8 w-8 p-0`,children:(0,I.jsx)(d,{className:`h-4 w-4`})}),(0,I.jsxs)(`span`,{className:`text-sm font-medium min-w-[3rem] text-center`,children:[Math.round(e*100),`%`]}),(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>t(),className:`h-8 w-8 p-0`,children:(0,I.jsx)(f,{className:`h-4 w-4`})})]})),[R.DOWNLOAD_PDF]:z(`top-right`,({pdf:e,pdfFileName:t})=>!e||!t?null:(0,I.jsx)(S,{text:`Download the document`,children:(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>{let n=new Blob([e],{type:`application/pdf`}),r=URL.createObjectURL(n);v(r,t),URL.revokeObjectURL(r)},className:`h-8 w-8 p-0`,children:(0,I.jsx)(s,{className:`h-4 w-4`})})})),[R.OPEN_PDF_IN_NEW_TAB]:z(`top-right`,({pdf:e})=>e?(0,I.jsx)(S,{text:`Open in a new tab`,children:(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));window.open(t,`_blank`),setTimeout(()=>URL.revokeObjectURL(t),5e3)},className:`h-8 w-8 p-0`,children:(0,I.jsx)(c,{className:`h-4 w-4`})})}):null),[R.RESET_ZOOM]:z(`top-right`,({resetTransform:e})=>(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>e(),className:`h-8 w-8 p-0`,children:(0,I.jsx)(u,{className:`h-4 w-4`})})),[R.FIT_TO_WIDTH]:z(`top-right`,({fitToContainer:e})=>(0,I.jsx)(S,{text:`Fit to container`,children:(0,I.jsx)(m,{appearance:`ghost`,size:`sm`,onClick:()=>e(),className:`h-8 w-8 p-0`,children:(0,I.jsx)(l,{className:`h-4 w-4`})})}))},V=({controls:e,controlContext:t})=>(0,I.jsx)(I.Fragment,{children:Object.keys(L).map(n=>{let r=e.filter(e=>e.position===n);return r.length===0?null:(0,I.jsx)(`div`,{className:p(`absolute z-10 flex items-center gap-2 bg-gradient-to-b from-white/90 to-white/80 backdrop-blur-sm rounded-lg shadow-sm p-1 ring-1 ring-black/5`,L[n]),children:r.map((e,n)=>(0,I.jsx)(`div`,{children:e.component(t)},n))},n)})});function H(e,t,n){let r=document.createRange();try{r.selectNodeContents(t);let i=r.getBoundingClientRect();return e.clientX>=i.left-n&&e.clientX<=i.right+n&&e.clientY>
1=i.top-n&&e.clientY<=i.bottom+n}catch{return!1}finally{r.detach()}}var U=({textLayerContainerRef:e,dimensions:t})=>(0,I.jsx)(`div`,{ref:e,className:`absolute top-0 left-0 z-10`,style:{width:t.width,height:t.height},onMouseDown:e=>{let t=e.target;t.tagName===`SPAN`&&H(e,t,15)?e.stopPropagation():window.getSelection()?.removeAllRanges()},onMouseMove:e=>{let t=e.target;t.tagName===`SPAN`&&(t.style.cursor=H(e,t,15)?`text`:`grab`)}}),W=({pdfData:e,pdfFileName:t,controls:n,canvasRef:r,textLayerContainerRef:i,canvasDimensions:a,enableTextSelection:o,canvasClassName:s})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{controls:n,controlContext:{pdf:e,pdfFileName:t,scale:1,zoomIn:()=>{},zoomOut:()=>{},resetTransform:()=>{},fitToContainer:()=>{}}}),(0,I.jsx)(`canvas`,{ref:r,className:s}),o&&(0,I.jsx)(U,{textLayerContainerRef:i,dimensions:a})]}),G=({canvasRef:e,textLayerContainerRef:t,canvasDimensions:n,enableTextSelection:r,canvasClassName:i})=>(0,I.jsxs)(`div`,{className:p(`relative border border-gray-200 rounded shadow-sm overflow-hidden bg-white`,i),style:{width:n.width||`auto`,height:n.height||`auto`},children:[(0,I.jsx)(`canvas`,{ref:e,className:i,style:{display:`block`,width:n.width,height:n.height}}),r&&(0,I.jsx)(U,{textLayerContainerRef:t,dimensions:n})]}),K=({pdfData:e,pdfFileName:t,controls:i,canvasRef:a,textLayerContainerRef:o,canvasDimensions:s,enableTextSelection:c,transformRef:l,scale:u,setScale:d,hasManuallyZoomedRef:f,initialScale:p,wrapperStyle:m,contentStyle:h,canvasClassName:g,autoFit:_=!0,viewportRef:v})=>{let{fit:y,fitToContainer:b,focusRegion:x}=F({transformRef:l,canvasDimensions:s,hasManuallyZoomedRef:f,setScale:d,enabled:_});return(0,C.useImperativeHandle)(v,()=>({fit:y,focusRegion:x}),[y,x]),(0,I.jsx)(`div`,{className:`w-full h-full`,children:(0,I.jsx)(r,{ref:l,initialScale:p,minScale:.5,maxScale:5,smooth:!0,wheel:{step:.1},doubleClick:{disabled:!1},onTransformed:(e,t)=>{d(t.scale)},onWheel:()=>{f.current=!0},onPinchingStart:()=>{f.current=!0},children:({zoomIn:r,zoomOut:l,resetTransform:d})=>(0,I.jsxs)(`div`,{className:`relative w-full h-full`,children:[(0,I.jsx)(V,{controls:i,controlContext:{pdf:e,pdfFileName:t,scale:u,zoomIn:()=>{f.current=!0,r()},zoomOut:()=>{f.current=!0,l()},resetTransform:d,fitToContainer:b}}),(0,I.jsx)(n,{wrapperStyle:{width:`100%`,height:`100%`,alignItems:`center`,...m},contentStyle:{width:`fit-content`,height:`fit-content`,...h},children:(0,I.jsx)(G,{canvasRef:a,textLayerContainerRef:o,canvasDimensions:s,enableTextSelection:c,canvasClassName:g})})]})})})},q=t({PdfPreview:()=>J});function J({pdf:e,pdfUrl:t,pdfFileId:n,error:r,loading:i,className:a,controls:s=[],pdfFileName:c,enableTextSelection:l=!1,wrapperStyle:u,contentStyle:d,initialScale:f=1,mode:m=`transform`,canvasClassName:h,autoFit:g=!0,viewportRef:_,maxPages:v,maxCanvasPixels:b,maxCanvasDimension:S}){let[w,T]=(0,C.useState)(null),[E,D]=(0,C.useState)(null);(0,C.useEffect)(()=>{if(T(null),D(null),!t)return;let e=new AbortController;return fetch(t,{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Could not load pdf file`);T(new Uint8Array(await e.arrayBuffer()))}).catch(t=>{e.signal.aborted||D(t instanceof Error?t.message:`Could not load pdf file`)}),()=>e.abort()},[t]);let{data:O,isLoading:k,error:A}=x(n,!1),j=O?o(O):w??e,M=i||k||!!(t&&!w&&!E),F=A?`Could not load pdf file`:E??r,{canvasRef:L,textLayerContainerRef:R,transformRef:z,hasManuallyZoomedRef:B}=N(),{scale:V,setScale:H,canvasDimensions:U,renderError:G}=P({pdfData:j,canvasRef:L,textLayerContainerRef:R,enableTextSelection:l,mode:m,maxPages:v,maxCanvasPixels:b,maxCanvasDimension:S});if((0,C.useEffect)(()=>{m!==`sticky`&&(B.current=!1)},[j,m,B]),M)return(0,I.jsx)(y,{className:p(`w-full h-full min-h-[400px] rounded-lg`,a)});if(!j||G)return(0,I.jsx)(`div`,{className:p(`flex items-center justify-center bg-transparent rounded-lg w-full h-full min-h-[400px]`,a),children:F?(0,I.jsx)(`p`,{className:`text-gray-500`,children:F}):G?(0,I.jsx)(`p`,{className:`text-gray-500`,children:`Couldn't display PDF`}):(0,I.jsx)(`p`,{className:`text-gray-500`,children:`No document available`})});let q={pdfData:j,pdfFileName:c,controls:s,canvasRef:L,textLayerContainerRef:R,canvasDimensions:U,enableTextSelection:l,canvasClassName:h};return m===`sticky`?(0,I.jsx)(`div`,{className:p(`relative`,a),children:(0,I.jsx)(W,{...q})}):(0,I.jsx)(`div`,{className:p(`bg-[#fbfbf8] rounded-lg w-full h-full overflow-hidden relative`,a),children:(0,I.jsx)(K,{...q,transformRef:z,scale:V,setScale:H,hasManuallyZoomedRef:B,initialScale:f,wrapperStyle:u,contentStyle:d,autoFit:g,viewportRef:_})})}export{q as n,B as r,J as t};
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.