1import{a as ds}from"./chunk-6EWWPBVH.js";import{Ba as di,C as cs,Dg as gr,E as hs,Fa as ct,Se as we,Te as ui,Uf as fr,Yg as mr,d as ye,df as pi,h as cr,hd as pr,la as hi,ma as Le,p as hr,x as dr,y as ur,z as ci}from"./chunk-BAKSV7Y6.js";import{Ab as Gt,Ca as q,Da as K,Ea as gt,Fa as vt,Gc as Zt,Hb as nt,Ia as Jn,Id as oi,Jb as ls,Kb as at,Kc as E,Kd as li,L as qn,La as tr,Lc as T,Mb as M,Mc as Jt,Md as lr,Na as ri,Nb as mt,Oa as ve,Ob as Bt,Rb as rt,S as Kn,Sb as Ie,Tb as ir,Ub as Wt,Vb as Xt,Wb as v,Xb as w,Yb as z,aa as Yn,ac as Ht,ba as jt,dc as tt,f as he,fc as F,gb as os,ia as Qn,ja as si,jc as sr,jd as St,ld as se,mb as er,mc as nr,n as Xn,na as as,nc as rr,o as rs,oa as Zn,ob as _,oc as ar,pb as Ct,qc as qt,rc as xe,ta as ie,u as Re,ua as ni,uc as k,vc as L,wc as Mt,xc as or,zb as Y,zd as ai}from"./chunk-TPMNAKGL.js";import"./chunk-2LGQJZXS.js";import"./chunk-K27TRVGX.js";import"./chunk-SE2NVOMR.js";import{a as Nt,b as _e,g as ce,h as I}from"./chunk-FJYW2LMB.js";var _r=(()=>{class o{static{this.\u0275fac=function(i){return new(i||o)}}static{this.\u0275cmp=ie({type:o,selectors:[["app-ai-cd-report-viewer"]],decls:7,vars:0,consts:[[1,"ai-cd-shell"],[1,"ai-cd-shell__left"],[1,"ai-cd-shell__right"],[1,"ai-cd-shell__content"]],template:function(i,s){i&1&&(v(0,"div",0)(1,"div",1),z(2,"app-left-bar"),w(),v(3,"div",2),z(4,"app-top-bar"),v(5,"div",3),z(6,"router-outlet"),w()()())},dependencies:[ur,fr,gr],styles:["[_nghost-%COMP%]{display:block;height:100%;min-height:0;--bg: #f4f6fa;--surface: #ffffff;--surface-2: #f8fafc;--border: #e4e8f0;--tx-border:#DDE2E9;--border-strong: #d3d9e6;--text: #111A27;--text-muted: #64708a;--text-faint: #93a0b8;--tx-body: #1E2938;--tx-grey: #414E62;--tx-btn-color: #7A28A0;--tx-btn-hover: #5b1e77;--brand: #2f6bff;--brand-dark: #1f4fd6;--brand-tint: #eaf1ff;--ai: #e5484d;--ai-tint: #fdecec;--ai-solid: #e5484d;--likely: #f5a524;--likely-tint: #fef4e2;--human: #30a46c;--radius: 12px;--radius-sm: 8px;--shadow-sm: 0 1px 2px rgba(20, 30, 55, .06), 0 1px 3px rgba(20, 30, 55, .05);--shadow-md: 0 4px 16px rgba(20, 30, 55, .08);--shadow-lg: 0 12px 40px rgba(20, 30, 55, .14)}.ai-cd-shell[_ngcontent-%COMP%]{display:flex;width:100%;height:100%;min-height:0}.ai-cd-shell__left[_ngcontent-%COMP%]{flex:none;width:var(--left-panel-width, 290px);height:100%;transition:width .3s ease}.ai-cd-shell__right[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;height:100%}.ai-cd-shell__content[_ngcontent-%COMP%]{flex:1;min-height:0;position:relative}"]})}}return o})();var Jr={IN_PROGRESS:"processing",SUCCESS:"completed",FAILED:"failed"};function us(o){return Jr[o??""]??(o??"").toLowerCase()}function ta(o){return{id:o.file_id??o.report_id??o.id??"",filename:o.file_name??o.filename??"",size:o.size??0,status:us(o.file_status??o.status),createdAt:o.uploaded_at??o.createdAt??"",numPages:o.numPages,error:o.error}}function ea(o){return o===!0?"completed":o===!1?"failed":us(typeof o=="string"?o:void 0)}function vr(o){return{id:o.file_id??o.report_id??o.id??"",filename:o.file_name??o.filename??"",size:0,status:ea(o.file_status??o.status),createdAt:o.uploaded_at??o.createdAt??"",url:o.url,error:o.error}}var fi=(()=>{class o{get apiRoot(){return this.base.replace(/\/ai-cd\/?$/,"")}constructor(t,i){this.http=t,this.storage=i,this.base=hs.aiCdReportBaseUrl}upload(t,i,s="ENAGO_REPORT"){let n=new FormData;return n.append("file",t),n.append("email",i),n.append("source",s),n.append("is_b2b_report","false"),n.append("word_count","0"),this.http.post(`${this.base}/documents`,n,{reportProgress:!0,observe:"events"}).pipe(Re(r=>{if(r.type===ye.UploadProgress)return{type:"progress",percent:r.total?Math.round(r.loaded/r.total*100):0};if(r.type===ye.Response){let a=r.body??{};return{type:"done",result:{id:a.file_id??a.id??"",status:us(a.file_status??a.status),filename:a.file_name??a.filename??""}}}return{type:"progress",percent:0}}))}getDocument(t){return this.http.get(`${this.base}/report/submission/download/pdf/${t}`,{observe:"response",responseType:"blob"}).pipe(Yn(i=>this.mapPdfResponse(t,i)))}mapPdfResponse(t,i){let s=i.body,n=(i.headers.get("content-type")||s?.type||"").toLowerCase();return s?n.includes("application/json")?Xn(s.text()).pipe(Re(r=>{let a={};try{a=JSON.parse(r)}catch{a={}}return vr(a)})):rs({id:t,filename:"",status:"completed",createdAt:"",fileBlob:s}):rs(vr({id:t}))}getReport(t){return this.http.get(`${this.base}/report/submission/download/json/${t}`).pipe(Re(i=>i.data))}listDocuments(){return this.http.get(`${this.base}/documents`).pipe(Re(t=>(t??[]).map(ta)))}fileUrl(t){return`${this.base}/documents/${t}/file`}reportDownloadUrl(t,i){return hs.downloadaicdBaseUrl+`download/ai_content_report/${btoa(i)}/${t}`}downloadReport(t,i){return this.http.get(this.reportDownloadUrl(t,i),{observe:"events",reportProgress:!0,responseType:"blob"})}static{this.\u0275fac=function(i){return new(i||o)(as(cr),as(di))}}static{this.\u0275prov=Qn({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o}
1)();var na=["fileInput"],ra=(o,e)=>e.id,aa=o=>({"is-dragging":o}),oa=o=>({progress:o});function la(o,e){if(o&1){let t=Ht();v(0,"div",22)(1,"label",23),k(2),E(3,"translate"),w(),v(4,"input",24),E(5,"translate"),tt("input",function(s){q(t);let n=F();return K(n.email.set(s.target.value))}),w()(),v(6,"div",25),E(7,"translate"),tt("dragover",function(s){q(t);let n=F();return K(n.onDragOver(s))})("dragleave",function(s){q(t);let n=F();return K(n.onDragLeave(s))})("drop",function(s){q(t);let n=F();return K(n.onDrop(s))})("click",function(){q(t);let s=F();return K(s.openPicker())})("keydown.enter",function(){q(t);let s=F();return K(s.openPicker())})("keydown.space",function(s){q(t);let n=F();return s.preventDefault(),K(n.openPicker())}),v(8,"div",26),gt(),v(9,"svg",27),z(10,"path",28)(11,"path",29),w()(),vt(),v(12,"div",30),k(13),E(14,"translate"),w(),v(15,"div",31),k(16),E(17,"translate"),w(),v(18,"div",32)(19,"span",5),k(20),E(21,"translate"),w()(),v(22,"div",33),k(23),E(24,"translate"),w(),v(25,"div",34)(26,"button",35),E(27,"translate"),tt("click",function(s){q(t);let n=F();return s.stopPropagation(),K(n.openPicker())}),v(28,"span",36),gt(),v(29,"svg",27),z(30,"rect",37)(31,"path",38)(32,"circle",39),w()(),vt(),v(33,"span",40),k(34),E(35,"translate"),w()(),v(36,"button",35),E(37,"translate"),tt("click",function(s){q(t);let n=F();return s.stopPropagation(),K(n.openPicker())}),v(38,"span",36),gt(),v(39,"svg",27),z(40,"rect",41)(41,"path",42),w()(),vt(),v(42,"span",40),k(43),E(44,"translate"),w()(),v(45,"button",35),E(46,"translate"),tt("click",function(s){q(t);let n=F();return s.stopPropagation(),K(n.openPicker())}),v(47,"span",36),gt(),v(48,"svg",43),z(49,"circle",44)(50,"circle",45)(51,"circle",46)(52,"circle",47),w()(),vt(),v(53,"span",40),k(54),E(55,"translate"),w()()()()}if(o&2){let t=F();_(),M("appLocalizationHover",t.keys.AICDReportView.emailLabel),_(),L(T(3,23,t.keys.AICDReportView.emailLabel)),_(2),M("value",t.email()),at("placeholder",T(5,25,t.keys.AICDReportView.emailPlaceholder)),_(2),M("ngClass",Zt(49,aa,t.dragging())),at("aria-label",T(7,27,t.keys.AICDReportView.dropzoneAriaLabel)),_(6),M("appLocalizationHover",t.keys.AICDReportView.dragDropTitle),_(),L(T(14,29,t.keys.AICDReportView.dragDropTitle)),_(2),M("appLocalizationHover",t.keys.AICDReportView.fileTypeHint),_(),L(T(17,31,t.keys.AICDReportView.fileTypeHint)),_(3),M("appLocalizationHover",t.keys.AICDReportView.or),_(),L(T(21,33,t.keys.AICDReportView.or)),_(2),M("appLocalizationHover",t.keys.AICDReportView.uploadFileFrom),_(),L(T(24,35,t.keys.AICDReportView.uploadFileFrom)),_(3),at("aria-label",T(27,37,t.keys.AICDReportView.uploadFromMyDriveAria)),_(7),M("appLocalizationHover",t.keys.AICDReportView.trinkaMyDrive),_(
1),L(T(35,39,t.keys.AICDReportView.trinkaMyDrive)),_(2),at("aria-label",T(37,41,t.keys.AICDReportView.uploadFromMyDeviceAria)),_(6),M("appLocalizationHover",t.keys.AICDReportView.myDevice),_(),L(T(44,43,t.keys.AICDReportView.myDevice)),_(2),at("aria-label",T(46,45,t.keys.AICDReportView.uploadFromOthersAria)),_(8),M("appLocalizationHover",t.keys.AICDReportView.others),_(),L(T(55,47,t.keys.AICDReportView.others))}}function ca(o,e){if(o&1&&(v(0,"span",5),k(1),E(2,"translate"),w()),o&2){let t=F(2);M("appLocalizationHover",t.keys.AICDReportView.uploadingProgress),_(),L(Jt(2,2,t.keys.AICDReportView.uploadingProgress,Zt(5,oa,t.progress())))}}function ha(o,e){if(o&1&&(v(0,"span",5),k(1),E(2,"translate"),w()),o&2){let t=F(2);M("appLocalizationHover",t.keys.AICDReportView.analyzingDocument),_(),L(T(2,2,t.keys.AICDReportView.analyzingDocument))}}function da(o,e){if(o&1&&(v(0,"div",19)(1,"div",48),k(2),w(),v(3,"div",49),z(4,"div",50),w(),v(5,"div",51),nt(6,ca,3,7,"span",5)(7,ha,3,4,"span",5),w()()),o&2){let t=F();_(2),L(t.fileName()),_(),at("aria-valuenow",t.progress()),_(),mt("width",t.progress(),"%"),_(2),rt(t.progress()<100?6:7)}}function ua(o,e){if(o&1&&(v(0,"div",20),k(1),w()),o&2){let t=F();_(),L(t.error())}}function pa(o,e){if(o&1&&(k(0),E(1,"number"),v(2,"span",5),k(3),E(4,"translate"),w()),o&2){let t=F().$implicit,i=F(2);Mt(" \xB7 ",Jt(1,3,t.size/1024/1024,"1.1-1")," "),_(2),M("appLocalizationHover",i.keys.AICDReportView.sizeMb),_(),L(T(4,6,i.keys.AICDReportView.sizeMb))}}function fa(o,e){if(o&1){let t=Ht();v(0,"button",54),tt("click",function(){let s=q(t).$implicit,n=F(2);return K(n.open(s))}),v(1,"div",55),k(2),w(),v(3,"div",56)(4,"div",57),k(5),w(),v(6,"div",58),k(7),E(8,"date"),nt(9,pa,5,8,"span",5),w()(),v(10,"span",59),k(11),E(12,"translate"),w()()}if(o&2){let t=e.$implicit,i=F(2);_(2),L(i.ext(t.filename)),_(3),L(t.filename),_(2),Mt(" ",Jt(8,7,t.createdAt,"MMM d, y, h:mm a")," "),_(2),rt(t.size?9:-1),_(),M("appLocalizationHover",i.statusLabel(t.status)),at("data-status",t.status),_(),L(T(12,10,i.statusLabel(t.status)))}}function ga(o,e){if(o&1&&(v(0,"section",21)(1,"h2")(2,"span",5),k(3),E(4,"translate"),w()(),v(5,"div",52),Wt(6,fa,13,12,"button",53,ra),w()()),o&2){let t=F();_(2),M("appLocalizationHover",t.keys.AICDReportView.recentChecks),_(),L(T(4,2,t.keys.AICDReportView.recentChecks)),_(3),Xt(t.recent())}}var wr=(()=>{class o{constructor(t,i,s){this.api=t,this.router=i,this.translate=s,this.keys=ct,this.fileInput=Gt("fileInput"),this.destroy$=new he,this.dragging=Y(!1),this.uploading=Y(!1),this.progress=Y(0),this.error=Y(null),this.fileName=Y(null),this.email=Y(""),this.recent=Y([]),this.loadRecent()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadRecent(){this.api.listDocuments().pipe(jt(this.destroy$)).subscribe({next:t=>this.recent.set(t.slice(0,6)),error:()=>{}})}onDragOver(t){t.preventDefault(),this.dragging.set(!0)}onDragLeave(t){t.preventDefault(),this.dragging.set(!1)}onDrop(t){t.preventDefault(),this.dragging.set(!1);let i=t.dataTransfer?.files?.[0];i&&this.handleFile(i)}onSelect(t){let s=t.target.files?.[0];s&&this.handleFile(s)}openPicker(){this.fileInput()?.nativeElement.click()}handleFile(t){if(this.error.set(null),!/\.(pdf|docx?|txt)$/i.test(t.name)){this.error.set(this.translate.instant(this.keys.AICDReportView.invalidFileType));return}let i=this.email().trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)){this.error.set(this.translate.instant(this.keys.AICDReportView.invalidEmail));return}this.fileName.set(t.name),this.uploading.set(!0),this.progress.set(0),this.api.upload(t,i).pipe(jt(this.destroy$)).subscribe({next:s=>{s.type==="progress"&&this.progress.set(s.percent),s.type==="done"&&this.router.navigate(["/ai-cd-report-viewer","report",s.result.id])},error:s=>{this.uploading.set(!1),this.error.set(s?.error?.error||this.translate.instant(this.keys.AICDReportView.uploadFailed))}})}open(t){this.router.navigate(["/ai-cd-report-viewer","report",t.id])}ext(t){let i=/\.([a-z0-9]+)$/i.exec(t||"");return i?i[1].toUpperCase():"DOC"}statusLabel(t){return t==="processing"?this.keys.AICDReportView.statusProcessing:t==="completed"?this.keys.AICDReportView.statusCompleted:this.keys.AICDReportView.statusFailed}static{this.\u0275fac=function(i){return new(i||o)(Ct(fi),Ct(ci),Ct(we))}}static{this.\u0275cmp=ie({type:o,selectors:[["app-ai-cd-upload"]],viewQuery:function(i,s){i&1&&qt(s.fileInput,na,5),i&2&&xe()},decls:46,vars:23,consts:[["fileInput",""],[1,"page"],[1,"content"],[1,"hero"],[1,"hero-left"],[3,"appLocalizationHover"],[1,"steps"],[1,"step-ic"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","1.7","stroke-linecap","round","stroke-linejoin","round"],["d","M12 15V6m0 0l-3 3m3-3l3 3"],["d","M6.5 18a4 4 0 0 1-.8-7.92A5.5 5.5 0 0 1 17 9.5a3.5 3.5 0 0 1 1 6.86"],["x","6","y","4","width","12","height","16","rx","2"],["d","M9 4h6v2a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V4z"],["d","M9.5 13l1.5 1.5L14 11"],["d","M12 4v10m0 0l-3.5-3.5M12 14l3.5-3.5"],["d","M5 18h14"],[1,"hero-right"],[1,"upload-card"],["type","file","accept","application/pdf,.pdf,.doc,.docx,.txt","hidden","",3,"change"],[1,"uploading"],["role","alert","aria-live","assertive",1,"error-banner"],[1,"recent"],[1,"email-row"],["for","ai-cd-email",3,"appLocalizationHover"],["id","ai-cd-email","type","email","autocomplete","email",3,"input","value"],["role","button","tabindex","0",1,"dropzone",3,"dragover","dragleave","drop","click","keydown.enter","keydown.space","ngClass"],[1,"dz-cloud"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","1.6","stroke-linecap","round","stroke-linejoin","round"],["d","M12 16V8m0 0l-3 3m3-3l3 3"],["d","M7 18a4.5 4.5 0 0 1-.9-8.91A5.5 5.5 0 0 1 17.5 10a3.5 3.5 0 0 1 .5 6.96"],[1,"dz-title",3,"appLocalizationHover"],[1,"dz-sub",3,"appLocalizationHover"],[1,"dz-or"],[1,"dz-from",3,"appLocalizationHover"],[1,"sources"],["type","button",1,"source",3,"click"],[1,"source-ic"],["x","4","y","5","width","16","height","14","rx","2"],["d","M4 12h16"],["cx","8","cy","15.5","r","1","fill","currentColor","stroke","none"],[1,"source-label",3,"appLocalizationHover"],["x","3","y","4","width","18","height","12","rx","2"],["d","M8 20h8M12 16v4"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","1.6"],["cx","12","cy","12","r","9"],["cx","8","cy","12","r","1","fill","currentColor","stroke","none"],["cx","12","cy","12","r","1","fill","currentColor","stroke","none"],["cx","16","cy","12","r","1","fill","currentColor","stroke","none"],[1,"up-name"],["role","progressbar","aria-valuemin","0","aria-valuemax","100",1,"progress-track"],[1,"progress-bar"],["aria-live","polite",1,"up-status"],[1,"recent-list"],[1,"recent-item"],[1,"recent-item",3,"click"],[1,"ri-icon"],[1,"ri-main"],[1,"ri-name"],[1,"ri-meta"],[1,"ri-status",3,"appLocalizationHover"]],template:function(i,s){if(i&1){let n=Ht();v(0,"div",1)(1,"main",2)(2,"div",3)(3,"div",4)(4,"h1")(5,"span",5),k(6),E(7,"translate"),w(),z(8,"br"),v(9,"span",5),k(10),E(11,"translate"),w()(),v(12,"ul",6)(13,"li")(14,"span",7),gt(),v(15,"svg",8),z(16,"path",9)(17,"path",10),w()(),vt(),v(18,"span",5),k(19),E(20,"translate"),w()(),v(21,"li")(22,"span",7),gt(),v(23,"svg",8),z(24,"rect",11)(25,"path",12)(26,"path",13),w()(),vt(),v(27,"span",5),k(28),E(29,"translate"),w()(),v(30,"li")(31,"span",7),gt(),v(32,"svg",8),z(33,"path",14)(34,"path",15),w()(),vt(),v(35,"span",5),k(36),E(37,"translate"),w()()()(),v(38,"div",16)(39,"div",17)(40,"input",18,0),tt("change",function(a){return q(n),K(s.onSelect(a))}
1),w(),nt(42,la,56,51)(43,da,8,5,"div",19),w(),nt(44,ua,2,1,"div",20),w()(),nt(45,ga,8,4,"section",21),w()()}i&2&&(_(5),M("appLocalizationHover",s.keys.AICDReportView.uploadHeroTitleLine1),_(),L(T(7,13,s.keys.AICDReportView.uploadHeroTitleLine1)),_(3),M("appLocalizationHover",s.keys.AICDReportView.uploadHeroTitleLine2),_(),L(T(11,15,s.keys.AICDReportView.uploadHeroTitleLine2)),_(8),M("appLocalizationHover",s.keys.AICDReportView.uploadStep1),_(),L(T(20,17,s.keys.AICDReportView.uploadStep1)),_(8),M("appLocalizationHover",s.keys.AICDReportView.uploadStep2),_(),L(T(29,19,s.keys.AICDReportView.uploadStep2)),_(7),M("appLocalizationHover",s.keys.AICDReportView.uploadStep3),_(),L(T(37,21,s.keys.AICDReportView.uploadStep3)),_(6),rt(s.uploading()?43:42),_(2),rt(s.error()?44:-1),_(),rt(s.recent().length?45:-1))},dependencies:[ai,pi,li,oi,ui],styles:['[_nghost-%COMP%]{display:block;height:100%;min-height:0;--u-purple: #8b23c9;--u-purple-dark: #6d1a9e;--u-purple-tint: #f6ecfb;--u-border: #e0c6ef}.page[_ngcontent-%COMP%]{height:100%;overflow-y:auto;display:flex;flex-direction:column;background:var(--bg);font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif}.content[_ngcontent-%COMP%]{flex:1;width:100%;max-width:1080px;margin:0 auto;padding:48px 32px 80px}.hero[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1.05fr;gap:56px;align-items:center}.hero-left[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{font-size:34px;line-height:1.22;letter-spacing:-.02em;margin:0 0 30px;color:#101828}.steps[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:20px}.steps[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{display:flex;align-items:center;gap:14px;font-size:16px;color:var(--text-muted);font-weight:500}.step-ic[_ngcontent-%COMP%]{flex:none;width:26px;height:26px;color:var(--u-purple)}.step-ic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:100%;height:100%}.upload-card[_ngcontent-%COMP%]{background:var(--surface);border-radius:16px;box-shadow:var(--shadow-md);padding:16px}.dropzone[_ngcontent-%COMP%]{border:1.5px dashed var(--u-border);border-radius:12px;padding:36px 28px 40px;text-align:center;cursor:pointer;transition:border-color .15s ease,background .15s ease}.dropzone[_ngcontent-%COMP%]:hover, .dropzone.is-dragging[_ngcontent-%COMP%]{border-color:var(--u-purple);background:var(--u-purple-tint)}.dropzone[_ngcontent-%COMP%]:focus-visible{outline:2px solid var(--u-purple);outline-offset:2px}.dz-cloud[_ngcontent-%COMP%]{width:46px;height:46px;margin:0 auto 12px;color:var(--u-purple)}.dz-cloud[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:100%;height:100%}.dz-title[_ngcontent-%COMP%]{font-size:18px;font-weight:700;color:#101828}.dz-sub[_ngcontent-%COMP%]{font-size:13px;color:var(--text-muted);margin-top:6px}.dz-or[_ngcontent-%COMP%]{display:flex;align-items:center;gap:14px;margin:22px auto;max-width:320px;color:var(--text-faint);font-size:12px;font-weight:700;letter-spacing:.08em}.dz-or[_ngcontent-%COMP%]:before, .dz-or[_ngcontent-%COMP%]:after{content:"";flex:1;height:1px;background:var(--border)}.dz-from[_ngcontent-%COMP%]{font-size:15px;color:var(--u-purple-dark);font-weight:600;margin-bottom:18px}.sources[_ngcontent-%COMP%]{display:flex;justify-content:center;gap:40px}.source[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:8px;background:none;border:none;padding:6px;border-radius:10px;transition:transform .1s ease}.source[_ngcontent-%COMP%]:hover{transform:translateY(-2px)}.source-ic[_ngcontent-%COMP%]{width:34px;height:34px;color:var(--u-purple)}.source-ic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:100%;height:100%}.source-label[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:#101828}.uploading[_ngcontent-%COMP%]{padding:44px 28px;text-align:center}.up-name[_ngcontent-%COMP%]{font-weight:600;margin-bottom:16px}.progress-track[_ngcontent-%COMP%]{height:8px;background:var(--border);border-radius:999px;overflow:hidden;max-width:420px;margin:0 auto}.progress-bar[_ngcontent-%COMP%]{height:100%;background:linear-gradient(90deg,var(--u-purple),#c05be8);border-radius:999px;transition:width .2s ease}.up-status[_ngcontent-%COMP%]{margin-top:12px;font-size:14px;color:var(--text-muted)}.error-banner[_ngcontent-%COMP%]{margin-top:16px;padding:12px 16px;background:var(--ai-tint);color:var(--ai);border:1px solid #f5c2c4;border-radius:var(--radius-sm);font-size:14px;font-weight:500}.recent[_ngcontent-%COMP%]{margin-top:56px}.recent[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{font-size:13px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-faint);margin:0 0 14px}.recent-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:10px}.recent-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:14px;padding:14px 16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);text-align:left;transition:border-color .15s ease,box-shadow .15s ease}.recent-item[_ngcontent-%COMP%]:hover{border-color:var(--u-purple);box-shadow:var(--shadow-sm)}.ri-icon[_ngcontent-%COMP%]{flex:none;width:40px;height:40px;border-radius:9px;background:var(--u-purple-tint);color:var(--u-purple);display:inline-flex;align-items:center;justify-content:center;font-size:11px;font-weight:800}.ri-main[_ngcontent-%COMP%]{flex:1;min-width:0}
1.ri-name[_ngcontent-%COMP%]{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ri-meta[_ngcontent-%COMP%]{font-size:13px;color:var(--text-muted);margin-top:2px}.ri-status[_ngcontent-%COMP%]{flex:none;font-size:12px;font-weight:600;padding:4px 10px;border-radius:999px;text-transform:capitalize;background:var(--surface-2);color:var(--text-muted)}.ri-status[data-status=completed][_ngcontent-%COMP%]{background:#e7f7ee;color:var(--human)}.ri-status[data-status=processing][_ngcontent-%COMP%]{background:#fef4e2;color:#b7791f}.ri-status[data-status=failed][_ngcontent-%COMP%]{background:var(--ai-tint);color:var(--ai)}@media (max-width: 860px){.hero[_ngcontent-%COMP%]{grid-template-columns:1fr;gap:36px}.hero-left[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{font-size:28px}}.email-row[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px;margin-bottom:14px;text-align:left}.email-row[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:#33304a}.email-row[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{font-size:14px;padding:10px 12px;border:1px solid #d8d2e6;border-radius:8px;outline:none}.email-row[_ngcontent-%COMP%] input[_ngcontent-%COMP%]:focus{border-color:#6d40e0;box-shadow:0 0 0 3px #6d40e026}']})}}return o})();var xt={"confident-human":{labelKey:ct.AICDReportView.verdict.confidentHuman.label,descKey:ct.AICDReportView.verdict.confidentHuman.desc},"leaning-human":{labelKey:ct.AICDReportView.verdict.leaningHuman.label,descKey:ct.AICDReportView.verdict.leaningHuman.desc},inconclusive:{labelKey:ct.AICDReportView.verdict.inconclusive.label,descKey:ct.AICDReportView.verdict.inconclusive.desc},"leaning-ai":{labelKey:ct.AICDReportView.verdict.leaningAi.label,descKey:ct.AICDReportView.verdict.leaningAi.desc},"confident-ai":{labelKey:ct.AICDReportView.verdict.confidentAi.label,descKey:ct.AICDReportView.verdict.confidentAi.desc}},Ar={"confident-human":ct.AICDReportView.bandDesc.confidentHuman,"leaning-human":ct.AICDReportView.bandDesc.leaningHuman,inconclusive:ct.AICDReportView.bandDesc.inconclusive,"leaning-ai":ct.AICDReportView.bandDesc.leaningAi,"confident-ai":ct.AICDReportView.bandDesc.confidentAi},Ce={"confident-human":{color:"#15803D",background:"#F0FDF4",borderColor:"#15803D",borderStyle:"solid"},"leaning-human":{color:"#3b82f6",background:"#F0F9FF",borderColor:"#3b82f6",borderStyle:"solid"},inconclusive:{color:"#64748b",background:"#fff",borderColor:"#64748b",borderStyle:"solid"},"leaning-ai":{color:"#e08600",background:"#FFF7ED",borderColor:"#C2410C",borderStyle:"solid"},"confident-ai":{color:"#e5484d",background:"#FFF1F2",borderColor:"#9F1239",borderStyle:"solid"}},Se=["confident-human","leaning-human","inconclusive","leaning-ai","confident-ai"];function ps(o){if(o<20){let t="confident-human";return{key:t,labelKey:xt[t].labelKey,descKey:xt[t].descKey,color:"#15803D",background:"#F0FDF4",borderColor:"#15803D",borderStyle:"solid"}}if(o<40){let t="leaning-human";return{key:t,labelKey:xt[t].labelKey,descKey:xt[t].descKey,color:"#0369A1",background:"#F0F9FF",borderColor:"#0369A1",borderStyle:"solid"}}if(o<60){let t="inconclusive";return{key:t,labelKey:xt[t].labelKey,descKey:xt[t].descKey,color:"#334155",background:"#F8FAFC",borderColor:"#334155",borderStyle:"solid"}}if(o<80){let t="leaning-ai";return{key:t,labelKey:xt[t].labelKey,descKey:xt[t].descKey,color:"#e08600",background:"#FFF7ED",borderColor:"#C2410C",borderStyle:"solid"}}let e="confident-ai";return{key:e,labelKey:xt[e].labelKey,descKey:xt[e].descKey,color:"#9F1239",background:"#FFF1F2",borderColor:"#9F1239",borderStyle:"solid"}}var He={};He.d=(o,e)=>{for(var t in e)He.o(e,t)&&!He.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:e[t]})};He.o=(o,e)=>Object.prototype.hasOwnProperty.call(o,e);var V=globalThis.pdfjsLib={};He.d(V,{AbortException:()=>Qt,AnnotationEditorLayer:()=>po,AnnotationEditorParamsType:()=>W,AnnotationEditorType:()=>$,AnnotationEditorUIManager:()=>Ge,AnnotationLayer:()=>Tn,AnnotationMode:()=>ne,ColorPicker:()=>qi,DOMSVGFactory:()=>Ye,DrawLayer:()=>Bn,FeatureTest:()=>bt,GlobalWorkerOptions:()=>ue,ImageKind:()=>xi,InvalidPDFException:()=>ze,MissingPDFException:()=>pe,OPS:()=>Vt,OutputScale:()=>
1je,PDFDataRangeTransport:()=>Fi,PDFDateString:()=>Ai,PDFWorker:()=>Pe,PasswordResponses:()=>xa,PermissionFlag:()=>va,PixelsPerInch:()=>ae,RenderingCancelledException:()=>Ue,TextLayer:()=>qe,TouchManager:()=>Si,UnexpectedResponseException:()=>Te,Util:()=>D,VerbosityLevel:()=>Qi,XfaLayer:()=>Hi,build:()=>co,createValidAbsoluteUrl:()=>Ca,fetchData:()=>es,getDocument:()=>ro,getFilenameFromUrl:()=>Ia,getPdfFilenameFromUrl:()=>La,getXfaPageViewport:()=>Oa,isDataScheme:()=>is,isPdfFile:()=>zn,noContextMenu:()=>zt,normalizeUnicode:()=>Ta,setLayerDimensions:()=>fe,shadow:()=>j,stopEvent:()=>It,version:()=>lo});var At=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Hr=[1,0,0,1,0,0],vs=[.001,0,0,.001,0,0],ma=1e7,vi=1.35,ba=.35,bl=ba/vi,Rt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ne={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},_a="pdfjs_internal_editor_",$={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},W={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},va={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},yt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},xi={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},pt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var Oe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var Qi={ERRORS:0,WARNINGS:1,INFOS:5},Vt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},xa={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Zi=Qi.WARNINGS;function ya(o){Number.isInteger(o)&&(Zi=o)}function wa(){return Zi}function Ji(o){Zi>=Qi.INFOS&&console.log(`Info: ${o}`)}function U(o){Zi>=Qi.WARNINGS&&console.log(`Warning: ${o}`)}function Z(o){throw new Error(o)}function dt(o,e){o||Z(e)}function Aa(o){switch(o?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Ca(o,e=null,t=null){if(!o)return null;
1try{if(t&&typeof o=="string"&&(t.addDefaultProtocol&&o.startsWith("www.")&&o.match(/\./g)?.length>=2&&(o=`http://${o}`),t.tryConvertEncoding))try{o=Pa(o)}catch{}let i=e?new URL(o,e):new URL(o);if(Aa(i))return i}catch{}return null}function j(o,e,t,i=!1){return Object.defineProperty(o,e,{value:t,enumerable:!i,configurable:!0,writable:!1}),t}var oe=function(){function e(t,i){this.message=t,this.name=i}return e.prototype=new Error,e.constructor=e,e}(),yi=class extends oe{constructor(e,t){super(e,"PasswordException"),this.code=t}},Ve=class extends oe{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}},ze=class extends oe{constructor(e){super(e,"InvalidPDFException")}},pe=class extends oe{constructor(e){super(e,"MissingPDFException")}},Te=class extends oe{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}},xs=class extends oe{constructor(e){super(e,"FormatError")}},Qt=class extends oe{constructor(e){super(e,"AbortException")}};function Vr(o){(typeof o!="object"||o?.length===void 0)&&Z("Invalid argument for bytesToString");let e=o.length,t=8192;if(e<t)return String.fromCharCode.apply(null,o);let i=[];for(let s=0;s<e;s+=t){let n=Math.min(s+t,e),r=o.subarray(s,n);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function ts(o){typeof o!="string"&&Z("Invalid argument for stringToBytes");let e=o.length,t=new Uint8Array(e);for(let i=0;i<e;++i)t[i]=o.charCodeAt(i)&255;return t}function Sa(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function Hn(o){let e=Object.create(null);for(let[t,i]of o)e[t]=i;return e}function Ea(){let o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function ka(){try{return new Function(""),!0}catch{return!1}}var bt=class{static get isLittleEndian(){return j(this,"isLittleEndian",Ea())}static get isEvalSupported(){return j(this,"isEvalSupported",ka())}static get isOffscreenCanvasSupported(){return j(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return j(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?j(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):j(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return j(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},fs=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0")),D=class{static makeHexColor(e,t,i){return`#${fs[e]}${fs[t]}${fs[i]}`}static scaleMinMax(e,t){let i;e[0]?(e[0]<0&&(i=t[0],t[0]=t[2],t[2]=i),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(i=t[1],t[1]=t[3],t[3]=i),t[1]*=e[3],t[3]*=e[3]):(i=t[0],t[0]=t[1],t[1]=i,i=t[2],t[2]=t[3],t[3]=i,e[1]<0&&(i=t[1],t[1]=t[3],t[3]=i),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(i=t[0],t[0]=t[2],t[2]=i),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){let i=e[0]*t[0]+e[1]*t[2]+t[4],s=e[0]*t[1]+e[1]*t[3]+t[5];return[i,s]}static applyInverseTransform(e,t){let i=t[0]*t[3]-t[1]*t[2],s=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/i,n=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/i;return[s,n]}static getAxialAlignedBoundingBox(e,t){let i=this.applyTransform(e,t),s=this.applyTransform(e.slice(2,4),t),n=this.applyTransform([e[0],e[3]],t),r=this.applyTransform([e[2],e[1]],t);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],i=e[0]*t[0]+e[1]*t[2],s=e[0]*t[1]+e[1]*t[3],n=e[2]*t[0]+e[3]*t[2],r=e[2]*t[1]+e[3]*t[3],a=(i+r)/2,l=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,c=a+l||1,h=a-l||1;return[Math.sqrt(c),Math.sqrt(h)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),s=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>s)return null;let n=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return n>r?null:[i,n,s,r]}static#t(e,t,i,s,n,r,a,l,c,h){if(c<=0||c>=1)return;let d=1-c,u=c*c,p=u*c,f=d*(d*(d*e+3*c*t)+3*u*i)+p*s,g=d*(d*(d*n+3*c*r)+3*u*a)+p*l;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],g)}static#e(e,t,i,s,n,r,a,l,c,h,d,u){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&this.#t(e,t,i,s,n,r,a,l,-d/h,u);return}let p=h**2-4*d*c;if(p<0)return;let f=Math.sqrt(p),g=2*c;this.#t(e,t,i,s,n,r,a,l,(-h+f)/g,u),this.#t(e,t,i,s,n,r,a,l,(-h-f)/g,u)}static bezierBoundingBox(e,t,i,s,n,r,a,l,c){return c?(c[0]=Math.min(c[0],e,a),c[1]=Math.min(c[1],t,l),c[2]=Math.max(c[2],e,a),c[3]=Math.max(c[3],t,l)):c=[Math.min(e,a),Math.min(t,l),Math.max(e,a),Math.max(t,l)],this.#e(e,i,n,a,t,s,r,l,3*(-e+3*(i-n)+a),6*(e-2*i+n),3*(i-e),c),this.#e(e,i,n,a,t,s,r,l,3*(-t+3*(s-r)+l),6*(t-2*s+r),3*(s-t),c),c}};function Pa(o){return decodeURIComponent(escape(o))}var gs=null,Cr=null;function Ta(o){return gs||(gs=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Cr=new Map([["\uFB05","\u017Ft"]])),o.replaceAll(gs,(e,t,i)=>t?t.normalize("NFKC"):Cr.get(i))}function Ma(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let o=new Uint8Array(32);return crypto.getRandomValues(o),Vr(o)}var Vn="pdfjs_internal_id_";function Ra(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(Vr(o))}typeof Promise.try!="function"&&(Promise.try=function(o,...e){return new Promise(t=>{t(o(...e))})});var te="http://www.w3.org/2000/svg",ae=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};function es(o,e="text"){return I(this,null,function*(){if(Be(o,document.baseURI)){let t=yield fetch(o);if(!t.ok)throw new Error(t.statusText);switch(e){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json()}return t.text()}return new Promise((t,i)=>{let s=new XMLHttpRequest;s.open("GET",o,!0),s.responseType=e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(e){case"arraybuffer":case"blob":case"json":t(s.response);return}t(s.responseText);return}i(new Error(s.statusText))}},s.send(null)})})}var $e=class o{constructor({viewBox:e,userUnit:t,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=e,this.userUnit=t,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=t;let l=(e[2]+e[0])/2,c=(e[3]+e[1])/2,h,d,u,p;switch(s%=360,s<0&&(s+=360),s){case 180:h=-1,d=0,u=0,p=1;break;case 90:h=0,d=1,u=1,p=0;break;case 270:h=0,d=-1,u=-1,p=0;break;case 0:h=1,d=0,u=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,p=-p);let f,g,b,m;h===0?(f=Math.abs(c-e[1])*i+n,g=Math.abs(l-e[0])*i+r,b=(e[3]-e[1])*i,m=(e[2]-e[0])*i):(f=Math.abs(l-e[0])*i+n,g=Math.abs(c-e[1])*i+r,b=(e[2]-e[0])*i,m=(e[3]-e[1])*i),this.transform=[h*i,d*i,u*i,p*i,f-h*i*l-u*i*c,g-d*i*l-p*i*c],this.width=b,this.height=m}get rawDims(){let{userUnit:e,viewBox:t}=this,i=t.map(s=>s*e);return j(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new o({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(e,t){return D.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=D.applyTransform([e[0],e[1]],this.transform),i=D.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],i[0],i[1]]}convertToPdfPoint(e,t){return D.applyInverseTransform([e,t],this.transform)}},Ue=class extends oe{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}};function is(o){let e=o.length,t=0;for(;t<e&&o[t].trim()==="";)t++;return o.substring(t,t+5).toLowerCase()==="data:"}
1function zn(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function Ia(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function La(o,e="document.pdf"){if(typeof o!="string")return e;if(is(o))return U('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let t=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=t.exec(o),n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}var wi=class{started=Object.create(null);times=[];time(e){e in this.started&&U(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||U(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:i}of this.times)t=Math.max(i.length,t);for(let{name:i,start:s,end:n}of this.times)e.push(`${i.padEnd(t)} ${n-s}ms 2`);return e.join("")}};function Be(o,e){try{let{protocol:t}=e?new URL(o,e):new URL(o);return t==="http:"||t==="https:"}catch{return!1}}function zt(o){o.preventDefault()}function It(o){o.preventDefault(),o.stopPropagation()}var Ai=class{static#t;static toDateObject(e){if(!e||typeof e!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let t=this.#t.exec(e);if(!t)return null;let i=parseInt(t[1],10),s=parseInt(t[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(t[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(t[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;let c=t[7]||"Z",h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(t[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(r+=h,a+=d):c==="+"&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,l))}};function Oa(o,{scale:e=1,rotation:t=0}){let{width:i,height:s}=o.attributes.style,n=[0,0,parseInt(i),parseInt(s)];return new $e({viewBox:n,userUnit:1,scale:e,rotation:t})}function $n(o){if(o.startsWith("#")){let e=parseInt(o.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(e=>parseInt(e)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(U(`Not a valid color format: "${o}"`),[0,0,0])}function Da(o){let e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(let t of o.keys()){e.style.color=t;let i=window.getComputedStyle(e).color;o.set(t,$n(i))}e.remove()}function et(o){let{a:e,b:t,c:i,d:s,e:n,f:r}=o.getTransform();return[e,t,i,s,n,r]}function Kt(o){let{a:e,b:t,c:i,d:s,e:n,f:r}=o.getTransform().invertSelf();return[e,t,i,s,n,r]}function fe(o,e,t=!1,i=!0){if(e instanceof $e){let{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=o,a=bt.isCSSRoundSupported,l=`var(--scale-factor) * ${s}px`,c=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,d=a?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!t||e.rotation%180===0?(r.width=h,r.height=d):(r.width=d,r.height=h)}i&&o.setAttribute("data-main-rotation",e.rotation)}var je=class{constructor(){let e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},ys=class o{#t=null;#e=null;#i;#s=null;#r=null;static#n=null;constructor(e){this.#i=e,o.#n||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let e=this.#t=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");let t=this.#i._uiManager._signal;e.addEventListener("contextmenu",zt,{signal:t}),e.addEventListener("pointerdown",o.#l,{signal:t});let i=this.#s=document.createElement("div");i.className="buttons",e.append(i);let s=this.#i.toolbarPosition;if(s){let{style:n}=e,r=this.#i._uiManager.direction==="ltr"?1-s[0]:s[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),e}get div(){return this.#t}static#l(e){e.stopPropagation()}#o(e){this.#i._focusEventsAllowed=!1,It(e)}#h(e){this.#i._focusEventsAllowed=!0,It(e)}#c(e){let t=this.#i._uiManager._signal;e.addEventListener("focusin",this.#o.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#h.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",zt,{signal:t})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown()}#u(){let{editorType:e,_uiManager:t}=this.#i,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",o.#n[e]),this.#c(i),i.addEventListener("click",
2s=>{t.delete()},{signal:t._signal}),this.#s.append(i)}get#d(){let e=document.createElement("div");return e.className="divider",e}addAltText(e){return I(this,null,function*(){let t=yield e.render();this.#c(t),this.#s.prepend(t,this.#d),this.#r=e})}addColorPicker(e){this.#e=e;let t=e.renderButton();this.#c(t),this.#s.prepend(t,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},ws=class{#t=null;#e=null;#i;constructor(e){this.#i=e}#s(){let e=this.#e=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",zt,{signal:this.#i._signal});let t=this.#t=document.createElement("div");return t.className="buttons",e.append(t),this.#n(),e}#r(e,t){let i=0,s=0;for(let n of e){let r=n.y+n.height;if(r<i)continue;let a=n.x+(t?n.width:0);if(r>i){s=a,i=r;continue}t?a>s&&(s=a):a<s&&(s=a)}return[t?1-s:s,i]}show(e,t,i){let[s,n]=this.#r(t,i),{style:r}=this.#e||=this.#s();e.append(this.#e),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(){let e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let i=this.#i._signal;e.addEventListener("contextmenu",zt,{signal:i}),e.addEventListener("click",()=>{this.#i.highlightSelection("floating_button")},{signal:i}),this.#t.append(e)}};function Ci(o,e,t){for(let i of t)e.addEventListener(i,o[i].bind(o))}var As=class{#t=0;get id(){return`${_a}${this.#t++}`}},Cs=class o{#t=Ma();#e=0;#i=null;static get _isSVGFittingCanvas(){let e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=e;let n=s.decode().then(()=>(i.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0]===0));return j(this,"_isSVGFittingCanvas",n)}#s(e,t){return I(this,null,function*(){this.#i||=new Map;let i=this.#i.get(e);if(i===null)return null;if(i?.bitmap)return i.refCounter+=1,i;try{i||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let s;if(typeof t=="string"?(i.url=t,s=yield es(t,"blob")):t instanceof File?s=i.file=t:t instanceof Blob&&(s=t),s.type==="image/svg+xml"){let n=o._isSVGFittingCanvas,r=new FileReader,a=new Image,l=new Promise((c,h)=>{a.onload=()=>{i.bitmap=a,i.isSvg=!0,c()},r.onload=()=>I(this,null,function*(){let d=i.svgUrl=r.result;a.src=(yield n)?`${d}#svgView(preserveAspectRatio(none))`:d}),a.onerror=r.onerror=h});r.readAsDataURL(s),yield l}else i.bitmap=yield createImageBitmap(s);i.refCounter=1}catch(s){U(s),i=null}return this.#i.set(e,i),i&&this.#i.set(i.id,i),i})}getFromFile(e){return I(this,null,function*(){let{lastModified:t,name:i,size:s,type:n}=e;return this.#s(`${t}_${i}_${s}_${n}`,e)})}getFromUrl(e){return I(this,null,function*(){return this.#s(e,e)})}getFromBlob(e,t){return I(this,null,function*(){let i=yield t;return this.#s(e,i)})}getFromId(e){return I(this,null,function*(){this.#i||=new Map;let t=this.#i.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:i}=t;return delete t.blobPromise,this.getFromBlob(t.id,i)}return this.getFromUrl(t.url)})}getFromCanvas(e,t){this.#i||=new Map;let i=this.#i.get(e);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(t.width,t.height);return s.getContext("2d").drawImage(t,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(e,i),this.#i.set(i.id,i),i}getSvgUrl(e){let t=this.#i.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#i||=new Map;let t=this.#i.get(e);if(!t||(t.refCounter-=1,t.refCounter!==0))return;let{bitmap:i}=t;if(!t.url&&!t.file){let s=new OffscreenCanvas(i.width,i.height);s.getContext("bitmaprenderer").transferFromImageBitmap(i),t.blobPromise=s.convertToBlob()}i.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#t}_`)}},Ss=class{#t=[];#e=!1;#i;#s=-1;constructor(e=128){this.#i=e}add({cmd:e,undo:t,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&e(),this.#e)return;let l={cmd:e,undo:t,post:i,type:n};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(l);return}if(r&&this.#t[this.#s].type===n){a&&(l.undo=this.#t[this.#s].undo),this.#t[this.#s]=l;return}let c=this.#s+1;c===this.#i?this.#t.splice(0,1):(this.#s=c,c<this.#t.length&&this.#t.splice(c)),this.#t.push(l)}undo(){if(this.#s===-1)return;this.#e=!0;let{undo:e,post:t}=this.#t[this.#s];e(),t?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:e,post:t}=this.#t[this.#s];e(),t?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(e){if(this.#s!==-1){for(let t=this.#s;t>=0;t--)if(this.#t[t].type!==e){this.#t.splice(t+1,this.#s-t),this.#s=t;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}},ge=class{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=bt.platform;for(let[i,s,n={}]of e)for(let r of i){let a=r.startsWith("mac+");t&&a?(this.callbacks.set(r.slice(4),{callback:s,options:n}),this.allKeys.add(r.split("+").at(-1))):!t&&!a&&(this.callbacks.set(r,{callback:s,options:n}),this.allKeys.add(r.split("+").at(-1)))}}#t(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);let t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let i=this.callbacks.get(this.#t(t));if(!i)return;let{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(e,t)||(s.bind(e,...r,t)(),n||It(t))}},Es=class o{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return Da(e),j(this,"_colors",e)}convert(e){let t=$n(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[i,s]of this._colors)if(s.every((n,r)=>n===t[r]))return o._colorsMapping.get(i);return t}getHexCode(e){let t=this._colors.get(e);return t?D.makeHexColor(...t):e}},Ge=(()=>{class o{#t=new AbortController;#e=null;#i=new Map;#s=new Map;#r=null;#n=null;#l=null;#o=new Ss;#h=null;#c=null;#u=0;#d=new Set;#p=null;#a=null;#f=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#x=null;#_=null;#y=null;#A=null;#S=!1;#k=null;#T=new As;#w=!1;#P=!1;#E=null;#R=null;#O=null;#F=null;#C=$.NONE;#v=new Set;#L=null;#z=null;#$=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#D=null;#B=null;#j=null;#I=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;
vendor: 4,181 bytes, line 2
2static get _keyboardManager(){let t=o.prototype,i=a=>a.#B.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:l})=>{if(l instanceof HTMLInputElement){let{type:c}=l;return c!=="text"&&c!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return j(this,"_keyboardManager",new ge([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:l})=>!(l instanceof HTMLButtonElement)&&a.#B.contains(l)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:l})=>!(l instanceof HTMLButtonElement)&&a.#B.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,i,s,n,r,a,l,c,h,d,u,p,f){let g=this._signal=this.#t.signal;this.#B=t,this.#j=i,this.#r=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:g}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),n._on("setpreference",this.onSetPreference.bind(this),{signal:g}),n._on("switchannotationeditorparams",b=>this.updateParams(b.type,b.value),{signal:g}),this.#et(),this.#rt(),this.#q(),this.#n=r.annotationStorage,this.#x=r.filterFactory,this.#z=a,this.#A=l||null,this.#m=c,this.#g=h,this.#b=d,this.#F=u||null,this.viewParameters={realScale:ae.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#I?.resolve(),this.#I=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#s.values())t.destroy();this.#s.clear(),this.#i.clear(),this.#f.clear(),this.#e=null,this.#v.clear(),this.#o.destroy(),this.#r?.destroy(),this.#k?.hide(),this.#k=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#D&&(clearTimeout(this.#D),this.#D=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return j(this,"hcmFilter",this.#z?this.#x.addHCMFilter(this.#z.foreground,this.#z.background):"none")}get direction(){return j(this,"direction",getComputedStyle(this.#B).direction)}get highlightColors(){return j(this,"highlightColors",this.#A?new Map(this.#A.split(",").map(t=>t.split("=").map(i=>i.trim()))):null)}get highlightColorNames(){return j(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#c=t}setMainHighlightColorPicker(t){this.#O=t}editAltText(t,i=!1){this.#r?.editAltText(this,t,i)}switchToMode(t,i){this._eventBus.on("annotationeditormodechanged",i,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,i){this._eventBus.dispatch("setpreference",{source:this,name:t,value:i})}onSetPreference({name:t,value:i}
2){switch(t){case"enableNewAltTextWhenAddingImage":this.#b=i;break}}onPageChanging({pageNumber:t}){this.#u=t-1}focusMainContainer(){this.#B.focus()}findParent(t,i){for(let s of this.#s.values()){let{x:n,y:r,width:a,height:l}=s.div.getBoundingClientRect();if(t>=n&&t<=n+a&&i>=r&&i<=r+l)return s}return null}disableUserSelect(t=!1){this.#j.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#f.add(t)}removeShouldRescale(t){this.#f.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*ae.PDF_TO_CSS_UNITS;for(let i of this.#f)i.onScaleChanging();this.#c?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#H({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:i}=this;if(i.hasTextLayer(t))return i;for(let s of this.#s.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t=""){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,l=i.toString(),h=this.#H(i).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;i.empty();let u=this.#X(h),p=this.#C===$.NONE,f=()=>{u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:l}),p&&this.showAllEditors("highlight",!0,!0)};if(p){this.switchToMode($.HIGHLIGHT,f);return}f()}#J(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#H(t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(this.#k||=new ws(this),this.#k.show(s,n,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#n&&!this.#n.has(t.id)&&this.#n.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#L&&(this.#k?.hide(),this.#L=null,this.#M({hasSelectedText:!1}));return}let{anchorNode:i}=t;if(i===this.#L)return;let n=this.#H(t).closest(".textLayer");if(!n){this.#L&&(this.#k?.hide(),this.#L=null,this.#M({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#L=i,this.#M({hasSelectedText:!0}),!(this.#C!==$.HIGHLIGHT&&this.#C!==$.NONE)&&(this.#C===$.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){let r=this.#C===$.HIGHLIGHT?this.#X(n):null;r?.toggleDrawing();let a=new AbortController,l=this.combinedSignal(a),c=h=>{h.type==="pointerup"&&h.button!==0||(a.abort(),r?.toggleDrawing(!0),h.type==="pointerup"&&this.#W("main_toolbar"))};window.addEventListener("pointerup",c,{signal:l}),window.addEventListener("blur",c,{signal:l})}}#W(t=""){this.#C===$.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#J()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#it(){if(this.#y)return;this.#y=new AbortController;let t=this.combinedSignal(this.#y);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#st(){this.#y?.abort(),this.#y=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#W("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let i of this.#v)if(i.div.contains(t)){this.#R=[i,t],i._focusEventsAllowed=!1;break}}focus(){if(!this.#R)return;let[t,i]=this.#R;this.#R=null,i.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),i.focus()}#q(){if(this.#E)return;this.#E=new AbortController;let t=this.combinedSignal(this.#E);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#nt(){this.#E?.abort(),this.#E=null}#K(){if(this.#h)return;this.#h=new AbortController;let t=this.combinedSignal(this.#h);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Y(){this.#h?.abort(),this.#h=null}#rt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#q(),this.#K()}removeEditListeners(){this.#nt(),this.#Y()}dragOver(t){for(let{type:i}of t.dataTransfer.items)for(let s of this.#a)if(s.isHandlingMimeForPasting(i)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let i of t.dataTransfer.items)for(let s of this.#a)if(s.isHandlingMimeForPasting(i.type)){s.paste(i,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let i=[];for(let s of this.#v){let n=s.serialize(!0);n&&i.push(n)}i.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}paste(t){return I(this,null,function*(){t.preventDefault();let{clipboardData:i}=t;
2for(let r of i.items)for(let a of this.#a)if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=i.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){U(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let n=this.currentLayer;try{let r=[];for(let c of s){let h=yield n.deserialize(c);if(!h)return;r.push(h)}let a=()=>{for(let c of r)this.#Q(c);this.#Z(r)},l=()=>{for(let c of r)c.remove()};this.addCommands({cmd:a,undo:l,mustExec:!0})}catch(r){U(`paste: "${r.message}".`)}})}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==$.NONE&&!this.isEditorHandlingKeyboard&&o._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#W("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#M(t){Object.entries(t).some(([s,n])=>this.#U[s]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#U,t)}),this.#C===$.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#V([[W.HIGHLIGHT_FREE,!0]]))}#V(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#it(),this.#K(),this.#M({isEditing:this.#C!==$.NONE,isEmpty:this.#G(),hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:this.#o.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#st(),this.#Y(),this.#M({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#a){this.#a=t;for(let i of this.#a)this.#V(i.defaultPropertiesToUpdate)}}getId(){return this.#T.id}get currentLayer(){return this.#s.get(this.#u)}getLayer(t){return this.#s.get(t)}get currentPageIndex(){return this.#u}addLayer(t){this.#s.set(t.pageIndex,t),this.#w?t.enable():t.disable()}removeLayer(t){this.#s.delete(t.pageIndex)}updateMode(t,i=null,s=!1){return I(this,null,function*(){if(this.#C!==t&&!(this.#I&&(yield this.#I.promise,!this.#I))){if(this.#I=Promise.withResolvers(),this.#C=t,t===$.NONE){this.setEditingState(!1),this.#ot(),this._editorUndoBar?.hide(),this.#I.resolve();return}this.setEditingState(!0),yield this.#at(),this.unselectAll();for(let n of this.#s.values())n.updateMode(t);if(!i){s&&this.addNewEditorFromKeyboard(),this.#I.resolve();return}for(let n of this.#i.values())n.annotationElementId===i?(this.setSelected(n),n.enterInEditMode()):n.unselect();this.#I.resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,i){if(this.#a){switch(t){case W.CREATE:this.currentLayer.addNewEditor();return;case W.HIGHLIGHT_DEFAULT_COLOR:this.#O?.updateColor(i);break;case W.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#$||=new Map).set(t,i),this.showAllEditors("highlight",i);break}for(let s of this.#v)s.updateParams(t,i);for(let s of this.#a)s.updateDefaultParams(t,i)}}showAllEditors(t,i,s=!1){for(let r of this.#i.values())r.editorType===t&&r.show(i);(this.#$?.get(W.HIGHLIGHT_SHOW_ALL)??!0)!==i&&this.#V([[W.HIGHLIGHT_SHOW_ALL,i]])}enableWaiting(t=!1){if(this.#P!==t){this.#P=t;for(let i of this.#s.values())t?i.disableClick():i.enableClick(),i.div.classList.toggle("waiting",t)}}#at(){return I(this,null,function*(){if(!this.#w){this.#w=!0;let t=[];for(let i of this.#s.values())t.push(i.enable());yield Promise.all(t);for(let i of this.#i.values())i.enable()}})}#ot(){if(this.unselectAll(),this.#w){this.#w=!1;for(let t of this.#s.values())t.disable();for(let t of this.#i.values())t.disable()}}getEditors(t){let i=[];for(let s of this.#i.values())s.pageIndex===t&&i.push(s);return i}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#i.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#n?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
2isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let i=this.#s.get(t.pageIndex);i?i.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#V(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#lt===t&&this.#V(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#V(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#M({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#V(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}setSelected(t){this.#c?.commitOrRemove();for(let i of this.#v)i!==t&&i.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#V(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#M({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#o.undo(),this.#M({hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#G()}),this._editorUndoBar?.hide()}redo(){this.#o.redo(),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:this.#o.hasSomethingToRedo(),isEmpty:this.#G()})}addCommands(t){this.#o.add(t),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#G()})}cleanUndoStack(t){this.#o.cleanType(t)}#G(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(let t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let i=t?[t]:[...this.#v],s=()=>{this._editorUndoBar?.show(n,i.length===1?i[0].editorType:i.length);for(let r of i)r.remove()},n=()=>{for(let r of i)this.#Q(r)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#Z(t){for(let i of this.#v)i.unselect();this.#v.clear();for(let i of t)i.isEmpty()||(this.#v.add(i),i.select());this.#M({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#Z(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==$.NONE))&&!this.#c?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#M({hasSelectedEditor:!1})}}translateSelectedEditors(t,i,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=i;let[n,r]=this.#N,a=[...this.#v],l=1e3;this.#D&&clearTimeout(this.#D),this.#D=setTimeout(()=>{this.#D=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let c of a)this.#i.has(c.id)&&c.translateInPage(n,r)},undo:()=>{for(let c of a)this.#i.has(c.id)&&c.translateInPage(-n,-r)},mustExec:!1})},l);for(let c of a)c.translateInPage(t,i)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(let t of this.#v)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);let t=this.#p;this.#p=null;let i=!1;for(let[{x:n,y:r,pageIndex:a},l]of t)l.newX=n,l.newY=r,l.newPageIndex=a,i||=n!==l.savedX||r!==l.savedY||a!==l.savedPageIndex;if(!i)return!1;let s=(n,r,a,l)=>{if(this.#i.has(n.id)){let c=this.#s.get(l);c?n._setParentAndPosition(c,r,a):(n.pageIndex=l,n.x=r,n.y=a)}};return this.addCommands({cmd:()=>{for(let[n,{newX:r,newY:a,newPageIndex:l}]of t)s(n,r,a,l)},undo:()=>{for(let[n,{savedX:r,savedY:a,savedPageIndex:l}]of t)s(n,r,a,l)},mustExec:!0}),!0}dragSelectedEditors(t,i){if(this.#p)for(let s of this.#p.keys())s.drag(t,i)}rebuild(t){if(t.parent===null){let i=this.getLayer(t.pageIndex);i?(i.changeParent(t),i.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.
2size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return j(this,"imageManager",new Cs)}getSelectionBoxes(t){if(!t)return null;let i=document.getSelection();for(let h=0,d=i.rangeCount;h<d;h++)if(!t.contains(i.getRangeAt(h).commonAncestorContainer))return null;let{x:s,y:n,width:r,height:a}=t.getBoundingClientRect(),l;switch(t.getAttribute("data-main-rotation")){case"90":l=(h,d,u,p)=>({x:(d-n)/a,y:1-(h+u-s)/r,width:p/a,height:u/r});break;case"180":l=(h,d,u,p)=>({x:1-(h+u-s)/r,y:1-(d+p-n)/a,width:u/r,height:p/a});break;case"270":l=(h,d,u,p)=>({x:1-(d+p-n)/a,y:(h-s)/r,width:p/a,height:u/r});break;default:l=(h,d,u,p)=>({x:(h-s)/r,y:(d-n)/a,width:u/r,height:p/a});break}let c=[];for(let h=0,d=i.rangeCount;h<d;h++){let u=i.getRangeAt(h);if(!u.collapsed)for(let{x:p,y:f,width:g,height:b}of u.getClientRects())g===0||b===0||c.push(l(p,f,g,b))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:t,id:i}){(this.#l||=new Map).set(t,i)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let i=this.#l?.get(t.data.id);if(!i)return;let s=this.#n.getRawValue(i);s&&(this.#C===$.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}return o})(),Sr=(()=>{class o{#t=null;#e=!1;#i=null;#s=null;#r=null;#n=null;#l=!1;#o=null;#h=null;#c=null;#u=null;#d=!1;static#p=null;static _l10n=null;constructor(t){this.#h=t,this.#d=t._uiManager.useNewAltTextFlow,o.#p||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){o._l10n??=t}render(){return I(this,null,function*(){let t=this.#i=document.createElement("button");t.className="altText",t.tabIndex="0";let i=this.#s=document.createElement("span");t.append(i),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",o.#p.missing),i.setAttribute("data-l10n-id",o.#p["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let s=this.#h._uiManager._signal;t.addEventListener("contextmenu",zt,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});let n=r=>{r.preventDefault(),this.#h._uiManager.editAltText(this.#h),this.#d&&this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#a}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#l=!0,n(r))},{signal:s}),yield this.#f(),t})}get#a(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}setGuessedText(t){return I(this,null,function*(){this.#t===null&&(this.#c=t,this.#u=yield o._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#f())})}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let i=this.#o=document.createElement("div");i.className="noAltTextBadge",this.#h.div.append(i)}this.#o.classList.toggle("hidden",!t)}serialize(t){let i=this.#t;return!t&&this.#c===i&&(i=this.#u),{altText:i,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:i,guessedText:s,textWithDisclaimer:n,cancel:r=!1}){s&&(this.#c=s,this.#u=n),!(this.#t===t&&this.#e===i)&&(r||(this.#t=t,this.#e=i),this.#f())}toggle(t=!1){this.#i&&(!t&&this.#n&&(clearTimeout(this.#n),this.#n=null),this.#i.disabled=!t)}shown(){this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#a}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#r=null,this.#o?.remove(),this.#o=null}#f(){return I(this,null,function*(){let t=this.#i;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",o.#p[this.#a]),this.#s?.setAttribute("data-l10n-id",o.#p[`${this.#a}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=this.#r;if(!i){this.#r=i=document.createElement("span"),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${this.#h.id}`;let n=100,r=this.#h._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#h._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#n&&(clearTimeout(this.#n),this.#n=null),this.#r?.classList.remove("show")},{signal:r})}this.#e?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=this.#t),i.parentNode||t.append(i),this.#h.getImageForAltText()?.setAttribute("aria-describedby",i.id)})}}return o}
2)(),Si=class o{#t;#e=!1;#i=null;#s;#r;#n;#l;#o;#h=null;#c;#u=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#t=e,this.#i=i,this.#s=t,this.#r=s,this.#n=n,this.#l=r,this.#c=new AbortController,this.#o=AbortSignal.any([a,this.#c.signal]),e.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#o})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return j(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#d(e){if(this.#s?.()||e.touches.length<2)return;if(!this.#u){this.#u=new AbortController;let s=AbortSignal.any([this.#o,this.#u.signal]),n=this.#t,r={signal:s,passive:!1};n.addEventListener("touchmove",this.#p.bind(this),r),n.addEventListener("touchend",this.#a.bind(this),r),n.addEventListener("touchcancel",this.#a.bind(this),r),this.#r?.()}if(It(e),e.touches.length!==2||this.#i?.()){this.#h=null;return}let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]),this.#h={touch0X:t.screenX,touch0Y:t.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#p(e){if(!this.#h||e.touches.length!==2)return;let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]);let{screenX:s,screenY:n}=t,{screenX:r,screenY:a}=i,l=this.#h,{touch0X:c,touch0Y:h,touch1X:d,touch1Y:u}=l,p=d-c,f=u-h,g=r-s,b=a-n,m=Math.hypot(g,b)||1,x=Math.hypot(p,f)||1;if(!this.#e&&Math.abs(x-m)<=o.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=s,l.touch0Y=n,l.touch1X=r,l.touch1Y=a,e.preventDefault(),!this.#e){this.#e=!0;return}let y=[(s+r)/2,(n+a)/2];this.#n?.(y,x,m)}#a(e){this.#u.abort(),this.#u=null,this.#l?.(),this.#h&&(e.preventDefault(),this.#h=null,this.#e=!1)}destroy(){this.#c?.abort(),this.#c=null}},it=class o{#t=null;#e=null;#i=null;#s=!1;#r=null;#n="";#l=!1;#o=null;#h=null;#c=null;#u=null;#d="";#p=!1;#a=null;#f=!1;#m=!1;#g=!1;#b=null;#x=0;#_=0;#y=null;#A=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#S=!1;#k=o._zIndex++;static _borderLineWidth=-1;static _colorManager=new Es;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let e=o.prototype._resizeWithKeyboard,t=Ge.TRANSLATE_SMALL,i=Ge.TRANSLATE_BIG;return j(this,"_resizerKeyboardManager",new ge([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,i]}],[["Escape","mac+Escape"],o.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];let[a,l]=this.parentDimensions;this.x=e.x/a,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return j(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new ks({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(o._l10n??=e,o._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),o._borderLineWidth!==-1)return;let i=getComputedStyle(document.documentElement);o._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Z("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(e){this.#S=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#k}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#H(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#p?this.#p=!1:this.parent.setSelected(this))}focusout(e){!this._focusEventsAllowed||!this.isAttachedToDOM||e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,i,s){let[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(e+i)/n,this.y=(t+s)/r,this.fixAndSetPosition()}#T([e,t],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/e,this.y+=s/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#T(this.parentDimensions,e,t)}translateInPage(e,t){this.#a||=[this.x,this.y,this.width,this.height],this.#T(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#a||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,n]}=this;if(this.x+=e/s,this.y+=t/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this,[l,c]=this.getBaseTranslation();r+=l,a+=c;let{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}get _hasBeenResized(){return!!this.#a&&(this.#a[2]!==this.width||this.#a[3]!==this.height)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:i}=o,s=i/e,n=i/t;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[i,s]}=this,{x:n,y:r,width:a,height:l}=this;if(a*=i,l*=s,n*=i,r*=s,this._mustFixPosition)switch(e){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-l,r));break;case 90:n=Math.max(0,Math.min(i-l,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(l,r));break;case 270:n=Math.min(i,Math.max(l,n)),r=Math.max(0,Math.min(s-a,r));break}this.x=n/=i,this.y=r/=s;let[c,h]=this.getBaseTranslation();n+=c,r+=h,t.left=`${(100*n).toFixed(2)}%`,t.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#w(e,t,i){switch(i){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return o.#w(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return o.#w(e,t,360-this.parentRotation)}#P(e){switch(e){case 90:{let[t,i]=this.pageDimensions;return[0,-t/i,i/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,i]=this.pageDimensions;return[0,t/i,-i/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,i]}=this;return[t*e,i*e]}setDims(e,t){let[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*e/i).toFixed(2)}%`,this.#l||(n.height=`${(100*t/s).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:i}=e,s=i.endsWith("%"),n=!this.#l&&t.endsWith("%");if(s&&n)return;let[r,a]=this.parentDimensions;s||(e.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),!this.#l&&!n&&(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#E(){if(this.#o)return;this.#o=document.createElement("div"),this.#o.classList.add("resizers");let e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(let i of e){let s=document.createElement("div");this.#o.append(s),s.classList.add("resizer",i),s.setAttribute("data-resizer-name",i),s.addEventListener("pointerdown",this.#R.bind(this,i),{signal:t}),s.addEventListener("contextmenu",zt,{signal:t}),s.tabIndex=-1}this.div.prepend(this.#o)}#R(e,t){t.preventDefault();let{isMac:i}=bt.platform;if(t.button!==0||t.ctrlKey&&i)return;this.#i?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#h=[t.screenX,t.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,e),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",It,{passive:!1,signal:r}),window.addEventListener("contextmenu",zt,{signal:r}),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;
2let c=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=l,this.#F()};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})}#O(e,t,i,s){this.width=i,this.height=s,this.x=e,this.y=t;let[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#F(){if(!this.#c)return;let{savedX:e,savedY:t,savedWidth:i,savedHeight:s}=this.#c;this.#c=null;let n=this.x,r=this.y,a=this.width,l=this.height;n===e&&r===t&&a===i&&l===s||this.addCommands({cmd:this.#O.bind(this,n,r,a,l),undo:this.#O.bind(this,e,t,i,s),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#C(e,t){let[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,l=this.height,c=o.MIN_SIZE/i,h=o.MIN_SIZE/s,d=this.#P(this.rotation),u=(O,N)=>[d[0]*O+d[2]*N,d[1]*O+d[3]*N],p=this.#P(360-this.rotation),f=(O,N)=>[p[0]*O+p[2]*N,p[1]*O+p[3]*N],g,b,m=!1,x=!1;switch(e){case"topLeft":m=!0,g=(O,N)=>[0,0],b=(O,N)=>[O,N];break;case"topMiddle":g=(O,N)=>[O/2,0],b=(O,N)=>[O/2,N];break;case"topRight":m=!0,g=(O,N)=>[O,0],b=(O,N)=>[0,N];break;case"middleRight":x=!0,g=(O,N)=>[O,N/2],b=(O,N)=>[0,N/2];break;case"bottomRight":m=!0,g=(O,N)=>[O,N],b=(O,N)=>[0,0];break;case"bottomMiddle":g=(O,N)=>[O/2,N],b=(O,N)=>[O/2,0];break;case"bottomLeft":m=!0,g=(O,N)=>[0,N],b=(O,N)=>[O,0];break;case"middleLeft":x=!0,g=(O,N)=>[0,N/2],b=(O,N)=>[O,N/2];break}let y=g(a,l),A=b(a,l),C=u(...A),P=o._round(n+C[0]),S=o._round(r+C[1]),B=1,H=1,X,G;if(t.fromKeyboard)({deltaX:X,deltaY:G}=t);else{let{screenX:O,screenY:N}=t,[Lt,$t]=this.#h;[X,G]=this.screenToPageTranslation(O-Lt,N-$t),this.#h[0]=O,this.#h[1]=N}if([X,G]=f(X/i,G/s),m){let O=Math.hypot(a,l);B=H=Math.max(Math.min(Math.hypot(A[0]-y[0]-X,A[1]-y[1]-G)/O,1/a,1/l),c/a,h/l)}else x?B=Math.max(c,Math.min(1,Math.abs(A[0]-y[0]-X)))/a:H=Math.max(h,Math.min(1,Math.abs(A[1]-y[1]-G)))/l;let st=o._round(a*B),ut=o._round(l*H);C=u(...b(st,ut));let Q=P-C[0],Et=S-C[1];this.#a||=[this.x,this.y,this.width,this.height],this.width=st,this.height=ut,this.x=Q,this.y=Et,this.setDims(i*st,s*ut),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}addEditToolbar(){return I(this,null,function*(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new ys(this),this.div.append(this._editToolbar.render()),this.#i&&(yield this._editToolbar.addAltText(this.#i)),this._editToolbar)})}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#i?.destroy())}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){return I(this,null,function*(){this.#i||(Sr.initialize(o._l10n),this.#i=new Sr(this),this.#t&&(this.#i.data=this.#t,this.#t=null),yield this.addEditToolbar())})}get altTextData(){return this.#i?.data}set altTextData(e){this.#i&&(this.#i.data=e)}get guessedAltText(){return this.#i?.guessedText}setGuessedAltText(e){return I(this,null,function*(){yield this.#i?.setGuessedText(e)})}serializeAltText(e){return this.#i?.serialize(e)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#s?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#N();let[e,t]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[i,s]=this.getInitialTranslation();return this.translate(i,s),Ci(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#A||=new Si({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#z.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}
2#v(){this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(e,t,i){let n=.7*(i/t)+1-.7;if(n===1)return;let r=this.#P(this.rotation),a=(P,S)=>[r[0]*P+r[2]*S,r[1]*P+r[3]*S],[l,c]=this.parentDimensions,h=this.x,d=this.y,u=this.width,p=this.height,f=o.MIN_SIZE/l,g=o.MIN_SIZE/c;n=Math.max(Math.min(n,1/u,1/p),f/u,g/p);let b=o._round(u*n),m=o._round(p*n);if(b===u&&m===p)return;this.#a||=[h,d,u,p];let x=a(u/2,p/2),y=o._round(h+x[0]),A=o._round(d+x[1]),C=a(b/2,m/2);this.x=y-C[0],this.y=A-C[1],this.width=b,this.height=m,this.setDims(l*b,c*m),this.fixAndSetPosition(),this._onResizing()}#z(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#F()}pointerdown(e){let{isMac:t}=bt.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#p=!0,this._isDraggable){this.#U(e);return}this.#$(e)}get isSelected(){return this._uiManager.isSelected(this)}#$(e){let{isMac:t}=bt.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#U(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=c=>{s.abort(),this.#r=null,this.#p=!1,this._uiManager.endDragSession()||this.#$(c),i&&this._onStopDragging()};t&&(this.#x=e.clientX,this.#_=e.clientY,this.#r=e.pointerId,this.#n=e.pointerType,window.addEventListener("pointermove",c=>{i||(i=!0,this._onStartDragging());let{clientX:h,clientY:d,pointerId:u}=c;if(u!==this.#r){It(c);return}let[p,f]=this.screenToPageTranslation(h-this.#x,d-this.#_);this.#x=h,this.#_=d,this._uiManager.dragSelectedEditors(p,f)},r),window.addEventListener("touchmove",It,r),window.addEventListener("pointerdown",c=>{c.pointerType===this.#n&&(this.#A||c.isPrimary)&&a(c),It(c)},r));let l=c=>{if(!this.#r||this.#r===c.pointerId){a(c);return}It(c)};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,i){e.changeParent(this),this.x=t,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,i=this.rotation){let s=this.parentScale,[n,r]=this.pageDimensions,[a,l]=this.pageTranslation,c=e/s,h=t/s,d=this.x*n,u=this.y*r,p=this.width*n,f=this.height*r;switch(i){case 0:return[d+c+a,r-u-h-f+l,d+c+p+a,r-u-h+l];case 90:return[d+h+a,r-u+c+l,d+h+f+a,r-u+c+p+l];case 180:return[d-c-p+a,r-u+h+l,d-c+a,r-u+h+f+l];case 270:return[d-h-f+a,r-u-c-p+l,d-h+a,r-u-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[i,s,n,r]=e,a=n-i,l=r-s;switch(this.rotation){case 0:return[i,t-r,a,l];case 90:return[i,t-s,l,a];case 180:return[n,t-s,a,l];case 270:return[n,t-r,l,a];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return t<r&&s>0&&e<n&&i>0}#N(){if(this.#u||!this.div)return;this.#u=new AbortController;let e=this._uiManager.combinedSignal(this.#u);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#N()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Z("An editor must be serializable")}static deserialize(e,t,i){return I(this,null,function*(){let s=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:i});s.rotation=e.rotation,s.#t=e.accessibilityData;let[n,r]=s.pageDimensions,[a,l,c,h]=s.getRectInCurrentCoords(e.rect,r);return s.x=a/n,s.y=l/r,s.width=c/n,s.height=h/r,s})}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#H(),this.removeEditToolbar(),this.#y){for(let e of this.#y.values())clearTimeout(e);this.#y=null}this.parent=null,this.#A?.destroy(),this.#A=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#E(),this.#o.classList.remove("hidden"),Ci(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let t=this.#o.children;if(!this.#e){this.#e=Array.from(t);let r=this.#D.bind(this),a=this.#B.bind(this),l=this._uiManager._signal;for(let c of this.#e){let h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:l}),c.addEventListener("blur",a,{signal:l}),c.addEventListener("focus",this.#j.bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",o._l10nResizer[h])}}let i=this.#e[0],s=0;for(let r of t){if(r===i)break;s++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==s){if(n<s)for(let a=0;a<s-n;a++)this.#o.append(this.#o.firstChild);else if(n>s)for(let a=0;a<n-s;a++)this.#o.firstChild.before(this.#o.lastChild);let r=0;for(let a of t){let c=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",o._l10nResizer[c])}}this.#I(0),this.#g=!0,this.#o.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#D(e){o._resizerKeyboardManager.exec(this,e)}#B(e){this.#g&&e.relatedTarget?.parentNode!==this.#o&&this.#H()}#j(e){this.#d=this.#g?e:""}#I(e){if(this.#e)for(let t of this.#e)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#g&&this.#C(this.#d,{deltaX:e,deltaY:t,fromKeyboard:!0})}#H(){this.#g=!1,this.#I(-1),this.#F()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)}unselect(){this.#o?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#f}set isEditing(e){this.#f=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#l=!0;let i=e/t,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#y||=new Map;let{action:i}=e,s=this.#y.get(i);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(e),this.#y.delete(i),this.#y.size===0&&(this.#y=null)},o._telemetryTimeout),this.#y.set(i,s);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#s=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#s=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");
2if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){let i=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),i.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t?.nodeName==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}},ks=class extends it{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Er=3285377520,Ft=4294901760,Yt=65535,Ei=class{constructor(e){this.h1=e?e&4294967295:Er,this.h2=e?e&4294967295:Er}update(e){let t,i;if(typeof e=="string"){t=new Uint8Array(e.length*2),i=0;for(let g=0,b=e.length;g<b;g++){let m=e.charCodeAt(g);m<=255?t[i++]=m:(t[i++]=m>>>8,t[i++]=m&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),i=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,n=i-s*4,r=new Uint32Array(t.buffer,0,s),a=0,l=0,c=this.h1,h=this.h2,d=3432918353,u=461845907,p=d&Yt,f=u&Yt;for(let g=0;g<s;g++)g&1?(a=r[g],a=a*d&Ft|a*p&Yt,a=a<<15|a>>>17,a=a*u&Ft|a*f&Yt,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(l=r[g],l=l*d&Ft|l*p&Yt,l=l<<15|l>>>17,l=l*u&Ft|l*f&Yt,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,n){case 3:a^=t[s*4+2]<<16;case 2:a^=t[s*4+1]<<8;case 1:a^=t[s*4],a=a*d&Ft|a*p&Yt,a=a<<15|a>>>17,a=a*u&Ft|a*f&Yt,s&1?c^=a:h^=a}this.h1=c,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&Ft|e*36045&Yt,t=t*4283543511&Ft|((t<<16|e>>>16)*2950163797&Ft)>>>16,e^=t>>>1,e=e*444984403&Ft|e*60499&Yt,t=t*3301882366&Ft|((t<<16|e>>>16)*3120437893&Ft)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}},Ps=Object.freeze({map:null,hash:"",transfer:void 0}),We=class{#t=!1;#e=null;#i=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let i=this.#i.get(e);return i===void 0?t:Object.assign(t,i)}getRawValue(e){return this.#i.get(e)}remove(e){if(this.#i.delete(e),this.#i.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let t of this.#i.values())if(t instanceof it)return;this.onAnnotationEditor(null)}}setValue(e,t){let i=this.#i.get(e),s=!1;if(i!==void 0)for(let[n,r]of Object.entries(t))i[n]!==r&&(s=!0,i[n]=r);else s=!0,this.#i.set(e,t);s&&this.#s(),t instanceof it&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#i.has(e)}getAll(){return this.#i.size>0?Hn(this.#i):null}setAll(e){for(let[t,i]of Object.entries(e))this.setValue(t,i)}get size(){return this.#i.size}#s(){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 ki(this)}get serializable(){if(this.#i.size===0)return Ps;let e=new Map,t=new Ei,i=[],s=Object.create(null),n=!1;for(let[r,a]of this.#i){let l=a instanceof it?a.serialize(!1,s):a;l&&(e.set(r,l),t.update(`${r}:${JSON.stringify(l)}`),n||=!!l.bitmap)}if(n)for(let r of e.values())r.bitmap&&i.push(r.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:i}:Ps}get editorStats(){let e=null,t=new Map;for(let i of this.#i.values()){if(!(i instanceof it))continue;let s=i.telemetryFinalData;if(!s)continue;let{type:n}=s;t.has(n)||t.set(n,Object.getPrototypeOf(i).constructor),e||=Object.create(null);let r=e[n]||=new Map;for(let[a,l]of Object.entries(s)){if(a==="type")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));let h=c.get(l)??0;c.set(l,h+1)}}for(let[i,s]of t)e[i]=s.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let e=[];for(let t of this.#i.values())!(t instanceof it)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return this.#e={ids:new Set(e),hash:e.join(",")}}},ki=class extends We{#t;constructor(e){super();let{map:t,hash:i,transfer:s}=e.serializable,n=structuredClone(t,s?{transfer:s}:null);this.#t={map:n,hash:i,transfer:s}}get print(){Z("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return j(this,"modifiedIds",{ids:new Set,hash:""})}},Ts=class{#t=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(i){return I(this,arguments,function*({systemFontInfo:e,_inspectFont:t}
2){if(!(!e||this.#t.has(e.loadedName))){if(dt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:s,src:n,style:r}=e,a=new FontFace(s,n,r);this.addNativeFontFace(a);try{yield a.load(),this.#t.add(s),t?.(e)}catch{U(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}Z("Not implemented: loadSystemFont without the Font Loading API.")}})}bind(e){return I(this,null,function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){yield this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let i=e.createNativeFontFace();if(i){this.addNativeFontFace(i);try{yield i.loaded}catch(s){throw U(`Failed to load font '${i.family}': '${s}'.`),e.disableFontFace=!0,s}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise(i=>{let s=this._queueLoadingCallback(i);this._prepareFontLoadEvent(e,s)})}})}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return j(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;return(At||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),j(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){function t(){for(dt(!s.done,"completeRequest() cannot be called twice."),s.done=!0;i.length>0&&i[0].done;){let n=i.shift();setTimeout(n.callback,0)}}let{loadingRequests:i}=this,s={done:!1,complete:t,callback:e};return i.push(s),s}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return j(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function i(A,C){return A.charCodeAt(C)<<24|A.charCodeAt(C+1)<<16|A.charCodeAt(C+2)<<8|A.charCodeAt(C+3)&255}function s(A,C,P,S){let B=A.substring(0,C),H=A.substring(C+P);return B+S+H}let n,r,a=this._document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d"),c=0;function h(A,C){if(++c>30){U("Load test font never loaded."),C();return}if(l.font="30px "+A,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(h.bind(null,A,C))}let d=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=s(u,976,d.length,d);let f=16,g=1482184792,b=i(u,f);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+i(d,n)|0;n<d.length&&(b=b-g+i(d+"XXX",n)|0),u=s(u,f,4,Sa(b));let m=`url(data:font/opentype;base64,${btoa(u)});`,x=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(x);let y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(let A of[e.loadedName,d]){let C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=A,y.append(C)}this._document.body.append(y),h(d,()=>{y.remove(),t.complete()})}},Ms=class{constructor(e,{disableFontFace:t=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(let n in e)this[n]=e[n];this.disableFontFace=t===!0,this.fontExtraProperties=i===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${Ra(this.data)});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let i=this.loadedName+"_path_"+t,s;try{s=e.get(i)}catch(r){U(`getPathGenerator - ignoring character: "${r}".`)}let n=new Path2D(s||"");return this.fontExtraProperties||e.delete(i),this.compiledGlyphs[t]=n}},gi={DATA:1,ERROR:2},ht={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function kr(){}
2function Pt(o){if(o instanceof Qt||o instanceof ze||o instanceof pe||o instanceof yi||o instanceof Te||o instanceof Ve)return o;switch(o instanceof Error||typeof o=="object"&&o!==null||Z('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new Qt(o.message);case"InvalidPDFException":return new ze(o.message);case"MissingPDFException":return new pe(o.message);case"PasswordException":return new yi(o.message,o.code);case"UnexpectedResponseException":return new Te(o.message,o.status);case"UnknownErrorException":return new Ve(o.message,o.details)}return new Ve(o.message,o.toString())}var de=class{#t=new AbortController;constructor(e,t,i){this.sourceName=e,this.targetName=t,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#s(e);return}if(e.callback){let i=e.callbackId,s=this.callbackCapabilities[i];if(!s)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],e.callback===gi.DATA)s.resolve(e.data);else if(e.callback===gi.ERROR)s.reject(Pt(e.reason));else throw new Error("Unexpected callback case");return}let t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let i=this.sourceName,s=e.sourceName,n=this.comObj;Promise.try(t,e.data).then(function(r){n.postMessage({sourceName:i,targetName:s,callback:gi.DATA,callbackId:e.callbackId,data:r})},function(r){n.postMessage({sourceName:i,targetName:s,callback:gi.ERROR,callbackId:e.callbackId,reason:Pt(r)})});return}if(e.streamId){this.#i(e);return}t(e.data)}on(e,t){let i=this.actionHandler;if(i[e])throw new Error(`There is already an actionName called "${e}"`);i[e]=t}send(e,t,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},i)}sendWithPromise(e,t,i){let s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:t},i)}catch(r){n.reject(r)}return n.promise}sendWithStream(e,t,i,s){let n=this.streamId++,r=this.sourceName,a=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{let h=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:r,targetName:a,action:e,streamId:n,data:t,desiredSize:c.desiredSize},s),h.promise},pull:c=>{let h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,l.postMessage({sourceName:r,targetName:a,stream:ht.PULL,streamId:n,desiredSize:c.desiredSize}),h.promise},cancel:c=>{dt(c instanceof Error,"cancel must have a valid reason");let h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,l.postMessage({sourceName:r,targetName:a,stream:ht.CANCEL,streamId:n,reason:Pt(c)}),h.promise}},i)}#i(e){let t=e.streamId,i=this.sourceName,s=e.sourceName,n=this.comObj,r=this,a=this.actionHandler[e.action],l={enqueue(c,h=1,d){if(this.isCancelled)return;let u=this.desiredSize;this.desiredSize-=h,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:ht.ENQUEUE,streamId:t,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:ht.CLOSE,streamId:t}),delete r.streamSinks[t])},error(c){dt(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:ht.ERROR,streamId:t,reason:Pt(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,Promise.try(a,e.data,l).then(function(){n.postMessage({sourceName:i,targetName:s,stream:ht.START_COMPLETE,streamId:t,success:!0})},function(c){n.postMessage({sourceName:i,targetName:s,stream:ht.START_COMPLETE,streamId:t,reason:Pt(c)})})}#s(e){let t=e.streamId,i=this.sourceName,s=e.sourceName,n=this.comObj,r=this.streamControllers[t],a=this.streamSinks[t];switch(e.stream){case ht.START_COMPLETE:e.success?r.startCall.resolve():r.startCall.reject(Pt(e.reason));break;case ht.PULL_COMPLETE:e.success?r.pullCall.resolve():r.pullCall.reject(Pt(e.reason));break;case ht.PULL:if(!a){n.postMessage({sourceName:i,targetName:s,stream:ht.PULL_COMPLETE,streamId:t,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,Promise.try(a.onPull||kr).then(function(){n.postMessage({sourceName:i,targetName:s,stream:ht.PULL_COMPLETE,streamId:t,success:!0})},function(c){n.postMessage({sourceName:i,targetName:s,stream:ht.PULL_COMPLETE,streamId:t,reason:Pt(c)})});break;case ht.ENQUEUE:if(dt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(e.chunk);break;case ht.CLOSE:if(dt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#r(r,t);break;case ht.ERROR:dt(r,"error should have stream controller"),r.controller.error(Pt(e.reason)),this.#r(r,t);break;case ht.CANCEL_COMPLETE:e.success?r.cancelCall.resolve():r.cancelCall.reject(Pt(e.reason)),this.#r(r,t);break;case ht.CANCEL:if(!a)break;let l=Pt(e.reason);Promise.try(a.onCancel||kr,l).then(function(){n.postMessage({sourceName:i,targetName:s,stream:ht.CANCEL_COMPLETE,streamId:t,success:!0})},function(c){n.postMessage({sourceName:i,targetName:s,stream:ht.CANCEL_COMPLETE,streamId:t,reason:Pt(c)})}),a.sinkCapability.reject(l),a.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}#r(e,t){return I(this,null,function*(){yield Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]})}destroy(){this.#t?.abort(),this.#t=null}},Pi=class{#t=!1;constructor({enableHWA:e=!1}){this.#t=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#t})}}reset(e,t,i){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=i}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Z("Abstract method `_createCanvas` called.")}},Rs=class extends Pi{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let i=this._document.createElement("canvas");return i.width=e,i.height=t,i}},Ti=class{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}fetch(t){return I(this,arguments,function*({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");let i=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(i).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${i}`)})})}_fetch(e){return I(this,null,function*(){Z("Abstract method `_fetch` called.")})}},Mi=class extends Ti{_fetch(e){return I(this,null,function*(){let t=yield es(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):ts(t)})}},Ri=class{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,i,s,n){return"none"}destroy(e=!1){}},Is=class extends Ri{#t;#e;#i;#s;#r;#n;#l=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#s=e,this.#r=t}get#o(){return this.#e||=new Map}get#h(){return this.#n||=new Map}get#c(){if(!this.#i){let e=this.#r.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let i=this.#r.createElementNS(te,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i=this.#r.createElementNS(te,"defs"),e.append(i),i.append(this.#i),this.#r.body.append(e)}return this.#i}#u(e){if(e.length===1){let l=e[0],c=new Array(256);for(let d=0;d<256;d++)c[d]=l[d]/255;let h=c.join(",");return[h,h,h]}let[t,i,s]=e,n=new Array(256),r=new Array(256),a=new Array(256);for(let l=0;l<256;l++)n[l]=t[l]/255,r[l]=i[l]/255,a[l]=s[l]/255;return[n.join(","),r.join(","),a.join(",")]}#d(e){if(this.#t===void 0){this.#t="";let t=this.#r.URL;t!==this.#r.baseURI&&(is(t)?U('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=t.split("#",1)[0])}return`url(${this.#t}#${e})`}addFilter(e){if(!e)return"none";let t=this.#o.get(e);if(t)return t;let[i,s,n]=this.#u(e),r=e.length===1?i:`${i}${s}${n}`;if(t=this.#o.get(r),t)return this.#o.set(e,t),t;let a=`g_${this.#s}_transfer_map_${this.#l++}`,l=this.#d(a);this.#o.set(e,l),this.#o.set(r,l);let c=this.#f(a);return this.#g(i,s,n,c),l}addHCMFilter(e,t){let i=`${e}-${t}`,s="base",n=this.#h.get(s);if(n?.key===i||(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#h.set(s,n)),!e||!t))return n.url;let r=this.#x(e);e=D.makeHexColor(...r);let a=this.#x(t);if(t=D.makeHexColor(...a),this.#c.style.color="",e==="#000000"&&t==="#ffffff"||e===t)return n.url;let l=new Array(256);for(let p=0;p<=255;p++){let f=p/255;l[p]=f<=.03928?f/12.92:((f+.055)/1.055)**2.4}let c=l.join(","),h=`g_${this.#s}_hcm_filter`,d=n.filter=this.#f(h);this.#g(c,c,c,d),this.#a(d);let u=(p,f)=>{let g=r[p]/255,b=a[p]/255,m=new Array(f+1);for(let x=0;x<=f;x++)m[x]=g+x/f*(b-g);return m.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(h),n.url}addAlphaFilter(e){let t=this.#o.get(e);if(t)return t;let[i]=this.#u([e]),s=`alpha_${i}`;if(t=this.#o.get(s),t)return this.#o.set(e,t),t;let n=`g_${this.#s}_alpha_map_${this.#l++}`,r=this.#d(n);this.#o.set(e,r),this.#o.set(s,r);let a=this.#f(n);return this.#b(i,a),r}addLuminosityFilter(e){let t=this.#o.get(e||"luminosity");if(t)return t;let i,s;if(e?([i]=this.#u([e]),s=`luminosity_${i}`):s="luminosity",t=this.#o.get(s),t)return this.#o.set(e,t),t;let n=`g_${this.#s}_luminosity_map_${this.#l++}`,r=this.#d(n);this.#o.set(e,r),this.#o.set(s,r);let a=this.#f(n);return this.#p(a),e&&this.#b(i,a),r}addHighlightHCMFilter(e,t,i,s,n){let r=`${t}-${i}-${s}-${n}`,a=this.#h.get(e);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#h.set(e,a)),!t||!i))return a.url;let[l,c]=[t,i].map(this.#x.bind(this)),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[u,p]=[s,n].map(this.#x.bind(this));d<h&&([h,d,u,p]=[d,h,p,u]),this.#c.style.color="";let f=(m,x,y)=>{let A=new Array(256),C=(d-h)/y,P=m/255,S=(x-m)/(255*y),B=0;for(let H=0;H<=y;H++){let X=Math.round(h+H*C),G=P+H*S;for(let st=B;st<=X;st++)A[st]=G;B=X+1}for(let H=B;H<256;H++)A[H]=A[B-1];return A.join(",")},g=`g_${this.#s}_hcm_${e}_filter`,b=a.filter=this.#f(g);return this.#a(b),this.#g(f(u[0],p[0],5),f(u[1],p[1],5),f(u[2],p[2],5),b),a.url=this.#d(g),a.url}destroy(e=!1){e&&this.#n?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#l=0)}#p(e){let t=this.#r.createElementNS(te,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.a
2ppend(t)}#a(e){let t=this.#r.createElementNS(te,"feColorMatrix");t.setAttribute("type","matrix"),t.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"),e.append(t)}#f(e){let t=this.#r.createElementNS(te,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#c.append(t),t}#m(e,t,i){let s=this.#r.createElementNS(te,t);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),e.append(s)}#g(e,t,i,s){let n=this.#r.createElementNS(te,"feComponentTransfer");s.append(n),this.#m(n,"feFuncR",e),this.#m(n,"feFuncG",t),this.#m(n,"feFuncB",i)}#b(e,t){let i=this.#r.createElementNS(te,"feComponentTransfer");t.append(i),this.#m(i,"feFuncA",e)}#x(e){return this.#c.style.color=e,$n(getComputedStyle(this.#c).getPropertyValue("color"))}},Ii=class{constructor({baseUrl:e=null}){this.baseUrl=e}fetch(t){return I(this,arguments,function*({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");let i=`${this.baseUrl}${e}`;return this._fetch(i).catch(s=>{throw new Error(`Unable to load font data at: ${i}`)})})}_fetch(e){return I(this,null,function*(){Z("Abstract method `_fetch` called.")})}},Li=class extends Ii{_fetch(e){return I(this,null,function*(){let t=yield es(e,"arraybuffer");return new Uint8Array(t)})}};At&&U("Please use the `legacy` build in Node.js environments.");function zr(o){return I(this,null,function*(){let t=yield process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(t)})}var Ls=class extends Ri{},Os=class extends Pi{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}},Ds=class extends Ti{_fetch(e){return I(this,null,function*(){return zr(e)})}},Fs=class extends Ii{_fetch(e){return I(this,null,function*(){return zr(e)})}},wt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ns(o,e){if(!e)return;let t=e[2]-e[0],i=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],t,i),o.clip(s)}var Xe=class{getPattern(){Z("Abstract method `getPattern` called.")}},Bs=class extends Xe{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type==="axial"?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let i of this._colorStops)t.addColorStop(i[0],i[1]);return t}getPattern(e,t,i,s){let n;if(s===wt.STROKE||s===wt.FILL){let r=t.current.getClippedPathBoundingBox(s,et(e))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,l=Math.ceil(r[3]-r[1])||1,c=t.cachedCanvases.getCanvas("pattern",a,l),h=c.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=D.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...t.baseTransform),this.matrix&&h.transform(...this.matrix),Ns(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=e.createPattern(c.canvas,"no-repeat");let d=new DOMMatrix(i);n.setTransform(d)}else Ns(e,this._bbox),n=this._createGradient(e);return n}};function ms(o,e,t,i,s,n,r,a){let l=e.coords,c=e.colors,h=o.data,d=o.width*4,u;l[t+1]>l[i+1]&&(u=t,t=i,i=u,u=n,n=r,r=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[t+1]>l[i+1]&&(u=t,t=i,i=u,u=n,n=r,r=u);let p=(l[t]+e.offsetX)*e.scaleX,f=(l[t+1]+e.offsetY)*e.scaleY,g=(l[i]+e.offsetX)*e.scaleX,b=(l[i+1]+e.offsetY)*e.scaleY,m=(l[s]+e.offsetX)*e.scaleX,x=(l[s+1]+e.offsetY)*e.scaleY;if(f>=x)return;let y=c[n],A=c[n+1],C=c[n+2],P=c[r],S=c[r+1],B=c[r+2],H=c[a],X=c[a+1],G=c[a+2],st=Math.round(f),ut=Math.round(x),Q,Et,O,N,Lt,$t,le,Ot;for(let ft=st;ft<=ut;ft++){if(ft<b){let J=ft<f?0:(f-ft)/(f-b);Q=p-(p-g)*J,Et=y-(y-P)*J,O=A-(A-S)*J,N=C-(C-B)*J}else{let J;ft>x?J=1:b===x?J=0:J=(b-ft)/(b-x),Q=g-(g-m)*J,Et=P-(P-H)*J,O=S-(S-X)*J,N=B-(B-G)*J}let lt;ft<f?lt=0:ft>x?lt=1:lt=(f-ft)/(f-x),Lt=p-(p-m)*lt,$t=y-(y-H)*lt,le=A-(A-X)*lt,Ot=C-(C-G)*lt;let be=Math.round(Math.min(Q,Lt)),Me=Math.round(Math.max(Q,Lt)),Dt=d*ft+be*4;for(let J=be;J<=Me;J++)lt=(Q-J)/(Q-Lt),lt<0?lt=0:lt>1&&(lt=1),h[Dt++]=Et-(Et-$t)*lt|0,h[Dt++]=O-(O-le)*lt|0,h[Dt++]=N-(N-Ot)*lt|0,h[Dt++]=255}}function Fa(o,e,t){let i=e.coords,s=e.colors,n,r;switch(e.type){case"lattice":let a=e.verticesPerRow,l=Math.floor(i.length/a)-1,c=a-1;for(n=0;n<l;n++){let h=n*a;for(let d=0;d<c;d++,h++)ms(o,t,i[h],i[h+1],i[h+a],s[h],s[h+1],s[h+a]),ms(o,t,i[h+a+1],i[h+1],i[h+a],s[h+a+1],s[h+1],s[h+a])}break;case"triangles":for(n=0,r=i.length;n<r;n+=3)ms(o,t,i[n],i[n+1],i[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}var Hs=class extends Xe{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,i){let a=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*e[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(h*e[1]*1.1)),3e3),p=c/d,f=h/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-l,scaleX:1/p,scaleY:1/f},b=d+2*2,m=u+2*2,x=i.getCanvas("mesh",b,m),y=x.context,A=y.createImageData(d,u);if(t){let P=A.data;for(let S=0,B=P.length;S<B;S+=4)P[S]=t[0],P[S+1]=t[1],P[S+2]=t[2],P[S+3]=255}for(let P of this._figures)Fa(A,P,g);return y.putImageData(A,2,2),{canvas:x.canvas,offsetX:a-2*p,offsetY:l-2*f,scaleX:p,scaleY:f}}getPattern(e,t,i,s){Ns(e,this._bbox);let n;if(s===wt.SHADING)n=D.singularValueDecompose2dScale(et(e));else if(n=D.singularValueDecompose2dScale(t.baseTransform),this.matrix
2){let a=D.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}let r=this._createMeshCanvas(n,s===wt.SHADING?null:this._background,t.cachedCanvases);return s!==wt.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(r.offsetX,r.offsetY),e.scale(r.scaleX,r.scaleY),e.createPattern(r.canvas,"no-repeat")}},Vs=class extends Xe{getPattern(){return"hotpink"}};function Na(o){switch(o[0]){case"RadialAxial":return new Bs(o);case"Mesh":return new Hs(o);case"Dummy":return new Vs}throw new Error(`Unknown IR type: ${o[0]}`)}var Pr={COLORED:1,UNCOLORED:2},Ba=(()=>{class o{static MAX_PATTERN_SIZE=3e3;constructor(t,i,s,n,r){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=i,this.ctx=s,this.canvasGraphicsFactory=n,this.baseTransform=r}createPatternCanvas(t){let{bbox:i,operatorList:s,paintType:n,tilingType:r,color:a,canvasGraphicsFactory:l}=this,{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),Ji("TilingType: "+r);let d=i[0],u=i[1],p=i[2],f=i[3],g=p-d,b=f-u,m=D.singularValueDecompose2dScale(this.matrix),x=D.singularValueDecompose2dScale(this.baseTransform),y=m[0]*x[0],A=m[1]*x[1],C=g,P=b,S=!1,B=!1,H=Math.ceil(c*y),X=Math.ceil(h*A),G=Math.ceil(g*y),st=Math.ceil(b*A);H>=G?C=c:S=!0,X>=st?P=h:B=!0;let ut=this.getSizeAndScale(C,this.ctx.canvas.width,y),Q=this.getSizeAndScale(P,this.ctx.canvas.height,A),Et=t.cachedCanvases.getCanvas("pattern",ut.size,Q.size),O=Et.context,N=l.createCanvasGraphics(O);if(N.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(N,n,a),O.translate(-ut.scale*d,-Q.scale*u),N.transform(ut.scale,0,0,Q.scale,0,0),O.save(),this.clipBbox(N,d,u,p,f),N.baseTransform=et(N.ctx),N.executeOperatorList(s),N.endDrawing(),O.restore(),S||B){let Lt=Et.canvas;S&&(C=c),B&&(P=h);let $t=this.getSizeAndScale(C,this.ctx.canvas.width,y),le=this.getSizeAndScale(P,this.ctx.canvas.height,A),Ot=$t.size,ft=le.size,lt=t.cachedCanvases.getCanvas("pattern-workaround",Ot,ft),be=lt.context,Me=S?Math.floor(g/c):0,Dt=B?Math.floor(b/h):0;for(let J=0;J<=Me;J++)for(let Ut=0;Ut<=Dt;Ut++)be.drawImage(Lt,Ot*J,ft*Ut,Ot,ft,0,0,Ot,ft);return{canvas:lt.canvas,scaleX:$t.scale,scaleY:le.scale,offsetX:d,offsetY:u}}return{canvas:Et.canvas,scaleX:ut.scale,scaleY:Q.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,i,s){let n=Math.max(o.MAX_PATTERN_SIZE,i),r=Math.ceil(t*s);return r>=n?r=n:s=r/t,{scale:s,size:r}}clipBbox(t,i,s,n,r){let a=n-i,l=r-s;t.ctx.rect(i,s,a,l),t.current.updateRectMinMax(et(t.ctx),[i,s,n,r]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,i,s){let n=t.ctx,r=t.current;switch(i){case Pr.COLORED:let a=this.ctx;n.fillStyle=a.fillStyle,n.strokeStyle=a.strokeStyle,r.fillColor=a.fillStyle,r.strokeColor=a.strokeStyle;break;case Pr.UNCOLORED:let l=D.makeHexColor(s[0],s[1],s[2]);n.fillStyle=l,n.strokeStyle=l,r.fillColor=l,r.strokeColor=l;break;default:throw new xs(`Unsupported paint type: ${i}`)}}getPattern(t,i,s,n){let r=s;n!==wt.SHADING&&(r=D.transform(r,i.baseTransform),this.matrix&&(r=D.transform(r,this.matrix)));let a=this.createPatternCanvas(i),l=new DOMMatrix(r);l=l.translate(a.offsetX,a.offsetY),l=l.scale(1/a.scaleX,1/a.scaleY);let c=t.createPattern(a.canvas,"repeat");return c.setTransform(l),c}}return o})();function Ha({src:o,srcPos:e=0,dest:t,width:i,height:s,nonBlackColor:n=4294967295,inverseDecode:r=!1}){let a=bt.isLittleEndian?4278190080:255,[l,c]=r?[n,a]:[a,n],h=i>>3,d=i&7,u=o.length;t=new Uint32Array(t.buffer);let p=0;for(let f=0;f<s;f++){for(let b=e+h;e<b;e++){let m=e<u?o[e]:255;t[p++]=m&128?c:l,t[p++]=m&64?c:l,t[p++]=m&32?c:l,t[p++]=m&16?c:l,t[p++]=m&8?c:l,t[p++]=m&4?c:l,t[p++]=m&2?c:l,t[p++]=m&1?c:l}if(d===0)continue;let g=e<u?o[e++]:255;for(let b=0;b<d;b++)t[p++]=g&1<<7-b?c:l}return{srcPos:e,destPos:p}}var Tr=16,Mr=100,Va=15,Rr=10,Ir=1e3,Tt=16;function za(o,e){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){e.save(),this.__originalSave()}
2,o.restore=function(){e.restore(),this.__originalRestore()},o.translate=function(i,s){e.translate(i,s),this.__originalTranslate(i,s)},o.scale=function(i,s){e.scale(i,s),this.__originalScale(i,s)},o.transform=function(i,s,n,r,a,l){e.transform(i,s,n,r,a,l),this.__originalTransform(i,s,n,r,a,l)},o.setTransform=function(i,s,n,r,a,l){e.setTransform(i,s,n,r,a,l),this.__originalSetTransform(i,s,n,r,a,l)},o.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},o.rotate=function(i){e.rotate(i),this.__originalRotate(i)},o.clip=function(i){e.clip(i),this.__originalClip(i)},o.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},o.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},o.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},o.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},o.closePath=function(){e.closePath(),this.__originalClosePath()},o.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}var zs=class{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,i){let s;return this.cache[e]!==void 0?(s=this.cache[e],this.canvasFactory.reset(s,t,i)):(s=this.canvasFactory.create(t,i),this.cache[e]=s),s}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}};function mi(o,e,t,i,s,n,r,a,l,c){let[h,d,u,p,f,g]=et(o);if(d===0&&u===0){let x=r*h+f,y=Math.round(x),A=a*p+g,C=Math.round(A),P=(r+l)*h+f,S=Math.abs(Math.round(P)-y)||1,B=(a+c)*p+g,H=Math.abs(Math.round(B)-C)||1;return o.setTransform(Math.sign(h),0,0,Math.sign(p),y,C),o.drawImage(e,t,i,s,n,0,0,S,H),o.setTransform(h,d,u,p,f,g),[S,H]}if(h===0&&p===0){let x=a*u+f,y=Math.round(x),A=r*d+g,C=Math.round(A),P=(a+c)*u+f,S=Math.abs(Math.round(P)-y)||1,B=(r+l)*d+g,H=Math.abs(Math.round(B)-C)||1;return o.setTransform(0,Math.sign(d),Math.sign(u),0,y,C),o.drawImage(e,t,i,s,n,0,0,H,S),o.setTransform(h,d,u,p,f,g),[H,S]}o.drawImage(e,t,i,s,n,r,a,l,c);let b=Math.hypot(h,d),m=Math.hypot(u,p);return[b*l,m*c]}function $a(o){let{width:e,height:t}=o;if(e>Ir||t>Ir)return null;let i=1e3,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1,r=new Uint8Array(n*(t+1)),a,l,c,h=e+7&-8,d=new Uint8Array(h*t),u=0;for(let m of o.data){let x=128;for(;x>0;)d[u++]=m&x?0:255,x>>=1}let p=0;for(u=0,d[u]!==0&&(r[0]=1,++p),l=1;l<e;l++)d[u]!==d[u+1]&&(r[l]=d[u]?2:1,++p),u++;for(d[u]!==0&&(r[l]=2,++p),a=1;a<t;a++){u=a*h,c=a*n,d[u-h]!==d[u]&&(r[c]=d[u]?1:8,++p);let m=(d[u]?4:0)+(d[u-h]?8:0);for(l=1;l<e;l++)m=(m>>2)+(d[u+1]?4:0)+(d[u-h+1]?8:0),s[m]&&(r[c+l]=s[m],++p),u++;if(d[u-h]!==d[u]&&(r[c+l]=d[u]?2:4,++p),p>i)return null}for(u=h*(t-1),c=a*n,d[u]!==0&&(r[c]=8,++p),l=1;l<e;l++)d[u]!==d[u+1]&&(r[c+l]=d[u]?4:8,++p),u++;if(d[u]!==0&&(r[c+l]=4,++p),p>i)return null;let f=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=t;a++){let m=a*n,x=m+e;for(;m<x&&!r[m];)m++;if(m===x)continue;g.moveTo(m%n,a);let y=m,A=r[m];do{let C=f[A];do m+=C;while(!r[m]);let P=r[m];P!==5&&P!==10?(A=P,r[m]=0):(A=P&51*A>>4,r[m]&=A>>2|A<<2),g.lineTo(m%n,m/n|0),r[m]||--p}while(y!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/e,-1/t),m.translate(0,-t),m.fill(g),m.beginPath(),m.restore()}}var Oi=class{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Hr,this.textMatrixScale=1,this.fontMatrix=vs,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=yt.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,i){[t,i]=D.applyTransform([t,i],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(e,t){let i=D.applyTransform(t,e),s=D.applyTransform(t.slice(2),e),n=D.applyTransform([t[0],t[3]],e),r=D.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(e,t){D.scaleMinMax(e,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(e,t,i,s,n,r,a,l,c,h){let d=D.bezierBoundingBox(t,i,s,n,r,a,l,c,h);h||this.updateRectMinMax(e,d)}getPathBoundingBox(e=wt.FILL,t=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(e===wt.STROKE){t||Z("Stroke bounding box must include transform.");let s=D.singularValueDecompose2dScale(t),n=s[0]*this.lineWidth/2,r=s[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}updateClipFromPath(){let e=D.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=wt.FILL,t=null){return D.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function Lr(o,e){if(e instanceof ImageData){o.putImageData(e,0,0);return}let t=e.height,i=e.width,s=t%Tt,n=(t-s)/Tt,r=s===0?n:n+1,a=o.createImageData(i,Tt),l=0,c,h=e.data,d=a.data,u,p,f,g;if(e.kind===xi.GRAYSCALE_1BPP){let b=h.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),x=m.length,y=i+7>>3,A=4294967295,C=bt.isLittleEndian?4278190080:255;for(u=0;
2u<r;u++){for(f=u<n?Tt:s,c=0,p=0;p<f;p++){let P=b-l,S=0,B=P>y?i:P*8-7,H=B&-8,X=0,G=0;for(;S<H;S+=8)G=h[l++],m[c++]=G&128?A:C,m[c++]=G&64?A:C,m[c++]=G&32?A:C,m[c++]=G&16?A:C,m[c++]=G&8?A:C,m[c++]=G&4?A:C,m[c++]=G&2?A:C,m[c++]=G&1?A:C;for(;S<B;S++)X===0&&(G=h[l++],X=128),m[c++]=G&X?A:C,X>>=1}for(;c<x;)m[c++]=0;o.putImageData(a,0,u*Tt)}}else if(e.kind===xi.RGBA_32BPP){for(p=0,g=i*Tt*4,u=0;u<n;u++)d.set(h.subarray(l,l+g)),l+=g,o.putImageData(a,0,p),p+=Tt;u<r&&(g=i*s*4,d.set(h.subarray(l,l+g)),o.putImageData(a,0,p))}else if(e.kind===xi.RGB_24BPP)for(f=Tt,g=i*f,u=0;u<r;u++){for(u>=n&&(f=s,g=i*f),c=0,p=g;p--;)d[c++]=h[l++],d[c++]=h[l++],d[c++]=h[l++],d[c++]=255;o.putImageData(a,0,u*Tt)}else throw new Error(`bad image kind: ${e.kind}`)}function Or(o,e){if(e.bitmap){o.drawImage(e.bitmap,0,0);return}let t=e.height,i=e.width,s=t%Tt,n=(t-s)/Tt,r=s===0?n:n+1,a=o.createImageData(i,Tt),l=0,c=e.data,h=a.data;for(let d=0;d<r;d++){let u=d<n?Tt:s;({srcPos:l}=Ha({src:c,srcPos:l,dest:h,width:i,height:u,nonBlackColor:0})),o.putImageData(a,0,d*Tt)}}function De(o,e){let t=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let i of t)o[i]!==void 0&&(e[i]=o[i]);o.setLineDash!==void 0&&(e.setLineDash(o.getLineDash()),e.lineDashOffset=o.lineDashOffset)}function bi(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",o.setLineDash!==void 0&&(o.setLineDash([]),o.lineDashOffset=0),!At){let{filter:e}=o;e!=="none"&&e!==""&&(o.filter="none")}}function Dr(o,e){if(e)return!0;let t=D.singularValueDecompose2dScale(o);t[0]=Math.fround(t[0]),t[1]=Math.fround(t[1]);let i=Math.fround((globalThis.devicePixelRatio||1)*ae.PDF_TO_CSS_UNITS);return t[0]<=i&&t[1]<=i}var Ua=["butt","round","square"],ja=["miter","round","bevel"],Ga={},Fr={},ke=class o{constructor(e,t,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},l,c){this.ctx=e,this.current=new Oi(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=i,this.canvasFactory=s,this.filterFactory=n,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=a||[],this.optionalContentConfig=r,this.cachedCanvases=new zs(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return typeof e=="string"?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:i=!1,background:s=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){let l=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...et(this.compositeCtx))}this.ctx.save(),bi(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=et(this.ctx)}executeOperatorList(e,t,i,s){let n=e.argsArray,r=e.fnArray,a=t||0,l=n.length;if(l===a)return a;let c=l-a>Rr&&typeof i=="function",h=c?Date.now()+Va:0,d=0,u=this.commonObjs,p=this.objs,f;for(;;){if(s!==void 0&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(f=r[a],f!==Vt.dependency)this[f].apply(this,n[a]);else for(let g of n[a]){let b=g.startsWith("g_")?u:p;if(!b.has(g))return b.get(g,i),a}if(a++,a===l)return a;
2if(c&&++d>Rr){if(Date.now()>h)return i(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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 e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let i=e.width??e.displayWidth,s=e.height??e.displayHeight,n=Math.max(Math.hypot(t[0],t[1]),1),r=Math.max(Math.hypot(t[2],t[3]),1),a=i,l=s,c="prescale1",h,d;for(;n>2&&a>1||r>2&&l>1;){let u=a,p=l;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,r/=l/p),h=this.cachedCanvases.getCanvas(c,u,p),d=h.context,d.clearRect(0,0,u,p),d.drawImage(e,0,0,a,l,0,0,u,p),e=h.canvas,a=u,l=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:a,paintHeight:l}}_createMaskCanvas(e){let t=this.ctx,{width:i,height:s}=e,n=this.current.fillColor,r=this.current.patternFill,a=et(t),l,c,h,d;if((e.bitmap||e.data)&&e.count>1){let B=e.bitmap||e.data.buffer;c=JSON.stringify(r?a:[a.slice(0,4),n]),l=this._cachedBitmapsMap.get(B),l||(l=new Map,this._cachedBitmapsMap.set(B,l));let H=l.get(c);if(H&&!r){let X=Math.round(Math.min(a[0],a[2])+a[4]),G=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:H,offsetX:X,offsetY:G}}h=H}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),Or(d.context,e));let u=D.transform(a,[1/i,0,0,-1/s,0,0]);u=D.transform(u,[1,0,0,1,0,-s]);let[p,f,g,b]=D.getAxialAlignedBoundingBox([0,0,i,s],u),m=Math.round(g-p)||1,x=Math.round(b-f)||1,y=this.cachedCanvases.getCanvas("fillCanvas",m,x),A=y.context,C=p,P=f;A.translate(-C,-P),A.transform(...u),h||(h=this._scaleImage(d.canvas,Kt(A)),h=h.img,l&&r&&l.set(c,h)),A.imageSmoothingEnabled=Dr(et(A),e.interpolate),mi(A,h,0,0,h.width,h.height,0,0,i,s),A.globalCompositeOperation="source-in";let S=D.transform(Kt(A),[1,0,0,1,-C,-P]);return A.fillStyle=r?n.getPattern(t,this,S,wt.FILL):n,A.fillRect(0,0,i,s),l&&!r&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,y.canvas)),{canvas:y.canvas,offsetX:Math.round(C),offsetY:Math.round(P)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=Ua[e]}setLineJoin(e){this.ctx.lineJoin=ja[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,e,t);this.suspendedCtx=this.ctx,this.ctx=s.context;let n=this.ctx;n.setTransform(...et(this.suspendedCtx)),De(this.suspendedCtx,n),za(n,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(),De(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,t,this.ctx,e),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(
2)}composeSMask(e,t,i,s){let n=s[0],r=s[1],a=s[2]-n,l=s[3]-r;a===0||l===0||(this.genericComposeSMask(t.context,i,a,l,t.subtype,t.backdrop,t.transferMap,n,r,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(i.canvas,0,0),e.restore())}genericComposeSMask(e,t,i,s,n,r,a,l,c,h,d){let u=e.canvas,p=l-h,f=c-d;if(r){let b=D.makeHexColor(...r);if(p<0||f<0||p+i>u.width||f+s>u.height){let m=this.cachedCanvases.getCanvas("maskExtension",i,s),x=m.context;x.drawImage(u,-p,-f),x.globalCompositeOperation="destination-atop",x.fillStyle=b,x.fillRect(0,0,i,s),x.globalCompositeOperation="source-over",u=m.canvas,p=f=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let m=new Path2D;m.rect(p,f,i,s),e.clip(m),e.globalCompositeOperation="destination-atop",e.fillStyle=b,e.fillRect(p,f,i,s),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?t.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(t.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(l,c,i,s),t.clip(g),t.globalCompositeOperation="destination-in",t.drawImage(u,p,f,i,s,l,c,i,s),t.restore()}save(){this.inSMaskMode?(De(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),De(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,i,s,n,r){this.ctx.transform(e,t,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,i){let s=this.ctx,n=this.current,r=n.x,a=n.y,l,c,h=et(s),d=h[0]===0&&h[3]===0||h[1]===0&&h[2]===0,u=d?i.slice(0):null;for(let p=0,f=0,g=e.length;p<g;p++)switch(e[p]|0){case Vt.rectangle:r=t[f++],a=t[f++];let b=t[f++],m=t[f++],x=r+b,y=a+m;s.moveTo(r,a),b===0||m===0?s.lineTo(x,y):(s.lineTo(x,a),s.lineTo(x,y),s.lineTo(r,y)),d||n.updateRectMinMax(h,[r,a,x,y]),s.closePath();break;case Vt.moveTo:r=t[f++],a=t[f++],s.moveTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Vt.lineTo:r=t[f++],a=t[f++],s.lineTo(r,a),d||n.updatePathMinMax(h,r,a);break;case Vt.curveTo:l=r,c=a,r=t[f+4],a=t[f+5],s.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],r,a),n.updateCurvePathMinMax(h,l,c,t[f],t[f+1],t[f+2],t[f+3],r,a,u),f+=6;break;case Vt.curveTo2:l=r,c=a,s.bezierCurveTo(r,a,t[f],t[f+1],t[f+2],t[f+3]),n.updateCurvePathMinMax(h,l,c,r,a,t[f],t[f+1],t[f+2],t[f+3],u),r=t[f+2],a=t[f+3],f+=4;break;case Vt.curveTo3:l=r,c=a,r=t[f+2],a=t[f+3],s.bezierCurveTo(t[f],t[f+1],r,a,r,a),n.updateCurvePathMinMax(h,l,c,t[f],t[f+1],r,a,r,a,u),f+=4;break;case Vt.closePath:s.closePath();break}d&&n.updateScalingPathMinMax(h,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,i=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof i=="object"&&i?.getPattern?(t.save(),t.strokeStyle=i.getPattern(t,this,Kt(t),wt.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,i=this.current.fillColor,s=this.current.patternFill,n=!1;s&&(t.save(),t.fillStyle=i.getPattern(t,this,Kt(t),wt.FILL),n=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),n&&t.restore(),e&&this.consumePath(r)}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=Ga}eoClip(){this.pendingClip=Fr}beginText(){this.current.textMatrix=Hr,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(e===void 0){t.beginPath();return}let i=new Path2D,s=t.getTransform().invertSelf();for(let{transform:n,x:r,y:a,fontSize:l,path:c}of e)i.addPath(c,new DOMMatrix(n).preMultiplySelf(s).translate(r,a).scale(l,-l));t.clip(i),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let i=this.commonObjs.get(e),s=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(s.fontMatrix=i.fontMatrix||vs,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&U("Invalid font matrix for font "+e),t<0?(t=-t,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;let n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`,a="normal";i.black?a="900":i.bold&&(a="bold");let l=i.italic?"italic":"normal",c=t;t<Tr?c=Tr:t>Mr&&(c=Mr),this.current.fontSizeScale=t/c,this.ctx.font=`${l} ${a} ${c}px ${r}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,i,s,n,r){this.current.textMatrix=[e,t,i,s,n,r],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#i(e,t,i){let s=new Path2D;return s.addPath(e,new DOMMatrix(i).invertSelf().multiplySelf(t)),s}paintChar(e,t,i,s,n){let r=this.ctx,a=this.current,l=a.font,c=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=c&yt.FILL_STROKE_MASK,u=!!(c&yt.ADD_TO_PATH_FLAG),p=a.patternFill&&!l.missingFile,f=a.patternStroke&&!l.missingFile,g;if((l.disableFontFace||u||p||f)&&(g=l.getPathGenerator(this.commonObjs,e)),l.disableFontFace||p||f){if(r.save(),r.translate(t,i),r.scale(h,-h),d===yt.FILL||d===yt.FILL_STROKE)if(s){let b=r.getTransform();r.setTransform(...s),r.fill(this.#i(g,b,s))}
2else r.fill(g);if(d===yt.STROKE||d===yt.FILL_STROKE)if(n){let b=r.getTransform();r.setTransform(...n),r.stroke(this.#i(g,b,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else(d===yt.FILL||d===yt.FILL_STROKE)&&r.fillText(e,t,i),(d===yt.STROKE||d===yt.FILL_STROKE)&&r.strokeText(e,t,i);u&&(this.pendingTextPaths||=[]).push({transform:et(r),x:t,y:i,fontSize:h,path:g})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,i=!1;for(let s=3;s<t.length;s+=4)if(t[s]>0&&t[s]<255){i=!0;break}return j(this,"isFontSubpixelAAEnabled",i)}showText(e){let t=this.current,i=t.font;if(i.isType3Font)return this.showType3Text(e);let s=t.fontSize;if(s===0)return;let n=this.ctx,r=t.fontSizeScale,a=t.charSpacing,l=t.wordSpacing,c=t.fontDirection,h=t.textHScale*c,d=e.length,u=i.vertical,p=u?1:-1,f=i.defaultVMetrics,g=s*t.fontMatrix[0],b=t.textRenderingMode===yt.FILL&&!i.disableFontFace&&!t.patternFill;n.save(),n.transform(...t.textMatrix),n.translate(t.x,t.y+t.textRise),c>0?n.scale(h,-1):n.scale(h,1);let m,x;if(t.patternFill){n.save();let S=t.fillColor.getPattern(n,this,Kt(n),wt.FILL);m=et(n),n.restore(),n.fillStyle=S}if(t.patternStroke){n.save();let S=t.strokeColor.getPattern(n,this,Kt(n),wt.STROKE);x=et(n),n.restore(),n.strokeStyle=S}let y=t.lineWidth,A=t.textMatrixScale;if(A===0||y===0){let S=t.textRenderingMode&yt.FILL_STROKE_MASK;(S===yt.STROKE||S===yt.FILL_STROKE)&&(y=this.getSinglePixelWidth())}else y/=A;if(r!==1&&(n.scale(r,r),y/=r),n.lineWidth=y,i.isInvalidPDFjsFont){let S=[],B=0;for(let H of e)S.push(H.unicode),B+=H.width;n.fillText(S.join(""),0,0),t.x+=B*g*h,n.restore(),this.compose();return}let C=0,P;for(P=0;P<d;++P){let S=e[P];if(typeof S=="number"){C+=p*S*s/1e3;continue}let B=!1,H=(S.isSpace?l:0)+a,X=S.fontChar,G=S.accent,st,ut,Q=S.width;if(u){let O=S.vmetric||f,N=-(S.vmetric?O[1]:Q*.5)*g,Lt=O[2]*g;Q=O?-O[0]:Q,st=N/r,ut=(C+Lt)/r}else st=C/r,ut=0;if(i.remeasure&&Q>0){let O=n.measureText(X).width*1e3/s*r;if(Q<O&&this.isFontSubpixelAAEnabled){let N=Q/O;B=!0,n.save(),n.scale(N,1),st/=N}else Q!==O&&(st+=(Q-O)/2e3*s/r)}if(this.contentVisible&&(S.isInFont||i.missingFile)){if(b&&!G)n.fillText(X,st,ut);else if(this.paintChar(X,st,ut,m,x),G){let O=st+s*G.offset.x/r,N=ut-s*G.offset.y/r;this.paintChar(G.fontChar,O,N,m,x)}}let Et=u?Q*g-H*c:Q*g+H*c;C+=Et,B&&n.restore()}u?t.y-=C:t.x+=C*h,n.restore(),this.compose()}showType3Text(e){let t=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,l=i.charSpacing,c=i.wordSpacing,h=i.textHScale*r,d=i.fontMatrix||vs,u=e.length,p=i.textRenderingMode===yt.INVISIBLE,f,g,b,m;if(!(p||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...i.textMatrix),t.translate(i.x,i.y),t.scale(h,r),f=0;f<u;
2++f){if(g=e[f],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),i.x+=m*h;continue}let x=(g.isSpace?c:0)+l,y=s.charProcOperatorList[g.operatorListId];if(!y){U(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),t.scale(n,n),t.transform(...d),this.executeOperatorList(y),this.restore()),b=D.applyTransform([g.width,0],d)[0]*n+x,t.translate(b,0),i.x+=b*h}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if(e[0]==="TilingPattern"){let i=e[1],s=this.baseTransform||et(this.ctx),n={createCanvasGraphics:r=>new o(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new Ba(e,i,this.ctx,n,s)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,i){this.ctx.strokeStyle=this.current.strokeColor=D.makeHexColor(e,t,i),this.current.patternStroke=!1}
2setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,i){this.ctx.fillStyle=this.current.fillColor=D.makeHexColor(e,t,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=Na(this.getObject(e)),this.cachedPatterns.set(e,i)),t&&(i.matrix=t),i}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let i=this._getPattern(e);t.fillStyle=i.getPattern(t,this,Kt(t),wt.SHADING);let s=Kt(t);if(s){let{width:n,height:r}=t.canvas,[a,l,c,h]=D.getAxialAlignedBoundingBox([0,0,n,r],s);this.ctx.fillRect(a,l,c-a,h-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Z("Should not call beginInlineImage")}beginImageData(){Z("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=et(this.ctx),t)){let i=t[2]-t[0],s=t[3]-t[1];this.ctx.rect(t[0],t[1],i,s),this.current.updateRectMinMax(et(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||Ji("TODO: Support non-isolated groups."),e.knockout&&U("Knockout groups not supported.");let i=et(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=D.getAxialAlignedBoundingBox(e.bbox,et(t)),n=[0,0,t.canvas.width,t.canvas.height];s=D.intersect(s,n)||[0,0,0,0];let r=Math.floor(s[0]),a=Math.floor(s[1]),l=Math.max(Math.ceil(s[2])-r,1),c=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,l,c]);let h="groupAt"+this.groupLevel;e.smask&&(h+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(h,l,c),u=d.context;u.translate(-r,-a),u.transform(...i),e.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(r,a),t.save()),De(t,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let s=et(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);let n=D.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],s);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,i,s,n){if(this.#t(),bi(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let r=t[2]-t[0],a=t[3]-t[1];if(n&&this.annotationCanvasMap){i=i.slice(),i[4]-=t[0],i[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=r,t[3]=a;let[l,c]=D.singularValueDecompose2dScale(et(this.ctx)),{viewportScale:h}=this,d=Math.ceil(r*this.outputScaleX*h),u=Math.ceil(a*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,u);let{canvas:p,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(e,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,a*c),bi(this.ctx)}else bi(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Oi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;e=this.getObject(e.data,e),e.count=t;let i=this.ctx,s=this.processingType3;if(s&&(s.compiled===void 0&&(s.compiled=$a(e)),s.compiled)){s.compiled(i);return}let n=this._createMaskCanvas(e),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(
2),this.compose()}paintImageMaskXObjectRepeat(e,t,i=0,s=0,n,r){if(!this.contentVisible)return;e=this.getObject(e.data,e);let a=this.ctx;a.save();let l=et(a);a.transform(t,i,s,n,0,0);let c=this._createMaskCanvas(e);a.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let h=0,d=r.length;h<d;h+=2){let u=D.transform(l,[t,i,s,n,r[h],r[h+1]]),[p,f]=D.applyTransform([0,0],u);a.drawImage(c.canvas,p,f)}a.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(let n of e){let{data:r,width:a,height:l,transform:c}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,l),d=h.context;d.save();let u=this.getObject(r,n);Or(d,u),d.globalCompositeOperation="source-in",d.fillStyle=s?i.getPattern(d,this,Kt(t),wt.FILL):i,d.fillRect(0,0,a,l),d.restore(),t.save(),t.transform(...c),t.scale(1,-1),mi(t,h.canvas,0,0,a,l,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);if(!t){U("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t)}paintImageXObjectRepeat(e,t,i,s){if(!this.contentVisible)return;let n=this.getObject(e);if(!n){U("Dependent image isn't ready yet");return}let r=n.width,a=n.height,l=[];for(let c=0,h=s.length;c<h;c+=2)l.push({transform:[t,0,0,i,s[c],s[c+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,l)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;let{bitmap:t,width:i,height:s}=e,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(t,0,0),r.filter="none",n.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t=e.width,i=e.height,s=this.ctx;if(this.save(),!At){let{filter:a}=s;a!=="none"&&a!==""&&(s.filter="none")}s.scale(1/t,-1/i);let n;if(e.bitmap)n=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)n=e;else{let l=this.cachedCanvases.getCanvas("inlineImage",t,i).context;Lr(l,e),n=this.applyTransferMapsToCanvas(l)}let r=this._scaleImage(n,Kt(s));s.imageSmoothingEnabled=Dr(et(s),e.interpolate),mi(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,t,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let i=this.ctx,s;if(e.bitmap)s=e.bitmap;else{let n=e.width,r=e.height,l=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Lr(l,e),s=this.applyTransferMapsToCanvas(l)}for(let n of t)i.save(),i.transform(...n.transform),i.scale(1,-1),mi(i,s,n.x,n.y,n.w,n.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){e==="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(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let i=this.ctx;this.pendingClip&&(t||(this.pendingClip===Fr?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=et(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),i=Math.hypot(e[0],e[2]),s=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:i,c:s,d:n}=this.ctx.getTransform(),r,a;
2if(i===0&&s===0){let l=Math.abs(t),c=Math.abs(n);if(l===c)if(e===0)r=a=1/l;else{let h=l*e;r=a=h<1?1/h:1}else if(e===0)r=1/l,a=1/c;else{let h=l*e,d=c*e;r=h<1?1/h:1,a=d<1?1/d:1}}else{let l=Math.abs(t*n-i*s),c=Math.hypot(t,i),h=Math.hypot(s,n);if(e===0)r=h/l,a=c/l;else{let d=e*l;r=h>d?h/d:1,a=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(t.lineWidth=i||1,s===1&&n===1){t.stroke();return}let r=t.getLineDash();if(e&&t.save(),t.scale(s,n),r.length>0){let a=Math.max(s,n);t.setLineDash(r.map(l=>l/a)),t.lineDashOffset/=a}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(let o in Vt)ke.prototype[o]!==void 0&&(ke.prototype[Vt[o]]=ke.prototype[o]);var ue=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");this.#t=e}static get workerSrc(){return this.#e}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");this.#e=e}},$s=class{#t;#e;constructor({parsedData:e,rawData:t}){this.#t=e,this.#e=t}getRaw(){return this.#e}get(e){return this.#t.get(e)??null}getAll(){return Hn(this.#t)}has(e){return this.#t.has(e)}},Ee=Symbol("INTERNAL"),Us=class{#t=!1;#e=!1;#i=!1;#s=!0;constructor(e,{name:t,intent:i,usage:s,rbGroups:n}){this.#t=!!(e&Rt.DISPLAY),this.#e=!!(e&Rt.PRINT),this.name=t,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;let{print:e,view:t}=this.usage;return this.#t?t?.viewState!=="OFF":this.#e?e?.printState!=="OFF":!0}_setVisible(e,t,i=!1){e!==Ee&&Z("Internal method `_setVisible` called."),this.#i=i,this.#s=t}},js=class{#t=null;#e=new Map;#i=null;#s=null;constructor(e,t=Rt.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,this.#s=e.order;for(let i of e.groups)this.#e.set(i.id,new Us(t,i));if(e.baseState==="OFF")for(let i of this.#e.values())i._setVisible(Ee,!1);for(let i of e.on)this.#e.get(i)._setVisible(Ee,!0);for(let i of e.off)this.#e.get(i)._setVisible(Ee,!1);this.#i=this.getHash()}}#r(e){let t=e.length;if(t<2)return!0;let i=e[0];for(let s=1;s<t;s++){let n=e[s],r;if(Array.isArray(n))r=this.#r(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return U(`Optional content group not found: ${n}`),!0;switch(i){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return i==="And"}isVisible(e){if(this.#e.size===0)return!0;if(!e)return Ji("Optional content group not defined."),!0;if(e.type==="OCG")return this.#e.has(e.id)?this.#e.get(e.id).visible:(U(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return this.#r(e.expression);if(!e.policy||e.policy==="AnyOn"){for(let t of e.ids){if(!this.#e.has(t))return U(`Optional content group not found: ${t}`),!0;if(this.#e.get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(let t of e.ids){if(!this.#e.has(t))return U(`Optional content group not found: ${t}`),!0;if(!this.#e.get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(let t of e.ids){if(!this.#e.has(t))return U(`Optional content group not found: ${t}`),!0;if(!this.#e.get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(let t of e.ids){if(!this.#e.has(t))return U(`Optional content group not found: ${t}`),!0;if(this.#e.get(t).visible)return!1}return!0}return U(`Unknown optional content policy ${e.policy}.`),!0}return U(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,i=!0){let s=this.#e.get(e);if(!s){U(`Optional content group not found: ${e}`);return}if(i&&t&&s.rbGroups.length)for(let n of s.rbGroups)for(let r of n)r!==e&&this.#e.get(r)?._setVisible(Ee,!1,!0);s._setVisible(Ee,!!t,!0),this.#t=null}setOCGState({state:e,preserveRB:t}){let i;for(let s of e){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let n=this.#e.get(s);if(n)switch(i){case"ON":this.setVisibility(s,!0,t);break;case"OFF":this.setVisibility(s,!1,t);break;case"Toggle":this.setVisibility(s,!n.visible,t);break}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Hn(this.#e):null}getGroup(e){return this.#e.get(e)||null}getHash(){if(this.#t!==null)return this.#t;let e=new Ei;for(let[t,i]of this.#e)e.update(`${t}:${i.visible}`);return this.#t=e.hexdigest()}},Gs=class{constructor(e,{disableRange:t=!1,disableStream:i=!1}){dt(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=e;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){let l=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!i,this._isRangeSupported=!t,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),e.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let i=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{let s=this._rangeReaders.some(function(n){return n._begin!==e?!1:(n._enqueue(i),!0)});dt(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){e.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){dt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new Ws(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let i=new Xs(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}},Ws=class{constructor(e,t,i=!1,s=null){this._stream=e,this._done=i||!1,this._filename=zn(s)?s:null,this._queuedChunks=t||[],this._loaded=0;for(let n of this._queuedChunks)this._loaded+=n.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return I(this,null,function*(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},Xs=class{constructor(e,t,i){this._stream=e,this._begin=t,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return I(this,null,function*(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};function Wa(o){let e=!0,t=i("filename\\*","i").exec(o);if(t){t=t[1];let h=a(t);return h=unescape(h),h=l(h),h=c(h),n(h)}if(t=r(o),t){let h=c(t);return n(h)}if(t=i("filename","i").exec(o),t){t=t[1];let h=a(t);return h=c(h),n(h)}function i(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function s(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(h,{fatal:!0}),p=ts(d);d=u.decode(p),e=!1}catch{}}return d}function n(h){return e&&/[\x80-\xff]/.test(h)&&(h=s("utf-8",h),e&&(h=s("iso-8859-1",h))),h}function r(h){let d=[],u,p=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(h))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}let f=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=l(m))),f.push(m)}return f.join("")}function a(h){if(h.startsWith('"')){let d=h.slice(1).split('\\"');for(let u=0;u<d.length;++u){let p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function l(h){let d=h.indexOf("'");if(d===-1)return h;let u=h.slice(0,d),f=h.slice(d+1).replace(/^[^']*'/,"");return s(u,f)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,f){if(p==="q"||p==="Q")return f=f.replaceAll("_"," "),f=f.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),s(u,f);try{f=atob(f)}catch{}return s(u,f)})}return""}function $r(o,e){let t=new Headers;if(!o||!e||typeof e!="object")return t;for(let i in e){let s=e[i];s!==void 0&&t.append(i,s)}return t}function ss(o){try{return new URL(o).origin}catch{}return null}function Ur({responseHeaders:o,isHttp:e,rangeChunkSize:t,disableRange:i}){let s={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(o.get("Content-Length"),10);return!Number.isInteger(n)||(s.suggestedLength=n,n<=2*t)||i||!e||o.get("Accept-Ranges")!=="bytes"||(o.get("Content-Encoding")||"identity")!=="identity"||(s.allowRangeRequests=!0),s}function jr(o){let e=o.get("Content-Disposition");if(e){let t=Wa(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(zn(t))return t}return null}function ns(o,e){return o===404||o===0&&e.startsWith("file:")?new pe('Missing PDF "'+e+'".'):new Te(`Unexpected server response
2(${o}) while retrieving PDF "${e}".`,o)}function Gr(o){return o===200||o===206}function Wr(o,e,t){return{method:"GET",headers:o,signal:t.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Xr(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(U(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}var Di=class{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=$r(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return dt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new qs(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let i=new Ks(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},qs=class{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;let i=new Headers(e.headers),s=t.url;fetch(s,Wr(i,this._withCredentials,this._abortController)).then(n=>{if(e._responseOrigin=ss(n.url),!Gr(n.status))throw ns(n.status,s);this._reader=n.body.getReader(),this._headersCapability.resolve();let r=n.headers,{allowRangeRequests:a,suggestedLength:l}=Ur({responseHeaders:r,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=l||this._contentLength,this._filename=jr(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Qt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){yield this._headersCapability.promise;let{value:e,done:t}=yield this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Xr(e),done:!1})})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},Ks=class{constructor(e,t,i){this._stream=e,this._reader=null,this._loaded=0;let s=e.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;let n=new Headers(e.headers);n.append("Range",`bytes=${t}-${i-1}`);let r=s.url;fetch(r,Wr(n,this._withCredentials,this._abortController)).then(a=>{let l=ss(a.url);if(l!==e._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${e._responseOrigin}".`);if(!Gr(a.status))throw ns(a.status,r);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){yield this._readCapability.promise;let{value:e,done:t}=yield this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Xr(e),done:!1})})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},bs=200,_s=206;function Xa(o){let e=o.response;return typeof e!="string"?e:ts(e).buffer}var Ys=class{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:i}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=$r(this.isHttp,t),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){let t=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(let[n,r]of this.headers)t.setRequestHeader(n,r);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),s.expectedStatus=_s):s.expectedStatus=bs,t.responseType="arraybuffer",dt(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,i),t.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=e.onHeadersReceived,s.onDone=e.onDone,s.onError=e.onError,s.onProgress=e.onProgress,t.send(null),i}onProgress(e,t){let i=this.pendingRequests[e];i&&i.onProgress?.(t)}onStateChange(e,t){let i=this.pendingRequests[e];if(!i)return;let s=i.xhr;if(s.readyState>
2=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),s.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],s.status===0&&this.isHttp){i.onError(s.status);return}let n=s.status||bs;if(!(n===bs&&i.expectedStatus===_s)&&n!==i.expectedStatus){i.onError(s.status);return}let a=Xa(s);if(n===_s){let l=s.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);c?i.onDone({begin:parseInt(c[1],10),chunk:a}):(U('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):i.onError(s.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}},Qs=class{constructor(e){this._source=e,this._manager=new Ys(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return dt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Zs(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let i=new Js(this._manager,e,t);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},Zs=class{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=ss(t.responseURL);let i=t.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{let[l,...c]=a.split(": ");return[l,c.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=Ur({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=jr(s),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=ns(e,this._url),this._headersCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){return I(this,null,function*(){if(yield this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0,this._headersCapability.reject(e);for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest
2(this._fullRequestId),this._fullRequestReader=null}},Js=class{constructor(e,t,i){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let e=ss(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=ns(e,this._url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}read(){return I(this,null,function*(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise})}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},qa=/^[a-z][a-z0-9\-+.]+:/i;function Ka(o){if(qa.test(o))return new URL(o);let e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(o))}var tn=class{constructor(e){this.source=e,this.url=Ka(e.url),dt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return dt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new en(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let i=new sn(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},en=class{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new pe(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Qt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},sn=class{constructor(e,t,i){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let s=e.source;this._isStreamingSupported=!s.disableStream;let n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:t,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){return I(this,null,function*(){if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}},Ya=1e5,kt=30,Qa=.8,qe=class o{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#l=0;#o=0;#h=null;#c=null;#u=0;#d=0;#p=Object.create(null);#a=[];#f=null;#m=[];#g=new WeakMap;#b=null;static#x=new Map;static#_=new Map;static#y=new WeakMap;static#A=null;static#S=new Set;constructor({textContentSource:e,container:t,viewport:i}){if(e instanceof ReadableStream)this.#f=e;else if(typeof e=="object")this.#f=new ReadableStream({start(l){l.enqueue(e),l.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=t,this.#d=i.scale*(globalThis.devicePixelRatio||1),this.#u=i.rotation,this.#n={div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:n,pageX:r,pageY:a}=i.rawDims;this.#b=[1,0,0,-1,-r,a+n],this.#o=s,this.#l=n,o.#R(),fe(t,i),this.#t.promise.finally(()=>{o.#S.delete(this),this.#n=null,this.#p=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=bt.platform;return j(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){let e=()=>{this.#h.read().then(({value:t,done:i})=>{if(i){this.#t.resolve();return}this.#r??=t.lang,Object.assign(this.#p,t.styles),this.#k(t.items),e()},this.#t.reject)};return this.#h=this.#f.getReader(),o.#S.add(this),e(),this.#t.promise}update({viewport:e,onBefore:t=null}){let i=e.scale*(globalThis.devicePixelRatio||1),s=e.rotation;if(s!==this.#u&&(t?.(),this.#u=s,fe(this.#c,{rotation:s})),i!==this.#d){t?.(),this.#d=i;let n={div:null,properties:null,ctx:o.#P(this.#r)};for(let r of this.#m)n.properties=this.#g.get(r),n.div=r,this.#w(n)}}cancel(){let e=new Qt("TextLayer task cancelled.");this.#h?.cancel(e).catch(()=>{}),this.#h=null,this.#t.reject(e)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#a}#k(e){if(this.#i)return;this.#n.ctx??=o.#P(this.#r);let t=this.#m,i=this.#a;for(let s of e){if(t.length>Ya){U("Ignoring additional textDivs for performance reasons."),this.#i=!0;return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){let n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),s.id!==null&&this.#e.setAttribute("id",`${s.id}`),n.append(this.#e)}else s.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}i.push(s.str),this.#T(s)}}#T(e){let t=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};this.#m.push(t);let s=D.transform(this.#b,e.transform),n=Math.atan2(s[1],s[0]),r=this.#p[e.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#s&&r.fontSubstitution||r.fontFamily;a=o.fontFamilyMap.get(a)||a;let l=Math.hypot(s[2],s[3]),c=l*o.#O(a,this.#r),h,d;n===0?(h=s[4],d=s[5]-c):(h=s[4]+c*Math.sin(n),d=s[5]-c*Math.cos(n));let u="calc(var(--scale-factor)*",p=t.style;this.#e===this.#c?(p.left=`${(100*h/this.#o).toFixed(2)}%`,p.top=`${(100*d/this.#l).toFixed(2)}%`):(p.left=`${u}${h.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(o.#A*l).toFixed(2)}px)`,p.fontFamily=a,i.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#s&&(t.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName),n!==0&&(i.angle=n*(180/Math.PI));let f=!1;if(e.str.length>1)f=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){let g=Math.abs(e.transform[0]),b=Math.abs(e.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(f=!0)}if(f&&(i.canvasWidth=r.vertical?e.height:e.width),this.#g.set(t,i),this.#n.div=t,this.#n.properties=i,this.#w(this.#n),i.hasText&&this.#e.append(t),i.hasEOL){let g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#w(e){let{div:t,properties:i,ctx:s}=e,{style:n}=t,r="";if(o.#A>1&&(r=`scale(${1/o.#A})`),i.canvasWidth!==0&&i.hasText){let{fontFamily:a}=n,{canvasWidth:l,fontSize:c}=i;o.#E(s,c*this.#d,a);let{width:h}=s.measureText(t.textContent);h>0&&(r=`scaleX(${l*this.#d/h}) ${r}`)}i.angle!==0&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#S.size>0)){this.#x.clear();for(let{canvas:e}of this.#_.values())e.remove();this.#_.clear()}}static#P(e=null){let t=this.#_.get(e||="");if(!t){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=e,document.body.append(i),t=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(e,t),this.#y.set(t,{size:0,family:""})}return t}static#E(e,t,i){let s=this.#y.get(e);t===s.size&&i===s.family||(e.font=`${t}px ${i}`,s.size=t,s.family=i)}static#R(){if(this.#A!==null)return;let e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#A=e.getBoundingClientRect().height,e.remove()}static#O(e,t){let i=this.#x.get(e);if(i)return i;let s=this.#P(t);
2s.canvas.width=s.canvas.height=kt,this.#E(s,kt,e);let n=s.measureText(""),r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){let h=r/(r+a);return this.#x.set(e,h),s.canvas.width=s.canvas.height=0,h}s.strokeStyle="red",s.clearRect(0,0,kt,kt),s.strokeText("g",0,0);let l=s.getImageData(0,0,kt,kt).data;a=0;for(let h=l.length-1-3;h>=0;h-=4)if(l[h]>0){a=Math.ceil(h/4/kt);break}s.clearRect(0,0,kt,kt),s.strokeText("A",0,kt),l=s.getImageData(0,0,kt,kt).data,r=0;for(let h=0,d=l.length;h<d;h+=4)if(l[h]>0){r=kt-Math.floor(h/4/kt);break}s.canvas.width=s.canvas.height=0;let c=r?r/(r+a):Qa;return this.#x.set(e,c),c}},Ke=class o{static textContent(e){let t=[],i={items:t,styles:Object.create(null)};function s(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(o.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&t.push({str:r}),!!n.children)for(let l of n.children)s(l)}return s(e),i}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}},Za=65536,Ja=100,to=5e3,eo=At?Os:Rs,io=At?Ds:Mi,so=At?Ls:Is,no=At?Fs:Li;function ro(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});let e=new nn,{docId:t}=e,i=o.url?ao(o.url):null,s=o.data?oo(o.data):null,n=o.httpHeaders||null,r=o.withCredentials===!0,a=o.password??null,l=o.range instanceof Fi?o.range:null,c=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:Za,h=o.worker instanceof Pe?o.worker:null,d=o.verbosity,u=typeof o.docBaseUrl=="string"&&!is(o.docBaseUrl)?o.docBaseUrl:null,p=typeof o.cMapUrl=="string"?o.cMapUrl:null,f=o.cMapPacked!==!1,g=o.CMapReaderFactory||io,b=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,m=o.StandardFontDataFactory||no,x=o.stopAtErrors!==!0,y=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,A=o.isEvalSupported!==!1,C=typeof o.isOffscreenCanvasSupported=="boolean"?o.isOffscreenCanvasSupported:!At,P=typeof o.isImageDecoderSupported=="boolean"?o.isImageDecoderSupported:!At&&(bt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,B=typeof o.disableFontFace=="boolean"?o.disableFontFace:At,H=o.fontExtraProperties===!0,X=o.enableXfa===!0,G=o.ownerDocument||globalThis.document,st=o.disableRange===!0,ut=o.disableStream===!0,Q=o.disableAutoFetch===!0,Et=o.pdfBug===!0,O=o.CanvasFactory||eo,N=o.FilterFactory||so,Lt=o.enableHWA===!0,$t=l?l.length:o.length??NaN,le=typeof o.useSystemFonts=="boolean"?o.useSystemFonts:!At&&!B,Ot=typeof o.useWorkerFetch=="boolean"?o.useWorkerFetch:g===Mi&&m===Li&&p&&b&&Be(p,document.baseURI)&&Be(b,document.baseURI),ft=null;ya(d);let lt={canvasFactory:new O({ownerDocument:G,enableHWA:Lt}),filterFactory:new N({docId:t,ownerDocument:G}),cMapReaderFactory:Ot?null:new g({baseUrl:p,isCompressed:f}),standardFontDataFactory:Ot?null:new m({baseUrl:b})};if(!h){let Dt={verbosity:d,port:ue.workerPort};h=Dt.port?Pe.fromPort(Dt):new Pe(Dt),e._worker=h}let be={docId:t,apiVersion:"4.10.38",data:s,password:a,disableAutoFetch:Q,rangeChunkSize:c,length:$t,docBaseUrl:u,enableXfa:X,evaluatorOptions:{maxImageSize:y,disableFontFace:B,ignoreErrors:x,isEvalSupported:A,isOffscreenCanvasSupported:C,isImageDecoderSupported:P,canvasMaxAreaInBytes:S,fontExtraProperties:H,useSystemFonts:le,cMapUrl:Ot?p:null,standardFontDataUrl:Ot?b:null}},Me={disableFontFace:B,fontExtraProperties:H,ownerDocument:G,pdfBug:Et,styleElement:ft,loadingParams:{disableAutoFetch:Q,enableXfa:X}};return h.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");let Dt=h.messageHandler.sendWithPromise("GetDocRequest",be,s?[s.buffer]:null),J;if(l)J=new Gs(l,{disableRange:st,disableStream:ut});else if(!s){if(!i)throw new Error("getDocument - no `url` parameter provided.");let Ut;if(At)if(Be(i)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Ut=Di}else Ut=tn;else Ut=Be(i)?Di:Qs;J=new Ut({url:i,length:$t,httpHeaders:n,withCredentials:r,rangeChunkSize:c,disableRange:st,disableStream:ut})}return Dt.then(Ut=>{if(e.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");
2let Wn=new de(t,Ut,h.port),Qr=new ln(Wn,e,J,Me,lt);e._transport=Qr,Wn.send("Ready",null)})}).catch(e._capability.reject),e}function ao(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(At&&typeof o=="string")return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function oo(o){if(At&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if(typeof o=="string")return ts(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="object"&&!isNaN(o?.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Nr(o){return typeof o=="object"&&Number.isInteger(o?.num)&&o.num>=0&&Number.isInteger(o?.gen)&&o.gen>=0}var nn=class o{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${o.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return I(this,null,function*(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),yield this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null})}},Fi=class{constructor(e,t,i=!1,s=null){this.length=e,this.initialData=t,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let i of this._rangeListeners)i(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let i of this._progressListeners)i(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Z("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},rn=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}
2getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}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:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}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(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}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()}},an=class{#t=null;#e=!1;constructor(e,t,i,s=!1){this._pageIndex=e,this._pageInfo=t,this._transport=i,this._stats=s?new wi:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Ni,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:e,rotation:t=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new $e({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return I(this,null,function*(){return this._transport._htmlForXfa?.children[this._pageIndex]||null})}render({canvasContext:e,viewport:t,intent:i="display",annotationMode:s=ne.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");let u=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:p,cacheKey:f}=u;this.#e=!1,this.#s(),a||=this._transport.getOptionalContentConfig(p);let g=this._intentStates.get(f);g||(g=Object.create(null),this._intentStates.set(f,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let b=!!(p&Rt.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));let m=A=>{g.renderTasks.delete(x),(this._maybeCleanupAfterRender||b)&&(this.#e=!0),this.#i(!b),A?(x.capability.reject(A),this._abortOperatorList({intentState:g,reason:A instanceof Error?A:new Error(A)})):x.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new hn({callback:m,params:{canvasContext:e,viewport:t,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,page
2Colors:c});(g.renderTasks||=new Set).add(x);let y=x.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([A,C])=>{if(this.destroyed){m();return}if(this._stats?.time("Rendering"),!(C.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:A,optionalContentConfig:C}),x.operatorListChanged()}).catch(m),y}getOperatorList({intent:e="display",annotationMode:t=ne.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(l))}let r=this._transport.getRenderingIntent(e,t,i,s,!0),a=this._intentStates.get(r.cacheKey);a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a));let l;return a.opListReadCapability||(l=Object.create(null),l.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(l),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>Ke.textContent(i));let t=this.streamTextContent(e);return new Promise(function(i,s){function n(){r.read().then(function({value:l,done:c}){if(c){i(a);return}a.lang??=l.lang,Object.assign(a.styles,l.styles),a.items.push(...l.items),n()},s)}let r=t.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let i of t.renderTasks)e.push(i.completed),i.cancel();return this.objs.clear(),this.#e=!1,this.#s(),Promise.all(e)}cleanup(e=!1){this.#e=!0;let t=this.#i(!1);return e&&t&&(this._stats&&=new wi),t}#i(e=!1){if(this.#s(),!this.#e||this.destroyed)return!1;if(e)return this.#t=setTimeout(()=>{this.#t=null,this.#i(!1)},to),!1;for(let{renderTasks:t,operatorList:i}of this._intentStates.values())if(t.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#s(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(e,t){let i=this._intentStates.get(t);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let i=0,s=e.length;i<s;i++)t.operatorList.fnArray.push(e.fnArray[i]),t.operatorList.argsArray.push(e.argsArray[i]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let i of t.renderTasks)i.operatorListChanged();e.lastChunk&&this.#i(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i,modifiedIds:s}){let{map:n,transfer:r}=i,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:n,modifiedIds:s},r).getReader(),c=this._intentStates.get(t);c.streamReader=l;let h=()=>{l.read().then(({value:d,done:u})=>{if(u){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),h())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(let u of c.renderTasks)u.operatorListChanged();this.#i(!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};h()}_abortOperatorList({intentState:e,reason:t,force:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!i){if(e.renderTasks.size>0)return;if(t instanceof Ue){let s=Ja;t.extraDelay>0&&t.extraDelay<1e3&&(s+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},s);return}}if(e.streamReader.cancel(new Qt(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[s,n]of this._intentStates)if(n===e){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}},on=class{#t=new Map;#e=Promise.resolve();postMessage(e,t){let i={data:structuredClone(e,t?{transfer:t}:null)};this.#e.then(()=>{for(let[s]of this.#t)s.call(this,i)})}addEventListener(e,t,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:n}=i;if(n.aborted){U("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(e,t);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(t,s)}removeEventListener(e,t){this.#t.get(t)?.(),this.#t.delete(t)}terminate(){for(let[,e]of this.#t)e?.();this.#t.clear()}},Pe=class o{static#t=0;static#e=!1;static#i;static{At&&(this.#e=!0,ue.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let i;try{if(i=new URL(e),!i.origin||i.origin==="null")return!1}catch{return!1}let s=new URL(t,i);return i.origin===s.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:i=wa()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(o.#i?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(o.#i||=new WeakMap).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return this._readyCapability.promise}#s(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new de("main","worker",e),this._messageHandler.on("ready",function(){}),this.#s()}_initialize(){if(o.#e||o.#r){this._setupFakeWorker();return}let{workerSrc:e}=o;try{o._isSameOrigin(window.location.href,e)||(e=o._createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:"module"}),i=new de("main","worker",t),s=()=>{n.abort(),i.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;t.addEventListener("error",()=>{this._webWorker||s()},{signal:n.signal}),i.on("test",a=>{if(n.abort(),this.destroyed||!a){s();return}this._messageHandler=i,this._port=t,this._webWorker=t,this.#s()}),i.on("ready",a=>{if(n.abort(),this.destroyed){s();return}try{r()}catch{this._setupFakeWorker()}});let r=()=>{let a=new Uint8Array;i.send("test",a,[a.buffer])};r();return}catch{Ji("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){o.#e||(U("Setting up fake worker."),o.#e=!0),o._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let t=new on;this._port=t;let i=`fake${o.#t++}`,s=new de(i+"_worker",i,t);e.setup(s,t),this._messageHandler=new de(i,i+"_worker",t),this.#s()}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,o.#i?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let t=this.#i?.get(e.port);
2if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new o(e)}static get workerSrc(){if(ue.workerSrc)return ue.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#r(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return j(this,"_setupFakeWorkerGlobal",I(this,null,function*(){return this.#r?this.#r:(yield import(this.workerSrc)).WorkerMessageHandler}))}},ln=class{#t=new Map;#e=new Map;#i=new Map;#s=new Map;#r=null;constructor(e,t,i,s,n){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Ni,this.fontLoader=new Ts({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#n(e,t=null){let i=this.#t.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise(e,t);return this.#t.set(e,s),s}get annotationStorage(){return j(this,"annotationStorage",new We)}getRenderingIntent(e,t=ne.ENABLE,i=null,s=!1,n=!1){let r=Rt.DISPLAY,a=Ps;switch(e){case"any":r=Rt.ANY;break;case"display":break;case"print":r=Rt.PRINT;break;default:U(`getRenderingIntent - invalid intent: ${e}`)}let l=r&Rt.PRINT&&i instanceof ki?i:this.annotationStorage;switch(t){case ne.DISABLE:r+=Rt.ANNOTATIONS_DISABLE;break;case ne.ENABLE:break;case ne.ENABLE_FORMS:r+=Rt.ANNOTATIONS_FORMS;break;case ne.ENABLE_STORAGE:r+=Rt.ANNOTATIONS_STORAGE,a=l.serializable;break;default:U(`getRenderingIntent - invalid annotationMode: ${t}`)}s&&(r+=Rt.IS_EDITING),n&&(r+=Rt.OPLIST);let{ids:c,hash:h}=l.modifiedIds,d=[r,a.hash,h];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:c}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));let e=[];for(let i of this.#e.values())e.push(i._destroy());this.#e.clear(),this.#i.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),qe.cleanup(),this._networkStream?.cancelAllRequests(new Qt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(i,s)=>{dt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},s.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){s.close();return}dt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{s.error(n)})},s.onCancel=n=>{this._fullReader.cancel(n),s.ready.catch(r=>{if(!this.destroyed)throw r})}}),e.on("ReaderHeadersReady",i=>I(this,null,function*(){yield this._fullReader.headersReady;let{isStreamingSupported:s,isRangeSupported:n,contentLength:r}=this._fullReader;return(!s||!n)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=a=>{t.onProgress?.({loaded:a.loaded,total:a.total})}),{isStreamingSupported:s,isRangeSupported:n,contentLength:r}})),e.on("GetRangeReader",(i,s)=>{dt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(i.begin,i.end);if(!n){s.close();return}s.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){s.close();return}dt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{s.error(r)})},s.onCancel=r=>{n.cancel(r),s.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("GetDoc",({pdfInfo:i})=>{this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,t._capability.resolve(new rn(i,this))}),e.on("DocException",i=>{t._capability.reject(Pt(i))}),e.on("PasswordRequest",i=>{this.#r=Promise.withResolvers();try{if(!t.onPassword)throw Pt(i);let s=n=>{n instanceof Error?this.#r.reject(n):this.#r.resolve({password:n})};t.onPassword(s,i.code)}catch(s){this.#r.reject(s)}return this.#r.promise}),e.on("DataLoaded",i=>{t.onProgress?.({loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),e.on("StartRenderPage",i=>{if(this.destroyed)return;this.#e.get(i.pageIndex)._startRenderPage(i.transparency,i.cacheKey)}),e.on("commonobj",([i,s,n])=>{if(this.destroyed||this.commonObjs.has(i))return null;switch(s){case"Font":let{disableFontFace:r,fontExtraProperties:a,pdfBug:l}=this._params;if("error"in n){let u=n.error;U(`Error during font loading: ${u}`),this.commonObjs.resolve(i,u);break}let c=l&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,h=new Ms(n,{disableFontFace:r,fontExtraProperties:a,inspectFont:c});this.fontLoader.bind(h).catch(()=>
2e.sendWithPromise("FontFallback",{id:i})).finally(()=>{!a&&h.data&&(h.data=null),this.commonObjs.resolve(i,h)});break;case"CopyLocalImage":let{imageRef:d}=n;dt(d,"The imageRef must be defined.");for(let u of this.#e.values())for(let[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(i,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(i,n);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),e.on("obj",([i,s,n,r])=>{if(this.destroyed)return;let a=this.#e.get(s);if(!a.objs.has(i)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(i,r),r?.dataLen>ma&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(i,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),e.on("DocProgress",i=>{this.destroyed||t.onProgress?.({loaded:i.loaded,total:i.total})}),e.on("FetchBuiltInCMap",i=>I(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(i)})),e.on("FetchStandardFontData",i=>I(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(i)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&U("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));let t=e-1,i=this.#i.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#s.set(n.refStr,e);let r=new an(t,n,this,this._params.pdfBug);return this.#e.set(t,r),r});return this.#i.set(t,s),s}getPageIndex(e){return Nr(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#n("GetFieldObjects")}hasJSActions(){return this.#n("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}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.#n("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#n("GetOptionalContentConfig").then(t=>new js(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=this.#t.get(e);if(t)return t;
2let i=this.messageHandler.sendWithPromise(e,null).then(s=>({info:s[0],metadata:s[1]?new $s(s[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(e,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return I(this,null,function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let t of this.#e.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),qe.cleanup()}})}cachedPageNumber(e){if(!Nr(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this.#s.get(t)??null}},Fe=Symbol("INITIAL_DATA"),Ni=class{#t=Object.create(null);#e(e){return this.#t[e]||=_e(Nt({},Promise.withResolvers()),{data:Fe})}get(e,t=null){if(t){let s=this.#e(e);return s.promise.then(()=>t(s.data)),null}let i=this.#t[e];
2if(!i||i.data===Fe)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return i.data}has(e){let t=this.#t[e];return!!t&&t.data!==Fe}delete(e){let t=this.#t[e];return!t||t.data===Fe?!1:(delete this.#t[e],!0)}resolve(e,t=null){let i=this.#e(e);i.data=t,i.resolve()}clear(){for(let e in this.#t){let{data:t}=this.#t[e];t?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let e in this.#t){let{data:t}=this.#t[e];t!==Fe&&(yield[e,t])}}},cn=class{#t=null;constructor(e){this.#t=e,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(e=0){this.#t.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#t.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#t;return e.form||e.canvas&&t?.size>0}},hn=class o{#t=null;static#e=new WeakSet;constructor({callback:e,params:t,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=e,this.params=t,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new cn(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=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(o.#e.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.");o.#e.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:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new ke(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:e,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),o.#e.delete(this._canvas),this.callback(e||new Ue(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return I(this,null,function*(){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(),o.#e.delete(this._canvas),this.callback())))})}},lo="4.10.38",co="f9bea397f";function Br(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function Ne(o){return Math.max(0,Math.min(255,255*o))}var Bi=class{static CMYK_G([e,t,i,s]){return["G",1-Math.min(1,.3*e+.59*i+.11*t+s)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=Ne(e),[e,e,e]}static G_HTML([e]){let t=Br(e);return`#${t}${t}${t}`}static RGB_G([e,t,i]){return["G",.3*e+.59*t+.11*i]}static RGB_rgb(e){return e.map(Ne)}static RGB_HTML(e){return`#${e.map(Br).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,i,s]){return["RGB",1-Math.min(1,e+s),1-Math.min(1,i+s),1-Math.min(1,t+s)]}static CMYK_rgb([e,t,i,s]){return[Ne(1-Math.min(1,e+s)),Ne(1-Math.min(1,i+s)),Ne(1-Math.min(1,t+s))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,i]){let s=1-e,n=1-t,r=1-i,a=Math.min(s,n,r);return["CMYK",s,n,r,a]}},dn=class{create(e,t,i=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${e}px`),s.setAttribute("height",`${t}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${e} ${t}`),s}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Z("Abstract method `_createSVG` called.")}},Ye=class extends dn{_createSVG(e){return document.createElementNS(te,e)}},Hi=class{static setupStorage(e,t,i,s,n){let r=s.getValue(t,{value:null});switch(i.name){case"textarea":if(r.value!==null&&(e.textContent=r.value),n==="print")break;e.addEventListener("input",a=>{s.setValue(t,{value:a.target.value})});break;case"input":if(i.attributes.type==="radio"||i.attributes.type==="checkbox"){if(r.value===i.attributes.xfaOn?e.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&e.removeAttribute("checked"),n==="print")break;e.addEventListener("change",a=>{s.setValue(t,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&e.setAttribute("value",r.value),n==="print")break;e.addEventListener("input",a=>{s.setValue(t,{value:a.target.value})})}break;case"select":if(r.value!==null){e.setAttribute("value",r.value);for(let a of i.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}e.addEventListener("input",a=>{let l=a.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;s.setValue(t,{value:c})});break}}static setAttributes({html:e,element:t,storage:i=null,intent:s,linkService:n}){let{attributes:r}=t,a=e instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${s}`);for(let[l,c]of Object.entries(r))if(c!=null)switch(l){case"class":c.length&&e.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",c);break;case"style":Object.assign(e.style,c);break;case"textContent":e.textContent=c;break;default:(!a||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,c)}a&&n.addLinkAttributes(e,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(e,r.dataId,t,i)}static render(e){let t=e.annotationStorage,i=e.linkService,s=e.xfaHtml,n=e.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});let a=n!=="richText",l=e.div;if(l.append(r),e.viewport){let d=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=d}a&&l.setAttribute("class","xfaLayer xfaFont");let c=[];if(s.children.length===0){if(s.value){let d=document.createTextNode(s.value);r.append(d),a&&Ke.shouldBuildText(s.name)&&c.push(d)}return{textDivs:c}}let h=[[s,-1,r]];for(;h.length>0;){let[d,u,p]=h.at(-1);if(u+1===d.children.length){h.pop();continue}let f=d.children[++h.at(-1)[1]];if(f===null)continue;let{name:g}=f;if(g==="#text"){let m=document.createTextNode(f.value);c.push(m),p.append(m);continue}let b=f?.attributes?.xmlns?document.createElementNS(f.attributes.xmlns,g):document.createElement(g);if(p.append(b),f.attributes&&this.setAttributes({html:b,element:f,storage:t,intent:n,linkService:i}),f.children?.length>0)h.push([f,-1,b]);else if(f.value){let m=document.createTextNode(f.value);a&&Ke.shouldBuildText(g)&&c.push(m),b.append(m)}}for(let d of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}},ei=1e3,ho=9,me=new WeakSet;function re(o){return{width:o[2]-o[0],height:o[3]-o[1]}}var un=class{static create(e){switch(e.data.annotationType){case pt.LINK:return new Vi(e);case pt.TEXT:return new pn(e);case pt.WIDGET:switch(e.data.fieldType){case"Tx":return new fn(e);case"Btn":return e.data.radioButton?new zi(e):e.data.checkBox?new mn(e):new bn(e);case"Ch":return new _n(e);case"Sig":return new gn(e)}return new ee(e);case pt.POPUP:return new Qe(e);case pt.FREETEXT:return new $i(e);case pt.LINE:return new xn(e);case pt.SQUARE:return new yn(e);case pt.CIRCLE:return new wn(e);case pt.POLYLINE:return new Ui(e);case pt.CARET:return new Cn(e);case pt.INK:return new Ze(e);case pt.POLYGON:return new An(e);case pt.HIGHLIGHT:return new ji(e);case pt.UNDERLINE:return new Sn(e);case pt.SQUIGGLY:return new En(e);case pt.STRIKEOUT:return new kn(e);case pt.STAMP:return new Gi(e);case pt.FILEATTACHMENT:return new Pn(e);default:return new ot(e)}}},ot=class o{#t=null;#e=!1;#i=null;constructor(e,{isRenderable:t=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:i}){return!!(e?.str||t?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return o._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#s(t),this.#i?.popup.updateEdited(e)}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}
2#s(e){let{container:{style:t},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:l}}}}=this;i?.splice(0,4,...e);let{width:c,height:h}=re(e);t.left=`${100*(e[0]-a)/n}%`,t.top=`${100*(r-e[3]+l)/r}%`,s===0?(t.width=`${100*c/n}%`,t.height=`${100*h/r}%`):this.setRotation(s)}_createContainer(e){let{data:t,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",t.id),this instanceof ee||(n.tabIndex=ei);let{style:r}=n;if(r.zIndex=this.parent.zIndex++,t.alternativeText&&(n.title=t.alternativeText),t.noRotate&&n.classList.add("norotate"),!t.rect||this instanceof Qe){let{rotation:g}=t;return!t.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}let{width:a,height:l}=re(t.rect);if(!e&&t.borderStyle.width>0){r.borderWidth=`${t.borderStyle.width}px`;let g=t.borderStyle.horizontalCornerRadius,b=t.borderStyle.verticalCornerRadius;if(g>0||b>0){let x=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=x}else if(this instanceof zi){let x=`calc(${a}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;r.borderRadius=x}switch(t.borderStyle.style){case Oe.SOLID:r.borderStyle="solid";break;case Oe.DASHED:r.borderStyle="dashed";break;case Oe.BEVELED:U("Unimplemented border style: beveled");break;case Oe.INSET:U("Unimplemented border style: inset");break;case Oe.UNDERLINE:r.borderBottomStyle="solid";break;default:break}let m=t.borderColor||null;m?(this.#e=!0,r.borderColor=D.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}let c=D.normalizeRect([t.rect[0],i.view[3]-t.rect[1]+i.view[1],t.rect[2],i.view[3]-t.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:u,pageY:p}=s.rawDims;r.left=`${100*(c[0]-u)/h}%`,r.top=`${100*(c[1]-p)/d}%`;let{rotation:f}=t;return t.hasOwnCanvas||f===0?(r.width=`${100*a/h}%`,r.height=`${100*l/d}%`):this.setRotation(f,n),n}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=re(this.data.rect),a,l;e%180===0?(a=100*n/i,l=100*r/s):(a=100*r/i,l=100*n/s),t.style.width=`${a}%`,t.style.height=`${l}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(t,i,s)=>{let n=s.detail[t],r=n[0],a=n.slice(1);s.target.style[i]=Bi[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[i]:Bi[`${r}_rgb`](a)})};return j(this,"_commonActions",{display:t=>{let{display:i}=t.detail,s=i%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:i===1||i===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:i}=t.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{let i=t.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(e,t){let i=this._commonActions;for(let s of Object.keys(t.detail))(e[s]||i[s])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let i=this._commonActions;for(let[s,n]of Object.entries(t)){let r=i[s];if(r){let a={detail:{[s]:n},target:e};r(a),delete t[s]}}}
2_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,i,s,n]=this.data.rect.map(g=>Math.fround(g));if(e.length===8){let[g,b,m,x]=e.subarray(2,6);if(s===g&&n===b&&t===m&&i===x)return}let{style:r}=this.container,a;if(this.#e){let{borderColor:g,borderWidth:b}=r;r.borderWidth=0,a=["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="${g}" stroke-width="${b}">`],this.container.classList.add("hasBorder")}let l=s-t,c=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let u=h.createElement("defs");d.append(u);let p=h.createElement("clipPath"),f=`clippath_${this.data.id}`;p.setAttribute("id",f),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let g=2,b=e.length;g<b;g+=8){let m=e[g],x=e[g+1],y=e[g+2],A=e[g+3],C=h.createElement("rect"),P=(y-t)/l,S=(n-x)/c,B=(m-y)/l,H=(x-A)/c;C.setAttribute("x",P),C.setAttribute("y",S),C.setAttribute("width",B),C.setAttribute("height",H),p.append(C),a?.push(`<rect vector-effect="non-scaling-stroke" x="${P}" y="${S}" width="${B}" height="${H}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){let{data:e}=this,t=this.#i=new Qe({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Z("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[e];if(s)for(let{page:n,id:r,exportValues:a}of s){if(n===-1||r===t)continue;let l=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!me.has(c)){U(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:l,domElement:c})}return i}for(let s of document.getElementsByName(e)){let{exportValue:n}=s,r=s.getAttribute("data-element-id");r!==t&&me.has(s)&&i.push({id:r,exportValue:n,domElement:s})}return i}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 e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}},Vi=class extends ot{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let s=!1;return e.url?(t.addLinkAttributes(i,e.url,e.newWindow),s=!0):e.action?(this._bindNamedAction(i,e.action),s=!0):e.attachment?(this.#e(i,e.attachment,e.attachmentDest),s=!0):e.setOCGState?(this.#i(i,e.setOCGState),s=!0):e.dest?(this._bindLink(i,e.dest),s=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),s=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t==="")&&this.#t()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#t()}#e(e,t,i=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,i),!1),this.#t()}#i(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#t()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(t.actions)){let n=i.get(s);n&&(e[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:s}}),!1))}e.onclick||(e.onclick=()=>!1),this.#t()}
2_bindResetFormAction(e,t){let i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){U('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{i?.();let{fields:s,refs:n,include:r}=t,a=[];if(s.length!==0||n.length!==0){let h=new Set(n);for(let d of s){let u=this._fieldObjects[d]||[];for(let{id:p}of u)h.add(p)}for(let d of Object.values(this._fieldObjects))for(let u of d)h.has(u.id)===r&&a.push(u)}else for(let h of Object.values(this._fieldObjects))a.push(...h);let l=this.annotationStorage,c=[];for(let h of a){let{id:d}=h;switch(c.push(d),h.type){case"text":{let p=h.defaultValue||"";l.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{let p=h.defaultValue===h.exportValues;l.setValue(d,{value:p});break}case"combobox":case"listbox":{let p=h.defaultValue||"";l.setValue(d,{value:p});break}default:continue}let u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!me.has(u)){U(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}}),!1}}},pn=class extends ot{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}},ee=class extends ot{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return bt.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,i,s,n){i.includes("mouse")?e.addEventListener(i,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):e.addEventListener(i,r=>{if(i==="blur"){if(!t.focused||!r.relatedTarget)return;t.focused=!1}else if(i==="focus"){if(t.focused)return;t.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r)}})})}_setEventListeners(e,t,i,s){for(let[n,r]of i)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(t||={focused:!1}),this._setEventListener(e,t,n,r,s),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(e,t,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(e,t,"focus","Focus",null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":D.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||ho,n=e.style,r,a=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){let c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),h=Math.round(c/(vi*s))||1,d=c/h;r=Math.min(s,l(d/vi))}else{let c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(s,l(c/vi))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=D.makeHexColor(i[0],i[1],i[2]),this.data.textAlignment!==null&&(n.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}},fn=class extends ee{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,i,s){let n=this.annotationStorage;
vendor: 3,691 bytes, lines 2-3
2for(let r of this._getElementsByName(e.name,e.id))r.domElement&&(r.domElement[t]=i),n.setValue(r.id,{[s]:i})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=e.getValue(t,{value:this.data.fieldValue}),n=s.value||"",r=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join(` 3`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let l={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),me.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=ei,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",h=>{e.setValue(t,{value:h.target.value}),this.setPropertyOnSiblings(i,"value",h.target.value,"value"),l.formattedValue=null}),i.addEventListener("resetform",h=>{let d=this.data.defaultFieldValue??"";i.value=l.userValue=d,l.formattedValue=null});let c=h=>{let{formattedValue:d}=l;d!=null&&(h.target.value=d),h.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",d=>{if(l.focused)return;let{target:u}=d;l.userValue&&(u.value=l.userValue),l.lastCommittedValue=u.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)}),i.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);let u={value(p){l.userValue=p.detail.value??"",e.setValue(t,{value:l.userValue.toString()}),p.target.value=l.userValue},formattedValue(p){let{formattedValue:f}=p.detail;l.formattedValue=f,f!=null&&p.target!==document.activeElement&&(p.target.value=f),e.setValue(t,{formattedValue:f})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{let{charLimit:f}=p.detail,{target:g}=p;if(f===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",f);let b=l.userValue;!b||b.length<=f||(b=b.slice(0,f),g.value=l.userValue=b,e.setValue(t,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("keydown",d=>{l.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(l.commitKey=3),u===-1)return;let{value:p}=d.target;l.lastCommittedValue!==p&&(l.lastCommittedValue=p,l.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:p,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});let h=c;c=null,i.addEventListener("blur",d=>{if(!l.focused||!d.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);let{value:u}=d.target;l.userValue=u,l.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:u,willCommit:!0,commitKey:l.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),h(d)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",d=>{l.lastCommittedValue=null;let{data:u,target:p}=d,{value:f,selectionStart:g,selectionEnd:b}=p,m=g,x=b;switch(d.inputType){case"deleteWordBackward":{let y=f.substring(0,g).match(/\w*[^\w]*$/);y&&(m-=y[0].length);break}
3case"deleteWordForward":{let y=f.substring(g).match(/^[^\w]*\w*/);y&&(x+=y[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(x+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:f,change:u||"",willCommit:!1,selStart:m,selEnd:x}})}),this._setEventListeners(i,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(c&&i.addEventListener("blur",c),this.data.comb){let d=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},gn=class extends ee{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},mn=class extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,i=t.id,s=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",e.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");return me.add(n),n.setAttribute("data-element-id",i),n.disabled=t.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=t.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",t.exportValue),n.tabIndex=ei,n.addEventListener("change",r=>{let{name:a,checked:l}=r.target;for(let c of this._getElementsByName(a,i)){let h=l&&c.exportValue===t.exportValue;c.domElement&&(c.domElement.checked=h),e.setValue(c.id,{value:h})}e.setValue(i,{value:l})}),n.addEventListener("resetform",r=>{let a=t.defaultFieldValue||"Off";r.target.checked=a===t.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{let a={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(i,{value:l.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},zi=class extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,i=t.id,s=e.getValue(i,{value:t.fieldValue===t.buttonValue}).value;if(typeof s=="string"&&(s=s!==t.buttonValue,e.setValue(i,{value:s})),s)for(let r of this._getElementsByName(t.fieldName,i))e.setValue(r.id,{value:!1});let n=document.createElement("input");if(me.add(n),n.setAttribute("data-element-id",i),n.disabled=t.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=t.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=ei,n.addEventListener("change",r=>{let{name:a,checked:l}=r.target;for(let c of this._getElementsByName(a,i))e.setValue(c.id,{value:!1});e.setValue(i,{value:l})}),n.addEventListener("resetform",r=>{let a=t.defaultFieldValue;r.target.checked=a!=null&&a===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;n.addEventListener("updatefromsandbox",a=>{let l={value:c=>{let h=r===c.detail.value;for(let d of this._getElementsByName(c.target.name)){let u=h&&d.id===i;d.domElement&&(d.domElement.checked=u),e.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(l,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}
3return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},bn=class extends Vi{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({},i)})),e}},_n=class extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,i=e.getValue(t,{value:this.data.fieldValue}),s=document.createElement("select");me.add(s),s.setAttribute("data-element-id",t),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=ei;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",h=>{let d=this.data.defaultFieldValue;for(let u of s.options)u.selected=u.value===d});for(let h of this.data.options){let d=document.createElement("option");d.textContent=h.displayValue,d.value=h.exportValue,i.value.includes(h.exportValue)&&(d.setAttribute("selected",!0),n=!1),s.append(d)}let r=null;if(n){let h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),s.prepend(h),r=()=>{h.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}let a=h=>{let d=h?"value":"textContent",{options:u,multiple:p}=s;return p?Array.prototype.filter.call(u,f=>f.selected).map(f=>f[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]},l=a(!1),c=h=>{let d=h.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",h=>{let d={value(u){r?.();let p=u.detail.value,f=new Set(Array.isArray(p)?p:[p]);for(let g of s.options)g.selected=f.has(g.value);e.setValue(t,{value:a(!0)}),l=a(!1)},multipleSelection(u){s.multiple=!0},remove(u){let p=s.options,f=u.detail.remove;p[f].selected=!1,s.remove(f),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),e.setValue(t,{value:a(!0),items:c(u)}),l=a(!1)},clear(u){for(;s.length!==0;)s.remove(0);e.setValue(t,{value:null,items:[]}),l=a(!1)},insert(u){let{index:p,displayValue:f,exportValue:g}=u.detail.insert,b=s.children[p],m=document.createElement("option");m.textContent=f,m.value=g,b?b.before(m):s.append(m),e.setValue(t,{value:a(!0),items:c(u)}),l=a(!1)},items(u){let{items:p}=u.detail;for(;s.length!==0;)s.remove(0);for(let f of p){let{displayValue:g,exportValue:b}=f,m=document.createElement("option");m.textContent=g,m.value=b,s.append(m)}s.options.length>0&&(s.options[0].selected=!0),e.setValue(t,{value:a(!0),items:c(u)}),l=a(!1)},indices(u){let p=new Set(u.detail.indices);for(let f of u.target.options)f.selected=p.has(f.index);e.setValue(t,{value:a(!0)}),l=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,h)}),s.addEventListener("input",h=>{let d=a(!0),u=a(!1);e.setValue(t,{value:d}),h.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],h=>h.target.value)):s.addEventListener("input",function(h){e.setValue(t,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},Qe=class extends ot{constructor(e){let{data:t,elements:i}=e;super(e,{isRenderable:ot._hasPopupData(t)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");let e=this.popup=new vn({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}),t=[];for(let i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",t.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(i=>`${Vn}${i}`).join(",")),this.container}}
3,vn=class{#t=this.#k.bind(this);#e=this.#E.bind(this);#i=this.#P.bind(this);#s=this.#w.bind(this);#r=null;#n=null;#l=null;#o=null;#h=null;#c=null;#u=null;#d=!1;#p=null;#a=null;#f=null;#m=null;#g=null;#b=null;#x=!1;constructor({container:e,color:t,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:l,rect:c,parentRect:h,open:d}){this.#n=e,this.#g=s,this.#l=r,this.#m=a,this.#c=l,this.#r=t,this.#f=c,this.#u=h,this.#h=i,this.#o=Ai.toDateObject(n),this.trigger=i.flatMap(u=>u.getElementsToTriggerPopup());for(let u of this.trigger)u.addEventListener("click",this.#s),u.addEventListener("mouseenter",this.#i),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(let u of i)u.container?.addEventListener("keydown",this.#t);this.#n.hidden=!0,d&&this.#w()}render(){if(this.#p)return;let e=this.#p=document.createElement("div");if(e.className="popup",this.#r){let n=e.style.outlineColor=D.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:e.style.backgroundColor=D.makeHexColor(...this.#r.map(a=>Math.floor(.7*(255-a)+a)))}let t=document.createElement("span");t.className="header";let i=document.createElement("h1");if(t.append(i),{dir:i.dir,str:i.textContent}=this.#g,e.append(t),this.#o){let n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#o.valueOf()})),t.append(n)}let s=this.#_;if(s)Hi.render({xfaHtml:s,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{let n=this._formatContents(this.#l);e.append(n)}this.#n.append(e)}get#_(){let e=this.#m,t=this.#l;return e?.str&&(!t?.str||t.str===e.str)&&this.#m.html||null}get#y(){return this.#_?.attributes?.style?.fontSize||0}get#A(){return this.#_?.attributes?.style?.color||null}#S(e){let t=[],i={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},s={style:{color:this.#A,fontSize:this.#y?`calc(${this.#y}px * var(--scale-factor))`:""}};for(let n of e.split(` 4`))t.push({name:"span",value:n,attributes:s});return i}_formatContents({str:e,dir:t}){let i=document.createElement("p");i.classList.add("popupContent"),i.dir=t;let s=e.split(/(?:\r\n?|\n)/);for(let n=0,r=s.length;n<r;++n){let a=s[n];i.append(document.createTextNode(a)),n<r-1&&i.append(document.createElement("br"))}return i}#k(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&this.#d)&&this.#w()}updateEdited({rect:e,popupContent:t}){this.#b||={contentsObj:this.#l,richText:this.#m},e&&(this.#a=null),t&&(this.#m=this.#S(t),this.#l=null),this.#p?.remove(),this.#p=null}resetEdited(){this.#b&&({contentsObj:this.#l,richText:this.#m}=this.#b,this.#b=null,this.#p?.remove(),this.#p=null,this.#a=null)}#T(){if(this.#a!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:s,pageY:n}}}=this.#c,r=!!this.#u,a=r?this.#u:this.#f;for(let f of this.#h)if(!a||D.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}let l=D.normalizeRect([a[0],e[3]-a[1]+e[1],a[2],e[3]-a[3]+e[1]]),h=r?a[2]-a[0]+5:0,d=l[0]+h,u=l[1];this.#a=[100*(d-s)/t,100*(u-n)/i];let{style:p}=this.#n;p.left=`${this.#a[0]}%`,p.top=`${this.#a[1]}%`}#w(){this.#d=!this.#d,this.#d?(this.#P(),this.#n.addEventListener("click",this.#s),this.#n.addEventListener("keydown",this.#t)):(this.#E(),this.#n.removeEventListener("click",this.#s),this.#n.removeEventListener("keydown",this.#t))}#P(){this.#p||this.render(),this.isVisible?this.#d&&this.#n.classList.add("focused"):(this.#T(),this.#n.hidden=!1,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)+1e3)}#E(){this.#n.classList.remove("focused"),!(this.#d||!this.isVisible)&&(this.#n.hidden=!0,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#n.hidden=!0)}maybeShow(){this.#x&&(this.#p||this.#P(),this.#x=!1,this.#n.hidden=!1)}get isVisible(){return this.#n.hidden===!1}},$i=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=$.FREETEXT}
4render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(let t of this.textContent){let i=document.createElement("span");i.textContent=t,e.append(i)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},xn=class extends ot{#t=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let e=this.data,{width:t,height:i}=re(e.rect),s=this.svgFactory.create(t,i,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),n.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),n.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),n.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),n.setAttribute("stroke-width",e.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},yn=class extends ot{#t=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let e=this.data,{width:t,height:i}=re(e.rect),s=this.svgFactory.create(t,i,!0),n=e.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",t-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},wn=class extends ot{#t=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let e=this.data,{width:t,height:i}=re(e.rect),s=this.svgFactory.create(t,i,!0),n=e.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",t/2),r.setAttribute("cy",i/2),r.setAttribute("rx",t/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Ui=class extends ot{#t=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:i,popupRef:s}}=this;if(!t)return this.container;let{width:n,height:r}=re(e),a=this.svgFactory.create(n,r,!0),l=[];for(let h=0,d=t.length;h<d;h+=2){let u=t[h]-e[0],p=e[3]-t[h+1];l.push(`${u},${p}`)}l=l.join(" ");let c=this.#t=this.svgFactory.createElement(this.svgElementName);return c.setAttribute("points",l),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),a.append(c),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},An=class extends Ui{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Cn=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Ze=class extends ot{#t=null;#e=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?$.HIGHLIGHT:$.INK}#i(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:l}=this.#i(t,e),c=this.svgFactory.create(a,l,!0),h=this.#t=this.svgFactory.createElement("svg:g");c.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let d=0,u=i.length;d<u;d++){let p=this.svgFactory.createElement(this.svgElementName);this.#e.push(p),p.setAttribute("points",i[d].join(",")),h.append(p)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:i,rect:s}=e,n=this.#t;if(t>
4=0&&n.setAttribute("stroke-width",t||1),i)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",i[r].join(","));if(s){let{transform:r,width:a,height:l}=this.#i(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${l}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},ji=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=$.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},Sn=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}},En=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}},kn=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}},Gi=class extends ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=$.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Pn=class extends ot{#t=null;constructor(e){super(e,{isRenderable:!0});let{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",Nt({source:this},t))}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:t}=this,i;t.hasAppearance||t.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),i.addEventListener("dblclick",this.#e.bind(this)),this.#t=i;let{isMac:s}=bt.platform;return e.addEventListener("keydown",n=>{n.key==="Enter"&&(s?n.metaKey:n.ctrlKey)&&this.#e()}),!t.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Tn=class{#t=null;#e=null;#i=new Map;#s=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=e,this.#t=t,this.#e=i,this.#s=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#i.size>0}#r(e,t){return I(this,null,function*(){let i=e.firstChild||e,s=i.id=`${Vn}${t}`,n=yield this.#s?.getAriaAttributes(s);if(n)for(let[r,a]of n)i.setAttribute(r,a);this.div.append(e),this.#t?.moveElementInDOM(this.div,e,i,!1)})}render(e){return I(this,null,function*(){let{annotations:t}=e,i=this.div;fe(i,this.viewport);let s=new Map,n={data:null,layer:i,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new Ye,annotationStorage:e.annotationStorage||new We,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let r of t){if(r.noHTML)continue;let a=r.annotationType===pt.POPUP;if(a){let h=s.get(r.id);if(!h)continue;n.elements=h}else{let{width:h,height:d}=re(r.rect);if(h<=0||d<=0)continue}n.data=r;let l=un.create(n);if(!l.isRenderable)continue;if(!a&&r.popupRef){let h=s.get(r.popupRef);h?h.push(l):s.set(r.popupRef,[l])}let c=l.render();r.hidden&&(c.style.visibility="hidden"),yield this.#r(c,r.id),l._isEditable&&(this.#i.set(l.data.id,l),this._annotationEditorUIManager?.renderAnnotationElement(l))}this.#n()})}update({viewport:e}){let t=this.div;this.viewport=e,fe(t,{rotation:e.rotation}),this.#n(),t.hidden=!1}#n(){if(!this.#e)return;let e=this.div;for(let[t,i]of this.#e){let s=e.querySelector(`[data-annotation-id="${t}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:n}=s;n?n.nodeName==="CANVAS"?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#i.values())}getEditableAnnotation(e){return this.#i.get(e)}},_i=/\r\n?|\n/g,Mn=class o extends it{#t;#e="";#i=`${this.id}-editor`;#s=null;#r;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let e=o.prototype,t=n=>n.isEmpty(),i=Ge.TRANSLATE_SMALL,s=Ge.TRANSLATE_BIG;return j(this,"_keyboardManager",new ge([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-s,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[s,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-s],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,s],checker:t}]]))}static _type="freetext";static _editorType=$.FREETEXT;constructor(e){super(_e(Nt({},e),{name:"freeTextEditor"})),this.#t=e.color||o._defaultColor||it._defaultLineColor,this.#r=e.fontSize||o._defaultFontSize}static initialize(e,t){it.initialize(e,t);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
4static updateDefaultParams(e,t){switch(e){case W.FREETEXT_SIZE:o._defaultFontSize=t;break;case W.FREETEXT_COLOR:o._defaultColor=t;break}}updateParams(e,t){switch(e){case W.FREETEXT_SIZE:this.#n(t);break;case W.FREETEXT_COLOR:this.#l(t);break}}static get defaultPropertiesToUpdate(){return[[W.FREETEXT_SIZE,o._defaultFontSize],[W.FREETEXT_COLOR,o._defaultColor||it._defaultLineColor]]}get propertiesToUpdate(){return[[W.FREETEXT_SIZE,this.#r],[W.FREETEXT_COLOR,this.#t]]}#n(e){let t=s=>{this.editorDiv.style.fontSize=`calc(${s}px * var(--scale-factor))`,this.translate(0,-(s-this.#r)*this.parentScale),this.#r=s,this.#h()},i=this.#r;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(e){let t=s=>{this.#t=this.editorDiv.style.color=s},i=this.#t;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-o._internalPadding*e,-(o._internalPadding+this.#r)*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar($.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let e=this._uiManager.combinedSignal(this.#s);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#i),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&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()}#o(){let e=[];this.editorDiv.normalize();let t=null;for(let i of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&i.nodeName==="BR"||(e.push(o.#c(i)),t=i);return e.join(` 5`)}#h(){let[e,t]=this.parentDimensions,i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{let{currentLayer:s,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",s.div.append(this.div),i=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/t):(this.width=i.height/e,this.height=i.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#e,t=this.#e=this.#o().trimEnd();if(e===t)return;let i=s=>{if(this.#e=s,!s){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#h()};this.addCommands({cmd:()=>{i(t)},undo:()=>{i(e)},mustExec:!1}),this.#h()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){o._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){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)}
5render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#i),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ci(this,this.div,["dblclick","keydown"]),this.width){let[s,n]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[a,l]=this.getInitialTranslation();[a,l]=this.pageTranslationToScreen(a,l);let[c,h]=this.pageDimensions,[d,u]=this.pageTranslation,p,f;switch(this.rotation){case 0:p=e+(r[0]-d)/c,f=t+this.height-(r[1]-u)/h;break;case 90:p=e+(r[0]-d)/c,f=t-(r[1]-u)/h,[a,l]=[l,-a];break;case 180:p=e-this.width+(r[0]-d)/c,f=t-(r[1]-u)/h,[a,l]=[-a,-l];break;case 270:p=e+(r[0]-d-this.height*h)/c,f=t+(r[1]-u-this.width*c)/h,[a,l]=[-l,a];break}this.setAt(p*s,f*n,a,l)}else this.setAt(e*s,t*n,this.width*s,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#c(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(_i,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:i}=t;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();let s=o.#p(t.getData("text")||"").replaceAll(_i,` 6`);if(!s)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!s.includes(`
7`)){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:l}=r,c=[],h=[];if(a.nodeType===Node.TEXT_NODE){let p=a.parentElement;if(h.push(a.nodeValue.slice(l).replaceAll(_i,"")),p!==this.editorDiv){let f=c;for(let g of this.editorDiv.childNodes){if(g===p){f=h;continue}f.push(o.#c(g))}}c.push(a.nodeValue.slice(0,l).replaceAll(_i,""))}else if(a===this.editorDiv){let p=c,f=0;for(let g of this.editorDiv.childNodes)f++===l&&(p=h),p.push(o.#c(g))}this.#e=`${c.join(` 8`)}${s}${h.join(` 9`)}`,this.#u();let d=new Range,u=c.reduce((p,f)=>p+f.length,0);for(let{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){let f=p.nodeValue.length;if(u<=f){d.setStart(p,u),d.setEnd(p,u);break}u-=f}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let e of this.#e.split(` 10`)){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#d(){return this.#e.replaceAll("\xA0"," ")}static#p(e){return e.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static deserialize(e,t,i){return I(this,null,function*(){let s=null;if(e instanceof $i){let{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:l,rotation:c,id:h,popupRef:d},textContent:u,textPosition:p,parent:{page:{pageNumber:f}}}=e;if(!u||u.length===0)return null;s=e={annotationType:$.FREETEXT,color:Array.from(a),fontSize:r,value:u.join(` 11`),position:p,pageIndex:f-1,rect:l.slice(0),rotation:c,id:h,deleted:!1,popupRef:d}}let n=yield ce(o,this,"deserialize").call(this,e,t,i);return n.#r=e.fontSize,n.#t=D.makeHexColor(...e.color),n.#e=o.#p(e.value),n.annotationElementId=e.id||null,n._initialData=s,n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=o._internalPadding*this.parentScale,i=this.getRect(t,t),s=it._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),n={annotationType:$.FREETEXT,color:s,fontSize:this.#r,value:this.#d(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?n:this.annotationElementId&&!this.#a(n)?null:(n.id=this.annotationElementId,n)}#a(e){let{value:t,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==i||e.color.some((r,a)=>r!==s[a])||e.pageIndex!==n}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(this.deleted)return t;let{style:i}=t;i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,t.replaceChildren();for(let n of this.#e.split(` 12`)){let r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),t.append(r)}let s=o._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(s,s),popupContent:this.#e}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}},R=(()=>{class o{static PRECISION=1e-4;toSVGPath(){Z("Abstract method `toSVGPath` must be implemented.")}get box(){Z("Abstract getter `box` must be implemented.")}serialize(t,i){Z("Abstract method `serialize` must be implemented.")}static _rescale(t,i,s,n,r,a){a||=new Float32Array(t.length);for(let l=0,c=t.length;l<c;l+=2)a[l]=i+t[l]*n,a[l+1]=s+t[l+1]*r;return a}static _rescaleAndSwap(t,i,s,n,r,a){a||=new Float32Array(t.length);for(let l=0,c=t.length;l<c;l+=2)a[l]=i+t[l+1]*n,a[l+1]=s+t[l]*r;return a}static _translate(t,i,s,n){n||=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r+=2)n[r]=i+t[r],n[r+1]=s+t[r+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,i,s,n,r){switch(r){case 90:return[1-i/s,t/n];case 180:return[1-t/s,1-i/n];case 270:return[i/s,1-t/n];default:return[t/s,i/n]}}static _normalizePagePoint(t,i,s){switch(s){case 90:return[1-i,t];case 180:return[1-t,1-i];case 270:return[i,1-t];default:return[t,i]}}static createBezierPoints(t,i,s,n,r,a){return[(t+5*s)/6,(i+5*n)/6,(5*s+r)/6,(5*n+a)/6,(s+r)/2,(n+a)/2]}}return o})(),Wi=class o{#t;#e=[];#i;#s;#r=[];#n=new Float32Array(18);#l;#o;#h;#c;#u;#d;#p=[];static#a=8;static#f=2;static#m=o.#a+o.#f;constructor({x:e,y:t},i,s,n,r,a=0){this.#t=i,this.#d=n*s,this.#s=r,this.#n.set([NaN,NaN,NaN,NaN,e,t],6),this.#i=a,this.#c=o.#a*s,this.#h=o.#m*s,this.#u=s,this.#p.push(e,t)}isEmpty(){return isNaN(this.#n[8])}#g(){let e=this.#n.subarray(4,6),t=this.#n.subarray(16,18),[i,s,n,r]=this.#t;return[(this.#l+(e[0]-t[0])/2-i)/n,(this.#o+(e[1]-t[1])/2-s)/r,(this.#l+(t[0]-e[0])/2-i)/n,(this.#o+(t[1]-e[1])/2-s)/r]}add({x:e,y:t}){this.#l=e,this.#o=t;let[i,s,n,r]=this.#t,[a,l,c,h]=this.#n.subarray(8,12),d=e-c,u=t-h,p=Math.hypot(d,u);if(p<this.#h)return!1;let f=p-this.#c,g=f/p,b=g*d,m=g*u,x=a,y=l;a=c,l=h,c+=b,h+=m,this.#p?.push(e,t);let A=-m/f,C=b/f,P=A*this.#d,S=C*this.#d;return this.#n.set(this.#n.subarray(2,8),0),this.#n.set([c+P,h+S],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([c-P,h-S],16),isNaN(this.#n[6])?(this.#r.length===0&&(this.#n.set([a+P,l+S],2),this.#r.push(NaN,NaN,NaN,NaN,(a+P-i)/n,(l+S-s)/r),this.#n.set([a-P,l-S],14),this.#e.push(NaN,NaN,NaN,NaN,(a-P-i)/n,(l-S-s)/r)),this.#n.set([x,y,a,l,c,h],6),!this.isEmpty()):(this.#n.set([x,y,a,l,c,h],6),Math.abs(Math.atan2(y-l,x-a)-Math.atan2(m,b))<Math.PI/2?([a,l,c,h]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+c)/2-i)/n,((l+h)/2-s)/r),[a,l,x,y]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((x+a)/2-i)/n,((y+l)/2-s)/r),!0):([x,y,a,l,c,h]=this.#n.subarray(0,6),this.#r.push(((x+5*a)/6-i)/n,((y+5*l)/6-s)/r,((5*a+c)/6-i)/n,((5*l+h)/6-s)/r,((a+c)/2-i)/n,((l+h)/2-s)/r),[c,h,a,l,x,y]=this.#n.subarray(12,18),this.#e.push(((x+5*a)/6-i)/n,((y+5*l)/6-s)/r,((5*a+c)/6-i)/n,((5*l+h)/6-s)/r,((a+c)/2-i)/n,((l+h)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";let e=this.#r,t=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#b();let i=[];i.push(`M${e[4]} ${e[5]}`);for(let s=6;s<e.length;s+=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);this.#_(i);for(let s=t.length-6;s>=6;s-=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);return this.#x(i),i.join(" ")}#b(){let[e,t,i,s]=this.#t,[n,r,a,l]=this.#g();return`M${(this.#n[2]-e)/i} ${(this.#n[3]-t)/s} L${(this.#n[4]-e)/i} ${(this.#n[5]-t)/s} L${n} ${r} L${a} ${l} L${(this.#n[16]-e)/i} ${(this.#n[17]-t)/s} L${(this.#n[14]-e)/i} ${(this.#n[15]-t)/s} Z`}#x(e){let t=this.#e;e.push(`L${t[4]} ${t[5]} Z`)}#_(e){let[t,i,s,n]=this.#t,r=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[l,c,h,d]=this.#g();e.push(`L${(r[0]-t)/s} ${(r[1]-i)/n} L${l} ${c} L${h} ${d} L${(a[0]-t)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(e,t,i,s,n,r){return new Xi(e,t,i,s,n,r)}getOutlines(){let e=this.#r,t=this.#e,i=this.#n,[s,n,r,a]=this.#t,l=new Float32Array((this.#p?.length??0)+2);for(let d=0,u=l.length-2;d<u;d+=2)l[d]=(this.#p[d]-s)/r,l[d+1]=(this.#p[d+1]-n)/a;if(l[l.length-2]=(this.#l-s)/r,l[l.length-1]=(this.#o-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#y(l);let c=new Float32Array(this.#r.length+24+this.#e.length),h=e.length;for(let d=0;d<h;d+=2){if(isNaN(e[d])){c[d]=c[d+1]=NaN;continue}c[d]=e[d],c[d+1]=e[d+1]}h=this.#S(c,h);for(let d=t.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(t[d+u])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=t[d+u],c[h+1]=t[d+u+1],h+=2}return this.#A(c,h),this.newFreeDrawOutline(c,l,this.#t,this.#u,this.#i,this.#s)}#y(e){let t=this.#n,[i,s,n,r]=this.#t,[a,l,c,h]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(t[2]-i)/n,(t[3]-s)/r,NaN,NaN,NaN,NaN,(t[4]-i)/n,(t[5]-s)/r,NaN,NaN,NaN,NaN,a,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(t[16]-i)/n,(t[17]-s)/r,NaN,NaN,NaN,NaN,(t[14]-i)/n,(t[15]-s)/r],0),this.newFreeDrawOutline(d,e,this.#t,this.#u,this.#i,this.#s)}#A(e,t){let i=this.#e;return e.set([NaN,NaN,NaN,NaN,i[4],i[5]],t),t+=6}#S(e,t){let i=this.#n.subarray(4,6),s=this.#n.subarray(16,18),[n,r,a,l]=this.#t,[c,h,d,u]=this.#g();return e.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/l],t),t+=24}},Xi=class extends R{#t;
12#e=new Float32Array(4);#i;#s;#r;#n;#l;constructor(e,t,i,s,n,r){super(),this.#l=e,this.#r=t,this.#t=i,this.#n=s,this.#i=n,this.#s=r,this.lastPoint=[NaN,NaN],this.#o(r);let[a,l,c,h]=this.#e;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/c,e[d+1]=(e[d+1]-l)/h;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/c,t[d+1]=(t[d+1]-l)/h}toSVGPath(){let e=[`M${this.#l[4]} ${this.#l[5]}`];for(let t=6,i=this.#l.length;t<i;t+=6){if(isNaN(this.#l[t])){e.push(`L${this.#l[t+4]} ${this.#l[t+5]}`);continue}e.push(`C${this.#l[t]} ${this.#l[t+1]} ${this.#l[t+2]} ${this.#l[t+3]} ${this.#l[t+4]} ${this.#l[t+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,t,i,s],n){let r=i-e,a=s-t,l,c;switch(n){case 0:l=R._rescale(this.#l,e,s,r,-a),c=R._rescale(this.#r,e,s,r,-a);break;case 90:l=R._rescaleAndSwap(this.#l,e,t,r,a),c=R._rescaleAndSwap(this.#r,e,t,r,a);break;case 180:l=R._rescale(this.#l,i,t,-r,a),c=R._rescale(this.#r,i,t,-r,a);break;case 270:l=R._rescaleAndSwap(this.#l,i,s,-r,-a),c=R._rescaleAndSwap(this.#r,i,s,-r,-a);break}return{outline:Array.from(l),points:[Array.from(c)]}}#o(e){let t=this.#l,i=t[4],s=t[5],n=i,r=s,a=i,l=s,c=i,h=s,d=e?Math.max:Math.min;for(let p=6,f=t.length;p<f;p+=6){if(isNaN(t[p]))n=Math.min(n,t[p+4]),r=Math.min(r,t[p+5]),a=Math.max(a,t[p+4]),l=Math.max(l,t[p+5]),h<t[p+5]?(c=t[p+4],h=t[p+5]):h===t[p+5]&&(c=d(c,t[p+4]));else{let g=D.bezierBoundingBox(i,s,...t.slice(p,p+6));n=Math.min(n,g[0]),r=Math.min(r,g[1]),a=Math.max(a,g[2]),l=Math.max(l,g[3]),h<g[3]?(c=g[2],h=g[3]):h===g[3]&&(c=d(c,g[2]))}i=t[p+4],s=t[p+5]}let u=this.#e;u[0]=n-this.#i,u[1]=r-this.#i,u[2]=a-n+2*this.#i,u[3]=l-r+2*this.#i,this.lastPoint=[c,h]}get box(){return this.#e}newOutliner(e,t,i,s,n,r=0){return new Wi(e,t,i,s,n,r)}getNewOutline(e,t){let[i,s,n,r]=this.#e,[a,l,c,h]=this.#t,d=n*c,u=r*h,p=i*c+a,f=s*h+l,g=this.newOutliner({x:this.#r[0]*d+p,y:this.#r[1]*u+f},this.#t,this.#n,e,this.#s,t??this.#i);for(let b=2;b<this.#r.length;b+=2)g.add({x:this.#r[b]*d+p,y:this.#r[b+1]*u+f});return g.getOutlines()}},Je=class{#t;#e;#i=[];#s=[];constructor(e,t=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,l=-1/0,h=10**-4;for(let{x:m,y:x,width:y,height:A}of e){let C=Math.floor((m-t)/h)*h,P=Math.ceil((m+y+t)/h)*h,S=Math.floor((x-t)/h)*h,B=Math.ceil((x+A+t)/h)*h,H=[C,S,B,!0],X=[P,S,B,!1];this.#i.push(H,X),n=Math.min(n,C),r=Math.max(r,P),a=Math.min(a,S),l=Math.max(l,B)}let d=r-n+2*i,u=l-a+2*i,p=n-i,f=a-i,g=this.#i.at(s?-1:-2),b=[g[0],g[2]];for(let m of this.#i){let[x,y,A]=m;m[0]=(x-p)/d,m[1]=(y-f)/u,m[2]=(A-f)/u}this.#t=new Float32Array([p,f,d,u]),this.#e=b}getOutlines(){this.#i.sort((t,i)=>t[0]-i[0]||t[1]-i[1]||t[2]-i[2]);let e=[];for(let t of this.#i)t[3]?(e.push(...this.#h(t)),this.#l(t)):(this.#o(t),e.push(...this.#h(t)));return this.#r(e)}#r(e){let t=[],i=new Set;for(let r of e){let[a,l,c]=r;t.push([a,l,r],[a,c,r])}t.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=t.length;r<a;r+=2){let l=t[r][2],c=t[r+1][2];l.push(c),c.push(l),i.add(l),i.add(c)}let s=[],n;for(;i.size>0;){let r=i.values().next().value,[a,l,c,h,d]=r;i.delete(r);let u=a,p=l;for(n=[a,c],s.push(n);;){let f;if(i.has(h))f=h;else if(i.has(d))f=d;else break;i.delete(f),[a,l,c,h,d]=f,u!==a&&(n.push(u,p,a,p===l?l:c),u=a),p=p===l?c:l}n.push(u,p)}return new Rn(s,this.#t,this.#e)}#n(e){let t=this.#s,i=0,s=t.length-1;for(;i<=s;){let n=i+s>>1,r=t[n][0];if(r===e)return n;r<e?i=n+1:s=n-1}return s+1}#l([,e,t]){let i=this.#n(e);this.#s.splice(i,0,[e,t])}#o([,e,t]){let i=this.#n(e);for(let s=i;s<this.#s.length;s++){let[n,r]=this.#s[s];if(n!==e)break;if(n===e&&r===t){this.#s.splice(s,1);return}}for(let s=i-1;s>=0;s--){let[n,r]=this.#s[s];if(n!==e)break;if(n===e&&r===t){this.#s.splice(s,1);return}}}#h(e){let[t,i,s]=e,n=[[t,i,s]],r=this.#n(s);for(let a=0;a<r;a++){let[l,c]=this.#s[a];for(let h=0,d=n.length;h<d;h++){let[,u,p]=n[h];if(!(c<=u||p<=l)){if(u>=l){if(p>c)n[h][1]=c;else{if(d===1)return[];n.splice(h,1),h--,d--}continue}n[h][2]=l,p>c&&n.push([t,c,p])}}}return n}},Rn=class extends R{#t;#e;constructor(e,t,i){super(),this.#e=e,this.#t=t,this.lastPoint=i}toSVGPath(){let e=[];for(let t of this.#e){let[i,s]=t;e.push(`M${i} ${s}`);for(let n=2;n<t.length;n+=2){let r=t[n],a=t[n+1];r===i?(e.push(`V${a}`),s=a):a===s&&(e.push(`H${r}`),i=r)}e.push("Z")}return e.join(" ")}serialize([e,t,i,s],n){let r=[],a=i-e,l=s-t;for(let c of this.#e){let h=new Array(c.length);for(let d=0;d<c.length;d+=2)h[d]=e+c[d]*a,h[d+1]=s-c[d+1]*l;r.push(h)}return r}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},ti=class extends Wi{newFreeDrawOutline(e,t,i,s,n,r){return new In(e,t,i,s,n,r)}},In=class extends Xi{newOutliner(e,t,i,s,n,r=0){return new ti(e,t,i,s,n,r)}},qi=class o{#t=null;#e=null;#i;#s=null;#r=!1;#n=!1;#l=null;#o;#h=null;#c=null;#u;static#d=null;static get _keyboardManager(){return j(this,"_keyboardManager",new ge([[["Escape","mac+Escape"],o.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],o.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],o.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],o.prototype._moveToPrevious],[["Home","mac+Home"],o.prototype._moveToBeginning],[["End","mac+End"],o.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#n=!1,this.#u=W.HIGHLIGHT_COLOR,this.#l=e):(this.#n=!0,this.#u=W.HIGHLIGHT_DEFAULT_COLOR),this.#c=e?._uiManager||t,this.#o=this.#c._eventBus,this.#i=e?.color||this.#c?.highlightColors.values().next().value||"#FFFF98",o.#d||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let e=this.#t=document.createElement("button");
12e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);let t=this.#c._signal;e.addEventListener("click",this.#m.bind(this),{signal:t}),e.addEventListener("keydown",this.#f.bind(this),{signal:t});let i=this.#e=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#i,e.append(i),e}renderMainDropdown(){let e=this.#s=this.#p();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#p(){let e=document.createElement("div"),t=this.#c._signal;e.addEventListener("contextmenu",zt,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[i,s]of this.#c.highlightColors){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",o.#d[i]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#i),n.addEventListener("click",this.#a.bind(this,s),{signal:t}),e.append(n)}return e.addEventListener("keydown",this.#f.bind(this),{signal:t}),e}#a(e,t){t.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:this.#u,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#t){this.#m(e);return}let t=e.target.getAttribute("data-color");t&&this.#a(t,e)}_moveToNext(e){if(!this.#b){this.#m(e);return}if(e.target===this.#t){this.#s.firstChild?.focus();return}e.target.nextSibling?.focus()}_moveToPrevious(e){if(e.target===this.#s?.firstChild||e.target===this.#t){this.#b&&this._hideDropdownFromKeyboard();return}this.#b||this.#m(e),e.target.previousSibling?.focus()}_moveToBeginning(e){if(!this.#b){this.#m(e);return}this.#s.firstChild?.focus()}_moveToEnd(e){if(!this.#b){this.#m(e);return}this.#s.lastChild?.focus()}#f(e){o._keyboardManager.exec(this,e)}#m(e){if(this.#b){this.hideDropdown();return}if(this.#r=e.detail===0,this.#h||(this.#h=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#c.combinedSignal(this.#h)})),this.#s){this.#s.classList.remove("hidden");return}let t=this.#s=this.#p();this.#t.append(t)}#g(e){this.#s?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#h?.abort(),this.#h=null}get#b(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#n){if(!this.#b){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(e){if(this.#e&&(this.#e.style.backgroundColor=e),!this.#s)return;let t=this.#c.highlightColors.values();for(let i of this.#s.children)i.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}},Ki=class o extends it{#t=null;#e=0;#i;#s=null;#r=null;#n=null;#l=null;#o=0;#h=null;#c=null;#u=null;#d=!1;#p=null;#a;#f=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=$.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let e=o.prototype;return j(this,"_keyboardManager",new ge([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super(_e(Nt({},e),{name:"highlightEditor"})),this.color=e.color||o._defaultColor,this.#g=e.thickness||o._defaultThickness,this.#a=e.opacity||o._defaultOpacity,this.#i=e.boxes||null,this.#b=e.methodOfCreation||"",this.#m=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#d=!0,this.#_(e),this.#T()):this.#i&&(this.#t=e.anchorNode,this.#e=e.anchorOffset,this.#l=e.focu
12sNode,this.#o=e.focusOffset,this.#x(),this.#T(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#x(){let e=new Je(this.#i,.001);this.#c=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let t=new Je(this.#i,.0025,.001,this._uiManager.direction==="ltr");this.#n=t.getOutlines();let{lastPoint:i}=this.#n;this.#p=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#_({highlightOutlines:e,highlightId:t,clipPathId:i}){this.#c=e;let s=1.5;if(this.#n=e.getNewOutline(this.#g/2+s,.0025),t>=0)this.#u=t,this.#s=i,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#f=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},!0);else if(this.parent){let h=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:o.#w(this.#c.box,(h-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#f,{bbox:o.#w(this.#n.box,h),path:{d:this.#n.toSVGPath()}})}let[n,r,a,l]=e.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=l;break;case 90:{let[h,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/h,this.height=l*h/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=l;break;case 270:{let[h,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/h,this.height=l*h/d;break}}let{lastPoint:c}=this.#n;this.#p=[(c[0]-n)/a,(c[1]-r)/l]}static initialize(e,t){it.initialize(e,t),o._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case W.HIGHLIGHT_DEFAULT_COLOR:o._defaultColor=t;break;case W.HIGHLIGHT_THICKNESS:o._defaultThickness=t;break}}translateInPage(e,t){}get toolbarPosition(){return this.#p}updateParams(e,t){switch(e){case W.HIGHLIGHT_COLOR:this.#y(t);break;case W.HIGHLIGHT_THICKNESS:this.#A(t);break}}static get defaultPropertiesToUpdate(){return[[W.HIGHLIGHT_DEFAULT_COLOR,o._defaultColor],[W.HIGHLIGHT_THICKNESS,o._defaultThickness]]}get propertiesToUpdate(){return[[W.HIGHLIGHT_COLOR,this.color||o._defaultColor],[W.HIGHLIGHT_THICKNESS,this.#g||o._defaultThickness],[W.HIGHLIGHT_FREE,this.#d]]}#y(e){let t=(n,r)=>{this.color=n,this.#a=r,this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:n,"fill-opacity":r}}),this.#r?.updateColor(n)},i=this.color,s=this.#a;this.addCommands({cmd:t.bind(this,e,o._defaultOpacity),undo:t.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#A(e){let t=this.#g,i=s=>{this.#g=s,this.#S(s)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}addEditToolbar(){return I(this,null,function*(){let e=yield ce(o.prototype,this,"addEditToolbar").call(this);return e?(this._uiManager.highlightColors&&(this.#r=new qi({editor:this}),e.addColorPicker(this.#r)),e):null})}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#R())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#R())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#T(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#k():e&&(this.#T(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#S(e){if(!this.#d)return;this.#_({highlightOutlines:this.#c.getNewOutline(e/2)}),this.fixAndSetPosition();let[t,i]=this.parentDimensions;this.setDims(this.width*t,this.height*i)}#k(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#f),this.#f=null)}#T(e=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#s}=e.drawLayer.draw({bbox:this.#c.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#a},rootClass:{highlight:!0,free:this.#d},path:{d:this.#c.toSVGPath()}},!1,!0),this.#f=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},this.#d),this.#h&&(this.#h.style.clipPath=this.#s))}static#w([e,t,i,s],n){switch(n){case 90:return[1-t-s,e,s,i];case 180:return[1-e-i,1-t-s,i,s];case 270:return[t,1-e-i,s,i]}return[e,t,i,s]}rotate(e){let{drawLayer:t}=this.parent,i;this.#d?(e=(e-this.rotation+360)%360,i=o.#w(this.#c.box,e)):i=o.#w([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#u,{bbox:i,root:{"data-main-rotation":e}}),t.updateProperties(this.#f,{bbox:o.#w(this.#n.box,e),root:{"data-main-rotation":e}})}
12render(){if(this.div)return this.div;let e=super.render();this.#m&&(e.setAttribute("aria-label",this.#m),e.setAttribute("role","mark")),this.#d?e.classList.add("free"):this.div.addEventListener("keydown",this.#P.bind(this),{signal:this._uiManager._signal});let t=this.#h=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#s;let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Ci(this,this.#h,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!1}})}#P(e){o._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#E(!0);break;case 1:case 3:this.#E(!1);break}}#E(e){if(!this.#t)return;let t=window.getSelection();e?t.setPosition(this.#t,this.#e):t.setPosition(this.#l,this.#o)}select(){super.select(),this.#f&&this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#f&&(this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{selected:!1}}),this.#d||this.#E(!1))}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#f,{rootClass:{hidden:!e}}))}#R(){return this.#d?this.rotation:0}#O(){if(this.#d)return null;let[e,t]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#i,r=new Float32Array(n.length*8),a=0;for(let{x:l,y:c,width:h,height:d}of n){let u=l*e+i,p=(1-c)*t+s;r[a]=r[a+4]=u,r[a+1]=r[a+3]=p,r[a+2]=r[a+6]=u+h*e,r[a+5]=r[a+7]=p-d*t,a+=8}return r}#F(e){return this.#c.serialize(e,this.#R())}static startHighlighting(e,t,{target:i,x:s,y:n}){let{x:r,y:a,width:l,height:c}=i.getBoundingClientRect(),h=new AbortController,d=e.combinedSignal(h),u=p=>{h.abort(),this.#v(e,p)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",It,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",zt,{signal:d}),i.addEventListener("pointermove",this.#C.bind(this,e),{signal:d}),this._freeHighlight=new ti({x:s,y:n},[r,a,l,c],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#C(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(e,t,i){return I(this,null,function*(){let s=null;if(e instanceof ji){let{data:{quadPoints:f,rect:g,rotation:b,id:m,color:x,opacity:y,popupRef:A},parent:{page:{pageNumber:C}}}=e;s=e={annotationType:$.HIGHLIGHT,color:Array.from(x),opacity:y,quadPoints:f,boxes:null,pageIndex:C-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:A}}else if(e instanceof Ze){let{data:{inkLists:f,rect:g,rotation:b,id:m,color:x,borderStyle:{rawWidth:y},popupRef:A},parent:{page:{pageNumber:C}}}=e;s=e={annotationType:$.HIGHLIGHT,color:Array.from(x),thickness:y,inkLists:f,boxes:null,pageIndex:C-1,rect:g.slice(0),rotation:b,id:m,deleted:!1,popupRef:A}}let{color:n,quadPoints:r,inkLists:a,opacity:l}=e,c=yield ce(o,this,"deserialize").call(this,e,t,i);c.color=D.makeHexColor(...n),c.#a=l||1,a&&(c.#g=e.thickness),c.annotationElementId=e.id||null,c._initialData=s;let[h,d]=c.pageDimensions,[u,p]=c.pageTranslation;if(r){let f=c.#i=[];for(let g=0;g<r.length;g+=8)f.push({x:(r[g]-u)/h,y:1-(r[g+1]-p)/d,width:(r[g+2]-r[g])/h,height:(r[g+1]-r[g+5])/
12d});c.#x(),c.#T(),c.rotate(c.rotation)}else if(a){c.#d=!0;let f=a[0],g={x:f[0]-u,y:d-(f[1]-p)},b=new ti(g,[0,0,h,d],1,c.#g/2,!0,.001);for(let y=0,A=f.length;y<A;y+=2)g.x=f[y]-u,g.y=d-(f[y+1]-p),b.add(g);let{id:m,clipPathId:x}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:b.toSVGPath()}},!0,!0);c.#_({highlightOutlines:b.getOutlines(),highlightId:m,clipPathId:x}),c.#T()}return c})}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=this.getRect(0,0),i=it._colorManager.convert(this.color),s={annotationType:$.HIGHLIGHT,color:i,opacity:this.#a,thickness:this.#g,quadPoints:this.#O(),outlines:this.#F(t),pageIndex:this.pageIndex,rect:t,rotation:this.#R(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#L(s)?null:(s.id=this.annotationElementId,s)}#L(e){let{color:t}=this._initialData;return e.color.some((i,s)=>i!==t[s])}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Ln=class{#t=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,i]of Object.entries(e))this.updateProperty(t,i)}updateSVGProperty(e,t){this.#t[e]=t}toSVGProperties(){let e=this.#t;return this.#t=Object.create(null),{root:e}}reset(){this.#t=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Z("Not implemented")}},uo=(()=>{class o extends it{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#r=null;static#n=NaN;static#l=null;static#o=null;static#h=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#c(t),this.#p())}#c({drawOutlines:t,drawId:i,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,i>=0?(this._drawId=i,this.parent.drawLayer.finalizeDraw(i,t.defaultProperties)):this._drawId=this.#u(t,this.parent),this.#m(t.box)}#u(t,i){let{id:s}=i.drawLayer.draw(o._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,i){let s=new Set(Object.keys(t));for(let[n,r]of Object.entries(i))s.has(n)?Object.assign(t[n],r):t[n]=r;return t}static getDefaultDrawingOptions(t){Z("Not implemented")}static get typesMap(){Z("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,i){let s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,i),this._currentParent&&(o.#i.updateProperty(s,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,i){let s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,i)}static get defaultPropertiesToUpdate(){let t=[],i=this._defaultDrawingOptions;for(let[s,n]of this.typesMap)t.push([s,i[n]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:i}=this;for(let[s,n]of this.constructor.typesMap)t.push([s,i[n]]);return t}_updateProperty(t,i,s){let n=this._drawingOptions,r=n[i],a=l=>{n.updateProperty(i,l);let c=this.#t.updateProperty(i,l);c&&this.#m(c),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,s),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#f()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#f()),{bbox:this.#g()}))}_onTranslating(t,i){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,i)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#f(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#p(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let i=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#d()):t&&(this._uiManager.addShouldRescale(this),this.#p(t),i=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),i&&this.select()}#d(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#p(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#u(this.#t,t)}}#a([t,i,s,n]){let{parentDimensions:[r,a],rotation:l}=this;switch(l){case 90:return[i,1-t,s*(a/r),n*(r/a)];case 180:return[1-t,1-i,s,n];case 270:return[1-i,t,s*(a/r),n*(r/a)];default:return[t,i,s,n]}}#f(){let{x:t,y:i,width:s,height:n,parentDimensions:[r,a],rotation:l}=this;switch(l){case 90:return[1-i,t,s*(r/a),n*(a/r)];case 180:return[1-t,1-i,s,n];case 270:return[i,1-t,s*(r/a),n*(a/r)];default:return[t,i,s,n]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#a(t),this.div){this.fixAndSetPosition();let[i,s]=this.parentDimensions;this.setDims(this.width*i,this.height*s)}this._onResized()}#g(){let{x:t,y:i,width:s,height:n,rotation:r,parentRotation:a,parentDimensions:[l,c]}=this;switch((r*4+a)/90){case 1:return[1-i-n,t,n,s];case 2:return[1-t-s,1-i-n,s,n];case 3:return[i,1-t-s,n,s];case 4:return[t,i-s*(l/c),n*(c/l),s*(l/c)];case 5:return[1-i,t,s*(l/c),n*(c/l)];case 6:return[1-t-n*(c/l),1-i,n*(c/l),s*(l/c)];case 7:return[i-s*(l/c),1-t-n*(c/l),s*(l/c),n*(c/l)];case 8:return[t-s,i-n,s,n];case 9:return[1-i,t-s,n,s];case 10:return[1-t,1-i,s,n];case 11:return[i-n,1-t,n,s];case 12:return[t-n*(c/l),i,n*(c/l),s*(l/c)];case 13:return[1-i-s*(l/c),t-n*(c/l),s*(l/c),n*(c/l)];case 14:return[1-t,1-i-s*(l/c),n*(c/l),s*(l/c)];case 15:return[i,1-t,s*(l/c),n*(c/l)];default:return[t,i,s,n]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
12render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let i=document.createElement("div");t.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";let[s,n]=this.parentDimensions;return this.setDims(this.width*s,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,i,s,n,r){Z("Not implemented")}static startDrawing(t,i,s,n){let{target:r,offsetX:a,offsetY:l,pointerId:c,pointerType:h}=n;if(o.#l&&o.#l!==h)return;let{viewport:{rotation:d}}=t,{width:u,height:p}=r.getBoundingClientRect(),f=o.#s=new AbortController,g=t.combinedSignal(f);if(o.#n||=c,o.#l??=h,window.addEventListener("pointerup",b=>{o.#n===b.pointerId?this._endDraw(b):o.#o?.delete(b.pointerId)},{signal:g}),window.addEventListener("pointercancel",b=>{o.#n===b.pointerId?this._currentParent.endDrawingSession():o.#o?.delete(b.pointerId)},{signal:g}),window.addEventListener("pointerdown",b=>{o.#l===b.pointerType&&((o.#o||=new Set).add(b.pointerId),o.#i.isCancellable()&&(o.#i.removeLastElement(),o.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",zt,{signal:g}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),r.addEventListener("touchmove",b=>{b.timeStamp===o.#h&&It(b)},{signal:g}
12),t.toggleDrawing(),i._editorUndoBar?.hide(),o.#i){t.drawLayer.updateProperties(this._currentDrawId,o.#i.startNew(a,l,u,p,d));return}i.updateUIForDefaultProperties(this),o.#i=this.createDrawerInstance(a,l,u,p,d),o.#r=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(o.#r.toSVGProperties(),o.#i.defaultSVGProperties),!0,!1)}static _drawMove(t){if(o.#h=-1,!o.#i)return;let{offsetX:i,offsetY:s,pointerId:n}=t;if(o.#n===n){if(o.#o?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,o.#i.add(i,s)),o.#h=t.timeStamp,It(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,o.#i=null,o.#r=null,o.#l=null,o.#h=NaN),o.#s&&(o.#s.abort(),o.#s=null,o.#n=NaN,o.#o=null)}static _endDraw(t){let i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),t&&i.drawLayer.updateProperties(this._currentDrawId,o.#i.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let s=o.#i,n=this._currentDrawId,r=s.getLastElement();i.addCommands({cmd:()=>{i.drawLayer.updateProperties(n,s.setLastElement(r))},undo:()=>{i.drawLayer.updateProperties(n,s.removeLastElement())},mustExec:!1,type:W.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(W.DRAW_STEP),!o.#i.isEmpty()){let{pageDimensions:[s,n],scale:r}=i,a=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:o.#i.getOutlines(s*r,n*r,r,this._INNER_MARGIN),drawingOptions:o.#r,mustBeCommitted:!t});return this._cleanup(!0),a}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,i,s,n,r,a){Z("Not implemented")}static deserialize(t,i,s){return I(this,null,function*(){let{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:l}}=i.viewport,c=this.deserializeDraw(a,l,n,r,this._INNER_MARGIN,t),h=yield ce(o,this,"deserialize").call(this,t,i,s);return h.createDrawingOptions(t),h.#c({drawOutlines:c}),h.#p(),h.onScaleChanging(),h.rotate(),h})}serializeDraw(t){let[i,s]=this.pageTranslation,[n,r]=this.pageDimensions;return this.#t.serialize([i,s,n,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}return o})(),On=class{#t=new Float64Array(6);#e;#i;#s;#r;#n;#l="";#o=0;#h=new Yi;#c;#u;constructor(e,t,i,s,n,r){this.#c=i,this.#u=s,this.#s=n,this.#r=r,[e,t]=this.#d(e,t);let a=this.#e=[NaN,NaN,NaN,NaN,e,t];this.#n=[e,t],this.#i=[{line:a,points:this.#n}],this.#t.set(a,0)}updateProperty(e,t){e==="stroke-width"&&(this.#r=t)}#d(e,t){return R._normalizePoint(e,t,this.#c,this.#u,this.#s)}isEmpty(){return!this.#i||this.#i.length===0}isCancellable(){return this.#n.length<=10}add(e,t){[e,t]=this.#d(e,t);let[i,s,n,r]=this.#t.subarray(2,6),a=e-n,l=t-r;return Math.hypot(this.#c*a,this.#u*l)<=2?null:(this.#n.push(e,t),isNaN(i)?(this.#t.set([n,r,e,t],2),this.#e.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([i,s,n,r,e,t],0),this.#e.push(...R.createBezierPoints(i,s,n,r,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){let i=this.add(e,t);return i||(this.#n.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,i,s,n){this.#c=i,this.#u=s,this.#s=n,[e,t]=this.#d(e,t);let r=this.#e=[NaN,NaN,NaN,NaN,e,t];this.#n=[e,t];let a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:r,points:this.#n}),this.#t.set(r,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(e){return this.#i?(this.#i.push(e),this.#e=e.line,this.#n=e.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(e)}removeLastElement(){if(!this.#i)return this.#h.removeLastElement();this.#i.pop(),this.#l="";for(let e=0,t=this.#i.length;e<t;e++){let{line:i,points:s}=this.#i[e];this.#e=i,this.#n=s,this.#o=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let e=R.svgRound(this.#e[4]),t=R.svgRound(this.#e[5]);if(this.#n.length===2)return this.#l=`${this.#l} M ${e} ${t} Z`,this.#l;if(this.#n.length<=6){let s=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,s)} M ${e} ${t}`,this.#o=6}if(this.#n.length===4){let s=R.svgRound(this.#e[10]),n=R.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${s} ${n}`,this.#o=12,this.#l}let i=[];this.#o===0&&(i.push(`M ${e} ${t}`),this.#o=6);for(let s=this.#o,n=this.#e.length;s<n;s+=6){let[r,a,l,c,h,d]=this.#e.slice(s,s+6).map(R.svgRound);i.push(`C${r} ${a} ${l} ${c} ${h} ${d}`)}return this.#l+=i.join(" "),this.#o=this.#e.length,this.#l}getOutlines(e,t,i,s){let n=this.#i.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#i,e,t,i,this.#s,this.#r,s),this.#t=null,this.#e=null,this.#i=null,this.#l=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},Yi=class o extends R{#t;#e=0;#i;#s;#r;#n;#l;#o;#h;build(e,t,i,s,n,r,a){this.#r=t,this.#n=i,this.#l=s,this.#o=n,this.#h=r,this.#i=a??0,this.#s=e,this.#d()}setLastElement(e){return this.#s.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#s){if(e.push(`M${R.svgRound(t[4])} ${R.svgRound(t[5])}`),t.length===6){e.push("Z");continue}if(t.length===12){e.push(`L${R.svgRound(t[10])} ${R.svgRound(t[11])}`);continue}for(let i=6,s=t.length;i<s;i+=6){let[n,r,a,l,c,h]=t.subarray(i,i+6).map(R.svgRound);e.push(`C${n} ${r} ${a} ${l} ${c} ${h}`)}}return e.join("")}serialize([e,t,i,s],n){let r=[],a=[],[l,c,h,d]=this.#u(),u,p,f,g,b,m,x,y,A;switch(this.#o){case 0:A=R._rescale,u=e,p=t+s,f=i,g=-s,b=e+l*i,m=t+(1-c-d)*s,x=e+(l+h)*i,y=t+(1-c)*s;break;case 90:A=R._rescaleAndSwap,u=e,p=t,f=i,g=s,b=e+c*i,m=t+l*s,x=e+(c+d)*i,y=t+(l+h)*s;break;case 180:A=R._rescale,u=e+i,p=t,f=-i,g=s,b=e+(1-l-h)*i,m=t+c*s,x=e+(1-l)*i,y=t+(c+d)*s;break;case 270:A=R._rescaleAndSwap,u=e+i,p=t+s,f=-i,g=-s,b=e+(1-c-d)*i,m=t+(1-l-h)*s,x=e+(1-c)*i,y=t+(1-l)*s;break}for(let{line:C,points:P}of this.#s)r.push(A(C,u,p,f,g,n?new Array(C.length):null)),a.push(A(P,u,p,f,g,n?new Array(P.length):null));return{lines:r,points:a,rect:[b,m,x,y]}}static deserialize(e,t,i,s,n,{paths:{lines:r,points:a},rotation:l,thickness:c}){let h=[],d,u,p,f,g;switch(l){case 0:g=R._rescale,d=-e/i,u=t/s+1,p=1/i,f=-1/s;break;case 90:g=R._rescaleAndSwap,d=-t/s,u=-e/i,p=1/s,f=1/i;break;case 180:g=R._rescale,d=e/i+1,u=-t/s,p=-1/i,f=1/s;break;case 270:g=R._rescaleAndSwap,d=t/s+1,u=e/i+1,p=-1/s,f=-1/i;break}if(!r){r=[];for(let m of a){let x=m.length;if(x===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(x===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}let y=new Float32Array(3*(x-2));
12r.push(y);let[A,C,P,S]=m.subarray(0,4);y.set([NaN,NaN,NaN,NaN,A,C],0);for(let B=4;B<x;B+=2){let H=m[B],X=m[B+1];y.set(R.createBezierPoints(A,C,P,S,H,X),(B-2)*3),[A,C,P,S]=[P,S,H,X]}}}for(let m=0,x=r.length;m<x;m++)h.push({line:g(r[m].map(y=>y??NaN),d,u,p,f),points:g(a[m].map(y=>y??NaN),d,u,p,f)});let b=new o;return b.build(h,i,s,1,l,c,n),b}#c(e=this.#h){let t=this.#i+e/2*this.#l;return this.#o%180===0?[t/this.#r,t/this.#n]:[t/this.#n,t/this.#r]}#u(){let[e,t,i,s]=this.#t,[n,r]=this.#c(0);return[e+n,t+r,i-2*n,s-2*r]}#d(){let e=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:s}of this.#s){if(s.length<=12){for(let a=4,l=s.length;a<l;a+=6){let[c,h]=s.subarray(a,a+2);e[0]=Math.min(e[0],c),e[1]=Math.min(e[1],h),e[2]=Math.max(e[2],c),e[3]=Math.max(e[3],h)}continue}let n=s[4],r=s[5];for(let a=6,l=s.length;a<l;a+=6){let[c,h,d,u,p,f]=s.subarray(a,a+6);D.bezierBoundingBox(n,r,c,h,d,u,p,f,e),n=p,r=f}}let[t,i]=this.#c();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-i)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+i)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#t}updateProperty(e,t){return e==="stroke-width"?this.#p(t):null}#p(e){let[t,i]=this.#c();this.#h=e;let[s,n]=this.#c(),[r,a]=[s-t,n-i],l=this.#t;return l[0]-=r,l[1]-=a,l[2]+=2*r,l[3]+=2*a,l}updateParentDimensions([e,t],i){let[s,n]=this.#c();this.#r=e,this.#n=t,this.#l=i;let[r,a]=this.#c(),l=r-s,c=a-n,h=this.#t;return h[0]-=l,h[1]-=c,h[2]+=2*l,h[3]+=2*c,h}updateRotation(e){return this.#e=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(R.svgRound).join(" ")}get defaultProperties(){let[e,t]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(e)} ${R.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#t,i=0,s=0,n=0,r=0,a=0,l=0;switch(this.#e){case 90:s=t/e,n=-e/t,a=e;break;case 180:i=-1,r=-1,a=e,l=t;break;case 270:s=-t/e,n=e/t,l=t;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${R.svgRound(a)} ${R.svgRound(l)})`}getPathResizingSVGProperties([e,t,i,s]){let[n,r]=this.#c(),[a,l,c,h]=this.#t;if(Math.abs(c-n)<=R.PRECISION||Math.abs(h-r)<=R.PRECISION){let g=e+i/2-(a+c/2),b=t+s/2-(l+h/2);return{path:{"transform-origin":`${R.svgRound(e)} ${R.svgRound(t)}`,transform:`${this.rotationTransform} translate(${g} ${b})`}}}let d=(i-2*n)/(c-2*n),u=(s-2*r)/(h-2*r),p=c/i,f=h/s;return{path:{"transform-origin":`${R.svgRound(a)} ${R.svgRound(l)}`,transform:`${this.rotationTransform} scale(${p} ${f}) translate(${R.svgRound(n)} ${R.svgRound(r)}) scale(${d} ${u}) translate(${R.svgRound(-n)} ${R.svgRound(-r)})`}}}getPathResizedSVGProperties([e,t,i,s]){let[n,r]=this.#c(),a=this.#t,[l,c,h,d]=a;if(a[0]=e,a[1]=t,a[2]=i,a[3]=s,Math.abs(h-n)<=R.PRECISION||Math.abs(d-r)<=R.PRECISION){let b=e+i/2-(l+h/2),m=t+s/2-(c+d/2);for(let{line:x,points:y}of this.#s)R._translate(x,b,m,x),R._translate(y,b,m,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(e)} ${R.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let u=(i-2*n)/(h-2*n),p=(s-2*r)/(d-2*r),f=-u*(l+n)+e+n,g=-p*(c+r)+t+r;if(u!==1||p!==1||f!==0||g!==0)for(let{line:b,points:m}of this.#s)R._rescale(b,f,g,u,p,b),R._rescale(m,f,g,u,p,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${R.svgRound(e)} ${R.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],i){let[s,n]=i,r=this.#t,a=e-r[0],l=t-r[1];if(this.#r===s&&this.#n===n)for(let{line:c,points:h}of this.#s)R._translate(c,a,l,c),R._translate(h,a,l,h);else{let c=this.#r/s,h=this.#n/n;this.#r=s,this.#n=n;for(let{line:d,points:u}of this.#s)R._rescale(d,a,l,c,h,d),R._rescale(u,a,l,c,h,u);r[2]*=c,r[3]*=h}return r[0]=e,r[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${R.svgRound(e)} ${R.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${R.svgRound(e[0])} ${R.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}},Dn=class o extends Ln{#t;constructor(e){super(),this.#t=e,super.updateProperties({fill:"none",stroke:it._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){e==="stroke-width"&&(t??=this["stroke-width"],t*=this.#t.realScale),super.updateSVGProperty(e,t)}clone(){let e=new o(this.#t);return e.updateAll(this),e}},Fn=class o extends uo{static _type="ink";static _editorType=$.INK;static _defaultDrawingOptions=null;constructor(e){super(_e(Nt({},e),{name:"inkEditor"})),this._willKeepAspectRatio=!0}static initialize(e,t){it.initialize(e,t),this._defaultDrawingOptions=new Dn(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[W.INK_THICKNESS,"stroke-width"],[W.INK_COLOR,"stroke"],[W.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,i,s,n){return new On(e,t,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,i,s,n,r){return Yi.deserialize(e,t,i,s,n,r)}static deserialize(e,t,i){return I(this,null,function*(){let s=null;if(e instanceof Ze){let{data:{inkLists:r,rect:a,rotation:l,id:c,color:h,opacity:d,borderStyle:{rawWidth:u},popupRef:p},parent:{page:{pageNumber:f}}}=e;s=e={annotationType:$.INK,color:Array.from(h),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:f-1,rect:a.slice(0),rotation:l,id:c,deleted:!1,popupRef:p}}let n=yield ce(o,this,"deserialize").call(this,e,t,i);return n.annotationElementId=e.id||null,n._initialData=s,n})}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:i}=this;t.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:i}){this._drawingOptions=o.getDefaultDrawingOptions({stroke:D.makeHexColor(...e),"stroke-width":t,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:i,rect:s}=this.serializeDraw(e),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,l={annotationType:$.INK,color:it._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:t,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?l:this.annotationElementId&&!this.#t(l)?null:(l.id=this.annotationElementId,l)}
12#t(e){let{color:t,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((r,a)=>r!==t[a])||e.thickness!==i||e.opacity!==s||e.pageIndex!==n}renderAnnotationElement(e){let{points:t,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:t}),null}},Nn=class o extends it{#t=null;#e=null;#i=null;#s=null;#r=null;#n="";#l=null;#o=null;#h=!1;#c=!1;static _type="stamp";static _editorType=$.STAMP;constructor(e){super(_e(Nt({},e),{name:"stampEditor"})),this.#s=e.bitmapUrl,this.#r=e.bitmapFile}static initialize(e,t){it.initialize(e,t)}static get supportedTypes(){return j(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return j(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor($.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#u(e,t=!1){if(!e){this.remove();return}this.#t=e.bitmap,t||(this.#e=e.id,this.#h=e.isSvg),e.file&&(this.#n=e.file.name),this.#a()}#d(){if(this.#i=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}mlGuessAltText(e=null,t=!0){return I(this,null,function*(){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");let{data:s,width:n,height:r}=e||this.copyCanvas(null,null,!0).imageData,a=yield i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");let l=a.output;return yield this.setGuessedAltText(l),t&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l})}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(i=>this.#u(i,!0)).finally(()=>this.#d());return}if(this.#s){let i=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(i).then(s=>this.#u(s)).finally(()=>this.#d());return}if(this.#r){let i=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(i).then(s=>this.#u(s)).finally(()=>this.#d());return}let e=document.createElement("input");e.type="file",e.accept=o.supportedTypesStr;let t=this._uiManager._signal;this.#i=new Promise(i=>{e.addEventListener("change",()=>I(this,null,function*(){if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let s=yield this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#u(s)}i()}),{signal:t}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:t})}).finally(()=>this.#d()),e.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#o&&(clearTimeout(this.#o),this.#o=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#p();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#p(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#r||this.#e)}get isResizable(){return!0}
12render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#a():this.#p(),this.width&&!this.annotationElementId){let[i,s]=this.parentDimensions;this.setAt(e*i,t*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#o!==null&&clearTimeout(this.#o);let e=200;this.#o=setTimeout(()=>{this.#o=null,this.#m()},e)}#a(){let{div:e}=this,{width:t,height:i}=this.#t,[s,n]=this.pageDimensions,r=.75;if(this.width)t=this.width*s,i=this.height*n;else if(t>r*s||i>r*n){let h=Math.min(r*s/t,r*n/i);t*=h,i*=h}let[a,l]=this.parentDimensions;this.setDims(t*a/s,i*l/n),this._uiManager.enableWaiting(!1);let c=this.#l=document.createElement("canvas");c.setAttribute("role","img"),this.addContainer(c),this.width=t/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),this.#m(),this.#c||(this.parent.addUndoableEditor(this),this.#c=!0),this._reportTelemetry({action:"inserted_image"}),this.#n&&c.setAttribute("aria-label",this.#n)}copyCanvas(e,t,i=!1){e||(e=224);let{width:s,height:n}=this.#t,r=new je,a=this.#t,l=s,c=n,h=null;if(t){if(s>t||n>t){let P=Math.min(t/s,t/n);l=Math.floor(s*P),c=Math.floor(n*P)}h=document.createElement("canvas");let u=h.width=Math.ceil(l*r.sx),p=h.height=Math.ceil(c*r.sy);this.#h||(a=this.#f(u,p));let f=h.getContext("2d");f.filter=this._uiManager.hcmFilter;let g="white",b="#cfcfd8";this._uiManager.hcmFilter!=="none"?b="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(g="#8f8f9d",b="#42414d");let m=15,x=m*r.sx,y=m*r.sy,A=new OffscreenCanvas(x*2,y*2),C=A.getContext("2d");C.fillStyle=g,C.fillRect(0,0,x*2,y*2),C.fillStyle=b,C.fillRect(0,0,x,y),C.fillRect(x,y,x,y),f.fillStyle=f.createPattern(A,"repeat"),f.fillRect(0,0,u,p),f.drawImage(a,0,0,a.width,a.height,0,0,u,p)}let d=null;if(i){let u,p;if(r.symmetric&&a.width<e&&a.height<e)u=a.width,p=a.height;else if(a=this.#t,s>e||n>e){let b=Math.min(e/s,e/n);u=Math.floor(s*b),p=Math.floor(n*b),this.#h||(a=this.#f(u,p))}let g=new OffscreenCanvas(u,p).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,p),d={width:u,height:p,data:g.getImageData(0,0,u,p).data}}return{canvas:h,width:l,height:c,imageData:d}}#f(e,t){let{width:i,height:s}=this.#t,n=i,r=s,a=this.#t;for(;n>2*e||r>2*t;){let l=n,c=r;n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,l,c,0,0,n,r),a=h.transferToImageBitmap()}return a}#m(){let[e,t]=this.parentDimensions,{width:i,height:s}=this,n=new je,r=Math.ceil(i*e*n.sx),a=Math.ceil(s*t*n.sy),l=this.#l;if(!l||l.width===r&&l.height===a)return;l.width=r,l.height=a;let c=this.#h?this.#t:this.#f(r,a),h=l.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(c,0,0,c.width,c.height,0,0,r,a)}getImageForAltText(){return this.#l}#g(e){if(e){if(this.#h){let s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#t,t.getContext("2d").drawImage(this.#t,0,0),t.toDataURL()}if(this.#h){let[t,i]=this.pageDimensions,s=Math.round(this.width*t*ae.PDF_TO_CSS_UNITS),n=Math.round(this.height*i*ae.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(s,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,s,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static deserialize(e,t,i){return I(this,null,function*(){let s=null;if(e instanceof Gi){let{data:{rect:f,rotation:g,id:b,structParent:m,popupRef:x},container:y,parent:{page:{pageNumber:A}}}=e,C=y.querySelector("canvas"),P=i.imageManager.getFromCanvas(y.id,C);C.remove();let S=(yield t._structTree.getAriaAttributes(`${Vn}${b}`))?.get("aria-label")||"";s=e={annotationType:$.STAMP,bitmapId:P.id,bitmap:P.bitmap,pageIndex:A-1,rect:f.slice(0),rotation:g,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:S},isSvg:!1,structParent:m,popupRef:x}}let n=yield ce(o,this,"deserialize").call(this,e,t,i),{rect:r,bitmap:a,bitmapUrl:l,bitmapId:c,isSvg:h,accessibilityData:d}=e;c&&i.imageManager.isValidId(c)?(n.#e=c,a&&(n.#t=a)):n.#s=l,n.#h=h;let[u,p]=n.pageDimensions;return n.width=(r[2]-r[0])/u,n.height=(r[3]-r[1])/p,n.annotationElementId=e.id||null,d&&(n.altTextData=d),n._initialData=s,n.#c=!!s,n})}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i={annotationType:$.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#h,structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=this.#g(!0),i.accessibilityData=this.serializeAltText(!0),i;let{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){let a=this.#b(i);if(a.isSame)return null;a.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,t===null)return i;t.stamps||=new Map;let r=this.#h?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;
12if(!t.stamps.has(this.#e))t.stamps.set(this.#e,{area:r,serialized:i}),i.bitmap=this.#g(!1);else if(this.#h){let a=t.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#g(!1))}return i}#b(e){let{pageIndex:t,accessibilityData:{altText:i}}=this._initialData,s=e.pageIndex===t,n=(e.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}},po=(()=>{class o{#t;#e=!1;#i=null;#s=null;#r=null;#n=new Map;#l=!1;#o=!1;#h=!1;#c=null;#u=null;#d=null;#p=null;#a;static _initialized=!1;static#f=new Map([Mn,Fn,Nn,Ki].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:l,textLayer:c,viewport:h,l10n:d}){let u=[...o.#f.values()];if(!o._initialized){o._initialized=!0;for(let p of u)p.initialize(d,t)}t.registerEditorTypes(u),this.#a=t,this.pageIndex=i,this.div=s,this.#t=r,this.#i=a,this.viewport=h,this.#d=c,this.drawLayer=l,this._structTree=n,this.#a.addLayer(this)}get isEmpty(){return this.#n.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===$.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#_(),t){case $.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case $.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case $.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:i}=this.div;for(let s of o.#f.values())i.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}cleanUndoStack(t){this.#a.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#i?.div.classList.toggle("disabled",!t)}enable(){return I(this,null,function*(){this.#h=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let s of this.#n.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#i){this.#h=!1;return}let i=this.#i.getEditableAnnotations();for(let s of i){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;let n=yield this.deserialize(s);n&&(this.addOrRebuild(n),n.enableEditing())}this.#h=!1})}disable(){this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,i=new Map;for(let n of this.#n.values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else i.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}if(this.#i){let n=this.#i.getEditableAnnotations();for(let r of n){let{id:a}=r.data;if(this.#a.isDeletedAnnotationElement(a))continue;let l=i.get(a);if(l){l.resetAnnotationElement(r),l.show(!1),r.show();continue}l=t.get(a),l&&(this.#a.addChangedExistingAnnotation(l),l.renderAnnotationElement(r)&&l.show(!1)),r.show()}}this.#_(),this.isEmpty&&(this.div.hidden=!0);let{classList:s}=this.div;for(let n of o.#f.values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#o=!1}getEditableAnnotation(t){return this.#i?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#p){this.#p=new AbortController;let t=this.#a.combinedSignal(this.#p);this.#d.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#p&&(this.#p.abort(),this.#p=null,this.#d.div.classList.remove("highlighting"))}#m(t){this.#a.unselectAll();let{target:i}=t;if(i===this.#d.div||(i.getAttribute("role")==="img"||i.classList.contains("endOfContent"))&&this.#d.div.contains(i)){let{isMac:s}=bt.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#a.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),Ki.startHighlighting(this,this.#a.direction==="ltr",{target:this.#d.div,x:t.x,y:t.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;let t=this.#a.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let i=this.pointerup.bind(this);this.div.addEventListener("pointerup",i,{signal:t}),this.div.addEventListener("pointercancel",i,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#n.set(t.id,t);let{annotationElementId:i}=t;i&&this.#a.isDeletedAnnotationElement(i)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#n.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),it.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}
12add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){let i=t.render();this.div.append(i),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#h),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:i}=document;t.div.contains(i)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),i.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let i=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:i,undo:s,mustExec:!1})}getNextId(){return this.#a.getId()}get#g(){return o.#f.get(this.#a.getMode())}combinedSignal(t){return this.#a.combinedSignal(t)}#b(t){let i=this.#g;return i?new i.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,i){this.#a.updateToolbar(t),this.#a.updateMode(t);let{offsetX:s,offsetY:n}=this.#x(),r=this.getNextId(),a=this.#b(Nt({parent:this,id:r,x:s,y:n,uiManager:this.#a,isCentered:!0},i));a&&this.add(a)}deserialize(t){return I(this,null,function*(){return(yield o.#f.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a))||null})}createAndAddNewEditor(t,i,s={}){let n=this.getNextId(),r=this.#b(Nt({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:i},s));return r&&this.add(r),r}#x(){let{x:t,y:i,width:s,height:n}=this.div.getBoundingClientRect(),r=Math.max(0,t),a=Math.max(0,i),l=Math.min(window.innerWidth,t+s),c=Math.min(window.innerHeight,i+n),h=(r+l)/2-t,d=(a+c)/2-i,[u,p]=this.viewport.rotation%180===0?[h,d]:[d,h];return{offsetX:u,offsetY:p}}addNewEditor(){this.createAndAddNewEditor(this.#x(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){let{isMac:i}=bt.platform;if(!(t.button!==0||t.ctrlKey&&i)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#a.getMode()===$.STAMP){this.#a.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#a.getMode()===$.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:i}=bt.platform;if(t.button!==0||t.ctrlKey&&i||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let s=this.#a.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#c){this.#g.startDrawing(this,this.#a,!1,t);return}this.#a.setCurrentDrawingSession(this),this.#c=new AbortController;let i=this.#a.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:i}),this.#g.startDrawing(this,this.#a,!1,t)}pause(t){if(t){let{activeElement:i}=document;this.div.contains(i)&&(this.#u=i);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#c?(this.#a.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#u=null,this.#g.endDrawing(t)):null}findNewParent(t,i,s){let n=this.#a.findParent(i,s);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(let t of this.#n.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#n.clear(),this.#a.removeLayer(this)}#_(){for(let t of this.#n.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,fe(this.div,t);for(let i of this.#a.getEditors(this.pageIndex))this.add(i),i.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#_();let i=this.viewport.rotation,s=t.rotation;if(this.viewport=t,fe(this.div,{rotation:s}),i!==s)for(let n of this.#n.values())n.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:i}=this.viewport.rawDims;return[t,i]}get scale(){return this.#a.viewParameters.realScale}}return o}
12)(),Bn=class o{#t=null;#e=0;#i=new Map;#s=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(!this.#t){this.#t=e;return}if(this.#t!==e){if(this.#i.size>0)for(let t of this.#i.values())t.remove(),e.append(t);this.#t=e}}static get _svgFactory(){return j(this,"_svgFactory",new Ye)}static#r(e,[t,i,s,n]){let{style:r}=e;r.top=`${100*i}%`,r.left=`${100*t}%`,r.width=`${100*s}%`,r.height=`${100*n}%`}#n(){let e=o._svgFactory.create(1,1,!0);return this.#t.append(e),e.setAttribute("aria-hidden",!0),e}#l(e,t){let i=o._svgFactory.createElement("clipPath");e.append(i);let s=`clip_${t}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let n=o._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${t}`),n.classList.add("clip"),s}#o(e,t){for(let[i,s]of Object.entries(t))s===null?e.removeAttribute(i):e.setAttribute(i,s)}draw(e,t=!1,i=!1){let s=this.#e++,n=this.#n(),r=o._svgFactory.createElement("defs");n.append(r);let a=o._svgFactory.createElement("path");r.append(a);let l=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",l),a.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#s.set(s,a);let c=i?this.#l(r,l):null,h=o._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(n,e),this.#i.set(s,n),{id:s,clipPathId:`url(#${c})`}}drawOutline(e,t){let i=this.#e++,s=this.#n(),n=o._svgFactory.createElement("defs");s.append(n);let r=o._svgFactory.createElement("path");n.append(r);let a=`path_p${this.pageIndex}_${i}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let l;if(t){let d=o._svgFactory.createElement("mask");n.append(d),l=`mask_p${this.pageIndex}_${i}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");let u=o._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");let p=o._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${a}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}let c=o._svgFactory.createElement("use");s.append(c),c.setAttribute("href",`#${a}`),l&&c.setAttribute("mask",`url(#${l})`);let h=c.cloneNode();return s.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(s,e),this.#i.set(i,s),i}finalizeDraw(e,t){this.#s.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;let{root:i,bbox:s,rootClass:n,path:r}=t,a=typeof e=="number"?this.#i.get(e):e;if(a){if(i&&this.#o(a,i),s&&o.#r(a,s),n){let{classList:l}=a;for(let[c,h]of Object.entries(n))l.toggle(c,h)}if(r){let c=a.firstChild.firstChild;this.#o(c,r)}}}updateParent(e,t){if(t===this)return;let i=this.#i.get(e);i&&(t.#t.append(i),this.#i.delete(e),t.#i.set(e,i))}remove(e){this.#s.delete(e),this.#t!==null&&(this.#i.get(e).remove(),this.#i.delete(e))}destroy(){this.#t=null;for(let e of this.#i.values())e.remove();this.#i.clear(),this.#s.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:Je};var _l=V.AbortException,vl=V.AnnotationEditorLayer,xl=V.AnnotationEditorParamsType,yl=V.AnnotationEditorType,wl=V.AnnotationEditorUIManager,Al=V.AnnotationLayer,Cl=V.AnnotationMode,Sl=V.ColorPicker,El=V.DOMSVGFactory,kl=V.DrawLayer,Pl=V.FeatureTest,qr=V.GlobalWorkerOptions,Tl=V.ImageKind,Ml=V.InvalidPDFException,Rl=V.MissingPDFException,Il=V.OPS,Ll=V.OutputScale,Ol=V.PDFDataRangeTransport,Dl=V.PDFDateString,Fl=V.PDFWorker,Nl=V.PasswordResponses,Bl=V.PermissionFlag,Hl=V.PixelsPerInch,Vl=V.RenderingCancelledException,zl=V.TextLayer,$l=V.TouchManager,Ul=V.UnexpectedResponseException,jl=V.Util,Gl=V.VerbosityLevel,Wl=V.XfaLayer,Xl=V.build,ql=V.createValidAbsoluteUrl,Kl=V.fetchData,Un=V.getDocument,Yl=V.getFilenameFromUrl,Ql=V.getPdfFilenameFromUrl,Zl=V.getXfaPageViewport,Jl=V.isDataScheme,tc=V.isPdfFile,ec=V.noContextMenu,ic=V.normalizeUnicode,sc=V.setLayerDimensions,nc=V.shadow,rc=V.stopEvent,ac=V.version;var go=["scroll"],mo=["host"];function bo(o,e){if(o&1&&z(0,"div",8),o&2){let t=e.$implicit;mt("width",t.w,"%")("--sk-band",t.band),Bt("sk-hl",t.hl)("sk-ul",t.ul)}}function _o(o,e){if(o&1&&(v(0,"div",5),z(1,"div",6),Wt(2,bo,1,8,"div",7,Ie),w()),o&2){let t=F(2);_(),mt("width",52,"%"),_(),Xt(t.skeletonLines)}}function vo(o,e){if(o&1&&(v(0,"div",4),Wt(1,_o,4,2,"div",5,Ie),w()),o&2){let t=F();_(),Xt(t.skeletonPages)}}qr.workerSrc="assets/pdf.worker.min.mjs";var ii=(()=>{class o{constructor(t,i){this.zone=t,this.translate=i,this.loading=Y(!0),this.skeletonPages=[0,1],this.skeletonLines=[{w:96,hl:!1,ul:!1,band:""},{w:88,hl:!1,ul:!1,band:""},{w:92,hl:!0,ul:!1,band:"#e5484d"},{w:70,hl:!1,ul:!1,band:""},{w:90,hl:!1,ul:!0,band:"#e08600"},{w:84,hl:!1,ul:!1,band:""},{w:78,hl:!0,ul:!1,band:"#3b82f6"},{w:94,hl:!1,ul:!1,band:""},{w:62,hl:!1,ul:!0,band:"#1e40af"}],this.src=ve.required(),this.segments=ve([]),this.zoom=ve(1.3),this.activeSegmentId=ve(null),this.visibleConfidence
12s=ve(new Set(Se)),this.ready=ri(),this.pageChange=ri(),this.segmentClick=ri(),this.scrollRef=Gt.required("scroll"),this.hostRef=Gt.required("host"),this.pages=[],this.segmentEls=new Map,this.currentPage=1,this.destroyed=!1,this.fitScale=1,this.lastContainerWidth=0,this.destroy$=new he,this.resize$=new he,this.scrollHorizontalPadding=32,this.maxDevicePixelRatio=2,this.onScroll=()=>{let s=this.scrollRef().nativeElement,n=s.scrollTop+s.clientHeight/2,r=1;for(let a of this.pages)if(a.wrapper.offsetTop<=n)r=a.page;else break;r!==this.currentPage&&(this.currentPage=r,this.pageChange.emit(r))},se(()=>{let s=this.src();s&&this.load(s)},{allowSignalWrites:!0}),se(()=>{this.zoom(),this.doc&&this.renderAll()}),se(()=>{this.segments(),this.visibleConfidences(),this.doc&&this.drawHighlights()}),se(()=>{let s=this.activeSegmentId();this.applyActive(s)})}ngAfterViewInit(){let t=this.scrollRef().nativeElement;t.addEventListener("scroll",this.onScroll,{passive:!0}),this.resize$.pipe(qn(100),jt(this.destroy$)).subscribe(()=>{let s=this.scrollRef().nativeElement.clientWidth;Math.abs(s-this.lastContainerWidth)<1||this.doc&&this.renderAll()}),this.resizeObserver=new ResizeObserver(()=>this.resize$.next()),this.resizeObserver.observe(t)}ngOnDestroy(){this.destroyed=!0,this.destroy$.next(),this.destroy$.complete(),this.resizeObserver?.disconnect(),this.scrollRef()?.nativeElement.removeEventListener("scroll",this.onScroll),this.cleanup(),this.doc?.destroy()}cleanup(){for(let i of this.pages)i.renderTask?.cancel();this.pages=[],this.segmentEls.clear();let t=this.hostRef().nativeElement;t.innerHTML=""}load(t){return I(this,null,function*(){if(this.hostRef){this.loading.set(!0),this.cleanup(),this.doc?.destroy();try{let i=t instanceof Blob?Un({data:yield t.arrayBuffer()}):Un({url:t});if(this.doc=yield i.promise,this.destroyed)return;let s=this.hostRef().nativeElement;for(let n=1;n<=this.doc.numPages;n++){let r=yield this.doc.getPage(n);if(this.destroyed)return;let a=document.createElement("div");a.className="page-wrap",a.dataset.page=String(n);let l=document.createElement("canvas");l.className="page-canvas";let c=document.createElement("div");c.className="page-overlay";let h=document.createElement("div");h.className="page-label",h.textContent=`Page ${n}`,a.appendChild(l),a.appendChild(c),a.appendChild(h),s.appendChild(a),this.pages.push({page:n,proxy:r,wrapper:a,canvas:l,overlay:c})}this.ready.emit(this.doc.numPages),yield this.renderAll(),this.drawHighlights(),this.zone.run(()=>this.loading.set(!1))}catch(i){this.zone.run(()=>this.loading.set(!1)),console.error("Failed to load PDF",i)}}})}updateFitScale(){if(!this.pages.length){this.fitScale=1;return}let t=this.scrollRef().nativeElement,i=t.clientWidth-this.scrollHorizontalPadding;if(i<=0)return;let s=this.pages[0].proxy.getViewport({scale:1});s.width<=0||(this.fitScale=i/s.width,this.lastContainerWidth=t.clientWidth)}getRenderScale(){return this.zoom()*this.fitScale}getOutputScale(){return Math.min(window.devicePixelRatio||1,this.maxDevicePixelRatio)}renderAll(){return I(this,null,function*(){this.updateFitScale();let t=this.getRenderScale(),i=this.getOutputScale();for(let s of this.pages){s.renderTask?.cancel();let n=s.proxy.getViewport({scale:t}),r=Math.floor(n.width*i),a=Math.floor(n.height*i),l=Math.floor(n.width),c=Math.floor(n.height);s.canvas.width=r,s.canvas.height=a,s.canvas.style.width=`${l}px`,s.canvas.style.height=`${c}px`,s.wrapper.style.width=`${l}px`,s.overlay.style.width=`${l}px`,s.overlay.style.height=`${c}px`;let h=s.canvas.getContext("2d");if(!h)continue;h.setTransform(1,0,0,1,0,0);let d=i!==1?[i,0,0,i,0,0]:void 0;try{s.renderTask=s.proxy.render({canvasContext:h,viewport:n,transform:d}),yield s.renderTask.promise}catch(u){u?.name!=="RenderingCancelledException"&&console.error(u)}}this.drawHighlights()})}drawHighlights(){let t=this.segments(),i=this.visibleConfidences();this.segmentEls.clear();let s=new Map;for(let n of this.pages)n.overlay.innerHTML="",s.set(n.page,n.overlay);for(let n of t){if(!i.has(n.confidence))continue;let r=[];for(let a of n.boxes){let l=s.get(a.page);if(!l)continue;let c=l.clientWidth,h=l.clientHeight,d=document.createElement("div");d.className=`hl hl-${n.confidence}`,d.style.left=`${a.x0*c}px`,d.style.top=`${a.y0*h+2}px`,d.style.width=`${(a.x1-a.x0)*c}px`,d.style.height=`${(a.y1-a.y0)*h+3}px`,d.dataset.seg=n.id,d.title=this.translate.instant(xt[n.confidence].labelKey),d.addEventListener("click",u=>{u.stopPropagation(),this.segmentClick.emit(n.id)}),l.appendChild(d),r.push(d)}r.length&&this.segmentEls.set(n.id,r)}this.applyActive(this.activeSegmentId())}applyActive(t){for(let[i,s]of this.segmentEls)for(let n of s)n.classList.toggle("is-active",i===t)}scrollToSegment(t){let i=this.segmentEls.get(t);i?.length&&i[0].scrollIntoView({behavior:"smooth",block:"center"})}scrollToPage(t){this.pages.find(s=>s.page===t)?.wrapper.scrollIntoView({behavior:"smooth",block:"start"})}static{this.\u0275fac=function(i){return new(i||o)(Ct(tr),Ct(we))}}static{this.\u0275cmp=ie({type:o,selectors:[["app-ai-cd-pdf-viewer"]],viewQuery:function(i,s){i&1&&(qt(s.scrollRef,go,5),qt(s.hostRef,mo,5)),i&2&&xe(2)},inputs:{src:[1,"src"],segments:[1,"segments"],zoom:[1,"zoom"],activeSegmentId:[1,"activeSegmentId"],visibleConfidence
12s:[1,"visibleConfidences"]},outputs:{ready:"ready",pageChange:"pageChange",segmentClick:"segmentClick"},decls:5,vars:1,consts:[["scroll",""],["host",""],[1,"scroll"],[1,"pages"],["role","status","aria-label","Loading report preview",1,"pdf-shimmer"],[1,"sk-page"],[1,"sk-line","sk-title"],[1,"sk-line",3,"sk-hl","sk-ul","width","--sk-band"],[1,"sk-line"]],template:function(i,s){i&1&&(v(0,"div",2,0),z(2,"div",3,1),w(),nt(4,vo,3,0,"div",4)),i&2&&(_(4),rt(s.loading()?4:-1))},styles:[`app-ai-cd-pdf-viewer{display:block;height:100%;min-height:0;position:relative}app-ai-cd-pdf-viewer .scroll{height:100%;overflow:auto;overflow-x:auto;background:#eef1f6;padding:28px 0 60px}app-ai-cd-pdf-viewer .pages{display:flex;flex-direction:column;align-items:center;gap:24px;width:100%;min-width:min-content}app-ai-cd-pdf-viewer .page-wrap{position:relative;flex:none;max-width:100%;background:#fff;box-shadow:var(--shadow-md);border-radius:4px;overflow:hidden;font-size:0}app-ai-cd-pdf-viewer .page-canvas{display:block}app-ai-cd-pdf-viewer .page-overlay{position:absolute;inset:0;pointer-events:none}app-ai-cd-pdf-viewer .page-label{position:absolute;bottom:8px;right:10px;font-size:11px;font-weight:600;color:var(--text-faint);background:#ffffffd9;padding:2px 8px;border-radius:6px;pointer-events:none}app-ai-cd-pdf-viewer .hl{position:absolute;pointer-events:auto;cursor:pointer;border-radius:2px;mix-blend-mode:multiply;transition:filter .12s ease,outline-color .12s ease;outline:2px solid transparent}app-ai-cd-pdf-viewer .hl-confident-human,app-ai-cd-pdf-viewer .hl-confident-human.is-active{--highlight-background: #F0FDF4;background:var(--highlight-background)}app-ai-cd-pdf-viewer .hl-leaning-human,app-ai-cd-pdf-viewer .hl-leaning-human.is-active{--highlight-background: #DEE9FE;background:var(--highlight-background)}app-ai-cd-pdf-viewer .hl-inconclusive,app-ai-cd-pdf-viewer .hl-inconclusive.is-active{--highlight-background: #E7EAEF;background:var(--highlight-background)}app-ai-cd-pdf-viewer x .hl-leaning-ai,app-ai-cd-pdf-viewer .hl-leaning-ai.is-active{--highlight-background: #FDEFE3;background:var(--highlight-background)}app-ai-cd-pdf-viewer .hl-confident-ai,app-ai-cd-pdf-viewer .hl-confident-ai.is-active{--highlight-background: #FFF1F2;background:var(--highlight-background)}app-ai-cd-pdf-viewer .hl:hover{filter:brightness(.94) saturate(1.2)}app-ai-cd-pdf-viewer .hl.is-active{outline-offset:1px;animation:active-highlight-flash 1.5s ease-out}@keyframes active-highlight-flash{0%,35%{background:#3b82f68c}to{background:var(--highlight-background)}}app-ai-cd-pdf-viewer .pdf-shimmer{position:absolute;inset:0;z-index:5;overflow:hidden;background:#eef1f6;display:flex;flex-direction:column;align-items:center;gap:24px;padding:28px 0 60px}app-ai-cd-pdf-viewer .sk-page{width:min(720px,82%);aspect-ratio:8.5/11;flex:none;background:#fff;border-radius:4px;box-shadow:var(--shadow-md);padding:48px 52px;display:flex;flex-direction:column;gap:14px;overflow:hidden}app-ai-cd-pdf-viewer .sk-line{position:relative;height:12px;border-radius:4px;background:linear-gradient(90deg,#e9edf3 25%,#f4f7fb 37%,#e9edf3 63%);background-size:400% 100%;animation:sk-shimmer 1.4s ease infinite}app-ai-cd-pdf-viewer .sk-title{height:20px;margin-bottom:10px}app-ai-cd-pdf-viewer .sk-hl:after{content:"";position:absolute;inset:-2px -4px;border-radius:4px;background:var(--sk-band);opacity:.16}app-ai-cd-pdf-viewer .sk-ul:after{content:"";position:absolute;left:0;right:0;bottom:-4px;height:2px;border-radius:2px;background:var(--sk-band);opacity:.7}@keyframes sk-shimmer{0%{background-position:100% 0}to{background-position:0 0}}@media (prefers-reduced-motion: reduce){app-ai-cd-pdf-viewer .sk-line{animation:none}} 13`],encapsulation:2})}}return o})();var _t=function(o){return o.ReportViewed="AI_CD_Report_Viewed",o.ReportLoadFailed="AI_CD_Report_Load_Failed",o.DownloadClicked="AI_CD_Report_Download_Clicked",o.BackClicked="AI_CD_Report_Back_Clicked",o.PassageSelected="AI_CD_Report_Passage_Selected",o.FilterToggled="AI_CD_Report_Filter_Toggled",o.BandFiltered="AI_CD_Report_Band_Filtered",o.ZoomChanged="AI_CD_Report_Zoom_Changed",o.PageNavigated="AI_CD_Report_Page_Navigated",o}(_t||{});var yo=["filterBtn"],wo=["scoreCard"],Ao=["sidebar"],Co=["filterWrap"],So=(o,e)=>e.key,Eo=(o,e)=>e.id,ko=o=>({progress:o}),Po=o=>({score:o}),To=o=>({on:o}),Mo=o=>({hatch:o}),Ro=o=>({off:o});function Io(o,e){o&1&&(v(0,"div",17),k(1),w()),o&2&&(_(),Mt(" ",e," "))}function Lo(o,e){if(o&1&&(v(0,"span",18),z(1,"span",20),k(2),E(3,"date"),w()),o&2){let t=F(2);_(2),Mt(" ",Jt(3,1,t.createdAt()+"Z","MMM d, y h:mm a")," ")}}function Oo(o,e){if(o&1&&(v(0,"div",8)(1,"span",16),k(2),E(3,"translate"),nt(4,Io,2,1,"div",17),w(),nt
13(5,Lo,4,4,"span",18),v(6,"span",19),z(7,"span",20),k(8),E(9,"number"),v(10,"span",21),k(11),E(12,"translate"),w(),v(13,"em"),k(14),E(15,"number"),v(16,"span",21),k(17),E(18,"translate"),w(),k(19," )"),w()()()),o&2){let t,i=F();_(),at("tabindex",i.fileNameTooltip()?0:null)("aria-describedby",i.fileNameTooltip()?"file-name-tooltip":null),_(),Mt(" ",i.fileDisplayName()||T(3,11,i.keys.AICDReportView.documentFallback)," "),_(2),rt((t=i.fileNameTooltip())?4:-1,t),_(),rt(i.createdAt()?5:-1),_(3),Mt(" ",T(9,13,i.report().score.totalWords)," "),_(2),M("appLocalizationHover",i.keys.AICDReportView.words),_(),L(T(12,15,i.keys.AICDReportView.words)),_(3),Mt("( ",T(15,17,i.paragraphCount())," "),_(2),M("appLocalizationHover",i.keys.AICDReportView.paragraphs),_(),L(T(18,19,i.report().score.totalWords>1?i.keys.AICDReportView.paragraphs:i.keys.AICDReportView.paragraph))}}function Do(o,e){if(o&1&&(v(0,"span",21),k(1),E(2,"translate"),w()),o&2){let t=F(3);M("appLocalizationHover",t.keys.AICDReportView.downloadingProgress),_(),L(Jt(2,2,t.keys.AICDReportView.downloadingProgress,Zt(5,ko,t.downloadProgress())))}}function Fo(o,e){if(o&1&&(v(0,"span",21),k(1),E(2,"translate"),w()),o&2){let t=F(3);M("appLocalizationHover",t.keys.AICDReportView.downloading),_(),L(T(2,2,t.keys.AICDReportView.downloading))}}function No(o,e){if(o&1&&nt(0,Do,3,7,"span",21)(1,Fo,3,4,"span",21),o&2){let t=F(2);rt(t.downloadProgress()>0?0:1)}}function Bo(o,e){if(o&1&&(v(0,"span",21),k(1),E(2,"translate"),w()),o&2){let t=F(2);M("appLocalizationHover",t.keys.AICDReportView.downloadPdf),_(),L(T(2,2,t.keys.AICDReportView.downloadPdf))}}function Ho(o,e){if(o&1){let t=Ht();v(0,"button",22),tt("click",function(){q(t);let s=F();return K(s.download())}),gt(),v(1,"svg",23),z(2,"path",24),w(),vt(),v(3,"span",25),nt(4,No,2,1)(5,Bo,3,4,"span",21),w()()}if(o&2){let t=F();M("disabled",t.downloading()),at("aria-busy",t.downloading()),_(4),rt(t.downloading()?4:5)}}function Vo(o,e){if(o&1){let t=Ht();v(0,"div",11)(1,"button",26),E(2,"translate"),E(3,"translate"),tt("click",function(){q(t);let s=F();return K(s.prevPage())}),z(4,"img",27),w(),v(5,"span",28),E(6,"translate"),k(7),w(),v(8,"button",26),E(9,"translate"),E(10,"translate"),tt("click",function(){q(t);let s=F();return K(s.nextPage())}),z(11,"img",29),w(),z(12,"span",30),v(13,"button",31),E(14,"translate"),E(15,"translate"),tt("click",function(){q(t);let s=F();return K(s.zoomOut())}),z(16,"img",32),w(),v(17,"button",33),E(18,"translate"),E(19,"translate"),tt("click",function(){q(t);let s=F();return K(s.resetZoom())}),k(20),E(21,"number"),w(),v(22,"button",31),E(23,"translate"),E(24,"translate"),tt("click",function(){q(t);let s=F();return K(s.zoomIn())}),z(25,"img",34),w()()}if(o&2){let t=F();_(),M("disabled",t.currentPage()<=1),at("title",T(2,16,t.keys.AICDReportView.previousPage))("aria-label",T(3,18,t.keys.AICDReportView.previousPage)),_(4),at("title",T(6,20,t.keys.AICDReportView.page)),_(2),or("",t.currentPage()," / ",t.numPages(),""),_(),M("disabled",t.currentPage()>=t.numPages()),at("title",T(9,22,t.keys.AICDReportView.nextPage))("aria-label",T(10,24,t.keys.AICDReportView.nextPage)),_(5),at("title",T(14,26,t.keys.AICDReportView.zoomOut))("aria-label",T(15,28,t.keys.AICDReportView.zoomOut)),_(4),at("title",T(18,30,t.keys.AICDReportView.resetZoom))("aria-label",T(19,32,t.keys.AICDReportView.resetZoom)),_(3),Mt(" ",Jt(21,34,t.zoom()*100,"1.0-0"),"% "),_(2),at("title",T(23,37,t.keys.AICDReportView.zoomIn))("aria-label",T(24,39,t.keys.AICDReportView.zoomIn))}}function zo(o,e){if(o&1){let t=Ht();v(0,"div",12)(1,"button",35),tt("click",function(){q(t);let s=F();return K(s.mobileTab.set(s.mobileTabs.Document))}),v(2,"span",21),k(3),E(4,"translate"),w()(),v(5,"button",35),tt("click",function(){q(t);let s=F();return K(s.mobileTab.set(s.mobileTabs.Report))}),v(6,"span",21),k(7),E(8,"translate"),w()()()}if(o&2){let t=F();_(),Bt("active",t.mobileTab()===t.mobileTabs.Document),_(),M("appLocalizationHover",t.keys.AICDReportView.mobileTabDocument),_(),L(T(4,8,t.keys.AICDReportView.mobileTabDocument)),_(2),Bt("active",t.mobileTab()===t.mobileTabs.Report),_(),M("appLocalizationHover",t.keys.AICDReportView.mobileTabReport),_(),L(T(8,10,t.keys.AICDReportView.mobileTabReport))}}function $o(o,e){if(o&1&&(v(0,"div",14)(1,"div",36)(2,"h3")(3,"span",21),k(4),E(5,"translate"),w()(),v(6,"p"),k(7),w()()()),o&2){let t=F();_(3),M("appLocalizationHover",t.keys.AICDReportView.errorTitle),_(),L(T(5,3,t.keys.AICDReportView.errorTitle)),_(3),L(t.loadError())}}function Uo(o,e){if(o&1&&(v(0,"div",14)(1,"div",37),z(2,"div",38),v(3,"h3")(4,"span",21),k(5),E(6,"translate"),w()(),v(7,"p")(8,"span",21),k(9),E(10,"translate"),w()()()()),o&2){let t=F();_(4),M("appLocalizationHover",t.keys.AICDReportView.analyzingTitle),_(),L(T(6,4,t.keys.AICDReportView.analyzingTitle)),_(3),M("appLocalizationHover",t.keys.AICDReportView.analyzingDesc),_(),L(T(10,6,t.keys.AICDReportView.analyzingDesc))}}function jo(o,e){if(o&1&&(v(0,"div",85)(1,"span",99)(2,"span",21),k(3),E(4,"translate"),w(),v(5,"span",100),gt(),v(6,"svg",53),z(7,"path",54)(8,"path",55)(9,"path",56),w(),vt(),v(10,"span",101),k(11),w()()(),v(12,"span",102),z(13,"span",103),w(),v(14,"span",104)(15,"b"),k(16),E(17,"number"),w(),k(18),w()()),o&2){let t=e.$implicit,i=F(2);_(2),M("appLocalizationHover",t.labelKey),_(),L(T(4,13,t.labelKey)),_(2),at("aria-describedby","band-tooltip-"+t.key),_(5),sr("id","band-tooltip-",t.key,""),_(),Mt(" ",i.bandTip(t.key)," "),_(2),mt("width",t.words>0?t.pct<3?3:t.pct:0,"%")("--band",t.color),M("ngClass",Zt(17,Mo,t.hatch)),_(3),L(T(17,15,t.words)),_(2),Mt(" (",t.pct,"%)")}}function Go(o,e){if(o&1&&z(0,"div",110),o&2){let t=e.$implicit;M("innerHTML",t,os)}}function Wo(o,e){if(o&1&&(v(0,"section",86)(1,"div",105),gt(),v(2,"svg",106),z(3,"circle",107)(4,"path",108),w(),vt(),v(5,"span",21),k(6),E(7,"translate"),w()(),v(8,"div",109),Wt(9,Go,1,1,"div",110,Ie),w()()),o&2){let t=F(2);_(5),M("appLocalizationHover",t.keys.AICDReportView.notScored),_(),L(T(7,2,t.ke
13ys.AICDReportView.notScored)),_(3),Xt(t.notScored())}}function Xo(o,e){o&1&&(gt(),v(0,"svg",116),z(1,"path",117),w())}function qo(o,e){if(o&1){let t=Ht();v(0,"button",114),tt("click",function(){let s=q(t).$implicit,n=F(3);return K(n.toggleConfidence(s))}),v(1,"span",115),nt(2,Xo,2,0,":svg:svg",116),w(),v(3,"span",21),k(4),E(5,"translate"),w()()}if(o&2){let t=e.$implicit,i=F(3);M("ngClass",Zt(10,Ro,!i.visible().has(t))),_(),mt("border-color",i.bandColor(t))("background-color",i.visible().has(t)?i.bandColor(t):i.bandColor(t)+"20"),_(),rt(i.visible().has(t)?2:-1),_(),M("appLocalizationHover",i.tierLabelKey(t)),_(),L(T(5,8,i.tierLabelKey(t)))}}function Ko(o,e){if(o&1&&(v(0,"div",111)(1,"div",112)(2,"span",21),k(3),E(4,"translate"),w()(),Wt(5,qo,6,12,"button",113,ir),w()),o&2){let t=F(2);Bt("filter-menu-up",t.filterMenuOpenUp()),_(2),M("appLocalizationHover",t.keys.AICDReportView.showBands),_(),L(T(4,4,t.keys.AICDReportView.showBands)),_(2),Xt(t.tiers)}}function Yo(o,e){if(o&1){let t=Ht();v(0,"button",118),tt("click",function(){let s=q(t).$implicit,n=F(2);return K(n.selectSegment(s.id))}),v(1,"div",119),z(2,"span",120),v(3,"span",121),k(4),E(5,"translate"),w()(),z(6,"div",122),w()}if(o&2){let t=e.$implicit,i=F(2);Bt("active",i.activeSegmentId()===t.id),M("id","seg-item-"+t.id),_(2),mt("background-color",i.passageBand(t.score).color),_(),mt("color",i.passageBand(t.score).color),M("appLocalizationHover",i.passageBand(t.score).labelKey),_(),L(T(5,10,i.passageBand(t.score).labelKey)),_(2),M("innerHTML",t.text,os)}}function Qo(o,e){if(o&1&&(v(0,"div",98)(1,"span",21),k(2),E(3,"translate"),w()()),o&2){let t=F(2);_(),M("appLocalizationHover",t.keys.AICDReportView.noPassagesMatchFilters),_(),L(T(3,2,t.keys.AICDReportView.noPassagesMatchFilters))}}function Zo(o,e){if(o&1){let t=Ht();v(0,"div",39)(1,"div",40)(2,"app-ai-cd-pdf-viewer",41),tt("ready",function(s){q(t);let n=F();return K(n.onReady(s))})("pageChange",function(s){q(t);let n=F();return K(n.onPageChange(s))})("segmentClick",function(s){q(t);let n=F();return K(n.onViewerSegmentClick(s))}),w()(),v(3,"p",42)(4,"b")(5,"span",21),k(6),E(7,"translate"),w()(),v(8,"span",21),k(9),E(10,"translate"),w()()(),v(11,"aside",43,0),tt("scroll",function(s){q(t);let n=F();return K(n.onSidebarScroll(s))}),v(13,"div",44)(14,"section",45,1)(16,"div",46)(17,"div",47)(18,"div",48)(19,"span",49)(20,"span",21),k(21),E(22,"translate"),w()(),v(23,"div",50)(24,"span",51),k(25),w(),v(26,"span",52),gt(),v(27,"svg",53),z(28,"path",54)(29,"path",55)(30,"path",56),w(),vt(),v(31,"div",57)(32,"span",21),k(33),E(34,"translate"),w()()()(),v(35,"span",58),z(36,"span",59),v(37,"span",21),k(38),E(39,"translate"),w()()(),v(40,"p",60)(41,"span",21),k(42),E(43,"translate"),w()()(),v(44,"div",61)(45,"div",62)(46,"span",63)(47,"div",64)(48,"span",21),k(49),E(50,"translate"),w()()()(),v(51,"div",65)(52,"span",66)(53,"span",21),k(54),E(55,"translate"),w()()(),z(56,"div",67)(57,"span",68),v(58,"div",69)(59,"span"),k(60," 0 "),gt(),v(61,"svg",70),z(62,"path",71),w(),vt(),v(63,"span",21),k(64),E(65,"translate"),w()(),v(66,"span",72)(67,"span",21),k(68),E(69,"translate"),w()(),v(70,"span")(71,"span",21),k(72),E(73,"translate"),w(),gt(),v(74,"svg",73),z(75,"path",74),w(),k(76," 100 "),w()()()()()(),vt(),v(77,"section",75),E(78,"translate"),v(79,"div",76)(80,"div",77)(81,"span",78),k(82),w(),v(83,"span",79)(84,"span",21),k(85),E(86,"translate"),w()()(),v(87,"span",80),z(88,"span",59),v(89,"span",21),k(90),E(91,"translate"),w()()()(),v(92,"section",81)(93,"h2",82)(94,"span",21),k(95),E(96,"translate"),w()(),v(97,"p",83)(98,"span",21),k(99),E(100,"translate"),w()(),v(101,"div",84),Wt(102,jo,19,19,"div",85,So),w()(),nt(104,Wo,11,4,"section",86),v(105,"section",87)(106,"div",88)(107,"span",89)(108,"span",21),k(109),E(110,"translate"),w(),v(111,"span",90),k(112),w()(),v(113,"div",91)(114,"div",92,2),tt("click",function(s){return q(t),K(s.stopPropagation())}),v(116,"button",93,3),E(118,"translate"),E(119,"translate"),tt("click",function(){q(t);let s=F();return K(s.toggleFilters())}),gt(),v(120,"svg",23),z(121,"path",94),w()(),nt(122,Ko,7,6,"div",95),w()()(),vt(),v(123,"div",96),Wt(124,Yo,7,12,"button",97,Eo,!1,Qo,4,4,"div",98),w()()()}if(o&2){let t=F();_(2),M("src",t.fileUrl())("segments",t.aiSegments())("zoom",t.zoom())("activeSegmentId",t.activeSegmentId())("visibleConfidence
13s",t.visible()),_(3),M("appLocalizationHover",t.keys.AICDReportView.disclaimerLabel),_(),L(T(7,68,t.keys.AICDReportView.disclaimerLabel)),_(2),M("appLocalizationHover",t.keys.AICDReportView.disclaimerBody),_(),L(T(10,70,t.keys.AICDReportView.disclaimerBody)),_(4),mt("min-height",t.scoreCardCollapsed()?t.scoreCardSlotHeight():null,"px"),_(),Bt("score-card-full-hidden",t.scoreCardCollapsed()),at("aria-hidden",t.scoreCardCollapsed()),_(6),M("appLocalizationHover",t.keys.AICDReportView.aiScore),_(),L(T(22,72,t.keys.AICDReportView.aiScore)),_(4),L(t.report().score.aiLikelihood),_(6),M("ngClass",t.report().score.aiLikelihood<10?"tooltip-left":"tooltip-center"),_(),M("appLocalizationHover",t.keys.AICDReportView.scoreTip),_(),L(T(34,74,t.keys.AICDReportView.scoreTip)),_(3),mt("background",t.verdict().color),_(),M("appLocalizationHover",t.verdict().labelKey),_(),L(T(39,76,t.verdict().labelKey)),_(3),M("appLocalizationHover",t.verdict().descKey),_(),L(T(43,78,t.verdict().descKey)),_(3),mt("left",t.report().score.aiLikelihood,"%"),_(2),M("ngClass",t.scaleMarkerTooltipAlign()),_(),M("appLocalizationHover",t.keys.AICDReportView.scoreTip),_(),L(T(50,80,t.keys.AICDReportView.scoreTip)),_(2),mt("left",t.report().score.aiLikelihood,"%"),M("ngClass",t.scaleFlagPosition()),_(2),M("appLocalizationHover",t.keys.AICDReportView.scaleHere),_(),L(Jt(55,82,t.keys.AICDReportView.scaleHere,Zt(107,Po,t.report().score.aiLikelihood))),_(3),mt("left",t.report().score.aiLikelihood,"%"),_(6),M("appLocalizationHover",t.keys.AICDReportView.scaleHuman),_(),L(T(65,85,t.keys.AICDReportView.scaleHuman)),_(3),M("appLocalizationHover",t.keys.AICDReportView.scaleUncertain),_(),L(T(69,87,t.keys.AICDReportView.scaleUncertain)),_(3),M("appLocalizationHover",t.keys.AICDReportView.scaleAi),_(),L(T(73,89,t.keys.AICDReportView.scaleAi)),_(5),Bt("score-card-collapsed-visible",t.scoreCardCollapsed()),at("aria-hidden",!t.scoreCardCollapsed())("aria-label",T(78,91,t.keys.AICDReportView.aiScoreSummary)),_(5),L(t.report().score.aiLikelihood),_(2),M("appLocalizationHover",t.keys.AICDReportView.aiScore),_(),L(T(86,93,t.keys.AICDReportView.aiScore)),_(3),mt("background",t.verdict().color),_(),M("appLocalizationHover",t.verdict().labelKey),_(),L(T(91,95,t.verdict().labelKey)),_(4),M("appLocalizationHover",t.keys.AICDReportView.scoreDistribution),_(),L(T(96,97,t.keys.AICDReportView.scoreDistribution)),_(3),M("appLocalizationHover",t.keys.AICDReportView.scoreDistributionDesc),_(),L(T(100,99,t.keys.AICDReportView.scoreDistributionDesc)),_(3),Xt(t.distribution()),_(2),rt(t.notScored().length?104:-1),_(4),M("appLocalizationHover",t.keys.AICDReportView.flaggedPassages),_(),L(T(110,101,t.keys.AICDReportView.flaggedPassages)),_(3),L(t.visibleSegments().length),_(4),M("ngClass",Zt(109,To,t.filtered()||t.filtersOpen())),at("title",T(118,103,t.keys.AICDReportView.filterByConfidence))("aria-label",T(119,105,t.keys.AICDReportView.filterByConfidence)),_(6),rt(t.filtersOpen()?122:-1),_(2),Xt(t.visibleSegmentsToRender())}}function Jo(o,e){if(o&1&&(v(0,"div",123),k(1),w()),o&2){let t=e;mt("left",t.left,"px")("top",t.top,"px"),Bt("place-bottom",t.place==="bottom"),_(),Mt(" ",t.text," ")}}var jn=["confident-ai","leaning-ai","inconclusive","leaning-human","confident-human"],Gn='width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"',tl={human:`<svg ${Gn}><path d="M12 3l7 3v5c0 4-3 7-7 8-4-1-7-4-7-8V6z"/><path d="M9 12l2 2 4-4"/></svg>`,ai:`<svg ${Gn}><rect x="4" y="8" width="16" height="12" rx="2"/><path d="M12 8V4"/><circle cx="9" cy="14" r="0.6"/><circle cx="15" cy="14" r="0.6"/></svg>`,inconclusive:`<svg ${Gn}><path d="M6 18L18 6"/><path d="M9 18L18 9"/><path d="M6 15L15 6"/></svg>`},Kr=(()=>{class o{constructor(t,i,s,n,r,a,l){this.api=t,this.route=i,this.router=s,this.sanitizer=n,this.amplitude=r,this.translate=a,this.storage=l,this.keys=ct,this.mobileTabs=Le,this.injector=Zn(Jn),this.viewer=Gt(ii),this.filterBtnRef=Gt("filterBtn"),this.scoreCardRef=Gt("scoreCard"),this.sidebarRef=Gt("sidebar"),this.destroy$=new he,this.id=Y(""),this.doc=Y(null),this.report=Y(null),this.loadError=Y(null),this.zoom=Y(1),this.currentPage=Y(1),this.numPages=Y(0),this.activeSegmentId=Y(null),this.visible=Y(new Set(Se)),this.filtersOpen=Y(!1),this.filterMenuOpenUp=Y(!1),this.filterMenuHeight=260,this.mobileTab=Y(Le.Document),this.tip=Y(null),this.tiers=Se,this.fileUrl=Y(""),this.downloading=Y(!1),this.downloadProgress=Y(0),this.aiSegments=St(()=>this.report()?.segments??[]),this.visibleSegments=St(()=>{let c=this.visible();return this.aiSegments().filter(h=>c.has(h.confidence))}),this.fileNameMaxLength=20,this.createdAt=St(()=>this.report()?.createdAt??this.doc()?.createdAt??""),this.paragraphCount=St(()=>this.report()?.paragraphs?.length??0),this.fileFullName=St(()=>this.doc()?.filename||this.report()?.filename||""),this.fileDisplayName=St(()=>{let c=this.fileFullName();
13return c.length<=this.fileNameMaxLength?decodeURIComponent(c):`${decodeURIComponent(c.slice(0,this.fileNameMaxLength))}\u2026`}),this.fileNameTooltip=St(()=>{let c=this.fileFullName();return c.length>this.fileNameMaxLength?decodeURIComponent(c):null}),this.notScored=St(()=>(this.report()?.paragraphs??[]).filter(c=>!c.scored&&c.text.trim()).map(c=>c.text.trim())),this.verdict=St(()=>ps(this.report()?.score.aiLikelihood??0)),this.scaleFlagPosition=St(()=>{let c=this.report()?.score.aiLikelihood??50;return`scale-flag-pos-${this.scaleMarkerEdgeAlign(c)}`}),this.scaleMarkerTooltipAlign=St(()=>{let c=this.report()?.score.aiLikelihood??50;return`scale-marker-tooltip-${this.scaleMarkerEdgeAlign(c)}`}),this.filtered=St(()=>this.visible().size<Se.length),this.distribution=St(()=>{let c=this.report()?.paragraphs??[],h={};for(let u of jn)h[u]=0;for(let u of c)u.scored&&h[u.band]!=null&&(h[u.band]+=u.words||0);let d=jn.reduce((u,p)=>u+h[p],0)||1;return jn.map(u=>({key:u,labelKey:xt[u].labelKey,color:Ce[u].color,background:Ce[u].background,borderColor:Ce[u].borderColor,borderStyle:Ce[u].borderStyle,words:h[u],pct:Math.round(h[u]/d*100),hatch:u==="confident-ai"||u==="confident-human"}))}),this.iconCache=new Map,this.displayCount=Y(15),this.scoreCardCollapsed=Y(!1),this.scoreCardSlotHeight=Y(0),this.scoreCardCollapseScrollTop=0,this.scoreCardExpandedHeight=0,this.scoreCardCollapseHysteresis=48,this.visibleSegmentsToRender=St(()=>this.visibleSegments().slice(0,this.displayCount())),this.route.paramMap.pipe(jt(this.destroy$)).subscribe(c=>{let h=c.get("id")||"";this.id.set(h),this.fetch(h)}),se(()=>{this.visibleSegments(),this.displayCount.set(15)}),se(()=>{this.report()&&(this.resetScoreCardCollapse(),ls(()=>{let c=this.sidebarRef()?.nativeElement;c&&this.cacheScoreCardMetrics(c)},{injector:this.injector}))})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}logEvent(t,i={}){this.amplitude.logAmplitude(t,Nt({report_id:this.id()},i))}fetch(t){this.api.getDocument(t).pipe(jt(this.destroy$)).subscribe({next:i=>{this.doc.set(i),i.status==="failed"?(this.loadError.set(i.error||this.translate.instant(this.keys.AICDReportView.analysisFailed)),this.logEvent(_t.ReportLoadFailed,{reason:"analysis_failed"})):this.loadReport(t)},error:()=>{this.loadError.set(this.translate.instant(this.keys.AICDReportView.documentNotFound)),this.logEvent(_t.ReportLoadFailed,{reason:"document_not_found"})}})}loadReport(t){this.api.getReport(t).pipe(jt(this.destroy$)).subscribe({next:i=>{this.report.set(i),this.fileUrl.set(this.doc()?.fileBlob??this.doc()?.url??""),this.logEvent(_t.ReportViewed,{ai_likelihood:i.score?.aiLikelihood,total_words:i.score?.totalWords,paragraph_count:i.paragraphs?.length??0,flagged_passages:i.segments?.length??0})},error:()=>{this.loadError.set(this.translate.instant(this.keys.AICDReportView.couldNotLoadReport)),this.logEvent(_t.ReportLoadFailed,{reason:"report_fetch_failed"})}})}scaleMarkerEdgeAlign(t){return t<=25?hi.Left:t>=75?hi.Right:hi.Center}passageBand(t){return ps(t)}bandColor(t){return Ce[t].color}toggleConfidence(t){let i=new Set(this.visible());i.has(t)?i.delete(t):i.add(t),this.visible.set(i),this.logEvent(_t.BandFiltered,{band:t,visible:i.has(t)}),this.resetVisibleSegments()}toggleFilters(){!this.filtersOpen()&&this.updateFilterMenuPlacement(),this.filtersOpen.update(i=>!i),this.logEvent(_t.FilterToggled,{open:this.filtersOpen()})}updateFilterMenuPlacement(){let t=this.filterBtnRef()?.nativeElement;if(!t){this.filterMenuOpenUp.set(!1);return}let i=window.innerHeight-t.getBoundingClientRect().bottom;this.filterMenuOpenUp.set(i<this.filterMenuHeight)}bandTip(t){let i=this.translate.instant(xt[t].labelKey),s=this.translate.instant(Ar[t]);return`${i}: ${s}`}tierLabelKey(t){return xt[t].labelKey}showTip(t,i){let n=t.currentTarget.getBoundingClientRect(),r=n.top>120?"top":"bottom";this.tip.set({text:i,left:n.left+n.width/2,top:r==="top"?n.top-8:n.bottom+8,place:r})}hideTip(){this.tip.set(null)}selectSegment(t){this.activeSegmentId.set(t);let i=this.aiSegments().find(s=>s.id===t);this.logEvent(_t.PassageSelected,{segment_id:t,band:i?.confidence,page:i?.page}),this.mobileTab.set(Le.Document),queueMicrotask(()=>this.viewer()?.scrollToSegment(t))}onViewerSegmentClick(t){this.activeSegmentId.set(t),this.mobileTab.set(Le.Report),this.ensureSegmentRen
13dered(t)&&this.scrollSidebarSegmentIntoView(t)}ensureSegmentRendered(t){let i=this.visibleSegments(),s=i.findIndex(r=>r.id===t);if(s===-1)return!1;let n=Math.min(i.length,s+1);return this.displayCount()<n&&this.displayCount.set(n),!0}scrollSidebarSegmentIntoView(t,i=0){let n=document.getElementById(`seg-item-${t}`);if(n){n.scrollIntoView({behavior:"smooth",block:"center"});return}i>=6||ls(()=>this.scrollSidebarSegmentIntoView(t,i+1),{injector:this.injector})}onReady(t){this.numPages.set(t)}onPageChange(t){this.currentPage.set(t)}prevPage(){let t=Math.max(1,this.currentPage()-1);this.viewer()?.scrollToPage(t),this.logEvent(_t.PageNavigated,{direction:"prev",page:t})}nextPage(){let t=Math.min(this.numPages(),this.currentPage()+1);this.viewer()?.scrollToPage(t),this.logEvent(_t.PageNavigated,{direction:"next",page:t})}zoomIn(){this.zoom.set(Math.min(3,+(this.zoom()+.25).toFixed(2))),this.logEvent(_t.ZoomChanged,{action:"in",zoom:this.zoom()})}zoomOut(){this.zoom.set(Math.max(.5,+(this.zoom()-.25).toFixed(2))),this.logEvent(_t.ZoomChanged,{action:"out",zoom:this.zoom()})}resetZoom(){this.zoom.set(1),this.logEvent(_t.ZoomChanged,{action:"reset",zoom:this.zoom()})}download(){let t=this.id();!t||this.downloading()||(this.logEvent(_t.DownloadClicked),this.downloading.set(!0),this.downloadProgress.set(0),this.api.downloadReport(t,this.storage.getUserEmail()).pipe(Kn(()=>this.downloading.set(!1)),jt(this.destroy$)).subscribe({next:i=>this.onDownloadEvent(i),error:()=>this.logEvent(_t.ReportLoadFailed,{reason:"download_failed"})}))}onDownloadEvent(t){t.type===ye.DownloadProgress?this.downloadProgress.set(t.total?Math.round(t.loaded/t.total*100):0):t.type===ye.Response&&this.handleDownload(t)}handleDownload(t){let i=t.body;if(!i)return;if((t.headers.get("content-type")||i.type||"").toLowerCase().includes("application/json")){i.text().then(r=>{let a={};try{a=JSON.parse(r)}catch{a={}}let l=a.url??a.data?.url??a.file_url??"";l&&this.triggerDownload(l)});return}let n=URL.createObjectURL(i);this.triggerDownload(n),URL.revokeObjectURL(n)}triggerDownload(t){let i=document.createElement("a");i.href=t,i.download=this.downloadFilename(),i.target="_blank",i.rel="noopener",document.body.appendChild(i),i.click(),i.remove()}downloadFilename(){let i=(this.report()?.filename||this.doc()?.filename||"report").replace(/\.[^.]+$/,"");return`${decodeURIComponent(i)}-ai-content-report.pdf`}back(){this.logEvent(_t.BackClicked),this.router.navigate(["/ai-cd-report-viewer"])}bandIcon(t){if(!this.iconCache.has(t)){let i=t==="inconclusive"?"inconclusive":t.endsWith("-ai")?"ai":"human";this.iconCache.set(t,this.sanitizer.bypassSecurityTrustHtml(tl[i]))}return this.iconCache.get(t)}onSidebarScroll(t){let i=t.target;this.updateScoreCardCollapse(i),i.scrollTop+i.clientHeight>=i.scrollHeight-100&&this.displayCount()<this.visibleSegments().length&&this.displayCount.update(n=>n+15)}updateScoreCardCollapse(t){if(t.scrollTop<=0){this.resetScoreCardCollapse();return}if(this.scoreCardCollapsed()){let s=this.scoreCardCollapseScrollTop-this.scoreCardCollapseHysteresis;this.scoreCardCollapseScrollTop>0&&t.scrollTop<s&&this.resetScoreCardCollapse();return}this.scoreCardRef()?.nativeElement&&(this.cacheScoreCardMetrics(t),this.scoreCardCollapseScrollTop>0&&t.scrollTop>=this.scoreCardCollapseScrollTop&&(this.scoreCardSlotHeight.set(this.scoreCardExpandedHeight),this.setScoreCardCollapsed(!0)))}cacheScoreCardMetrics(t){if(this.scoreCardCollapsed()||this.scoreCardCollapseScrollTop>0)return;let i=this.scoreCardRef()?.nativeElement;i&&(this.scoreCardExpandedHeight=i.offsetHeight,this.scoreCardCollapseScrollTop=this.getElementScrollOffset(i,t)+this.scoreCardExpandedHeight)}setScoreCardCollapsed(t){this.scoreCardCollapsed()!==t&&this.scoreCardCollapsed.set(t)}resetScoreCardCollapse(){this.scoreCardCollapseScrollTop=0,this.scoreCardExpandedHeight=0,this.scoreCardSlotHeight.set(0),this.setScoreCardCollapsed(!1)}getElementScrollOffset(t,i){let s=i.getBoundingClientRect();return t.getBoundingClientRect().top-s.top+i.scrollTop}resetVisibleSegments(){this.displayCount.set(15)}onDocumentClick(t){if(!this.filtersOpen()||!this.filterWrap)return;t.composedPath().includes(this.filterWrap.nativeElement)||this.filtersOpen.set(!1)}static{this.\u0275fac=function(i){return new(i||o)(Ct(fi),Ct(dr),Ct(ci),Ct(hr),Ct(pr),Ct(we),Ct(di))}}static{this.\u0275cmp=ie({type:o,selectors:[["app-ai-cd-report"]],viewQuery:function(i,s){if(i&1&&(qt(s.viewer,ii,5),qt(s.filterBtnRef,yo,5),qt(s.scoreCardRef,wo,5),qt(s.sidebarRef,Ao,5),nr(Co,5)),i&2){xe(4);let n;rr(n=ar())&&(s.filterWrap=n.first)}},hostBindings:function(i,s){i&1&&tt("click",function(r){return s.onDocumentClick(r)}
vendor: 3,997 bytes, line 13
13,!1,er)},decls:14,vars:8,consts:[["sidebar",""],["scoreCard",""],["filterWrap",""],["filterBtn",""],[1,"report"],[1,"toolbar"],[1,"tb-left"],[1,"tb-title"],[1,"tb-meta"],[1,"tb-right"],[1,"btn","btn-primary","dl-btn",3,"disabled"],[1,"float-controls"],[1,"mobile-tabs"],[1,"body"],[1,"state-center"],[1,"tooltip",3,"place-bottom","left","top"],[1,"tb-file","custom-tooltip"],["id","file-name-tooltip","role","tooltip",1,"custom-tooltip-content","tooltip-center"],[1,"tb-date"],[1,"tb-words"],[1,"tb-dot"],[3,"appLocalizationHover"],[1,"btn","btn-primary","dl-btn",3,"click","disabled"],["width","16","height","16","viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2","stroke-linecap","round","stroke-linejoin","round"],["d","M12 3v12M7 10l5 5 5-5M5 21h14"],[1,"btn-label"],[1,"fc-btn",3,"click","disabled"],["src","/assets/icons/chevron-left.svg","alt","","aria-hidden","true",1,"fc-icon"],[1,"fc-page"],["src","/assets/icons/chevron-right.svg","alt","","aria-hidden","true",1,"fc-icon"],[1,"fc-divider"],[1,"fc-btn",3,"click"],["src","/assets/icons/zoom-out.svg","alt","","aria-hidden","true",1,"fc-icon"],[1,"fc-zoom",3,"click"],["src","/assets/icons/zoom-in.svg","alt","","aria-hidden","true",1,"fc-icon"],[3,"click"],[1,"state-card","error"],[1,"state-card"],[1,"spinner"],[1,"viewer-pane"],[1,"viewer-scroll"],[3,"ready","pageChange","segmentClick","src","segments","zoom","activeSegmentId","visibleConfidences"],[1,"disclaimer"],[1,"sidebar",3,"scroll"],[1,"score-card-slot"],[1,"card","score-card"],[1,"score-card-body"],[1,"score-top"],[1,"score-figure"],[1,"score-label"],[1,"score-num-row"],[1,"score-num"],["tabindex","0","aria-describedby","score-tooltip",1,"info-i","custom-tooltip"],["width","16","height","16","viewBox","0 0 16 16","fill","none","xmlns","http://www.w3.org/2000/svg","aria-hidden","true","focusable","false"],["d","M8 0C12.413 0 16 3.58698 16 8C16 12.413 12.413 16 8 16C3.58698 16 0 12.413 0 8C0 3.58698 3.58698 0 8 0ZM8 14.8837C11.7953 14.8837 14.8837 11.7953 14.8837 8C14.8837 4.20465 11.7953 1.11628 8 1.11628C4.20465 1.11628 1.11628 4.20465 1.11628 8C1.11628 11.7953 4.20465 14.8837 8 14.8837Z","fill","#414E62"],["d","M7.99998 6.69746C8.3051 6.69746 8.55812 6.95048 8.55812 7.2556V10.9765C8.55812 11.2816 8.3051 11.5347 7.99998 11.5347C7.69486 11.5347 7.44184 11.2816 7.44184 10.9765V7.2556C7.44184 6.95048 7.69486 6.69746 7.99998 6.69746Z","fill","#414E62"],["d","M8 4.27951C8.09674 4.27951 8.19349 4.30183 8.28279 4.33904C8.37209 4.37625 8.45395 4.42835 8.52837 4.49532C8.59535 4.56974 8.64744 4.64416 8.68465 4.7409C8.72186 4.83021 8.74419 4.92695 8.74419 5.02369C8.74419 5.12044 8.72186 5.21718 8.68465 5.30649C8.64744 5.39579 8.59535 5.47765 8.52837 5.55207C8.45395 5.61904 8.37209 5.67114 8.28279 5.70835C8.10419 5.78276 7.89581 5.78276 7.71721 5.70835C7.62791 5.67114 7.54605 5.61904 7.47163 5.55207C7.40465 5.47765 7.35256 5.39579 7.31535 5.30649C7.27814 5.21718 7.25581 5.12044 7.25581 5.02369C7.25581 4.92695 7.27814 4.83021 7.31535 4.7409C7.35256 4.64416 7.40465 4.56974 7.47163 4.49532C7.54605 4.42835 7.62791 4.37625 7.71721 4.33904C7.80651 4.30183 7.90326 4.27951 8 4.27951Z","fill","#414E62"],["id","score-tooltip","role","tooltip",1,"custom-tooltip-content","tooltip-bottom",3,"ngClass"],[1,"verdict-pill"],[1,"pill-dot"],[1,"score-desc"],[1,"scale"],[1,"scale-tri-anchor"],["tabindex","0","aria-describedby","scale-marker-tooltip",1,"scale-tri","custom-tooltip"],["id","scale-marker-tooltip","role","tooltip",1,"custom-tooltip-content","scale-marker-tooltip",3,"ngClass"],[1,"scale-flag-anchor",3,"ngClass"],[1,"scale-flag"],[1,"scale-bar"],[1,"scale-knob"],[1,"scale-axis"],["width","20","height","8","viewBox","0 0 20 8","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M0.146446 3.32858C-0.0488148 3.52384 -0.0488148 3.84042 0.146446 4.03568L3.32843 7.21766C3.52369 7.41293 3.84027 7.41293 4.03553 7.21766C4.2308 7.0224 4.2308 6.70582 4.03553 6.51056L1.20711 3.68213L4.03553 0.853702C4.2308 0.65844 4.2308
130.341857 4.03553 0.146595C3.84027 -0.0486672 3.52369 -0.0486672 3.32843 0.146595L0.146446 3.32858ZM19.5 3.68213V3.18213L0.5 3.18213V3.68213V4.18213L19.5 4.18213V3.68213Z","fill","#414E62"],[1,"scale-mid"],["width","23","height","8","viewBox","0 0 23 8","fill","none","xmlns","http://www.w3.org/2000/svg"],["d","M22.3536 4.03568C22.5488 3.84042 22.5488 3.52384 22.3536 3.32858L19.1716 0.146597C18.9763 -0.0486655 18.6597 -0.0486656 18.4645 0.146597C18.2692 0.341859 18.2692 0.658441 18.4645 0.853703L21.2929 3.68213L18.4645 6.51056C18.2692 6.70582 18.2692 7.0224 18.4645 7.21766C18.6597 7.41293 18.9763 7.41293 19.1716 7.21766L22.3536 4.03568ZM0 3.68213L-4.37114e-08 4.18213L22 4.18213L22 3.68213L22 3.18213L4.37114e-08 3.18213L0 3.68213Z","fill","#414E62"],[1,"card","score-card","score-card-collapsed"],[1,"score-card-compact"],[1,"score-compact-left"],[1,"score-compact-num"],[1,"score-compact-label"],[1,"verdict-pill","score-compact-pill"],[1,"dist-block"],[1,"section-head"],[1,"section-sub"],[1,"dist"],[1,"dist-row"],[1,"not-scored"],[1,"matches"],[1,"matches-head"],[1,"mh-title"],[1,"count"],[1,"mh-right"],[1,"filter-wrap",3,"click"],[1,"filter-btn",3,"click","ngClass"],["d","M3 5h18M6 12h12M10 19h4"],[1,"filter-menu",3,"filter-menu-up"],[1,"matches-list"],[1,"match",3,"id","active"],[1,"matches-empty"],[1,"dist-label"],["tabindex","0",1,"info-i","custom-tooltip","sm","text-left"],["role","tooltip",1,"custom-tooltip-content","tooltip-left","text-left",3,"id"],[1,"dist-track"],[1,"dist-fill",3,"ngClass"],[1,"dist-val"],[1,"ns-head"],["width","14","height","14","viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2"],["cx","12","cy","12","r","9"],["d","M6 6l12 12"],[1,"ns-list"],[1,"ns-item",3,"innerHTML"],[1,"filter-menu"],[1,"fm-head"],[1,"fm-item",3,"ngClass"],[1,"fm-item",3,"click","ngClass"],[1,"fm-check"],["width","12","height","12","viewBox","0 0 24 24","fill","none","stroke","#fff","stroke-width","3","stroke-linecap","round","stroke-linejoin","round"],["d","M20 6L9 17l-5-5"],[1,"match",3,"click","id"],[1,"match-head"],[1,"match-dot"],[1,"match-label",3,"appLocalizationHover"],[1,"match-text",3,"innerHTML"],[1,"tooltip"]],template:function(i,s){if(i&1&&(v(0,"div",4)(1,"header",5)(2,"div",6)(3,"div",7),nt(4,Oo,20,21,"div",8),w()(),v(5,"div",9),nt(6,Ho,6,3,"button",10),w(),nt(7,Vo,26,41,"div",11),w(),nt(8,zo,9,12,"div",12),v(9,"div",13),nt(10,$o,8,5,"div",14)(11,Uo,11,8,"div",14)(12,Zo,127,111),w(),nt
13(13,Jo,2,7,"div",15),w()),i&2){let n;_(4),rt(s.report()?4:-1),_(2),rt(s.report()?6:-1),_(),rt(s.report()&&s.mobileTab()!==s.mobileTabs.Report?7:-1),_(),rt(s.report()?8:-1),_(),Bt("tab-report",s.mobileTab()===s.mobileTabs.Report),_(),rt(s.loadError()?10:s.report()?12:11),_(3),rt((n=s.tip())?13:-1,n)}},dependencies:[ai,pi,ii,li,oi,ui],styles:['[_nghost-%COMP%]{display:block;height:100%;min-height:0}.report[_ngcontent-%COMP%]{height:100%;display:flex;flex-direction:column;font-family:Open Sans}.btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:7px;font-size:14px;font-weight:600;line-height:1;padding:9px 15px;border:1px solid transparent;border-radius:5px;cursor:pointer;transition:all .18s ease}.btn[_ngcontent-%COMP%]:active{transform:translateY(1px)}.btn-primary[_ngcontent-%COMP%]{background:var(--brand);color:#fff}.btn-primary[_ngcontent-%COMP%]:hover{background:var(--brand-dark)}.btn-primary[_ngcontent-%COMP%]:disabled{color:var(--text-faint);cursor:not-allowed}.btn-ghost[_ngcontent-%COMP%]{background:var(--surface);border-color:var(--border-strong);color:var(--text)}.btn-ghost[_ngcontent-%COMP%]:hover{background:var(--surface-2)}.icon-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:var(--radius-sm);border:1px solid var(--border-strong);background:var(--surface);color:var(--text);cursor:pointer}.icon-btn[_ngcontent-%COMP%]:hover{background:var(--surface-2)}.btn[_ngcontent-%COMP%]:focus-visible, .icon-btn[_ngcontent-%COMP%]:focus-visible, .fc-btn[_ngcontent-%COMP%]:focus-visible, .fc-zoom[_ngcontent-%COMP%]:focus-visible, .filter-btn[_ngcontent-%COMP%]:focus-visible{outline:2px solid var(--brand);outline-offset:2px}.toolbar[_ngcontent-%COMP%]{position:relative;flex:none;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 22px 12px 25px;background:var(--surface);border-bottom:1px solid var(--border);z-index:5}.tb-left[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;min-width:0;flex:1}.tb-back[_ngcontent-%COMP%]{flex:none}.tb-title[_ngcontent-%COMP%]{min-width:0}.tb-heading[_ngcontent-%COMP%]{margin:0;font-size:17px;font-weight:600;color:var(--text);line-height:1.2;font-family:Open Sans}.tb-meta[_ngcontent-%COMP%]{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:12.5px;color:var(--tx-grey);line-height:1;margin-top:3px}.tb-meta[_ngcontent-%COMP%] em[_ngcontent-%COMP%]{font-style:normal;color:var(--text-faint)}.tb-file[_ngcontent-%COMP%]{font-weight:600;color:var(--tx-grey);max-width:260px;border-radius:0;overflow:visible;white-space:nowrap;cursor:default}.tb-file.custom-tooltip[_ngcontent-%COMP%]:hover .custom-tooltip-content[_ngcontent-%COMP%], .tb-file.custom-tooltip[_ngcontent-%COMP%]:focus-within .custom-tooltip-content[_ngcontent-%COMP%]{opacity:1;visibility:visible;display:block}.tb-file[_ngcontent-%COMP%] .custom-tooltip-content[_ngcontent-%COMP%]{z-index:20;white-space:normal;word-break:break-word}.tb-dot[_ngcontent-%COMP%]{width:1px;height:12px;background:var(--tx-border);display:inline-flex}.tb-date[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px}.tb-words[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;white-space:nowrap}.tb-words[_ngcontent-%COMP%] em[_ngcontent-%COMP%]{font-style:normal;color:var(--text-faint)}.tb-right[_ngcontent-%COMP%]{flex:none;display:flex;align-items:center;gap:10px}.share-btn[_ngcontent-%COMP%]{background:var(--surface);border:1px solid var(--border-strong);color:var(--text)}.share-btn[_ngcontent-%COMP%]:disabled{opacity:.55;cursor:not-allowed}.dl-btn[_ngcontent-%COMP%]{border:1px solid var(--tx-btn-color);background:var(--tx-btn-color);color:#fff}.dl-btn[_ngcontent-%COMP%]:hover{background:var(--tx-btn-hover);border-color:var(--tx-btn-hover)}.dl-btn[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.mobile-tabs[_ngcontent-%COMP%]{display:none;flex:none;gap:6px;padding:8px 12px;background:var(--surface);border-bottom:1px solid var(--border)}.mobile-tabs[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{flex:1;padding:9px 0;border:1px solid var(--border-strong);background:var(--surface);border-radius:8px;font-size:14px;font-weight:600;color:var(--text-muted);cursor:pointer;transition:all .15s ease}.mobile-tabs[_ngcontent-%COMP%] button.active[_ngcontent-%COMP%]{background:#7a28a0;border-color:#7a28a0;color:#fff}.body[_ngcontent-%COMP%]{flex:1;display:flex;min-height:0}.viewer-pane[_ngcontent-%COMP%]{position:relative;flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--bg)}.viewer-scroll[_ngcontent-%COMP%]{flex:1;min-height:0}.viewer-scroll[_ngcontent-%COMP%] app-ai-cd-pdf-viewer[_ngcontent-%COMP%]{display:block;height:100%}.disclaimer[_ngcontent-%COMP%]{flex:none;margin:0;padding:12px 26px;font-size:10.5px;line-height:1.55;color:var(--tx-grey);background:var(--surface);border-top:1px solid var(--tx-border)}
13.float-controls[_ngcontent-%COMP%]{position:absolute;top:50%;width:300px;left:max(430px,100% - 452px - 16px - 300px);transform:translateY(-50%);display:flex;align-items:center;gap:4px;padding:7px 10px;background:var(--surface);border-left:1px solid var(--border);border-right:1px solid var(--border);border-radius:999px;z-index:10;border-radius:0!important}.fc-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;border-radius:50%;background:transparent;color:var(--text);cursor:pointer;transition:background .12s ease}.fc-btn[_ngcontent-%COMP%]:hover{background:var(--surface-2)}.fc-btn[_ngcontent-%COMP%]:disabled{color:var(--text-faint);cursor:not-allowed}.fc-btn[_ngcontent-%COMP%]:disabled .fc-icon[_ngcontent-%COMP%]{opacity:.4}.fc-page[_ngcontent-%COMP%]{min-width:56px;text-align:center;font-size:14px;font-weight:600;color:var(--text)}.fc-zoom[_ngcontent-%COMP%]{min-width:52px;height:32px;border:none;background:transparent;border-radius:8px;font-size:14px;font-weight:600;color:var(--text);cursor:pointer}.fc-zoom[_ngcontent-%COMP%]:hover{background:var(--surface-2)}.fc-divider[_ngcontent-%COMP%]{width:1px;height:22px;background:var(--border-strong);margin:0 6px}.fc-icon[_ngcontent-%COMP%]{display:inline-block;width:18px;height:18px}.sidebar[_ngcontent-%COMP%]{flex:none;width:452px;background:#fafbfc;border-left:1px solid var(--tx-border);display:flex;flex-direction:column;overflow-y:auto;padding:18px;gap:24px}.card[_ngcontent-%COMP%]{display:block;background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow-sm)}.info-i[_ngcontent-%COMP%]{display:inline-flex;align-items:center;color:var(--text-faint);cursor:help;outline:none;transition:color .15s ease}.info-i[_ngcontent-%COMP%]:hover, .info-i[_ngcontent-%COMP%]:focus-visible{color:var(--text-muted)}.tooltip[_ngcontent-%COMP%]{position:fixed;z-index:1000;transform:translate(-50%,-100%);max-width:262px;width:max-content;padding:9px 13px;background:#26203a;color:#fff;font-size:12px;font-weight:400;line-height:1.5;text-align:left;border-radius:10px;box-shadow:0 10px 30px #100c2059;pointer-events:none;animation:_ngcontent-%COMP%_tip-in .12s ease}.tooltip[_ngcontent-%COMP%]:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:6px solid transparent;border-top-color:#26203a}.tooltip.place-bottom[_ngcontent-%COMP%]{transform:translate(-50%)}.tooltip.place-bottom[_ngcontent-%COMP%]:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:#26203a}@keyframes _ngcontent-%COMP%_tip-in{0%{opacity:0}to{opacity:1}}.info-i[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:14px;height:14px}.info-i.sm[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:12px;height:12px}.score-card-slot[_ngcontent-%COMP%]{flex:none}.score-card[_ngcontent-%COMP%]{padding:22px 15px;background:#eff6ff;border-color:var(--tx-border);box-shadow:none;overflow:visible}.score-card-full-hidden[_ngcontent-%COMP%]{display:none}.score-card-collapsed[_ngcontent-%COMP%]{display:none;flex:none}.score-card-collapsed.score-card-collapsed-visible[_ngcontent-%COMP%]{display:block;position:sticky;top:-18px;z-index:6;padding:12px 16px;background:#eff6ff;border-color:var(--tx-border);box-shadow:0 4px 12px #0f172a14;border-radius:0!important;width:452px;transform:translate(-19px)}.score-card-collapsed.score-card-collapsed-visible[_ngcontent-%COMP%] .score-card-compact[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:12px}.score-compact-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:8px;min-width:0}.score-compact-num[_ngcontent-%COMP%]{font-size:36px;font-weight:700;line-height:1;color:var(--text);flex:none}.score-compact-label[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--text);white-space:nowrap;text-transform:capitalize}.score-compact-pill[_ngcontent-%COMP%]{flex:none;margin:0;font-size:13px;padding:6px 12px}.score-label[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--text);text-transform:capitalize}.score-top[_ngcontent-%COMP%]{display:flex;gap:18px;align-items:stretch}.score-figure[_ngcontent-%COMP%]{flex:none;display:flex;flex-direction:column;align-items:flex-start;min-width:132px}.score-num-row[_ngcontent-%COMP%]{display:flex;align-items:flex-end;
13gap:6px;margin:4px 0 14px}.score-num[_ngcontent-%COMP%]{font-size:86px;font-weight:600;line-height:.9;color:var(--text)}.score-num-row[_ngcontent-%COMP%] .info-i[_ngcontent-%COMP%]{margin-bottom:3px;width:18px;height:18px;justify-content:center;align-content:center}.verdict-pill[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px;padding:7px 14px;background:#fff;border-radius:999px;box-shadow:var(--shadow-sm);font-weight:600;font-size:14px;color:var(--text)}.pill-dot[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:50%;flex:none}.score-desc[_ngcontent-%COMP%]{margin:0;padding-left:18px;font-size:13px;line-height:1.6;color:var(--tx-body);position:relative}.score-desc[_ngcontent-%COMP%]:before{content:"";position:absolute;width:1px;height:80%;left:0;top:10%;background-color:#ced5de}.scale[_ngcontent-%COMP%]{position:relative;margin-top:30px;overflow:visible}.scale-bar[_ngcontent-%COMP%]{position:relative;height:8px;border-radius:999px;background:linear-gradient(90deg,#1e40af,#3b82f6 22%,#94a3b8 50%,#e08600 76%,#e5484d)}.scale-tri-anchor[_ngcontent-%COMP%]{position:absolute;top:-21px;transform:translate(-50%);z-index:4;transition:left .5s ease}.scale-flag-anchor[_ngcontent-%COMP%]{position:absolute;top:-21px;display:flex;align-items:center;min-height:10px;transform:translate(10px);z-index:3;transition:left .5s ease,transform .5s ease}.scale-flag-anchor.scale-flag-pos-left[_ngcontent-%COMP%], .scale-flag-anchor.scale-flag-pos-center[_ngcontent-%COMP%]{transform:translate(10px)}.scale-flag-anchor.scale-flag-pos-right[_ngcontent-%COMP%]{transform:translate(calc(-100% - 10px))}.scale-flag[_ngcontent-%COMP%]{font-size:12px;font-weight:700;color:var(--text);white-space:nowrap}.scale-tri[_ngcontent-%COMP%]{flex:none;width:0;height:0;border-left:7px solid transparent;border-right:7px solid transparent;border-top:10px solid var(--text)}.scale-tri.custom-tooltip[_ngcontent-%COMP%]{position:relative;display:block;border-radius:0;justify-content:flex-start;cursor:pointer;outline:none;top:8px}.scale-tri.custom-tooltip[_ngcontent-%COMP%]:hover .custom-tooltip-content[_ngcontent-%COMP%], .scale-tri.custom-tooltip[_ngcontent-%COMP%]:focus-within .custom-tooltip-content[_ngcontent-%COMP%], .scale-tri.custom-tooltip[_ngcontent-%COMP%]:focus-visible .custom-tooltip-content[_ngcontent-%COMP%]{opacity:1;visibility:visible;display:block}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip[_ngcontent-%COMP%]{z-index:10;white-space:normal;word-break:break-word;top:auto;bottom:30px}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip[_ngcontent-%COMP%]:after{top:auto;bottom:-15px;border-top:8px solid var(--tx-grey);border-bottom:8px solid transparent}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-center[_ngcontent-%COMP%]{left:50%;transform:translate(-50%)}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-center[_ngcontent-%COMP%]:after{left:50%;right:auto;transform:translate(-50%)}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-left[_ngcontent-%COMP%]{left:0;transform:translate(0)}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-left[_ngcontent-%COMP%]:after{left:7px;right:auto;transform:none}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-right[_ngcontent-%COMP%]{left:auto;right:0;transform:translate(15px)}.scale-tri.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.scale-marker-tooltip.scale-marker-tooltip-right[_ngcontent-%COMP%]:after{left:auto;right:7px;transform:none}.scale-knob[_ngcontent-%COMP%]{position:absolute;top:4px;transform:translate(-50%,-50%);width:6px;height:15px;background:#fff;border:2px solid #334155;border-radius:4px;transition:left .5s ease;z-index:2}.scale-axis[_ngcontent-%COMP%]{display:flex;justify-content:space-between;font-size:14px;color:var(--tx-grey);margin-top:8px;font-weight:700}.scale-axis[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;gap:8px}.scale-mid[_ngcontent-%COMP%]{color:#647087;font-size:12px}.dist-block[_ngcontent-%COMP%]{padding:0 4px}.section-head[_ngcontent-%COMP%]{margin:15px 0 4px;font-size:16px;font-weight:600;line-height:1.2;color:var(--text);font-family:Open Sans}.section-sub[_ngcontent-%COMP%]{margin:0 0 10px;font-size:13px;line-height:1.5;color:var(--tx-body)}.dist[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;padding:16px 0 24px;border-bottom:1px solid var(--tx-border)}.dist-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px}.dist-label[_ngcontent-%COMP%]{flex:none;width:140px;
13display:flex;align-items:center;gap:5px;font-size:14px;font-weight:600;color:var(--tx-grey)}.dist-track[_ngcontent-%COMP%]{flex:1;height:12px;background:#f3f4f6;border-radius:999px;overflow:hidden;min-width:0}.dist-fill[_ngcontent-%COMP%]{display:block;height:100%;border-radius:999px;min-width:3px;background-color:var(--band);transition:width .5s ease}.dist-fill.hatch[_ngcontent-%COMP%]{background-image:repeating-linear-gradient(45deg,var(--band),var(--band) 4px,rgba(255,255,255,.45) 4px,rgba(255,255,255,.45) 8px)}.dist-val[_ngcontent-%COMP%]{flex:none;width:92px;text-align:right;font-size:13px;color:var(--tx-grey)}.dist-val[_ngcontent-%COMP%] b[_ngcontent-%COMP%]{font-weight:700;color:var(--text)}.not-scored[_ngcontent-%COMP%]{border:1.2px dashed #64748B;border-radius:8px;padding:12px;background:#fff;position:relative}.ns-head[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;height:22px;font-size:11px;font-weight:700;padding:2px 10px;border-radius:999px;border:1px solid #64748B;margin-bottom:8px;position:absolute;top:-11px;left:15px;background-color:#fff!important}.ns-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px;max-height:132px;overflow-y:auto}.ns-item[_ngcontent-%COMP%]{flex:none;font-size:12px;line-height:1.4;color:var(--tx-body);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.matches[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:10px}.matches-head[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between}.mh-title[_ngcontent-%COMP%]{font-size:15px;font-weight:600;color:var(--text);display:flex;align-items:center;gap:10px}.mh-right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px}.count[_ngcontent-%COMP%]{background:var(--surface);border:1px solid var(--tx-border);color:var(--tx-grey);border-radius:999px;padding:2px 9px;font-size:12px;font-weight:600}.filter-wrap[_ngcontent-%COMP%]{position:relative}.filter-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:8px;border:1px solid var(--tx-border);background:var(--surface);color:var(--tx-grey);cursor:pointer;transition:all .15s ease}.filter-btn[_ngcontent-%COMP%]:hover{color:var(--text);border-color:var(--text-faint)}.filter-btn.on[_ngcontent-%COMP%]{color:#7a28a0;border-color:#7a28a0;background:#7a28a014}.filter-menu[_ngcontent-%COMP%]{position:absolute;top:38px;right:0;z-index:20;width:196px;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-lg);padding:8px}.filter-menu.filter-menu-up[_ngcontent-%COMP%]{top:-260px}.fm-head[_ngcontent-%COMP%]{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--tx-grey);padding:4px 8px 8px}.fm-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:7px 8px;border:none;background:transparent;border-radius:8px;font-size:13px;font-weight:500;color:var(--text);cursor:pointer}.fm-item[_ngcontent-%COMP%]:hover{background:var(--surface-2)}.fm-item.off[_ngcontent-%COMP%]{color:var(--text-faint)}.fm-check[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border-radius:4px;border:1.5px solid var(--border-strong);color:#7a28a0;flex:none}.fm-item[_ngcontent-%COMP%]:not(.off) .fm-check[_ngcontent-%COMP%]{border-color:#7a28a0;background:#7a28a014}.fm-dot[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;flex:none}.matches-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px}.match[_ngcontent-%COMP%]{text-align:left;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:16px 20px;cursor:pointer;box-shadow:0 1px 3px #0f172a0f;transition:border-color .15s ease,box-shadow .15s ease,background .15s ease}.match[_ngcontent-%COMP%]:hover{box-shadow:0 2px 6px #0f172a14}.match.active[_ngcontent-%COMP%]{background:#f8f4ff;border-color:#7a28a0;box-shadow:0 0 0 1px #7a28a0}.match-head[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;margin-bottom:10px}.match-dot[_ngcontent-%COMP%]{width:8px;height:8px;border-radius:50%;flex-shrink:0}.match-label[_ngcontent-%COMP%]{font-size:14px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;line-height:1}.match-text[_ngcontent-%COMP%]{font-size:14px;line-height:1.5;color:#475569;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.matches-empty[_ngcontent-%COMP%]{padding:24px;text-align:center;color:var(--text-faint);font-size:13px}.state-center[_ngcontent-%COMP%]{flex:1;display:flex;align-items:center;justify-content:center}.state-card[_ngcontent-%COMP%]{text-align:center;background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:40px 48px;box-shadow:var(--shadow-sm);max-width:420px}.state-card[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:18px 0 8px;font-size:18px}.state-card[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0 0 4px;color:var(--tx-grey);font-size:14px;line-height:1.5}.state-card.error[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{color:var(--ai)}.state-card.error[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]{margin-top:18px}.spinner[_ngcontent-%COMP%]{width:42px;height:42px;margin:0 auto;border:4px solid var(--border);border-top-color:var(--tx-btn-color);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}@media (max-width: 1000px){.sidebar[_ngcontent-%COMP%]{width:380px}.tb-file[_ngcontent-%COMP%]{max-width:160px}
13.float-controls[_ngcontent-%COMP%]{left:max(430px,100% - 380px - 16px - 300px)}}@media (max-width: 820px){.mobile-tabs[_ngcontent-%COMP%]{display:flex}.toolbar[_ngcontent-%COMP%]{padding:10px 14px;gap:10px;flex-wrap:wrap}.tb-heading[_ngcontent-%COMP%]{font-size:15px}.tb-meta[_ngcontent-%COMP%]{font-size:11px;gap:4px}.tb-file[_ngcontent-%COMP%]{max-width:130px}.btn[_ngcontent-%COMP%]{padding:8px 11px;font-size:13px}.share-btn[_ngcontent-%COMP%] .btn-label[_ngcontent-%COMP%]{display:none}.float-controls[_ngcontent-%COMP%]{position:static;order:3;flex:1 0 100%;width:auto;justify-content:center;top:auto;left:auto;transform:none;margin-top:8px}.body[_ngcontent-%COMP%]{position:relative}.viewer-pane[_ngcontent-%COMP%], .sidebar[_ngcontent-%COMP%]{flex:1 1 100%;width:100%;min-width:0}.sidebar[_ngcontent-%COMP%]{border-left:none;padding:14px}.body[_ngcontent-%COMP%]:not(.tab-report) .sidebar[_ngcontent-%COMP%]{display:none}.body.tab-report[_ngcontent-%COMP%] .viewer-pane[_ngcontent-%COMP%]{display:none}.dist-label[_ngcontent-%COMP%]{width:100px;font-size:12px}.dist-val[_ngcontent-%COMP%]{width:78px}}@media (max-width: 520px){.tb-date[_ngcontent-%COMP%], .dl-btn[_ngcontent-%COMP%] .btn-label[_ngcontent-%COMP%]{display:none}.tb-heading[_ngcontent-%COMP%]{font-size:14px}}.custom-tooltip[_ngcontent-%COMP%]{position:relative;border-radius:50%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer}.custom-tooltip[_ngcontent-%COMP%]:hover .custom-tooltip-content[_ngcontent-%COMP%]{opacity:1;visibility:visible;display:block}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content[_ngcontent-%COMP%]{background:var(--tx-grey);z-index:1;border-radius:8px;display:none;color:#fff;min-width:260px;padding:9px;position:absolute;left:50%;transform:translate(-50%);font-size:12px;visibility:hidden;opacity:0;top:30px;line-height:1.4;text-align:center;transition:opacity .5s ease,visibility .5s ease,transform .5s ease}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.text-left[_ngcontent-%COMP%]{text-align:left}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content[_ngcontent-%COMP%]:after{border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid var(--tx-grey);box-shadow:0 4px 10px #111a241a;top:-5px;content:"";height:0;position:absolute;left:50%;transform:translate(-50%);width:0}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-right[_ngcontent-%COMP%]{left:inherit;right:0}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-right[_ngcontent-%COMP%]:after{left:inherit;right:20px}@media (max-width: 500px){.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-right[_ngcontent-%COMP%]{transform:translate(0)}}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-left[_ngcontent-%COMP%]{left:-14px;right:inherit;top:20px;transform:translate(0)}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-left[_ngcontent-%COMP%]:after{left:20px;right:inherit}@media (max-width: 500px){.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-left[_ngcontent-%COMP%]{transform:translate(0)}}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-bottom[_ngcontent-%COMP%]{top:inherit;bottom:30px}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-bottom[_ngcontent-%COMP%]:after{left:20px;right:inherit;top:inherit;bottom:-15px;border-top:8px solid var(--tx-grey);border-bottom:8px solid transparent}@media (max-width: 500px){.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-bottom[_ngcontent-%COMP%]{transform:translate(0)}}.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content.tooltip-center[_ngcontent-%COMP%]:after{left:50%}@media (max-width: 500px){.custom-tooltip[_ngcontent-%COMP%] .custom-tooltip-content[_ngcontent-%COMP%]{padding:8px;font-size:13px;min-width:165px;left:50%;transform:translate(-50%)}}']})}}return o})();var el=[{path:"",component:_r,children:[{path:"",redirectTo:"home",pathMatch:"full"},{path:"home",component:wr,canActivate:[ds]},{path:"report/:id",component:Kr,canActivate:[ds]}]}],Yr=(()=>{class o{static{this.\u0275fac=function(i){return new(i||o)}}static{this.\u0275mod=ni({type:o})}static{this.\u0275inj=si({imports:[cs.forChild(el),cs]})}}return o}
13)();var Kc=(()=>{class o{static{this.\u0275fac=function(i){return new(i||o)}}static{this.\u0275mod=ni({type:o})}static{this.\u0275inj=si({imports:[lr,mr,Yr]})}}return o})();export{Kc as AiCdReportViewerModule};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.