/* esm.sh - @embedpdf/plugin-render@2.15.1/react */
import{jsx as d}from"../../../../react@19.3.1/es2022/jsx-runtime.mjs";import{useState as P,useRef as b,useMemo as c,useEffect as v,Fragment as j}from"../../../../react@19.3.1/es2022/react.mjs";import{ignore as k,PdfErrorCode as w}from"../../../models@2.15.1/es2022/models.mjs";import{useCapability as y,usePlugin as C,useDocumentState as S}from"../../../core@2.15.1/X-ZHJlYWN0LWRvbUAxOS4zLjEscmVhY3RAMTkuMy4x/es2022/react.mjs";import{RenderPlugin as R}from"./plugin-render.mjs";export*from"./plugin-render.mjs";var z=()=>C(R.id),D=()=>y(R.id);function A({documentId:n,pageIndex:t,scale:o,dpr:s,style:g,...p}){let{provides:u}=D(),e=S(n),[i,L]=P(null),r=b(null),h=c(()=>e&&e.pageRefreshVersions[t]||0,[e,t]),l=c(()=>o!==void 0?o:e?.scale??1,[o,e?.scale]),a=c(()=>s!==void 0?s:window.devicePixelRatio,[s]);return v(()=>{if(!u)return;let f=u.forDocument(n).renderPage({pageIndex:t,options:{scaleFactor:l,dpr:a}});return f.wait(U=>{let m=URL.createObjectURL(U);L(m),r.current=m},k),()=>{r.current?(URL.revokeObjectURL(r.current),r.current=null):f.abort({code:w.Cancelled,message:"canceled render task"})}},[n,t,l,a,u,h]),d(j,{children:i&&d("img",{src:i,onLoad:()=>{r.current&&(URL.revokeObjectURL(r.current),r.current=null)},...p,style:{width:"100%",height:"100%",...g||{}}})})}export{A as RenderLayer,D as useRenderCapability,z as useRenderPlugin};
//# sourceMappingURL=react.mjs.map