@copio/sdk 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cdn.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var td=Object.defineProperty;var Es=(s,t,e)=>()=>{if(e)throw e[0];try{return s&&(t=s(s=0)),t}catch(i){throw e=[i],i}};var yi=(s,t)=>{for(var e in t)td(s,e,{get:t[e],enumerable:!0})};var nl={};yi(nl,{Path2D:()=>Lu,createCanvas:()=>Ru,default:()=>Mu});var Mu,Ru,Lu,rl=Es(()=>{Mu={},Ru=()=>null,Lu=globalThis.Path2D||class{}});var vh={};yi(vh,{Path2D:()=>Nu,createCanvas:()=>Ou,default:()=>Fu});var Fu,Ou,Nu,wh=Es(()=>{Fu={},Ou=()=>null,Nu=globalThis.Path2D||class{}});var xh={};yi(xh,{Path2D:()=>Uu,createCanvas:()=>$u,default:()=>Bu});var Bu,$u,Uu,Ah=Es(()=>{Bu={},$u=()=>null,Uu=globalThis.Path2D||class{}});var Sh={};yi(Sh,{Path2D:()=>ju,createCanvas:()=>Hu,default:()=>zu});var zu,Hu,ju,Eh=Es(()=>{zu={},Hu=()=>null,ju=globalThis.Path2D||class{}});var Ch={};yi(Ch,{Path2D:()=>Wu,createCanvas:()=>Gu,default:()=>Vu});var Vu,Gu,Wu,_h=Es(()=>{Vu={},Gu=()=>null,Wu=globalThis.Path2D||class{}});var kh={};yi(kh,{Path2D:()=>Ku,createCanvas:()=>Xu,default:()=>qu});var qu,Xu,Ku,Th=Es(()=>{qu={},Xu=()=>null,Ku=globalThis.Path2D||class{}});var Oo={};yi(Oo,{BUILD_DATE:()=>qc,COPIO_EVENTS:()=>te,Canvas2DAdapter:()=>li,CopioAddEditDialog:()=>qn,CopioCarousel:()=>Wn,CopioDocOcrDialog:()=>ir,CopioEngine:()=>cs,CopioHeader:()=>Kn,CopioImages:()=>$n,CopioLoader:()=>Yn,CopioRow:()=>Xn,CopioScanner:()=>Zn,CopioSyncDialog:()=>sr,DocRepository:()=>_i,Document:()=>En,ImageProcessorPort:()=>qe,IndexedDbStorageAdapter:()=>Ji,LicenseManager:()=>Fo,MemoryStorageAdapter:()=>vi,NullImageProcessorAdapter:()=>as,NullOcrAdapter:()=>Pe,NullPdfAdapter:()=>We,NullSyncAdapter:()=>or,OcrPort:()=>oi,Page:()=>ls,PdfKitAdapter:()=>vs,PdfPort:()=>ai,PeerJsAdapter:()=>rr,SUPPORTED_LANGUAGES:()=>Lo,ScanSession:()=>Cn,StoragePort:()=>Ue,SyncManager:()=>Ui,SyncPort:()=>ui,TesseractWasmAdapter:()=>ys,VERSION:()=>Xc,adoptScannerStyles:()=>Mo,clearNotifications:()=>ol,createDefaultAdapter:()=>Ls,dispatchCopioEvent:()=>lo,docRepository:()=>Fa,exportDocumentAsImages:()=>xl,exportDocumentAsMarkdown:()=>Al,exportDocumentAsPdf:()=>nr,extractExif:()=>zs,fileToBase64:()=>Hs,getAssetBase:()=>eo,getContainer:()=>Fi,getCroppedSrc:()=>Ra,getOcrWorker:()=>tr,getRegisteredService:()=>Ti,getScannerStyleSheet:()=>Io,hasActiveEdits:()=>ao,loadCropper:()=>io,loadJsZip:()=>so,loadMarked:()=>ki,loadPdfKit:()=>Vs,loadPeerJs:()=>no,loadQrCode:()=>ro,loadScript:()=>ri,loadTesseract:()=>oo,normalizeEditStack:()=>_n,notify:()=>Pt,randomId:()=>we,recognizeDocumentPages:()=>en,recognizeImageText:()=>er,registerService:()=>Pi,renderPdfPagesToDataUrls:()=>Ri,resolveAssetUrl:()=>ni,rotateSrc:()=>Ma,scannerCss:()=>Qn,setAssetBase:()=>os,setContainer:()=>Li,terminateOcrWorker:()=>bs,thresholdSrc:()=>Ia});var Ue=class{async init(){throw new Error("StoragePort.init() must be implemented by adapter")}async listDocs(){throw new Error("StoragePort.listDocs() must be implemented by adapter")}async getDoc(t){throw new Error("StoragePort.getDoc() must be implemented by adapter")}async saveDoc(t,e){throw new Error("StoragePort.saveDoc() must be implemented by adapter")}async deleteDoc(t){throw new Error("StoragePort.deleteDoc() must be implemented by adapter")}async savePage(t,e,i){throw new Error("StoragePort.savePage() must be implemented by adapter")}async getPage(t,e){throw new Error("StoragePort.getPage() must be implemented by adapter")}async deletePage(t,e){throw new Error("StoragePort.deletePage() must be implemented by adapter")}subscribe(t){return()=>{}}};var vi=class extends Ue{#t=new Map;#e=new Map;#i=new Set;constructor(){super()}async init(){return{kind:"memory",persistent:!1}}listDocsSync(){return Array.from(this.#t.values()).map(t=>({id:t.id,name:t.name,pages:Array.isArray(t.pages)?[...t.pages]:[]}))}async listDocs(){return this.listDocsSync()}getDocSync(t){let e=this.#t.get(t);return e?{id:e.id,name:e.name,pages:Array.isArray(e.pages)?[...e.pages]:[]}:null}async getDoc(t){return this.getDocSync(t)}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=[];if(Array.isArray(e.pages))i=[...e.pages];else if(typeof e.pages=="string")try{i=JSON.parse(e.pages)}catch{i=[]}this.#t.set(t,{id:t,name:e.name||"",pages:i}),this.#n()}async deleteDoc(t){this.#t.delete(t);let e=`${t}/`;for(let i of this.#e.keys())i.startsWith(e)&&this.#e.delete(i);this.#n()}async savePage(t,e,i){this.#e.set(`${t}/${e}`,i);let n=this.#t.get(t);if(n){let o=n.pages.findIndex(l=>l.id===e);if(o>=0)typeof i=="object"&&i!==null&&!(i instanceof Blob)?n.pages[o]={...n.pages[o],...i}:n.pages[o]={...n.pages[o],src:i};else{let l=typeof i=="object"&&i!==null&&!(i instanceof Blob)?{id:e,...i}:{id:e,src:i};n.pages.push(l)}}this.#n()}async getPage(t,e){if(this.#e.has(`${t}/${e}`))return this.#e.get(`${t}/${e}`);let i=this.#t.get(t);if(i){let n=i.pages.find(o=>o.id===e);if(n)return n.src??n}return null}async deletePage(t,e){this.#e.delete(`${t}/${e}`);let i=this.#t.get(t);i&&(i.pages=i.pages.filter(n=>n.id!==e)),this.#n()}subscribe(t){return this.#i.add(t),()=>{this.#i.delete(t)}}clear(){this.#t.clear(),this.#e.clear(),this.#n()}#n(){for(let t of this.#i)try{t()}catch(e){console.error("Error in MemoryStorageAdapter subscriber:",e)}}};var Si=s=>typeof s;var Yl=Si(""),ed=Si(!0),Jl=Si(0),id=Si(Si),xr="type",Hi="default",Ko="Listener",Hl="Result",Yo="add",ji="Has",hn="Ids",Ai="Table",jl=Ai+"s",sd=Ai+hn,Ts="Row",Ql=Ts+"Count",Zl=Ts+hn,nd="Sorted"+Ts+hn,an="Cell",Cr=an+hn,_r="Value",Vl=_r+"s",rd=_r+hn,Bt=s=>""+s;var od=(s,t="",e)=>s.split(t,e),Jo=globalThis,Ir=Math,jo=Ir.max,Vo=Ir.min,ad=Ir.floor,tc=isFinite,St=s=>s==null,$t=(s,t,e)=>St(s)?e?.():t(s),ec=s=>s==Yl||s==ed,ld=s=>Si(s)==Yl,ze=s=>Si(s)==id,Ps=s=>Array.isArray(s),Qo=(s,t,e)=>s.slice(t,e),Ce=s=>s.length,ic=()=>{};var Go=async(s,t,e)=>{try{return await s()}catch(i){t?.(i)}},Zo=(s,t)=>s.includes(t),kr=(s,t)=>s.every(t),sc=(s,t)=>Ce(s)===Ce(t)&&kr(s,((e,i)=>t[i]===e)),Gl=(s,t)=>kr(s,((e,i)=>i==0||t(s[i-1],e)<=0)),ta=(s,t)=>s.sort(t),ve=(s,t)=>s.forEach(t),Wi=(s,t)=>s.map(t),Wl=s=>nc(s,((t,e)=>t+e),0),ln=s=>Ce(s)==0,nc=(s,t,e)=>s.reduce(t,e),ye=(s,...t)=>s.push(...t),ql=s=>s.pop(),rc=s=>s.shift(),_s=s=>{let t=Si(s);return ec(t)||t==Jl&&tc(s)?t:void 0};var Tr=(s,t,e,i,n)=>St(n)?s.delCell(t,e,i,!0):s.setCell(t,e,i,n),ea=(s,t,e)=>St(e)?s.delValue(t):s.setValue(t,e),ra=s=>t=>nc(Ds(t),((e,i)=>e+s(i)),0),Is=s=>s?.size??0,qi=ra(Is),Ze=ra(qi),Wo=ra(Ze),Ht=(s,t)=>s?.has(t)??!1,vt=s=>St(s)||Is(s)==0,Ds=s=>[...s?.values()??[]],ks=s=>s.clear(),yt=(s,t)=>s?.forEach(t),je=(s,t)=>s?.delete(t),Ei=Object,Xl=s=>Ei.getPrototypeOf(s),cd=Ei.isFrozen,oc=Ei.entries,Pr=s=>!St(s)&&$t(Xl(s),(t=>t==Ei.prototype||St(Xl(t))),(()=>!0)),hd=Ei.keys,Ms=Ei.freeze,dd=(s=[])=>Ei.fromEntries(s),on=(s,t)=>t in s,ac=(s,t)=>(delete s[t],s),ud=(s,t)=>ve(oc(s),(([e,i])=>t(i,e))),Qe=(s,t)=>dd(((e,i)=>Wi(oc(e),(([n,o])=>i(o,n))))(s,((e,i)=>[i,t(e,i)]))),He=s=>Pr(s)&&(t=>Ce(hd(t)))(s)==0;var wi=(s,t,e,i=0)=>St(s)||!Pr(s)||!i&&He(s)||cd(s)?(e?.(),!1):(ud(s,((n,o)=>{t(n,o)||ac(s,o)})),!!i||!He(s)),ft=s=>new Map(s),Gi=s=>[...s?.keys()??[]],ht=(s,t)=>s?.get(t),Yt=(s,t)=>yt(s,((e,i)=>t(i,e))),bt=(s,t,e)=>St(e)?(je(s,t),s):s?.set(t,e),zt=(s,t,e,i)=>(Ht(s,t)?i?.(ht(s,t)):bt(s,t,e()),ht(s,t)),Vi=(s,t,e,i=bt)=>(Qe(t,((n,o)=>e(s,o,n))),Yt(s,(n=>on(t,n)?0:i(s,n))),s),be=(s,t,e,i)=>{let n={};return yt(s,((o,l)=>{if(!e?.(o,l)){let h=t?t(o,l):o;i?.(h)||(n[l]=h)}})),n},ia=(s,t,e)=>be(s,(i=>be(i,t,e)),vt,He),Ar=(s,t,e)=>be(s,(i=>ia(i,t,e)),vt,He),xi=(s,t)=>{let e=ft();return yt(s,((i,n)=>e.set(n,t?.(i)??i))),e},sa=s=>xi(s,xi),qo=s=>xi(s,sa),cn=(s,t,e,i,n=0)=>$t((e?zt:ht)(s,t[n],n>Ce(t)-2?e:ft),(o=>{if(n>Ce(t)-2)return i?.(o)&&bt(s,t[n]),o;let l=cn(o,t,e,i,n+1);return vt(o)&&bt(s,t[n]),l})),Jt=s=>new Set(Ps(s)||St(s)?s:[s]),Vt=(s,t)=>s?.add(t),Mr=(s,t,e,i,n)=>{let o=s.hasRow,l=ft(),h=ft(),g=ft(),m=ft(),d=ft(),a=ft(),f=(y,r,...c)=>{let b=zt(a,y,Jt);return ve(c,(w=>Vt(b,w)&&r&&s.callListener(w))),c},A=(y,...r)=>$t(ht(a,y),(c=>{ve(ln(r)?Ds(c):r,(b=>{s.delListener(b),je(c,b)})),vt(c)&&bt(a,y)})),C=(y,r)=>{bt(l,y,r),Ht(h,y)||(bt(h,y,t()),bt(m,y,ft()),bt(d,y,ft()),n(g))},u=y=>{bt(l,y),bt(h,y),bt(m,y),bt(d,y),A(y),n(g)};return[()=>s,()=>Gi(l),y=>Yt(h,y),y=>Ht(h,y),y=>ht(l,y),y=>ht(h,y),(y,r)=>bt(h,y,r),C,(y,r,c,b,w)=>{C(y,r);let P=ft(),E=ft(),I=ht(m,y),N=ht(d,y),z=X=>{let it=j=>s.getCell(r,X,j),at=ht(I,X),K=o(r,X)?e(b(it,X)):void 0;if(at===K||Ps(at)&&Ps(K)&&sc(at,K)||bt(P,X,[at,K]),!St(w)){let j=ht(N,X),G=o(r,X)?w(it,X):void 0;j!=G&&bt(E,X,G)}},H=X=>{c((()=>{yt(P,(([,it],at)=>bt(I,at,it))),yt(E,((it,at)=>bt(N,at,it)))}),P,E,I,N,X),ks(P),ks(E)};Yt(I,z),s.hasTable(r)&&ve(s.getRowIds(r),(X=>{Ht(I,X)||z(X)})),H(!0),A(y),f(y,0,s.addRowListener(r,null,((X,it,at)=>z(at))),s.addTableListener(r,(()=>H())))},u,y=>i(y,g),()=>Yt(a,u),f,A]},Dr=(s,t)=>ld(s)?e=>e(s):s??(()=>t??""),dn=(s,t)=>{let e=new WeakMap;return i=>{e.has(i)||e.set(i,s(i));let n=e.get(i);return t?.(n),n}},pd=/^\d+$/,lc=()=>{let s=[],t=0;return[e=>(e?rc(s):null)??""+t++,e=>{pd.test(e)&&Ce(s)<1e3&&ye(s,e)}]},un=s=>{let t,[e,i]=lc(),n=ft();return[(o,l,h,g=[],m=()=>[])=>{t??=s();let d=e(1);return bt(n,d,[o,l,h,g,m]),Vt(cn(l,h??[""],Jt),d),d},(o,l,...h)=>ve(((g,m=[""])=>{let d=[],a=(f,A)=>A==Ce(m)?ye(d,f):m[A]===null?yt(f,(C=>a(C,A+1))):ve([m[A],null],(C=>a(ht(f,C),A+1)));return a(g,0),d})(o,l),(g=>yt(g,(m=>ht(n,m)[0](t,...l??[],...h))))),o=>$t(ht(n,o),(([,l,h])=>(cn(l,h??[""],void 0,(g=>(je(g,o),vt(g)?1:0))),bt(n,o),i(o),h))),o=>$t(ht(n,o),(([l,,h=[],g,m])=>{let d=(...a)=>{let f=Ce(a);f==Ce(h)?l(t,...a,...m(a)):St(h[f])?ve(g[f]?.(...a)??[],(A=>d(...a,A))):d(...a,h[f])};d()}))]},Ip=dn((s=>{let t,e,i,n=100,o=ft(),l=ft(),h=1,g=ft(),m=ft(),[d,a,f]=un((()=>G)),A=ft(),C=ft(),u=[],y=[],r=(Y,et)=>{h=0,s.transaction((()=>{let[rt,ct]=ht(A,et);yt(rt,((st,W)=>yt(st,((x,T)=>yt(x,((R,p)=>Tr(s,W,T,p,R[Y]))))))),yt(ct,((st,W)=>ea(s,W,st[Y])))})),h=1},c=Y=>{bt(A,Y),bt(C,Y),a(m,[Y])},b=(Y,et)=>ve(((rt,ct)=>rt.splice(0,ct))(Y,et??Ce(Y)),c),w=()=>b(u,Ce(u)-n),P=()=>$t(t,(()=>{ye(u,t),w(),b(y),t=void 0,i=1})),E=()=>{t=ql(u),i=1},I,N,z=(Y="")=>(St(t)&&(t=""+e++,bt(A,t,[o,l]),K(t,Y),o=ft(),l=ft(),i=1),t),H=()=>{ln(u)||(((Y,...et)=>{Y.unshift(...et)})(y,z()),r(0,t),t=ql(u),i=1)},X=()=>{ln(y)||(ye(u,t),t=rc(y),r(1,t),i=1)},it=()=>{i&&(a(g),i=0)},at=Y=>{let et=z(Y);return it(),et},K=(Y,et)=>(j(Y)&&ht(C,Y)!==et&&(bt(C,Y,et),a(m,[Y])),G),j=Y=>Ht(A,Y),G={setSize:Y=>(n=Y,w(),G),addCheckpoint:at,setCheckpoint:K,getStore:()=>s,getCheckpointIds:()=>[[...u],t,[...y]],forEachCheckpoint:Y=>Yt(C,Y),hasCheckpoint:j,getCheckpoint:Y=>ht(C,Y),goBackward:()=>(H(),it(),G),goForward:()=>(X(),it(),G),goTo:Y=>{let et=Zo(u,Y)?H:Zo(y,Y)?X:null;for(;!St(et)&&Y!=t;)et();return it(),G},addCheckpointIdsListener:Y=>d(Y,g),addCheckpointListener:(Y,et)=>d(et,m,[Y]),delListener:Y=>(f(Y),G),clear:()=>(b(u),b(y),St(t)||c(t),t=void 0,e=0,at(),G),clearForward:()=>(ln(y)||(b(y),a(g)),G),destroy:()=>{s.delListener(I),s.delListener(N)},getListenerStats:()=>({checkpointIds:qi(g),checkpoint:qi(m)}),_registerListeners:()=>{I=s.addCellListener(null,null,null,((Y,et,rt,ct,st,W)=>{if(h){P();let x=zt(o,et,ft),T=zt(x,rt,ft),R=zt(T,ct,(()=>[W,void 0]));R[1]=st,R[0]===st&&vt(bt(T,ct))&&vt(bt(x,rt))&&vt(bt(o,et))&&E(),it()}})),N=s.addValueListener(null,((Y,et,rt,ct)=>{if(h){P();let st=zt(l,et,(()=>[ct,void 0]));st[1]=rt,st[0]===rt&&vt(bt(l,et))&&E(),it()}}))}};return Ms(G.clear())}),(s=>s._registerListeners())),fd=od("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"),Mp=ft(Wi(fd,((s,t)=>[s,t])));var Rp=Jo.crypto?s=>Jo.crypto.getRandomValues(s):s=>Wi(s,(()=>ad(256*Ir.random())));var gd=JSON.stringify,Xo=JSON.parse,Cs=s=>gd(s,((t,e)=>{return i=Map,e instanceof i?Ei.fromEntries([...e]):e;var i})),Lp=new Jo.TextEncoder;var Fp=2**36,Op=2**30,Np=2**24,Bp=2**18;var cc=(s,t)=>(s??0)<(t??0)?-1:1,$p=dn((s=>{let t=ft(),e=ft(),[i,n,o]=un((()=>c)),[l,h,g,m,d,a,f,,A,C,u,y]=Mr(s,ft,(b=>St(b)?"":Ps(b)?Wi(b,Bt):Bt(b)),i,n),r=(b,w,P)=>{let E=d(b);yt(P,((I,N)=>w(N,(z=>yt(I,(H=>z(H,(X=>s.forEachCell(E,H,X)))))))))},c={setIndexDefinition:(b,w,P,E,I,N=cc)=>{let z=St(I)?void 0:([H],[X])=>I(H,X);return A(b,w,((H,X,it,at,K,j)=>{let G=0,Y=Jt(),et=Jt(),rt=a(b);if(yt(X,(([ct,st],W)=>{let x=Jt(ct),T=Jt(st);yt(x,(R=>je(T,R)?je(x,R):0)),yt(x,(R=>{Vt(Y,R),$t(ht(rt,R),(p=>{je(p,W),vt(p)&&(bt(rt,R),G=1)}))})),yt(T,(R=>{Vt(Y,R),Ht(rt,R)||(bt(rt,R,Jt()),G=1),Vt(ht(rt,R),W),St(E)||Vt(et,R)}))})),H(),vt(K)||(j?Yt(rt,(ct=>Vt(et,ct))):Yt(it,(ct=>$t(ht(at,ct),(st=>ve(Ps(st)?st:[st],(W=>Vt(et,W))))))),yt(et,(ct=>{let st=(x,T)=>N(ht(K,x),ht(K,T),ct),W=[...ht(rt,ct)];Gl(W,st)||(bt(rt,ct,Jt(ta(W,st))),Vt(Y,ct))}))),(G||j)&&!St(z)){let ct=[...rt];Gl(ct,z)||(f(b,ft(ta(ct,z))),G=1)}G&&n(t,[b]),yt(Y,(ct=>n(e,[b,ct])))}),Dr(P),$t(E,Dr)),c},delIndexDefinition:b=>(C(b),c),getStore:l,getIndexIds:h,forEachIndex:b=>g(((w,P)=>b(w,(E=>r(w,E,P))))),forEachSlice:(b,w)=>r(b,w,a(b)),hasIndex:m,hasSlice:(b,w)=>Ht(a(b),w),getTableId:d,getSliceIds:b=>Gi(a(b)),getSliceRowIds:(b,w)=>Ds(ht(a(b),w)),addIndexIdsListener:u,addSliceIdsListener:(b,w)=>i(w,t,[b]),addSliceRowIdsListener:(b,w,P)=>i(P,e,[b,w]),delListener:b=>(o(b),c),destroy:y,getListenerStats:()=>({sliceIds:qi(t),sliceRowIds:Ze(e)})};return Ms(c)}));var Sr=s=>[s,s],qt=(s,t=qi)=>t(s[0])+t(s[1]),Xt=()=>[ft(),ft()],Kl=s=>[...s],Er=([s,t])=>s===t,rn=(s,t,e)=>bt(s,t,ht(s,t)==-e?void 0:e),pn=()=>{let s,t,e=!1,i=!1,n=0,o=[],l=ft(),h=ft(),g=ft(),m=ft(),d=ft(),a=ft(),f=ft(),A=ft(),C=ft(),u=ft(),y=ft(),r=ft(),c=ft(),b=ft(),w=Jt(),P=ft(),E=ft(),I=ft(),N=ft(),z=Xt(),H=Xt(),X=Xt(),it=Xt(),at=Xt(),K=Xt(),j=Xt(),G=Xt(),Y=Xt(),et=Xt(),rt=Xt(),ct=Xt(),st=Xt(),W=Xt(),x=Xt(),T=Xt(),R=Xt(),p=Xt(),v=Xt(),_=Xt(),k=Xt(),O=Xt(),M=ft(),S=Xt(),[L,U,$,D]=un((()=>de)),F=B=>{if(!wi(B,((J,ot)=>Zo([xr,Hi],ot))))return!1;let q=B[xr];return!(!ec(q)&&q!=Jl)&&(_s(B[Hi])!=q&&ac(B,Hi),!0)},V=Ps,Q=(B,q)=>(!s||Ht(y,q)||Be(q))&&wi(B,((J,ot)=>Z(q,ot,J)),(()=>Be(q))),Z=(B,q,J,ot)=>wi(ot?J:dt(J,B,q),((ut,mt)=>$t(tt(B,q,mt,ut),(At=>(J[mt]=At,!0)),(()=>!1))),(()=>Be(B,q))),tt=(B,q,J,ot)=>s?$t(ht(ht(y,B),J),(ut=>_s(ot)!=ut[xr]?Be(B,q,J,ot,ut[Hi]):ot),(()=>Be(B,q,J,ot))):St(_s(ot))?Be(B,q,J,ot):ot,nt=(B,q)=>wi(q?B:lt(B),((J,ot)=>$t(pt(ot,J),(ut=>(B[ot]=ut,!0)),(()=>!1))),(()=>zi())),pt=(B,q)=>t?$t(ht(c,B),(J=>_s(q)!=J[xr]?zi(B,q,J[Hi]):q),(()=>zi(B,q))):St(_s(q))?zi(B,q):q,dt=(B,q,J)=>($t(ht(r,q),(([ot,ut])=>{yt(ot,((mt,At)=>{on(B,At)||(B[At]=mt)})),yt(ut,(mt=>{on(B,mt)||Be(q,J,mt)}))})),B),lt=B=>(t&&(yt(b,((q,J)=>{on(B,J)||(B[J]=q)})),yt(w,(q=>{on(B,q)||zi(q)}))),B),wt=B=>Vi(y,B,((q,J,ot)=>{let ut=ft(),mt=Jt();Vi(zt(y,J,ft),ot,((At,Dt,Rt)=>{bt(At,Dt,Rt),$t(Rt[Hi],(Je=>bt(ut,Dt,Je)),(()=>Vt(mt,Dt)))})),bt(r,J,[ut,mt])}),((q,J)=>{bt(y,J),bt(r,J)})),Tt=B=>Vi(c,B,((q,J,ot)=>{bt(c,J,ot),$t(ot[Hi],(ut=>bt(b,J,ut)),(()=>Vt(w,J)))}),((q,J)=>{bt(c,J),bt(b,J),je(w,J)})),xt=B=>He(B)?br():gr(B),It=B=>Vi(I,B,((q,J,ot)=>Lt(J,ot)),((q,J)=>pi(J))),Lt=(B,q)=>Vi(zt(I,B,(()=>(gi(B,1),bt(P,B,lc()),bt(E,B,ft()),ft()))),q,((J,ot,ut)=>Ut(B,J,ot,ut)),((J,ot)=>fi(B,J,ot))),Ut=(B,q,J,ot,ut)=>Vi(zt(q,J,(()=>(ws(B,J,1),ft()))),ot,((mt,At,Dt)=>jt(B,J,mt,At,Dt)),((mt,At)=>le(B,q,J,mt,At,ut))),jt=(B,q,J,ot,ut)=>{Ht(J,ot)||Me(B,q,ot,1);let mt=ht(J,ot);ut!==mt&&(ne(B,q,ot,mt,ut),bt(J,ot,ut))},he=(B,q,J,ot,ut)=>$t(ht(q,J),(mt=>jt(B,J,mt,ot,ut)),(()=>Ut(B,q,J,dt({[ot]:ut},B,J)))),Se=B=>He(B)?yr():mr(B),Ne=B=>Vi(N,B,((q,J,ot)=>Te(J,ot)),((q,J)=>oe(J))),Te=(B,q)=>{Ht(N,B)||ar(B,1);let J=ht(N,B);q!==J&&(xs(B,J,q),bt(N,B,q))},Ie=B=>ht(I,B)??Lt(B,{}),pi=B=>Lt(B,{}),fi=(B,q,J)=>{let[,ot]=ht(P,B);ot(J),Ut(B,q,J,{},!0)},le=(B,q,J,ot,ut,mt)=>{let At=ht(ht(r,B)?.[0],ut);if(!St(At)&&!mt)return jt(B,J,ot,ut,At);let Dt=Rt=>{ne(B,J,Rt,ht(ot,Rt)),Me(B,J,Rt,-1),bt(ot,Rt)};St(At)?Dt(ut):Yt(ot,Dt),vt(ot)&&(ws(B,J,-1),vt(bt(q,J))&&(gi(B,-1),bt(I,B),bt(P,B),bt(E,B)))},oe=B=>{let q=ht(b,B);if(!St(q))return Te(B,q);xs(B,ht(N,B)),ar(B,-1),bt(N,B)},gi=(B,q)=>rn(l,B,q),ws=(B,q,J)=>rn(zt(m,B,ft),q,J)&&bt(g,B,zt(g,B,(()=>0))+J),Me=(B,q,J,ot)=>{let ut=ht(E,B),mt=ht(ut,J)??0;(mt==0&&ot==1||mt==1&&ot==-1)&&rn(zt(h,B,ft),J,ot),bt(ut,J,mt!=-ot?mt+ot:null),rn(zt(zt(d,B,ft),q,ft),J,ot)},ne=(B,q,J,ot,ut)=>{zt(zt(zt(a,B,ft),q,ft),J,(()=>[ot,0]))[1]=ut,o[3]?.(B,q,J,ut)},ar=(B,q)=>rn(f,B,q),xs=(B,q,J)=>{zt(A,B,(()=>[q,0]))[1]=J,o[4]?.(B,J)},Be=(B,q,J,ot,ut)=>(ye(zt(zt(zt(C,B,ft),q,ft),J,(()=>[])),ot),ut),zi=(B,q,J)=>(ye(zt(u,B,(()=>[])),q),J),$e=(B,q,J)=>$t(ht(ht(ht(a,B),q),J),(([ot,ut])=>[!0,ot,ut]),(()=>[!1,...Sr(dr(B,q,J))])),lr=B=>$t(ht(A,B),(([q,J])=>[!0,q,J]),(()=>[!1,...Sr(ur(B))])),As=B=>vt(C)||vt(T[B])?0:yt(B?qo(C):C,((q,J)=>yt(q,((ot,ut)=>yt(ot,((mt,At)=>U(T[B],[J,ut,At],mt))))))),mi=B=>vt(u)||vt(R[B])?0:yt(B?xi(u):u,((q,J)=>U(R[B],[J],q))),pe=(B,q,J,ot)=>{if(!vt(B))return U(q,ot,(()=>be(B))),Yt(B,((ut,mt)=>U(J,[...ot??[],ut],mt==1))),1},cr=B=>{let q=pr();q!=e&&U(z[B],void 0,q);let J=vt(et[B]),ot=vt(st[B])&&vt(W[B])&&vt(Y[B])&&vt(rt[B])&&vt(K[B])&&vt(j[B])&&vt(G[B])&&J&&vt(X[B])&&vt(it[B]),ut=vt(x[B])&&vt(ct[B])&&vt(at[B])&&vt(H[B]);if(!ot||!ut){let mt=B?[xi(l),sa(h),xi(g),sa(m),qo(d),qo(a)]:[l,h,g,m,d,a];if(!ot){pe(mt[0],X[B],it[B]),yt(mt[1],((Dt,Rt)=>pe(Dt,K[B],j[B],[Rt]))),yt(mt[2],((Dt,Rt)=>{Dt!=0&&U(G[B],[Rt],kl(Rt))}));let At=Jt();yt(mt[3],((Dt,Rt)=>{pe(Dt,Y[B],rt[B],[Rt])&&!J&&(U(et[B],[Rt,null]),Vt(At,Rt))})),J||yt(mt[5],((Dt,Rt)=>{if(!Ht(At,Rt)){let Je=Jt();yt(Dt,(bi=>yt(bi,(([vr,wr],nn)=>wr!==vr?Vt(Je,nn):je(bi,nn))))),yt(Je,(bi=>U(et[B],[Rt,bi])))}})),yt(mt[4],((Dt,Rt)=>yt(Dt,((Je,bi)=>pe(Je,st[B],W[B],[Rt,bi])))))}if(!ut){let At;yt(mt[5],((Dt,Rt)=>{let Je;yt(Dt,((bi,vr)=>{let wr;yt(bi,(([nn,zl],Zh)=>{zl!==nn&&(U(x[B],[Rt,vr,Zh],zl,nn,$e),At=Je=wr=1)})),wr&&U(ct[B],[Rt,vr],$e)})),Je&&U(at[B],[Rt],$e)})),At&&U(H[B],void 0,$e)}}},El=B=>{let q=fr();q!=i&&U(p[B],void 0,q);let J=vt(_[B])&&vt(k[B]),ot=vt(O[B])&&vt(v[B]);if(!J||!ot){let ut=B?[xi(f),xi(A)]:[f,A];if(J||pe(ut[0],_[B],k[B]),!ot){let mt;yt(ut[1],(([At,Dt],Rt)=>{Dt!==At&&(U(O[B],[Rt],Dt,At,lr),mt=1)})),mt&&U(v[B],void 0,lr)}}},Wt=(B,...q)=>(Ho((()=>B(...Wi(q,Bt)))),de),Cl=(B,q,J,ot,ut)=>{let mt=hr(B,q,...J);return L((()=>{let At=hr(B,q,...J);sc(At,mt)||(mt=At,ot(de,B,q,...J,mt))}),et[ut?1:0],[B,q],[Ee])},No=()=>Ar(I),Ee=()=>Gi(I),_l=B=>Gi(ht(E,Bt(B))),kl=B=>Is(ht(I,Bt(B))),Ss=B=>Gi(ht(I,Bt(B))),hr=(B,q,J,ot=0,ut)=>{return Pr(B)?hr(B.tableId,B.cellId,B.descending,B.offset,B.limit):Wi(Qo(ta((mt=ht(I,Bt(B)),At=(Dt,Rt)=>[St(q)?Rt:ht(Dt,Bt(q)),Rt],Wi([...mt?.entries()??[]],(([Dt,Rt])=>At(Rt,Dt)))),(([Dt],[Rt])=>cc(Dt,Rt)*(J?-1:1))),ot,St(ut)?ut:ot+ut),(([,Dt])=>Dt));var mt,At},Bo=(B,q)=>Gi(ht(ht(I,Bt(B)),Bt(q))),dr=(B,q,J)=>ht(ht(ht(I,Bt(B)),Bt(q)),Bt(J)),$o=()=>be(N),Uo=()=>Gi(N),ur=B=>ht(N,Bt(B)),pr=()=>!vt(I),Tl=B=>Ht(I,Bt(B)),Pl=(B,q)=>Ht(ht(E,Bt(B)),Bt(q)),Dl=(B,q)=>Ht(ht(I,Bt(B)),Bt(q)),Il=(B,q,J)=>Ht(ht(ht(I,Bt(B)),Bt(q)),Bt(J)),fr=()=>!vt(N),Ml=B=>Ht(N,Bt(B)),gr=B=>Wt((()=>(q=>wi(q,Q,Be))(B)?It(B):0)),mr=B=>Wt((()=>nt(B)?Ne(B):0)),Rl=B=>(Go((()=>xt(Xo(B)))),de),Ll=B=>Wt((()=>{if((s=wi(B,(q=>wi(q,F))))&&(wt(B),!vt(I))){let q=No();br(),gr(q)}})),Fl=B=>Wt((()=>{if(t=(q=>wi(q,F))(B)){let q=$o();zo(),yr(),t=!0,Tt(B),mr(q)}})),br=()=>Wt((()=>It({}))),Ol=B=>Wt((q=>Ht(I,q)?pi(q):0),B),Nl=(B,q)=>Wt(((J,ot)=>$t(ht(I,J),(ut=>Ht(ut,ot)?fi(J,ut,ot):0))),B,q),yr=()=>Wt((()=>Ne({}))),Bl=()=>Wt((()=>{wt({}),s=!1})),zo=()=>Wt((()=>{Tt({}),t=!1})),Ho=(B,q)=>{if(n!=-1){$l();let J=B();return Ul(q),J}},$l=()=>(n!=-1&&n++,n==1&&(o[0]?.(),U(M)),de),Ul=B=>(n>0&&(n--,n==0&&(n=1,As(1),vt(a)||cr(1),mi(1),vt(A)||El(1),B?.(de)&&(yt(a,((q,J)=>yt(q,((ot,ut)=>yt(ot,(([mt],At)=>Tr(de,J,ut,At,mt))))))),ks(a),yt(A,(([q],J)=>ea(de,J,q))),ks(A)),U(S[0],void 0),n=-1,As(0),vt(a)||cr(0),mi(0),vt(A)||El(0),o[1]?.(),U(S[1],void 0),o[2]?.(),n=0,e=pr(),i=fr(),ve([l,h,g,m,d,a,C,f,A,u],ks))),de),de={getContent:()=>[No(),$o()],getTables:No,getTableIds:Ee,getTable:B=>ia(ht(I,Bt(B))),getTableCellIds:_l,getRowCount:kl,getRowIds:Ss,getSortedRowIds:hr,getRow:(B,q)=>be(ht(ht(I,Bt(B)),Bt(q))),getCellIds:Bo,getCell:dr,getValues:$o,getValueIds:Uo,getValue:ur,hasTables:pr,hasTable:Tl,hasTableCell:Pl,hasRow:Dl,hasCell:Il,hasValues:fr,hasValue:Ml,getTablesJson:()=>Cs(I),getValuesJson:()=>Cs(N),getJson:()=>Cs([I,N]),getTablesSchemaJson:()=>Cs(y),getValuesSchemaJson:()=>Cs(c),getSchemaJson:()=>Cs([y,c]),hasTablesSchema:()=>s,hasValuesSchema:()=>t,setContent:B=>Wt((()=>{let q=ze(B)?B():B;V(q)&&(([J,ot])=>{(He(J)?br:gr)(J),(He(ot)?yr:mr)(ot)})(q)})),setTables:gr,setTable:(B,q)=>Wt((J=>Q(q,J)?Lt(J,q):0),B),setRow:(B,q,J)=>Wt(((ot,ut)=>Z(ot,ut,J)?Ut(ot,Ie(ot),ut,J):0),B,q),addRow:(B,q,J=!0)=>Ho((()=>{let ot;return Z(B,ot,q)&&(B=Bt(B),Ut(B,Ie(B),ot=((ut,mt)=>{let[At]=ht(P,ut),Dt;do Dt=At(mt);while(Ht(ht(I,ut),Dt));return Dt})(B,J?1:0),q)),ot})),setPartialRow:(B,q,J)=>Wt(((ot,ut)=>{if(Z(ot,ut,J,1)){let mt=Ie(ot);Qe(J,((At,Dt)=>he(ot,mt,ut,Dt,At)))}}),B,q),setCell:(B,q,J,ot)=>Wt(((ut,mt,At)=>$t(tt(ut,mt,At,ze(ot)?ot(dr(ut,mt,At)):ot),(Dt=>he(ut,Ie(ut),mt,At,Dt)))),B,q,J),setValues:mr,setPartialValues:B=>Wt((()=>nt(B,1)?Qe(B,((q,J)=>Te(J,q))):0)),setValue:(B,q)=>Wt((J=>$t(pt(J,ze(q)?q(ur(J)):q),(ot=>Te(J,ot)))),B),applyChanges:B=>Wt((()=>{Qe(B[0],((q,J)=>St(q)?Ol(J):Qe(q,((ot,ut)=>St(ot)?Nl(J,ut):Qe(ot,((mt,At)=>Tr(de,J,ut,At,mt))))))),Qe(B[1],((q,J)=>ea(de,J,q)))})),setTablesJson:Rl,setValuesJson:B=>(Go((()=>Se(Xo(B)))),de),setJson:B=>Wt((()=>Go((()=>{let[q,J]=Xo(B);xt(q),Se(J)}),(()=>Rl(B))))),setTablesSchema:Ll,setValuesSchema:Fl,setSchema:(B,q)=>Wt((()=>{Ll(B),Fl(q)})),delTables:br,delTable:Ol,delRow:Nl,delCell:(B,q,J,ot)=>Wt(((ut,mt,At)=>$t(ht(I,ut),(Dt=>$t(ht(Dt,mt),(Rt=>Ht(Rt,At)?le(ut,Dt,mt,Rt,At,ot):0))))),B,q,J),delValues:yr,delValue:B=>Wt((q=>Ht(N,q)?oe(q):0),B),delTablesSchema:Bl,delValuesSchema:zo,delSchema:()=>Wt((()=>{Bl(),zo()})),transaction:Ho,startTransaction:$l,getTransactionChanges:()=>[be(a,((B,q)=>ht(l,q)===-1?void 0:be(B,((J,ot)=>ht(ht(m,q),ot)===-1?void 0:be(J,(([,ut])=>ut),(ut=>Er(ut)))),vt,He)),vt,He),be(A,(([,B])=>B),(B=>Er(B))),1],getTransactionLog:()=>[!vt(a),!vt(A),Ar(a,Kl,Er),Ar(C),be(A,Kl,Er),be(u),be(l),ia(m),Ar(d),be(f)],finishTransaction:Ul,forEachTable:B=>yt(I,((q,J)=>B(J,(ot=>yt(q,((ut,mt)=>ot(mt,(At=>Yt(ut,At))))))))),forEachTableCell:(B,q)=>Yt(ht(E,Bt(B)),q),forEachRow:(B,q)=>yt(ht(I,Bt(B)),((J,ot)=>q(ot,(ut=>Yt(J,ut))))),forEachCell:(B,q,J)=>Yt(ht(ht(I,Bt(B)),Bt(q)),J),forEachValue:B=>Yt(N,B),addSortedRowIdsListener:(B,q,J,ot,ut,mt,At)=>Pr(B)?Cl(B.tableId,B.cellId,[B.descending??!1,B.offset??0,B.limit],q,J):Cl(B,q,[J,ot,ut],mt,At),addStartTransactionListener:B=>L(B,M),addWillFinishTransactionListener:B=>L(B,S[0]),addDidFinishTransactionListener:B=>L(B,S[1]),callListener:B=>(D(B),de),delListener:B=>($(B),de),getListenerStats:()=>({hasTables:qt(z),tables:qt(H),tableIds:qt(X),hasTable:qt(it),table:qt(at),tableCellIds:qt(K),hasTableCell:qt(j,Ze),rowCount:qt(G),rowIds:qt(Y),sortedRowIds:qt(et),hasRow:qt(rt,Ze),row:qt(ct,Ze),cellIds:qt(st,Ze),hasCell:qt(W,Wo),cell:qt(x,Wo),invalidCell:qt(T,Wo),hasValues:qt(p),values:qt(v),valueIds:qt(_),hasValue:qt(k),value:qt(O),invalidValue:qt(R),transaction:qi(M)+qt(S)}),isMergeable:()=>!1,createStore:pn,addListener:L,callListeners:U,setInternalListeners:(B,q,J,ot,ut)=>o=[B,q,J,ot,ut]};return Qe({[ji+jl]:[0,z,[],()=>[pr()]],[jl]:[0,H],[sd]:[0,X],[ji+Ai]:[1,it,[Ee],B=>[Tl(...B)]],[Ai]:[1,at,[Ee]],[Ai+Cr]:[1,K,[Ee]],[ji+Ai+an]:[2,j,[Ee,_l],B=>[Pl(...B)]],[Ql]:[1,G,[Ee]],[Zl]:[1,Y,[Ee]],[ji+Ts]:[2,rt,[Ee,Ss],B=>[Dl(...B)]],[Ts]:[2,ct,[Ee,Ss]],[Cr]:[2,st,[Ee,Ss]],[ji+an]:[3,W,[Ee,Ss,Bo],B=>[Il(...B)]],[an]:[3,x,[Ee,Ss,Bo],B=>Sr(dr(...B))],InvalidCell:[3,T],[ji+Vl]:[0,p,[],()=>[fr()]],[Vl]:[0,v],[rd]:[0,_],[ji+_r]:[1,k,[Uo],B=>[Ml(...B)]],[_r]:[1,O,[Uo],B=>Sr(ur(B[0]))],InvalidValue:[1,R]},(([B,q,J,ot],ut)=>{de[Yo+ut+Ko]=(...mt)=>L(mt[B],q[mt[B+1]?1:0],B>0?Qo(mt,0,B):void 0,J,ot)})),Ms(de)};var na=ft([["avg",[(s,t)=>Wl(s)/t,(s,t,e)=>s+(t-s)/(e+1),(s,t,e)=>s+(s-t)/(e-1),(s,t,e,i)=>s+(t-e)/i]],["max",[s=>jo(...s),(s,t)=>jo(t,s),(s,t)=>t==s?void 0:s,(s,t,e)=>e==s?void 0:jo(t,s)]],["min",[s=>Vo(...s),(s,t)=>Vo(t,s),(s,t)=>t==s?void 0:s,(s,t,e)=>e==s?void 0:Vo(t,s)]],["sum",[s=>Wl(s),(s,t)=>s+t,(s,t)=>s-t,(s,t,e)=>s-e+t]]]),hc=(s,t,e,i,n,o=!1)=>{if(vt(e))return;let[l,h,g,m]=n;return o||=St(s),yt(i,(([d,a])=>{o||(s=St(d)?h?.(s,a,t++):St(a)?g?.(s,d,t--):m?.(s,a,d,t),o||=St(s))})),o?l(Ds(e),Is(e)):s},Up=dn((s=>{let t=ft(),[e,i,n]=un((()=>y)),[o,l,h,g,m,d,a,,f,A,C,u]=Mr(s,ic,(r=>isNaN(r)||St(r)||r===!0||r===!1||r===""?void 0:1*r),e,i),y={setMetricDefinition:(r,c,b,w,P,E,I)=>{let N=ze(b)?[b,P,E,I]:ht(na,b)??ht(na,"sum");return f(r,c,((z,H,X,it,at,K)=>{let j=d(r),G=Is(it);K||=St(j),z();let Y=hc(j,G,it,H,N,K);tc(Y)||(Y=void 0),Y!=j&&(a(r,Y),i(t,[r],Y,j))}),Dr(w,1)),y},delMetricDefinition:r=>(A(r),y),getStore:o,getMetricIds:l,forEachMetric:h,hasMetric:g,getTableId:m,getMetric:d,addMetricIdsListener:C,addMetricListener:(r,c)=>e(c,t,[r]),delListener:r=>(n(r),y),destroy:u,getListenerStats:()=>({metric:qi(t)})};return Ms(y)})),zp=dn((s=>{let t=s.createStore,e=t(),i=t(),n=ft(),{addListener:o,callListeners:l,delListener:h}=i,[g,m,d,a,f,,,A,,C,u,y,r,c]=Mr(s,(()=>!0),ic,o,l),b=(I,N,...z)=>ve(z,(H=>Vt(zt(zt(n,N,ft),I,Jt),H))),w=I=>{$t(ht(n,I),(N=>{Yt(N,((z,H)=>yt(H,(X=>z.delListener(X))))),ks(N)})),ve([i,e],(N=>N.delTable(I)))},P=(I,N,z)=>b(N,I,N.addStartTransactionListener(z.startTransaction),N.addDidFinishTransactionListener((()=>z.finishTransaction()))),E={setQueryDefinition:(I,N,z)=>{A(I,N),w(I);let H=[],X=[[null,[N,null,null,[],ft()]]],it=[],at=[],K=[];z({select:(st,W)=>{let x=ze(st)?[Ce(H)+"",st]:[St(W)?st:W,T=>T(st,W)];return ye(H,x),{as:T=>x[0]=T}},join:(st,W,x)=>{let T=St(x)||ze(W)?null:W,R=St(T)?W:x,p=[st,[st,T,ze(R)?R:v=>v(R),[],ft()]];return ye(X,p),{as:v=>p[0]=v}},where:(st,W,x)=>ye(it,ze(st)?st:St(x)?T=>T(st)===W:T=>T(st,W)===x),group:(st,W,x,T,R)=>{let p=[st,[st,ze(W)?[W,x,T,R]:ht(na,W)??[(v,_)=>_]]];return ye(at,p),{as:v=>p[0]=v}},having:(st,W)=>ye(K,ze(st)?st:x=>x(st)===W)});let j=ft(H);if(vt(j))return E;let G=ft(X);Yt(G,((st,[,W])=>$t(ht(G,W),(({3:x})=>St(st)?0:ye(x,st)))));let Y=ft(at),et=e;if(vt(Y)&&ln(K))et=i;else{P(I,et,i);let st=ft();Yt(Y,((R,[p,v])=>Vt(zt(st,p,Jt),[R,v])));let W=Jt();Yt(j,(R=>Ht(st,R)?0:Vt(W,R)));let x=ft(),T=(R,p,v,_)=>$t(R,(([k,O,M,S])=>{Yt(p,((L,[U])=>{let $=zt(k,L,ft),D=ht($,v),F=_?void 0:U;if(D!==F){let V=Jt([[D,F]]),Q=Is($);bt($,v,F),yt(ht(st,L),(([Z,tt])=>{let nt=hc(S[Z],Q,$,V,tt);S[Z]=St(_s(nt))?null:nt}))}})),vt(O)||!kr(K,(L=>L((U=>S[U]))))?i.delRow(I,M):St(M)?R[2]=i.addRow(I,S):i.setRow(I,M,S)}));b(et,I,et.addRowListener(I,null,((R,p,v,_)=>{let k=[],O=[],M=ft(),S=et.hasRow(I,v),L=!S;yt(W,(U=>{let[$,D,F]=_(I,v,U);ye(k,D),ye(O,F),L||=$})),Yt(st,(U=>{let[$,,D]=_(I,v,U);(L||$)&&bt(M,U,[D])})),L&&T(cn(x,k,void 0,(([,U])=>(je(U,v),vt(U)))),M,v,1),S&&T(cn(x,O,(()=>{let U={};return yt(W,($=>U[$]=et.getCell(I,v,$))),[ft(),Jt(),void 0,U]}),(([,U])=>{Vt(U,v)})),M,v)})))}P(I,s,et);let rt=(st,W,x,T)=>{let R=p=>s.getCell(W,x,p);ve(T,(p=>{let[v,,_,k,O]=ht(G,p),M=_?.(R,st),[S,L]=ht(O,st)??[];M!=S&&(St(L)||c(I,L),bt(O,st,St(M)?null:[M,...r(I,1,s.addRowListener(v,M,(()=>rt(st,v,M,k))))]))})),(p=>{let v=(_,k)=>s.getCell(...St(k)?[N,p,_]:_===N?[N,p,k]:[ht(G,_)?.[0],ht(ht(G,_)?.[4],p)?.[0],k]);et.transaction((()=>kr(it,(_=>_(v)))?Yt(j,((_,k)=>Tr(et,I,p,_,k(v,p)))):et.delRow(I,p)))})(st)},{3:ct}=ht(G,null);return et.transaction((()=>r(I,1,s.addRowListener(N,null,((st,W,x)=>{s.hasRow(N,x)?rt(x,N,x,ct):(et.delRow(I,x),yt(G,(({4:T})=>$t(ht(T,x),(([,R])=>{c(I,R),bt(T,x)})))))}))))),E},delQueryDefinition:I=>(w(I),C(I),E),getStore:g,getQueryIds:m,forEachQuery:d,hasQuery:a,getTableId:f,addQueryIdsListener:I=>u((()=>I(E))),delListener:I=>(h(I),E),destroy:y,getListenerStats:()=>{let{tables:I,tableIds:N,transaction:z,...H}=i.getListenerStats();return H}};return Qe({[Ai]:[1,1],[Ai+Cr]:[0,1],[Ql]:[0,1],[Zl]:[0,1],[nd]:[0,5],[Ts]:[1,2],[Cr]:[0,2],[an]:[1,3]},(([I,N],z)=>{ve(I?["get","has","forEach"]:["get"],(H=>E[H+Hl+z]=(...X)=>i[H+z](...X))),E[Yo+Hl+z+Ko]=(...H)=>i[Yo+z+Ko](...Qo(H,0,N),((X,...it)=>H[N](E,...it)),!0)})),Ms(E)})),Hp=dn((s=>{let t=ft(),e=ft(),i=ft(),n=ft(),[o,l,h]=un((()=>P)),[g,m,d,a,f,A,,,C,u,y,r]=Mr(s,(()=>[ft(),ft(),ft(),ft()]),(E=>St(E)?void 0:E+""),o,l),c=(E,I,N)=>$t(A(E),(([z,,H])=>{if(!Ht(H,I)){let X=Jt();if(f(E)!=w(E))Vt(X,I);else{let it=I;for(;!St(it)&&!Ht(X,it);)Vt(X,it),it=ht(z,it)}if(N)return X;bt(H,I,X)}return ht(H,I)})),b=(E,I)=>$t(A(E),(([,,N])=>bt(N,I))),w=E=>ht(t,E),P={setRelationshipDefinition:(E,I,N,z)=>(bt(t,E,N),C(E,I,((H,X)=>{let it=Jt(),at=Jt(),K=Jt(),[j,G]=A(E);yt(X,(([Y,et],rt)=>{St(Y)||(Vt(at,Y),$t(ht(G,Y),(ct=>{je(ct,rt),vt(ct)&&bt(G,Y)}))),St(et)||(Vt(at,et),Ht(G,et)||bt(G,et,Jt()),Vt(ht(G,et),rt)),Vt(it,rt),bt(j,rt,et),Yt(ht(n,E),(ct=>{Ht(c(E,ct),rt)&&Vt(K,ct)}))})),H(),yt(it,(Y=>l(e,[E,Y]))),yt(at,(Y=>l(i,[E,Y]))),yt(K,(Y=>{b(E,Y),l(n,[E,Y])}))}),Dr(z)),P),delRelationshipDefinition:E=>(bt(t,E),u(E),P),getStore:g,getRelationshipIds:m,forEachRelationship:E=>d((I=>E(I,(N=>s.forEachRow(f(I),N))))),hasRelationship:a,getLocalTableId:f,getRemoteTableId:w,getRemoteRowId:(E,I)=>ht(A(E)?.[0],I),getLocalRowIds:(E,I)=>Ds(ht(A(E)?.[1],I)),getLinkedRowIds:(E,I)=>St(A(E))?[I]:Ds(c(E,I,!0)),addRelationshipIdsListener:y,addRemoteRowIdListener:(E,I,N)=>o(N,e,[E,I]),addLocalRowIdsListener:(E,I,N)=>o(N,i,[E,I]),addLinkedRowIdsListener:(E,I,N)=>(c(E,I),o(N,n,[E,I])),delListener:E=>(b(...h(E)??[]),P),destroy:r,getListenerStats:()=>({remoteRowId:Ze(e),localRowIds:Ze(i),linkedRowIds:Ze(n)})};return Ms(P)}));var pc=Promise,md=globalThis,dc=md.window,bd=1e3,yd=(s,t,e)=>setInterval(s,t*bd),vd=clearInterval,Ve=s=>s==null,Nr=(s,t,e)=>Ve(s)?e?.():t(s),aa=s=>Array.isArray(s),Ki=s=>s.length,wd=(s,t)=>s.test(t),fc=s=>new pc(s),gc=async s=>pc.all(s),mc=s=>{throw new Error(s)},Xi=async(s,t,e)=>{try{return await s()}catch(i){t?.(i)}},la=(s,t)=>s.forEach(t),fn=(s,t)=>s.map(t),xd=(s,t)=>s.splice(0,t),Br=(s,...t)=>s.push(...t),bc=s=>s.shift(),Rs=Object,uc=s=>Rs.getPrototypeOf(s),Ad=Rs.entries,Sd=s=>!Ve(s)&&Nr(uc(s),t=>t==Rs.prototype||Ve(uc(t)),()=>!0),Ed=Rs.keys,Cd=Rs.freeze,_d=(s=[])=>Rs.fromEntries(s),kd=(s,t)=>t in s,Td=(s,t)=>fn(Ad(s),([e,i])=>t(i,e)),Pd=s=>Ki(Ed(s)),Rr=s=>Sd(s)&&Pd(s)==0,Dd=s=>s?.size??0,Id=(s,t)=>s?.has(t)??!1,yc=s=>Ve(s)||Dd(s)==0,vc=(s,t)=>s?.forEach(t),wc=(s,t)=>s?.delete(t),gn=s=>new Map(s),Re=(s,t)=>s?.get(t),Yi=(s,t,e)=>Ve(e)?(wc(s,t),s):s?.set(t,e),ca=(s,t,e,i)=>(Id(s,t)?i?.(Re(s,t)):Yi(s,t,e()),Re(s,t)),ha=(s,t,e,i,n=0)=>Nr((e?ca:Re)(s,t[n],n>Ki(t)-2?e:gn),o=>{if(n>Ki(t)-2)return i?.(o)&&Yi(s,t[n]),o;let l=ha(o,t,e,i,n+1);return yc(o)&&Yi(s,t[n]),l}),Md=/^\d+$/,Rd=()=>{let s=[],t=0;return[e=>(e?bc(s):null)??""+t++,e=>{wd(Md,e)&&Ki(s)<1e3&&Br(s,e)}]},Ld=s=>new Set(aa(s)||Ve(s)?s:[s]),Fd=(s,t)=>s?.add(t),Od=(s,t=[""])=>{let e=[],i=(n,o)=>o==Ki(t)?Br(e,n):t[o]===null?vc(n,l=>i(l,o+1)):la([t[o],null],l=>i(Re(n,l),o+1));return i(s,0),e},Nd=s=>{let t,[e,i]=Rd(),n=gn();return[(o,l,h,g=[],m=()=>[])=>{t??=s();let d=e(1);return Yi(n,d,[o,l,h,g,m]),Fd(ha(l,h??[""],Ld),d),d},(o,l,...h)=>la(Od(o,l),g=>vc(g,m=>Re(n,m)[0](t,...l??[],...h))),o=>Nr(Re(n,o),([,l,h])=>(ha(l,h??[""],void 0,g=>(wc(g,o),yc(g)?1:0)),Yi(n,o),i(o),h)),o=>Nr(Re(n,o),([l,,h=[],g,m])=>{let d=(...a)=>{let f=Ki(a);f==Ki(h)?l(t,...a,...m(a)):Ve(h[f])?la(g[f]?.(...a)??[],A=>d(...a,A)):d(...a,h[f])};d()})]},Lr=gn(),Fr=gn(),Bd=(s=1,t,e)=>s!=1&&t.isMergeable()?[1,t.getMergeableContent,()=>t.getTransactionMergeableChanges(!e),([[i],[n]])=>!Rr(i)||!Rr(n),t.setDefaultContent]:s!=2?[0,t.getContent,t.getTransactionChanges,([i,n])=>!Rr(i)||!Rr(n),t.setContent]:mc("Store type not supported by this Persister"),$d=(s,t,e,i,n,o,l,h={},g=0,m=[])=>{let d=0,a=0,f=0,A,C,u;ca(Lr,m,()=>0),ca(Fr,m,()=>[]);let y=gn(),[r,c,b,w,P]=Bd(l,s,g),[E,I,N]=Nd(()=>p),z=v=>{v!=d&&(d=v,I(y,void 0,d))},H=async()=>{if(!Re(Lr,m)){for(Yi(Lr,m,1);!Ve(A=bc(Re(Fr,m)));)await Xi(A,o);Yi(Lr,m,0)}},X=v=>{(r&&aa(v?.[0])?v?.[2]===1?s.applyMergeableChanges:s.setMergeableContent:v?.[2]===1?s.applyChanges:s.setContent)(v)},it=async v=>(d!=2&&(z(1),a++,await R(async()=>{await Xi(async()=>{let _=await t();aa(_)?X(_):v?P(v):mc(`Content is not an array: ${_}`)},()=>{v&&P(v)}),z(0)})),p),at=async v=>(K(),await it(v),await Xi(async()=>C=await i(async(_,k)=>{k||_?d!=2&&(z(1),a++,X(k??_),z(0)):await it()}),o),p),K=async()=>(C&&(await Xi(()=>n(C),o),C=void 0),p),j=()=>!Ve(C),G=async v=>(d!=1&&(z(2),f++,await R(async()=>{await Xi(()=>e(c,v),o),z(0)})),p),Y=async()=>(et(),await G(),u=s.addDidFinishTransactionListener(()=>{let v=b();w(v)&&G(v)}),p),et=async()=>(u&&(s.delListener(u),u=void 0),p),rt=()=>!Ve(u),ct=async(v,_=!1)=>{let[k,O]=_?[Y,at]:[at,Y];return await k(v),await O(v),p},st=async(v=!1)=>{let[_,k]=v?[et,K]:[K,et];return await _(),await k(),p},W=()=>d,x=v=>E(v,y),T=v=>(N(v),s),R=async(...v)=>(Br(Re(Fr,m),...v),await H(),p),p={load:it,startAutoLoad:at,stopAutoLoad:K,isAutoLoading:j,save:G,startAutoSave:Y,stopAutoSave:et,isAutoSaving:rt,startAutoPersisting:ct,stopAutoPersisting:st,getStatus:W,addStatusListener:x,delListener:T,schedule:R,getStore:()=>s,destroy:()=>(xd(Re(Fr,m)),st()),getStats:()=>({loads:a,saves:f}),...h};return Cd(p)},oa=["t","v"],Ud={keyPath:"k"},zd=async(s,t)=>{let e=Td(t,(i,n)=>Or(s,"put",{k:n,v:i}));fn(await Or(s,"getAllKeys"),i=>kd(t,i)?0:Br(e,Or(s,"delete",i))),await gc(e)},Or=async(s,t,e)=>fc((i,n)=>{let o=s[t](e);o.onsuccess=()=>i(o.result),o.onerror=()=>n(`objectStore.${t} error`)}),$r=(s,t,e=1,i)=>{let n=async(o,l=[],h=0)=>fc((g,m)=>{let d=(dc?dc.indexedDB:indexedDB).open(t,h?2:void 0);d.onupgradeneeded=()=>h&&fn(oa,a=>Xi(()=>d.result.createObjectStore(a,Ud))),d.onsuccess=()=>Xi(async()=>{let a=d.result.transaction(oa,"readwrite"),f=await gc(fn(oa,(A,C)=>o(a.objectStore(A),l[C])));d.result.close(),g(f)},a=>{d.result.close(),m(a)}),d.onerror=()=>m("indexedDB.open error")});return $d(s,async()=>await n(async o=>_d(fn(await Or(o,"getAll"),({k:l,v:h})=>[l,h]))),o=>n((l,h)=>zd(l,h),o(),1),o=>yd(o,e),o=>vd(o),i,1,{getDbName:()=>t})};var Ur=pn();Ur.setTable("docs",{});var zr=$r(Ur,"copio-db");zr.startAutoLoad();zr.startAutoSave();var Ji=class extends Ue{#t=null;#e=null;#i="copio-db";#n=!1;constructor(t={}){super(),t.dbName&&t.dbName!=="copio-db"?(this.#i=t.dbName,this.#t=t.store||pn(),this.#t.setTable("docs",{}),this.#e=t.persister||$r(this.#t,this.#i),this.#n=!0):(this.#t=t.store||Ur,this.#e=t.persister||zr,this.#i="copio-db")}get store(){return this.#t}get persister(){return this.#e}async init(){return this.#n?(await this.#e.load(),this.#e.startAutoLoad(),this.#e.startAutoSave()):await this.#e.load(),{kind:"indexeddb",persistent:!0}}listDocsSync(){let t=this.#t.getTable("docs");return Object.entries(t||{}).map(([e,i])=>({id:e,name:i.name||"",pages:this.#r(i.pages)}))}async listDocs(){return this.listDocsSync()}getDocSync(t){if(!this.#t.hasRow("docs",t))return null;let e=this.#t.getRow("docs",t);return{id:t,name:e.name||"",pages:this.#r(e.pages)}}async getDoc(t){return this.getDocSync(t)}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=Array.isArray(e.pages)?e.pages:this.#r(e.pages);this.#t.setRow("docs",t,{name:e.name||"",pages:JSON.stringify(i)})}async deleteDoc(t){this.#t.delRow("docs",t)}async savePage(t,e,i){let n=await this.getDoc(t);if(!n)throw new Error(`Document ${t} not found`);let o=n.pages.findIndex(l=>l.id===e);if(o>=0)typeof i=="object"&&i!==null&&!(i instanceof Blob)?n.pages[o]={...n.pages[o],...i}:n.pages[o]={...n.pages[o],src:i};else{let l=typeof i=="object"&&i!==null&&!(i instanceof Blob)?{id:e,...i}:{id:e,src:i};n.pages.push(l)}await this.saveDoc(t,n)}async getPage(t,e){let i=await this.getDoc(t);if(!i)return null;let n=i.pages.find(o=>o.id===e);return n?n.src??n:null}async deletePage(t,e){let i=await this.getDoc(t);i&&(i.pages=i.pages.filter(n=>n.id!==e),await this.saveDoc(t,i))}subscribe(t){let e=this.#t.addTableListener("docs",t);return()=>{this.#t.delListener(e)}}#r(t){if(Array.isArray(t))return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}};function Ls(s={}){return s.forceMemory?new vi:typeof indexedDB<"u"?new Ji(s):new vi}function Nt(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}var Ea=typeof self<"u"?self:global,wn=typeof navigator<"u",Hd=wn&&typeof HTMLImageElement>"u",xc=!(typeof global>"u"||typeof process>"u"||!process.versions||!process.versions.node),Ca=Ea.Buffer,Hr=Ea.BigInt,_a=!!Ca,jr=s=>Rc(s)?void 0:s,jd=s=>s!==void 0;function Rc(s){return s===void 0||(s instanceof Map?s.size===0:Object.values(s).filter(jd).length===0)}function re(s){let t=new Error(s);throw delete t.stack,t}function Lc(s){return(s=(function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t})(s).trim())===""?void 0:s}function Ac(s){let t=(function(e){let i=0;return e.ifd0.enabled&&(i+=1024),e.exif.enabled&&(i+=2048),e.makerNote&&(i+=2048),e.userComment&&(i+=1024),e.gps.enabled&&(i+=512),e.interop.enabled&&(i+=100),e.ifd1.enabled&&(i+=1024),i+2048})(s);return s.jfif.enabled&&(t+=50),s.xmp.enabled&&(t+=2e4),s.iptc.enabled&&(t+=14e3),s.icc.enabled&&(t+=6e3),t}var fa=s=>String.fromCharCode.apply(null,s),Sc=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function Fc(s){return Sc?Sc.decode(s):_a?Buffer.from(s).toString("utf8"):decodeURIComponent(escape(fa(s)))}var ii=class s{static from(t,e){return t instanceof this&&t.le===e?t:new s(t,void 0,void 0,e)}constructor(t,e=0,i,n){if(typeof n=="boolean"&&(this.le=n),Array.isArray(t)&&(t=new Uint8Array(t)),t===0)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){i===void 0&&(i=t.byteLength-e);let o=new DataView(t,e,i);this._swapDataView(o)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof s){i===void 0&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength&&re("Creating view outside of available memory in ArrayBuffer");let o=new DataView(t.buffer,e,i);this._swapDataView(o)}else if(typeof t=="number"){let o=new DataView(new ArrayBuffer(t));this._swapDataView(o)}else re("Invalid input argument for BufferView: "+t)}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=s){return t instanceof DataView||t instanceof s?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array||re("BufferView.set(): Invalid data argument."),this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new s(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){return Fc(this.getUint8Array(t,e))}getLatin1String(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return fa(i)}getUnicodeString(t=0,e=this.byteLength){let i=[];for(let n=0;n<e&&t+n<this.byteLength;n+=2)i.push(this.getUint16(t+n));return fa(i)}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64&&this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64&&this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}};function ga(s,t){re(`${s} '${t}' was not loaded, try using full build of exifr.`)}var xn=class extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||ga(this.kind,t),e&&(t in e||(function(i,n){re(`Unknown ${i} '${n}'.`)})(this.kind,t),e[t].enabled||ga(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}},ns=new xn("file parser"),ge=new xn("segment parser"),rs=new xn("file reader"),Oc=Ea.fetch;function Ec(s,t){return(e=s).startsWith("data:")||e.length>1e4?ba(s,t,"base64"):xc&&s.includes("://")?ma(s,t,"url",Ns):xc?ba(s,t,"fs"):wn?ma(s,t,"url",Ns):void re("Invalid input argument");var e}async function ma(s,t,e,i){return rs.has(e)?ba(s,t,e):i?(async function(n,o){let l=await o(n);return new ii(l)})(s,i):void re(`Parser ${e} is not loaded`)}async function ba(s,t,e){let i=new(rs.get(e))(s,t);return await i.read(),i}var Ns=s=>Oc(s).then((t=>t.arrayBuffer())),Bs=s=>new Promise(((t,e)=>{let i=new FileReader;i.onloadend=()=>t(i.result||new ArrayBuffer),i.onerror=e,i.readAsArrayBuffer(s)})),ya=class extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}};function Le(s,t,e){let i=new ya;for(let[n,o]of e)i.set(n,o);if(Array.isArray(t))for(let n of t)s.set(n,i);else s.set(t,i);return i}function ka(s,t,e){let i,n=s.get(t);for(i of e)n.set(i[0],i[1])}var ei=new Map,Us=new Map,ss=new Map,Zi=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],An=["jfif","xmp","icc","iptc","ihdr"],$s=["tiff",...An],Zt=["ifd0","ifd1","exif","gps","interop"],ts=[...$s,...Zt],es=["makerNote","userComment"],Sn=["translateKeys","translateValues","reviveValues","multiSegment"],is=[...Sn,"sanitize","mergeOutput","silentErrors"],Vr=class{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}},Qi=class extends Vr{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,n){if(super(),Nt(this,"enabled",!1),Nt(this,"skip",new Set),Nt(this,"pick",new Set),Nt(this,"deps",new Set),Nt(this,"translateKeys",!1),Nt(this,"translateValues",!1),Nt(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=Zt.includes(t),this.canBeFiltered&&(this.dict=ei.get(t)),i!==void 0)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if(typeof i=="object"){if(this.enabled=!0,this.parse=i.parse!==!1,this.canBeFiltered){let{pick:o,skip:l}=i;o&&o.length>0&&this.translateTagSet(o,this.pick),l&&l.length>0&&this.translateTagSet(l,this.skip)}this.applyInheritables(i)}else i===!0||i===!1?this.parse=this.enabled=i:re(`Invalid options argument: ${i}`)}applyInheritables(t){let e,i;for(e of Sn)i=t[e],i!==void 0&&(this[e]=i)}translateTagSet(t,e){if(this.dict){let i,n,{tagKeys:o,tagValues:l}=this.dict;for(i of t)typeof i=="string"?(n=l.indexOf(i),n===-1&&(n=o.indexOf(Number(i))),n!==-1&&e.add(Number(o[n]))):e.add(i)}else for(let i of t)e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,Gr(this.pick,this.deps)):this.enabled&&this.pick.size>0&&Gr(this.pick,this.deps)}},fe={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,ihdr:void 0,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},Cc=new Map,Ci=class extends Vr{static useCached(t){let e=Cc.get(t);return e!==void 0||(e=new this(t),Cc.set(t,e)),e}constructor(t){super(),t===!0?this.setupFromTrue():t===void 0?this.setupFromUndefined():Array.isArray(t)?this.setupFromArray(t):typeof t=="object"?this.setupFromObject(t):re(`Invalid options argument ${t}`),this.firstChunkSize===void 0&&(this.firstChunkSize=wn?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of Zi)this[t]=fe[t];for(t of is)this[t]=fe[t];for(t of es)this[t]=fe[t];for(t of ts)this[t]=new Qi(t,fe[t],void 0,this)}setupFromTrue(){let t;for(t of Zi)this[t]=fe[t];for(t of is)this[t]=fe[t];for(t of es)this[t]=!0;for(t of ts)this[t]=new Qi(t,!0,void 0,this)}setupFromArray(t){let e;for(e of Zi)this[e]=fe[e];for(e of is)this[e]=fe[e];for(e of es)this[e]=fe[e];for(e of ts)this[e]=new Qi(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,Zt)}setupFromObject(t){let e;for(e of(Zt.ifd0=Zt.ifd0||Zt.image,Zt.ifd1=Zt.ifd1||Zt.thumbnail,Object.assign(this,t),Zi))this[e]=da(t[e],fe[e]);for(e of is)this[e]=da(t[e],fe[e]);for(e of es)this[e]=da(t[e],fe[e]);for(e of $s)this[e]=new Qi(e,fe[e],t[e],this);for(e of Zt)this[e]=new Qi(e,fe[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,Zt,ts),t.tiff===!0?this.batchEnableWithBool(Zt,!0):t.tiff===!1?this.batchEnableWithUserValue(Zt,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,Zt):typeof t.tiff=="object"&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,Zt)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let n=e[i];this[i].enabled=n!==!1&&n!==void 0}}setupGlobalFilters(t,e,i,n=i){if(t&&t.length){for(let l of n)this[l].enabled=!1;let o=_c(t,i);for(let[l,h]of o)Gr(this[l].pick,h),this[l].enabled=!0}else if(e&&e.length){let o=_c(e,i);for(let[l,h]of o)Gr(this[l].skip,h)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:n,icc:o}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),n.enabled||t.skip.add(33723),o.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:n}=this;n.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=Zt.some((o=>this[o].enabled===!0))||this.makerNote||this.userComment;for(let o of Zt)this[o].finalizeFilters()}get onlyTiff(){return!An.map((t=>this[t].enabled)).some((t=>t===!0))&&this.tiff.enabled}checkLoadedPlugins(){for(let t of $s)this[t].enabled&&!ge.has(t)&&ga("segment parser",t)}};function _c(s,t){let e,i,n,o,l=[];for(n of t){for(o of(e=ei.get(n),i=[],e))(s.includes(o[0])||s.includes(o[1]))&&i.push(o[0]);i.length&&l.push([n,i])}return l}function da(s,t){return s!==void 0?s:t!==void 0?t:void 0}function Gr(s,t){for(let e of t)s.add(e)}Nt(Ci,"default",fe);var si=class{constructor(t){Nt(this,"parsers",{}),Nt(this,"output",{}),Nt(this,"errors",[]),Nt(this,"pushToErrors",(e=>this.errors.push(e))),this.options=Ci.useCached(t)}async read(t){this.file=await(function(e,i){return typeof e=="string"?Ec(e,i):wn&&!Hd&&e instanceof HTMLImageElement?Ec(e.src,i):e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView?new ii(e):wn&&e instanceof Blob?ma(e,i,"blob",Bs):void re("Invalid input argument")})(t,this.options)}setup(){if(this.fileParser)return;let{file:t}=this,e=t.getUint16(0);for(let[i,n]of ns)if(n.canHandle(t,e))return this.fileParser=new n(this.options,this.file,this.parsers),t[i]=!0;this.file.close&&this.file.close(),re("Unknown file format")}async parse(){let{output:t,errors:e}=this;return this.setup(),this.options.silentErrors?(await this.executeParsers().catch(this.pushToErrors),e.push(...this.fileParser.errors)):await this.executeParsers(),this.file.close&&this.file.close(),this.options.silentErrors&&e.length>0&&(t.errors=e),jr(t)}async executeParsers(){let{output:t}=this;await this.fileParser.parse();let e=Object.values(this.parsers).map((async i=>{let n=await i.parse();i.assignToOutput(t,n)}));this.options.silentErrors&&(e=e.map((i=>i.catch(this.pushToErrors)))),await Promise.all(e)}async extractThumbnail(){this.setup();let{options:t,file:e}=this,i=ge.get("tiff",t);var n;if(e.tiff?n={start:0,type:"tiff"}:e.jpeg&&(n=await this.fileParser.getOrFindSegment("tiff")),n===void 0)return;let o=await this.fileParser.ensureSegmentChunk(n),l=this.parsers.tiff=new i(o,t,e),h=await l.extractThumbnail();return e.close&&e.close(),h}};async function Ta(s,t){let e=new si(t);return await e.read(s),e.parse()}var Vd=Object.freeze({__proto__:null,parse:Ta,Exifr:si,fileParsers:ns,segmentParsers:ge,fileReaders:rs,tagKeys:ei,tagValues:Us,tagRevivers:ss,createDictionary:Le,extendDictionary:ka,fetchUrlAsArrayBuffer:Ns,readBlobAsArrayBuffer:Bs,chunkedProps:Zi,otherSegments:An,segments:$s,tiffBlocks:Zt,segmentsAndBlocks:ts,tiffExtractables:es,inheritables:Sn,allFormatters:is,Options:Ci}),Wr=class{constructor(t,e,i){Nt(this,"errors",[]),Nt(this,"ensureSegmentChunk",(async n=>{let o=n.start,l=n.size||65536;if(this.file.chunked)if(this.file.available(o,l))n.chunk=this.file.subarray(o,l);else try{n.chunk=await this.file.readChunk(o,l)}catch(h){re(`Couldn't read segment: ${JSON.stringify(n)}. ${h.message}`)}else this.file.byteLength>o+l?n.chunk=this.file.subarray(o,l):n.size===void 0?n.chunk=this.file.subarray(o):re("Segment unreachable: "+JSON.stringify(n));return n.chunk})),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}injectSegment(t,e){this.options[t].enabled&&this.createParser(t,e)}createParser(t,e){let i=new(ge.get(t))(e,this.options,this.file);return this.parsers[t]=i}createParsers(t){for(let e of t){let{type:i,chunk:n}=e,o=this.options[i];if(o&&o.enabled){let l=this.parsers[i];l&&l.append||l||this.createParser(i,n)}}}async readSegments(t){let e=t.map(this.ensureSegmentChunk);await Promise.all(e)}},ti=class{static findPosition(t,e){let i=t.getUint16(e+2)+2,n=typeof this.headerLength=="function"?this.headerLength(t,e,i):this.headerLength,o=e+n,l=i-n;return{offset:e,length:i,headerLength:n,start:o,size:l,end:o+l}}static parse(t,e={}){return new this(t,new Ci({[this.type]:e}),t).parse()}normalizeInput(t){return t instanceof ii?t:new ii(t)}constructor(t,e={},i){Nt(this,"errors",[]),Nt(this,"raw",new Map),Nt(this,"handleError",(n=>{if(!this.options.silentErrors)throw n;this.errors.push(n.message)})),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=ss.get(e),n=Us.get(e),o=ei.get(e),l=this.options[e],h=l.reviveValues&&!!i,g=l.translateValues&&!!n,m=l.translateKeys&&!!o,d={};for(let[a,f]of t)h&&i.has(a)?f=i.get(a)(f):g&&n.has(a)&&(f=this.translateValue(f,n.get(a))),m&&o.has(a)&&(a=o.get(a)||a),d[a]=f;return d}translateValue(t,e){return e[t]||e.DEFAULT||t}assignToOutput(t,e){this.assignObjectToOutput(t,this.constructor.type,e)}assignObjectToOutput(t,e,i){if(this.globalOptions.mergeOutput)return Object.assign(t,i);t[e]?Object.assign(t[e],i):t[e]=i}};Nt(ti,"headerLength",4),Nt(ti,"type",void 0),Nt(ti,"multiSegment",!1),Nt(ti,"canHandle",(()=>!1));function Gd(s){return s===192||s===194||s===196||s===219||s===221||s===218||s===254}function Wd(s){return s>=224&&s<=239}function qd(s,t,e){for(let[i,n]of ge)if(n.canHandle(s,t,e))return i}var qr=class extends Wr{constructor(...t){super(...t),Nt(this,"appSegments",[]),Nt(this,"jpegSegments",[]),Nt(this,"unknownSegments",[])}static canHandle(t,e){return e===65496}async parse(){await this.findAppSegments(),await this.readSegments(this.appSegments),this.mergeMultiSegments(),this.createParsers(this.mergedAppSegments||this.appSegments)}setupSegmentFinderArgs(t){t===!0?(this.findAll=!0,this.wanted=new Set(ge.keyList())):(t=t===void 0?ge.keyList().filter((e=>this.options[e].enabled)):t.filter((e=>this.options[e].enabled&&ge.has(e))),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:n,wanted:o,remaining:l}=this;if(!n&&this.file.chunked&&(n=Array.from(o).some((h=>{let g=ge.get(h),m=this.options[h];return g.multiSegment&&m.multiSegment})),n&&await this.file.readWhole()),t=this.findAppSegmentsInRange(t,i.byteLength),!this.options.onlyTiff&&i.chunked){let h=!1;for(;l.size>0&&!h&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:g}=i,m=this.appSegments.some((d=>!this.file.available(d.offset||d.start,d.length||d.size)));if(h=t>g&&!m?!await i.readNextChunk(t):!await i.readNextChunk(g),(t=this.findAppSegmentsInRange(t,i.byteLength))===void 0)return}}}findAppSegmentsInRange(t,e){e-=2;let i,n,o,l,h,g,{file:m,findAll:d,wanted:a,remaining:f,options:A}=this;for(;t<e;t++)if(m.getUint8(t)===255){if(i=m.getUint8(t+1),Wd(i)){if(n=m.getUint16(t+2),o=qd(m,t,n),o&&a.has(o)&&(l=ge.get(o),h=l.findPosition(m,t),g=A[o],h.type=o,this.appSegments.push(h),!d&&(l.multiSegment&&g.multiSegment?(this.unfinishedMultiSegment=h.chunkNumber<h.chunkCount,this.unfinishedMultiSegment||f.delete(o)):f.delete(o),f.size===0)))break;A.recordUnknownSegments&&(h=ti.findPosition(m,t),h.marker=i,this.unknownSegments.push(h)),t+=n+1}else if(Gd(i)){if(n=m.getUint16(t+2),i===218&&A.stopAfterSos!==!1)return;A.recordJpegSegments&&this.jpegSegments.push({offset:t,length:n,marker:i}),t+=n+1}}return t}mergeMultiSegments(){if(!this.appSegments.some((e=>e.multiSegment)))return;let t=(function(e,i){let n,o,l,h=new Map;for(let g=0;g<e.length;g++)n=e[g],o=n[i],h.has(o)?l=h.get(o):h.set(o,l=[]),l.push(n);return Array.from(h)})(this.appSegments,"type");this.mergedAppSegments=t.map((([e,i])=>{let n=ge.get(e,this.options);return n.handleMultiSegments?{type:e,chunk:n.handleMultiSegments(i)}:i[0]}))}getSegment(t){return this.appSegments.find((e=>e.type===t))}async getOrFindSegment(t){let e=this.getSegment(t);return e===void 0&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}};Nt(qr,"type","jpeg"),ns.set("jpeg",qr);var Xd=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4],va=class extends ti{parseHeader(){var t=this.chunk.getUint16();t===18761?this.le=!0:t===19789&&(this.le=!1),this.chunk.le=this.le,this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:n,skip:o}=this.options[e];n=new Set(n);let l=n.size>0,h=o.size===0,g=this.chunk.getUint16(t);t+=2;for(let m=0;m<g;m++){let d=this.chunk.getUint16(t);if(l){if(n.has(d)&&(i.set(d,this.parseTag(t,d,e)),n.delete(d),n.size===0))break}else!h&&o.has(d)||i.set(d,this.parseTag(t,d,e));t+=12}return i}parseTag(t,e,i){let{chunk:n}=this,o=n.getUint16(t+2),l=n.getUint32(t+4),h=Xd[o];if(h*l<=4?t+=8:t=n.getUint32(t+8),(o<1||o>13)&&re(`Invalid TIFF value type. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${o}, offset ${t}`),t>n.byteLength&&re(`Invalid TIFF value offset. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${o}, offset ${t} is outside of chunk size ${n.byteLength}`),o===1)return n.getUint8Array(t,l);if(o===2)return Lc(n.getString(t,l));if(o===7)return n.getUint8Array(t,l);if(l===1)return this.parseTagValue(o,t);{let g=new((function(d){switch(d){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}})(o))(l),m=h;for(let d=0;d<l;d++)g[d]=this.parseTagValue(o,t),t+=m;return g}}parseTagValue(t,e){let{chunk:i}=this;switch(t){case 1:return i.getUint8(e);case 3:return i.getUint16(e);case 4:return i.getUint32(e);case 5:return i.getUint32(e)/i.getUint32(e+4);case 6:return i.getInt8(e);case 8:return i.getInt16(e);case 9:return i.getInt32(e);case 10:return i.getInt32(e)/i.getInt32(e+4);case 11:return i.getFloat(e);case 12:return i.getDouble(e);case 13:return i.getUint32(e);default:re(`Invalid tiff type ${t}`)}}},bn=class extends va{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1165519206&&t.getUint16(e+8)===0}async parse(){this.parseHeader();let{options:t}=this;return t.ifd0.enabled&&await this.parseIfd0Block(),t.exif.enabled&&await this.safeParse("parseExifBlock"),t.gps.enabled&&await this.safeParse("parseGpsBlock"),t.interop.enabled&&await this.safeParse("parseInteropBlock"),t.ifd1.enabled&&await this.safeParse("parseThumbnailBlock"),this.createOutput()}safeParse(t){let e=this[t]();return e.catch!==void 0&&(e=e.catch(this.handleError)),e}findIfd0Offset(){this.ifd0Offset===void 0&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(this.ifd1Offset===void 0){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;let{file:t}=this;this.findIfd0Offset(),this.ifd0Offset<8&&re("Malformed EXIF data"),!t.chunked&&this.ifd0Offset>t.byteLength&&re(`IFD0 offset points to outside of file.
2
2
  this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${t.byteLength}`),t.tiff&&await t.ensureChunk(this.ifd0Offset,Ac(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return e.size!==0?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async parseExifBlock(){if(this.exif||(this.ifd0||await this.parseIfd0Block(),this.exifOffset===void 0))return;this.file.tiff&&await this.file.ensureChunk(this.exifOffset,Ac(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&i.length===1&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps||(this.ifd0||await this.parseIfd0Block(),this.gpsOffset===void 0))return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",kc(...t.get(2),t.get(1))),t.set("longitude",kc(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),this.interopOffset!==void 0||this.exif||await this.parseExifBlock(),this.interopOffset!==void 0))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),this.ifd1===void 0)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,n={};for(e of Zt)if(t=this[e],!Rc(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if(e==="ifd1")continue;Object.assign(n,i)}else n[e]=i;return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,n]of Object.entries(e))this.assignObjectToOutput(t,i,n)}};function kc(s,t,e,i){var n=s+t/60+e/3600;return i!=="S"&&i!=="W"||(n*=-1),n}Nt(bn,"type","tiff"),Nt(bn,"headerLength",10),ge.set("tiff",bn);var Kd=Object.freeze({__proto__:null,default:Vd,Exifr:si,fileParsers:ns,segmentParsers:ge,fileReaders:rs,tagKeys:ei,tagValues:Us,tagRevivers:ss,createDictionary:Le,extendDictionary:ka,fetchUrlAsArrayBuffer:Ns,readBlobAsArrayBuffer:Bs,chunkedProps:Zi,otherSegments:An,segments:$s,tiffBlocks:Zt,segmentsAndBlocks:ts,tiffExtractables:es,inheritables:Sn,allFormatters:is,Options:Ci,parse:Ta}),Pa={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Nc=Object.assign({},Pa,{firstChunkSize:4e4,gps:[1,2,3,4]});async function Yd(s){let t=new si(Nc);await t.read(s);let e=await t.parse();if(e&&e.gps){let{latitude:i,longitude:n}=e.gps;return{latitude:i,longitude:n}}}var Bc=Object.assign({},Pa,{tiff:!1,ifd1:!0,mergeOutput:!1});async function Jd(s){let t=new si(Bc);await t.read(s);let e=await t.extractThumbnail();return e&&_a?Ca.from(e):e}async function Qd(s){let t=await this.thumbnail(s);if(t!==void 0){let e=new Blob([t]);return URL.createObjectURL(e)}}var $c=Object.assign({},Pa,{firstChunkSize:4e4,ifd0:[274]});async function Uc(s){let t=new si($c);await t.read(s);let e=await t.parse();if(e&&e.ifd0)return e.ifd0[274]}var zc=Object.freeze({1:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:0,rad:0},2:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:0,rad:0},3:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:180,rad:180*Math.PI/180},4:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:180,rad:180*Math.PI/180},5:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:90,rad:90*Math.PI/180},6:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:90,rad:90*Math.PI/180},7:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:270,rad:270*Math.PI/180},8:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:270,rad:270*Math.PI/180}}),Fs=!0,Os=!0;if(typeof navigator=="object"){let s=navigator.userAgent;if(s.includes("iPad")||s.includes("iPhone")){let t=s.match(/OS (\d+)_(\d+)/);if(t){let[,e,i]=t;Fs=Number(e)+.1*Number(i)<13.4,Os=!1}}else if(s.includes("OS X 10")){let[,t]=s.match(/OS X 10[_.](\d+)/);Fs=Os=Number(t)<15}if(s.includes("Chrome/")){let[,t]=s.match(/Chrome\/(\d+)/);Fs=Os=Number(t)<81}else if(s.includes("Firefox/")){let[,t]=s.match(/Firefox\/(\d+)/);Fs=Os=Number(t)<77}}async function Zd(s){let t=await Uc(s);return Object.assign({canvas:Fs,css:Os},zc[t])}var wa=class extends ii{constructor(...t){super(...t),Nt(this,"ranges",new xa),this.byteLength!==0&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(t===0&&this.byteLength===0&&i){let n=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(n)}else{let n=t+e;if(n>this.byteLength){let{dataView:o}=this._extend(n);this._swapDataView(o)}}}_extend(t){let e;e=_a?Ca.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let n=super.set(t,e);return this.ranges.add(e,n.byteLength),n}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}},xa=class{constructor(){Nt(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let n=t+e,o=this.list.filter((l=>Tc(t,l.offset,n)||Tc(t,l.end,n)));if(o.length>0){t=Math.min(t,...o.map((h=>h.offset))),n=Math.max(n,...o.map((h=>h.end))),e=n-t;let l=o.shift();l.offset=t,l.length=e,l.end=n,this.list=this.list.filter((h=>!o.includes(h)))}else this.list.push({offset:t,length:e,end:n})}available(t,e){let i=t+e;return this.list.some((n=>n.offset<=t&&i<=n.end))}};function Tc(s,t,e){return s<=t&&t<=e}var Xr=class extends wa{constructor(t,e){super(0),Nt(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,(e=this.safeWrapAddress(t,e))!==0)return this._readChunk(t,e)}safeWrapAddress(t,e){return this.size!==void 0&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(this.ranges.list.length!==0)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return this.size!==void 0&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}};rs.set("blob",class extends Xr{async readWhole(){this.chunked=!1;let s=await Bs(this.input);this._swapArrayBuffer(s)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(s,t){let e=t?s+t:void 0,i=this.input.slice(s,e),n=await Bs(i);return this.set(n,s,!0)}});var tu=Object.freeze({__proto__:null,default:Kd,Exifr:si,fileParsers:ns,segmentParsers:ge,fileReaders:rs,tagKeys:ei,tagValues:Us,tagRevivers:ss,createDictionary:Le,extendDictionary:ka,fetchUrlAsArrayBuffer:Ns,readBlobAsArrayBuffer:Bs,chunkedProps:Zi,otherSegments:An,segments:$s,tiffBlocks:Zt,segmentsAndBlocks:ts,tiffExtractables:es,inheritables:Sn,allFormatters:is,Options:Ci,parse:Ta,gpsOnlyOptions:Nc,gps:Yd,thumbnailOnlyOptions:Bc,thumbnail:Jd,thumbnailUrl:Qd,orientationOnlyOptions:$c,orientation:Uc,rotations:zc,get rotateCanvas(){return Fs},get rotateCss(){return Os},rotation:Zd});rs.set("url",class extends Xr{async readWhole(){this.chunked=!1;let s=await Ns(this.input);s instanceof ArrayBuffer?this._swapArrayBuffer(s):s instanceof Uint8Array&&this._swapBuffer(s)}async _readChunk(s,t){let e=t?s+t-1:void 0,i=this.options.httpHeaders||{};(s||e)&&(i.range=`bytes=${[s,e].join("-")}`);let n=await Oc(this.input,{headers:i}),o=await n.arrayBuffer(),l=o.byteLength;if(n.status!==416)return l!==t&&(this.size=s+l),this.set(o,s,!0)}});ii.prototype.getUint64=function(s){let t=this.getUint32(s),e=this.getUint32(s+4);return t<1048575?t<<32|e:typeof Hr!==void 0?(console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),Hr(t)<<Hr(32)|Hr(e)):void re("Trying to read 64b value but JS can only handle 53b numbers.")};var Aa=class extends Wr{parseBoxes(t=0){let e=[];for(;t<this.file.byteLength-4;){let i=this.parseBoxHead(t);if(e.push(i),i.length===0)break;t+=i.length}return e}parseSubBoxes(t){t.boxes=this.parseBoxes(t.start)}findBox(t,e){return t.boxes===void 0&&this.parseSubBoxes(t),t.boxes.find((i=>i.kind===e))}parseBoxHead(t){let e=this.file.getUint32(t),i=this.file.getString(t+4,4),n=t+8;return e===1&&(e=this.file.getUint64(t+8),n+=8),{offset:t,length:e,kind:i,start:n}}parseBoxFullHead(t){if(t.version!==void 0)return;let e=this.file.getUint32(t.start);t.version=e>>24,t.start+=4}},Kr=class extends Aa{static canHandle(t,e){if(e!==0)return!1;let i=t.getUint16(2);if(i>50)return!1;let n=16,o=[];for(;n<i;)o.push(t.getString(n,4)),n+=4;return o.includes(this.type)}async parse(){let t=this.file.getUint32(0),e=this.parseBoxHead(t);for(;e.kind!=="meta";)t+=e.length,await this.file.ensureChunk(t,16),e=this.parseBoxHead(t);await this.file.ensureChunk(e.offset,e.length),this.parseBoxFullHead(e),this.parseSubBoxes(e),this.options.icc.enabled&&await this.findIcc(e),this.options.tiff.enabled&&await this.findExif(e)}async registerSegment(t,e,i){await this.file.ensureChunk(e,i);let n=this.file.subarray(e,i);this.createParser(t,n)}async findIcc(t){let e=this.findBox(t,"iprp");if(e===void 0)return;let i=this.findBox(e,"ipco");if(i===void 0)return;let n=this.findBox(i,"colr");n!==void 0&&await this.registerSegment("icc",n.offset+12,n.length)}async findExif(t){let e=this.findBox(t,"iinf");if(e===void 0)return;let i=this.findBox(t,"iloc");if(i===void 0)return;let n=this.findExifLocIdInIinf(e),o=this.findExtentInIloc(i,n);if(o===void 0)return;let[l,h]=o;await this.file.ensureChunk(l,h);let g=4+this.file.getUint32(l);l+=g,h-=g,await this.registerSegment("tiff",l,h)}findExifLocIdInIinf(t){this.parseBoxFullHead(t);let e,i,n,o,l=t.start,h=this.file.getUint16(l);for(l+=2;h--;){if(e=this.parseBoxHead(l),this.parseBoxFullHead(e),i=e.start,e.version>=2&&(n=e.version===3?4:2,o=this.file.getString(i+n+2,4),o==="Exif"))return this.file.getUintBytes(i,n);l+=e.length}}get8bits(t){let e=this.file.getUint8(t);return[e>>4,15&e]}findExtentInIloc(t,e){this.parseBoxFullHead(t);let i=t.start,[n,o]=this.get8bits(i++),[l,h]=this.get8bits(i++),g=t.version===2?4:2,m=t.version===1||t.version===2?2:0,d=h+n+o,a=t.version===2?4:2,f=this.file.getUintBytes(i,a);for(i+=a;f--;){let A=this.file.getUintBytes(i,g);i+=g+m+2+l;let C=this.file.getUint16(i);if(i+=2,A===e)return C>1&&console.warn(`ILOC box has more than one extent but we're only processing one
3
- Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+h,n),this.file.getUintBytes(i+h+n,o)];i+=C*d}}},Yr=class extends Kr{};Nt(Yr,"type","heic");var Jr=class extends Kr{};Nt(Jr,"type","avif"),ns.set("heic",Yr),ns.set("avif",Jr),Le(ei,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),Le(ei,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),Le(ei,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),Le(Us,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);var yn=Le(Us,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]),Pc={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};yn.set(37392,Pc),yn.set(41488,Pc);var ua={0:"Normal",1:"Low",2:"High"};function Dc(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Ic(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function pa(s){if(typeof s=="string"){var[t,e,i,n,o,l]=s.trim().split(/[-: ]/g).map(Number),h=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(o)||Number.isNaN(l)||(h.setHours(n),h.setMinutes(o),h.setSeconds(l)),Number.isNaN(+h)?s:h}}function mn(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Mc(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Mc(s[e],s[e+1]));return Lc(String.fromCodePoint(...t))}function Mc(s,t){return s<<8|t}yn.set(41992,ua),yn.set(41993,ua),yn.set(41994,ua),Le(ss,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Fc(s):s}],[306,pa],[40091,mn],[40092,mn],[40093,mn],[40094,mn],[40095,mn]]),Le(ss,"exif",[[40960,Ic],[36864,Ic],[36867,pa],[36868,pa],[40962,Dc],[40963,Dc]]),Le(ss,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var vn=class extends ti{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:ii.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(o){let l={},h={};for(let g of Gc)l[g]=[],h[g]=0;return o.replace(nu,((g,m,d)=>{if(m==="<"){let a=++h[d];return l[d].push(a),`${g}#${a}`}return`${g}#${l[d].pop()}`}))})(t);let e=Qr.findAll(t,"rdf","Description");e.length===0&&e.push(new Qr("rdf","Description",void 0,t));let i,n={};for(let o of e)for(let l of o.properties)i=su(l.ns,n),Hc(l,i);return(function(o){let l;for(let h in o)l=o[h]=jr(o[h]),l===void 0&&delete o[h];return jr(o)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};Nt(vn,"type","xmp"),Nt(vn,"multiSegment",!0),ge.set("xmp",vn);var Sa=class s{static findAll(t){return jc(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=Vc(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},Qr=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return jc(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],o=t[8];return new s(e,i,n,o)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=Sa.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?Vc(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return iu(this.children.map(eu));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)Hc(e,t);return this.value!==void 0&&(t.value=this.value),jr(t)}};function Hc(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var eu=s=>s.serialize(),iu=s=>s.length===1?s[0]:s,su=(s,t)=>t[s]?t[s]:t[s]={};function jc(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function Vc(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var Gc=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],nu=new RegExp(`(<|\\/)(${Gc.join("|")})`,"g"),Wc=tu;async function zs(s){try{return await Wc.parse(s)||null}catch{return null}}function we(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function Hs(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let h=await s.arrayBuffer(),g=globalThis.Buffer,m=typeof g<"u"?g.from(h).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(h)));return`data:${s.type||"image/png"};base64,${m}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((h,g)=>{let m=new FileReader;m.onload=()=>h(m.result),m.onerror=g,m.readAsDataURL(s)});let o=document.createElement("canvas");o.width=Math.round(t.width*n),o.height=Math.round(t.height*n),o.getContext("2d").drawImage(t,0,0,o.width,o.height),t.close();let l=s.type==="image/png"?"image/png":"image/jpeg";return o.toDataURL(l,l==="image/png"?void 0:.82)}function Da(s,t=21,e=.2,i=128){let{data:n,width:o,height:l}=s,h=o+1,g=new Float64Array((o+1)*(l+1)),m=new Float64Array((o+1)*(l+1)),d=new Uint8Array(o*l);for(let f=0;f<l;f++){let A=0,C=0,u=f*o,y=(f+1)*h,r=f*h;for(let c=0;c<o;c++){let b=(u+c)*4,w=n[b]*77+n[b+1]*150+n[b+2]*29>>8;d[u+c]=w,A+=w,C+=w*w,g[y+c+1]=g[r+c+1]+A,m[y+c+1]=m[r+c+1]+C}}let a=Math.floor(t/2);for(let f=0;f<l;f++){let A=Math.max(0,f-a),C=Math.min(l-1,f+a),u=A*h,y=(C+1)*h;for(let r=0;r<o;r++){let c=Math.max(0,r-a),b=Math.min(o-1,r+a),w=(b-c+1)*(C-A+1),P=g[y+b+1]-g[u+b+1]-g[y+c]+g[u+c],E=m[y+b+1]-m[u+b+1]-m[y+c]+m[u+c],I=P/w,N=Math.max(0,E/w-I*I),z=Math.sqrt(N),H=I*(1+e*(z/i-1)),X=f*o+r,it=d[X]<H?0:255,at=X*4;n[at]=it,n[at+1]=it,n[at+2]=it}}return s}function Ia(s,t=21,e=.2,i=128){return new Promise(n=>{let o=new Image;o.onload=()=>{let l=document.createElement("canvas");l.width=o.width,l.height=o.height;let h=l.getContext("2d");h.drawImage(o,0,0);let g=h.getImageData(0,0,l.width,l.height);Da(g,t,e,i),h.putImageData(g,0,0);let m=s.startsWith("data:image/png"),d=m?"image/png":"image/jpeg";n(l.toDataURL(d,m?void 0:.82))},o.src=s})}function Ma(s){return new Promise(t=>{let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=e.height,i.height=e.width;let n=i.getContext("2d");n.translate(i.width/2,i.height/2),n.rotate(Math.PI/2),n.drawImage(e,-e.width/2,-e.height/2);let o=s.startsWith("data:image/png"),l=o?"image/png":"image/jpeg";t(i.toDataURL(l,o?void 0:.82))},e.src=s})}function Ra(s,t=""){if(!s)return"";let e=s.getCroppedCanvas(),i=t.startsWith("data:image/png"),n=i?"image/png":"image/jpeg";return e.toDataURL(n,i?void 0:.82)}function Ge(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=s.crop&&typeof s.crop=="object"&&s.crop.width>0&&s.crop.height>0?{x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:null,e=(Math.round(s.rotation||0)%360+360)%360,i=s.filter==="bw"?"bw":"none";return{crop:t,rotation:e,filter:i}}function La(s){if(!s)return!1;let t=Ge(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function js(s,t){let e=Ge(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,o=document.createElement("canvas"),l=i,h=n,g=0,m=0;e.crop&&(g=Math.max(0,Math.min(e.crop.x,i)),m=Math.max(0,Math.min(e.crop.y,n)),l=Math.max(1,Math.min(e.crop.width,i-g)),h=Math.max(1,Math.min(e.crop.height,n-m))),o.width=l,o.height=h,o.getContext("2d").drawImage(s,g,m,l,h,0,0,l,h);let a=o;if(e.rotation!==0){let f=e.rotation,A=document.createElement("canvas");f===90||f===270?(A.width=a.height,A.height=a.width):(A.width=a.width,A.height=a.height);let C=A.getContext("2d");C.translate(A.width/2,A.height/2),C.rotate(f*Math.PI/180),C.drawImage(a,-a.width/2,-a.height/2),a=A}if(e.filter==="bw"){let f=a.getContext("2d"),A=f.getImageData(0,0,a.width,a.height);Da(A),f.putImageData(A,0,0)}return a}function Zr(s,t){if(!s)return Promise.resolve("");let e=Ge(t);return La(e)?new Promise((i,n)=>{let o=new Image;o.onload=()=>{try{let l=s.startsWith("data:image/png"),h=l?"image/png":"image/jpeg",g=js(o,e);i(g.toDataURL(h,l?void 0:.82))}catch(l){n(l)}},o.onerror=n,o.src=s}):Promise.resolve(s)}var _i=class{#t=null;#e=new Map;#i=new Map;constructor(t=Ls()){this.#t=t}get adapter(){return this.#t}get store(){return this.#t?.store??null}async init(){return this.#t.init()}listDocsSync(){return typeof this.#t.listDocsSync=="function"?this.#t.listDocsSync().map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}}):[]}async listDocs(){return(await this.#t.listDocs()).map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}})}getDocSync(t){if(!t)return null;if(typeof this.#t.getDocSync=="function"){let n=this.#t.getDocSync(t);return n?{id:n.id,name:n.name||"",pages:this.#s(n.pages)}:null}let i=this.listDocsSync().find(n=>n.id===t);return i?{id:i.id,name:i.name,pages:i.pages||[]}:null}async getDoc(t){return this.getDocSync(t)}async createDoc(t="Untitled Document",e=[]){let i=we(),n=this.#s(e),o={id:i,name:t||"Untitled Document",pages:n};return await this.#t.saveDoc(i,o),o}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=this.#s(e.pages);await this.#t.saveDoc(t,{id:t,name:e.name||"",pages:i})}async renameDoc(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);i.name=e,await this.saveDoc(t,i)}async deleteDoc(t,{soft:e=!0,timeoutMs:i=5e3}={}){if(!t)return;let n=this.getDocSync(t);if(n){if(this.#n(t),await this.#t.deleteDoc(t),e&&i>0){let o=setTimeout(async()=>{this.#e.delete(t)},i);this.#e.set(t,{doc:n,timerId:o})}return{id:t,name:n.name,undo:()=>this.undoDeleteDoc(t)}}}#n(t){if(this.#e.has(t)){let e=this.#e.get(t);clearTimeout(e.timerId),this.#e.delete(t)}}async undoDeleteDoc(t){let e=this.#e.get(t);return e?(clearTimeout(e.timerId),this.#e.delete(t),await this.#t.saveDoc(t,e.doc),e.doc):null}isSoftDeletedDoc(t){return this.#e.has(t)}async addPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=Array.isArray(e)?e:[e];i.pages.push(...n),await this.saveDoc(t,i)}async updatePage(t,e,i){let n=await this.getDoc(t);if(!n)throw new Error(`Document "${t}" not found`);let o=n.pages.findIndex(l=>l.id===e);if(o===-1)throw new Error(`Page "${e}" not found in document "${t}"`);n.pages[o]={...n.pages[o],...i},await this.saveDoc(t,n)}async reorderPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=new Map(i.pages.map(l=>[l.id,l])),o=[];for(let l of e)n.has(l)&&(o.push(n.get(l)),n.delete(l));for(let l of n.values())o.push(l);i.pages=o,await this.saveDoc(t,i)}async deletePage(t,e,{soft:i=!0,timeoutMs:n=5e3}={}){let o=await this.getDoc(t);if(!o)throw new Error(`Document "${t}" not found`);let l=o.pages.findIndex(d=>d.id===e);if(l===-1)return;let[h]=o.pages.splice(l,1);await this.saveDoc(t,o);let g=`${t}:${e}`;if(this.#r(g),!i||n<=0){if(typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(d){console.warn("[DocRepository] Adapter deletePage error:",d)}return}let m=setTimeout(async()=>{if(this.#i.delete(g),typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(d){console.warn("[DocRepository] Adapter deletePage error:",d)}},n);return this.#i.set(g,{docId:t,pageId:e,page:h,index:l,timerId:m}),{docId:t,pageId:e,undo:()=>this.undoDeletePage(t,e)}}#r(t){if(this.#i.has(t)){let e=this.#i.get(t);clearTimeout(e.timerId),this.#i.delete(t)}}async undoDeletePage(t,e){let i=`${t}:${e}`,n=this.#i.get(i);if(!n)return null;clearTimeout(n.timerId),this.#i.delete(i);let o=await this.getDoc(t);if(!o)return null;let l=Math.min(n.index,o.pages.length);return o.pages.splice(l,0,n.page),await this.saveDoc(t,o),n.page}isSoftDeletedPage(t,e){return this.#i.has(`${t}:${e}`)}subscribe(t){return this.#t.subscribe(t)}async getAllDocs(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]=i;return e}async exportAll(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]={name:i.name,pages:JSON.stringify(i.pages)};return e}async importDocs(t){let e=0;for(let[i,n]of Object.entries(t||{})){await this.getDoc(i)||e++;let l=this.#s(n.pages);await this.saveDoc(i,{name:n.name||"",pages:l})}return e}#s(t){if(Array.isArray(t))return[...t];if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}},Fa=new _i;var Oa=".";function eo(){return Oa}function os(s){typeof s=="string"&&(Oa=s.replace(/\/+$/,"")||".")}function ni(s){if(!s)return"";if(/^(https?:|\/\/|data:|blob:)/i.test(s))return s;let t=s.replace(/^\/+/,""),e=Oa;return!e||e==="."?t:`${e}/${t}`}var to=new Map;function ri(s,t){let e=t();if(e)return Promise.resolve(e);if(to.has(s))return to.get(s);let i=new Promise((n,o)=>{if(typeof document>"u"){o(new Error(`Cannot load script "${s}" in an environment without DOM document.`));return}let l=ni(s),h=document.querySelector(`script[src="${l}"], script[src="${s}"]`);if(h){if(t()){n(t());return}h.addEventListener("load",()=>n(t()),{once:!0}),h.addEventListener("error",()=>o(new Error(`Failed to load "${s}": Network error`)),{once:!0});return}let g=document.createElement("script");g.src=l,g.async=!0,g.onload=()=>{let m=t();n(m)},g.onerror=()=>{to.delete(s),g.remove(),o(new Error(`Failed to load script "${s}": Network error`))},document.head.appendChild(g)});return to.set(s,i),i}async function io(){return ri("js/lib/cropper.js",()=>window.Cropper)}async function Vs(){return ri("js/lib/pdfkit.js",()=>window.PDFDocument)}async function so(){return ri("js/lib/jszip.min.js",()=>window.JSZip)}async function ki(){return ri("js/lib/marked.min.js",()=>window.marked)}async function no(){return ri("js/lib/peerjs.min.js",()=>window.Peer)}async function ro(){return ri("js/lib/qrcode.js",()=>window.qrcode)}async function oo(){return ri("js/lib/tesseract.min.js",()=>window.Tesseract)}var qc="2026-11-01T09:35:29.171Z",Xc="0.1.0";var oi=class{async recognizeImageText(t,e={}){throw new Error("OcrPort.recognizeImageText() must be implemented by adapter")}async recognizeDocumentPages(t,e={}){throw new Error("OcrPort.recognizeDocumentPages() must be implemented by adapter")}async getOcrWorker(t="eng",e=null){throw new Error("OcrPort.getOcrWorker() must be implemented by adapter")}async terminateOcrWorker(){throw new Error("OcrPort.terminateOcrWorker() must be implemented by adapter")}};var Pe=class extends oi{async recognizeImageText(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async recognizeDocumentPages(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async getOcrWorker(){return null}async terminateOcrWorker(){}};var ai=class{async exportDocumentAsPdf(t,e,i={}){throw new Error("PdfPort.exportDocumentAsPdf() must be implemented by adapter")}async renderPdfPagesToDataUrls(t){throw new Error("PdfPort.renderPdfPagesToDataUrls() must be implemented by adapter")}};var We=class extends ai{async exportDocumentAsPdf(t,e,i={}){let n=new Error('Feature "pdf" is disabled or PDF module not opted in');throw n.code="FEATURE_DISABLED",n}async renderPdfPagesToDataUrls(t){return[]}};var qe=class{async renderEdits(t,e){throw new Error("ImageProcessorPort.renderEdits() must be implemented by adapter")}async crop(t,e){throw new Error("ImageProcessorPort.crop() must be implemented by adapter")}async rotate(t,e){throw new Error("ImageProcessorPort.rotate() must be implemented by adapter")}async applyFilter(t,e){throw new Error("ImageProcessorPort.applyFilter() must be implemented by adapter")}};function ru(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var li=class extends qe{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await ru(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),js(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};var as=class extends qe{async renderEdits(t,e){return t}async crop(t,e){return t}async rotate(t,e){return t}async applyFilter(t,e){return t}};function _n(s={}){let t=s&&s.crop&&typeof s.crop=="object"?{x:Math.max(0,Math.min(1,Number(s.crop.x)||0)),y:Math.max(0,Math.min(1,Number(s.crop.y)||0)),w:Math.max(0,Math.min(1,Number(s.crop.w)||1)),h:Math.max(0,Math.min(1,Number(s.crop.h)||1))}:null,e=0;if(s&&s.rotate!==void 0){let n=(Math.round(Number(s.rotate)/90)*90%360+360)%360;(n===90||n===180||n===270)&&(e=n)}let i=s&&s.filter==="bw"?"bw":"none";return{crop:t,rotate:e,filter:i}}function ao(s){return s?!!(s.crop||s.rotate&&s.rotate!==0||s.filter&&s.filter!=="none"):!1}var ls=class{constructor(t){this.id=t.id,this.src=t.src,this.originalSrc=t.originalSrc||t.src,this.edits=_n(t.edits),this.name=t.name||"Page",this.type=t.type||"image",this.orientation=t.orientation||1,this.ocrText=t.ocrText||null,this.ocrConfidence=t.ocrConfidence??null}get isModified(){return ao(this.edits)}toJSON(){return{id:this.id,src:this.src,originalSrc:this.originalSrc,edits:this.edits,name:this.name,type:this.type,orientation:this.orientation,ocrText:this.ocrText,ocrConfidence:this.ocrConfidence}}},En=class{constructor(t){this.id=t.id,this.name=t.name||"Untitled Document",this.pages=Array.isArray(t.pages)?t.pages.map(e=>e instanceof ls?e:new ls(e)):[],this.createdAt=t.createdAt||Date.now(),this.updatedAt=t.updatedAt||Date.now()}get pageCount(){return this.pages.length}toJSON(){return{id:this.id,name:this.name,pages:this.pages.map(t=>t.toJSON()),createdAt:this.createdAt,updatedAt:this.updatedAt}}},Cn=class{constructor(t={}){this.mode=t.mode==="single"?"single":"batch",this.aspect=t.aspect||"auto",this.docId=t.docId||null,this.maxPages=Math.max(0,Number(t.maxPages)||0),this.stage="viewfinder",this.activePageIndex=0,this.history=[],this.future=[]}pushHistory(t){this.history.push(t),this.future=[],this.history.length>50&&this.history.shift()}undo(){if(this.history.length===0)return null;let t=this.history.pop();return this.future.push(t),t}redo(){if(this.future.length===0)return null;let t=this.future.pop();return this.history.push(t),t}};var te={PAGE_ADDED:"copio:page-added",PAGE_REMOVED:"copio:page-removed",PAGES_CHANGED:"copio:pages-changed",SCAN_COMPLETE:"copio:scan-complete",EXPORT_PROGRESS:"copio:export-progress",EXPORT_COMPLETE:"copio:export-complete",OCR_COMPLETE:"copio:ocr-complete",SYNC_CONNECTED:"copio:sync-connected",ERROR:"copio:error"};function lo(s,t,e={}){let i=new CustomEvent(t,{bubbles:!0,composed:!0,cancelable:!0,detail:e});return s&&typeof s.dispatchEvent=="function"&&s.dispatchEvent(i),i}var $a=["crop","rotate","filter","ocr","export","sync"],Na=["pdf","zip","png","jpg"],Ba=["eng"],Ua={};function Pi(s,t){!s||!t||(Ua[s]=t,typeof globalThis<"u"&&(globalThis.__copio_services__=globalThis.__copio_services__||{},globalThis.__copio_services__[s]=t))}function Ti(s){return Ua[s]?Ua[s]:typeof globalThis<"u"&&globalThis.__copio_services__?.[s]?globalThis.__copio_services__[s]:null}function ou(s){return s?s instanceof Set?new Set(s):Array.isArray(s)?new Set(s.map(t=>String(t).trim().toLowerCase()).filter(Boolean)):typeof s=="string"?new Set(s.split(/[\s,]+/).map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set($a):new Set($a)}function co(s,t){return s?Array.isArray(s)?s.map(e=>String(e).trim().toLowerCase()).filter(Boolean):typeof s=="string"?s.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean):[...t]:[...t]}var cs=class{#t=new Set($a);#e=[...Na];#i=[...Ba];#n=0;#r="";#s=null;#o=null;#c={};#a=!0;#d=!0;#p=null;#u=new Map;#l=new Map;constructor(t={}){this.#s=t.storage||Ls(t),this.#o=t.repository||new _i(this.#s),t.services&&(this.#c={...t.services}),t.imageProcessor?(this.#p=t.imageProcessor,this.#c.imageProcessor=t.imageProcessor):this.getService("imageProcessor")?this.#p=this.getService("imageProcessor"):typeof document<"u"?this.#p=new li:this.#p=new as,t.features!==void 0&&this.setFeatures(t.features),t.exportFormats!==void 0&&(this.#e=co(t.exportFormats,Na)),t.ocrLanguages!==void 0&&(this.#i=co(t.ocrLanguages,Ba)),t.maxPages!==void 0&&(this.#n=Math.max(0,Number(t.maxPages)||0)),t.assetBase!==void 0&&os(t.assetBase),t.licenseKey!==void 0&&(this.#r=String(t.licenseKey||"")),t.ocr!==void 0?this.ocr=!!t.ocr:t.features!==void 0&&!this.hasFeature("ocr")&&(this.ocr=!1),t.pdf!==void 0?this.pdf=!!t.pdf:t.exportFormats!==void 0&&!this.#e.includes("pdf")&&(this.pdf=!1)}async init(){return this.#s.init()}setService(t,e){this.#c[t]=e}getService(t){return this.#c[t]||Ti(t)}hasFeature(t){return t?this.#t.has(String(t).trim().toLowerCase()):!1}get features(){return Array.from(this.#t)}setFeatures(t){this.#t=ou(t),this.hasFeature("ocr")?(this.#a=!0,this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr"))):(this.#a=!1,this.setService("ocr",new Pe))}enableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.add(e),e==="ocr"&&(this.#a=!0,this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr")))}}disableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.delete(e),e==="ocr"&&(this.#a=!1,this.setService("ocr",new Pe))}}get ocr(){return this.#a&&this.hasFeature("ocr")}set ocr(t){this.#a=!!t,this.#a?(this.enableFeature("ocr"),this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr"))):(this.disableFeature("ocr"),this.setService("ocr",new Pe))}get pdf(){return this.#d&&this.#e.includes("pdf")}set pdf(t){this.#d=!!t,this.#d?(this.#e.includes("pdf")||this.#e.push("pdf"),this.getService("pdf")instanceof We&&this.setService("pdf",Ti("pdf"))):(this.#e=this.#e.filter(e=>e!=="pdf"),this.setService("pdf",new We))}get exportFormats(){return[...this.#e]}set exportFormats(t){this.#e=co(t,Na),this.#e.includes("pdf")?(this.#d=!0,this.getService("pdf")instanceof We&&this.setService("pdf",Ti("pdf"))):(this.#d=!1,this.setService("pdf",new We))}get ocrLanguages(){return[...this.#i]}set ocrLanguages(t){this.#i=co(t,Ba)}get maxPages(){return this.#n}set maxPages(t){this.#n=Math.max(0,Number(t)||0)}get assetBase(){return eo()}set assetBase(t){os(t)}get licenseKey(){return this.#r}set licenseKey(t){this.#r=String(t||"")}get storage(){return this.#s}setStorage(t){t&&(this.#s=t,this.#o=new _i(this.#s))}#f(t,e){this.#u.has(t)||this.#u.set(t,[]);let i=this.#u.get(t);i.push(e),i.length>50&&i.shift(),this.#l.has(t)&&(this.#l.get(t).length=0)}get imageProcessor(){return this.#p}setImageProcessor(t){t&&(this.#p=t,this.setService("imageProcessor",t))}get docs(){return this.#o}async listDocuments(){return this.#o.listDocs()}async getDocument(t){return this.#o.getDoc(t)}async createDocument(t,e){return this.#o.createDoc(t,e)}async deleteDocument(t,e={}){return this.#o.deleteDoc(t,e)}async undoDeleteDocument(t){return this.#o.undoDeleteDoc(t)}async renameDocument(t,e){return this.#o.renameDoc(t,e)}async addPages(t,e){return this.#o.addPages(t,e)}async deletePage(t,e,i={}){return this.#f(t,{type:"delete",pageId:e}),this.#o.deletePage(t,e,i)}async undoDeletePage(t,e){return this.#o.undoDeletePage(t,e)}async updatePage(t,e,i){return this.#o.updatePage(t,e,i)}async reorderPages(t,e){let i=await this.getDocument(t),n=i?.pages?i.pages.map(o=>o.id):[];return this.#f(t,{type:"reorder",priorOrder:n,newOrder:[...e]}),this.#o.reorderPages(t,e)}async#g(t){if(t)return t;let e=await this.listDocuments();return e.length>0?e[0].id:null}async applyEdit(t,e,i){let n=await this.#g(t),o=n?await this.getDocument(n):null;if(!o||!o.pages)throw new Error(`Document with ID "${n||t}" not found`);let l=o.pages.find(f=>f.id===e);if(!l)throw new Error(`Page with ID "${e}" not found in document "${n}"`);let h={...l.edits||{crop:null,rotate:0,filter:"none"}},g=l.src,m=_n({...h,...i}),d=l.originalSrc||l.src,a=d;return this.#p&&(a=await this.#p.renderEdits(d,m)),await this.updatePage(n,e,{originalSrc:d,src:a,edits:m}),this.#f(n,{type:"edit",pageId:e,priorEdits:h,priorSrc:g,newEdits:m,newSrc:a}),{...l,originalSrc:d,src:a,edits:m}}async undo(t){let e=await this.#g(t),i=e?this.#u.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#l.has(e)||this.#l.set(e,[]),this.#l.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.priorEdits,src:n.priorSrc}),{type:"edit",pageId:n.pageId,restoredEdits:n.priorEdits}):n.type==="delete"?(await this.undoDeletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.#o.reorderPages(e,n.priorOrder),{type:"reorder",priorOrder:n.priorOrder}):n}async redo(t){let e=await this.#g(t),i=e?this.#l.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#u.has(e)||this.#u.set(e,[]),this.#u.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.newEdits,src:n.newSrc}),{type:"edit",pageId:n.pageId,appliedEdits:n.newEdits}):n.type==="delete"?(await this.deletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.reorderPages(e,n.newOrder),{type:"reorder",newOrder:n.newOrder}):n}subscribe(t){return this.#o.subscribe(t)}async addFiles(t,e=null){if(!t||t.length===0)return[];let i=Array.from(t),n=[];for(let l of i)if(l.type==="application/pdf"){let h=this.getService("pdf");if(h&&typeof h.renderPdfPagesToDataUrls=="function"){let g=await h.renderPdfPagesToDataUrls(l);for(let m of g)n.push({id:we(),src:m,originalSrc:m,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:l.name||"PDF Page"})}else console.warn("PDF import service (PdfPort) not registered. Skipping PDF file.")}else if(l.type&&l.type.startsWith("image/")){let h=await Hs(l),g=null;try{g=await zs(l)}catch{}n.push({id:we(),src:h,originalSrc:h,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:l.name||"Captured Image",orientation:g})}if(n.length===0)return[];let o=e;if(o)await this.getDocument(o)||await this.#o.saveDoc(o,{name:"Scanned Document",pages:[]});else{let l=await this.listDocuments();l.length>0?o=l[0].id:o=(await this.createDocument("Scanned Document",[])).id}if(this.#n>0){let l=(await this.getDocument(o))?.pages||[],h=Math.max(0,this.#n-l.length);if(h<=0)throw new Error(`Maximum page limit (${this.#n}) reached`);n.splice(h)}return await this.addPages(o,n),n}async getPages(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return[];e=n[0].id}return(await this.getDocument(e))?.pages||[]}async clear(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return;e=n[0].id}let i=await this.getDocument(e);if(!(!i||!i.pages))for(let n of i.pages)await this.deletePage(e,n.id)}async#h(t){if(Array.isArray(t))return{docName:"document",pages:t,docId:null};if(typeof t=="string"){let i=await this.getDocument(t);return{docName:i?.name||"document",pages:i?.pages||[],docId:t}}let e=await this.listDocuments();if(e.length>0){let i=await this.getDocument(e[0].id);return{docName:i?.name||"document",pages:i?.pages||[],docId:e[0].id}}return{docName:"document",pages:[],docId:null}}async exportPdf(t,e={}){if(!this.hasFeature("export")){let l=new Error('Feature "export" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}if(!this.#d||!this.#e.includes("pdf")){let l=new Error('Feature "pdf" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}let{docName:i,pages:n}=await this.#h(t),o=this.getService("pdf")||this.getService("export");if(!o||typeof o.exportDocumentAsPdf!="function")throw new Error("Export service (PdfPort) is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsPdf(i,n,{download:!1,showProgress:!1,...e})}async exportZip(t,e={}){if(!this.hasFeature("export")){let l=new Error('Feature "export" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}let{docName:i,pages:n}=await this.#h(t),o=this.getService("export");if(!o||typeof o.exportDocumentAsImages!="function")throw new Error("Export service is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsImages(i,n,{download:!1,showProgress:!1,...e})}async runOcr(t,e=null,i={}){if(!this.#a||!this.hasFeature("ocr")){let m=new Error('Feature "ocr" is disabled');throw Object.assign(m,{code:"FEATURE_DISABLED"}),m}let{pages:n}=await this.#h(t),o=n;e&&(o=n.filter(m=>m.id===e));let l=this.getService("ocr");if(!l||typeof l.recognizeDocumentPages!="function")throw new Error("OCR service (OcrPort) is not registered. Import @copio/sdk or register an ocrService.");let h=i.lang||this.#i[0]||"eng",g=await l.recognizeDocumentPages(o,{lang:h,...i});return{text:g.combinedText,...g}}async sync(t={}){if(!this.hasFeature("sync")){let i=new Error('Feature "sync" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}let e=this.getService("sync");if(!e)throw new Error("Sync service (SyncPort) is not registered. Import @copio/sdk or register a syncService.");return new e(this.#o,t.onStateChange)}};function Kc(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Ke(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Kc(Object(e),!0).forEach(function(i){au(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):Kc(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function go(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?go=function(t){return typeof t}:go=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},go(s)}function au(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function hi(){return hi=Object.assign||function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},hi.apply(this,arguments)}function lu(s,t){if(s==null)return{};var e={},i=Object.keys(s),n,o;for(o=0;o<i.length;o++)n=i[o],!(t.indexOf(n)>=0)&&(e[n]=s[n]);return e}function cu(s,t){if(s==null)return{};var e=lu(s,t),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(n=0;n<o.length;n++)i=o[n],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(s,i)&&(e[i]=s[i])}return e}var hu="1.15.6";function ci(s){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(s)}var di=ci(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Fn=ci(/Edge/i),Yc=ci(/firefox/i),Dn=ci(/safari/i)&&!ci(/chrome/i)&&!ci(/android/i),tl=ci(/iP(ad|od|hone)/i),nh=ci(/chrome/i)&&ci(/android/i),rh={capture:!1,passive:!1};function Ot(s,t,e){s.addEventListener(t,e,!di&&rh)}function Ft(s,t,e){s.removeEventListener(t,e,!di&&rh)}function wo(s,t){if(t){if(t[0]===">"&&(t=t.substring(1)),s)try{if(s.matches)return s.matches(t);if(s.msMatchesSelector)return s.msMatchesSelector(t);if(s.webkitMatchesSelector)return s.webkitMatchesSelector(t)}catch{return!1}return!1}}function oh(s){return s.host&&s!==document&&s.host.nodeType?s.host:s.parentNode}function Oe(s,t,e,i){if(s){e=e||document;do{if(t!=null&&(t[0]===">"?s.parentNode===e&&wo(s,t):wo(s,t))||i&&s===e)return s;if(s===e)break}while(s=oh(s))}return null}var Jc=/\s+/g;function _e(s,t,e){if(s&&t)if(s.classList)s.classList[e?"add":"remove"](t);else{var i=(" "+s.className+" ").replace(Jc," ").replace(" "+t+" "," ");s.className=(i+(e?" "+t:"")).replace(Jc," ")}}function Et(s,t,e){var i=s&&s.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(s,""):s.currentStyle&&(e=s.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Ks(s,t){var e="";if(typeof s=="string")e=s;else do{var i=Et(s,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(s=s.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(e)}function ah(s,t,e){if(s){var i=s.getElementsByTagName(t),n=0,o=i.length;if(e)for(;n<o;n++)e(i[n],n);return i}return[]}function Xe(){var s=document.scrollingElement;return s||document.documentElement}function ie(s,t,e,i,n){if(!(!s.getBoundingClientRect&&s!==window)){var o,l,h,g,m,d,a;if(s!==window&&s.parentNode&&s!==Xe()?(o=s.getBoundingClientRect(),l=o.top,h=o.left,g=o.bottom,m=o.right,d=o.height,a=o.width):(l=0,h=0,g=window.innerHeight,m=window.innerWidth,d=window.innerHeight,a=window.innerWidth),(t||e)&&s!==window&&(n=n||s.parentNode,!di))do if(n&&n.getBoundingClientRect&&(Et(n,"transform")!=="none"||e&&Et(n,"position")!=="static")){var f=n.getBoundingClientRect();l-=f.top+parseInt(Et(n,"border-top-width")),h-=f.left+parseInt(Et(n,"border-left-width")),g=l+o.height,m=h+o.width;break}while(n=n.parentNode);if(i&&s!==window){var A=Ks(n||s),C=A&&A.a,u=A&&A.d;A&&(l/=u,h/=C,a/=C,d/=u,g=l+d,m=h+a)}return{top:l,left:h,bottom:g,right:m,width:a,height:d}}}function Qc(s,t,e){for(var i=Mi(s,!0),n=ie(s)[t];i;){var o=ie(i)[e],l=void 0;if(e==="top"||e==="left"?l=n>=o:l=n<=o,!l)return i;if(i===Xe())break;i=Mi(i,!1)}return!1}function Ys(s,t,e,i){for(var n=0,o=0,l=s.children;o<l.length;){if(l[o].style.display!=="none"&&l[o]!==Ct.ghost&&(i||l[o]!==Ct.dragged)&&Oe(l[o],e.draggable,s,!1)){if(n===t)return l[o];n++}o++}return null}function el(s,t){for(var e=s.lastElementChild;e&&(e===Ct.ghost||Et(e,"display")==="none"||t&&!wo(e,t));)e=e.previousElementSibling;return e||null}function De(s,t){var e=0;if(!s||!s.parentNode)return-1;for(;s=s.previousElementSibling;)s.nodeName.toUpperCase()!=="TEMPLATE"&&s!==Ct.clone&&(!t||wo(s,t))&&e++;return e}function Zc(s){var t=0,e=0,i=Xe();if(s)do{var n=Ks(s),o=n.a,l=n.d;t+=s.scrollLeft*o,e+=s.scrollTop*l}while(s!==i&&(s=s.parentNode));return[t,e]}function du(s,t){for(var e in s)if(s.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===s[e][i])return Number(e)}return-1}function Mi(s,t){if(!s||!s.getBoundingClientRect)return Xe();var e=s,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var n=Et(e);if(e.clientWidth<e.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return Xe();if(i||t)return e;i=!0}}while(e=e.parentNode);return Xe()}function uu(s,t){if(s&&t)for(var e in t)t.hasOwnProperty(e)&&(s[e]=t[e]);return s}function za(s,t){return Math.round(s.top)===Math.round(t.top)&&Math.round(s.left)===Math.round(t.left)&&Math.round(s.height)===Math.round(t.height)&&Math.round(s.width)===Math.round(t.width)}var In;function lh(s,t){return function(){if(!In){var e=arguments,i=this;e.length===1?s.call(i,e[0]):s.apply(i,e),In=setTimeout(function(){In=void 0},t)}}}function pu(){clearTimeout(In),In=void 0}function ch(s,t,e){s.scrollLeft+=t,s.scrollTop+=e}function hh(s){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(s).cloneNode(!0):e?e(s).clone(!0)[0]:s.cloneNode(!0)}function dh(s,t,e){var i={};return Array.from(s.children).forEach(function(n){var o,l,h,g;if(!(!Oe(n,t.draggable,s,!1)||n.animated||n===e)){var m=ie(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,m.left),i.top=Math.min((l=i.top)!==null&&l!==void 0?l:1/0,m.top),i.right=Math.max((h=i.right)!==null&&h!==void 0?h:-1/0,m.right),i.bottom=Math.max((g=i.bottom)!==null&&g!==void 0?g:-1/0,m.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var Ae="Sortable"+new Date().getTime();function fu(){var s=[],t;return{captureAnimationState:function(){if(s=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(Et(n,"display")==="none"||n===Ct.ghost)){s.push({target:n,rect:ie(n)});var o=Ke({},s[s.length-1].rect);if(n.thisAnimationDuration){var l=Ks(n,!0);l&&(o.top-=l.f,o.left-=l.e)}n.fromRect=o}})}},addAnimationState:function(i){s.push(i)},removeAnimationState:function(i){s.splice(du(s,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var o=!1,l=0;s.forEach(function(h){var g=0,m=h.target,d=m.fromRect,a=ie(m),f=m.prevFromRect,A=m.prevToRect,C=h.rect,u=Ks(m,!0);u&&(a.top-=u.f,a.left-=u.e),m.toRect=a,m.thisAnimationDuration&&za(f,a)&&!za(d,a)&&(C.top-a.top)/(C.left-a.left)===(d.top-a.top)/(d.left-a.left)&&(g=mu(C,f,A,n.options)),za(a,d)||(m.prevFromRect=d,m.prevToRect=a,g||(g=n.options.animation),n.animate(m,C,a,g)),g&&(o=!0,l=Math.max(l,g),clearTimeout(m.animationResetTimer),m.animationResetTimer=setTimeout(function(){m.animationTime=0,m.prevFromRect=null,m.fromRect=null,m.prevToRect=null,m.thisAnimationDuration=null},g),m.thisAnimationDuration=g)}),clearTimeout(t),o?t=setTimeout(function(){typeof i=="function"&&i()},l):typeof i=="function"&&i(),s=[]},animate:function(i,n,o,l){if(l){Et(i,"transition",""),Et(i,"transform","");var h=Ks(this.el),g=h&&h.a,m=h&&h.d,d=(n.left-o.left)/(g||1),a=(n.top-o.top)/(m||1);i.animatingX=!!d,i.animatingY=!!a,Et(i,"transform","translate3d("+d+"px,"+a+"px,0)"),this.forRepaintDummy=gu(i),Et(i,"transition","transform "+l+"ms"+(this.options.easing?" "+this.options.easing:"")),Et(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){Et(i,"transition",""),Et(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},l)}}}}function gu(s){return s.offsetWidth}function mu(s,t,e,i){return Math.sqrt(Math.pow(t.top-s.top,2)+Math.pow(t.left-s.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var Gs=[],Ha={initializeByDefault:!0},On={mount:function(t){for(var e in Ha)Ha.hasOwnProperty(e)&&!(e in t)&&(t[e]=Ha[e]);Gs.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Gs.push(t)},pluginEvent:function(t,e,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=t+"Global";Gs.forEach(function(l){e[l.pluginName]&&(e[l.pluginName][o]&&e[l.pluginName][o](Ke({sortable:e},i)),e.options[l.pluginName]&&e[l.pluginName][t]&&e[l.pluginName][t](Ke({sortable:e},i)))})},initializePlugins:function(t,e,i,n){Gs.forEach(function(h){var g=h.pluginName;if(!(!t.options[g]&&!h.initializeByDefault)){var m=new h(t,e,t.options);m.sortable=t,m.options=t.options,t[g]=m,hi(i,m.defaults)}});for(var o in t.options)if(t.options.hasOwnProperty(o)){var l=this.modifyOption(t,o,t.options[o]);typeof l<"u"&&(t.options[o]=l)}},getEventProperties:function(t,e){var i={};return Gs.forEach(function(n){typeof n.eventProperties=="function"&&hi(i,n.eventProperties.call(e[n.pluginName],t))}),i},modifyOption:function(t,e,i){var n;return Gs.forEach(function(o){t[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[e]=="function"&&(n=o.optionListeners[e].call(t[o.pluginName],i))}),n}};function bu(s){var t=s.sortable,e=s.rootEl,i=s.name,n=s.targetEl,o=s.cloneEl,l=s.toEl,h=s.fromEl,g=s.oldIndex,m=s.newIndex,d=s.oldDraggableIndex,a=s.newDraggableIndex,f=s.originalEvent,A=s.putSortable,C=s.extraEventProperties;if(t=t||e&&e[Ae],!!t){var u,y=t.options,r="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!di&&!Fn?u=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(u=document.createEvent("Event"),u.initEvent(i,!0,!0)),u.to=l||e,u.from=h||e,u.item=n||e,u.clone=o,u.oldIndex=g,u.newIndex=m,u.oldDraggableIndex=d,u.newDraggableIndex=a,u.originalEvent=f,u.pullMode=A?A.lastPutMode:void 0;var c=Ke(Ke({},C),On.getEventProperties(i,t));for(var b in c)u[b]=c[b];e&&e.dispatchEvent(u),y[r]&&y[r].call(t,u)}}var yu=["evt"],xe=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=cu(i,yu);On.pluginEvent.bind(Ct)(t,e,Ke({dragEl:gt,parentEl:Qt,ghostEl:kt,rootEl:Gt,nextEl:us,lastDownEl:mo,cloneEl:Kt,cloneHidden:Ii,dragStarted:kn,putSortable:ce,activeSortable:Ct.active,originalEvent:n,oldIndex:Xs,oldDraggableIndex:Mn,newIndex:ke,newDraggableIndex:Di,hideGhostForTarget:gh,unhideGhostForTarget:mh,cloneNowHidden:function(){Ii=!0},cloneNowShown:function(){Ii=!1},dispatchSortableEvent:function(h){me({sortable:e,name:h,originalEvent:n})}},o))};function me(s){bu(Ke({putSortable:ce,cloneEl:Kt,targetEl:gt,rootEl:Gt,oldIndex:Xs,oldDraggableIndex:Mn,newIndex:ke,newDraggableIndex:Di},s))}var gt,Qt,kt,Gt,us,mo,Kt,Ii,Xs,ke,Mn,Di,ho,ce,qs=!1,xo=!1,Ao=[],hs,Fe,ja,Va,th,eh,kn,Ws,Rn,Ln=!1,uo=!1,bo,ue,Ga=[],Ya=!1,So=[],Co=typeof document<"u",po=tl,ih=Fn||di?"cssFloat":"float",vu=Co&&!nh&&!tl&&"draggable"in document.createElement("div"),uh=(function(){if(Co){if(di)return!1;var s=document.createElement("x");return s.style.cssText="pointer-events:auto",s.style.pointerEvents==="auto"}})(),ph=function(t,e){var i=Et(t),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=Ys(t,0,e),l=Ys(t,1,e),h=o&&Et(o),g=l&&Et(l),m=h&&parseInt(h.marginLeft)+parseInt(h.marginRight)+ie(o).width,d=g&&parseInt(g.marginLeft)+parseInt(g.marginRight)+ie(l).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&h.float&&h.float!=="none"){var a=h.float==="left"?"left":"right";return l&&(g.clear==="both"||g.clear===a)?"vertical":"horizontal"}return o&&(h.display==="block"||h.display==="flex"||h.display==="table"||h.display==="grid"||m>=n&&i[ih]==="none"||l&&i[ih]==="none"&&m+d>n)?"vertical":"horizontal"},wu=function(t,e,i){var n=i?t.left:t.top,o=i?t.right:t.bottom,l=i?t.width:t.height,h=i?e.left:e.top,g=i?e.right:e.bottom,m=i?e.width:e.height;return n===h||o===g||n+l/2===h+m/2},xu=function(t,e){var i;return Ao.some(function(n){var o=n[Ae].options.emptyInsertThreshold;if(!(!o||el(n))){var l=ie(n),h=t>=l.left-o&&t<=l.right+o,g=e>=l.top-o&&e<=l.bottom+o;if(h&&g)return i=n}}),i},fh=function(t){function e(o,l){return function(h,g,m,d){var a=h.options.group.name&&g.options.group.name&&h.options.group.name===g.options.group.name;if(o==null&&(l||a))return!0;if(o==null||o===!1)return!1;if(l&&o==="clone")return o;if(typeof o=="function")return e(o(h,g,m,d),l)(h,g,m,d);var f=(l?h:g).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var i={},n=t.group;(!n||go(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=e(n.pull,!0),i.checkPut=e(n.put),i.revertClone=n.revertClone,t.group=i},gh=function(){!uh&&kt&&Et(kt,"display","none")},mh=function(){!uh&&kt&&Et(kt,"display","")};Co&&!nh&&document.addEventListener("click",function(s){if(xo)return s.preventDefault(),s.stopPropagation&&s.stopPropagation(),s.stopImmediatePropagation&&s.stopImmediatePropagation(),xo=!1,!1},!0);var ds=function(t){if(gt){t=t.touches?t.touches[0]:t;var e=xu(t.clientX,t.clientY);if(e){var i={};for(var n in t)t.hasOwnProperty(n)&&(i[n]=t[n]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[Ae]._onDragOver(i)}}},Au=function(t){gt&&gt.parentNode[Ae]._isOutsideThisEl(t.target)};function Ct(s,t){if(!(s&&s.nodeType&&s.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(s));this.el=s,this.options=t=hi({},t),s[Ae]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(s.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ph(s,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(l,h){l.setData("Text",h.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Ct.supportPointer!==!1&&"PointerEvent"in window&&(!Dn||tl),emptyInsertThreshold:5};On.initializePlugins(this,s,e);for(var i in e)!(i in t)&&(t[i]=e[i]);fh(t);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=t.forceFallback?!1:vu,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Ot(s,"pointerdown",this._onTapStart):(Ot(s,"mousedown",this._onTapStart),Ot(s,"touchstart",this._onTapStart)),this.nativeDraggable&&(Ot(s,"dragover",this),Ot(s,"dragenter",this)),Ao.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),hi(this,fu())}Ct.prototype={constructor:Ct,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Ws=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,gt):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,n=this.options,o=n.preventOnFilter,l=t.type,h=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,g=(h||t).target,m=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||g,d=n.filter;if(Du(i),!gt&&!(/mousedown|pointerdown/.test(l)&&t.button!==0||n.disabled)&&!m.isContentEditable&&!(!this.nativeDraggable&&Dn&&g&&g.tagName.toUpperCase()==="SELECT")&&(g=Oe(g,n.draggable,i,!1),!(g&&g.animated)&&mo!==g)){if(Xs=De(g),Mn=De(g,n.draggable),typeof d=="function"){if(d.call(this,t,g,this)){me({sortable:e,rootEl:m,name:"filter",targetEl:g,toEl:i,fromEl:i}),xe("filter",e,{evt:t}),o&&t.preventDefault();return}}else if(d&&(d=d.split(",").some(function(a){if(a=Oe(m,a.trim(),i,!1),a)return me({sortable:e,rootEl:a,name:"filter",targetEl:g,fromEl:i,toEl:i}),xe("filter",e,{evt:t}),!0}),d)){o&&t.preventDefault();return}n.handle&&!Oe(m,n.handle,i,!1)||this._prepareDragStart(t,h,g)}}},_prepareDragStart:function(t,e,i){var n=this,o=n.el,l=n.options,h=o.ownerDocument,g;if(i&&!gt&&i.parentNode===o){var m=ie(i);if(Gt=o,gt=i,Qt=gt.parentNode,us=gt.nextSibling,mo=i,ho=l.group,Ct.dragged=gt,hs={target:gt,clientX:(e||t).clientX,clientY:(e||t).clientY},th=hs.clientX-m.left,eh=hs.clientY-m.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,gt.style["will-change"]="all",g=function(){if(xe("delayEnded",n,{evt:t}),Ct.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!Yc&&n.nativeDraggable&&(gt.draggable=!0),n._triggerDragStart(t,e),me({sortable:n,name:"choose",originalEvent:t}),_e(gt,l.chosenClass,!0)},l.ignore.split(",").forEach(function(d){ah(gt,d.trim(),Wa)}),Ot(h,"dragover",ds),Ot(h,"mousemove",ds),Ot(h,"touchmove",ds),l.supportPointer?(Ot(h,"pointerup",n._onDrop),!this.nativeDraggable&&Ot(h,"pointercancel",n._onDrop)):(Ot(h,"mouseup",n._onDrop),Ot(h,"touchend",n._onDrop),Ot(h,"touchcancel",n._onDrop)),Yc&&this.nativeDraggable&&(this.options.touchStartThreshold=4,gt.draggable=!0),xe("delayStart",this,{evt:t}),l.delay&&(!l.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(Fn||di))){if(Ct.eventCanceled){this._onDrop();return}l.supportPointer?(Ot(h,"pointerup",n._disableDelayedDrag),Ot(h,"pointercancel",n._disableDelayedDrag)):(Ot(h,"mouseup",n._disableDelayedDrag),Ot(h,"touchend",n._disableDelayedDrag),Ot(h,"touchcancel",n._disableDelayedDrag)),Ot(h,"mousemove",n._delayedDragTouchMoveHandler),Ot(h,"touchmove",n._delayedDragTouchMoveHandler),l.supportPointer&&Ot(h,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(g,l.delay)}else g()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){gt&&Wa(gt),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Ft(t,"mouseup",this._disableDelayedDrag),Ft(t,"touchend",this._disableDelayedDrag),Ft(t,"touchcancel",this._disableDelayedDrag),Ft(t,"pointerup",this._disableDelayedDrag),Ft(t,"pointercancel",this._disableDelayedDrag),Ft(t,"mousemove",this._delayedDragTouchMoveHandler),Ft(t,"touchmove",this._delayedDragTouchMoveHandler),Ft(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?Ot(document,"pointermove",this._onTouchMove):e?Ot(document,"touchmove",this._onTouchMove):Ot(document,"mousemove",this._onTouchMove):(Ot(gt,"dragend",this),Ot(Gt,"dragstart",this._onDragStart));try{document.selection?yo(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(qs=!1,Gt&&gt){xe("dragStarted",this,{evt:e}),this.nativeDraggable&&Ot(document,"dragover",Au);var i=this.options;!t&&_e(gt,i.dragClass,!1),_e(gt,i.ghostClass,!0),Ct.active=this,t&&this._appendGhost(),me({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Fe){this._lastX=Fe.clientX,this._lastY=Fe.clientY,gh();for(var t=document.elementFromPoint(Fe.clientX,Fe.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Fe.clientX,Fe.clientY),t!==e);)e=t;if(gt.parentNode[Ae]._isOutsideThisEl(t),e)do{if(e[Ae]){var i=void 0;if(i=e[Ae]._onDragOver({clientX:Fe.clientX,clientY:Fe.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=oh(e));mh()}},_onTouchMove:function(t){if(hs){var e=this.options,i=e.fallbackTolerance,n=e.fallbackOffset,o=t.touches?t.touches[0]:t,l=kt&&Ks(kt,!0),h=kt&&l&&l.a,g=kt&&l&&l.d,m=po&&ue&&Zc(ue),d=(o.clientX-hs.clientX+n.x)/(h||1)+(m?m[0]-Ga[0]:0)/(h||1),a=(o.clientY-hs.clientY+n.y)/(g||1)+(m?m[1]-Ga[1]:0)/(g||1);if(!Ct.active&&!qs){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(kt){l?(l.e+=d-(ja||0),l.f+=a-(Va||0)):l={a:1,b:0,c:0,d:1,e:d,f:a};var f="matrix(".concat(l.a,",").concat(l.b,",").concat(l.c,",").concat(l.d,",").concat(l.e,",").concat(l.f,")");Et(kt,"webkitTransform",f),Et(kt,"mozTransform",f),Et(kt,"msTransform",f),Et(kt,"transform",f),ja=d,Va=a,Fe=o}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!kt){var t=this.options.fallbackOnBody?document.body:Gt,e=ie(gt,!0,po,!0,t),i=this.options;if(po){for(ue=t;Et(ue,"position")==="static"&&Et(ue,"transform")==="none"&&ue!==document;)ue=ue.parentNode;ue!==document.body&&ue!==document.documentElement?(ue===document&&(ue=Xe()),e.top+=ue.scrollTop,e.left+=ue.scrollLeft):ue=Xe(),Ga=Zc(ue)}kt=gt.cloneNode(!0),_e(kt,i.ghostClass,!1),_e(kt,i.fallbackClass,!0),_e(kt,i.dragClass,!0),Et(kt,"transition",""),Et(kt,"transform",""),Et(kt,"box-sizing","border-box"),Et(kt,"margin",0),Et(kt,"top",e.top),Et(kt,"left",e.left),Et(kt,"width",e.width),Et(kt,"height",e.height),Et(kt,"opacity","0.8"),Et(kt,"position",po?"absolute":"fixed"),Et(kt,"zIndex","100000"),Et(kt,"pointerEvents","none"),Ct.ghost=kt,t.appendChild(kt),Et(kt,"transform-origin",th/parseInt(kt.style.width)*100+"% "+eh/parseInt(kt.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,n=t.dataTransfer,o=i.options;if(xe("dragStart",this,{evt:t}),Ct.eventCanceled){this._onDrop();return}xe("setupClone",this),Ct.eventCanceled||(Kt=hh(gt),Kt.removeAttribute("id"),Kt.draggable=!1,Kt.style["will-change"]="",this._hideClone(),_e(Kt,this.options.chosenClass,!1),Ct.clone=Kt),i.cloneId=yo(function(){xe("clone",i),!Ct.eventCanceled&&(i.options.removeCloneOnHide||Gt.insertBefore(Kt,gt),i._hideClone(),me({sortable:i,name:"clone"}))}),!e&&_e(gt,o.dragClass,!0),e?(xo=!0,i._loopId=setInterval(i._emulateDragOver,50)):(Ft(document,"mouseup",i._onDrop),Ft(document,"touchend",i._onDrop),Ft(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,gt)),Ot(document,"drop",i),Et(gt,"transform","translateZ(0)")),qs=!0,i._dragStartId=yo(i._dragStarted.bind(i,e,t)),Ot(document,"selectstart",i),kn=!0,window.getSelection().removeAllRanges(),Dn&&Et(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,n,o,l,h=this.options,g=h.group,m=Ct.active,d=ho===g,a=h.sort,f=ce||m,A,C=this,u=!1;if(Ya)return;function y(et,rt){xe(et,C,Ke({evt:t,isOwner:d,axis:A?"vertical":"horizontal",revert:l,dragRect:n,targetRect:o,canSort:a,fromSortable:f,target:i,completed:c,onMove:function(st,W){return fo(Gt,e,gt,n,st,ie(st),t,W)},changed:b},rt))}function r(){y("dragOverAnimationCapture"),C.captureAnimationState(),C!==f&&f.captureAnimationState()}function c(et){return y("dragOverCompleted",{insertion:et}),et&&(d?m._hideClone():m._showClone(C),C!==f&&(_e(gt,ce?ce.options.ghostClass:m.options.ghostClass,!1),_e(gt,h.ghostClass,!0)),ce!==C&&C!==Ct.active?ce=C:C===Ct.active&&ce&&(ce=null),f===C&&(C._ignoreWhileAnimating=i),C.animateAll(function(){y("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(i===gt&&!gt.animated||i===e&&!i.animated)&&(Ws=null),!h.dragoverBubble&&!t.rootEl&&i!==document&&(gt.parentNode[Ae]._isOutsideThisEl(t.target),!et&&ds(t)),!h.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),u=!0}function b(){ke=De(gt),Di=De(gt,h.draggable),me({sortable:C,name:"change",toEl:e,newIndex:ke,newDraggableIndex:Di,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=Oe(i,h.draggable,e,!0),y("dragOver"),Ct.eventCanceled)return u;if(gt.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||C._ignoreWhileAnimating===i)return c(!1);if(xo=!1,m&&!h.disabled&&(d?a||(l=Qt!==Gt):ce===this||(this.lastPutMode=ho.checkPull(this,m,gt,t))&&g.checkPut(this,m,gt,t))){if(A=this._getDirection(t,i)==="vertical",n=ie(gt),y("dragOverValid"),Ct.eventCanceled)return u;if(l)return Qt=Gt,r(),this._hideClone(),y("revert"),Ct.eventCanceled||(us?Gt.insertBefore(gt,us):Gt.appendChild(gt)),c(!0);var w=el(e,h.draggable);if(!w||_u(t,A,this)&&!w.animated){if(w===gt)return c(!1);if(w&&e===t.target&&(i=w),i&&(o=ie(i)),fo(Gt,e,gt,n,i,o,t,!!i)!==!1)return r(),w&&w.nextSibling?e.insertBefore(gt,w.nextSibling):e.appendChild(gt),Qt=e,b(),c(!0)}else if(w&&Cu(t,A,this)){var P=Ys(e,0,h,!0);if(P===gt)return c(!1);if(i=P,o=ie(i),fo(Gt,e,gt,n,i,o,t,!1)!==!1)return r(),e.insertBefore(gt,P),Qt=e,b(),c(!0)}else if(i.parentNode===e){o=ie(i);var E=0,I,N=gt.parentNode!==e,z=!wu(gt.animated&&gt.toRect||n,i.animated&&i.toRect||o,A),H=A?"top":"left",X=Qc(i,"top","top")||Qc(gt,"top","top"),it=X?X.scrollTop:void 0;Ws!==i&&(I=o[H],Ln=!1,uo=!z&&h.invertSwap||N),E=ku(t,i,o,A,z?1:h.swapThreshold,h.invertedSwapThreshold==null?h.swapThreshold:h.invertedSwapThreshold,uo,Ws===i);var at;if(E!==0){var K=De(gt);do K-=E,at=Qt.children[K];while(at&&(Et(at,"display")==="none"||at===kt))}if(E===0||at===i)return c(!1);Ws=i,Rn=E;var j=i.nextElementSibling,G=!1;G=E===1;var Y=fo(Gt,e,gt,n,i,o,t,G);if(Y!==!1)return(Y===1||Y===-1)&&(G=Y===1),Ya=!0,setTimeout(Eu,30),r(),G&&!j?e.appendChild(gt):i.parentNode.insertBefore(gt,G?j:i),X&&ch(X,0,it-X.scrollTop),Qt=gt.parentNode,I!==void 0&&!uo&&(bo=Math.abs(I-ie(i)[H])),b(),c(!0)}if(e.contains(gt))return c(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Ft(document,"mousemove",this._onTouchMove),Ft(document,"touchmove",this._onTouchMove),Ft(document,"pointermove",this._onTouchMove),Ft(document,"dragover",ds),Ft(document,"mousemove",ds),Ft(document,"touchmove",ds)},_offUpEvents:function(){var t=this.el.ownerDocument;Ft(t,"mouseup",this._onDrop),Ft(t,"touchend",this._onDrop),Ft(t,"pointerup",this._onDrop),Ft(t,"pointercancel",this._onDrop),Ft(t,"touchcancel",this._onDrop),Ft(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(ke=De(gt),Di=De(gt,i.draggable),xe("drop",this,{evt:t}),Qt=gt&&gt.parentNode,ke=De(gt),Di=De(gt,i.draggable),Ct.eventCanceled){this._nulling();return}qs=!1,uo=!1,Ln=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ja(this.cloneId),Ja(this._dragStartId),this.nativeDraggable&&(Ft(document,"drop",this),Ft(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Dn&&Et(document.body,"user-select",""),Et(gt,"transform",""),t&&(kn&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),kt&&kt.parentNode&&kt.parentNode.removeChild(kt),(Gt===Qt||ce&&ce.lastPutMode!=="clone")&&Kt&&Kt.parentNode&&Kt.parentNode.removeChild(Kt),gt&&(this.nativeDraggable&&Ft(gt,"dragend",this),Wa(gt),gt.style["will-change"]="",kn&&!qs&&_e(gt,ce?ce.options.ghostClass:this.options.ghostClass,!1),_e(gt,this.options.chosenClass,!1),me({sortable:this,name:"unchoose",toEl:Qt,newIndex:null,newDraggableIndex:null,originalEvent:t}),Gt!==Qt?(ke>=0&&(me({rootEl:Qt,name:"add",toEl:Qt,fromEl:Gt,originalEvent:t}),me({sortable:this,name:"remove",toEl:Qt,originalEvent:t}),me({rootEl:Qt,name:"sort",toEl:Qt,fromEl:Gt,originalEvent:t}),me({sortable:this,name:"sort",toEl:Qt,originalEvent:t})),ce&&ce.save()):ke!==Xs&&ke>=0&&(me({sortable:this,name:"update",toEl:Qt,originalEvent:t}),me({sortable:this,name:"sort",toEl:Qt,originalEvent:t})),Ct.active&&((ke==null||ke===-1)&&(ke=Xs,Di=Mn),me({sortable:this,name:"end",toEl:Qt,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){xe("nulling",this),Gt=gt=Qt=kt=us=Kt=mo=Ii=hs=Fe=kn=ke=Di=Xs=Mn=Ws=Rn=ce=ho=Ct.dragged=Ct.ghost=Ct.clone=Ct.active=null,So.forEach(function(t){t.checked=!0}),So.length=ja=Va=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":gt&&(this._onDragOver(t),Su(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,n=0,o=i.length,l=this.options;n<o;n++)e=i[n],Oe(e,l.draggable,this.el,!1)&&t.push(e.getAttribute(l.dataIdAttr)||Pu(e));return t},sort:function(t,e){var i={},n=this.el;this.toArray().forEach(function(o,l){var h=n.children[l];Oe(h,this.options.draggable,n,!1)&&(i[o]=h)},this),e&&this.captureAnimationState(),t.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return Oe(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var n=On.modifyOption(this,t,e);typeof n<"u"?i[t]=n:i[t]=e,t==="group"&&fh(i)},destroy:function(){xe("destroy",this);var t=this.el;t[Ae]=null,Ft(t,"mousedown",this._onTapStart),Ft(t,"touchstart",this._onTapStart),Ft(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(Ft(t,"dragover",this),Ft(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ao.splice(Ao.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!Ii){if(xe("hideClone",this),Ct.eventCanceled)return;Et(Kt,"display","none"),this.options.removeCloneOnHide&&Kt.parentNode&&Kt.parentNode.removeChild(Kt),Ii=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(Ii){if(xe("showClone",this),Ct.eventCanceled)return;gt.parentNode==Gt&&!this.options.group.revertClone?Gt.insertBefore(Kt,gt):us?Gt.insertBefore(Kt,us):Gt.appendChild(Kt),this.options.group.revertClone&&this.animate(gt,Kt),Et(Kt,"display",""),Ii=!1}}};function Su(s){s.dataTransfer&&(s.dataTransfer.dropEffect="move"),s.cancelable&&s.preventDefault()}function fo(s,t,e,i,n,o,l,h){var g,m=s[Ae],d=m.options.onMove,a;return window.CustomEvent&&!di&&!Fn?g=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent("move",!0,!0)),g.to=t,g.from=s,g.dragged=e,g.draggedRect=i,g.related=n||t,g.relatedRect=o||ie(t),g.willInsertAfter=h,g.originalEvent=l,s.dispatchEvent(g),d&&(a=d.call(m,g,l)),a}function Wa(s){s.draggable=!1}function Eu(){Ya=!1}function Cu(s,t,e){var i=ie(Ys(e.el,0,e.options,!0)),n=dh(e.el,e.options,kt),o=10;return t?s.clientX<n.left-o||s.clientY<i.top&&s.clientX<i.right:s.clientY<n.top-o||s.clientY<i.bottom&&s.clientX<i.left}function _u(s,t,e){var i=ie(el(e.el,e.options.draggable)),n=dh(e.el,e.options,kt),o=10;return t?s.clientX>n.right+o||s.clientY>i.bottom&&s.clientX>i.left:s.clientY>n.bottom+o||s.clientX>i.right&&s.clientY>i.top}function ku(s,t,e,i,n,o,l,h){var g=i?s.clientY:s.clientX,m=i?e.height:e.width,d=i?e.top:e.left,a=i?e.bottom:e.right,f=!1;if(!l){if(h&&bo<m*n){if(!Ln&&(Rn===1?g>d+m*o/2:g<a-m*o/2)&&(Ln=!0),Ln)f=!0;else if(Rn===1?g<d+bo:g>a-bo)return-Rn}else if(g>d+m*(1-n)/2&&g<a-m*(1-n)/2)return Tu(t)}return f=f||l,f&&(g<d+m*o/2||g>a-m*o/2)?g>d+m/2?1:-1:0}function Tu(s){return De(gt)<De(s)?1:-1}function Pu(s){for(var t=s.tagName+s.className+s.src+s.href+s.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function Du(s){So.length=0;for(var t=s.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&So.push(i)}}function yo(s){return setTimeout(s,0)}function Ja(s){return clearTimeout(s)}Co&&Ot(document,"touchmove",function(s){(Ct.active||qs)&&s.cancelable&&s.preventDefault()});Ct.utils={on:Ot,off:Ft,css:Et,find:ah,is:function(t,e){return!!Oe(t,e,t,!1)},extend:uu,throttle:lh,closest:Oe,toggleClass:_e,clone:hh,index:De,nextTick:yo,cancelNextTick:Ja,detectDirection:ph,getChild:Ys,expando:Ae};Ct.get=function(s){return s[Ae]};Ct.mount=function(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(Ct.utils=Ke(Ke({},Ct.utils),i.utils)),On.mount(i)})};Ct.create=function(s,t){return new Ct(s,t)};Ct.version=hu;var ee=[],Tn,Qa,Za=!1,qa,Xa,Eo,Pn;function Iu(){function s(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return s.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?Ot(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Ot(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Ot(document,"touchmove",this._handleFallbackAutoScroll):Ot(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?Ft(document,"dragover",this._handleAutoScroll):(Ft(document,"pointermove",this._handleFallbackAutoScroll),Ft(document,"touchmove",this._handleFallbackAutoScroll),Ft(document,"mousemove",this._handleFallbackAutoScroll)),sh(),vo(),pu()},nulling:function(){Eo=Qa=Tn=Za=Pn=qa=Xa=null,ee.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){var n=this,o=(e.touches?e.touches[0]:e).clientX,l=(e.touches?e.touches[0]:e).clientY,h=document.elementFromPoint(o,l);if(Eo=e,i||this.options.forceAutoScrollFallback||Fn||di||Dn){Ka(e,this.options,h,i);var g=Mi(h,!0);Za&&(!Pn||o!==qa||l!==Xa)&&(Pn&&sh(),Pn=setInterval(function(){var m=Mi(document.elementFromPoint(o,l),!0);m!==g&&(g=m,vo()),Ka(e,n.options,m,i)},10),qa=o,Xa=l)}else{if(!this.options.bubbleScroll||Mi(h,!0)===Xe()){vo();return}Ka(e,this.options,Mi(h,!1),!1)}}},hi(s,{pluginName:"scroll",initializeByDefault:!0})}function vo(){ee.forEach(function(s){clearInterval(s.pid)}),ee=[]}function sh(){clearInterval(Pn)}var Ka=lh(function(s,t,e,i){if(t.scroll){var n=(s.touches?s.touches[0]:s).clientX,o=(s.touches?s.touches[0]:s).clientY,l=t.scrollSensitivity,h=t.scrollSpeed,g=Xe(),m=!1,d;Qa!==e&&(Qa=e,vo(),Tn=t.scroll,d=t.scrollFn,Tn===!0&&(Tn=Mi(e,!0)));var a=0,f=Tn;do{var A=f,C=ie(A),u=C.top,y=C.bottom,r=C.left,c=C.right,b=C.width,w=C.height,P=void 0,E=void 0,I=A.scrollWidth,N=A.scrollHeight,z=Et(A),H=A.scrollLeft,X=A.scrollTop;A===g?(P=b<I&&(z.overflowX==="auto"||z.overflowX==="scroll"||z.overflowX==="visible"),E=w<N&&(z.overflowY==="auto"||z.overflowY==="scroll"||z.overflowY==="visible")):(P=b<I&&(z.overflowX==="auto"||z.overflowX==="scroll"),E=w<N&&(z.overflowY==="auto"||z.overflowY==="scroll"));var it=P&&(Math.abs(c-n)<=l&&H+b<I)-(Math.abs(r-n)<=l&&!!H),at=E&&(Math.abs(y-o)<=l&&X+w<N)-(Math.abs(u-o)<=l&&!!X);if(!ee[a])for(var K=0;K<=a;K++)ee[K]||(ee[K]={});(ee[a].vx!=it||ee[a].vy!=at||ee[a].el!==A)&&(ee[a].el=A,ee[a].vx=it,ee[a].vy=at,clearInterval(ee[a].pid),(it!=0||at!=0)&&(m=!0,ee[a].pid=setInterval(function(){i&&this.layer===0&&Ct.active._onTouchMove(Eo);var j=ee[this.layer].vy?ee[this.layer].vy*h:0,G=ee[this.layer].vx?ee[this.layer].vx*h:0;typeof d=="function"&&d.call(Ct.dragged.parentNode[Ae],G,j,s,Eo,ee[this.layer].el)!=="continue"||ch(ee[this.layer].el,G,j)}.bind({layer:a}),24))),a++}while(t.bubbleScroll&&f!==g&&(f=Mi(f,!1)));Za=m}},30),bh=function(t){var e=t.originalEvent,i=t.putSortable,n=t.dragEl,o=t.activeSortable,l=t.dispatchSortableEvent,h=t.hideGhostForTarget,g=t.unhideGhostForTarget;if(e){var m=i||o;h();var d=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,a=document.elementFromPoint(d.clientX,d.clientY);g(),m&&!m.el.contains(a)&&(l("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function il(){}il.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=Ys(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(e,n):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:bh};hi(il,{pluginName:"revertOnSpill"});function sl(){}sl.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,n=i||this.sortable;n.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),n.animateAll()},drop:bh};hi(sl,{pluginName:"removeOnSpill"});Ct.mount(new Iu);Ct.mount(sl,il);var yh=Ct;var Js,Nn,Bn,_o,Yu={976:(s,t,e)=>{e.d(t,{AnnotationLayer:()=>T,FreeTextAnnotationElement:()=>H,InkAnnotationElement:()=>Y,StampAnnotationElement:()=>W});var i=e(292),n=e(419),o=e(792);function l(R){return Math.floor(255*Math.max(0,Math.min(1,R))).toString(16).padStart(2,"0")}function h(R){return Math.max(0,Math.min(255,255*R))}class g{static CMYK_G([p,v,_,k]){return["G",1-Math.min(1,.3*p+.59*_+.11*v+k)]}static G_CMYK([p]){return["CMYK",0,0,0,1-p]}static G_RGB([p]){return["RGB",p,p,p]}static G_rgb([p]){return[p=h(p),p,p]}static G_HTML([p]){let v=l(p);return`#${v}${v}${v}`}static RGB_G([p,v,_]){return["G",.3*p+.59*v+.11*_]}static RGB_rgb(p){return p.map(h)}static RGB_HTML(p){return`#${p.map(l).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([p,v,_,k]){return["RGB",1-Math.min(1,p+k),1-Math.min(1,_+k),1-Math.min(1,v+k)]}static CMYK_rgb([p,v,_,k]){return[h(1-Math.min(1,p+k)),h(1-Math.min(1,_+k)),h(1-Math.min(1,v+k))]}static CMYK_HTML(p){let v=this.CMYK_RGB(p).slice(1);return this.RGB_HTML(v)}static RGB_CMYK([p,v,_]){let k=1-p,O=1-v,M=1-_;return["CMYK",k,O,M,Math.min(k,O,M)]}}var m=e(284);let d=1e3,a=new WeakSet;function f(R){return{width:R[2]-R[0],height:R[3]-R[1]}}class A{static create(p){switch(p.data.annotationType){case i.AnnotationType.LINK:return new u(p);case i.AnnotationType.TEXT:return new y(p);case i.AnnotationType.WIDGET:switch(p.data.fieldType){case"Tx":return new c(p);case"Btn":return p.data.radioButton?new P(p):p.data.checkBox?new w(p):new E(p);case"Ch":return new I(p);case"Sig":return new b(p)}return new r(p);case i.AnnotationType.POPUP:return new N(p);case i.AnnotationType.FREETEXT:return new H(p);case i.AnnotationType.LINE:return new X(p);case i.AnnotationType.SQUARE:return new it(p);case i.AnnotationType.CIRCLE:return new at(p);case i.AnnotationType.POLYLINE:return new K(p);case i.AnnotationType.CARET:return new G(p);case i.AnnotationType.INK:return new Y(p);case i.AnnotationType.POLYGON:return new j(p);case i.AnnotationType.HIGHLIGHT:return new et(p);case i.AnnotationType.UNDERLINE:return new rt(p);case i.AnnotationType.SQUIGGLY:return new ct(p);case i.AnnotationType.STRIKEOUT:return new st(p);case i.AnnotationType.STAMP:return new W(p);case i.AnnotationType.FILEATTACHMENT:return new x(p);default:return new C(p)}}}class C{#t=!1;constructor(p,{isRenderable:v=!1,ignoreBorder:_=!1,createQuadrilaterals:k=!1}={}){this.isRenderable=v,this.data=p.data,this.layer=p.layer,this.linkService=p.linkService,this.downloadManager=p.downloadManager,this.imageResourcesPath=p.imageResourcesPath,this.renderForms=p.renderForms,this.svgFactory=p.svgFactory,this.annotationStorage=p.annotationStorage,this.enableScripting=p.enableScripting,this.hasJSActions=p.hasJSActions,this._fieldObjects=p.fieldObjects,this.parent=p.parent,v&&(this.container=this._createContainer(_)),k&&this._createQuadrilaterals()}static _hasPopupData({titleObj:p,contentsObj:v,richText:_}){return!!(p?.str||v?.str||_?.str)}get hasPopupData(){return C._hasPopupData(this.data)}_createContainer(p){let{data:v,parent:{page:_,viewport:k}}=this,O=document.createElement("section");O.setAttribute("data-annotation-id",v.id),this instanceof r||(O.tabIndex=d),O.style.zIndex=this.parent.zIndex++,v.popupRef&&O.setAttribute("aria-haspopup","dialog"),v.alternativeText&&(O.title=v.alternativeText),v.noRotate&&O.classList.add("norotate");let{pageWidth:M,pageHeight:S,pageX:L,pageY:U}=k.rawDims;if(!v.rect||this instanceof N){let{rotation:Q}=v;return v.hasOwnCanvas||Q===0||this.setRotation(Q,O),O}let{width:$,height:D}=f(v.rect),F=i.Util.normalizeRect([v.rect[0],_.view[3]-v.rect[1]+_.view[1],v.rect[2],_.view[3]-v.rect[3]+_.view[1]]);if(!p&&v.borderStyle.width>0){O.style.borderWidth=`${v.borderStyle.width}px`;let Q=v.borderStyle.horizontalCornerRadius,Z=v.borderStyle.verticalCornerRadius;if(Q>0||Z>0){let nt=`calc(${Q}px * var(--scale-factor)) / calc(${Z}px * var(--scale-factor))`;O.style.borderRadius=nt}else if(this instanceof P){let nt=`calc(${$}px * var(--scale-factor)) / calc(${D}px * var(--scale-factor))`;O.style.borderRadius=nt}switch(v.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:O.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:O.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:O.style.borderBottomStyle="solid"}let tt=v.borderColor||null;tt?(this.#t=!0,O.style.borderColor=i.Util.makeHexColor(0|tt[0],0|tt[1],0|tt[2])):O.style.borderWidth=0}O.style.left=100*(F[0]-L)/M+"%",O.style.top=100*(F[1]-U)/S+"%";let{rotation:V}=v;return v.hasOwnCanvas||V===0?(O.style.width=100*$/M+"%",O.style.height=100*D/S+"%"):this.setRotation(V,O),O}setRotation(p,v=this.container){if(!this.data.rect)return;let{pageWidth:_,pageHeight:k}=this.parent.viewport.rawDims,{width:O,height:M}=f(this.data.rect),S,L;p%180==0?(S=100*O/_,L=100*M/k):(S=100*M/_,L=100*O/k),v.style.width=`${S}%`,v.style.height=`${L}%`,v.setAttribute("data-main-rotation",(360-p)%360)}get _commonActions(){let p=(v,_,k)=>{let O=k.detail[v],M=O[0],S=O.slice(1);k.target.style[_]=g[`${M}_HTML`](S),this.annotationStorage.setValue(this.data.id,{[_]:g[`${M}_rgb`](S)})};return(0,i.shadow)(this,"_commonActions",{display:v=>{let{display:_}=v.detail,k=_%2==1;this.container.style.visibility=k?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:k,noPrint:_===1||_===2})},print:v=>{this.annotationStorage.setValue(this.data.id,{noPrint:!v.detail.print})},hidden:v=>{let{hidden:_}=v.detail;this.container.style.visibility=_?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:_,noView:_})},focus:v=>{setTimeout((()=>v.target.focus({preventScroll:!1})),0)},userName:v=>{v.target.title=v.detail.userName},readonly:v=>{v.target.disabled=v.detail.readonly},required:v=>{this._setRequired(v.target,v.detail.required)},bgColor:v=>{p("bgColor","backgroundColor",v)},fillColor:v=>{p("fillColor","backgroundColor",v)},fgColor:v=>{p("fgColor","color",v)},textColor:v=>{p("textColor","color",v)},borderColor:v=>{p("borderColor","borderColor",v)},strokeColor:v=>{p("strokeColor","borderColor",v)},rotation:v=>{let _=v.detail.rotation;this.setRotation(_),this.annotationStorage.setValue(this.data.id,{rotation:_})}})}_dispatchEventFromSandbox(p,v){let _=this._commonActions;for(let k of Object.keys(v.detail))(p[k]||_[k])?.(v)}_setDefaultPropertiesFromJS(p){if(!this.enableScripting)return;let v=this.annotationStorage.getRawValue(this.data.id);if(!v)return;let _=this._commonActions;for(let[k,O]of Object.entries(v)){let M=_[k];M&&(M({detail:{[k]:O},target:p}),delete v[k])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:p}=this.data;if(!p)return;let[v,_,k,O]=this.data.rect;if(p.length===1){let[,{x:Z,y:tt},{x:nt,y:pt}]=p[0];if(k===Z&&O===tt&&v===nt&&_===pt)return}let{style:M}=this.container,S;if(this.#t){let{borderColor:Z,borderWidth:tt}=M;M.borderWidth=0,S=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${Z}" stroke-width="${tt}">`],this.container.classList.add("hasBorder")}let L=k-v,U=O-_,{svgFactory:$}=this,D=$.createElement("svg");D.classList.add("quadrilateralsContainer"),D.setAttribute("width",0),D.setAttribute("height",0);let F=$.createElement("defs");D.append(F);let V=$.createElement("clipPath"),Q=`clippath_${this.data.id}`;V.setAttribute("id",Q),V.setAttribute("clipPathUnits","objectBoundingBox"),F.append(V);for(let[,{x:Z,y:tt},{x:nt,y:pt}]of p){let dt=$.createElement("rect"),lt=(nt-v)/L,wt=(O-tt)/U,Tt=(Z-nt)/L,xt=(tt-pt)/U;dt.setAttribute("x",lt),dt.setAttribute("y",wt),dt.setAttribute("width",Tt),dt.setAttribute("height",xt),V.append(dt),S?.push(`<rect vector-effect="non-scaling-stroke" x="${lt}" y="${wt}" width="${Tt}" height="${xt}"/>`)}this.#t&&(S.push("</g></svg>')"),M.backgroundImage=S.join("")),this.container.append(D),this.container.style.clipPath=`url(#${Q})`}_createPopup(){let{container:p,data:v}=this;p.setAttribute("aria-haspopup","dialog");let _=new N({data:{color:v.color,titleObj:v.titleObj,modificationDate:v.modificationDate,contentsObj:v.contentsObj,richText:v.richText,parentRect:v.rect,borderStyle:0,id:`popup_${v.id}`,rotation:v.rotation},parent:this.parent,elements:[this]});this.parent.div.append(_.render())}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(p,v=null){let _=[];if(this._fieldObjects){let k=this._fieldObjects[p];if(k)for(let{page:O,id:M,exportValues:S}of k){if(O===-1||M===v)continue;let L=typeof S=="string"?S:null,U=document.querySelector(`[data-element-id="${M}"]`);!U||a.has(U)?_.push({id:M,exportValue:L,domElement:U}):(0,i.warn)(`_getElementsByName - element not allowed: ${M}`)}return _}for(let k of document.getElementsByName(p)){let{exportValue:O}=k,M=k.getAttribute("data-element-id");M!==v&&a.has(k)&&_.push({id:M,exportValue:O,domElement:k})}return _}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let p=this.getElementsToTriggerPopup();if(Array.isArray(p))for(let v of p)v.classList.add("highlightArea");else p.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:p,data:{id:v}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:p,editId:v})}))}}class u extends C{constructor(p,v=null){super(p,{isRenderable:!0,ignoreBorder:!!v?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=p.data.isTooltipOnly}render(){let{data:p,linkService:v}=this,_=document.createElement("a");_.setAttribute("data-element-id",p.id);let k=!1;return p.url?(v.addLinkAttributes(_,p.url,p.newWindow),k=!0):p.action?(this._bindNamedAction(_,p.action),k=!0):p.attachment?(this.#e(_,p.attachment,p.attachmentDest),k=!0):p.setOCGState?(this.#i(_,p.setOCGState),k=!0):p.dest?(this._bindLink(_,p.dest),k=!0):(p.actions&&(p.actions.Action||p.actions["Mouse Up"]||p.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(_,p),k=!0),p.resetForm?(this._bindResetFormAction(_,p.resetForm),k=!0):this.isTooltipOnly&&!k&&(this._bindLink(_,""),k=!0)),this.container.classList.add("linkAnnotation"),k&&this.container.append(_),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(p,v){p.href=this.linkService.getDestinationHash(v),p.onclick=()=>(v&&this.linkService.goToDestination(v),!1),(v||v==="")&&this.#t()}_bindNamedAction(p,v){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.linkService.executeNamedAction(v),!1),this.#t()}#e(p,v,_=null){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.downloadManager?.openOrDownloadData(v.content,v.filename,_),!1),this.#t()}#i(p,v){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.linkService.executeSetOCGState(v),!1),this.#t()}_bindJSAction(p,v){p.href=this.linkService.getAnchorUrl("");let _=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let k of Object.keys(v.actions)){let O=_.get(k);O&&(p[O]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v.id,name:k}}),!1))}p.onclick||(p.onclick=()=>!1),this.#t()}_bindResetFormAction(p,v){let _=p.onclick;_||(p.href=this.linkService.getAnchorUrl("")),this.#t(),this._fieldObjects?p.onclick=()=>{_?.();let{fields:k,refs:O,include:M}=v,S=[];if(k.length!==0||O.length!==0){let $=new Set(O);for(let D of k){let F=this._fieldObjects[D]||[];for(let{id:V}of F)$.add(V)}for(let D of Object.values(this._fieldObjects))for(let F of D)$.has(F.id)===M&&S.push(F)}else for(let $ of Object.values(this._fieldObjects))S.push(...$);let L=this.annotationStorage,U=[];for(let $ of S){let{id:D}=$;switch(U.push(D),$.type){case"text":{let V=$.defaultValue||"";L.setValue(D,{value:V});break}case"checkbox":case"radiobutton":{let V=$.defaultValue===$.exportValues;L.setValue(D,{value:V});break}case"combobox":case"listbox":{let V=$.defaultValue||"";L.setValue(D,{value:V});break}default:continue}let F=document.querySelector(`[data-element-id="${D}"]`);F&&(a.has(F)?F.dispatchEvent(new Event("resetform")):(0,i.warn)(`_bindResetFormAction - element not allowed: ${D}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:U,name:"ResetForm"}}),!1}:((0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),_||(p.onclick=()=>!1))}}class y extends C{constructor(p){super(p,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let p=document.createElement("img");return p.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",p.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),p.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(p),this.container}}class r extends C{render(){return this.container}showElementAndHideCanvas(p){this.data.hasOwnCanvas&&(p.previousSibling?.nodeName==="CANVAS"&&(p.previousSibling.hidden=!0),p.hidden=!1)}_getKeyModifier(p){return i.FeatureTest.platform.isMac?p.metaKey:p.ctrlKey}_setEventListener(p,v,_,k,O){_.includes("mouse")?p.addEventListener(_,(M=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(M),shift:M.shiftKey,modifier:this._getKeyModifier(M)}})})):p.addEventListener(_,(M=>{if(_==="blur"){if(!v.focused||!M.relatedTarget)return;v.focused=!1}else if(_==="focus"){if(v.focused)return;v.focused=!0}O&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(M)}})}))}_setEventListeners(p,v,_,k){for(let[O,M]of _)(M==="Action"||this.data.actions?.[M])&&(M!=="Focus"&&M!=="Blur"||(v||={focused:!1}),this._setEventListener(p,v,O,M,k),M!=="Focus"||this.data.actions?.Blur?M!=="Blur"||this.data.actions?.Focus||this._setEventListener(p,v,"focus","Focus",null):this._setEventListener(p,v,"blur","Blur",null))}_setBackgroundColor(p){let v=this.data.backgroundColor||null;p.style.backgroundColor=v===null?"transparent":i.Util.makeHexColor(v[0],v[1],v[2])}_setTextStyle(p){let v=["left","center","right"],{fontColor:_}=this.data.defaultAppearanceData,k=this.data.defaultAppearanceData.fontSize||9,O=p.style,M,S=L=>Math.round(10*L)/10;if(this.data.multiLine){let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2),U=L/(Math.round(L/(i.LINE_FACTOR*k))||1);M=Math.min(k,S(U/i.LINE_FACTOR))}else{let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2);M=Math.min(k,S(L/i.LINE_FACTOR))}O.fontSize=`calc(${M}px * var(--scale-factor))`,O.color=i.Util.makeHexColor(_[0],_[1],_[2]),this.data.textAlignment!==null&&(O.textAlign=v[this.data.textAlignment])}_setRequired(p,v){v?p.setAttribute("required",!0):p.removeAttribute("required"),p.setAttribute("aria-required",v)}}class c extends r{constructor(p){super(p,{isRenderable:p.renderForms||p.data.hasOwnCanvas||!p.data.hasAppearance&&!!p.data.fieldValue})}setPropertyOnSiblings(p,v,_,k){let O=this.annotationStorage;for(let M of this._getElementsByName(p.name,p.id))M.domElement&&(M.domElement[v]=_),O.setValue(M.id,{[k]:_})}render(){let p=this.annotationStorage,v=this.data.id;this.container.classList.add("textWidgetAnnotation");let _=null;if(this.renderForms){let k=p.getValue(v,{value:this.data.fieldValue}),O=k.value||"",M=p.getValue(v,{charLimit:this.data.maxLen}).charLimit;M&&O.length>M&&(O=O.slice(0,M));let S=k.formattedValue||this.data.textContent?.join(`
3
+ Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+h,n),this.file.getUintBytes(i+h+n,o)];i+=C*d}}},Yr=class extends Kr{};Nt(Yr,"type","heic");var Jr=class extends Kr{};Nt(Jr,"type","avif"),ns.set("heic",Yr),ns.set("avif",Jr),Le(ei,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),Le(ei,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),Le(ei,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),Le(Us,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);var yn=Le(Us,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]),Pc={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};yn.set(37392,Pc),yn.set(41488,Pc);var ua={0:"Normal",1:"Low",2:"High"};function Dc(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Ic(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function pa(s){if(typeof s=="string"){var[t,e,i,n,o,l]=s.trim().split(/[-: ]/g).map(Number),h=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(o)||Number.isNaN(l)||(h.setHours(n),h.setMinutes(o),h.setSeconds(l)),Number.isNaN(+h)?s:h}}function mn(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Mc(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Mc(s[e],s[e+1]));return Lc(String.fromCodePoint(...t))}function Mc(s,t){return s<<8|t}yn.set(41992,ua),yn.set(41993,ua),yn.set(41994,ua),Le(ss,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Fc(s):s}],[306,pa],[40091,mn],[40092,mn],[40093,mn],[40094,mn],[40095,mn]]),Le(ss,"exif",[[40960,Ic],[36864,Ic],[36867,pa],[36868,pa],[40962,Dc],[40963,Dc]]),Le(ss,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var vn=class extends ti{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:ii.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(o){let l={},h={};for(let g of Gc)l[g]=[],h[g]=0;return o.replace(nu,((g,m,d)=>{if(m==="<"){let a=++h[d];return l[d].push(a),`${g}#${a}`}return`${g}#${l[d].pop()}`}))})(t);let e=Qr.findAll(t,"rdf","Description");e.length===0&&e.push(new Qr("rdf","Description",void 0,t));let i,n={};for(let o of e)for(let l of o.properties)i=su(l.ns,n),Hc(l,i);return(function(o){let l;for(let h in o)l=o[h]=jr(o[h]),l===void 0&&delete o[h];return jr(o)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};Nt(vn,"type","xmp"),Nt(vn,"multiSegment",!0),ge.set("xmp",vn);var Sa=class s{static findAll(t){return jc(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=Vc(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},Qr=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return jc(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],o=t[8];return new s(e,i,n,o)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=Sa.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?Vc(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return iu(this.children.map(eu));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)Hc(e,t);return this.value!==void 0&&(t.value=this.value),jr(t)}};function Hc(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var eu=s=>s.serialize(),iu=s=>s.length===1?s[0]:s,su=(s,t)=>t[s]?t[s]:t[s]={};function jc(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function Vc(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var Gc=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],nu=new RegExp(`(<|\\/)(${Gc.join("|")})`,"g"),Wc=tu;async function zs(s){try{return await Wc.parse(s)||null}catch{return null}}function we(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function Hs(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let h=await s.arrayBuffer(),g=globalThis.Buffer,m=typeof g<"u"?g.from(h).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(h)));return`data:${s.type||"image/png"};base64,${m}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((h,g)=>{let m=new FileReader;m.onload=()=>h(m.result),m.onerror=g,m.readAsDataURL(s)});let o=document.createElement("canvas");o.width=Math.round(t.width*n),o.height=Math.round(t.height*n),o.getContext("2d").drawImage(t,0,0,o.width,o.height),t.close();let l=s.type==="image/png"?"image/png":"image/jpeg";return o.toDataURL(l,l==="image/png"?void 0:.82)}function Da(s,t=21,e=.2,i=128){let{data:n,width:o,height:l}=s,h=o+1,g=new Float64Array((o+1)*(l+1)),m=new Float64Array((o+1)*(l+1)),d=new Uint8Array(o*l);for(let f=0;f<l;f++){let A=0,C=0,u=f*o,y=(f+1)*h,r=f*h;for(let c=0;c<o;c++){let b=(u+c)*4,w=n[b]*77+n[b+1]*150+n[b+2]*29>>8;d[u+c]=w,A+=w,C+=w*w,g[y+c+1]=g[r+c+1]+A,m[y+c+1]=m[r+c+1]+C}}let a=Math.floor(t/2);for(let f=0;f<l;f++){let A=Math.max(0,f-a),C=Math.min(l-1,f+a),u=A*h,y=(C+1)*h;for(let r=0;r<o;r++){let c=Math.max(0,r-a),b=Math.min(o-1,r+a),w=(b-c+1)*(C-A+1),P=g[y+b+1]-g[u+b+1]-g[y+c]+g[u+c],E=m[y+b+1]-m[u+b+1]-m[y+c]+m[u+c],I=P/w,N=Math.max(0,E/w-I*I),z=Math.sqrt(N),H=I*(1+e*(z/i-1)),X=f*o+r,it=d[X]<H?0:255,at=X*4;n[at]=it,n[at+1]=it,n[at+2]=it}}return s}function Ia(s,t=21,e=.2,i=128){return new Promise(n=>{let o=new Image;o.onload=()=>{let l=document.createElement("canvas");l.width=o.width,l.height=o.height;let h=l.getContext("2d");h.drawImage(o,0,0);let g=h.getImageData(0,0,l.width,l.height);Da(g,t,e,i),h.putImageData(g,0,0);let m=s.startsWith("data:image/png"),d=m?"image/png":"image/jpeg";n(l.toDataURL(d,m?void 0:.82))},o.src=s})}function Ma(s){return new Promise(t=>{let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=e.height,i.height=e.width;let n=i.getContext("2d");n.translate(i.width/2,i.height/2),n.rotate(Math.PI/2),n.drawImage(e,-e.width/2,-e.height/2);let o=s.startsWith("data:image/png"),l=o?"image/png":"image/jpeg";t(i.toDataURL(l,o?void 0:.82))},e.src=s})}function Ra(s,t=""){if(!s)return"";let e=s.getCroppedCanvas(),i=t.startsWith("data:image/png"),n=i?"image/png":"image/jpeg";return e.toDataURL(n,i?void 0:.82)}function Ge(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=s.crop&&typeof s.crop=="object"&&s.crop.width>0&&s.crop.height>0?{x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:null,e=(Math.round(s.rotation||0)%360+360)%360,i=s.filter==="bw"?"bw":"none";return{crop:t,rotation:e,filter:i}}function La(s){if(!s)return!1;let t=Ge(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function js(s,t){let e=Ge(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,o=document.createElement("canvas"),l=i,h=n,g=0,m=0;e.crop&&(g=Math.max(0,Math.min(e.crop.x,i)),m=Math.max(0,Math.min(e.crop.y,n)),l=Math.max(1,Math.min(e.crop.width,i-g)),h=Math.max(1,Math.min(e.crop.height,n-m))),o.width=l,o.height=h,o.getContext("2d").drawImage(s,g,m,l,h,0,0,l,h);let a=o;if(e.rotation!==0){let f=e.rotation,A=document.createElement("canvas");f===90||f===270?(A.width=a.height,A.height=a.width):(A.width=a.width,A.height=a.height);let C=A.getContext("2d");C.translate(A.width/2,A.height/2),C.rotate(f*Math.PI/180),C.drawImage(a,-a.width/2,-a.height/2),a=A}if(e.filter==="bw"){let f=a.getContext("2d"),A=f.getImageData(0,0,a.width,a.height);Da(A),f.putImageData(A,0,0)}return a}function Zr(s,t){if(!s)return Promise.resolve("");let e=Ge(t);return La(e)?new Promise((i,n)=>{let o=new Image;o.onload=()=>{try{let l=s.startsWith("data:image/png"),h=l?"image/png":"image/jpeg",g=js(o,e);i(g.toDataURL(h,l?void 0:.82))}catch(l){n(l)}},o.onerror=n,o.src=s}):Promise.resolve(s)}var _i=class{#t=null;#e=new Map;#i=new Map;constructor(t=Ls()){this.#t=t}get adapter(){return this.#t}get store(){return this.#t?.store??null}async init(){return this.#t.init()}listDocsSync(){return typeof this.#t.listDocsSync=="function"?this.#t.listDocsSync().map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}}):[]}async listDocs(){return(await this.#t.listDocs()).map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}})}getDocSync(t){if(!t)return null;if(typeof this.#t.getDocSync=="function"){let n=this.#t.getDocSync(t);return n?{id:n.id,name:n.name||"",pages:this.#s(n.pages)}:null}let i=this.listDocsSync().find(n=>n.id===t);return i?{id:i.id,name:i.name,pages:i.pages||[]}:null}async getDoc(t){return this.getDocSync(t)}async createDoc(t="Untitled Document",e=[]){let i=we(),n=this.#s(e),o={id:i,name:t||"Untitled Document",pages:n};return await this.#t.saveDoc(i,o),o}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=this.#s(e.pages);await this.#t.saveDoc(t,{id:t,name:e.name||"",pages:i})}async renameDoc(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);i.name=e,await this.saveDoc(t,i)}async deleteDoc(t,{soft:e=!0,timeoutMs:i=5e3}={}){if(!t)return;let n=this.getDocSync(t);if(n){if(this.#n(t),await this.#t.deleteDoc(t),e&&i>0){let o=setTimeout(async()=>{this.#e.delete(t)},i);this.#e.set(t,{doc:n,timerId:o})}return{id:t,name:n.name,undo:()=>this.undoDeleteDoc(t)}}}#n(t){if(this.#e.has(t)){let e=this.#e.get(t);clearTimeout(e.timerId),this.#e.delete(t)}}async undoDeleteDoc(t){let e=this.#e.get(t);return e?(clearTimeout(e.timerId),this.#e.delete(t),await this.#t.saveDoc(t,e.doc),e.doc):null}isSoftDeletedDoc(t){return this.#e.has(t)}async addPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=Array.isArray(e)?e:[e];i.pages.push(...n),await this.saveDoc(t,i)}async updatePage(t,e,i){let n=await this.getDoc(t);if(!n)throw new Error(`Document "${t}" not found`);let o=n.pages.findIndex(l=>l.id===e);if(o===-1)throw new Error(`Page "${e}" not found in document "${t}"`);n.pages[o]={...n.pages[o],...i},await this.saveDoc(t,n)}async reorderPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=new Map(i.pages.map(l=>[l.id,l])),o=[];for(let l of e)n.has(l)&&(o.push(n.get(l)),n.delete(l));for(let l of n.values())o.push(l);i.pages=o,await this.saveDoc(t,i)}async deletePage(t,e,{soft:i=!0,timeoutMs:n=5e3}={}){let o=await this.getDoc(t);if(!o)throw new Error(`Document "${t}" not found`);let l=o.pages.findIndex(d=>d.id===e);if(l===-1)return;let[h]=o.pages.splice(l,1);await this.saveDoc(t,o);let g=`${t}:${e}`;if(this.#r(g),!i||n<=0){if(typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(d){console.warn("[DocRepository] Adapter deletePage error:",d)}return}let m=setTimeout(async()=>{if(this.#i.delete(g),typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(d){console.warn("[DocRepository] Adapter deletePage error:",d)}},n);return this.#i.set(g,{docId:t,pageId:e,page:h,index:l,timerId:m}),{docId:t,pageId:e,undo:()=>this.undoDeletePage(t,e)}}#r(t){if(this.#i.has(t)){let e=this.#i.get(t);clearTimeout(e.timerId),this.#i.delete(t)}}async undoDeletePage(t,e){let i=`${t}:${e}`,n=this.#i.get(i);if(!n)return null;clearTimeout(n.timerId),this.#i.delete(i);let o=await this.getDoc(t);if(!o)return null;let l=Math.min(n.index,o.pages.length);return o.pages.splice(l,0,n.page),await this.saveDoc(t,o),n.page}isSoftDeletedPage(t,e){return this.#i.has(`${t}:${e}`)}subscribe(t){return this.#t.subscribe(t)}async getAllDocs(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]=i;return e}async exportAll(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]={name:i.name,pages:JSON.stringify(i.pages)};return e}async importDocs(t){let e=0;for(let[i,n]of Object.entries(t||{})){await this.getDoc(i)||e++;let l=this.#s(n.pages);await this.saveDoc(i,{name:n.name||"",pages:l})}return e}#s(t){if(Array.isArray(t))return[...t];if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}},Fa=new _i;var Oa=".";function eo(){return Oa}function os(s){typeof s=="string"&&(Oa=s.replace(/\/+$/,"")||".")}function ni(s){if(!s)return"";if(/^(https?:|\/\/|data:|blob:)/i.test(s))return s;let t=s.replace(/^\/+/,""),e=Oa;return!e||e==="."?t:`${e}/${t}`}var to=new Map;function ri(s,t){let e=t();if(e)return Promise.resolve(e);if(to.has(s))return to.get(s);let i=new Promise((n,o)=>{if(typeof document>"u"){o(new Error(`Cannot load script "${s}" in an environment without DOM document.`));return}let l=ni(s),h=document.querySelector(`script[src="${l}"], script[src="${s}"]`);if(h){if(t()){n(t());return}h.addEventListener("load",()=>n(t()),{once:!0}),h.addEventListener("error",()=>o(new Error(`Failed to load "${s}": Network error`)),{once:!0});return}let g=document.createElement("script");g.src=l,g.async=!0,g.onload=()=>{let m=t();n(m)},g.onerror=()=>{to.delete(s),g.remove(),o(new Error(`Failed to load script "${s}": Network error`))},document.head.appendChild(g)});return to.set(s,i),i}async function io(){return ri("js/lib/cropper.js",()=>window.Cropper)}async function Vs(){return ri("js/lib/pdfkit.js",()=>window.PDFDocument)}async function so(){return ri("js/lib/jszip.min.js",()=>window.JSZip)}async function ki(){return ri("js/lib/marked.min.js",()=>window.marked)}async function no(){return ri("js/lib/peerjs.min.js",()=>window.Peer)}async function ro(){return ri("js/lib/qrcode.js",()=>window.qrcode)}async function oo(){return ri("js/lib/tesseract.min.js",()=>window.Tesseract)}var qc="2026-11-01T16:24:14.013Z",Xc="0.1.2";var oi=class{async recognizeImageText(t,e={}){throw new Error("OcrPort.recognizeImageText() must be implemented by adapter")}async recognizeDocumentPages(t,e={}){throw new Error("OcrPort.recognizeDocumentPages() must be implemented by adapter")}async getOcrWorker(t="eng",e=null){throw new Error("OcrPort.getOcrWorker() must be implemented by adapter")}async terminateOcrWorker(){throw new Error("OcrPort.terminateOcrWorker() must be implemented by adapter")}};var Pe=class extends oi{async recognizeImageText(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async recognizeDocumentPages(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async getOcrWorker(){return null}async terminateOcrWorker(){}};var ai=class{async exportDocumentAsPdf(t,e,i={}){throw new Error("PdfPort.exportDocumentAsPdf() must be implemented by adapter")}async renderPdfPagesToDataUrls(t){throw new Error("PdfPort.renderPdfPagesToDataUrls() must be implemented by adapter")}};var We=class extends ai{async exportDocumentAsPdf(t,e,i={}){let n=new Error('Feature "pdf" is disabled or PDF module not opted in');throw n.code="FEATURE_DISABLED",n}async renderPdfPagesToDataUrls(t){return[]}};var qe=class{async renderEdits(t,e){throw new Error("ImageProcessorPort.renderEdits() must be implemented by adapter")}async crop(t,e){throw new Error("ImageProcessorPort.crop() must be implemented by adapter")}async rotate(t,e){throw new Error("ImageProcessorPort.rotate() must be implemented by adapter")}async applyFilter(t,e){throw new Error("ImageProcessorPort.applyFilter() must be implemented by adapter")}};function ru(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var li=class extends qe{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await ru(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),js(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};var as=class extends qe{async renderEdits(t,e){return t}async crop(t,e){return t}async rotate(t,e){return t}async applyFilter(t,e){return t}};function _n(s={}){let t=s&&s.crop&&typeof s.crop=="object"?{x:Math.max(0,Math.min(1,Number(s.crop.x)||0)),y:Math.max(0,Math.min(1,Number(s.crop.y)||0)),w:Math.max(0,Math.min(1,Number(s.crop.w)||1)),h:Math.max(0,Math.min(1,Number(s.crop.h)||1))}:null,e=0;if(s&&s.rotate!==void 0){let n=(Math.round(Number(s.rotate)/90)*90%360+360)%360;(n===90||n===180||n===270)&&(e=n)}let i=s&&s.filter==="bw"?"bw":"none";return{crop:t,rotate:e,filter:i}}function ao(s){return s?!!(s.crop||s.rotate&&s.rotate!==0||s.filter&&s.filter!=="none"):!1}var ls=class{constructor(t){this.id=t.id,this.src=t.src,this.originalSrc=t.originalSrc||t.src,this.edits=_n(t.edits),this.name=t.name||"Page",this.type=t.type||"image",this.orientation=t.orientation||1,this.ocrText=t.ocrText||null,this.ocrConfidence=t.ocrConfidence??null}get isModified(){return ao(this.edits)}toJSON(){return{id:this.id,src:this.src,originalSrc:this.originalSrc,edits:this.edits,name:this.name,type:this.type,orientation:this.orientation,ocrText:this.ocrText,ocrConfidence:this.ocrConfidence}}},En=class{constructor(t){this.id=t.id,this.name=t.name||"Untitled Document",this.pages=Array.isArray(t.pages)?t.pages.map(e=>e instanceof ls?e:new ls(e)):[],this.createdAt=t.createdAt||Date.now(),this.updatedAt=t.updatedAt||Date.now()}get pageCount(){return this.pages.length}toJSON(){return{id:this.id,name:this.name,pages:this.pages.map(t=>t.toJSON()),createdAt:this.createdAt,updatedAt:this.updatedAt}}},Cn=class{constructor(t={}){this.mode=t.mode==="single"?"single":"batch",this.aspect=t.aspect||"auto",this.docId=t.docId||null,this.maxPages=Math.max(0,Number(t.maxPages)||0),this.stage="viewfinder",this.activePageIndex=0,this.history=[],this.future=[]}pushHistory(t){this.history.push(t),this.future=[],this.history.length>50&&this.history.shift()}undo(){if(this.history.length===0)return null;let t=this.history.pop();return this.future.push(t),t}redo(){if(this.future.length===0)return null;let t=this.future.pop();return this.history.push(t),t}};var te={PAGE_ADDED:"copio:page-added",PAGE_REMOVED:"copio:page-removed",PAGES_CHANGED:"copio:pages-changed",SCAN_COMPLETE:"copio:scan-complete",EXPORT_PROGRESS:"copio:export-progress",EXPORT_COMPLETE:"copio:export-complete",OCR_COMPLETE:"copio:ocr-complete",SYNC_CONNECTED:"copio:sync-connected",ERROR:"copio:error"};function lo(s,t,e={}){let i=new CustomEvent(t,{bubbles:!0,composed:!0,cancelable:!0,detail:e});return s&&typeof s.dispatchEvent=="function"&&s.dispatchEvent(i),i}var $a=["crop","rotate","filter","ocr","export","sync"],Na=["pdf","zip","png","jpg"],Ba=["eng"],Ua={};function Pi(s,t){!s||!t||(Ua[s]=t,typeof globalThis<"u"&&(globalThis.__copio_services__=globalThis.__copio_services__||{},globalThis.__copio_services__[s]=t))}function Ti(s){return Ua[s]?Ua[s]:typeof globalThis<"u"&&globalThis.__copio_services__?.[s]?globalThis.__copio_services__[s]:null}function ou(s){return s?s instanceof Set?new Set(s):Array.isArray(s)?new Set(s.map(t=>String(t).trim().toLowerCase()).filter(Boolean)):typeof s=="string"?new Set(s.split(/[\s,]+/).map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set($a):new Set($a)}function co(s,t){return s?Array.isArray(s)?s.map(e=>String(e).trim().toLowerCase()).filter(Boolean):typeof s=="string"?s.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean):[...t]:[...t]}var cs=class{#t=new Set($a);#e=[...Na];#i=[...Ba];#n=0;#r="";#s=null;#o=null;#c={};#a=!0;#d=!0;#p=null;#u=new Map;#l=new Map;constructor(t={}){this.#s=t.storage||Ls(t),this.#o=t.repository||new _i(this.#s),t.services&&(this.#c={...t.services}),t.imageProcessor?(this.#p=t.imageProcessor,this.#c.imageProcessor=t.imageProcessor):this.getService("imageProcessor")?this.#p=this.getService("imageProcessor"):typeof document<"u"?this.#p=new li:this.#p=new as,t.features!==void 0&&this.setFeatures(t.features),t.exportFormats!==void 0&&(this.#e=co(t.exportFormats,Na)),t.ocrLanguages!==void 0&&(this.#i=co(t.ocrLanguages,Ba)),t.maxPages!==void 0&&(this.#n=Math.max(0,Number(t.maxPages)||0)),t.assetBase!==void 0&&os(t.assetBase),t.licenseKey!==void 0&&(this.#r=String(t.licenseKey||"")),t.ocr!==void 0?this.ocr=!!t.ocr:t.features!==void 0&&!this.hasFeature("ocr")&&(this.ocr=!1),t.pdf!==void 0?this.pdf=!!t.pdf:t.exportFormats!==void 0&&!this.#e.includes("pdf")&&(this.pdf=!1)}async init(){return this.#s.init()}setService(t,e){this.#c[t]=e}getService(t){return this.#c[t]||Ti(t)}hasFeature(t){return t?this.#t.has(String(t).trim().toLowerCase()):!1}get features(){return Array.from(this.#t)}setFeatures(t){this.#t=ou(t),this.hasFeature("ocr")?(this.#a=!0,this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr"))):(this.#a=!1,this.setService("ocr",new Pe))}enableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.add(e),e==="ocr"&&(this.#a=!0,this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr")))}}disableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.delete(e),e==="ocr"&&(this.#a=!1,this.setService("ocr",new Pe))}}get ocr(){return this.#a&&this.hasFeature("ocr")}set ocr(t){this.#a=!!t,this.#a?(this.enableFeature("ocr"),this.getService("ocr")instanceof Pe&&this.setService("ocr",Ti("ocr"))):(this.disableFeature("ocr"),this.setService("ocr",new Pe))}get pdf(){return this.#d&&this.#e.includes("pdf")}set pdf(t){this.#d=!!t,this.#d?(this.#e.includes("pdf")||this.#e.push("pdf"),this.getService("pdf")instanceof We&&this.setService("pdf",Ti("pdf"))):(this.#e=this.#e.filter(e=>e!=="pdf"),this.setService("pdf",new We))}get exportFormats(){return[...this.#e]}set exportFormats(t){this.#e=co(t,Na),this.#e.includes("pdf")?(this.#d=!0,this.getService("pdf")instanceof We&&this.setService("pdf",Ti("pdf"))):(this.#d=!1,this.setService("pdf",new We))}get ocrLanguages(){return[...this.#i]}set ocrLanguages(t){this.#i=co(t,Ba)}get maxPages(){return this.#n}set maxPages(t){this.#n=Math.max(0,Number(t)||0)}get assetBase(){return eo()}set assetBase(t){os(t)}get licenseKey(){return this.#r}set licenseKey(t){this.#r=String(t||"")}get storage(){return this.#s}setStorage(t){t&&(this.#s=t,this.#o=new _i(this.#s))}#f(t,e){this.#u.has(t)||this.#u.set(t,[]);let i=this.#u.get(t);i.push(e),i.length>50&&i.shift(),this.#l.has(t)&&(this.#l.get(t).length=0)}get imageProcessor(){return this.#p}setImageProcessor(t){t&&(this.#p=t,this.setService("imageProcessor",t))}get docs(){return this.#o}async listDocuments(){return this.#o.listDocs()}async getDocument(t){return this.#o.getDoc(t)}async createDocument(t,e){return this.#o.createDoc(t,e)}async deleteDocument(t,e={}){return this.#o.deleteDoc(t,e)}async undoDeleteDocument(t){return this.#o.undoDeleteDoc(t)}async renameDocument(t,e){return this.#o.renameDoc(t,e)}async addPages(t,e){return this.#o.addPages(t,e)}async deletePage(t,e,i={}){return this.#f(t,{type:"delete",pageId:e}),this.#o.deletePage(t,e,i)}async undoDeletePage(t,e){return this.#o.undoDeletePage(t,e)}async updatePage(t,e,i){return this.#o.updatePage(t,e,i)}async reorderPages(t,e){let i=await this.getDocument(t),n=i?.pages?i.pages.map(o=>o.id):[];return this.#f(t,{type:"reorder",priorOrder:n,newOrder:[...e]}),this.#o.reorderPages(t,e)}async#g(t){if(t)return t;let e=await this.listDocuments();return e.length>0?e[0].id:null}async applyEdit(t,e,i){let n=await this.#g(t),o=n?await this.getDocument(n):null;if(!o||!o.pages)throw new Error(`Document with ID "${n||t}" not found`);let l=o.pages.find(f=>f.id===e);if(!l)throw new Error(`Page with ID "${e}" not found in document "${n}"`);let h={...l.edits||{crop:null,rotate:0,filter:"none"}},g=l.src,m=_n({...h,...i}),d=l.originalSrc||l.src,a=d;return this.#p&&(a=await this.#p.renderEdits(d,m)),await this.updatePage(n,e,{originalSrc:d,src:a,edits:m}),this.#f(n,{type:"edit",pageId:e,priorEdits:h,priorSrc:g,newEdits:m,newSrc:a}),{...l,originalSrc:d,src:a,edits:m}}async undo(t){let e=await this.#g(t),i=e?this.#u.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#l.has(e)||this.#l.set(e,[]),this.#l.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.priorEdits,src:n.priorSrc}),{type:"edit",pageId:n.pageId,restoredEdits:n.priorEdits}):n.type==="delete"?(await this.undoDeletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.#o.reorderPages(e,n.priorOrder),{type:"reorder",priorOrder:n.priorOrder}):n}async redo(t){let e=await this.#g(t),i=e?this.#l.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#u.has(e)||this.#u.set(e,[]),this.#u.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.newEdits,src:n.newSrc}),{type:"edit",pageId:n.pageId,appliedEdits:n.newEdits}):n.type==="delete"?(await this.deletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.reorderPages(e,n.newOrder),{type:"reorder",newOrder:n.newOrder}):n}subscribe(t){return this.#o.subscribe(t)}async addFiles(t,e=null){if(!t||t.length===0)return[];let i=Array.from(t),n=[];for(let l of i)if(l.type==="application/pdf"){let h=this.getService("pdf");if(h&&typeof h.renderPdfPagesToDataUrls=="function"){let g=await h.renderPdfPagesToDataUrls(l);for(let m of g)n.push({id:we(),src:m,originalSrc:m,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:l.name||"PDF Page"})}else console.warn("PDF import service (PdfPort) not registered. Skipping PDF file.")}else if(l.type&&l.type.startsWith("image/")){let h=await Hs(l),g=null;try{g=await zs(l)}catch{}n.push({id:we(),src:h,originalSrc:h,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:l.name||"Captured Image",orientation:g})}if(n.length===0)return[];let o=e;if(o)await this.getDocument(o)||await this.#o.saveDoc(o,{name:"Scanned Document",pages:[]});else{let l=await this.listDocuments();l.length>0?o=l[0].id:o=(await this.createDocument("Scanned Document",[])).id}if(this.#n>0){let l=(await this.getDocument(o))?.pages||[],h=Math.max(0,this.#n-l.length);if(h<=0)throw new Error(`Maximum page limit (${this.#n}) reached`);n.splice(h)}return await this.addPages(o,n),n}async getPages(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return[];e=n[0].id}return(await this.getDocument(e))?.pages||[]}async clear(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return;e=n[0].id}let i=await this.getDocument(e);if(!(!i||!i.pages))for(let n of i.pages)await this.deletePage(e,n.id)}async#h(t){if(Array.isArray(t))return{docName:"document",pages:t,docId:null};if(typeof t=="string"){let i=await this.getDocument(t);return{docName:i?.name||"document",pages:i?.pages||[],docId:t}}let e=await this.listDocuments();if(e.length>0){let i=await this.getDocument(e[0].id);return{docName:i?.name||"document",pages:i?.pages||[],docId:e[0].id}}return{docName:"document",pages:[],docId:null}}async exportPdf(t,e={}){if(!this.hasFeature("export")){let l=new Error('Feature "export" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}if(!this.#d||!this.#e.includes("pdf")){let l=new Error('Feature "pdf" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}let{docName:i,pages:n}=await this.#h(t),o=this.getService("pdf")||this.getService("export");if(!o||typeof o.exportDocumentAsPdf!="function")throw new Error("Export service (PdfPort) is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsPdf(i,n,{download:!1,showProgress:!1,...e})}async exportZip(t,e={}){if(!this.hasFeature("export")){let l=new Error('Feature "export" is disabled');throw Object.assign(l,{code:"FEATURE_DISABLED"}),l}let{docName:i,pages:n}=await this.#h(t),o=this.getService("export");if(!o||typeof o.exportDocumentAsImages!="function")throw new Error("Export service is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsImages(i,n,{download:!1,showProgress:!1,...e})}async runOcr(t,e=null,i={}){if(!this.#a||!this.hasFeature("ocr")){let m=new Error('Feature "ocr" is disabled');throw Object.assign(m,{code:"FEATURE_DISABLED"}),m}let{pages:n}=await this.#h(t),o=n;e&&(o=n.filter(m=>m.id===e));let l=this.getService("ocr");if(!l||typeof l.recognizeDocumentPages!="function")throw new Error("OCR service (OcrPort) is not registered. Import @copio/sdk or register an ocrService.");let h=i.lang||this.#i[0]||"eng",g=await l.recognizeDocumentPages(o,{lang:h,...i});return{text:g.combinedText,...g}}async sync(t={}){if(!this.hasFeature("sync")){let i=new Error('Feature "sync" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}let e=this.getService("sync");if(!e)throw new Error("Sync service (SyncPort) is not registered. Import @copio/sdk or register a syncService.");return new e(this.#o,t.onStateChange)}};function Kc(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Ke(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Kc(Object(e),!0).forEach(function(i){au(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):Kc(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function go(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?go=function(t){return typeof t}:go=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},go(s)}function au(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function hi(){return hi=Object.assign||function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},hi.apply(this,arguments)}function lu(s,t){if(s==null)return{};var e={},i=Object.keys(s),n,o;for(o=0;o<i.length;o++)n=i[o],!(t.indexOf(n)>=0)&&(e[n]=s[n]);return e}function cu(s,t){if(s==null)return{};var e=lu(s,t),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(n=0;n<o.length;n++)i=o[n],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(s,i)&&(e[i]=s[i])}return e}var hu="1.15.6";function ci(s){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(s)}var di=ci(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Fn=ci(/Edge/i),Yc=ci(/firefox/i),Dn=ci(/safari/i)&&!ci(/chrome/i)&&!ci(/android/i),tl=ci(/iP(ad|od|hone)/i),nh=ci(/chrome/i)&&ci(/android/i),rh={capture:!1,passive:!1};function Ot(s,t,e){s.addEventListener(t,e,!di&&rh)}function Ft(s,t,e){s.removeEventListener(t,e,!di&&rh)}function wo(s,t){if(t){if(t[0]===">"&&(t=t.substring(1)),s)try{if(s.matches)return s.matches(t);if(s.msMatchesSelector)return s.msMatchesSelector(t);if(s.webkitMatchesSelector)return s.webkitMatchesSelector(t)}catch{return!1}return!1}}function oh(s){return s.host&&s!==document&&s.host.nodeType?s.host:s.parentNode}function Oe(s,t,e,i){if(s){e=e||document;do{if(t!=null&&(t[0]===">"?s.parentNode===e&&wo(s,t):wo(s,t))||i&&s===e)return s;if(s===e)break}while(s=oh(s))}return null}var Jc=/\s+/g;function _e(s,t,e){if(s&&t)if(s.classList)s.classList[e?"add":"remove"](t);else{var i=(" "+s.className+" ").replace(Jc," ").replace(" "+t+" "," ");s.className=(i+(e?" "+t:"")).replace(Jc," ")}}function Et(s,t,e){var i=s&&s.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(s,""):s.currentStyle&&(e=s.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Ks(s,t){var e="";if(typeof s=="string")e=s;else do{var i=Et(s,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(s=s.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(e)}function ah(s,t,e){if(s){var i=s.getElementsByTagName(t),n=0,o=i.length;if(e)for(;n<o;n++)e(i[n],n);return i}return[]}function Xe(){var s=document.scrollingElement;return s||document.documentElement}function ie(s,t,e,i,n){if(!(!s.getBoundingClientRect&&s!==window)){var o,l,h,g,m,d,a;if(s!==window&&s.parentNode&&s!==Xe()?(o=s.getBoundingClientRect(),l=o.top,h=o.left,g=o.bottom,m=o.right,d=o.height,a=o.width):(l=0,h=0,g=window.innerHeight,m=window.innerWidth,d=window.innerHeight,a=window.innerWidth),(t||e)&&s!==window&&(n=n||s.parentNode,!di))do if(n&&n.getBoundingClientRect&&(Et(n,"transform")!=="none"||e&&Et(n,"position")!=="static")){var f=n.getBoundingClientRect();l-=f.top+parseInt(Et(n,"border-top-width")),h-=f.left+parseInt(Et(n,"border-left-width")),g=l+o.height,m=h+o.width;break}while(n=n.parentNode);if(i&&s!==window){var A=Ks(n||s),C=A&&A.a,u=A&&A.d;A&&(l/=u,h/=C,a/=C,d/=u,g=l+d,m=h+a)}return{top:l,left:h,bottom:g,right:m,width:a,height:d}}}function Qc(s,t,e){for(var i=Mi(s,!0),n=ie(s)[t];i;){var o=ie(i)[e],l=void 0;if(e==="top"||e==="left"?l=n>=o:l=n<=o,!l)return i;if(i===Xe())break;i=Mi(i,!1)}return!1}function Ys(s,t,e,i){for(var n=0,o=0,l=s.children;o<l.length;){if(l[o].style.display!=="none"&&l[o]!==Ct.ghost&&(i||l[o]!==Ct.dragged)&&Oe(l[o],e.draggable,s,!1)){if(n===t)return l[o];n++}o++}return null}function el(s,t){for(var e=s.lastElementChild;e&&(e===Ct.ghost||Et(e,"display")==="none"||t&&!wo(e,t));)e=e.previousElementSibling;return e||null}function De(s,t){var e=0;if(!s||!s.parentNode)return-1;for(;s=s.previousElementSibling;)s.nodeName.toUpperCase()!=="TEMPLATE"&&s!==Ct.clone&&(!t||wo(s,t))&&e++;return e}function Zc(s){var t=0,e=0,i=Xe();if(s)do{var n=Ks(s),o=n.a,l=n.d;t+=s.scrollLeft*o,e+=s.scrollTop*l}while(s!==i&&(s=s.parentNode));return[t,e]}function du(s,t){for(var e in s)if(s.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===s[e][i])return Number(e)}return-1}function Mi(s,t){if(!s||!s.getBoundingClientRect)return Xe();var e=s,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var n=Et(e);if(e.clientWidth<e.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return Xe();if(i||t)return e;i=!0}}while(e=e.parentNode);return Xe()}function uu(s,t){if(s&&t)for(var e in t)t.hasOwnProperty(e)&&(s[e]=t[e]);return s}function za(s,t){return Math.round(s.top)===Math.round(t.top)&&Math.round(s.left)===Math.round(t.left)&&Math.round(s.height)===Math.round(t.height)&&Math.round(s.width)===Math.round(t.width)}var In;function lh(s,t){return function(){if(!In){var e=arguments,i=this;e.length===1?s.call(i,e[0]):s.apply(i,e),In=setTimeout(function(){In=void 0},t)}}}function pu(){clearTimeout(In),In=void 0}function ch(s,t,e){s.scrollLeft+=t,s.scrollTop+=e}function hh(s){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(s).cloneNode(!0):e?e(s).clone(!0)[0]:s.cloneNode(!0)}function dh(s,t,e){var i={};return Array.from(s.children).forEach(function(n){var o,l,h,g;if(!(!Oe(n,t.draggable,s,!1)||n.animated||n===e)){var m=ie(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,m.left),i.top=Math.min((l=i.top)!==null&&l!==void 0?l:1/0,m.top),i.right=Math.max((h=i.right)!==null&&h!==void 0?h:-1/0,m.right),i.bottom=Math.max((g=i.bottom)!==null&&g!==void 0?g:-1/0,m.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var Ae="Sortable"+new Date().getTime();function fu(){var s=[],t;return{captureAnimationState:function(){if(s=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(Et(n,"display")==="none"||n===Ct.ghost)){s.push({target:n,rect:ie(n)});var o=Ke({},s[s.length-1].rect);if(n.thisAnimationDuration){var l=Ks(n,!0);l&&(o.top-=l.f,o.left-=l.e)}n.fromRect=o}})}},addAnimationState:function(i){s.push(i)},removeAnimationState:function(i){s.splice(du(s,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var o=!1,l=0;s.forEach(function(h){var g=0,m=h.target,d=m.fromRect,a=ie(m),f=m.prevFromRect,A=m.prevToRect,C=h.rect,u=Ks(m,!0);u&&(a.top-=u.f,a.left-=u.e),m.toRect=a,m.thisAnimationDuration&&za(f,a)&&!za(d,a)&&(C.top-a.top)/(C.left-a.left)===(d.top-a.top)/(d.left-a.left)&&(g=mu(C,f,A,n.options)),za(a,d)||(m.prevFromRect=d,m.prevToRect=a,g||(g=n.options.animation),n.animate(m,C,a,g)),g&&(o=!0,l=Math.max(l,g),clearTimeout(m.animationResetTimer),m.animationResetTimer=setTimeout(function(){m.animationTime=0,m.prevFromRect=null,m.fromRect=null,m.prevToRect=null,m.thisAnimationDuration=null},g),m.thisAnimationDuration=g)}),clearTimeout(t),o?t=setTimeout(function(){typeof i=="function"&&i()},l):typeof i=="function"&&i(),s=[]},animate:function(i,n,o,l){if(l){Et(i,"transition",""),Et(i,"transform","");var h=Ks(this.el),g=h&&h.a,m=h&&h.d,d=(n.left-o.left)/(g||1),a=(n.top-o.top)/(m||1);i.animatingX=!!d,i.animatingY=!!a,Et(i,"transform","translate3d("+d+"px,"+a+"px,0)"),this.forRepaintDummy=gu(i),Et(i,"transition","transform "+l+"ms"+(this.options.easing?" "+this.options.easing:"")),Et(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){Et(i,"transition",""),Et(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},l)}}}}function gu(s){return s.offsetWidth}function mu(s,t,e,i){return Math.sqrt(Math.pow(t.top-s.top,2)+Math.pow(t.left-s.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var Gs=[],Ha={initializeByDefault:!0},On={mount:function(t){for(var e in Ha)Ha.hasOwnProperty(e)&&!(e in t)&&(t[e]=Ha[e]);Gs.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Gs.push(t)},pluginEvent:function(t,e,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=t+"Global";Gs.forEach(function(l){e[l.pluginName]&&(e[l.pluginName][o]&&e[l.pluginName][o](Ke({sortable:e},i)),e.options[l.pluginName]&&e[l.pluginName][t]&&e[l.pluginName][t](Ke({sortable:e},i)))})},initializePlugins:function(t,e,i,n){Gs.forEach(function(h){var g=h.pluginName;if(!(!t.options[g]&&!h.initializeByDefault)){var m=new h(t,e,t.options);m.sortable=t,m.options=t.options,t[g]=m,hi(i,m.defaults)}});for(var o in t.options)if(t.options.hasOwnProperty(o)){var l=this.modifyOption(t,o,t.options[o]);typeof l<"u"&&(t.options[o]=l)}},getEventProperties:function(t,e){var i={};return Gs.forEach(function(n){typeof n.eventProperties=="function"&&hi(i,n.eventProperties.call(e[n.pluginName],t))}),i},modifyOption:function(t,e,i){var n;return Gs.forEach(function(o){t[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[e]=="function"&&(n=o.optionListeners[e].call(t[o.pluginName],i))}),n}};function bu(s){var t=s.sortable,e=s.rootEl,i=s.name,n=s.targetEl,o=s.cloneEl,l=s.toEl,h=s.fromEl,g=s.oldIndex,m=s.newIndex,d=s.oldDraggableIndex,a=s.newDraggableIndex,f=s.originalEvent,A=s.putSortable,C=s.extraEventProperties;if(t=t||e&&e[Ae],!!t){var u,y=t.options,r="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!di&&!Fn?u=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(u=document.createEvent("Event"),u.initEvent(i,!0,!0)),u.to=l||e,u.from=h||e,u.item=n||e,u.clone=o,u.oldIndex=g,u.newIndex=m,u.oldDraggableIndex=d,u.newDraggableIndex=a,u.originalEvent=f,u.pullMode=A?A.lastPutMode:void 0;var c=Ke(Ke({},C),On.getEventProperties(i,t));for(var b in c)u[b]=c[b];e&&e.dispatchEvent(u),y[r]&&y[r].call(t,u)}}var yu=["evt"],xe=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=cu(i,yu);On.pluginEvent.bind(Ct)(t,e,Ke({dragEl:gt,parentEl:Qt,ghostEl:kt,rootEl:Gt,nextEl:us,lastDownEl:mo,cloneEl:Kt,cloneHidden:Ii,dragStarted:kn,putSortable:ce,activeSortable:Ct.active,originalEvent:n,oldIndex:Xs,oldDraggableIndex:Mn,newIndex:ke,newDraggableIndex:Di,hideGhostForTarget:gh,unhideGhostForTarget:mh,cloneNowHidden:function(){Ii=!0},cloneNowShown:function(){Ii=!1},dispatchSortableEvent:function(h){me({sortable:e,name:h,originalEvent:n})}},o))};function me(s){bu(Ke({putSortable:ce,cloneEl:Kt,targetEl:gt,rootEl:Gt,oldIndex:Xs,oldDraggableIndex:Mn,newIndex:ke,newDraggableIndex:Di},s))}var gt,Qt,kt,Gt,us,mo,Kt,Ii,Xs,ke,Mn,Di,ho,ce,qs=!1,xo=!1,Ao=[],hs,Fe,ja,Va,th,eh,kn,Ws,Rn,Ln=!1,uo=!1,bo,ue,Ga=[],Ya=!1,So=[],Co=typeof document<"u",po=tl,ih=Fn||di?"cssFloat":"float",vu=Co&&!nh&&!tl&&"draggable"in document.createElement("div"),uh=(function(){if(Co){if(di)return!1;var s=document.createElement("x");return s.style.cssText="pointer-events:auto",s.style.pointerEvents==="auto"}})(),ph=function(t,e){var i=Et(t),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=Ys(t,0,e),l=Ys(t,1,e),h=o&&Et(o),g=l&&Et(l),m=h&&parseInt(h.marginLeft)+parseInt(h.marginRight)+ie(o).width,d=g&&parseInt(g.marginLeft)+parseInt(g.marginRight)+ie(l).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&h.float&&h.float!=="none"){var a=h.float==="left"?"left":"right";return l&&(g.clear==="both"||g.clear===a)?"vertical":"horizontal"}return o&&(h.display==="block"||h.display==="flex"||h.display==="table"||h.display==="grid"||m>=n&&i[ih]==="none"||l&&i[ih]==="none"&&m+d>n)?"vertical":"horizontal"},wu=function(t,e,i){var n=i?t.left:t.top,o=i?t.right:t.bottom,l=i?t.width:t.height,h=i?e.left:e.top,g=i?e.right:e.bottom,m=i?e.width:e.height;return n===h||o===g||n+l/2===h+m/2},xu=function(t,e){var i;return Ao.some(function(n){var o=n[Ae].options.emptyInsertThreshold;if(!(!o||el(n))){var l=ie(n),h=t>=l.left-o&&t<=l.right+o,g=e>=l.top-o&&e<=l.bottom+o;if(h&&g)return i=n}}),i},fh=function(t){function e(o,l){return function(h,g,m,d){var a=h.options.group.name&&g.options.group.name&&h.options.group.name===g.options.group.name;if(o==null&&(l||a))return!0;if(o==null||o===!1)return!1;if(l&&o==="clone")return o;if(typeof o=="function")return e(o(h,g,m,d),l)(h,g,m,d);var f=(l?h:g).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var i={},n=t.group;(!n||go(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=e(n.pull,!0),i.checkPut=e(n.put),i.revertClone=n.revertClone,t.group=i},gh=function(){!uh&&kt&&Et(kt,"display","none")},mh=function(){!uh&&kt&&Et(kt,"display","")};Co&&!nh&&document.addEventListener("click",function(s){if(xo)return s.preventDefault(),s.stopPropagation&&s.stopPropagation(),s.stopImmediatePropagation&&s.stopImmediatePropagation(),xo=!1,!1},!0);var ds=function(t){if(gt){t=t.touches?t.touches[0]:t;var e=xu(t.clientX,t.clientY);if(e){var i={};for(var n in t)t.hasOwnProperty(n)&&(i[n]=t[n]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[Ae]._onDragOver(i)}}},Au=function(t){gt&&gt.parentNode[Ae]._isOutsideThisEl(t.target)};function Ct(s,t){if(!(s&&s.nodeType&&s.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(s));this.el=s,this.options=t=hi({},t),s[Ae]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(s.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ph(s,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(l,h){l.setData("Text",h.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Ct.supportPointer!==!1&&"PointerEvent"in window&&(!Dn||tl),emptyInsertThreshold:5};On.initializePlugins(this,s,e);for(var i in e)!(i in t)&&(t[i]=e[i]);fh(t);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=t.forceFallback?!1:vu,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Ot(s,"pointerdown",this._onTapStart):(Ot(s,"mousedown",this._onTapStart),Ot(s,"touchstart",this._onTapStart)),this.nativeDraggable&&(Ot(s,"dragover",this),Ot(s,"dragenter",this)),Ao.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),hi(this,fu())}Ct.prototype={constructor:Ct,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Ws=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,gt):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,n=this.options,o=n.preventOnFilter,l=t.type,h=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,g=(h||t).target,m=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||g,d=n.filter;if(Du(i),!gt&&!(/mousedown|pointerdown/.test(l)&&t.button!==0||n.disabled)&&!m.isContentEditable&&!(!this.nativeDraggable&&Dn&&g&&g.tagName.toUpperCase()==="SELECT")&&(g=Oe(g,n.draggable,i,!1),!(g&&g.animated)&&mo!==g)){if(Xs=De(g),Mn=De(g,n.draggable),typeof d=="function"){if(d.call(this,t,g,this)){me({sortable:e,rootEl:m,name:"filter",targetEl:g,toEl:i,fromEl:i}),xe("filter",e,{evt:t}),o&&t.preventDefault();return}}else if(d&&(d=d.split(",").some(function(a){if(a=Oe(m,a.trim(),i,!1),a)return me({sortable:e,rootEl:a,name:"filter",targetEl:g,fromEl:i,toEl:i}),xe("filter",e,{evt:t}),!0}),d)){o&&t.preventDefault();return}n.handle&&!Oe(m,n.handle,i,!1)||this._prepareDragStart(t,h,g)}}},_prepareDragStart:function(t,e,i){var n=this,o=n.el,l=n.options,h=o.ownerDocument,g;if(i&&!gt&&i.parentNode===o){var m=ie(i);if(Gt=o,gt=i,Qt=gt.parentNode,us=gt.nextSibling,mo=i,ho=l.group,Ct.dragged=gt,hs={target:gt,clientX:(e||t).clientX,clientY:(e||t).clientY},th=hs.clientX-m.left,eh=hs.clientY-m.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,gt.style["will-change"]="all",g=function(){if(xe("delayEnded",n,{evt:t}),Ct.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!Yc&&n.nativeDraggable&&(gt.draggable=!0),n._triggerDragStart(t,e),me({sortable:n,name:"choose",originalEvent:t}),_e(gt,l.chosenClass,!0)},l.ignore.split(",").forEach(function(d){ah(gt,d.trim(),Wa)}),Ot(h,"dragover",ds),Ot(h,"mousemove",ds),Ot(h,"touchmove",ds),l.supportPointer?(Ot(h,"pointerup",n._onDrop),!this.nativeDraggable&&Ot(h,"pointercancel",n._onDrop)):(Ot(h,"mouseup",n._onDrop),Ot(h,"touchend",n._onDrop),Ot(h,"touchcancel",n._onDrop)),Yc&&this.nativeDraggable&&(this.options.touchStartThreshold=4,gt.draggable=!0),xe("delayStart",this,{evt:t}),l.delay&&(!l.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(Fn||di))){if(Ct.eventCanceled){this._onDrop();return}l.supportPointer?(Ot(h,"pointerup",n._disableDelayedDrag),Ot(h,"pointercancel",n._disableDelayedDrag)):(Ot(h,"mouseup",n._disableDelayedDrag),Ot(h,"touchend",n._disableDelayedDrag),Ot(h,"touchcancel",n._disableDelayedDrag)),Ot(h,"mousemove",n._delayedDragTouchMoveHandler),Ot(h,"touchmove",n._delayedDragTouchMoveHandler),l.supportPointer&&Ot(h,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(g,l.delay)}else g()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){gt&&Wa(gt),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Ft(t,"mouseup",this._disableDelayedDrag),Ft(t,"touchend",this._disableDelayedDrag),Ft(t,"touchcancel",this._disableDelayedDrag),Ft(t,"pointerup",this._disableDelayedDrag),Ft(t,"pointercancel",this._disableDelayedDrag),Ft(t,"mousemove",this._delayedDragTouchMoveHandler),Ft(t,"touchmove",this._delayedDragTouchMoveHandler),Ft(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?Ot(document,"pointermove",this._onTouchMove):e?Ot(document,"touchmove",this._onTouchMove):Ot(document,"mousemove",this._onTouchMove):(Ot(gt,"dragend",this),Ot(Gt,"dragstart",this._onDragStart));try{document.selection?yo(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(qs=!1,Gt&&gt){xe("dragStarted",this,{evt:e}),this.nativeDraggable&&Ot(document,"dragover",Au);var i=this.options;!t&&_e(gt,i.dragClass,!1),_e(gt,i.ghostClass,!0),Ct.active=this,t&&this._appendGhost(),me({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Fe){this._lastX=Fe.clientX,this._lastY=Fe.clientY,gh();for(var t=document.elementFromPoint(Fe.clientX,Fe.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Fe.clientX,Fe.clientY),t!==e);)e=t;if(gt.parentNode[Ae]._isOutsideThisEl(t),e)do{if(e[Ae]){var i=void 0;if(i=e[Ae]._onDragOver({clientX:Fe.clientX,clientY:Fe.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=oh(e));mh()}},_onTouchMove:function(t){if(hs){var e=this.options,i=e.fallbackTolerance,n=e.fallbackOffset,o=t.touches?t.touches[0]:t,l=kt&&Ks(kt,!0),h=kt&&l&&l.a,g=kt&&l&&l.d,m=po&&ue&&Zc(ue),d=(o.clientX-hs.clientX+n.x)/(h||1)+(m?m[0]-Ga[0]:0)/(h||1),a=(o.clientY-hs.clientY+n.y)/(g||1)+(m?m[1]-Ga[1]:0)/(g||1);if(!Ct.active&&!qs){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(kt){l?(l.e+=d-(ja||0),l.f+=a-(Va||0)):l={a:1,b:0,c:0,d:1,e:d,f:a};var f="matrix(".concat(l.a,",").concat(l.b,",").concat(l.c,",").concat(l.d,",").concat(l.e,",").concat(l.f,")");Et(kt,"webkitTransform",f),Et(kt,"mozTransform",f),Et(kt,"msTransform",f),Et(kt,"transform",f),ja=d,Va=a,Fe=o}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!kt){var t=this.options.fallbackOnBody?document.body:Gt,e=ie(gt,!0,po,!0,t),i=this.options;if(po){for(ue=t;Et(ue,"position")==="static"&&Et(ue,"transform")==="none"&&ue!==document;)ue=ue.parentNode;ue!==document.body&&ue!==document.documentElement?(ue===document&&(ue=Xe()),e.top+=ue.scrollTop,e.left+=ue.scrollLeft):ue=Xe(),Ga=Zc(ue)}kt=gt.cloneNode(!0),_e(kt,i.ghostClass,!1),_e(kt,i.fallbackClass,!0),_e(kt,i.dragClass,!0),Et(kt,"transition",""),Et(kt,"transform",""),Et(kt,"box-sizing","border-box"),Et(kt,"margin",0),Et(kt,"top",e.top),Et(kt,"left",e.left),Et(kt,"width",e.width),Et(kt,"height",e.height),Et(kt,"opacity","0.8"),Et(kt,"position",po?"absolute":"fixed"),Et(kt,"zIndex","100000"),Et(kt,"pointerEvents","none"),Ct.ghost=kt,t.appendChild(kt),Et(kt,"transform-origin",th/parseInt(kt.style.width)*100+"% "+eh/parseInt(kt.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,n=t.dataTransfer,o=i.options;if(xe("dragStart",this,{evt:t}),Ct.eventCanceled){this._onDrop();return}xe("setupClone",this),Ct.eventCanceled||(Kt=hh(gt),Kt.removeAttribute("id"),Kt.draggable=!1,Kt.style["will-change"]="",this._hideClone(),_e(Kt,this.options.chosenClass,!1),Ct.clone=Kt),i.cloneId=yo(function(){xe("clone",i),!Ct.eventCanceled&&(i.options.removeCloneOnHide||Gt.insertBefore(Kt,gt),i._hideClone(),me({sortable:i,name:"clone"}))}),!e&&_e(gt,o.dragClass,!0),e?(xo=!0,i._loopId=setInterval(i._emulateDragOver,50)):(Ft(document,"mouseup",i._onDrop),Ft(document,"touchend",i._onDrop),Ft(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,gt)),Ot(document,"drop",i),Et(gt,"transform","translateZ(0)")),qs=!0,i._dragStartId=yo(i._dragStarted.bind(i,e,t)),Ot(document,"selectstart",i),kn=!0,window.getSelection().removeAllRanges(),Dn&&Et(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,n,o,l,h=this.options,g=h.group,m=Ct.active,d=ho===g,a=h.sort,f=ce||m,A,C=this,u=!1;if(Ya)return;function y(et,rt){xe(et,C,Ke({evt:t,isOwner:d,axis:A?"vertical":"horizontal",revert:l,dragRect:n,targetRect:o,canSort:a,fromSortable:f,target:i,completed:c,onMove:function(st,W){return fo(Gt,e,gt,n,st,ie(st),t,W)},changed:b},rt))}function r(){y("dragOverAnimationCapture"),C.captureAnimationState(),C!==f&&f.captureAnimationState()}function c(et){return y("dragOverCompleted",{insertion:et}),et&&(d?m._hideClone():m._showClone(C),C!==f&&(_e(gt,ce?ce.options.ghostClass:m.options.ghostClass,!1),_e(gt,h.ghostClass,!0)),ce!==C&&C!==Ct.active?ce=C:C===Ct.active&&ce&&(ce=null),f===C&&(C._ignoreWhileAnimating=i),C.animateAll(function(){y("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(i===gt&&!gt.animated||i===e&&!i.animated)&&(Ws=null),!h.dragoverBubble&&!t.rootEl&&i!==document&&(gt.parentNode[Ae]._isOutsideThisEl(t.target),!et&&ds(t)),!h.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),u=!0}function b(){ke=De(gt),Di=De(gt,h.draggable),me({sortable:C,name:"change",toEl:e,newIndex:ke,newDraggableIndex:Di,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=Oe(i,h.draggable,e,!0),y("dragOver"),Ct.eventCanceled)return u;if(gt.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||C._ignoreWhileAnimating===i)return c(!1);if(xo=!1,m&&!h.disabled&&(d?a||(l=Qt!==Gt):ce===this||(this.lastPutMode=ho.checkPull(this,m,gt,t))&&g.checkPut(this,m,gt,t))){if(A=this._getDirection(t,i)==="vertical",n=ie(gt),y("dragOverValid"),Ct.eventCanceled)return u;if(l)return Qt=Gt,r(),this._hideClone(),y("revert"),Ct.eventCanceled||(us?Gt.insertBefore(gt,us):Gt.appendChild(gt)),c(!0);var w=el(e,h.draggable);if(!w||_u(t,A,this)&&!w.animated){if(w===gt)return c(!1);if(w&&e===t.target&&(i=w),i&&(o=ie(i)),fo(Gt,e,gt,n,i,o,t,!!i)!==!1)return r(),w&&w.nextSibling?e.insertBefore(gt,w.nextSibling):e.appendChild(gt),Qt=e,b(),c(!0)}else if(w&&Cu(t,A,this)){var P=Ys(e,0,h,!0);if(P===gt)return c(!1);if(i=P,o=ie(i),fo(Gt,e,gt,n,i,o,t,!1)!==!1)return r(),e.insertBefore(gt,P),Qt=e,b(),c(!0)}else if(i.parentNode===e){o=ie(i);var E=0,I,N=gt.parentNode!==e,z=!wu(gt.animated&&gt.toRect||n,i.animated&&i.toRect||o,A),H=A?"top":"left",X=Qc(i,"top","top")||Qc(gt,"top","top"),it=X?X.scrollTop:void 0;Ws!==i&&(I=o[H],Ln=!1,uo=!z&&h.invertSwap||N),E=ku(t,i,o,A,z?1:h.swapThreshold,h.invertedSwapThreshold==null?h.swapThreshold:h.invertedSwapThreshold,uo,Ws===i);var at;if(E!==0){var K=De(gt);do K-=E,at=Qt.children[K];while(at&&(Et(at,"display")==="none"||at===kt))}if(E===0||at===i)return c(!1);Ws=i,Rn=E;var j=i.nextElementSibling,G=!1;G=E===1;var Y=fo(Gt,e,gt,n,i,o,t,G);if(Y!==!1)return(Y===1||Y===-1)&&(G=Y===1),Ya=!0,setTimeout(Eu,30),r(),G&&!j?e.appendChild(gt):i.parentNode.insertBefore(gt,G?j:i),X&&ch(X,0,it-X.scrollTop),Qt=gt.parentNode,I!==void 0&&!uo&&(bo=Math.abs(I-ie(i)[H])),b(),c(!0)}if(e.contains(gt))return c(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Ft(document,"mousemove",this._onTouchMove),Ft(document,"touchmove",this._onTouchMove),Ft(document,"pointermove",this._onTouchMove),Ft(document,"dragover",ds),Ft(document,"mousemove",ds),Ft(document,"touchmove",ds)},_offUpEvents:function(){var t=this.el.ownerDocument;Ft(t,"mouseup",this._onDrop),Ft(t,"touchend",this._onDrop),Ft(t,"pointerup",this._onDrop),Ft(t,"pointercancel",this._onDrop),Ft(t,"touchcancel",this._onDrop),Ft(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(ke=De(gt),Di=De(gt,i.draggable),xe("drop",this,{evt:t}),Qt=gt&&gt.parentNode,ke=De(gt),Di=De(gt,i.draggable),Ct.eventCanceled){this._nulling();return}qs=!1,uo=!1,Ln=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ja(this.cloneId),Ja(this._dragStartId),this.nativeDraggable&&(Ft(document,"drop",this),Ft(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Dn&&Et(document.body,"user-select",""),Et(gt,"transform",""),t&&(kn&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),kt&&kt.parentNode&&kt.parentNode.removeChild(kt),(Gt===Qt||ce&&ce.lastPutMode!=="clone")&&Kt&&Kt.parentNode&&Kt.parentNode.removeChild(Kt),gt&&(this.nativeDraggable&&Ft(gt,"dragend",this),Wa(gt),gt.style["will-change"]="",kn&&!qs&&_e(gt,ce?ce.options.ghostClass:this.options.ghostClass,!1),_e(gt,this.options.chosenClass,!1),me({sortable:this,name:"unchoose",toEl:Qt,newIndex:null,newDraggableIndex:null,originalEvent:t}),Gt!==Qt?(ke>=0&&(me({rootEl:Qt,name:"add",toEl:Qt,fromEl:Gt,originalEvent:t}),me({sortable:this,name:"remove",toEl:Qt,originalEvent:t}),me({rootEl:Qt,name:"sort",toEl:Qt,fromEl:Gt,originalEvent:t}),me({sortable:this,name:"sort",toEl:Qt,originalEvent:t})),ce&&ce.save()):ke!==Xs&&ke>=0&&(me({sortable:this,name:"update",toEl:Qt,originalEvent:t}),me({sortable:this,name:"sort",toEl:Qt,originalEvent:t})),Ct.active&&((ke==null||ke===-1)&&(ke=Xs,Di=Mn),me({sortable:this,name:"end",toEl:Qt,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){xe("nulling",this),Gt=gt=Qt=kt=us=Kt=mo=Ii=hs=Fe=kn=ke=Di=Xs=Mn=Ws=Rn=ce=ho=Ct.dragged=Ct.ghost=Ct.clone=Ct.active=null,So.forEach(function(t){t.checked=!0}),So.length=ja=Va=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":gt&&(this._onDragOver(t),Su(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,n=0,o=i.length,l=this.options;n<o;n++)e=i[n],Oe(e,l.draggable,this.el,!1)&&t.push(e.getAttribute(l.dataIdAttr)||Pu(e));return t},sort:function(t,e){var i={},n=this.el;this.toArray().forEach(function(o,l){var h=n.children[l];Oe(h,this.options.draggable,n,!1)&&(i[o]=h)},this),e&&this.captureAnimationState(),t.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return Oe(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var n=On.modifyOption(this,t,e);typeof n<"u"?i[t]=n:i[t]=e,t==="group"&&fh(i)},destroy:function(){xe("destroy",this);var t=this.el;t[Ae]=null,Ft(t,"mousedown",this._onTapStart),Ft(t,"touchstart",this._onTapStart),Ft(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(Ft(t,"dragover",this),Ft(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ao.splice(Ao.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!Ii){if(xe("hideClone",this),Ct.eventCanceled)return;Et(Kt,"display","none"),this.options.removeCloneOnHide&&Kt.parentNode&&Kt.parentNode.removeChild(Kt),Ii=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(Ii){if(xe("showClone",this),Ct.eventCanceled)return;gt.parentNode==Gt&&!this.options.group.revertClone?Gt.insertBefore(Kt,gt):us?Gt.insertBefore(Kt,us):Gt.appendChild(Kt),this.options.group.revertClone&&this.animate(gt,Kt),Et(Kt,"display",""),Ii=!1}}};function Su(s){s.dataTransfer&&(s.dataTransfer.dropEffect="move"),s.cancelable&&s.preventDefault()}function fo(s,t,e,i,n,o,l,h){var g,m=s[Ae],d=m.options.onMove,a;return window.CustomEvent&&!di&&!Fn?g=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent("move",!0,!0)),g.to=t,g.from=s,g.dragged=e,g.draggedRect=i,g.related=n||t,g.relatedRect=o||ie(t),g.willInsertAfter=h,g.originalEvent=l,s.dispatchEvent(g),d&&(a=d.call(m,g,l)),a}function Wa(s){s.draggable=!1}function Eu(){Ya=!1}function Cu(s,t,e){var i=ie(Ys(e.el,0,e.options,!0)),n=dh(e.el,e.options,kt),o=10;return t?s.clientX<n.left-o||s.clientY<i.top&&s.clientX<i.right:s.clientY<n.top-o||s.clientY<i.bottom&&s.clientX<i.left}function _u(s,t,e){var i=ie(el(e.el,e.options.draggable)),n=dh(e.el,e.options,kt),o=10;return t?s.clientX>n.right+o||s.clientY>i.bottom&&s.clientX>i.left:s.clientY>n.bottom+o||s.clientX>i.right&&s.clientY>i.top}function ku(s,t,e,i,n,o,l,h){var g=i?s.clientY:s.clientX,m=i?e.height:e.width,d=i?e.top:e.left,a=i?e.bottom:e.right,f=!1;if(!l){if(h&&bo<m*n){if(!Ln&&(Rn===1?g>d+m*o/2:g<a-m*o/2)&&(Ln=!0),Ln)f=!0;else if(Rn===1?g<d+bo:g>a-bo)return-Rn}else if(g>d+m*(1-n)/2&&g<a-m*(1-n)/2)return Tu(t)}return f=f||l,f&&(g<d+m*o/2||g>a-m*o/2)?g>d+m/2?1:-1:0}function Tu(s){return De(gt)<De(s)?1:-1}function Pu(s){for(var t=s.tagName+s.className+s.src+s.href+s.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function Du(s){So.length=0;for(var t=s.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&So.push(i)}}function yo(s){return setTimeout(s,0)}function Ja(s){return clearTimeout(s)}Co&&Ot(document,"touchmove",function(s){(Ct.active||qs)&&s.cancelable&&s.preventDefault()});Ct.utils={on:Ot,off:Ft,css:Et,find:ah,is:function(t,e){return!!Oe(t,e,t,!1)},extend:uu,throttle:lh,closest:Oe,toggleClass:_e,clone:hh,index:De,nextTick:yo,cancelNextTick:Ja,detectDirection:ph,getChild:Ys,expando:Ae};Ct.get=function(s){return s[Ae]};Ct.mount=function(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(Ct.utils=Ke(Ke({},Ct.utils),i.utils)),On.mount(i)})};Ct.create=function(s,t){return new Ct(s,t)};Ct.version=hu;var ee=[],Tn,Qa,Za=!1,qa,Xa,Eo,Pn;function Iu(){function s(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return s.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?Ot(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Ot(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Ot(document,"touchmove",this._handleFallbackAutoScroll):Ot(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?Ft(document,"dragover",this._handleAutoScroll):(Ft(document,"pointermove",this._handleFallbackAutoScroll),Ft(document,"touchmove",this._handleFallbackAutoScroll),Ft(document,"mousemove",this._handleFallbackAutoScroll)),sh(),vo(),pu()},nulling:function(){Eo=Qa=Tn=Za=Pn=qa=Xa=null,ee.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){var n=this,o=(e.touches?e.touches[0]:e).clientX,l=(e.touches?e.touches[0]:e).clientY,h=document.elementFromPoint(o,l);if(Eo=e,i||this.options.forceAutoScrollFallback||Fn||di||Dn){Ka(e,this.options,h,i);var g=Mi(h,!0);Za&&(!Pn||o!==qa||l!==Xa)&&(Pn&&sh(),Pn=setInterval(function(){var m=Mi(document.elementFromPoint(o,l),!0);m!==g&&(g=m,vo()),Ka(e,n.options,m,i)},10),qa=o,Xa=l)}else{if(!this.options.bubbleScroll||Mi(h,!0)===Xe()){vo();return}Ka(e,this.options,Mi(h,!1),!1)}}},hi(s,{pluginName:"scroll",initializeByDefault:!0})}function vo(){ee.forEach(function(s){clearInterval(s.pid)}),ee=[]}function sh(){clearInterval(Pn)}var Ka=lh(function(s,t,e,i){if(t.scroll){var n=(s.touches?s.touches[0]:s).clientX,o=(s.touches?s.touches[0]:s).clientY,l=t.scrollSensitivity,h=t.scrollSpeed,g=Xe(),m=!1,d;Qa!==e&&(Qa=e,vo(),Tn=t.scroll,d=t.scrollFn,Tn===!0&&(Tn=Mi(e,!0)));var a=0,f=Tn;do{var A=f,C=ie(A),u=C.top,y=C.bottom,r=C.left,c=C.right,b=C.width,w=C.height,P=void 0,E=void 0,I=A.scrollWidth,N=A.scrollHeight,z=Et(A),H=A.scrollLeft,X=A.scrollTop;A===g?(P=b<I&&(z.overflowX==="auto"||z.overflowX==="scroll"||z.overflowX==="visible"),E=w<N&&(z.overflowY==="auto"||z.overflowY==="scroll"||z.overflowY==="visible")):(P=b<I&&(z.overflowX==="auto"||z.overflowX==="scroll"),E=w<N&&(z.overflowY==="auto"||z.overflowY==="scroll"));var it=P&&(Math.abs(c-n)<=l&&H+b<I)-(Math.abs(r-n)<=l&&!!H),at=E&&(Math.abs(y-o)<=l&&X+w<N)-(Math.abs(u-o)<=l&&!!X);if(!ee[a])for(var K=0;K<=a;K++)ee[K]||(ee[K]={});(ee[a].vx!=it||ee[a].vy!=at||ee[a].el!==A)&&(ee[a].el=A,ee[a].vx=it,ee[a].vy=at,clearInterval(ee[a].pid),(it!=0||at!=0)&&(m=!0,ee[a].pid=setInterval(function(){i&&this.layer===0&&Ct.active._onTouchMove(Eo);var j=ee[this.layer].vy?ee[this.layer].vy*h:0,G=ee[this.layer].vx?ee[this.layer].vx*h:0;typeof d=="function"&&d.call(Ct.dragged.parentNode[Ae],G,j,s,Eo,ee[this.layer].el)!=="continue"||ch(ee[this.layer].el,G,j)}.bind({layer:a}),24))),a++}while(t.bubbleScroll&&f!==g&&(f=Mi(f,!1)));Za=m}},30),bh=function(t){var e=t.originalEvent,i=t.putSortable,n=t.dragEl,o=t.activeSortable,l=t.dispatchSortableEvent,h=t.hideGhostForTarget,g=t.unhideGhostForTarget;if(e){var m=i||o;h();var d=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,a=document.elementFromPoint(d.clientX,d.clientY);g(),m&&!m.el.contains(a)&&(l("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function il(){}il.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=Ys(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(e,n):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:bh};hi(il,{pluginName:"revertOnSpill"});function sl(){}sl.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,n=i||this.sortable;n.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),n.animateAll()},drop:bh};hi(sl,{pluginName:"removeOnSpill"});Ct.mount(new Iu);Ct.mount(sl,il);var yh=Ct;var Js,Nn,Bn,_o,Yu={976:(s,t,e)=>{e.d(t,{AnnotationLayer:()=>T,FreeTextAnnotationElement:()=>H,InkAnnotationElement:()=>Y,StampAnnotationElement:()=>W});var i=e(292),n=e(419),o=e(792);function l(R){return Math.floor(255*Math.max(0,Math.min(1,R))).toString(16).padStart(2,"0")}function h(R){return Math.max(0,Math.min(255,255*R))}class g{static CMYK_G([p,v,_,k]){return["G",1-Math.min(1,.3*p+.59*_+.11*v+k)]}static G_CMYK([p]){return["CMYK",0,0,0,1-p]}static G_RGB([p]){return["RGB",p,p,p]}static G_rgb([p]){return[p=h(p),p,p]}static G_HTML([p]){let v=l(p);return`#${v}${v}${v}`}static RGB_G([p,v,_]){return["G",.3*p+.59*v+.11*_]}static RGB_rgb(p){return p.map(h)}static RGB_HTML(p){return`#${p.map(l).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([p,v,_,k]){return["RGB",1-Math.min(1,p+k),1-Math.min(1,_+k),1-Math.min(1,v+k)]}static CMYK_rgb([p,v,_,k]){return[h(1-Math.min(1,p+k)),h(1-Math.min(1,_+k)),h(1-Math.min(1,v+k))]}static CMYK_HTML(p){let v=this.CMYK_RGB(p).slice(1);return this.RGB_HTML(v)}static RGB_CMYK([p,v,_]){let k=1-p,O=1-v,M=1-_;return["CMYK",k,O,M,Math.min(k,O,M)]}}var m=e(284);let d=1e3,a=new WeakSet;function f(R){return{width:R[2]-R[0],height:R[3]-R[1]}}class A{static create(p){switch(p.data.annotationType){case i.AnnotationType.LINK:return new u(p);case i.AnnotationType.TEXT:return new y(p);case i.AnnotationType.WIDGET:switch(p.data.fieldType){case"Tx":return new c(p);case"Btn":return p.data.radioButton?new P(p):p.data.checkBox?new w(p):new E(p);case"Ch":return new I(p);case"Sig":return new b(p)}return new r(p);case i.AnnotationType.POPUP:return new N(p);case i.AnnotationType.FREETEXT:return new H(p);case i.AnnotationType.LINE:return new X(p);case i.AnnotationType.SQUARE:return new it(p);case i.AnnotationType.CIRCLE:return new at(p);case i.AnnotationType.POLYLINE:return new K(p);case i.AnnotationType.CARET:return new G(p);case i.AnnotationType.INK:return new Y(p);case i.AnnotationType.POLYGON:return new j(p);case i.AnnotationType.HIGHLIGHT:return new et(p);case i.AnnotationType.UNDERLINE:return new rt(p);case i.AnnotationType.SQUIGGLY:return new ct(p);case i.AnnotationType.STRIKEOUT:return new st(p);case i.AnnotationType.STAMP:return new W(p);case i.AnnotationType.FILEATTACHMENT:return new x(p);default:return new C(p)}}}class C{#t=!1;constructor(p,{isRenderable:v=!1,ignoreBorder:_=!1,createQuadrilaterals:k=!1}={}){this.isRenderable=v,this.data=p.data,this.layer=p.layer,this.linkService=p.linkService,this.downloadManager=p.downloadManager,this.imageResourcesPath=p.imageResourcesPath,this.renderForms=p.renderForms,this.svgFactory=p.svgFactory,this.annotationStorage=p.annotationStorage,this.enableScripting=p.enableScripting,this.hasJSActions=p.hasJSActions,this._fieldObjects=p.fieldObjects,this.parent=p.parent,v&&(this.container=this._createContainer(_)),k&&this._createQuadrilaterals()}static _hasPopupData({titleObj:p,contentsObj:v,richText:_}){return!!(p?.str||v?.str||_?.str)}get hasPopupData(){return C._hasPopupData(this.data)}_createContainer(p){let{data:v,parent:{page:_,viewport:k}}=this,O=document.createElement("section");O.setAttribute("data-annotation-id",v.id),this instanceof r||(O.tabIndex=d),O.style.zIndex=this.parent.zIndex++,v.popupRef&&O.setAttribute("aria-haspopup","dialog"),v.alternativeText&&(O.title=v.alternativeText),v.noRotate&&O.classList.add("norotate");let{pageWidth:M,pageHeight:S,pageX:L,pageY:U}=k.rawDims;if(!v.rect||this instanceof N){let{rotation:Q}=v;return v.hasOwnCanvas||Q===0||this.setRotation(Q,O),O}let{width:$,height:D}=f(v.rect),F=i.Util.normalizeRect([v.rect[0],_.view[3]-v.rect[1]+_.view[1],v.rect[2],_.view[3]-v.rect[3]+_.view[1]]);if(!p&&v.borderStyle.width>0){O.style.borderWidth=`${v.borderStyle.width}px`;let Q=v.borderStyle.horizontalCornerRadius,Z=v.borderStyle.verticalCornerRadius;if(Q>0||Z>0){let nt=`calc(${Q}px * var(--scale-factor)) / calc(${Z}px * var(--scale-factor))`;O.style.borderRadius=nt}else if(this instanceof P){let nt=`calc(${$}px * var(--scale-factor)) / calc(${D}px * var(--scale-factor))`;O.style.borderRadius=nt}switch(v.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:O.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:O.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:O.style.borderBottomStyle="solid"}let tt=v.borderColor||null;tt?(this.#t=!0,O.style.borderColor=i.Util.makeHexColor(0|tt[0],0|tt[1],0|tt[2])):O.style.borderWidth=0}O.style.left=100*(F[0]-L)/M+"%",O.style.top=100*(F[1]-U)/S+"%";let{rotation:V}=v;return v.hasOwnCanvas||V===0?(O.style.width=100*$/M+"%",O.style.height=100*D/S+"%"):this.setRotation(V,O),O}setRotation(p,v=this.container){if(!this.data.rect)return;let{pageWidth:_,pageHeight:k}=this.parent.viewport.rawDims,{width:O,height:M}=f(this.data.rect),S,L;p%180==0?(S=100*O/_,L=100*M/k):(S=100*M/_,L=100*O/k),v.style.width=`${S}%`,v.style.height=`${L}%`,v.setAttribute("data-main-rotation",(360-p)%360)}get _commonActions(){let p=(v,_,k)=>{let O=k.detail[v],M=O[0],S=O.slice(1);k.target.style[_]=g[`${M}_HTML`](S),this.annotationStorage.setValue(this.data.id,{[_]:g[`${M}_rgb`](S)})};return(0,i.shadow)(this,"_commonActions",{display:v=>{let{display:_}=v.detail,k=_%2==1;this.container.style.visibility=k?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:k,noPrint:_===1||_===2})},print:v=>{this.annotationStorage.setValue(this.data.id,{noPrint:!v.detail.print})},hidden:v=>{let{hidden:_}=v.detail;this.container.style.visibility=_?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:_,noView:_})},focus:v=>{setTimeout((()=>v.target.focus({preventScroll:!1})),0)},userName:v=>{v.target.title=v.detail.userName},readonly:v=>{v.target.disabled=v.detail.readonly},required:v=>{this._setRequired(v.target,v.detail.required)},bgColor:v=>{p("bgColor","backgroundColor",v)},fillColor:v=>{p("fillColor","backgroundColor",v)},fgColor:v=>{p("fgColor","color",v)},textColor:v=>{p("textColor","color",v)},borderColor:v=>{p("borderColor","borderColor",v)},strokeColor:v=>{p("strokeColor","borderColor",v)},rotation:v=>{let _=v.detail.rotation;this.setRotation(_),this.annotationStorage.setValue(this.data.id,{rotation:_})}})}_dispatchEventFromSandbox(p,v){let _=this._commonActions;for(let k of Object.keys(v.detail))(p[k]||_[k])?.(v)}_setDefaultPropertiesFromJS(p){if(!this.enableScripting)return;let v=this.annotationStorage.getRawValue(this.data.id);if(!v)return;let _=this._commonActions;for(let[k,O]of Object.entries(v)){let M=_[k];M&&(M({detail:{[k]:O},target:p}),delete v[k])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:p}=this.data;if(!p)return;let[v,_,k,O]=this.data.rect;if(p.length===1){let[,{x:Z,y:tt},{x:nt,y:pt}]=p[0];if(k===Z&&O===tt&&v===nt&&_===pt)return}let{style:M}=this.container,S;if(this.#t){let{borderColor:Z,borderWidth:tt}=M;M.borderWidth=0,S=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${Z}" stroke-width="${tt}">`],this.container.classList.add("hasBorder")}let L=k-v,U=O-_,{svgFactory:$}=this,D=$.createElement("svg");D.classList.add("quadrilateralsContainer"),D.setAttribute("width",0),D.setAttribute("height",0);let F=$.createElement("defs");D.append(F);let V=$.createElement("clipPath"),Q=`clippath_${this.data.id}`;V.setAttribute("id",Q),V.setAttribute("clipPathUnits","objectBoundingBox"),F.append(V);for(let[,{x:Z,y:tt},{x:nt,y:pt}]of p){let dt=$.createElement("rect"),lt=(nt-v)/L,wt=(O-tt)/U,Tt=(Z-nt)/L,xt=(tt-pt)/U;dt.setAttribute("x",lt),dt.setAttribute("y",wt),dt.setAttribute("width",Tt),dt.setAttribute("height",xt),V.append(dt),S?.push(`<rect vector-effect="non-scaling-stroke" x="${lt}" y="${wt}" width="${Tt}" height="${xt}"/>`)}this.#t&&(S.push("</g></svg>')"),M.backgroundImage=S.join("")),this.container.append(D),this.container.style.clipPath=`url(#${Q})`}_createPopup(){let{container:p,data:v}=this;p.setAttribute("aria-haspopup","dialog");let _=new N({data:{color:v.color,titleObj:v.titleObj,modificationDate:v.modificationDate,contentsObj:v.contentsObj,richText:v.richText,parentRect:v.rect,borderStyle:0,id:`popup_${v.id}`,rotation:v.rotation},parent:this.parent,elements:[this]});this.parent.div.append(_.render())}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(p,v=null){let _=[];if(this._fieldObjects){let k=this._fieldObjects[p];if(k)for(let{page:O,id:M,exportValues:S}of k){if(O===-1||M===v)continue;let L=typeof S=="string"?S:null,U=document.querySelector(`[data-element-id="${M}"]`);!U||a.has(U)?_.push({id:M,exportValue:L,domElement:U}):(0,i.warn)(`_getElementsByName - element not allowed: ${M}`)}return _}for(let k of document.getElementsByName(p)){let{exportValue:O}=k,M=k.getAttribute("data-element-id");M!==v&&a.has(k)&&_.push({id:M,exportValue:O,domElement:k})}return _}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let p=this.getElementsToTriggerPopup();if(Array.isArray(p))for(let v of p)v.classList.add("highlightArea");else p.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:p,data:{id:v}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:p,editId:v})}))}}class u extends C{constructor(p,v=null){super(p,{isRenderable:!0,ignoreBorder:!!v?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=p.data.isTooltipOnly}render(){let{data:p,linkService:v}=this,_=document.createElement("a");_.setAttribute("data-element-id",p.id);let k=!1;return p.url?(v.addLinkAttributes(_,p.url,p.newWindow),k=!0):p.action?(this._bindNamedAction(_,p.action),k=!0):p.attachment?(this.#e(_,p.attachment,p.attachmentDest),k=!0):p.setOCGState?(this.#i(_,p.setOCGState),k=!0):p.dest?(this._bindLink(_,p.dest),k=!0):(p.actions&&(p.actions.Action||p.actions["Mouse Up"]||p.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(_,p),k=!0),p.resetForm?(this._bindResetFormAction(_,p.resetForm),k=!0):this.isTooltipOnly&&!k&&(this._bindLink(_,""),k=!0)),this.container.classList.add("linkAnnotation"),k&&this.container.append(_),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(p,v){p.href=this.linkService.getDestinationHash(v),p.onclick=()=>(v&&this.linkService.goToDestination(v),!1),(v||v==="")&&this.#t()}_bindNamedAction(p,v){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.linkService.executeNamedAction(v),!1),this.#t()}#e(p,v,_=null){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.downloadManager?.openOrDownloadData(v.content,v.filename,_),!1),this.#t()}#i(p,v){p.href=this.linkService.getAnchorUrl(""),p.onclick=()=>(this.linkService.executeSetOCGState(v),!1),this.#t()}_bindJSAction(p,v){p.href=this.linkService.getAnchorUrl("");let _=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let k of Object.keys(v.actions)){let O=_.get(k);O&&(p[O]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v.id,name:k}}),!1))}p.onclick||(p.onclick=()=>!1),this.#t()}_bindResetFormAction(p,v){let _=p.onclick;_||(p.href=this.linkService.getAnchorUrl("")),this.#t(),this._fieldObjects?p.onclick=()=>{_?.();let{fields:k,refs:O,include:M}=v,S=[];if(k.length!==0||O.length!==0){let $=new Set(O);for(let D of k){let F=this._fieldObjects[D]||[];for(let{id:V}of F)$.add(V)}for(let D of Object.values(this._fieldObjects))for(let F of D)$.has(F.id)===M&&S.push(F)}else for(let $ of Object.values(this._fieldObjects))S.push(...$);let L=this.annotationStorage,U=[];for(let $ of S){let{id:D}=$;switch(U.push(D),$.type){case"text":{let V=$.defaultValue||"";L.setValue(D,{value:V});break}case"checkbox":case"radiobutton":{let V=$.defaultValue===$.exportValues;L.setValue(D,{value:V});break}case"combobox":case"listbox":{let V=$.defaultValue||"";L.setValue(D,{value:V});break}default:continue}let F=document.querySelector(`[data-element-id="${D}"]`);F&&(a.has(F)?F.dispatchEvent(new Event("resetform")):(0,i.warn)(`_bindResetFormAction - element not allowed: ${D}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:U,name:"ResetForm"}}),!1}:((0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),_||(p.onclick=()=>!1))}}class y extends C{constructor(p){super(p,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let p=document.createElement("img");return p.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",p.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),p.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(p),this.container}}class r extends C{render(){return this.container}showElementAndHideCanvas(p){this.data.hasOwnCanvas&&(p.previousSibling?.nodeName==="CANVAS"&&(p.previousSibling.hidden=!0),p.hidden=!1)}_getKeyModifier(p){return i.FeatureTest.platform.isMac?p.metaKey:p.ctrlKey}_setEventListener(p,v,_,k,O){_.includes("mouse")?p.addEventListener(_,(M=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(M),shift:M.shiftKey,modifier:this._getKeyModifier(M)}})})):p.addEventListener(_,(M=>{if(_==="blur"){if(!v.focused||!M.relatedTarget)return;v.focused=!1}else if(_==="focus"){if(v.focused)return;v.focused=!0}O&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(M)}})}))}_setEventListeners(p,v,_,k){for(let[O,M]of _)(M==="Action"||this.data.actions?.[M])&&(M!=="Focus"&&M!=="Blur"||(v||={focused:!1}),this._setEventListener(p,v,O,M,k),M!=="Focus"||this.data.actions?.Blur?M!=="Blur"||this.data.actions?.Focus||this._setEventListener(p,v,"focus","Focus",null):this._setEventListener(p,v,"blur","Blur",null))}_setBackgroundColor(p){let v=this.data.backgroundColor||null;p.style.backgroundColor=v===null?"transparent":i.Util.makeHexColor(v[0],v[1],v[2])}_setTextStyle(p){let v=["left","center","right"],{fontColor:_}=this.data.defaultAppearanceData,k=this.data.defaultAppearanceData.fontSize||9,O=p.style,M,S=L=>Math.round(10*L)/10;if(this.data.multiLine){let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2),U=L/(Math.round(L/(i.LINE_FACTOR*k))||1);M=Math.min(k,S(U/i.LINE_FACTOR))}else{let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2);M=Math.min(k,S(L/i.LINE_FACTOR))}O.fontSize=`calc(${M}px * var(--scale-factor))`,O.color=i.Util.makeHexColor(_[0],_[1],_[2]),this.data.textAlignment!==null&&(O.textAlign=v[this.data.textAlignment])}_setRequired(p,v){v?p.setAttribute("required",!0):p.removeAttribute("required"),p.setAttribute("aria-required",v)}}class c extends r{constructor(p){super(p,{isRenderable:p.renderForms||p.data.hasOwnCanvas||!p.data.hasAppearance&&!!p.data.fieldValue})}setPropertyOnSiblings(p,v,_,k){let O=this.annotationStorage;for(let M of this._getElementsByName(p.name,p.id))M.domElement&&(M.domElement[v]=_),O.setValue(M.id,{[k]:_})}render(){let p=this.annotationStorage,v=this.data.id;this.container.classList.add("textWidgetAnnotation");let _=null;if(this.renderForms){let k=p.getValue(v,{value:this.data.fieldValue}),O=k.value||"",M=p.getValue(v,{charLimit:this.data.maxLen}).charLimit;M&&O.length>M&&(O=O.slice(0,M));let S=k.formattedValue||this.data.textContent?.join(`
4
4
  `)||null;S&&this.data.comb&&(S=S.replaceAll(/\s+/g,""));let L={userValue:O,formattedValue:S,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(_=document.createElement("textarea"),_.textContent=S??O,this.data.doNotScroll&&(_.style.overflowY="hidden")):(_=document.createElement("input"),_.type="text",_.setAttribute("value",S??O),this.data.doNotScroll&&(_.style.overflowX="hidden")),this.data.hasOwnCanvas&&(_.hidden=!0),a.add(_),_.setAttribute("data-element-id",v),_.disabled=this.data.readOnly,_.name=this.data.fieldName,_.tabIndex=d,this._setRequired(_,this.data.required),M&&(_.maxLength=M),_.addEventListener("input",($=>{p.setValue(v,{value:$.target.value}),this.setPropertyOnSiblings(_,"value",$.target.value,"value"),L.formattedValue=null})),_.addEventListener("resetform",($=>{let D=this.data.defaultFieldValue??"";_.value=L.userValue=D,L.formattedValue=null}));let U=$=>{let{formattedValue:D}=L;D!=null&&($.target.value=D),$.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){_.addEventListener("focus",(D=>{if(L.focused)return;let{target:F}=D;L.userValue&&(F.value=L.userValue),L.lastCommittedValue=F.value,L.commitKey=1,this.data.actions?.Focus||(L.focused=!0)})),_.addEventListener("updatefromsandbox",(D=>{this.showElementAndHideCanvas(D.target);let F={value(V){L.userValue=V.detail.value??"",p.setValue(v,{value:L.userValue.toString()}),V.target.value=L.userValue},formattedValue(V){let{formattedValue:Q}=V.detail;L.formattedValue=Q,Q!=null&&V.target!==document.activeElement&&(V.target.value=Q),p.setValue(v,{formattedValue:Q})},selRange(V){V.target.setSelectionRange(...V.detail.selRange)},charLimit:V=>{let{charLimit:Q}=V.detail,{target:Z}=V;if(Q===0){Z.removeAttribute("maxLength");return}Z.setAttribute("maxLength",Q);let tt=L.userValue;tt&&!(tt.length<=Q)&&(tt=tt.slice(0,Q),Z.value=L.userValue=tt,p.setValue(v,{value:tt}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v,name:"Keystroke",value:tt,willCommit:!0,commitKey:1,selStart:Z.selectionStart,selEnd:Z.selectionEnd}}))}};this._dispatchEventFromSandbox(F,D)})),_.addEventListener("keydown",(D=>{L.commitKey=1;let F=-1;if(D.key==="Escape"?F=0:D.key!=="Enter"||this.data.multiLine?D.key==="Tab"&&(L.commitKey=3):F=2,F===-1)return;let{value:V}=D.target;L.lastCommittedValue!==V&&(L.lastCommittedValue=V,L.userValue=V,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v,name:"Keystroke",value:V,willCommit:!0,commitKey:F,selStart:D.target.selectionStart,selEnd:D.target.selectionEnd}}))}));let $=U;U=null,_.addEventListener("blur",(D=>{if(!L.focused||!D.relatedTarget)return;this.data.actions?.Blur||(L.focused=!1);let{value:F}=D.target;L.userValue=F,L.lastCommittedValue!==F&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v,name:"Keystroke",value:F,willCommit:!0,commitKey:L.commitKey,selStart:D.target.selectionStart,selEnd:D.target.selectionEnd}}),$(D)})),this.data.actions?.Keystroke&&_.addEventListener("beforeinput",(D=>{L.lastCommittedValue=null;let{data:F,target:V}=D,{value:Q,selectionStart:Z,selectionEnd:tt}=V,nt=Z,pt=tt;switch(D.inputType){case"deleteWordBackward":{let dt=Q.substring(0,Z).match(/\w*[^\w]*$/);dt&&(nt-=dt[0].length);break}case"deleteWordForward":{let dt=Q.substring(Z).match(/^[^\w]*\w*/);dt&&(pt+=dt[0].length);break}case"deleteContentBackward":Z===tt&&(nt-=1);break;case"deleteContentForward":Z===tt&&(pt+=1)}D.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v,name:"Keystroke",value:Q,change:F||"",willCommit:!1,selStart:nt,selEnd:pt}})})),this._setEventListeners(_,L,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(D=>D.target.value))}if(U&&_.addEventListener("blur",U),this.data.comb){let $=(this.data.rect[2]-this.data.rect[0])/M;_.classList.add("comb"),_.style.letterSpacing=`calc(${$}px * var(--scale-factor) - 1ch)`}}else _=document.createElement("div"),_.textContent=this.data.fieldValue,_.style.verticalAlign="middle",_.style.display="table-cell",this.data.hasOwnCanvas&&(_.hidden=!0);return this._setTextStyle(_),this._setBackgroundColor(_),this._setDefaultPropertiesFromJS(_),this.container.append(_),this.container}}class b extends r{constructor(p){super(p,{isRenderable:!!p.data.hasOwnCanvas})}}class w extends r{constructor(p){super(p,{isRenderable:p.renderForms})}render(){let p=this.annotationStorage,v=this.data,_=v.id,k=p.getValue(_,{value:v.exportValue===v.fieldValue}).value;typeof k=="string"&&(k=k!=="Off",p.setValue(_,{value:k})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let O=document.createElement("input");return a.add(O),O.setAttribute("data-element-id",_),O.disabled=v.readOnly,this._setRequired(O,this.data.required),O.type="checkbox",O.name=v.fieldName,k&&O.setAttribute("checked",!0),O.setAttribute("exportValue",v.exportValue),O.tabIndex=d,O.addEventListener("change",(M=>{let{name:S,checked:L}=M.target;for(let U of this._getElementsByName(S,_)){let $=L&&U.exportValue===v.exportValue;U.domElement&&(U.domElement.checked=$),p.setValue(U.id,{value:$})}p.setValue(_,{value:L})})),O.addEventListener("resetform",(M=>{let S=v.defaultFieldValue||"Off";M.target.checked=S===v.exportValue})),this.enableScripting&&this.hasJSActions&&(O.addEventListener("updatefromsandbox",(M=>{let S={value(L){L.target.checked=L.detail.value!=="Off",p.setValue(_,{value:L.target.checked})}};this._dispatchEventFromSandbox(S,M)})),this._setEventListeners(O,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(M=>M.target.checked))),this._setBackgroundColor(O),this._setDefaultPropertiesFromJS(O),this.container.append(O),this.container}}class P extends r{constructor(p){super(p,{isRenderable:p.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let p=this.annotationStorage,v=this.data,_=v.id,k=p.getValue(_,{value:v.fieldValue===v.buttonValue}).value;if(typeof k=="string"&&(k=k!==v.buttonValue,p.setValue(_,{value:k})),k)for(let M of this._getElementsByName(v.fieldName,_))p.setValue(M.id,{value:!1});let O=document.createElement("input");if(a.add(O),O.setAttribute("data-element-id",_),O.disabled=v.readOnly,this._setRequired(O,this.data.required),O.type="radio",O.name=v.fieldName,k&&O.setAttribute("checked",!0),O.tabIndex=d,O.addEventListener("change",(M=>{let{name:S,checked:L}=M.target;for(let U of this._getElementsByName(S,_))p.setValue(U.id,{value:!1});p.setValue(_,{value:L})})),O.addEventListener("resetform",(M=>{let S=v.defaultFieldValue;M.target.checked=S!=null&&S===v.buttonValue})),this.enableScripting&&this.hasJSActions){let M=v.buttonValue;O.addEventListener("updatefromsandbox",(S=>{let L={value:U=>{let $=M===U.detail.value;for(let D of this._getElementsByName(U.target.name)){let F=$&&D.id===_;D.domElement&&(D.domElement.checked=F),p.setValue(D.id,{value:F})}}};this._dispatchEventFromSandbox(L,S)})),this._setEventListeners(O,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(S=>S.target.checked))}return this._setBackgroundColor(O),this._setDefaultPropertiesFromJS(O),this.container.append(O),this.container}}class E extends u{constructor(p){super(p,{ignoreBorder:p.data.hasAppearance})}render(){let p=super.render();p.classList.add("buttonWidgetAnnotation","pushButton");let v=p.lastChild;return this.enableScripting&&this.hasJSActions&&v&&(this._setDefaultPropertiesFromJS(v),v.addEventListener("updatefromsandbox",(_=>{this._dispatchEventFromSandbox({},_)}))),p}}class I extends r{constructor(p){super(p,{isRenderable:p.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let p=this.annotationStorage,v=this.data.id,_=p.getValue(v,{value:this.data.fieldValue}),k=document.createElement("select");a.add(k),k.setAttribute("data-element-id",v),k.disabled=this.data.readOnly,this._setRequired(k,this.data.required),k.name=this.data.fieldName,k.tabIndex=d;let O=this.data.combo&&this.data.options.length>0;this.data.combo||(k.size=this.data.options.length,this.data.multiSelect&&(k.multiple=!0)),k.addEventListener("resetform",($=>{let D=this.data.defaultFieldValue;for(let F of k.options)F.selected=F.value===D}));for(let $ of this.data.options){let D=document.createElement("option");D.textContent=$.displayValue,D.value=$.exportValue,_.value.includes($.exportValue)&&(D.setAttribute("selected",!0),O=!1),k.append(D)}let M=null;if(O){let $=document.createElement("option");$.value=" ",$.setAttribute("hidden",!0),$.setAttribute("selected",!0),k.prepend($),M=()=>{$.remove(),k.removeEventListener("input",M),M=null},k.addEventListener("input",M)}let S=$=>{let D=$?"value":"textContent",{options:F,multiple:V}=k;return V?Array.prototype.filter.call(F,(Q=>Q.selected)).map((Q=>Q[D])):F.selectedIndex===-1?null:F[F.selectedIndex][D]},L=S(!1),U=$=>{let D=$.target.options;return Array.prototype.map.call(D,(F=>({displayValue:F.textContent,exportValue:F.value})))};return this.enableScripting&&this.hasJSActions?(k.addEventListener("updatefromsandbox",($=>{let D={value(F){M?.();let V=F.detail.value,Q=new Set(Array.isArray(V)?V:[V]);for(let Z of k.options)Z.selected=Q.has(Z.value);p.setValue(v,{value:S(!0)}),L=S(!1)},multipleSelection(F){k.multiple=!0},remove(F){let V=k.options,Q=F.detail.remove;V[Q].selected=!1,k.remove(Q),V.length>0&&Array.prototype.findIndex.call(V,(Z=>Z.selected))===-1&&(V[0].selected=!0),p.setValue(v,{value:S(!0),items:U(F)}),L=S(!1)},clear(F){for(;k.length!==0;)k.remove(0);p.setValue(v,{value:null,items:[]}),L=S(!1)},insert(F){let{index:V,displayValue:Q,exportValue:Z}=F.detail.insert,tt=k.children[V],nt=document.createElement("option");nt.textContent=Q,nt.value=Z,tt?tt.before(nt):k.append(nt),p.setValue(v,{value:S(!0),items:U(F)}),L=S(!1)},items(F){let{items:V}=F.detail;for(;k.length!==0;)k.remove(0);for(let Q of V){let{displayValue:Z,exportValue:tt}=Q,nt=document.createElement("option");nt.textContent=Z,nt.value=tt,k.append(nt)}k.options.length>0&&(k.options[0].selected=!0),p.setValue(v,{value:S(!0),items:U(F)}),L=S(!1)},indices(F){let V=new Set(F.detail.indices);for(let Q of F.target.options)Q.selected=V.has(Q.index);p.setValue(v,{value:S(!0)}),L=S(!1)},editable(F){F.target.disabled=!F.detail.editable}};this._dispatchEventFromSandbox(D,$)})),k.addEventListener("input",($=>{let D=S(!0);p.setValue(v,{value:D}),$.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:v,name:"Keystroke",value:L,changeEx:D,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(k,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],($=>$.target.value))):k.addEventListener("input",(function($){p.setValue(v,{value:S(!0)})})),this.data.combo&&this._setTextStyle(k),this._setBackgroundColor(k),this._setDefaultPropertiesFromJS(k),this.container.append(k),this.container}}class N extends C{constructor(p){let{data:v,elements:_}=p;super(p,{isRenderable:C._hasPopupData(v)}),this.elements=_}render(){this.container.classList.add("popupAnnotation");let p=new z({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),v=[];for(let _ of this.elements)_.popup=p,v.push(_.data.id),_.addHighlightArea();return this.container.setAttribute("aria-controls",v.map((_=>`${i.AnnotationPrefix}${_}`)).join(",")),this.container}}class z{#t=this.#m.bind(this);#e=this.#C.bind(this);#i=this.#S.bind(this);#n=this.#y.bind(this);#r=null;#s=null;#o=null;#c=null;#a=null;#d=null;#p=null;#u=!1;#l=null;#f=null;#g=null;#h=null;#b=!1;constructor({container:p,color:v,elements:_,titleObj:k,modificationDate:O,contentsObj:M,richText:S,parent:L,rect:U,parentRect:$,open:D}){this.#s=p,this.#h=k,this.#o=M,this.#g=S,this.#d=L,this.#r=v,this.#f=U,this.#p=$,this.#a=_,this.#c=n.PDFDateString.toDateObject(O),this.trigger=_.flatMap((F=>F.getElementsToTriggerPopup()));for(let F of this.trigger)F.addEventListener("click",this.#n),F.addEventListener("mouseenter",this.#i),F.addEventListener("mouseleave",this.#e),F.classList.add("popupTriggerArea");for(let F of _)F.container?.addEventListener("keydown",this.#t);this.#s.hidden=!0,D&&this.#y()}render(){if(this.#l)return;let{page:{view:p},viewport:{rawDims:{pageWidth:v,pageHeight:_,pageX:k,pageY:O}}}=this.#d,M=this.#l=document.createElement("div");if(M.className="popup",this.#r){let pt=M.style.outlineColor=i.Util.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?M.style.backgroundColor=`color-mix(in srgb, ${pt} 30%, white)`:M.style.backgroundColor=i.Util.makeHexColor(...this.#r.map((lt=>Math.floor(.7*(255-lt)+lt))))}let S=document.createElement("span");S.className="header";let L=document.createElement("h1");if(S.append(L),{dir:L.dir,str:L.textContent}=this.#h,M.append(S),this.#c){let pt=document.createElement("span");pt.classList.add("popupDate"),pt.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),pt.setAttribute("data-l10n-args",JSON.stringify({date:this.#c.toLocaleDateString(),time:this.#c.toLocaleTimeString()})),S.append(pt)}let U=this.#o,$=this.#g;if(!$?.str||U?.str&&U.str!==$.str){let pt=this._formatContents(U);M.append(pt)}else m.XfaLayer.render({xfaHtml:$.html,intent:"richText",div:M}),M.lastChild.classList.add("richText","popupContent");let D=!!this.#p,F=D?this.#p:this.#f;for(let pt of this.#a)if(!F||i.Util.intersect(pt.data.rect,F)!==null){F=pt.data.rect,D=!0;break}let V=i.Util.normalizeRect([F[0],p[3]-F[1]+p[1],F[2],p[3]-F[3]+p[1]]),Q=D?F[2]-F[0]+5:0,Z=V[0]+Q,tt=V[1],{style:nt}=this.#s;nt.left=100*(Z-k)/v+"%",nt.top=100*(tt-O)/_+"%",this.#s.append(M)}_formatContents({str:p,dir:v}){let _=document.createElement("p");_.classList.add("popupContent"),_.dir=v;let k=p.split(/(?:\r\n?|\n)/);for(let O=0,M=k.length;O<M;++O){let S=k[O];_.append(document.createTextNode(S)),O<M-1&&_.append(document.createElement("br"))}return _}#m(p){p.altKey||p.shiftKey||p.ctrlKey||p.metaKey||(p.key==="Enter"||p.key==="Escape"&&this.#u)&&this.#y()}#y(){this.#u=!this.#u,this.#u?(this.#S(),this.#s.addEventListener("click",this.#n),this.#s.addEventListener("keydown",this.#t)):(this.#C(),this.#s.removeEventListener("click",this.#n),this.#s.removeEventListener("keydown",this.#t))}#S(){this.#l||this.render(),this.isVisible?this.#u&&this.#s.classList.add("focused"):(this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#C(){this.#s.classList.remove("focused"),!this.#u&&this.isVisible&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#b=this.isVisible,this.#b&&(this.#s.hidden=!0)}maybeShow(){this.#b&&(this.#b=!1,this.#s.hidden=!1)}get isVisible(){return this.#s.hidden===!1}}class H extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0}),this.textContent=p.data.textContent,this.textPosition=p.data.textPosition,this.annotationEditorType=i.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let p=document.createElement("div");p.classList.add("annotationTextContent"),p.setAttribute("role","comment");for(let v of this.textContent){let _=document.createElement("span");_.textContent=v,p.append(_)}this.container.append(p)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class X extends C{#t=null;constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let p=this.data,{width:v,height:_}=f(p.rect),k=this.svgFactory.create(v,_,!0),O=this.#t=this.svgFactory.createElement("svg:line");return O.setAttribute("x1",p.rect[2]-p.lineCoordinates[0]),O.setAttribute("y1",p.rect[3]-p.lineCoordinates[1]),O.setAttribute("x2",p.rect[2]-p.lineCoordinates[2]),O.setAttribute("y2",p.rect[3]-p.lineCoordinates[3]),O.setAttribute("stroke-width",p.borderStyle.width||1),O.setAttribute("stroke","transparent"),O.setAttribute("fill","transparent"),k.append(O),this.container.append(k),!p.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class it extends C{#t=null;constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let p=this.data,{width:v,height:_}=f(p.rect),k=this.svgFactory.create(v,_,!0),O=p.borderStyle.width,M=this.#t=this.svgFactory.createElement("svg:rect");return M.setAttribute("x",O/2),M.setAttribute("y",O/2),M.setAttribute("width",v-O),M.setAttribute("height",_-O),M.setAttribute("stroke-width",O||1),M.setAttribute("stroke","transparent"),M.setAttribute("fill","transparent"),k.append(M),this.container.append(k),!p.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class at extends C{#t=null;constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let p=this.data,{width:v,height:_}=f(p.rect),k=this.svgFactory.create(v,_,!0),O=p.borderStyle.width,M=this.#t=this.svgFactory.createElement("svg:ellipse");return M.setAttribute("cx",v/2),M.setAttribute("cy",_/2),M.setAttribute("rx",v/2-O/2),M.setAttribute("ry",_/2-O/2),M.setAttribute("stroke-width",O||1),M.setAttribute("stroke","transparent"),M.setAttribute("fill","transparent"),k.append(M),this.container.append(k),!p.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class K extends C{#t=null;constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let p=this.data,{width:v,height:_}=f(p.rect),k=this.svgFactory.create(v,_,!0),O=[];for(let S of p.vertices){let L=S.x-p.rect[0],U=p.rect[3]-S.y;O.push(L+","+U)}O=O.join(" ");let M=this.#t=this.svgFactory.createElement(this.svgElementName);return M.setAttribute("points",O),M.setAttribute("stroke-width",p.borderStyle.width||1),M.setAttribute("stroke","transparent"),M.setAttribute("fill","transparent"),k.append(M),this.container.append(k),!p.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class j extends K{constructor(p){super(p),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class G extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Y extends C{#t=[];constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=i.AnnotationEditorType.INK}render(){this.container.classList.add(this.containerClassName);let p=this.data,{width:v,height:_}=f(p.rect),k=this.svgFactory.create(v,_,!0);for(let O of p.inkLists){let M=[];for(let L of O){let U=L.x-p.rect[0],$=p.rect[3]-L.y;M.push(`${U},${$}`)}M=M.join(" ");let S=this.svgFactory.createElement(this.svgElementName);this.#t.push(S),S.setAttribute("points",M),S.setAttribute("stroke-width",p.borderStyle.width||1),S.setAttribute("stroke","transparent"),S.setAttribute("fill","transparent"),!p.popupRef&&this.hasPopupData&&this._createPopup(),k.append(S)}return this.container.append(k),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class et extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class rt extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ct extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class st extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class W extends C{constructor(p){super(p,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class x extends C{#t=null;constructor(p){super(p,{isRenderable:!0});let{filename:v,content:_}=this.data.file;this.filename=(0,n.getFilenameFromUrl)(v,!0),this.content=_,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,filename:v,content:_})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:p,data:v}=this,_;v.hasAppearance||v.fillAlpha===0?_=document.createElement("div"):(_=document.createElement("img"),_.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(v.name)?"paperclip":"pushpin"}.svg`,v.fillAlpha&&v.fillAlpha<1&&(_.style=`filter: opacity(${Math.round(100*v.fillAlpha)}%);`)),_.addEventListener("dblclick",this.#e.bind(this)),this.#t=_;let{isMac:k}=i.FeatureTest.platform;return p.addEventListener("keydown",(O=>{O.key==="Enter"&&(k?O.metaKey:O.ctrlKey)&&this.#e()})),!v.popupRef&&this.hasPopupData?this._createPopup():_.classList.add("popupTriggerArea"),p.append(_),p}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class T{#t=null;#e=null;#i=new Map;constructor({div:p,accessibilityManager:v,annotationCanvasMap:_,page:k,viewport:O}){this.div=p,this.#t=v,this.#e=_,this.page=k,this.viewport=O,this.zIndex=0}#n(p,v){let _=p.firstChild||p;_.id=`${i.AnnotationPrefix}${v}`,this.div.append(p),this.#t?.moveElementInDOM(this.div,p,_,!1)}async render(p){let{annotations:v}=p,_=this.div;(0,n.setLayerDimensions)(_,this.viewport);let k=new Map,O={data:null,layer:_,linkService:p.linkService,downloadManager:p.downloadManager,imageResourcesPath:p.imageResourcesPath||"",renderForms:p.renderForms!==!1,svgFactory:new n.DOMSVGFactory,annotationStorage:p.annotationStorage||new o.AnnotationStorage,enableScripting:p.enableScripting===!0,hasJSActions:p.hasJSActions,fieldObjects:p.fieldObjects,parent:this,elements:null};for(let M of v){if(M.noHTML)continue;let S=M.annotationType===i.AnnotationType.POPUP;if(S){let $=k.get(M.id);if(!$)continue;O.elements=$}else{let{width:$,height:D}=f(M.rect);if($<=0||D<=0)continue}O.data=M;let L=A.create(O);if(!L.isRenderable)continue;if(!S&&M.popupRef){let $=k.get(M.popupRef);$?$.push(L):k.set(M.popupRef,[L])}L.annotationEditorType>0&&this.#i.set(L.data.id,L);let U=L.render();M.hidden&&(U.style.visibility="hidden"),this.#n(U,M.id)}this.#r()}update({viewport:p}){let v=this.div;this.viewport=p,(0,n.setLayerDimensions)(v,{rotation:p.rotation}),this.#r(),v.hidden=!1}#r(){if(!this.#e)return;let p=this.div;for(let[v,_]of this.#e){let k=p.querySelector(`[data-annotation-id="${v}"]`);if(!k)continue;let{firstChild:O}=k;O?O.nodeName==="CANVAS"?O.replaceWith(_):O.before(_):k.append(_)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#i.values())}getEditableAnnotation(p){return this.#i.get(p)}}},792:(s,t,e)=>{e.d(t,{AnnotationStorage:()=>h,PrintAnnotationStorage:()=>g,SerializableEmpty:()=>l});var i=e(292),n=e(310),o=e(651);let l=Object.freeze({map:null,hash:"",transfer:void 0});class h{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(d,a){let f=this.#e.get(d);return f===void 0?a:Object.assign(a,f)}getRawValue(d){return this.#e.get(d)}remove(d){if(this.#e.delete(d),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let a of this.#e.values())if(a instanceof n.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(d,a){let f=this.#e.get(d),A=!1;if(f!==void 0)for(let[C,u]of Object.entries(a))f[C]!==u&&(A=!0,f[C]=u);else A=!0,this.#e.set(d,a);A&&this.#i(),a instanceof n.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(a.constructor._type)}has(d){return this.#e.has(d)}getAll(){return this.#e.size>0?(0,i.objectFromMap)(this.#e):null}setAll(d){for(let[a,f]of Object.entries(d))this.setValue(a,f)}get size(){return this.#e.size}#i(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new g(this)}get serializable(){if(this.#e.size===0)return l;let d=new Map,a=new o.MurmurHash3_64,f=[],A=Object.create(null),C=!1;for(let[u,y]of this.#e){let r=y instanceof n.AnnotationEditor?y.serialize(!1,A):y;r&&(d.set(u,r),a.update(`${u}:${JSON.stringify(r)}`),C||=!!r.bitmap)}if(C)for(let u of d.values())u.bitmap&&f.push(u.bitmap);return d.size>0?{map:d,hash:a.hexdigest(),transfer:f}:l}get editorStats(){let d=null,a=new Map;for(let f of this.#e.values()){if(!(f instanceof n.AnnotationEditor))continue;let A=f.telemetryFinalData;if(!A)continue;let{type:C}=A;a.has(C)||a.set(C,Object.getPrototypeOf(f).constructor),d||=Object.create(null);let u=d[C]||=new Map;for(let[y,r]of Object.entries(A)){if(y==="type")continue;let c=u.get(y);c||(c=new Map,u.set(y,c));let b=c.get(r)??0;c.set(r,b+1)}}for(let[f,A]of a)d[f]=A.computeTelemetryFinalData(d[f]);return d}}class g extends h{#t;constructor(d){super();let{map:a,hash:f,transfer:A}=d.serializable,C=structuredClone(a,A?{transfer:A}:null);this.#t={map:C,hash:f,transfer:A}}get print(){(0,i.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}},831:(s,t,e)=>{e.a(s,(async(i,n)=>{try{let at=function(M){if(typeof M=="string"||M instanceof URL?M={url:M}:(M instanceof ArrayBuffer||ArrayBuffer.isView(M))&&(M={data:M}),typeof M!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!M.url&&!M.data&&!M.range)throw new Error("Invalid parameter object: need either .data, .range or .url");let S=new Y,{docId:L}=S,U=M.url?j(M.url):null,$=M.data?G(M.data):null,D=M.httpHeaders||null,F=M.withCredentials===!0,V=M.password??null,Q=M.range instanceof et?M.range:null,Z=Number.isInteger(M.rangeChunkSize)&&M.rangeChunkSize>0?M.rangeChunkSize:E,tt=M.worker instanceof x?M.worker:null,nt=M.verbosity,pt=typeof M.docBaseUrl!="string"||(0,h.isDataScheme)(M.docBaseUrl)?null:M.docBaseUrl,dt=typeof M.cMapUrl=="string"?M.cMapUrl:null,lt=M.cMapPacked!==!1,wt=M.CMapReaderFactory||H,Tt=typeof M.standardFontDataUrl=="string"?M.standardFontDataUrl:null,xt=M.StandardFontDataFactory||it,It=M.stopAtErrors!==!0,Lt=Number.isInteger(M.maxImageSize)&&M.maxImageSize>-1?M.maxImageSize:-1,Ut=M.isEvalSupported!==!1,jt=typeof M.isOffscreenCanvasSupported=="boolean"?M.isOffscreenCanvasSupported:!o.isNodeJS,he=Number.isInteger(M.canvasMaxAreaInBytes)?M.canvasMaxAreaInBytes:-1,Se=typeof M.disableFontFace=="boolean"?M.disableFontFace:o.isNodeJS,Ne=M.fontExtraProperties===!0,Te=M.enableXfa===!0,Ie=M.ownerDocument||globalThis.document,pi=M.disableRange===!0,fi=M.disableStream===!0,le=M.disableAutoFetch===!0,oe=M.pdfBug===!0,gi=Q?Q.length:M.length??NaN,ws=typeof M.useSystemFonts=="boolean"?M.useSystemFonts:!o.isNodeJS&&!Se,Me=typeof M.useWorkerFetch=="boolean"?M.useWorkerFetch:wt===h.DOMCMapReaderFactory&&xt===h.DOMStandardFontDataFactory&&dt&&Tt&&(0,h.isValidFetchUrl)(dt,document.baseURI)&&(0,h.isValidFetchUrl)(Tt,document.baseURI),ne=M.canvasFactory||new z({ownerDocument:Ie}),ar=M.filterFactory||new X({docId:L,ownerDocument:Ie});(0,o.setVerbosityLevel)(nt);let xs={canvasFactory:ne,filterFactory:ar};if(Me||(xs.cMapReaderFactory=new wt({baseUrl:dt,isCompressed:lt}),xs.standardFontDataFactory=new xt({baseUrl:Tt})),!tt){let $e={verbosity:nt,port:f.GlobalWorkerOptions.workerPort};tt=$e.port?x.fromPort($e):new x($e),S._worker=tt}let Be={docId:L,apiVersion:"4.1.392",data:$,password:V,disableAutoFetch:le,rangeChunkSize:Z,length:gi,docBaseUrl:pt,enableXfa:Te,evaluatorOptions:{maxImageSize:Lt,disableFontFace:Se,ignoreErrors:It,isEvalSupported:Ut,isOffscreenCanvasSupported:jt,canvasMaxAreaInBytes:he,fontExtraProperties:Ne,useSystemFonts:ws,cMapUrl:Me?dt:null,standardFontDataUrl:Me?Tt:null}},zi={ignoreErrors:It,isEvalSupported:Ut,disableFontFace:Se,fontExtraProperties:Ne,enableXfa:Te,ownerDocument:Ie,disableAutoFetch:le,pdfBug:oe,styleElement:null};return tt.promise.then((function(){if(S.destroyed)throw new Error("Loading aborted");let $e=K(tt,Be),lr=new Promise((function(As){let mi;Q?mi=new y.PDFDataTransportStream(Q,{disableRange:pi,disableStream:fi}):$||(mi=(pe=>o.isNodeJS?(function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype})()&&(0,h.isValidFetchUrl)(pe.url)?new r.PDFFetchStream(pe):new b.PDFNodeStream(pe):(0,h.isValidFetchUrl)(pe.url)?new r.PDFFetchStream(pe):new c.PDFNetworkStream(pe))({url:U,length:gi,httpHeaders:D,withCredentials:F,rangeChunkSize:Z,disableRange:pi,disableStream:fi})),As(mi)}));return Promise.all([$e,lr]).then((function([As,mi]){if(S.destroyed)throw new Error("Loading aborted");let pe=new A.MessageHandler(L,As,tt.port),cr=new T(pe,S,mi,zi,xs);S._transport=cr,pe.send("Ready",null)}))})).catch(S._capability.reject),S},j=function(M){if(M instanceof URL)return M.href;try{return new URL(M,window.location).href}catch{if(o.isNodeJS&&typeof M=="string")return M}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")},G=function(M){if(o.isNodeJS&&typeof Buffer<"u"&&M instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(M instanceof Uint8Array&&M.byteLength===M.buffer.byteLength)return M;if(typeof M=="string")return(0,o.stringToBytes)(M);if(M instanceof ArrayBuffer||ArrayBuffer.isView(M)||typeof M=="object"&&!isNaN(M?.length))return new Uint8Array(M);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")};e.d(t,{PDFDataRangeTransport:()=>et,PDFWorker:()=>x,build:()=>O,getDocument:()=>at,version:()=>k});var o=e(292),l=e(792),h=e(419),g=e(10),m=e(573),d=e(923),a=e(814),f=e(164),A=e(178),C=e(62),u=e(626),y=e(585),r=e(94),c=e(457),b=e(786),w=e(50),P=i([m,b]);[m,b]=P.then?(await P)():P;let E=65536,I=100,N=5e3,z=o.isNodeJS?m.NodeCanvasFactory:h.DOMCanvasFactory,H=o.isNodeJS?m.NodeCMapReaderFactory:h.DOMCMapReaderFactory,X=o.isNodeJS?m.NodeFilterFactory:h.DOMFilterFactory,it=o.isNodeJS?m.NodeStandardFontDataFactory:h.DOMStandardFontDataFactory;async function K(M,S){if(M.destroyed)throw new Error("Worker was destroyed");let L=await M.messageHandler.sendWithPromise("GetDocRequest",S,S.data?[S.data.buffer]:null);if(M.destroyed)throw new Error("Worker was destroyed");return L}class Y{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Y.#t++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(S){throw this._worker?.port&&delete this._worker._pendingDestroy,S}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class et{constructor(S,L,U=!1,$=null){this.length=S,this.initialData=L,this.progressiveDone=U,this.contentDispositionFilename=$,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(S){this._rangeListeners.push(S)}addProgressListener(S){this._progressListeners.push(S)}addProgressiveReadListener(S){this._progressiveReadListeners.push(S)}addProgressiveDoneListener(S){this._progressiveDoneListeners.push(S)}onDataRange(S,L){for(let U of this._rangeListeners)U(S,L)}onDataProgress(S,L){this._readyCapability.promise.then((()=>{for(let U of this._progressListeners)U(S,L)}))}onDataProgressiveRead(S){this._readyCapability.promise.then((()=>{for(let L of this._progressiveReadListeners)L(S)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(let S of this._progressiveDoneListeners)S()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(S,L){(0,o.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class rt{constructor(S,L){this._pdfInfo=S,this._transport=L}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,o.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(S){return this._transport.getPage(S)}getPageIndex(S){return this._transport.getPageIndex(S)}getDestinations(){return this._transport.getDestinations()}getDestination(S){return this._transport.getDestination(S)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:S="display"}={}){let{renderingIntent:L}=this._transport.getRenderingIntent(S);return this._transport.getOptionalContentConfig(L)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(S=!1){return this._transport.startCleanup(S||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ct{#t=null;#e=!1;constructor(S,L,U,$=!1){this._pageIndex=S,this._pageInfo=L,this._transport=U,this._stats=$?new h.StatTimer:null,this._pdfBug=$,this.commonObjs=U.commonObjs,this.objs=new p,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:S,rotation:L=this.rotate,offsetX:U=0,offsetY:$=0,dontFlip:D=!1}={}){return new h.PageViewport({viewBox:this.view,scale:S,rotation:L,offsetX:U,offsetY:$,dontFlip:D})}getAnnotations({intent:S="display"}={}){let{renderingIntent:L}=this._transport.getRenderingIntent(S);return this._transport.getAnnotations(this._pageIndex,L)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,o.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:S,viewport:L,intent:U="display",annotationMode:$=o.AnnotationMode.ENABLE,transform:D=null,background:F=null,optionalContentConfigPromise:V=null,annotationCanvasMap:Q=null,pageColors:Z=null,printAnnotationStorage:tt=null}){this._stats?.time("Overall");let nt=this._transport.getRenderingIntent(U,$,tt),{renderingIntent:pt,cacheKey:dt}=nt;this.#e=!1,this.#n(),V||=this._transport.getOptionalContentConfig(pt);let lt=this._intentStates.get(dt);lt||(lt=Object.create(null),this._intentStates.set(dt,lt)),lt.streamReaderCancelTimeout&&(clearTimeout(lt.streamReaderCancelTimeout),lt.streamReaderCancelTimeout=null);let wt=!!(pt&o.RenderingIntentFlag.PRINT);lt.displayReadyCapability||(lt.displayReadyCapability=Promise.withResolvers(),lt.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(nt));let Tt=Lt=>{lt.renderTasks.delete(xt),(this._maybeCleanupAfterRender||wt)&&(this.#e=!0),this.#i(!wt),Lt?(xt.capability.reject(Lt),this._abortOperatorList({intentState:lt,reason:Lt instanceof Error?Lt:new Error(Lt)})):xt.capability.resolve(),this._stats?.timeEnd("Rendering"),this._stats?.timeEnd("Overall")},xt=new _({callback:Tt,params:{canvasContext:S,viewport:L,transform:D,background:F},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:Q,operatorList:lt.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!wt,pdfBug:this._pdfBug,pageColors:Z});(lt.renderTasks||=new Set).add(xt);let It=xt.task;return Promise.all([lt.displayReadyCapability.promise,V]).then((([Lt,Ut])=>{if(this.destroyed)Tt();else{if(this._stats?.time("Rendering"),!(Ut.renderingIntent&pt))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");xt.initializeGraphics({transparency:Lt,optionalContentConfig:Ut}),xt.operatorListChanged()}})).catch(Tt),It}getOperatorList({intent:S="display",annotationMode:L=o.AnnotationMode.ENABLE,printAnnotationStorage:U=null}={}){let $=this._transport.getRenderingIntent(S,L,U,!0),D,F=this._intentStates.get($.cacheKey);return F||(F=Object.create(null),this._intentStates.set($.cacheKey,F)),F.opListReadCapability||(D=Object.create(null),D.operatorListChanged=function(){F.operatorList.lastChunk&&(F.opListReadCapability.resolve(F.operatorList),F.renderTasks.delete(D))},F.opListReadCapability=Promise.withResolvers(),(F.renderTasks||=new Set).add(D),F.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList($)),F.opListReadCapability.promise}streamTextContent({includeMarkedContent:S=!1,disableNormalization:L=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:S===!0,disableNormalization:L===!0},{highWaterMark:100,size:U=>U.items.length})}getTextContent(S={}){if(this._transport._htmlForXfa)return this.getXfa().then((U=>w.XfaText.textContent(U)));let L=this.streamTextContent(S);return new Promise((function(U,$){let D=L.getReader(),F={items:[],styles:Object.create(null)};(function V(){D.read().then((function({value:Q,done:Z}){Z?U(F):(Object.assign(F.styles,Q.styles),F.items.push(...Q.items),V())}),$)})()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let S=[];for(let L of this._intentStates.values())if(this._abortOperatorList({intentState:L,reason:new Error("Page was destroyed."),force:!0}),!L.opListReadCapability)for(let U of L.renderTasks)S.push(U.completed),U.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(S)}cleanup(S=!1){this.#e=!0;let L=this.#i(!1);return S&&L&&(this._stats&&=new h.StatTimer),L}#i(S=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(S)return this.#t=setTimeout((()=>{this.#t=null,this.#i(!1)}),N),!1;for(let{renderTasks:L,operatorList:U}of this._intentStates.values())if(L.size>0||!U.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(S,L){let U=this._intentStates.get(L);U&&(this._stats?.timeEnd("Page Request"),U.displayReadyCapability?.resolve(S))}_renderPageChunk(S,L){for(let U=0,$=S.length;U<$;U++)L.operatorList.fnArray.push(S.fnArray[U]),L.operatorList.argsArray.push(S.argsArray[U]);L.operatorList.lastChunk=S.lastChunk,L.operatorList.separateAnnots=S.separateAnnots;for(let U of L.renderTasks)U.operatorListChanged();S.lastChunk&&this.#i(!0)}_pumpOperatorList({renderingIntent:S,cacheKey:L,annotationStorageSerializable:U}){let{map:$,transfer:D}=U,F=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:S,cacheKey:L,annotationStorage:$},D).getReader(),V=this._intentStates.get(L);V.streamReader=F;let Q=()=>{F.read().then((({value:Z,done:tt})=>{tt?V.streamReader=null:this._transport.destroyed||(this._renderPageChunk(Z,V),Q())}),(Z=>{if(V.streamReader=null,!this._transport.destroyed){if(V.operatorList){V.operatorList.lastChunk=!0;for(let tt of V.renderTasks)tt.operatorListChanged();this.#i(!0)}if(V.displayReadyCapability)V.displayReadyCapability.reject(Z);else{if(!V.opListReadCapability)throw Z;V.opListReadCapability.reject(Z)}}}))};Q()}_abortOperatorList({intentState:S,reason:L,force:U=!1}){if(S.streamReader){if(S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null),!U){if(S.renderTasks.size>0)return;if(L instanceof h.RenderingCancelledException){let $=I;L.extraDelay>0&&L.extraDelay<1e3&&($+=L.extraDelay),S.streamReaderCancelTimeout=setTimeout((()=>{S.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:S,reason:L,force:!0})}),$);return}}if(S.streamReader.cancel(new o.AbortException(L.message)).catch((()=>{})),S.streamReader=null,!this._transport.destroyed){for(let[$,D]of this._intentStates)if(D===S){this._intentStates.delete($);break}this.cleanup()}}}get stats(){return this._stats}}class st{#t=new Set;#e=Promise.resolve();postMessage(S,L){let U={data:structuredClone(S,L?{transfer:L}:null)};this.#e.then((()=>{for(let $ of this.#t)$.call(this,U)}))}addEventListener(S,L){this.#t.add(L)}removeEventListener(S,L){this.#t.delete(L)}terminate(){this.#t.clear()}}let W={isWorkerDisabled:!1,fakeWorkerId:0};o.isNodeJS&&(W.isWorkerDisabled=!0,f.GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"),W.isSameOrigin=function(M,S){let L;try{if(L=new URL(M),!L.origin||L.origin==="null")return!1}catch{return!1}let U=new URL(S,L);return L.origin===U.origin},W.createCDNWrapper=function(M){let S=`await import("${M}");`;return URL.createObjectURL(new Blob([S],{type:"text/javascript"}))};class x{static#t;constructor({name:S=null,port:L=null,verbosity:U=(0,o.getVerbosityLevel)()}={}){if(this.name=S,this.destroyed=!1,this.verbosity=U,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,L){if(x.#t?.has(L))throw new Error("Cannot use more than one PDFWorker per port.");(x.#t||=new WeakMap).set(L,this),this._initializeFromPort(L)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(S){this._port=S,this._messageHandler=new A.MessageHandler("main","worker",S),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!W.isWorkerDisabled&&!x.#e){let{workerSrc:S}=x;try{W.isSameOrigin(window.location.href,S)||(S=W.createCDNWrapper(new URL(S,window.location).href));let L=new Worker(S,{type:"module"}),U=new A.MessageHandler("main","worker",L),$=()=>{L.removeEventListener("error",D),U.destroy(),L.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},D=()=>{this._webWorker||$()};L.addEventListener("error",D),U.on("test",(V=>{L.removeEventListener("error",D),this.destroyed?$():V?(this._messageHandler=U,this._port=L,this._webWorker=L,this._readyCapability.resolve(),U.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),U.destroy(),L.terminate())})),U.on("ready",(V=>{if(L.removeEventListener("error",D),this.destroyed)$();else try{F()}catch{this._setupFakeWorker()}}));let F=()=>{let V=new Uint8Array;U.send("test",V,[V.buffer])};F();return}catch{(0,o.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){W.isWorkerDisabled||((0,o.warn)("Setting up fake worker."),W.isWorkerDisabled=!0),x._setupFakeWorkerGlobal.then((S=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let L=new st;this._port=L;let U="fake"+W.fakeWorkerId++,$=new A.MessageHandler(U+"_worker",U,L);S.setup($,L);let D=new A.MessageHandler(U,U+"_worker",L);this._messageHandler=D,this._readyCapability.resolve(),D.send("configure",{verbosity:this.verbosity})})).catch((S=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${S.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),x.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(S){if(!S?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let L=this.#t?.get(S.port);if(L){if(L._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return L}return new x(S)}static get workerSrc(){if(f.GlobalWorkerOptions.workerSrc)return f.GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#e(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return(0,o.shadow)(this,"_setupFakeWorkerGlobal",(async()=>this.#e?this.#e:(await import(this.workerSrc)).WorkerMessageHandler)())}}class T{#t=new Map;#e=new Map;#i=new Map;#n=null;constructor(S,L,U,$,D){this.messageHandler=S,this.loadingTask=L,this.commonObjs=new p,this.fontLoader=new g.FontLoader({ownerDocument:$.ownerDocument,styleElement:$.styleElement}),this._params=$,this.canvasFactory=D.canvasFactory,this.filterFactory=D.filterFactory,this.cMapReaderFactory=D.cMapReaderFactory,this.standardFontDataFactory=D.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=U,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#r(S,L=null){let U=this.#t.get(S);if(U)return U;let $=this.messageHandler.sendWithPromise(S,L);return this.#t.set(S,$),$}get annotationStorage(){return(0,o.shadow)(this,"annotationStorage",new l.AnnotationStorage)}getRenderingIntent(S,L=o.AnnotationMode.ENABLE,U=null,$=!1){let D=o.RenderingIntentFlag.DISPLAY,F=l.SerializableEmpty;switch(S){case"any":D=o.RenderingIntentFlag.ANY;break;case"display":break;case"print":D=o.RenderingIntentFlag.PRINT;break;default:(0,o.warn)(`getRenderingIntent - invalid intent: ${S}`)}switch(L){case o.AnnotationMode.DISABLE:D+=o.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case o.AnnotationMode.ENABLE:break;case o.AnnotationMode.ENABLE_FORMS:D+=o.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case o.AnnotationMode.ENABLE_STORAGE:D+=o.RenderingIntentFlag.ANNOTATIONS_STORAGE,F=(D&o.RenderingIntentFlag.PRINT&&U instanceof l.PrintAnnotationStorage?U:this.annotationStorage).serializable;break;default:(0,o.warn)(`getRenderingIntent - invalid annotationMode: ${L}`)}return $&&(D+=o.RenderingIntentFlag.OPLIST),{renderingIntent:D,cacheKey:`${D}_${F.hash}`,annotationStorageSerializable:F}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#n?.reject(new Error("Worker was destroyed during onPassword callback"));let S=[];for(let U of this.#e.values())S.push(U._destroy());this.#e.clear(),this.#i.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let L=this.messageHandler.sendWithPromise("Terminate",null);return S.push(L),Promise.all(S).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),(0,a.cleanupTextLayer)(),this._networkStream?.cancelAllRequests(new o.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:S,loadingTask:L}=this;S.on("GetReader",((U,$)=>{(0,o.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=D=>{this._lastProgress={loaded:D.loaded,total:D.total}},$.onPull=()=>{this._fullReader.read().then((function({value:D,done:F}){F?$.close():((0,o.assert)(D instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),$.enqueue(new Uint8Array(D),1,[D]))})).catch((D=>{$.error(D)}))},$.onCancel=D=>{this._fullReader.cancel(D),$.ready.catch((F=>{if(!this.destroyed)throw F}))}})),S.on("ReaderHeadersReady",(U=>{let $=Promise.withResolvers(),D=this._fullReader;return D.headersReady.then((()=>{(!D.isStreamingSupported||!D.isRangeSupported)&&(this._lastProgress&&L.onProgress?.(this._lastProgress),D.onProgress=F=>{L.onProgress?.({loaded:F.loaded,total:F.total})}),$.resolve({isStreamingSupported:D.isStreamingSupported,isRangeSupported:D.isRangeSupported,contentLength:D.contentLength})}),$.reject),$.promise})),S.on("GetRangeReader",((U,$)=>{(0,o.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let D=this._networkStream.getRangeReader(U.begin,U.end);D?($.onPull=()=>{D.read().then((function({value:F,done:V}){V?$.close():((0,o.assert)(F instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),$.enqueue(new Uint8Array(F),1,[F]))})).catch((F=>{$.error(F)}))},$.onCancel=F=>{D.cancel(F),$.ready.catch((V=>{if(!this.destroyed)throw V}))}):$.close()})),S.on("GetDoc",(({pdfInfo:U})=>{this._numPages=U.numPages,this._htmlForXfa=U.htmlForXfa,delete U.htmlForXfa,L._capability.resolve(new rt(U,this))})),S.on("DocException",(function(U){let $;switch(U.name){case"PasswordException":$=new o.PasswordException(U.message,U.code);break;case"InvalidPDFException":$=new o.InvalidPDFException(U.message);break;case"MissingPDFException":$=new o.MissingPDFException(U.message);break;case"UnexpectedResponseException":$=new o.UnexpectedResponseException(U.message,U.status);break;case"UnknownErrorException":$=new o.UnknownErrorException(U.message,U.details);break;default:(0,o.unreachable)("DocException - expected a valid Error.")}L._capability.reject($)})),S.on("PasswordRequest",(U=>{if(this.#n=Promise.withResolvers(),L.onPassword){let $=D=>{D instanceof Error?this.#n.reject(D):this.#n.resolve({password:D})};try{L.onPassword($,U.code)}catch(D){this.#n.reject(D)}}else this.#n.reject(new o.PasswordException(U.message,U.code));return this.#n.promise})),S.on("DataLoaded",(U=>{L.onProgress?.({loaded:U.length,total:U.length}),this.downloadInfoCapability.resolve(U)})),S.on("StartRenderPage",(U=>{this.destroyed||this.#e.get(U.pageIndex)._startRenderPage(U.transparency,U.cacheKey)})),S.on("commonobj",(([U,$,D])=>{if(this.destroyed||this.commonObjs.has(U))return null;switch($){case"Font":let F=this._params;if("error"in D){let tt=D.error;(0,o.warn)(`Error during font loading: ${tt}`),this.commonObjs.resolve(U,tt);break}let V=F.pdfBug&&globalThis.FontInspector?.enabled?(tt,nt)=>globalThis.FontInspector.fontAdded(tt,nt):null,Q=new g.FontFaceObject(D,{isEvalSupported:F.isEvalSupported,disableFontFace:F.disableFontFace,ignoreErrors:F.ignoreErrors,inspectFont:V});this.fontLoader.bind(Q).catch((()=>S.sendWithPromise("FontFallback",{id:U}))).finally((()=>{!F.fontExtraProperties&&Q.data&&(Q.data=null),this.commonObjs.resolve(U,Q)}));break;case"CopyLocalImage":let{imageRef:Z}=D;(0,o.assert)(Z,"The imageRef must be defined.");for(let tt of this.#e.values())for(let[,nt]of tt.objs)if(nt.ref===Z)return nt.dataLen?(this.commonObjs.resolve(U,structuredClone(nt)),nt.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(U,D);break;default:throw new Error(`Got unknown common object type ${$}`)}return null})),S.on("obj",(([U,$,D,F])=>{if(this.destroyed)return;let V=this.#e.get($);if(!V.objs.has(U))if(V._intentStates.size!==0)switch(D){case"Image":V.objs.resolve(U,F),F?.dataLen>o.MAX_IMAGE_SIZE_TO_CACHE&&(V._maybeCleanupAfterRender=!0);break;case"Pattern":V.objs.resolve(U,F);break;default:throw new Error(`Got unknown object type ${D}`)}else F?.bitmap?.close()})),S.on("DocProgress",(U=>{this.destroyed||L.onProgress?.({loaded:U.loaded,total:U.total})})),S.on("FetchBuiltInCMap",(U=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(U):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),S.on("FetchStandardFontData",(U=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(U):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&(0,o.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:S,transfer:L}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:S,filename:this._fullReader?.filename??null},L).finally((()=>{this.annotationStorage.resetModified()}))}getPage(S){if(!Number.isInteger(S)||S<=0||S>this._numPages)return Promise.reject(new Error("Invalid page request."));let L=S-1,U=this.#i.get(L);if(U)return U;let $=this.messageHandler.sendWithPromise("GetPage",{pageIndex:L}).then((D=>{if(this.destroyed)throw new Error("Transport destroyed");let F=new ct(L,D,this,this._params.pdfBug);return this.#e.set(L,F),F}));return this.#i.set(L,$),$}getPageIndex(S){return typeof S!="object"||S===null||!Number.isInteger(S.num)||S.num<0||!Number.isInteger(S.gen)||S.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:S.num,gen:S.gen})}getAnnotations(S,L){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:S,intent:L})}getFieldObjects(){return this.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(S){return typeof S!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:S})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#r("GetDocJSActions")}getPageJSActions(S){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:S})}getStructTree(S){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:S})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(S){return this.#r("GetOptionalContentConfig").then((L=>new u.OptionalContentConfig(L,S)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let S="GetMetadata",L=this.#t.get(S);if(L)return L;let U=this.messageHandler.sendWithPromise(S,null).then(($=>({info:$[0],metadata:$[1]?new C.Metadata($[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#t.set(S,U),U}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(S=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let L of this.#e.values())if(!L.cleanup())throw new Error(`startCleanup: Page ${L.pageNumber} is currently rendering.`);this.commonObjs.clear(),S||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),(0,a.cleanupTextLayer)()}}get loadingParams(){let{disableAutoFetch:S,enableXfa:L}=this._params;return(0,o.shadow)(this,"loadingParams",{disableAutoFetch:S,enableXfa:L})}}let R=Symbol("INITIAL_DATA");class p{#t=Object.create(null);#e(S){return this.#t[S]||={...Promise.withResolvers(),data:R}}get(S,L=null){if(L){let $=this.#e(S);return $.promise.then((()=>L($.data))),null}let U=this.#t[S];if(!U||U.data===R)throw new Error(`Requesting object that isn't resolved yet ${S}.`);return U.data}has(S){let L=this.#t[S];return!!L&&L.data!==R}resolve(S,L=null){let U=this.#e(S);U.data=L,U.resolve()}clear(){for(let S in this.#t){let{data:L}=this.#t[S];L?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let S in this.#t){let{data:L}=this.#t[S];L!==R&&(yield[S,L])}}}class v{#t=null;constructor(S){this.#t=S,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(S=0){this.#t.cancel(null,S)}get separateAnnots(){let{separateAnnots:S}=this.#t.operatorList;if(!S)return!1;let{annotationCanvasMap:L}=this.#t;return S.form||S.canvas&&L?.size>0}}class _{static#t=new WeakSet;constructor({callback:S,params:L,objs:U,commonObjs:$,annotationCanvasMap:D,operatorList:F,pageIndex:V,canvasFactory:Q,filterFactory:Z,useRequestAnimationFrame:tt=!1,pdfBug:nt=!1,pageColors:pt=null}){this.callback=S,this.params=L,this.objs=U,this.commonObjs=$,this.annotationCanvasMap=D,this.operatorListIdx=null,this.operatorList=F,this._pageIndex=V,this.canvasFactory=Q,this.filterFactory=Z,this._pdfBug=nt,this.pageColors=pt,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=tt===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new v(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=L.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:S=!1,optionalContentConfig:L}){if(this.cancelled)return;if(this._canvas){if(_.#t.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:U,viewport:$,transform:D,background:F}=this.params;this.gfx=new d.CanvasGraphics(U,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:L},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:D,viewport:$,transparency:S,background:F}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(S=null,L=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),_.#t.delete(this._canvas),this.callback(S||new h.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,L))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_.#t.delete(this._canvas),this.callback())))}}let k="4.1.392",O="fcb76a78d";n()}catch(E){n(E)}}))},583:(s,t,e)=>{e.d(t,{BaseCMapReaderFactory:()=>l,BaseCanvasFactory:()=>o,BaseFilterFactory:()=>n,BaseSVGFactory:()=>g,BaseStandardFontDataFactory:()=>h});var i=e(292);class n{constructor(){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(d){return"none"}addHCMFilter(d,a){return"none"}addHighlightHCMFilter(d,a,f,A,C){return"none"}destroy(d=!1){}}class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(d,a){if(d<=0||a<=0)throw new Error("Invalid canvas size");let f=this._createCanvas(d,a);return{canvas:f,context:f.getContext("2d")}}reset(d,a,f){if(!d.canvas)throw new Error("Canvas is not specified");if(a<=0||f<=0)throw new Error("Invalid canvas size");d.canvas.width=a,d.canvas.height=f}destroy(d){if(!d.canvas)throw new Error("Canvas is not specified");d.canvas.width=0,d.canvas.height=0,d.canvas=null,d.context=null}_createCanvas(d,a){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}class l{constructor({baseUrl:d=null,isCompressed:a=!0}){this.constructor===l&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=d,this.isCompressed=a}async fetch({name:d}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!d)throw new Error("CMap name must be specified.");let a=this.baseUrl+d+(this.isCompressed?".bcmap":""),f=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(a,f).catch((A=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${a}`)}))}_fetchData(d,a){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class h{constructor({baseUrl:d=null}){this.constructor===h&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=d}async fetch({filename:d}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!d)throw new Error("Font filename must be specified.");let a=`${this.baseUrl}${d}`;return this._fetchData(a).catch((f=>{throw new Error(`Unable to load font data at: ${a}`)}))}_fetchData(d){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class g{constructor(){this.constructor===g&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(d,a,f=!1){if(d<=0||a<=0)throw new Error("Invalid SVG dimensions");let A=this._createSVG("svg:svg");return A.setAttribute("version","1.1"),f||(A.setAttribute("width",`${d}px`),A.setAttribute("height",`${a}px`)),A.setAttribute("preserveAspectRatio","none"),A.setAttribute("viewBox",`0 0 ${d} ${a}`),A}createElement(d){if(typeof d!="string")throw new Error("Invalid SVG element type");return this._createSVG(d)}_createSVG(d){(0,i.unreachable)("Abstract method `_createSVG` called.")}}},923:(s,t,e)=>{e.d(t,{CanvasGraphics:()=>st});var i=e(292),n=e(419);let o="Fill",l="Stroke",h="Shading";function g(W,x){if(!x)return;let T=x[2]-x[0],R=x[3]-x[1],p=new Path2D;p.rect(x[0],x[1],T,R),W.clip(p)}class m{constructor(){this.constructor===m&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class d extends m{constructor(x){super(),this._type=x[1],this._bbox=x[2],this._colorStops=x[3],this._p0=x[4],this._p1=x[5],this._r0=x[6],this._r1=x[7],this.matrix=null}_createGradient(x){let T;this._type==="axial"?T=x.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(T=x.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let R of this._colorStops)T.addColorStop(R[0],R[1]);return T}getPattern(x,T,R,p){let v;if(p===l||p===o){let _=T.current.getClippedPathBoundingBox(p,(0,n.getCurrentTransform)(x))||[0,0,0,0],k=Math.ceil(_[2]-_[0])||1,O=Math.ceil(_[3]-_[1])||1,M=T.cachedCanvases.getCanvas("pattern",k,O,!0),S=M.context;S.clearRect(0,0,S.canvas.width,S.canvas.height),S.beginPath(),S.rect(0,0,S.canvas.width,S.canvas.height),S.translate(-_[0],-_[1]),R=i.Util.transform(R,[1,0,0,1,_[0],_[1]]),S.transform(...T.baseTransform),this.matrix&&S.transform(...this.matrix),g(S,this._bbox),S.fillStyle=this._createGradient(S),S.fill(),v=x.createPattern(M.canvas,"no-repeat");let L=new DOMMatrix(R);v.setTransform(L)}else g(x,this._bbox),v=this._createGradient(x);return v}}function a(W,x,T,R,p,v,_,k){let O=x.coords,M=x.colors,S=W.data,L=4*W.width,U;O[T+1]>O[R+1]&&(U=T,T=R,R=U,U=v,v=_,_=U),O[R+1]>O[p+1]&&(U=R,R=p,p=U,U=_,_=k,k=U),O[T+1]>O[R+1]&&(U=T,T=R,R=U,U=v,v=_,_=U);let $=(O[T]+x.offsetX)*x.scaleX,D=(O[T+1]+x.offsetY)*x.scaleY,F=(O[R]+x.offsetX)*x.scaleX,V=(O[R+1]+x.offsetY)*x.scaleY,Q=(O[p]+x.offsetX)*x.scaleX,Z=(O[p+1]+x.offsetY)*x.scaleY;if(D>=Z)return;let tt=M[v],nt=M[v+1],pt=M[v+2],dt=M[_],lt=M[_+1],wt=M[_+2],Tt=M[k],xt=M[k+1],It=M[k+2],Lt=Math.round(D),Ut=Math.round(Z),jt,he,Se,Ne,Te,Ie,pi,fi;for(let le=Lt;le<=Ut;le++){if(le<V){let ne=le<D?0:(D-le)/(D-V);jt=$-($-F)*ne,he=tt-(tt-dt)*ne,Se=nt-(nt-lt)*ne,Ne=pt-(pt-wt)*ne}else{let ne;ne=le>Z?1:V===Z?0:(V-le)/(V-Z),jt=F-(F-Q)*ne,he=dt-(dt-Tt)*ne,Se=lt-(lt-xt)*ne,Ne=wt-(wt-It)*ne}let oe;oe=le<D?0:le>Z?1:(D-le)/(D-Z),Te=$-($-Q)*oe,Ie=tt-(tt-Tt)*oe,pi=nt-(nt-xt)*oe,fi=pt-(pt-It)*oe;let gi=Math.round(Math.min(jt,Te)),ws=Math.round(Math.max(jt,Te)),Me=L*le+4*gi;for(let ne=gi;ne<=ws;ne++)oe=(jt-ne)/(jt-Te),oe<0?oe=0:oe>1&&(oe=1),S[Me++]=he-(he-Ie)*oe|0,S[Me++]=Se-(Se-pi)*oe|0,S[Me++]=Ne-(Ne-fi)*oe|0,S[Me++]=255}}function f(W,x,T){let R=x.coords,p=x.colors,v,_;switch(x.type){case"lattice":let k=x.verticesPerRow,O=Math.floor(R.length/k)-1,M=k-1;for(v=0;v<O;v++){let S=v*k;for(let L=0;L<M;L++,S++)a(W,T,R[S],R[S+1],R[S+k],p[S],p[S+1],p[S+k]),a(W,T,R[S+k+1],R[S+1],R[S+k],p[S+k+1],p[S+1],p[S+k])}break;case"triangles":for(v=0,_=R.length;v<_;v+=3)a(W,T,R[v],R[v+1],R[v+2],p[v],p[v+1],p[v+2]);break;default:throw new Error("illegal figure")}}class A extends m{constructor(x){super(),this._coords=x[2],this._colors=x[3],this._figures=x[4],this._bounds=x[5],this._bbox=x[7],this._background=x[8],this.matrix=null}_createMeshCanvas(x,T,R){let p=Math.floor(this._bounds[0]),v=Math.floor(this._bounds[1]),_=Math.ceil(this._bounds[2])-p,k=Math.ceil(this._bounds[3])-v,O=Math.min(Math.ceil(Math.abs(_*x[0]*1.1)),3e3),M=Math.min(Math.ceil(Math.abs(k*x[1]*1.1)),3e3),S=_/O,L=k/M,U={coords:this._coords,colors:this._colors,offsetX:-p,offsetY:-v,scaleX:1/S,scaleY:1/L},$=O+4,D=M+4,F=R.getCanvas("mesh",$,D,!1),V=F.context,Q=V.createImageData(O,M);if(T){let Z=Q.data;for(let tt=0,nt=Z.length;tt<nt;tt+=4)Z[tt]=T[0],Z[tt+1]=T[1],Z[tt+2]=T[2],Z[tt+3]=255}for(let Z of this._figures)f(Q,Z,U);return V.putImageData(Q,2,2),{canvas:F.canvas,offsetX:p-2*S,offsetY:v-2*L,scaleX:S,scaleY:L}}getPattern(x,T,R,p){g(x,this._bbox);let v;if(p===h)v=i.Util.singularValueDecompose2dScale((0,n.getCurrentTransform)(x));else if(v=i.Util.singularValueDecompose2dScale(T.baseTransform),this.matrix){let k=i.Util.singularValueDecompose2dScale(this.matrix);v=[v[0]*k[0],v[1]*k[1]]}let _=this._createMeshCanvas(v,p===h?null:this._background,T.cachedCanvases);return p!==h&&(x.setTransform(...T.baseTransform),this.matrix&&x.transform(...this.matrix)),x.translate(_.offsetX,_.offsetY),x.scale(_.scaleX,_.scaleY),x.createPattern(_.canvas,"no-repeat")}}class C extends m{getPattern(){return"hotpink"}}let u=1,y=2;class r{static MAX_PATTERN_SIZE=3e3;constructor(x,T,R,p,v){this.operatorList=x[2],this.matrix=x[3]||[1,0,0,1,0,0],this.bbox=x[4],this.xstep=x[5],this.ystep=x[6],this.paintType=x[7],this.tilingType=x[8],this.color=T,this.ctx=R,this.canvasGraphicsFactory=p,this.baseTransform=v}createPatternCanvas(x){let T=this.operatorList,R=this.bbox,p=this.xstep,v=this.ystep,_=this.paintType,k=this.tilingType,O=this.color,M=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+k);let S=R[0],L=R[1],U=R[2],$=R[3],D=i.Util.singularValueDecompose2dScale(this.matrix),F=i.Util.singularValueDecompose2dScale(this.baseTransform),V=[D[0]*F[0],D[1]*F[1]],Q=this.getSizeAndScale(p,this.ctx.canvas.width,V[0]),Z=this.getSizeAndScale(v,this.ctx.canvas.height,V[1]),tt=x.cachedCanvases.getCanvas("pattern",Q.size,Z.size,!0),nt=tt.context,pt=M.createCanvasGraphics(nt);pt.groupLevel=x.groupLevel,this.setFillAndStrokeStyleToContext(pt,_,O);let dt=S,lt=L,wt=U,Tt=$;return S<0&&(dt=0,wt+=Math.abs(S)),L<0&&(lt=0,Tt+=Math.abs(L)),nt.translate(-Q.scale*dt,-Z.scale*lt),pt.transform(Q.scale,0,0,Z.scale,0,0),nt.save(),this.clipBbox(pt,dt,lt,wt,Tt),pt.baseTransform=(0,n.getCurrentTransform)(pt.ctx),pt.executeOperatorList(T),pt.endDrawing(),{canvas:tt.canvas,scaleX:Q.scale,scaleY:Z.scale,offsetX:dt,offsetY:lt}}getSizeAndScale(x,T,R){x=Math.abs(x);let p=Math.max(r.MAX_PATTERN_SIZE,T),v=Math.ceil(x*R);return v>=p?v=p:R=v/x,{scale:R,size:v}}clipBbox(x,T,R,p,v){let _=p-T,k=v-R;x.ctx.rect(T,R,_,k),x.current.updateRectMinMax((0,n.getCurrentTransform)(x.ctx),[T,R,p,v]),x.clip(),x.endPath()}setFillAndStrokeStyleToContext(x,T,R){let p=x.ctx,v=x.current;switch(T){case u:let _=this.ctx;p.fillStyle=_.fillStyle,p.strokeStyle=_.strokeStyle,v.fillColor=_.fillStyle,v.strokeColor=_.strokeStyle;break;case y:let k=i.Util.makeHexColor(R[0],R[1],R[2]);p.fillStyle=k,p.strokeStyle=k,v.fillColor=k,v.strokeColor=k;break;default:throw new i.FormatError(`Unsupported paint type: ${T}`)}}getPattern(x,T,R,p){let v=R;p!==h&&(v=i.Util.transform(v,T.baseTransform),this.matrix&&(v=i.Util.transform(v,this.matrix)));let _=this.createPatternCanvas(T),k=new DOMMatrix(v);k=k.translate(_.offsetX,_.offsetY),k=k.scale(1/_.scaleX,1/_.scaleY);let O=x.createPattern(_.canvas,"repeat");return O.setTransform(k),O}}function c({src:W,srcPos:x=0,dest:T,width:R,height:p,nonBlackColor:v=4294967295,inverseDecode:_=!1}){let k=i.FeatureTest.isLittleEndian?4278190080:255,[O,M]=_?[v,k]:[k,v],S=R>>3,L=7&R,U=W.length;T=new Uint32Array(T.buffer);let $=0;for(let D=0;D<p;D++){for(let V=x+S;x<V;x++){let Q=x<U?W[x]:255;T[$++]=128&Q?M:O,T[$++]=64&Q?M:O,T[$++]=32&Q?M:O,T[$++]=16&Q?M:O,T[$++]=8&Q?M:O,T[$++]=4&Q?M:O,T[$++]=2&Q?M:O,T[$++]=1&Q?M:O}if(L===0)continue;let F=x<U?W[x++]:255;for(let V=0;V<L;V++)T[$++]=F&1<<7-V?M:O}return{srcPos:x,destPos:$}}let b=4096,w=16;class P{constructor(x){this.canvasFactory=x,this.cache=Object.create(null)}getCanvas(x,T,R){let p;return this.cache[x]!==void 0?(p=this.cache[x],this.canvasFactory.reset(p,T,R)):(p=this.canvasFactory.create(T,R),this.cache[x]=p),p}delete(x){delete this.cache[x]}clear(){for(let x in this.cache){let T=this.cache[x];this.canvasFactory.destroy(T),delete this.cache[x]}}}function E(W,x,T,R,p,v,_,k,O,M){let[S,L,U,$,D,F]=(0,n.getCurrentTransform)(W);if(L===0&&U===0){let V=_*S+D,Q=Math.round(V),Z=k*$+F,tt=Math.round(Z),nt=(_+O)*S+D,pt=Math.abs(Math.round(nt)-Q)||1,dt=(k+M)*$+F,lt=Math.abs(Math.round(dt)-tt)||1;return W.setTransform(Math.sign(S),0,0,Math.sign($),Q,tt),W.drawImage(x,T,R,p,v,0,0,pt,lt),W.setTransform(S,L,U,$,D,F),[pt,lt]}if(S===0&&$===0){let V=k*U+D,Q=Math.round(V),Z=_*L+F,tt=Math.round(Z),nt=(k+M)*U+D,pt=Math.abs(Math.round(nt)-Q)||1,dt=(_+O)*L+F,lt=Math.abs(Math.round(dt)-tt)||1;return W.setTransform(0,Math.sign(L),Math.sign(U),0,Q,tt),W.drawImage(x,T,R,p,v,0,0,lt,pt),W.setTransform(S,L,U,$,D,F),[lt,pt]}return W.drawImage(x,T,R,p,v,_,k,O,M),[Math.hypot(S,L)*O,Math.hypot(U,$)*M]}class I{constructor(x,T){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=i.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=i.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,x,T])}clone(){let x=Object.create(this);return x.clipBox=this.clipBox.slice(),x}setCurrentPoint(x,T){this.x=x,this.y=T}updatePathMinMax(x,T,R){[T,R]=i.Util.applyTransform([T,R],x),this.minX=Math.min(this.minX,T),this.minY=Math.min(this.minY,R),this.maxX=Math.max(this.maxX,T),this.maxY=Math.max(this.maxY,R)}updateRectMinMax(x,T){let R=i.Util.applyTransform(T,x),p=i.Util.applyTransform(T.slice(2),x),v=i.Util.applyTransform([T[0],T[3]],x),_=i.Util.applyTransform([T[2],T[1]],x);this.minX=Math.min(this.minX,R[0],p[0],v[0],_[0]),this.minY=Math.min(this.minY,R[1],p[1],v[1],_[1]),this.maxX=Math.max(this.maxX,R[0],p[0],v[0],_[0]),this.maxY=Math.max(this.maxY,R[1],p[1],v[1],_[1])}updateScalingPathMinMax(x,T){i.Util.scaleMinMax(x,T),this.minX=Math.min(this.minX,T[0]),this.minY=Math.min(this.minY,T[1]),this.maxX=Math.max(this.maxX,T[2]),this.maxY=Math.max(this.maxY,T[3])}updateCurvePathMinMax(x,T,R,p,v,_,k,O,M,S){let L=i.Util.bezierBoundingBox(T,R,p,v,_,k,O,M,S);S||this.updateRectMinMax(x,L)}getPathBoundingBox(x=o,T=null){let R=[this.minX,this.minY,this.maxX,this.maxY];if(x===l){T||(0,i.unreachable)("Stroke bounding box must include transform.");let p=i.Util.singularValueDecompose2dScale(T),v=p[0]*this.lineWidth/2,_=p[1]*this.lineWidth/2;R[0]-=v,R[1]-=_,R[2]+=v,R[3]+=_}return R}updateClipFromPath(){let x=i.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(x||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(x){this.clipBox=x,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(x=o,T=null){return i.Util.intersect(this.clipBox,this.getPathBoundingBox(x,T))}}function N(W,x){if(typeof ImageData<"u"&&x instanceof ImageData){W.putImageData(x,0,0);return}let T=x.height,R=x.width,p=T%w,v=(T-p)/w,_=p===0?v:v+1,k=W.createImageData(R,w),O,M=0,S=x.data,L=k.data,U,$,D,F;if(x.kind===i.ImageKind.GRAYSCALE_1BPP){let V=S.byteLength,Q=new Uint32Array(L.buffer,0,L.byteLength>>2),Z=Q.length,tt=R+7>>3,nt=4294967295,pt=i.FeatureTest.isLittleEndian?4278190080:255;for(U=0;U<_;U++){for(D=U<v?w:p,O=0,$=0;$<D;$++){let dt=V-M,lt=0,wt=dt>tt?R:8*dt-7,Tt=-8&wt,xt=0,It=0;for(;lt<Tt;lt+=8)It=S[M++],Q[O++]=128&It?nt:pt,Q[O++]=64&It?nt:pt,Q[O++]=32&It?nt:pt,Q[O++]=16&It?nt:pt,Q[O++]=8&It?nt:pt,Q[O++]=4&It?nt:pt,Q[O++]=2&It?nt:pt,Q[O++]=1&It?nt:pt;for(;lt<wt;lt++)xt===0&&(It=S[M++],xt=128),Q[O++]=It&xt?nt:pt,xt>>=1}for(;O<Z;)Q[O++]=0;W.putImageData(k,0,U*w)}}else if(x.kind===i.ImageKind.RGBA_32BPP){for($=0,F=R*w*4,U=0;U<v;U++)L.set(S.subarray(M,M+F)),M+=F,W.putImageData(k,0,$),$+=w;U<_&&(F=R*p*4,L.set(S.subarray(M,M+F)),W.putImageData(k,0,$))}else{if(x.kind!==i.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${x.kind}`);for(D=w,F=R*D,U=0;U<_;U++){for(U>=v&&(D=p,F=R*D),O=0,$=F;$--;)L[O++]=S[M++],L[O++]=S[M++],L[O++]=S[M++],L[O++]=255;W.putImageData(k,0,U*w)}}}function z(W,x){if(x.bitmap){W.drawImage(x.bitmap,0,0);return}let T=x.height,R=x.width,p=T%w,v=(T-p)/w,_=p===0?v:v+1,k=W.createImageData(R,w),O=0,M=x.data,S=k.data;for(let L=0;L<_;L++){let U=L<v?w:p;({srcPos:O}=c({src:M,srcPos:O,dest:S,width:R,height:U,nonBlackColor:0})),W.putImageData(k,0,L*w)}}function H(W,x){let T=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let R of T)W[R]!==void 0&&(x[R]=W[R]);W.setLineDash!==void 0&&(x.setLineDash(W.getLineDash()),x.lineDashOffset=W.lineDashOffset)}function X(W){if(W.strokeStyle=W.fillStyle="#000000",W.fillRule="nonzero",W.globalAlpha=1,W.lineWidth=1,W.lineCap="butt",W.lineJoin="miter",W.miterLimit=10,W.globalCompositeOperation="source-over",W.font="10px sans-serif",W.setLineDash!==void 0&&(W.setLineDash([]),W.lineDashOffset=0),!i.isNodeJS){let{filter:x}=W;x!=="none"&&x!==""&&(W.filter="none")}}function it(W,x,T,R){let p=W.length;for(let v=3;v<p;v+=4){let _=W[v];if(_===0)W[v-3]=x,W[v-2]=T,W[v-1]=R;else if(_<255){let k=255-_;W[v-3]=W[v-3]*_+x*k>>8,W[v-2]=W[v-2]*_+T*k>>8,W[v-1]=W[v-1]*_+R*k>>8}}}function at(W,x,T){let R=W.length;for(let p=3;p<R;p+=4){let v=T?T[W[p]]:W[p];x[p]=x[p]*v*.00392156862745098|0}}function K(W,x,T){let R=W.length;for(let p=3;p<R;p+=4){let v=77*W[p-3]+152*W[p-2]+28*W[p-1];x[p]=T?x[p]*T[v>>8]>>8:x[p]*v>>16}}function j(W,x,T,R){let p=R[0],v=R[1],_=R[2]-p,k=R[3]-v;_!==0&&k!==0&&((function(M,S,L,U,$,D,F,V,Q,Z,tt){let nt=!!D,pt=nt?D[0]:0,dt=nt?D[1]:0,lt=nt?D[2]:0,wt=$==="Luminosity"?K:at,Tt=Math.min(U,Math.ceil(1048576/L));for(let xt=0;xt<U;xt+=Tt){let It=Math.min(Tt,U-xt),Lt=M.getImageData(V-Z,xt+(Q-tt),L,It),Ut=S.getImageData(V,xt+Q,L,It);nt&&it(Lt.data,pt,dt,lt),wt(Lt.data,Ut.data,F),S.putImageData(Ut,V,xt+Q)}})(x.context,T,_,k,x.subtype,x.backdrop,x.transferMap,p,v,x.offsetX,x.offsetY),W.save(),W.globalAlpha=1,W.globalCompositeOperation="source-over",W.setTransform(1,0,0,1,0,0),W.drawImage(T.canvas,0,0),W.restore())}function G(W,x){let T=i.Util.singularValueDecompose2dScale(W);T[0]=Math.fround(T[0]),T[1]=Math.fround(T[1]);let R=Math.fround((globalThis.devicePixelRatio||1)*n.PixelsPerInch.PDF_TO_CSS_UNITS);return x!==void 0?x:T[0]<=R||T[1]<=R}let Y=["butt","round","square"],et=["miter","round","bevel"],rt={},ct={};class st{constructor(x,T,R,p,v,{optionalContentConfig:_,markedContentStack:k=null},O,M){this.ctx=x,this.current=new I(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=T,this.objs=R,this.canvasFactory=p,this.filterFactory=v,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=k||[],this.optionalContentConfig=_,this.cachedCanvases=new P(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=O,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=M,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(x,T=null){return typeof x=="string"?x.startsWith("g_")?this.commonObjs.get(x):this.objs.get(x):T}beginDrawing({transform:x,viewport:T,transparency:R=!1,background:p=null}){let v=this.ctx.canvas.width,_=this.ctx.canvas.height,k=this.ctx.fillStyle;if(this.ctx.fillStyle=p||"#ffffff",this.ctx.fillRect(0,0,v,_),this.ctx.fillStyle=k,R){let O=this.cachedCanvases.getCanvas("transparent",v,_);this.compositeCtx=this.ctx,this.transparentCanvas=O.canvas,this.ctx=O.context,this.ctx.save(),this.ctx.transform(...(0,n.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),X(this.ctx),x&&(this.ctx.transform(...x),this.outputScaleX=x[0],this.outputScaleY=x[0]),this.ctx.transform(...T.transform),this.viewportScale=T.scale,this.baseTransform=(0,n.getCurrentTransform)(this.ctx)}executeOperatorList(x,T,R,p){let v=x.argsArray,_=x.fnArray,k=T||0,O=v.length;if(O===k)return k;let M=O-k>10&&typeof R=="function",S=M?Date.now()+15:0,L=0,U=this.commonObjs,$=this.objs,D;for(;;){if(p!==void 0&&k===p.nextBreakPoint)return p.breakIt(k,R),k;if(D=_[k],D!==i.OPS.dependency)this[D].apply(this,v[k]);else for(let F of v[k]){let V=F.startsWith("g_")?U:$;if(!V.has(F))return V.get(F,R),k}if(k++,k===O)return k;if(M&&++L>10){if(Date.now()>S)return R(),k;L=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let x of this._cachedBitmapsMap.values()){for(let T of x.values())typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement&&(T.width=T.height=0);x.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let x=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(x!=="none"){let T=this.ctx.filter;this.ctx.filter=x,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=T}}}_scaleImage(x,T){let R=x.width,p=x.height,v,_,k=Math.max(Math.hypot(T[0],T[1]),1),O=Math.max(Math.hypot(T[2],T[3]),1),M=R,S=p,L="prescale1";for(;k>2&&M>1||O>2&&S>1;){let U=M,$=S;k>2&&M>1&&(U=M>=16384?Math.floor(M/2)-1||1:Math.ceil(M/2),k/=M/U),O>2&&S>1&&($=S>=16384?Math.floor(S/2)-1||1:Math.ceil(S)/2,O/=S/$),v=this.cachedCanvases.getCanvas(L,U,$),_=v.context,_.clearRect(0,0,U,$),_.drawImage(x,0,0,M,S,0,0,U,$),x=v.canvas,M=U,S=$,L=L==="prescale1"?"prescale2":"prescale1"}return{img:x,paintWidth:M,paintHeight:S}}_createMaskCanvas(x){let T=this.ctx,{width:R,height:p}=x,v=this.current.fillColor,_=this.current.patternFill,k=(0,n.getCurrentTransform)(T),O,M,S,L;if((x.bitmap||x.data)&&x.count>1){let wt=x.bitmap||x.data.buffer;M=JSON.stringify(_?k:[k.slice(0,4),v]),O=this._cachedBitmapsMap.get(wt),O||(O=new Map,this._cachedBitmapsMap.set(wt,O));let Tt=O.get(M);if(Tt&&!_)return{canvas:Tt,offsetX:Math.round(Math.min(k[0],k[2])+k[4]),offsetY:Math.round(Math.min(k[1],k[3])+k[5])};S=Tt}S||(L=this.cachedCanvases.getCanvas("maskCanvas",R,p),z(L.context,x));let U=i.Util.transform(k,[1/R,0,0,-1/p,0,0]);U=i.Util.transform(U,[1,0,0,1,0,-p]);let[$,D,F,V]=i.Util.getAxialAlignedBoundingBox([0,0,R,p],U),Q=Math.round(F-$)||1,Z=Math.round(V-D)||1,tt=this.cachedCanvases.getCanvas("fillCanvas",Q,Z),nt=tt.context,pt=$,dt=D;nt.translate(-pt,-dt),nt.transform(...U),S||(S=this._scaleImage(L.canvas,(0,n.getCurrentTransformInverse)(nt)),S=S.img,O&&_&&O.set(M,S)),nt.imageSmoothingEnabled=G((0,n.getCurrentTransform)(nt),x.interpolate),E(nt,S,0,0,S.width,S.height,0,0,R,p),nt.globalCompositeOperation="source-in";let lt=i.Util.transform((0,n.getCurrentTransformInverse)(nt),[1,0,0,1,-pt,-dt]);return nt.fillStyle=_?v.getPattern(T,this,lt,o):v,nt.fillRect(0,0,R,p),O&&!_&&(this.cachedCanvases.delete("fillCanvas"),O.set(M,tt.canvas)),{canvas:tt.canvas,offsetX:Math.round(pt),offsetY:Math.round(dt)}}setLineWidth(x){x!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=x,this.ctx.lineWidth=x}setLineCap(x){this.ctx.lineCap=Y[x]}setLineJoin(x){this.ctx.lineJoin=et[x]}setMiterLimit(x){this.ctx.miterLimit=x}setDash(x,T){let R=this.ctx;R.setLineDash!==void 0&&(R.setLineDash(x),R.lineDashOffset=T)}setRenderingIntent(x){}setFlatness(x){}setGState(x){for(let[T,R]of x)switch(T){case"LW":this.setLineWidth(R);break;case"LC":this.setLineCap(R);break;case"LJ":this.setLineJoin(R);break;case"ML":this.setMiterLimit(R);break;case"D":this.setDash(R[0],R[1]);break;case"RI":this.setRenderingIntent(R);break;case"FL":this.setFlatness(R);break;case"Font":this.setFont(R[0],R[1]);break;case"CA":this.current.strokeAlpha=R;break;case"ca":this.current.fillAlpha=R,this.ctx.globalAlpha=R;break;case"BM":this.ctx.globalCompositeOperation=R;break;case"SMask":this.current.activeSMask=R?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(R)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let x=this.inSMaskMode;this.current.activeSMask&&!x?this.beginSMaskMode():!this.current.activeSMask&&x&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let x=this.ctx.canvas.width,T=this.ctx.canvas.height,R="smaskGroupAt"+this.groupLevel,p=this.cachedCanvases.getCanvas(R,x,T);this.suspendedCtx=this.ctx,this.ctx=p.context;let v=this.ctx;v.setTransform(...(0,n.getCurrentTransform)(this.suspendedCtx)),H(this.suspendedCtx,v),(function(k,O){if(k._removeMirroring)throw new Error("Context is already forwarding operations.");k.__originalSave=k.save,k.__originalRestore=k.restore,k.__originalRotate=k.rotate,k.__originalScale=k.scale,k.__originalTranslate=k.translate,k.__originalTransform=k.transform,k.__originalSetTransform=k.setTransform,k.__originalResetTransform=k.resetTransform,k.__originalClip=k.clip,k.__originalMoveTo=k.moveTo,k.__originalLineTo=k.lineTo,k.__originalBezierCurveTo=k.bezierCurveTo,k.__originalRect=k.rect,k.__originalClosePath=k.closePath,k.__originalBeginPath=k.beginPath,k._removeMirroring=()=>{k.save=k.__originalSave,k.restore=k.__originalRestore,k.rotate=k.__originalRotate,k.scale=k.__originalScale,k.translate=k.__originalTranslate,k.transform=k.__originalTransform,k.setTransform=k.__originalSetTransform,k.resetTransform=k.__originalResetTransform,k.clip=k.__originalClip,k.moveTo=k.__originalMoveTo,k.lineTo=k.__originalLineTo,k.bezierCurveTo=k.__originalBezierCurveTo,k.rect=k.__originalRect,k.closePath=k.__originalClosePath,k.beginPath=k.__originalBeginPath,delete k._removeMirroring},k.save=function(){O.save(),this.__originalSave()},k.restore=function(){O.restore(),this.__originalRestore()},k.translate=function(S,L){O.translate(S,L),this.__originalTranslate(S,L)},k.scale=function(S,L){O.scale(S,L),this.__originalScale(S,L)},k.transform=function(S,L,U,$,D,F){O.transform(S,L,U,$,D,F),this.__originalTransform(S,L,U,$,D,F)},k.setTransform=function(S,L,U,$,D,F){O.setTransform(S,L,U,$,D,F),this.__originalSetTransform(S,L,U,$,D,F)},k.resetTransform=function(){O.resetTransform(),this.__originalResetTransform()},k.rotate=function(S){O.rotate(S),this.__originalRotate(S)},k.clip=function(S){O.clip(S),this.__originalClip(S)},k.moveTo=function(M,S){O.moveTo(M,S),this.__originalMoveTo(M,S)},k.lineTo=function(M,S){O.lineTo(M,S),this.__originalLineTo(M,S)},k.bezierCurveTo=function(M,S,L,U,$,D){O.bezierCurveTo(M,S,L,U,$,D),this.__originalBezierCurveTo(M,S,L,U,$,D)},k.rect=function(M,S,L,U){O.rect(M,S,L,U),this.__originalRect(M,S,L,U)},k.closePath=function(){O.closePath(),this.__originalClosePath()},k.beginPath=function(){O.beginPath(),this.__originalBeginPath()}})(v,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),H(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(x){if(!this.current.activeSMask)return;x?(x[0]=Math.floor(x[0]),x[1]=Math.floor(x[1]),x[2]=Math.ceil(x[2]),x[3]=Math.ceil(x[3])):x=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let T=this.current.activeSMask;j(this.suspendedCtx,T,this.ctx,x),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}save(){this.inSMaskMode?(H(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let x=this.current;this.stateStack.push(x),this.current=x.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),H(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(x,T,R,p,v,_){this.ctx.transform(x,T,R,p,v,_),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(x,T,R){let p=this.ctx,v=this.current,_,k,O=v.x,M=v.y,S=(0,n.getCurrentTransform)(p),L=S[0]===0&&S[3]===0||S[1]===0&&S[2]===0,U=L?R.slice(0):null;for(let $=0,D=0,F=x.length;$<F;$++)switch(0|x[$]){case i.OPS.rectangle:O=T[D++],M=T[D++];let V=T[D++],Q=T[D++],Z=O+V,tt=M+Q;p.moveTo(O,M),V===0||Q===0?p.lineTo(Z,tt):(p.lineTo(Z,M),p.lineTo(Z,tt),p.lineTo(O,tt)),L||v.updateRectMinMax(S,[O,M,Z,tt]),p.closePath();break;case i.OPS.moveTo:O=T[D++],M=T[D++],p.moveTo(O,M),L||v.updatePathMinMax(S,O,M);break;case i.OPS.lineTo:O=T[D++],M=T[D++],p.lineTo(O,M),L||v.updatePathMinMax(S,O,M);break;case i.OPS.curveTo:_=O,k=M,O=T[D+4],M=T[D+5],p.bezierCurveTo(T[D],T[D+1],T[D+2],T[D+3],O,M),v.updateCurvePathMinMax(S,_,k,T[D],T[D+1],T[D+2],T[D+3],O,M,U),D+=6;break;case i.OPS.curveTo2:_=O,k=M,p.bezierCurveTo(O,M,T[D],T[D+1],T[D+2],T[D+3]),v.updateCurvePathMinMax(S,_,k,O,M,T[D],T[D+1],T[D+2],T[D+3],U),O=T[D+2],M=T[D+3],D+=4;break;case i.OPS.curveTo3:_=O,k=M,O=T[D+2],M=T[D+3],p.bezierCurveTo(T[D],T[D+1],O,M,O,M),v.updateCurvePathMinMax(S,_,k,T[D],T[D+1],O,M,O,M,U),D+=4;break;case i.OPS.closePath:p.closePath()}L&&v.updateScalingPathMinMax(S,U),v.setCurrentPoint(O,M)}closePath(){this.ctx.closePath()}stroke(x=!0){let T=this.ctx,R=this.current.strokeColor;T.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof R=="object"&&R?.getPattern?(T.save(),T.strokeStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),l),this.rescaleAndStroke(!1),T.restore()):this.rescaleAndStroke(!0)),x&&this.consumePath(this.current.getClippedPathBoundingBox()),T.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(x=!0){let T=this.ctx,R=this.current.fillColor,p=!1;this.current.patternFill&&(T.save(),T.fillStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),o),p=!0);let v=this.current.getClippedPathBoundingBox();this.contentVisible&&v!==null&&(this.pendingEOFill?(T.fill("evenodd"),this.pendingEOFill=!1):T.fill()),p&&T.restore(),x&&this.consumePath(v)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=rt}eoClip(){this.pendingClip=ct}beginText(){this.current.textMatrix=i.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let x=this.pendingTextPaths,T=this.ctx;if(x!==void 0){T.save(),T.beginPath();for(let R of x)T.setTransform(...R.transform),T.translate(R.x,R.y),R.addToPath(T,R.fontSize);T.restore(),T.clip(),T.beginPath(),delete this.pendingTextPaths}else T.beginPath()}setCharSpacing(x){this.current.charSpacing=x}setWordSpacing(x){this.current.wordSpacing=x}setHScale(x){this.current.textHScale=x/100}setLeading(x){this.current.leading=-x}setFont(x,T){let R=this.commonObjs.get(x),p=this.current;if(!R)throw new Error(`Can't find font for ${x}`);if(p.fontMatrix=R.fontMatrix||i.FONT_IDENTITY_MATRIX,p.fontMatrix[0]!==0&&p.fontMatrix[3]!==0||(0,i.warn)("Invalid font matrix for font "+x),T<0?(T=-T,p.fontDirection=-1):p.fontDirection=1,this.current.font=R,this.current.fontSize=T,R.isType3Font)return;let v=R.loadedName||"sans-serif",_=R.systemFontInfo?.css||`"${v}", ${R.fallbackName}`,k="normal";R.black?k="900":R.bold&&(k="bold");let O=R.italic?"italic":"normal",M=T;T<16?M=16:T>100&&(M=100),this.current.fontSizeScale=T/M,this.ctx.font=`${O} ${k} ${M}px ${_}`}setTextRenderingMode(x){this.current.textRenderingMode=x}setTextRise(x){this.current.textRise=x}moveText(x,T){this.current.x=this.current.lineX+=x,this.current.y=this.current.lineY+=T}setLeadingMoveText(x,T){this.setLeading(-T),this.moveText(x,T)}setTextMatrix(x,T,R,p,v,_){this.current.textMatrix=[x,T,R,p,v,_],this.current.textMatrixScale=Math.hypot(x,T),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(x,T,R,p){let v=this.ctx,_=this.current,k=_.font,O=_.textRenderingMode,M=_.fontSize/_.fontSizeScale,S=O&i.TextRenderingMode.FILL_STROKE_MASK,L=!!(O&i.TextRenderingMode.ADD_TO_PATH_FLAG),U=_.patternFill&&!k.missingFile,$;(k.disableFontFace||L||U)&&($=k.getPathGenerator(this.commonObjs,x)),k.disableFontFace||U?(v.save(),v.translate(T,R),v.beginPath(),$(v,M),p&&v.setTransform(...p),S!==i.TextRenderingMode.FILL&&S!==i.TextRenderingMode.FILL_STROKE||v.fill(),S!==i.TextRenderingMode.STROKE&&S!==i.TextRenderingMode.FILL_STROKE||v.stroke(),v.restore()):(S!==i.TextRenderingMode.FILL&&S!==i.TextRenderingMode.FILL_STROKE||v.fillText(x,T,R),S!==i.TextRenderingMode.STROKE&&S!==i.TextRenderingMode.FILL_STROKE||v.strokeText(x,T,R)),L&&(this.pendingTextPaths||=[]).push({transform:(0,n.getCurrentTransform)(v),x:T,y:R,fontSize:M,addToPath:$})}get isFontSubpixelAAEnabled(){let{context:x}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);x.scale(1.5,1),x.fillText("I",0,10);let T=x.getImageData(0,0,10,10).data,R=!1;for(let p=3;p<T.length;p+=4)if(T[p]>0&&T[p]<255){R=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",R)}showText(x){let T=this.current,R=T.font;if(R.isType3Font)return this.showType3Text(x);let p=T.fontSize;if(p===0)return;let v=this.ctx,_=T.fontSizeScale,k=T.charSpacing,O=T.wordSpacing,M=T.fontDirection,S=T.textHScale*M,L=x.length,U=R.vertical,$=U?1:-1,D=R.defaultVMetrics,F=p*T.fontMatrix[0],V=T.textRenderingMode===i.TextRenderingMode.FILL&&!R.disableFontFace&&!T.patternFill;v.save(),v.transform(...T.textMatrix),v.translate(T.x,T.y+T.textRise),M>0?v.scale(S,-1):v.scale(S,1);let Q;if(T.patternFill){v.save();let dt=T.fillColor.getPattern(v,this,(0,n.getCurrentTransformInverse)(v),o);Q=(0,n.getCurrentTransform)(v),v.restore(),v.fillStyle=dt}let Z=T.lineWidth,tt=T.textMatrixScale;if(tt===0||Z===0){let dt=T.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;dt!==i.TextRenderingMode.STROKE&&dt!==i.TextRenderingMode.FILL_STROKE||(Z=this.getSinglePixelWidth())}else Z/=tt;if(_!==1&&(v.scale(_,_),Z/=_),v.lineWidth=Z,R.isInvalidPDFjsFont){let dt=[],lt=0;for(let wt of x)dt.push(wt.unicode),lt+=wt.width;v.fillText(dt.join(""),0,0),T.x+=lt*F*S,v.restore(),this.compose();return}let nt,pt=0;for(nt=0;nt<L;++nt){let dt=x[nt];if(typeof dt=="number"){pt+=$*dt*p/1e3;continue}let lt=!1,wt=(dt.isSpace?O:0)+k,Tt=dt.fontChar,xt=dt.accent,It,Lt,Ut=dt.width;if(U){let jt=dt.vmetric||D,he=-(dt.vmetric?jt[1]:.5*Ut)*F,Se=jt[2]*F;Ut=jt?-jt[0]:Ut,It=he/_,Lt=(pt+Se)/_}else It=pt/_,Lt=0;if(R.remeasure&&Ut>0){let jt=1e3*v.measureText(Tt).width/p*_;if(Ut<jt&&this.isFontSubpixelAAEnabled){let he=Ut/jt;lt=!0,v.save(),v.scale(he,1),It/=he}else Ut!==jt&&(It+=(Ut-jt)/2e3*p/_)}if(this.contentVisible&&(dt.isInFont||R.missingFile)){if(V&&!xt)v.fillText(Tt,It,Lt);else if(this.paintChar(Tt,It,Lt,Q),xt){let jt=It+p*xt.offset.x/_,he=Lt-p*xt.offset.y/_;this.paintChar(xt.fontChar,jt,he,Q)}}pt+=U?Ut*F-wt*M:Ut*F+wt*M,lt&&v.restore()}U?T.y-=pt:T.x+=pt*S,v.restore(),this.compose()}showType3Text(x){let T=this.ctx,R=this.current,p=R.font,v=R.fontSize,_=R.fontDirection,k=p.vertical?1:-1,O=R.charSpacing,M=R.wordSpacing,S=R.textHScale*_,L=R.fontMatrix||i.FONT_IDENTITY_MATRIX,U=x.length,$,D,F,V;if(R.textRenderingMode!==i.TextRenderingMode.INVISIBLE&&v!==0){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,T.save(),T.transform(...R.textMatrix),T.translate(R.x,R.y),T.scale(S,_),$=0;$<U;++$){if(D=x[$],typeof D=="number"){V=k*D*v/1e3,this.ctx.translate(V,0),R.x+=V*S;continue}let Q=(D.isSpace?M:0)+O,Z=p.charProcOperatorList[D.operatorListId];if(!Z){(0,i.warn)(`Type3 character "${D.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=D,this.save(),T.scale(v,v),T.transform(...L),this.executeOperatorList(Z),this.restore()),F=i.Util.applyTransform([D.width,0],L)[0]*v+Q,T.translate(F,0),R.x+=F*S}T.restore(),this.processingType3=null}}setCharWidth(x,T){}setCharWidthAndBounds(x,T,R,p,v,_){this.ctx.rect(R,p,v-R,_-p),this.ctx.clip(),this.endPath()}getColorN_Pattern(x){let T;if(x[0]==="TilingPattern"){let R=x[1],p=this.baseTransform||(0,n.getCurrentTransform)(this.ctx),v={createCanvasGraphics:_=>new st(_,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};T=new r(x,R,this.ctx,v,p)}else T=this._getPattern(x[1],x[2]);return T}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(x,T,R){let p=i.Util.makeHexColor(x,T,R);this.ctx.strokeStyle=p,this.current.strokeColor=p}setFillRGBColor(x,T,R){let p=i.Util.makeHexColor(x,T,R);this.ctx.fillStyle=p,this.current.fillColor=p,this.current.patternFill=!1}_getPattern(x,T=null){let R;return this.cachedPatterns.has(x)?R=this.cachedPatterns.get(x):(R=(function(v){switch(v[0]){case"RadialAxial":return new d(v);case"Mesh":return new A(v);case"Dummy":return new C}throw new Error(`Unknown IR type: ${v[0]}`)})(this.getObject(x)),this.cachedPatterns.set(x,R)),T&&(R.matrix=T),R}shadingFill(x){if(!this.contentVisible)return;let T=this.ctx;this.save();let R=this._getPattern(x);T.fillStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),h);let p=(0,n.getCurrentTransformInverse)(T);if(p){let{width:v,height:_}=T.canvas,[k,O,M,S]=i.Util.getAxialAlignedBoundingBox([0,0,v,_],p);this.ctx.fillRect(k,O,M-k,S-O)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(x,T){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(x)&&x.length===6&&this.transform(...x),this.baseTransform=(0,n.getCurrentTransform)(this.ctx),T)){let R=T[2]-T[0],p=T[3]-T[1];this.ctx.rect(T[0],T[1],R,p),this.current.updateRectMinMax((0,n.getCurrentTransform)(this.ctx),T),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(x){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let T=this.ctx;x.isolated||(0,i.info)("TODO: Support non-isolated groups."),x.knockout&&(0,i.warn)("Knockout groups not supported.");let R=(0,n.getCurrentTransform)(T);if(x.matrix&&T.transform(...x.matrix),!x.bbox)throw new Error("Bounding box is required.");let p=i.Util.getAxialAlignedBoundingBox(x.bbox,(0,n.getCurrentTransform)(T)),v=[0,0,T.canvas.width,T.canvas.height];p=i.Util.intersect(p,v)||[0,0,0,0];let _=Math.floor(p[0]),k=Math.floor(p[1]),O=Math.max(Math.ceil(p[2])-_,1),M=Math.max(Math.ceil(p[3])-k,1),S=1,L=1;O>b&&(S=O/b,O=b),M>b&&(L=M/b,M=b),this.current.startNewPathAndClipBox([0,0,O,M]);let U="groupAt"+this.groupLevel;x.smask&&(U+="_smask_"+this.smaskCounter++%2);let $=this.cachedCanvases.getCanvas(U,O,M),D=$.context;D.scale(1/S,1/L),D.translate(-_,-k),D.transform(...R),x.smask?this.smaskStack.push({canvas:$.canvas,context:D,offsetX:_,offsetY:k,scaleX:S,scaleY:L,subtype:x.smask.subtype,backdrop:x.smask.backdrop,transferMap:x.smask.transferMap||null,startTransformInverse:null}):(T.setTransform(1,0,0,1,0,0),T.translate(_,k),T.scale(S,L),T.save()),H(T,D),this.ctx=D,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(T),this.groupLevel++}endGroup(x){if(!this.contentVisible)return;this.groupLevel--;let T=this.ctx,R=this.groupStack.pop();if(this.ctx=R,this.ctx.imageSmoothingEnabled=!1,x.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let p=(0,n.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...p);let v=i.Util.getAxialAlignedBoundingBox([0,0,T.canvas.width,T.canvas.height],p);this.ctx.drawImage(T.canvas,0,0),this.ctx.restore(),this.compose(v)}}beginAnnotation(x,T,R,p,v){if(this.#t(),X(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(T)&&T.length===4){let _=T[2]-T[0],k=T[3]-T[1];if(v&&this.annotationCanvasMap){(R=R.slice())[4]-=T[0],R[5]-=T[1],(T=T.slice())[0]=T[1]=0,T[2]=_,T[3]=k;let[O,M]=i.Util.singularValueDecompose2dScale((0,n.getCurrentTransform)(this.ctx)),{viewportScale:S}=this,L=Math.ceil(_*this.outputScaleX*S),U=Math.ceil(k*this.outputScaleY*S);this.annotationCanvas=this.canvasFactory.create(L,U);let{canvas:$,context:D}=this.annotationCanvas;this.annotationCanvasMap.set(x,$),this.annotationCanvas.savedCtx=this.ctx,this.ctx=D,this.ctx.save(),this.ctx.setTransform(O,0,0,-M,0,k*M),X(this.ctx)}else X(this.ctx),this.ctx.rect(T[0],T[1],_,k),this.ctx.clip(),this.endPath()}this.current=new I(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...R),this.transform(...p)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(x){if(!this.contentVisible)return;let T=x.count;(x=this.getObject(x.data,x)).count=T;let R=this.ctx,p=this.processingType3;if(p&&(p.compiled===void 0&&(p.compiled=(function(O){let{width:M,height:S}=O;if(M>1e3||S>1e3)return null;let L=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),U=M+1,$,D,F,V=new Uint8Array(U*(S+1)),Q=M+7&-8,Z=new Uint8Array(Q*S),tt=0;for(let lt of O.data){let wt=128;for(;wt>0;)Z[tt++]=lt&wt?0:255,wt>>=1}let nt=0;for(tt=0,Z[tt]!==0&&(V[0]=1,++nt),D=1;D<M;D++)Z[tt]!==Z[tt+1]&&(V[D]=Z[tt]?2:1,++nt),tt++;for(Z[tt]!==0&&(V[D]=2,++nt),$=1;$<S;$++){tt=$*Q,F=$*U,Z[tt-Q]!==Z[tt]&&(V[F]=Z[tt]?1:8,++nt);let lt=(Z[tt]?4:0)+(Z[tt-Q]?8:0);for(D=1;D<M;D++)lt=(lt>>2)+(Z[tt+1]?4:0)+(Z[tt-Q+1]?8:0),L[lt]&&(V[F+D]=L[lt],++nt),tt++;if(Z[tt-Q]!==Z[tt]&&(V[F+D]=Z[tt]?2:4,++nt),nt>1e3)return null}for(tt=Q*(S-1),F=$*U,Z[tt]!==0&&(V[F]=8,++nt),D=1;D<M;D++)Z[tt]!==Z[tt+1]&&(V[F+D]=Z[tt]?4:8,++nt),tt++;if(Z[tt]!==0&&(V[F+D]=4,++nt),nt>1e3)return null;let pt=new Int32Array([0,U,-1,0,-U,0,0,0,1]),dt=new Path2D;for($=0;nt&&$<=S;$++){let lt=$*U,wt=lt+M;for(;lt<wt&&!V[lt];)lt++;if(lt===wt)continue;dt.moveTo(lt%U,$);let Tt=lt,xt=V[lt];do{let It=pt[xt];do lt+=It;while(!V[lt]);let Lt=V[lt];Lt!==5&&Lt!==10?(xt=Lt,V[lt]=0):(xt=Lt&51*xt>>4,V[lt]&=xt>>2|xt<<2),dt.lineTo(lt%U,lt/U|0),V[lt]||--nt}while(Tt!==lt);--$}return Z=null,V=null,function(lt){lt.save(),lt.scale(1/M,-1/S),lt.translate(0,-S),lt.fill(dt),lt.beginPath(),lt.restore()}})(x)),p.compiled)){p.compiled(R);return}let v=this._createMaskCanvas(x),_=v.canvas;R.save(),R.setTransform(1,0,0,1,0,0),R.drawImage(_,v.offsetX,v.offsetY),R.restore(),this.compose()}paintImageMaskXObjectRepeat(x,T,R=0,p=0,v,_){if(!this.contentVisible)return;x=this.getObject(x.data,x);let k=this.ctx;k.save();let O=(0,n.getCurrentTransform)(k);k.transform(T,R,p,v,0,0);let M=this._createMaskCanvas(x);k.setTransform(1,0,0,1,M.offsetX-O[4],M.offsetY-O[5]);for(let S=0,L=_.length;S<L;S+=2){let U=i.Util.transform(O,[T,R,p,v,_[S],_[S+1]]),[$,D]=i.Util.applyTransform([0,0],U);k.drawImage(M.canvas,$,D)}k.restore(),this.compose()}paintImageMaskXObjectGroup(x){if(!this.contentVisible)return;let T=this.ctx,R=this.current.fillColor,p=this.current.patternFill;for(let v of x){let{data:_,width:k,height:O,transform:M}=v,S=this.cachedCanvases.getCanvas("maskCanvas",k,O),L=S.context;L.save(),z(L,this.getObject(_,v)),L.globalCompositeOperation="source-in",L.fillStyle=p?R.getPattern(L,this,(0,n.getCurrentTransformInverse)(T),o):R,L.fillRect(0,0,k,O),L.restore(),T.save(),T.transform(...M),T.scale(1,-1),E(T,S.canvas,0,0,k,O,0,-1,1,1),T.restore()}this.compose()}paintImageXObject(x){if(!this.contentVisible)return;let T=this.getObject(x);T?this.paintInlineImageXObject(T):(0,i.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(x,T,R,p){if(!this.contentVisible)return;let v=this.getObject(x);if(!v){(0,i.warn)("Dependent image isn't ready yet");return}let _=v.width,k=v.height,O=[];for(let M=0,S=p.length;M<S;M+=2)O.push({transform:[T,0,0,R,p[M],p[M+1]],x:0,y:0,w:_,h:k});this.paintInlineImageXObjectGroup(v,O)}applyTransferMapsToCanvas(x){return this.current.transferMaps!=="none"&&(x.filter=this.current.transferMaps,x.drawImage(x.canvas,0,0),x.filter="none"),x.canvas}applyTransferMapsToBitmap(x){if(this.current.transferMaps==="none")return x.bitmap;let{bitmap:T,width:R,height:p}=x,v=this.cachedCanvases.getCanvas("inlineImage",R,p),_=v.context;return _.filter=this.current.transferMaps,_.drawImage(T,0,0),_.filter="none",v.canvas}paintInlineImageXObject(x){if(!this.contentVisible)return;let T=x.width,R=x.height,p=this.ctx;if(this.save(),!i.isNodeJS){let{filter:k}=p;k!=="none"&&k!==""&&(p.filter="none")}p.scale(1/T,-1/R);let v;if(x.bitmap)v=this.applyTransferMapsToBitmap(x);else if(typeof HTMLElement=="function"&&x instanceof HTMLElement||!x.data)v=x;else{let k=this.cachedCanvases.getCanvas("inlineImage",T,R).context;N(k,x),v=this.applyTransferMapsToCanvas(k)}let _=this._scaleImage(v,(0,n.getCurrentTransformInverse)(p));p.imageSmoothingEnabled=G((0,n.getCurrentTransform)(p),x.interpolate),E(p,_.img,0,0,_.paintWidth,_.paintHeight,0,-R,T,R),this.compose(),this.restore()}paintInlineImageXObjectGroup(x,T){if(!this.contentVisible)return;let R=this.ctx,p;if(x.bitmap)p=x.bitmap;else{let v=x.width,_=x.height,k=this.cachedCanvases.getCanvas("inlineImage",v,_).context;N(k,x),p=this.applyTransferMapsToCanvas(k)}for(let v of T)R.save(),R.transform(...v.transform),R.scale(1,-1),E(R,p,v.x,v.y,v.w,v.h,0,-1,1,1),R.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(x){}markPointProps(x,T){}beginMarkedContent(x){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(x,T){x==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(T)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(x){let T=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(x);let R=this.ctx;this.pendingClip&&(T||(this.pendingClip===ct?R.clip("evenodd"):R.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),R.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let x=(0,n.getCurrentTransform)(this.ctx);if(x[1]===0&&x[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(x[0]),Math.abs(x[3]));else{let T=Math.abs(x[0]*x[3]-x[2]*x[1]),R=Math.hypot(x[0],x[2]),p=Math.hypot(x[1],x[3]);this._cachedGetSinglePixelWidth=Math.max(R,p)/T}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:x}=this.current,{a:T,b:R,c:p,d:v}=this.ctx.getTransform(),_,k;if(R===0&&p===0){let O=Math.abs(T),M=Math.abs(v);if(O===M)if(x===0)_=k=1/O;else{let S=O*x;_=k=S<1?1/S:1}else if(x===0)_=1/O,k=1/M;else{let S=O*x,L=M*x;_=S<1?1/S:1,k=L<1?1/L:1}}else{let O=Math.abs(T*v-R*p),M=Math.hypot(T,R),S=Math.hypot(p,v);if(x===0)_=S/O,k=M/O;else{let L=x*O;_=S>L?S/L:1,k=M>L?M/L:1}}this._cachedScaleForStroking[0]=_,this._cachedScaleForStroking[1]=k}return this._cachedScaleForStroking}rescaleAndStroke(x){let{ctx:T}=this,{lineWidth:R}=this.current,[p,v]=this.getScaleForStroking();if(T.lineWidth=R||1,p===1&&v===1){T.stroke();return}let _=T.getLineDash();if(x&&T.save(),T.scale(p,v),_.length>0){let k=Math.max(p,v);T.setLineDash(_.map((O=>O/k))),T.lineDashOffset/=k}T.stroke(),x&&T.restore()}isContentVisible(){for(let x=this.markedContentStack.length-1;x>=0;x--)if(!this.markedContentStack[x].visible)return!1;return!0}}for(let W in i.OPS)st.prototype[W]!==void 0&&(st.prototype[i.OPS[W]]=st.prototype[W])},419:(s,t,e)=>{e.d(t,{DOMCMapReaderFactory:()=>d,DOMCanvasFactory:()=>g,DOMFilterFactory:()=>h,DOMSVGFactory:()=>f,DOMStandardFontDataFactory:()=>a,PDFDateString:()=>I,PageViewport:()=>A,PixelsPerInch:()=>l,RenderingCancelledException:()=>C,StatTimer:()=>b,fetchData:()=>m,getColorValues:()=>H,getCurrentTransform:()=>X,getCurrentTransformInverse:()=>it,getFilenameFromUrl:()=>r,getPdfFilenameFromUrl:()=>c,getRGB:()=>z,getXfaPageViewport:()=>N,isDataScheme:()=>u,isPdfFile:()=>y,isValidFetchUrl:()=>w,noContextMenu:()=>P,setLayerDimensions:()=>at});var i=e(583),n=e(292);let o="http://www.w3.org/2000/svg";class l{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class h extends i.BaseFilterFactory{#t;#e;#i;#n;#r;#s=0;constructor({docId:j,ownerDocument:G=globalThis.document}={}){super(),this.#i=j,this.#n=G}get#o(){return this.#t||=new Map}get#c(){return this.#r||=new Map}get#a(){if(!this.#e){let j=this.#n.createElement("div"),{style:G}=j;G.visibility="hidden",G.contain="strict",G.width=G.height=0,G.position="absolute",G.top=G.left=0,G.zIndex=-1;let Y=this.#n.createElementNS(o,"svg");Y.setAttribute("width",0),Y.setAttribute("height",0),this.#e=this.#n.createElementNS(o,"defs"),j.append(Y),Y.append(this.#e),this.#n.body.append(j)}return this.#e}addFilter(j){if(!j)return"none";let G,Y,et,rt,ct=this.#o.get(j);if(ct)return ct;if(j.length===1){let T=j[0],R=new Array(256);for(let p=0;p<256;p++)R[p]=T[p]/255;rt=G=Y=et=R.join(",")}else{let[T,R,p]=j,v=new Array(256),_=new Array(256),k=new Array(256);for(let O=0;O<256;O++)v[O]=T[O]/255,_[O]=R[O]/255,k[O]=p[O]/255;G=v.join(","),Y=_.join(","),et=k.join(","),rt=`${G}${Y}${et}`}if(ct=this.#o.get(rt),ct)return this.#o.set(j,ct),ct;let st=`g_${this.#i}_transfer_map_${this.#s++}`,W=`url(#${st})`;this.#o.set(j,W),this.#o.set(rt,W);let x=this.#p(st);return this.#l(G,Y,et,x),W}addHCMFilter(j,G){let Y=`${j}-${G}`,et="base",rt=this.#c.get(et);if(rt?.key===Y||(rt?(rt.filter?.remove(),rt.key=Y,rt.url="none",rt.filter=null):(rt={key:Y,url:"none",filter:null},this.#c.set(et,rt)),!j||!G))return rt.url;let ct=this.#f(j);j=n.Util.makeHexColor(...ct);let st=this.#f(G);if(G=n.Util.makeHexColor(...st),this.#a.style.color="",j==="#000000"&&G==="#ffffff"||j===G)return rt.url;let W=new Array(256);for(let v=0;v<=255;v++){let _=v/255;W[v]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}let x=W.join(","),T=`g_${this.#i}_hcm_filter`,R=rt.filter=this.#p(T);this.#l(x,x,x,R),this.#d(R);let p=(v,_)=>{let k=ct[v]/255,O=st[v]/255,M=new Array(_+1);for(let S=0;S<=_;S++)M[S]=k+S/_*(O-k);return M.join(",")};return this.#l(p(0,5),p(1,5),p(2,5),R),rt.url=`url(#${T})`,rt.url}addHighlightHCMFilter(j,G,Y,et,rt){let ct=`${G}-${Y}-${et}-${rt}`,st=this.#c.get(j);if(st?.key===ct||(st?(st.filter?.remove(),st.key=ct,st.url="none",st.filter=null):(st={key:ct,url:"none",filter:null},this.#c.set(j,st)),!G||!Y))return st.url;let[W,x]=[G,Y].map(this.#f.bind(this)),T=Math.round(.2126*W[0]+.7152*W[1]+.0722*W[2]),R=Math.round(.2126*x[0]+.7152*x[1]+.0722*x[2]),[p,v]=[et,rt].map(this.#f.bind(this));R<T&&([T,R,p,v]=[R,T,v,p]),this.#a.style.color="";let _=(M,S,L)=>{let U=new Array(256),$=(R-T)/L,D=M/255,F=(S-M)/(255*L),V=0;for(let Q=0;Q<=L;Q++){let Z=Math.round(T+Q*$),tt=D+Q*F;for(let nt=V;nt<=Z;nt++)U[nt]=tt;V=Z+1}for(let Q=V;Q<256;Q++)U[Q]=U[V-1];return U.join(",")},k=`g_${this.#i}_hcm_${j}_filter`,O=st.filter=this.#p(k);return this.#d(O),this.#l(_(p[0],v[0],5),_(p[1],v[1],5),_(p[2],v[2],5),O),st.url=`url(#${k})`,st.url}destroy(j=!1){(!j||this.#c.size===0)&&(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#s=0)}#d(j){let G=this.#n.createElementNS(o,"feColorMatrix");G.setAttribute("type","matrix"),G.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),j.append(G)}#p(j){let G=this.#n.createElementNS(o,"filter");return G.setAttribute("color-interpolation-filters","sRGB"),G.setAttribute("id",j),this.#a.append(G),G}#u(j,G,Y){let et=this.#n.createElementNS(o,G);et.setAttribute("type","discrete"),et.setAttribute("tableValues",Y),j.append(et)}#l(j,G,Y,et){let rt=this.#n.createElementNS(o,"feComponentTransfer");et.append(rt),this.#u(rt,"feFuncR",j),this.#u(rt,"feFuncG",G),this.#u(rt,"feFuncB",Y)}#f(j){return this.#a.style.color=j,z(getComputedStyle(this.#a).getPropertyValue("color"))}}class g extends i.BaseCanvasFactory{constructor({ownerDocument:j=globalThis.document}={}){super(),this._document=j}_createCanvas(j,G){let Y=this._document.createElement("canvas");return Y.width=j,Y.height=G,Y}}async function m(K,j="text"){if(w(K,document.baseURI)){let G=await fetch(K);if(!G.ok)throw new Error(G.statusText);switch(j){case"arraybuffer":return G.arrayBuffer();case"blob":return G.blob();case"json":return G.json()}return G.text()}return new Promise(((G,Y)=>{let et=new XMLHttpRequest;et.open("GET",K,!0),et.responseType=j,et.onreadystatechange=()=>{if(et.readyState===XMLHttpRequest.DONE)if(et.status!==200&&et.status!==0)Y(new Error(et.statusText));else{switch(j){case"arraybuffer":case"blob":case"json":G(et.response);return}G(et.responseText)}},et.send(null)}))}class d extends i.BaseCMapReaderFactory{_fetchData(j,G){return m(j,this.isCompressed?"arraybuffer":"text").then((Y=>({cMapData:Y instanceof ArrayBuffer?new Uint8Array(Y):(0,n.stringToBytes)(Y),compressionType:G})))}}class a extends i.BaseStandardFontDataFactory{_fetchData(j){return m(j,"arraybuffer").then((G=>new Uint8Array(G)))}}class f extends i.BaseSVGFactory{_createSVG(j){return document.createElementNS(o,j)}}class A{constructor({viewBox:j,scale:G,rotation:Y,offsetX:et=0,offsetY:rt=0,dontFlip:ct=!1}){this.viewBox=j,this.scale=G,this.rotation=Y,this.offsetX=et,this.offsetY=rt;let st=(j[2]+j[0])/2,W=(j[3]+j[1])/2,x,T,R,p,v,_,k,O;switch((Y%=360)<0&&(Y+=360),Y){case 180:x=-1,T=0,R=0,p=1;break;case 90:x=0,T=1,R=1,p=0;break;case 270:x=0,T=-1,R=-1,p=0;break;case 0:x=1,T=0,R=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}ct&&(R=-R,p=-p),x===0?(v=Math.abs(W-j[1])*G+et,_=Math.abs(st-j[0])*G+rt,k=(j[3]-j[1])*G,O=(j[2]-j[0])*G):(v=Math.abs(st-j[0])*G+et,_=Math.abs(W-j[1])*G+rt,k=(j[2]-j[0])*G,O=(j[3]-j[1])*G),this.transform=[x*G,T*G,R*G,p*G,v-x*G*st-R*G*W,_-T*G*st-p*G*W],this.width=k,this.height=O}get rawDims(){let{viewBox:j}=this;return(0,n.shadow)(this,"rawDims",{pageWidth:j[2]-j[0],pageHeight:j[3]-j[1],pageX:j[0],pageY:j[1]})}clone({scale:j=this.scale,rotation:G=this.rotation,offsetX:Y=this.offsetX,offsetY:et=this.offsetY,dontFlip:rt=!1}={}){return new A({viewBox:this.viewBox.slice(),scale:j,rotation:G,offsetX:Y,offsetY:et,dontFlip:rt})}convertToViewportPoint(j,G){return n.Util.applyTransform([j,G],this.transform)}convertToViewportRectangle(j){let G=n.Util.applyTransform([j[0],j[1]],this.transform),Y=n.Util.applyTransform([j[2],j[3]],this.transform);return[G[0],G[1],Y[0],Y[1]]}convertToPdfPoint(j,G){return n.Util.applyInverseTransform([j,G],this.transform)}}class C extends n.BaseException{constructor(j,G=0){super(j,"RenderingCancelledException"),this.extraDelay=G}}function u(K){let j=K.length,G=0;for(;G<j&&K[G].trim()==="";)G++;return K.substring(G,G+5).toLowerCase()==="data:"}function y(K){return typeof K=="string"&&/\.pdf$/i.test(K)}function r(K,j=!1){return j||([K]=K.split(/[#?]/,1)),K.substring(K.lastIndexOf("/")+1)}function c(K,j="document.pdf"){if(typeof K!="string")return j;if(u(K))return(0,n.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),j;let G=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,Y=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(K),et=G.exec(Y[1])||G.exec(Y[2])||G.exec(Y[3]);if(et&&(et=et[0],et.includes("%")))try{et=G.exec(decodeURIComponent(et))[0]}catch{}return et||j}class b{started=Object.create(null);times=[];time(j){j in this.started&&(0,n.warn)(`Timer is already running for ${j}`),this.started[j]=Date.now()}timeEnd(j){j in this.started||(0,n.warn)(`Timer has not been started for ${j}`),this.times.push({name:j,start:this.started[j],end:Date.now()}),delete this.started[j]}toString(){let j=[],G=0;for(let{name:Y}of this.times)G=Math.max(Y.length,G);for(let{name:Y,start:et,end:rt}of this.times)j.push(`${Y.padEnd(G)} ${rt-et}ms
5
5
  `);return j.join("")}}function w(K,j){try{let{protocol:G}=j?new URL(K,j):new URL(K);return G==="http:"||G==="https:"}catch{return!1}}function P(K){K.preventDefault()}let E;class I{static toDateObject(j){if(!j||typeof j!="string")return null;E||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let G=E.exec(j);if(!G)return null;let Y=parseInt(G[1],10),et=parseInt(G[2],10);et=et>=1&&et<=12?et-1:0;let rt=parseInt(G[3],10);rt=rt>=1&&rt<=31?rt:1;let ct=parseInt(G[4],10);ct=ct>=0&&ct<=23?ct:0;let st=parseInt(G[5],10);st=st>=0&&st<=59?st:0;let W=parseInt(G[6],10);W=W>=0&&W<=59?W:0;let x=G[7]||"Z",T=parseInt(G[8],10);T=T>=0&&T<=23?T:0;let R=parseInt(G[9],10)||0;return R=R>=0&&R<=59?R:0,x==="-"?(ct+=T,st+=R):x==="+"&&(ct-=T,st-=R),new Date(Date.UTC(Y,et,rt,ct,st,W))}}function N(K,{scale:j=1,rotation:G=0}){let{width:Y,height:et}=K.attributes.style,rt=[0,0,parseInt(Y),parseInt(et)];return new A({viewBox:rt,scale:j,rotation:G})}function z(K){if(K.startsWith("#")){let j=parseInt(K.slice(1),16);return[(16711680&j)>>16,(65280&j)>>8,255&j]}return K.startsWith("rgb(")?K.slice(4,-1).split(",").map((j=>parseInt(j))):K.startsWith("rgba(")?K.slice(5,-1).split(",").map((j=>parseInt(j))).slice(0,3):((0,n.warn)(`Not a valid color format: "${K}"`),[0,0,0])}function H(K){let j=document.createElement("span");j.style.visibility="hidden",document.body.append(j);for(let G of K.keys()){j.style.color=G;let Y=window.getComputedStyle(j).color;K.set(G,z(Y))}j.remove()}function X(K){let{a:j,b:G,c:Y,d:et,e:rt,f:ct}=K.getTransform();return[j,G,Y,et,rt,ct]}function it(K){let{a:j,b:G,c:Y,d:et,e:rt,f:ct}=K.getTransform().invertSelf();return[j,G,Y,et,rt,ct]}function at(K,j,G=!1,Y=!0){if(j instanceof A){let{pageWidth:et,pageHeight:rt}=j.rawDims,{style:ct}=K,st=n.FeatureTest.isCSSRoundSupported,W=`var(--scale-factor) * ${et}px`,x=`var(--scale-factor) * ${rt}px`,T=st?`round(${W}, 1px)`:`calc(${W})`,R=st?`round(${x}, 1px)`:`calc(${x})`;G&&j.rotation%180!=0?(ct.width=R,ct.height=T):(ct.width=T,ct.height=R)}Y&&K.setAttribute("data-main-rotation",j.rotation)}},47:(s,t,e)=>{e.d(t,{DrawLayer:()=>o});var i=e(419),n=e(292);class o{#t=null;#e=0;#i=new Map;#n=new Map;constructor({pageIndex:h}){this.pageIndex=h}setParent(h){if(this.#t){if(this.#t!==h){if(this.#i.size>0)for(let g of this.#i.values())g.remove(),h.append(g);this.#t=h}}else this.#t=h}static get _svgFactory(){return(0,n.shadow)(this,"_svgFactory",new i.DOMSVGFactory)}static#r(h,{x:g=0,y:m=0,width:d=1,height:a=1}={}){let{style:f}=h;f.top=100*m+"%",f.left=100*g+"%",f.width=100*d+"%",f.height=100*a+"%"}#s(h){let g=o._svgFactory.create(1,1,!0);return this.#t.append(g),g.setAttribute("aria-hidden",!0),o.#r(g,h),g}#o(h,g){let m=o._svgFactory.createElement("clipPath");h.append(m);let d=`clip_${g}`;m.setAttribute("id",d),m.setAttribute("clipPathUnits","objectBoundingBox");let a=o._svgFactory.createElement("use");return m.append(a),a.setAttribute("href",`#${g}`),a.classList.add("clip"),d}highlight(h,g,m,d=!1){let a=this.#e++,f=this.#s(h.box);f.classList.add("highlight"),h.free&&f.classList.add("free");let A=o._svgFactory.createElement("defs");f.append(A);let C=o._svgFactory.createElement("path");A.append(C);let u=`path_p${this.pageIndex}_${a}`;C.setAttribute("id",u),C.setAttribute("d",h.toSVGPath()),d&&this.#n.set(a,C);let y=this.#o(A,u),r=o._svgFactory.createElement("use");return f.append(r),f.setAttribute("fill",g),f.setAttribute("fill-opacity",m),r.setAttribute("href",`#${u}`),this.#i.set(a,f),{id:a,clipPathId:`url(#${y})`}}highlightOutline(h){let g=this.#e++,m=this.#s(h.box);m.classList.add("highlightOutline");let d=o._svgFactory.createElement("defs");m.append(d);let a=o._svgFactory.createElement("path");d.append(a);let f=`path_p${this.pageIndex}_${g}`;a.setAttribute("id",f),a.setAttribute("d",h.toSVGPath()),a.setAttribute("vector-effect","non-scaling-stroke");let A;if(h.free){m.classList.add("free");let y=o._svgFactory.createElement("mask");d.append(y),A=`mask_p${this.pageIndex}_${g}`,y.setAttribute("id",A),y.setAttribute("maskUnits","objectBoundingBox");let r=o._svgFactory.createElement("rect");y.append(r),r.setAttribute("width","1"),r.setAttribute("height","1"),r.setAttribute("fill","white");let c=o._svgFactory.createElement("use");y.append(c),c.setAttribute("href",`#${f}`),c.setAttribute("stroke","none"),c.setAttribute("fill","black"),c.setAttribute("fill-rule","nonzero"),c.classList.add("mask")}let C=o._svgFactory.createElement("use");m.append(C),C.setAttribute("href",`#${f}`),A&&C.setAttribute("mask",`url(#${A})`);let u=C.cloneNode();return m.append(u),C.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.#i.set(g,m),g}finalizeLine(h,g){let m=this.#n.get(h);this.#n.delete(h),this.updateBox(h,g.box),m.setAttribute("d",g.toSVGPath())}updateLine(h,g){this.#i.get(h).firstChild.firstChild.setAttribute("d",g.toSVGPath())}removeFreeHighlight(h){this.remove(h),this.#n.delete(h)}updatePath(h,g){this.#n.get(h).setAttribute("d",g.toSVGPath())}updateBox(h,g){o.#r(this.#i.get(h),g)}show(h,g){this.#i.get(h).classList.toggle("hidden",!g)}rotate(h,g){this.#i.get(h).setAttribute("data-main-rotation",g)}changeColor(h,g){this.#i.get(h).setAttribute("fill",g)}changeOpacity(h,g){this.#i.get(h).setAttribute("fill-opacity",g)}addClass(h,g){this.#i.get(h).classList.add(g)}removeClass(h,g){this.#i.get(h).classList.remove(g)}remove(h){this.#t!==null&&(this.#i.get(h).remove(),this.#i.delete(h))}destroy(){this.#t=null;for(let h of this.#i.values())h.remove();this.#i.clear()}}},731:(s,t,e)=>{e.d(t,{AnnotationEditorLayer:()=>u});var i=e(292),n=e(310),o=e(830),l=e(976);let h=/\r\n?|\n/g;class g extends n.AnnotationEditor{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#i=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#r=this.editorDivPaste.bind(this);#s;#o="";#c=`${this.id}-editor`;#a;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let r=g.prototype,c=P=>P.isEmpty(),b=o.AnnotationEditorUIManager.TRANSLATE_SMALL,w=o.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new o.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-b,0],checker:c}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-w,0],checker:c}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[b,0],checker:c}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[w,0],checker:c}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-b],checker:c}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-w],checker:c}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,b],checker:c}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,w],checker:c}]]))}static _type="freetext";static _editorType=i.AnnotationEditorType.FREETEXT;constructor(r){super({...r,name:"freeTextEditor"}),this.#s=r.color||g._defaultColor||n.AnnotationEditor._defaultLineColor,this.#a=r.fontSize||g._defaultFontSize}static initialize(r,c){n.AnnotationEditor.initialize(r,c,{strings:["pdfjs-free-text-default-content"]});let b=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(b.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,c){switch(r){case i.AnnotationEditorParamsType.FREETEXT_SIZE:g._defaultFontSize=c;break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:g._defaultColor=c}}updateParams(r,c){switch(r){case i.AnnotationEditorParamsType.FREETEXT_SIZE:this.#p(c);break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:this.#u(c)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,g._defaultFontSize],[i.AnnotationEditorParamsType.FREETEXT_COLOR,g._defaultColor||n.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,this.#a],[i.AnnotationEditorParamsType.FREETEXT_COLOR,this.#s]]}#p(r){let c=w=>{this.editorDiv.style.fontSize=`calc(${w}px * var(--scale-factor))`,this.translate(0,-(w-this.#a)*this.parentScale),this.#a=w,this.#f()},b=this.#a;this.addCommands({cmd:c.bind(this,r),undo:c.bind(this,b),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#u(r){let c=w=>{this.#s=this.editorDiv.style.color=w},b=this.#s;this.addCommands({cmd:c.bind(this,r),undo:c.bind(this,b),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(r,c){this._uiManager.translateSelectedEditors(r,c,!0)}getInitialTranslation(){let r=this.parentScale;return[-g._internalPadding*r,-(g._internalPadding+this.#a)*r]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(i.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",this.#n),this.editorDiv.addEventListener("focus",this.#e),this.editorDiv.addEventListener("blur",this.#t),this.editorDiv.addEventListener("input",this.#i),this.editorDiv.addEventListener("paste",this.#r))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#c),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#i),this.editorDiv.removeEventListener("paste",this.#r),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#l(){let r=[];this.editorDiv.normalize();for(let c of this.editorDiv.childNodes)r.push(g.#g(c));return r.join(`
6
6
  `)}#f(){let[r,c]=this.parentDimensions,b;if(this.isAttachedToDOM)b=this.div.getBoundingClientRect();else{let{currentLayer:w,div:P}=this,E=P.style.display;P.style.display="hidden",w.div.append(this.div),b=P.getBoundingClientRect(),P.remove(),P.style.display=E}this.rotation%180==this.parentRotation%180?(this.width=b.width/r,this.height=b.height/c):(this.width=b.height/r,this.height=b.width/c),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let r=this.#o,c=this.#o=this.#l().trimEnd();if(r===c)return;let b=w=>{this.#o=w,w?(this.#h(),this._uiManager.rebuild(this),this.#f()):this.remove()};this.addCommands({cmd:()=>{b(c)},undo:()=>{b(r)},mustExec:!1}),this.#f()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(r){this.enterInEditMode()}keydown(r){r.target===this.div&&r.key==="Enter"&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){g._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let r,c;this.width&&(r=this.x,c=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#c),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),n.AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then((w=>this.editorDiv?.setAttribute("default-content",w))),this.editorDiv.contentEditable=!0;let{style:b}=this.editorDiv;if(b.fontSize=`calc(${this.#a}px * var(--scale-factor))`,b.color=this.#s,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,o.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[w,P]=this.parentDimensions;if(this.annotationElementId){let{position:E}=this.#d,[I,N]=this.getInitialTranslation();[I,N]=this.pageTranslationToScreen(I,N);let[z,H]=this.pageDimensions,[X,it]=this.pageTranslation,at,K;switch(this.rotation){case 0:at=r+(E[0]-X)/z,K=c+this.height-(E[1]-it)/H;break;case 90:at=r+(E[0]-X)/z,K=c-(E[1]-it)/H,[I,N]=[N,-I];break;case 180:at=r-this.width+(E[0]-X)/z,K=c-(E[1]-it)/H,[I,N]=[-I,-N];break;case 270:at=r+(E[0]-X-this.height*H)/z,K=c+(E[1]-it-this.width*z)/H,[I,N]=[-N,I]}this.setAt(at*w,K*P,I,N)}else this.setAt(r*w,c*P,this.width*w,this.height*P);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#g(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(h,"")}editorDivPaste(r){let c=r.clipboardData||window.clipboardData,{types:b}=c;if(b.length===1&&b[0]==="text/plain")return;r.preventDefault();let w=g.#m(c.getData("text")||"").replaceAll(h,`