texlite 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +7 -0
- package/OPERATIONS.md +70 -3
- package/README.md +5 -0
- package/README.zh-CN.md +5 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/client/assets/{AdminUsers-Dazar9cj.js → AdminUsers-Buf5ZclR.js} +1 -1
- package/dist/client/assets/{CitationLibraryDialog-VSUiSPgG.js → CitationLibraryDialog-DrKbIlD-.js} +1 -1
- package/dist/client/assets/Dashboard-DLk2j3oq.js +2 -0
- package/dist/client/assets/{GitDialog-C9Loz4Al.js → GitDialog-CTWAU8q6.js} +1 -1
- package/dist/client/assets/{HistoryDialog-3UNN_jhU.js → HistoryDialog-Mo4p8HEg.js} +1 -1
- package/dist/client/assets/LatexEditor-CwvakYva.js +135 -0
- package/dist/client/assets/{PdfPreview-BKhcS-2c.js → PdfPreview-BUpELZd-.js} +1 -1
- package/dist/client/assets/{ProjectIconPickerDialog-BoWMjQVm.js → ProjectIconPickerDialog-BiWSwDdt.js} +1 -1
- package/dist/client/assets/{ProjectNavigationDialogs-CZKTnxrl.js → ProjectNavigationDialogs-CpjkXZTz.js} +1 -1
- package/dist/client/assets/{ProjectSettings-DiOQVJ40.js → ProjectSettings-DoxitHbX.js} +1 -1
- package/dist/client/assets/ProjectWorkspace-iNqXZlsj.js +29 -0
- package/dist/client/assets/{SelectionHistoryDialog-D3dO83lg.js → SelectionHistoryDialog-9FWlc3Rb.js} +1 -1
- package/dist/client/assets/{SystemMetricsDialog-0zCwLtH_.js → SystemMetricsDialog-24kifZO6.js} +1 -1
- package/dist/client/assets/TagManagementDialog-BHIA0vEA.js +1 -0
- package/dist/client/assets/{WordCountDialog-TwpyAP3m.js → WordCountDialog-DFIWvLrP.js} +1 -1
- package/dist/client/assets/check-C3GZh6a1.js +1 -0
- package/dist/client/assets/chevron-left-l1oupvGO.js +1 -0
- package/dist/client/assets/editor-3rgn4IYh.js +14 -0
- package/dist/client/assets/{hard-drive-XHSiS_A7.js → hard-drive-B-NSDVVA.js} +1 -1
- package/dist/client/assets/{index-Cd6-F29b.js → index-CNTGCh7t.js} +1 -1
- package/dist/client/assets/index-CrlfruX_.css +1 -0
- package/dist/client/assets/index-DIM_KiG2.js +12 -0
- package/dist/client/assets/katex-D9PXdmFF.css +1 -0
- package/dist/client/assets/{key-round-C-CXCWnz.js → key-round-BjL9H8-H.js} +1 -1
- package/dist/client/assets/{latexFormatterWorker-DYkYtcFy.js → latexFormatterWorker-BRmsns8a.js} +2 -2
- package/dist/client/assets/{minimize-2-BMDPVaF-.js → minimize-2-DDCq8c49.js} +1 -1
- package/dist/client/assets/{minus-BIa7-KuM.js → minus-DgKZCT9F.js} +1 -1
- package/dist/client/assets/{pdf-BB1XvBIF.js → pdf-DUYcbPMK.js} +1 -1
- package/dist/client/assets/{plus-BKDWy4Ui.js → plus-CezUzSIZ.js} +1 -1
- package/dist/client/assets/{refresh-cw-Bo7-a7-I.js → refresh-cw-CDFNL-qu.js} +1 -1
- package/dist/client/assets/{search-Bz9Ob5mT.js → search-CrDJjHoj.js} +1 -1
- package/dist/client/assets/{sigma-DxlHf9gv.js → sigma-DOcJr7VG.js} +1 -1
- package/dist/client/assets/spellCheck-BgWyesvf.js +1 -0
- package/dist/client/assets/{tags-IMZehjzE.js → tags-BedQ75lh.js} +1 -1
- package/dist/client/assets/{type-DTWpFQNQ.js → type-glZNdzZR.js} +1 -1
- package/dist/client/assets/{user-plus--aVpd8K6.js → user-plus-gQ6q5Nom.js} +1 -1
- package/dist/client/assets/{x-Tbo3aA0J.js → x-CSzFikn2.js} +1 -1
- package/dist/client/index.html +6 -4
- package/dist/server/app.js +130 -83
- package/dist/server/cli.js +4 -2
- package/dist/server/compileArtifacts.js +3 -2
- package/dist/server/config.js +27 -0
- package/dist/server/index.js +4 -2
- package/dist/server/instanceLock.js +4 -2
- package/dist/server/latexCompletion.js +126 -63
- package/dist/server/latexDocumentGraph.js +106 -0
- package/dist/server/latexSpellMask.js +3 -4
- package/dist/server/pm2.js +3 -2
- package/dist/server/projectReferences.js +109 -0
- package/dist/server/routes/auth.js +5 -2
- package/dist/server/routes/compile.js +2 -2
- package/dist/server/routes/projectFiles.js +12 -3
- package/dist/server/routes/projectReferences.js +36 -0
- package/dist/server/routes/projects.js +5 -0
- package/dist/server/routes/system.js +1 -0
- package/dist/server/zip.js +2 -16
- package/dist/shared/basePath.js +44 -0
- package/dist/shared/bibtexReferences.js +135 -0
- package/dist/shared/latexCommandSnippets.js +91 -0
- package/dist/shared/latexDependencies.js +71 -0
- package/dist/shared/latexLiterals.js +215 -0
- package/dist/shared/latexReferenceCommands.js +75 -0
- package/dist/shared/latexReferences.js +193 -0
- package/dist/shared/latexRoot.js +21 -0
- package/dist/shared/latexScanner.js +183 -0
- package/dist/shared/writingChecks.js +4 -0
- package/package.json +11 -4
- package/texlite.config.example.json +2 -4
- package/dist/client/assets/Dashboard-CoE5ESfb.js +0 -2
- package/dist/client/assets/LatexEditor-Bq76v8sO.js +0 -65
- package/dist/client/assets/ProjectWorkspace-DqLwkGpT.js +0 -27
- package/dist/client/assets/TagManagementDialog-C6KDwtvd.js +0 -1
- package/dist/client/assets/check-sZxOOKtS.js +0 -1
- package/dist/client/assets/chevron-left-32SrOwa5.js +0 -1
- package/dist/client/assets/editor-CiK7TK0p.js +0 -14
- package/dist/client/assets/index-BRr3Kuxh.css +0 -1
- package/dist/client/assets/index-BjzELSQ-.js +0 -12
- package/dist/client/assets/katex-CEK31ho9.css +0 -1
- package/dist/client/assets/spellCheck-BfZEnpwY.js +0 -1
|
@@ -52,4 +52,4 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
52
52
|
`)}`,this.#l();const c=new Range;let d=Math.sumPrecise(l.map(f=>f.length));for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(d<=p){c.setStart(f,d),c.setEnd(f,d);break}d-=p}n.removeAllRanges(),n.addRange(c)}#l(){if(this.editorDiv.replaceChildren(),!!this.#t)for(const t of this.#t.split(`
|
|
53
53
|
`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#d(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=nt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof Di){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:h,popupRef:c,richText:d,contentsObj:f,creationDate:p,modificationDate:g},textContent:m,textPosition:b,parent:{page:{pageNumber:y}}}=t;if(!m?.length)return null;i=t={annotationType:R.FREETEXT,color:Array.from(a),fontSize:r,value:m.join(`
|
|
54
54
|
`),position:b,pageIndex:y-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,popupRef:c,comment:f?.str||null,richText:d,creationDate:p,modificationDate:g}}const n=await super.deserialize(t,e,s);return n.#i=t.fontSize,n.color=C.makeHexColor(...t.color),n.#t=nt.#d(t.value),n._initialData=i,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=P._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});return this.addComment(s),t?(s.isCopy=!0,s):this.annotationElementId&&!this.#p(s)?null:(s.id=this.annotationElementId,s)}#p(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:s}=e;s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(const i of this.#t.split(`
|
|
55
|
-
`)){const n=document.createElement("div");n.append(i?document.createTextNode(i):document.createElement("br")),e.append(n)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class T{static PRECISION=1e-4;toSVGPath(){G("Abstract method `toSVGPath` must be implemented.")}get box(){G("Abstract getter `box` must be implemented.")}serialize(t,e){G("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}class Ht{#t;#e=[];#s;#i;#n=[];#a=new Float32Array(18);#r;#o;#h;#l;#u;#d;#p=[];static#m=8;static#g=2;static#c=Ht.#m+Ht.#g;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#i=r,this.#a.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#l=Ht.#m*i,this.#h=Ht.#c*i,this.#u=i,this.#p.push(t,e)}isEmpty(){return isNaN(this.#a[8])}#f(){const t=this.#a.subarray(4,6),e=this.#a.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#o=e;const[s,i,n,r]=this.#t;let[a,o,l,h]=this.#a.subarray(8,12);const c=t-l,d=e-h,f=Math.hypot(c,d);if(f<this.#h)return!1;const p=f-this.#l,g=p/f,m=g*c,b=g*d;let y=a,A=o;a=l,o=h,l+=m,h+=b,this.#p?.push(t,e);const w=-b/p,v=m/p,S=w*this.#d,x=v*this.#d;return this.#a.set(this.#a.subarray(2,8),0),this.#a.set([l+S,h+x],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([l-S,h-x],16),isNaN(this.#a[6])?(this.#n.length===0&&(this.#a.set([a+S,o+x],2),this.#n.push(NaN,NaN,NaN,NaN,(a+S-s)/n,(o+x-i)/r),this.#a.set([a-S,o-x],14),this.#e.push(NaN,NaN,NaN,NaN,(a-S-s)/n,(o-x-i)/r)),this.#a.set([y,A,a,o,l,h],6),!this.isEmpty()):(this.#a.set([y,A,a,o,l,h],6),Math.abs(Math.atan2(A-o,y-a)-Math.atan2(b,m))<Math.PI/2?([a,o,l,h]=this.#a.subarray(2,6),this.#n.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/n,((o+h)/2-i)/r),[a,o,y,A]=this.#a.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-s)/n,((A+o)/2-i)/r),!0):([y,A,a,o,l,h]=this.#a.subarray(0,6),this.#n.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),[l,h,a,o,y,A]=this.#a.subarray(12,18),this.#e.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#n,e=this.#e;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#y();const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#A(s),s.join(" ")}#y(){const[t,e,s,i]=this.#t,[n,r,a,o]=this.#f();return`M${(this.#a[2]-t)/s} ${(this.#a[3]-e)/i} L${(this.#a[4]-t)/s} ${(this.#a[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#a[16]-t)/s} ${(this.#a[17]-e)/i} L${(this.#a[14]-t)/s} ${(this.#a[15]-e)/i} Z`}#A(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){const[e,s,i,n]=this.#t,r=this.#a.subarray(4,6),a=this.#a.subarray(16,18),[o,l,h,c]=this.#f();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Ni(t,e,s,i,n,r)}getOutlines(){const t=this.#n,e=this.#e,s=this.#a,[i,n,r,a]=this.#t,o=new Float32Array((this.#p?.length??0)+2);for(let c=0,d=o.length-2;c<d;c+=2)o[c]=(this.#p[c]-i)/r,o[c+1]=(this.#p[c+1]-n)/a;if(o[o.length-2]=(this.#r-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#S(o);const l=new Float32Array(this.#n.length+24+this.#e.length);let h=t.length;for(let c=0;c<h;c+=2){if(isNaN(t[c])){l[c]=l[c+1]=NaN;continue}l[c]=t[c],l[c+1]=t[c+1]}h=this.#v(l,h);for(let c=e.length-6;c>=6;c-=6)for(let d=0;d<6;d+=2){if(isNaN(e[c+d])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[c+d],l[h+1]=e[c+d+1],h+=2}return this.#E(l,h),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#S(t){const e=this.#a,[s,i,n,r]=this.#t,[a,o,l,h]=this.#f(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(c,t,this.#t,this.#u,this.#s,this.#i)}#E(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#v(t,e){const s=this.#a.subarray(4,6),i=this.#a.subarray(16,18),[n,r,a,o]=this.#t,[l,h,c,d]=this.#f();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}}class Ni extends T{#t;#e=new Float32Array(4);#s;#i;#n;#a;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#n=e,this.#t=s,this.#a=i,this.#s=n,this.#i=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);const[a,o,l,h]=this.#e;for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,l;switch(n){case 0:o=T._rescale(this.#r,t,i,r,-a),l=T._rescale(this.#n,t,i,r,-a);break;case 90:o=T._rescaleAndSwap(this.#r,t,e,r,a),l=T._rescaleAndSwap(this.#n,t,e,r,a);break;case 180:o=T._rescale(this.#r,s,e,-r,a),l=T._rescale(this.#n,s,e,-r,a);break;case 270:o=T._rescaleAndSwap(this.#r,s,i,-r,-a),l=T._rescaleAndSwap(this.#n,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){const e=this.#r;let s=e[4],i=e[5];const n=[s,i,s,i];let r=s,a=i,o=s,l=i;const h=t?Math.max:Math.min,c=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){const g=e[f+4],m=e[f+5];isNaN(e[f])?(C.pointBoundingBox(g,m,n),a>m?(r=g,a=m):a===m&&(r=h(r,g)),l<m?(o=g,l=m):l===m&&(o=h(o,g))):(c.set(Mt,0),C.bezierBoundingBox(s,i,...e.slice(f,f+6),c),C.rectBoundingBox(...c,n),a>c[1]?(r=c[0],a=c[1]):a===c[1]&&(r=h(r,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),s=g,i=m}const d=this.#e;d[0]=n[0]-this.#s,d[1]=n[1]-this.#s,d[2]=n[2]-n[0]+2*this.#s,d[3]=n[3]-n[1]+2*this.#s,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,n,r=0){return new Ht(t,e,s,i,n,r)}getNewOutline(t,e){const[s,i,n,r]=this.#e,[a,o,l,h]=this.#t,c=n*l,d=r*h,f=s*l+a,p=i*h+o,g=this.newOutliner({x:this.#n[0]*c+f,y:this.#n[1]*d+p},this.#t,this.#a,t,this.#i,e??this.#s);for(let m=2;m<this.#n.length;m+=2)g.add({x:this.#n[m]*c+f,y:this.#n[m+1]*d+p});return g.getOutlines()}}class ms{#t;#e;#s;#i=[];#n=[];constructor(t,e=0,s=0,i=!0){const n=Mt.slice(),r=10**-4;for(const{x:g,y:m,width:b,height:y}of t){const A=Math.floor((g-e)/r)*r,w=Math.ceil((g+b+e)/r)*r,v=Math.floor((m-e)/r)*r,S=Math.ceil((m+y+e)/r)*r,x=[A,v,S,!0],E=[w,v,S,!1];this.#i.push(x,E),C.rectBoundingBox(A,v,w,S,n)}const a=n[2]-n[0]+2*s,o=n[3]-n[1]+2*s,l=n[0]-s,h=n[1]-s;let c=i?-1/0:1/0,d=1/0;const f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(const g of this.#i){const[m,b,y,A]=g;!A&&i?b<d?(d=b,c=m):b===d&&(c=Math.max(c,m)):A&&!i&&(b<d?(d=b,c=m):b===d&&(c=Math.min(c,m))),g[0]=(m-l)/a,g[1]=(b-h)/o,g[2]=(y-h)/o}this.#t=new Float32Array([l,h,a,o]),this.#e=[c,d],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#i)e[3]?(t.push(...this.#l(e)),this.#o(e)):(this.#h(e),t.push(...this.#l(e)));return this.#a(t)}#a(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,l,h,c]=r;s.delete(r);let d=a,f=o;for(n=[a,l],i.push(n);;){let p;if(s.has(h))p=h;else if(s.has(c))p=c;else break;s.delete(p),[a,o,l,h,c]=p,d!==a&&(n.push(d,f,a,f===o?o:l),d=a),f=f===o?l:o}n.push(d,f)}return new qr(i,this.#t,this.#e,this.#s)}#r(t){const e=this.#n;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#o([,t,e]){const s=this.#r(t);this.#n.splice(s,0,[t,e])}#h([,t,e]){const s=this.#r(t);for(let i=s;i<this.#n.length;i++){const[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}}#l(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#r(i);for(let a=0;a<r;a++){const[o,l]=this.#n[a];for(let h=0,c=n.length;h<c;h++){const[,d,f]=n[h];if(!(l<=d||f<=o)){if(d>=o){if(f>l)n[h][1]=l;else{if(c===1)return[];n.splice(h,1),h--,c--}continue}n[h][2]=o,f>l&&n.push([e,l,f])}}}return n}}class qr extends T{#t;#e;constructor(t,e,s,i){super(),this.#e=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-e;for(const l of this.#e){const h=new Array(l.length);for(let c=0;c<l.length;c+=2)h[c]=t+l[c]*a,h[c+1]=i-l[c+1]*o;r.push(h)}return r}get box(){return this.#t}}class bs extends Ht{newFreeDrawOutline(t,e,s,i,n,r){return new Qr(t,e,s,i,n,r)}}class Qr extends Ni{newOutliner(t,e,s,i,n,r=0){return new bs(t,e,s,i,n,r)}}class tt extends P{#t=null;#e=0;#s;#i=null;#n=null;#a=null;#r=null;#o=0;#h=null;#l=null;#u=null;#d=!1;#p=null;#m=null;#g=null;#c="";#f;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=R.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=tt.prototype;return D(this,"_keyboardManager",new gt([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||tt._defaultColor,this.#f=t.thickness||tt._defaultThickness,this.opacity=t.opacity||tt._defaultOpacity,this.#s=t.boxes||null,this.#y=t.methodOfCreation||"",this.#c=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#d=!0,this.#b(t),this.#x()):this.#s&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#o=t.focusOffset,this.#A(),this.#x(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#f,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#A(){const t=new ms(this.#s,.001);this.#l=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;const e=new ms(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#a=e.getOutlines();const{firstPoint:s}=this.#l;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height];const{lastPoint:i}=this.#a;this.#m=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#b({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#l=t;const i=1.5;if(this.#a=t.getNewOutline(this.#f/2+i,.0025),e>=0)this.#u=e,this.#i=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#g=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0);else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:tt.#T(this.#l.box,(c-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#g,{bbox:tt.#T(this.#a.box,c),path:{d:this.#a.toSVGPath()}})}const[n,r,a,o]=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{const[c,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/c,this.height=o*c/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{const[c,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/c,this.height=o*c/d;break}}const{firstPoint:l}=t;this.#p=[(l[0]-n)/a,(l[1]-r)/o];const{lastPoint:h}=this.#a;this.#m=[(h[0]-n)/a,(h[1]-r)/o]}static initialize(t,e){P.initialize(t,e),tt._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:tt._defaultColor=e;break;case B.HIGHLIGHT_THICKNESS:tt._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#m}get commentButtonPosition(){return this.#p}updateParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:this.#S(e);break;case B.HIGHLIGHT_THICKNESS:this.#E(e);break}}static get defaultPropertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,tt._defaultColor],[B.HIGHLIGHT_THICKNESS,tt._defaultThickness]]}get propertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,this.color||tt._defaultColor],[B.HIGHLIGHT_THICKNESS,this.#f||tt._defaultThickness],[B.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#n?.updateColor(this.color),super.onUpdatedColor()}#S(t){const e=(n,r)=>{this.color=n,this.opacity=r,this.onUpdatedColor()},s=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,t,tt._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#E(t){const e=this.#f,s=i=>{this.#f=i,this.#v(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#n=new At({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#k())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#C(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#x(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#C():t&&(this.#x(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#v(t){this.#d&&(this.#b({highlightOutlines:this.#l.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#C(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#g),this.#g=null)}#x(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#i}=t.drawLayer.draw({bbox:this.#l.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#g=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d),this.#h&&(this.#h.style.clipPath=this.#i))}static#T([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){const{drawLayer:e}=this.parent;let s;this.#d?(t=(t-this.rotation+360)%360,s=tt.#T(this.#l.box,t)):s=tt.#T([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#g,{bbox:tt.#T(this.#a.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#c&&(t.setAttribute("aria-label",this.#c),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#P.bind(this),{signal:this._uiManager._signal});const e=this.#h=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#i,this.setDims(),bi(this,this.#h,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1}})}#P(t){tt._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#M(!0);break;case 1:case 3:this.#M(!1);break}}#M(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#o)}select(){super.select(),this.#g&&this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#g&&(this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{selected:!1}}),this.#d||this.#M(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#g,{rootClass:{hidden:!t}}))}#k(){return this.#d?this.rotation:0}#F(){if(this.#d)return null;const[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=this.#s,r=new Float32Array(n.length*8);let a=0;for(const{x:o,y:l,width:h,height:c}of n){const d=o*t+s,f=(1-l)*e+i;r[a]=r[a+4]=d,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=d+h*t,r[a+5]=r[a+7]=f-c*e,a+=8}return r}#L(t){return this.#l.serialize(t,this.#k())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:l}=s.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=f=>{h.abort(),this.#O(t,f)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Q,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",vt,{signal:c}),s.addEventListener("pointermove",this.#D.bind(this,t),{signal:c}),this._freeHighlight=new bs({x:i,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.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#D(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#O(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,s){let i=null;if(t instanceof Li){const{data:{quadPoints:g,rect:m,rotation:b,id:y,color:A,opacity:w,popupRef:v,richText:S,contentsObj:x,creationDate:E,modificationDate:_},parent:{page:{pageNumber:k}}}=t;i=t={annotationType:R.HIGHLIGHT,color:Array.from(A),opacity:w,quadPoints:g,boxes:null,pageIndex:k-1,rect:m.slice(0),rotation:b,annotationElementId:y,id:y,deleted:!1,popupRef:v,richText:S,comment:x?.str||null,creationDate:E,modificationDate:_}}else if(t instanceof Is){const{data:{inkLists:g,rect:m,rotation:b,id:y,color:A,borderStyle:{rawWidth:w},popupRef:v,richText:S,contentsObj:x,creationDate:E,modificationDate:_},parent:{page:{pageNumber:k}}}=t;i=t={annotationType:R.HIGHLIGHT,color:Array.from(A),thickness:w,inkLists:g,boxes:null,pageIndex:k-1,rect:m.slice(0),rotation:b,annotationElementId:y,id:y,deleted:!1,popupRef:v,richText:S,comment:x?.str||null,creationDate:E,modificationDate:_}}const{color:n,quadPoints:r,inkLists:a,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,s);h.color=C.makeHexColor(...n),h.opacity=l||1,a&&(h.#f=t.thickness),h._initialData=i,t.comment&&h.setCommentData(t);const[c,d]=h.pageDimensions,[f,p]=h.pageTranslation;if(r){const g=h.#s=[];for(let m=0;m<r.length;m+=8)g.push({x:(r[m]-f)/c,y:1-(r[m+1]-p)/d,width:(r[m+2]-r[m])/c,height:(r[m+1]-r[m+5])/d});h.#A(),h.#x(),h.rotate(h.rotation)}else if(a||o){h.#d=!0;const g=(a||o.points)[0],m={x:g[0]-f,y:d-(g[1]-p)},b=new bs(m,[0,0,c,d],1,h.#f/2,!0,.001);for(let w=0,v=g.length;w<v;w+=2)m.x=g[w]-f,m.y=d-(g[w+1]-p),b.add(m);const{id:y,clipPathId:A}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:b.toSVGPath()}},!0,!0);h.#b({highlightOutlines:b.getOutlines(),highlightId:y,clipPathId:A}),h.#x(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=P._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(t);return Object.assign(s,{color:e,opacity:this.opacity,thickness:this.#f,quadPoints:this.#F(),outlines:this.#L(s.rect)}),this.addComment(s),this.annotationElementId&&!this.#N(s)?null:(s.id=this.annotationElementId,s)}#N(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Bi{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){G("Not implemented")}}class $ extends P{#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#n=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#a(t),this.#h())}#a({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#r(t,this.parent),this.#d(t.box)}#r(t,e){const{id:s}=e.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,n]of Object.entries(e))s.has(i)?Object.assign(t[i],n):t[i]=n;return t}static getDefaultDrawingOptions(t){G("Not implemented")}static get typesMap(){G("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&($.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,n=i[e],r=a=>{i.updateProperty(e,a);const o=this.#t.updateProperty(e,a);o&&this.#d(o),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){const s=this.constructor.typesMap.get(this.colorType),i=this.constructor.typesMap.get(this.opacityType),n=this._drawingOptions,r=n[s],a=n[i],o=(l,h)=>{n.updateProperty(s,l),n.updateProperty(i,h),this.#t.updateProperty(s,l),this.#t.updateProperty(i,h),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,r,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#u()),{bbox:this.#p()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#u()),{bbox:this.#p()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#p()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#p()}))}_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.#o(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#h(),this.#d(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#o()):t&&(this._uiManager.addShouldRescale(this),this.#h(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#o(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#h(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.#r(this.#t,t)}}#l([t,e,s,i]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#u(){const{x:t,y:e,width:s,height:i,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#d(t){[this.x,this.y,this.width,this.height]=this.#l(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#p(){const{x:t,y:e,width:s,height:i,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((n*4+r)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(a/o),i*(o/a),s*(a/o)];case 5:return[1-e,t,s*(a/o),i*(o/a)];case 6:return[1-t-i*(o/a),1-e,i*(o/a),s*(a/o)];case 7:return[e-s*(a/o),1-t-i*(o/a),s*(a/o),i*(o/a)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/a),e,i*(o/a),s*(a/o)];case 13:return[1-e-s*(a/o),t-i*(o/a),s*(a/o),i*(o/a)];case 14:return[1-t,1-e-s*(a/o),i*(o/a),s*(a/o)];case 15:return[e,1-t,s*(a/o),i*(o/a)];default:return[t,e,s,i]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#p()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");return s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,n){G("Not implemented")}static startDrawing(t,e,s,i){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=i;if(j.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:c,height:d}=n.getBoundingClientRect(),f=$.#i=new AbortController,p=t.combinedSignal(f);if(j.setPointer(l,o),window.addEventListener("pointerup",g=>{j.isSamePointerIdOrRemove(g.pointerId)&&this._endDraw(g)},{signal:p}),window.addEventListener("pointercancel",g=>{j.isSamePointerIdOrRemove(g.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",g=>{j.isSamePointerType(g.pointerType)&&(j.initializeAndAddPointerId(g.pointerId),$.#s.isCancellable()&&($.#s.removeLastElement(),$.#s.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",vt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",g=>{j.isSameTimeStamp(g.timeStamp)&&Q(g)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),$.#s){t.drawLayer.updateProperties(this._currentDrawId,$.#s.startNew(r,a,c,d,h));return}e.updateUIForDefaultProperties(this),$.#s=this.createDrawerInstance(r,a,c,d,h),$.#n=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties($.#n.toSVGProperties(),$.#s.defaultSVGProperties),!0,!1)}static _drawMove(t){if(j.isSameTimeStamp(t.timeStamp),!$.#s)return;const{offsetX:e,offsetY:s,pointerId:i}=t;if(j.isSamePointerId(i)){if(j.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#s.add(e,s)),j.setTimeStamp(t.timeStamp),Q(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,$.#s=null,$.#n=null,j.clearTimeStamp()),$.#i&&($.#i.abort(),$.#i=null,j.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,$.#s.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const s=$.#s,i=this._currentDrawId,n=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:B.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(B.DRAW_STEP),!$.#s.isEmpty()){const{pageDimensions:[s,i],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#s.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:$.#n,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r){G("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,i,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#a({drawOutlines:o}),l.#h(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return this.#t.serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Jr{#t=new Float64Array(6);#e;#s;#i;#n;#a;#r="";#o=0;#h=new be;#l;#u;constructor(t,e,s,i,n,r){this.#l=s,this.#u=i,this.#i=n,this.#n=r,[t,e]=this.#d(t,e);const a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e],this.#s=[{line:a,points:this.#a}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#n=e)}#d(t,e){return T._normalizePoint(t,e,this.#l,this.#u,this.#i)}isEmpty(){return!this.#s?.length}isCancellable(){return this.#a.length<=10}add(t,e){[t,e]=this.#d(t,e);const[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#l*a,this.#u*o)<=2?null:(this.#a.push(t,e),isNaN(s)?(this.#t.set([n,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,i,n,r,t,e],0),this.#e.push(...T.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){this.#l=s,this.#u=i,this.#i=n,[t,e]=this.#d(t,e);const r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e];const a=this.#s.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#s.push({line:r,points:this.#a}),this.#t.set(r,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#s.at(-1)}setLastElement(t){return this.#s?(this.#s.push(t),this.#e=t.line,this.#a=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(t)}removeLastElement(){if(!this.#s)return this.#h.removeLastElement();this.#s.pop(),this.#r="";for(let t=0,e=this.#s.length;t<e;t++){const{line:s,points:i}=this.#s[t];this.#e=s,this.#a=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#r}}}toSVGPath(){const t=T.svgRound(this.#e[4]),e=T.svgRound(this.#e[5]);if(this.#a.length===2)return this.#r=`${this.#r} M ${t} ${e} Z`,this.#r;if(this.#a.length<=6){const i=this.#r.lastIndexOf("M");this.#r=`${this.#r.slice(0,i)} M ${t} ${e}`,this.#o=6}if(this.#a.length===4){const i=T.svgRound(this.#e[10]),n=T.svgRound(this.#e[11]);return this.#r=`${this.#r} L ${i} ${n}`,this.#o=12,this.#r}const s=[];this.#o===0&&(s.push(`M ${t} ${e}`),this.#o=6);for(let i=this.#o,n=this.#e.length;i<n;i+=6){const[r,a,o,l,h,c]=this.#e.slice(i,i+6).map(T.svgRound);s.push(`C${r} ${a} ${o} ${l} ${h} ${c}`)}return this.#r+=s.join(" "),this.#o=this.#e.length,this.#r}getOutlines(t,e,s,i){const n=this.#s.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#s,t,e,s,this.#i,this.#n,i),this.#t=null,this.#e=null,this.#s=null,this.#r=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class be extends T{#t;#e=0;#s;#i;#n;#a;#r;#o;#h;build(t,e,s,i,n,r,a){this.#n=e,this.#a=s,this.#r=i,this.#o=n,this.#h=r,this.#s=a??0,this.#i=t,this.#d()}get thickness(){return this.#h}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#i){if(t.push(`M${T.svgRound(e[4])} ${T.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${T.svgRound(e[10])} ${T.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){const[n,r,a,o,l,h]=e.subarray(s,s+6).map(T.svgRound);t.push(`C${n} ${r} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,s,i],n){const r=[],a=[],[o,l,h,c]=this.#u();let d,f,p,g,m,b,y,A,w;switch(this.#o){case 0:w=T._rescale,d=t,f=e+i,p=s,g=-i,m=t+o*s,b=e+(1-l-c)*i,y=t+(o+h)*s,A=e+(1-l)*i;break;case 90:w=T._rescaleAndSwap,d=t,f=e,p=s,g=i,m=t+l*s,b=e+o*i,y=t+(l+c)*s,A=e+(o+h)*i;break;case 180:w=T._rescale,d=t+s,f=e,p=-s,g=i,m=t+(1-o-h)*s,b=e+l*i,y=t+(1-o)*s,A=e+(l+c)*i;break;case 270:w=T._rescaleAndSwap,d=t+s,f=e+i,p=-s,g=-i,m=t+(1-l-c)*s,b=e+(1-o-h)*i,y=t+(1-l)*s,A=e+(1-o)*i;break}for(const{line:v,points:S}of this.#i)r.push(w(v,d,f,p,g,n?new Array(v.length):null)),a.push(w(S,d,f,p,g,n?new Array(S.length):null));return{lines:r,points:a,rect:[m,b,y,A]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,f,p,g;switch(o){case 0:g=T._rescale,c=-t/s,d=e/i+1,f=1/s,p=-1/i;break;case 90:g=T._rescaleAndSwap,c=-e/i,d=-t/s,f=1/i,p=1/s;break;case 180:g=T._rescale,c=t/s+1,d=-e/i,f=-1/s,p=1/i;break;case 270:g=T._rescaleAndSwap,c=e/i+1,d=t/s+1,f=-1/i,p=-1/s;break}if(!r){r=[];for(const b of a){const y=b.length;if(y===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1]]));continue}if(y===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1],NaN,NaN,NaN,NaN,b[2],b[3]]));continue}const A=new Float32Array(3*(y-2));r.push(A);let[w,v,S,x]=b.subarray(0,4);A.set([NaN,NaN,NaN,NaN,w,v],0);for(let E=4;E<y;E+=2){const _=b[E],k=b[E+1];A.set(T.createBezierPoints(w,v,S,x,_,k),(E-2)*3),[w,v,S,x]=[S,x,_,k]}}}for(let b=0,y=r.length;b<y;b++)h.push({line:g(r[b].map(A=>A??NaN),c,d,f,p),points:g(a[b].map(A=>A??NaN),c,d,f,p)});const m=new this.prototype.constructor;return m.build(h,s,i,1,o,l,n),m}#l(t=this.#h){const e=this.#s+t/2*this.#r;return this.#o%180===0?[e/this.#n,e/this.#a]:[e/this.#a,e/this.#n]}#u(){const[t,e,s,i]=this.#t,[n,r]=this.#l(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){const t=this.#t=Bt.slice();for(const{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)C.pointBoundingBox(i[a],i[a+1],t);continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){const[l,h,c,d,f,p]=i.subarray(a,a+6);C.bezierBoundingBox(n,r,l,h,c,d,f,p,t),n=f,r=p}}const[e,s]=this.#l();t[0]=X(t[0]-e,0,1),t[1]=X(t[1]-s,0,1),t[2]=X(t[2]+e,0,1),t[3]=X(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#p(e):null}#p(t){const[e,s]=this.#l();this.#h=t;const[i,n]=this.#l(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){const[i,n]=this.#l();this.#n=t,this.#a=e,this.#r=s;const[r,a]=this.#l(),o=r-i,l=a-n,h=this.#t;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(T.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${T.svgRound(a)} ${T.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){const[n,r]=this.#l(),[a,o,l,h]=this.#t;if(Math.abs(l-n)<=T.PRECISION||Math.abs(h-r)<=T.PRECISION){const g=t+s/2-(a+l/2),m=e+i/2-(o+h/2);return{path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}const c=(s-2*n)/(l-2*n),d=(i-2*r)/(h-2*r),f=l/s,p=h/i;return{path:{"transform-origin":`${T.svgRound(a)} ${T.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${T.svgRound(n)} ${T.svgRound(r)}) scale(${c} ${d}) translate(${T.svgRound(-n)} ${T.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[n,r]=this.#l(),a=this.#t,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(h-n)<=T.PRECISION||Math.abs(c-r)<=T.PRECISION){const m=t+s/2-(o+h/2),b=e+i/2-(l+c/2);for(const{line:y,points:A}of this.#i)T._translate(y,m,b,y),T._translate(A,m,b,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(s-2*n)/(h-2*n),f=(i-2*r)/(c-2*r),p=-d*(o+n)+t+n,g=-f*(l+r)+e+r;if(d!==1||f!==1||p!==0||g!==0)for(const{line:m,points:b}of this.#i)T._rescale(m,p,g,d,f,m),T._rescale(b,p,g,d,f,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#n===i&&this.#a===n)for(const{line:l,points:h}of this.#i)T._translate(l,a,o,l),T._translate(h,a,o,h);else{const l=this.#n/i,h=this.#a/n;this.#n=i,this.#a=n;for(const{line:c,points:d}of this.#i)T._rescale(c,a,o,l,h,c),T._rescale(d,a,o,l,h,d);r[2]*=l,r[3]*=h}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${T.svgRound(t[0])} ${T.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Xe extends Bi{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:P._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Xe(this._viewParameters);return t.updateAll(this),t}}class Fs extends ${static _type="ink";static _editorType=R.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){P.initialize(t,e),this._defaultDrawingOptions=new Xe(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return D(this,"typesMap",new Map([[B.INK_THICKNESS,"stroke-width"],[B.INK_COLOR,"stroke"],[B.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new Jr(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return be.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof Is){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,opacity:c,borderStyle:{rawWidth:d},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:b},parent:{page:{pageNumber:y}}}=t;i=t={annotationType:R.INK,color:Array.from(h),thickness:d,opacity:c,paths:{points:r},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:b}}const n=await super.deserialize(t,e,s);return n._initialData=i,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new ue(this),[["colorPicker",this._colorPicker]]}get colorType(){return B.INK_COLOR}get colorAndOpacityType(){return B.INK_COLOR_AND_OPACITY}get opacityType(){return B.INK_OPACITY}updateParams(t,e){if(t===B.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===B.INK_COLOR_AND_OPACITY){super.updateDefaultParams(B.INK_COLOR,e.color),super.updateDefaultParams(B.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=Fs.getDefaultDrawingOptions({stroke:C.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:P._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class ys extends be{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Ee=8,se=3;class Kt{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,n,r,a){const o=this.#e(s,i,n,r);for(let l=0;l<8;l++){const h=(-l+o-a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#n(t,e,s,i,n,r,a){const o=this.#e(s,i,n,r);for(let l=0;l<8;l++){const h=(l+o+a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#a(t,e,s,i){const n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*s-1-h]=0;let a=1,o;const l=[];for(let h=1;h<s-1;h++){o=1;for(let c=1;c<e-1;c++){const d=h*e+c,f=r[d];if(f===0)continue;let p=h,g=c;if(f===1&&r[d-1]===0)a+=1,g-=1;else if(f>=1&&r[d+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}const m=[c,h],b=g===c+1,y={isHole:b,points:m,id:a,parent:0};l.push(y);let A;for(const M of l)if(M.id===o){A=M;break}A?A.isHole?y.parent=b?A.parent:o:y.parent=b?o:A.parent:y.parent=b?o:0;const w=this.#i(r,e,h,c,p,g,0);if(w===-1){r[d]=-a,r[d]!==1&&(o=Math.abs(r[d]));continue}let v=this.#s[2*w],S=this.#s[2*w+1];const x=h+v,E=c+S;p=x,g=E;let _=h,k=c;for(;;){const M=this.#n(r,e,_,k,p,g,1);v=this.#s[2*M],S=this.#s[2*M+1];const L=_+v,H=k+S;m.push(H,L);const U=_*e+k;if(r[U+1]===0?r[U]=-a:r[U]===1&&(r[U]=a),L===h&&H===c&&_===x&&k===E){r[d]!==1&&(o=Math.abs(r[d]));break}else p=_,g=k,_=L,k=H}}}return l}static#r(t,e,s,i){if(s-e<=4){for(let x=e;x<s-2;x+=2)i.push(t[x],t[x+1]);return}const n=t[e],r=t[e+1],a=t[s-4]-n,o=t[s-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,f=o/a,p=1/l,g=Math.atan(f),m=Math.cos(g),b=Math.sin(g),y=p*(Math.abs(m)+Math.abs(b)),A=p*(1-y+y**2),w=Math.max(Math.atan(Math.abs(b+m)*A),Math.atan(Math.abs(b-m)*A));let v=0,S=e;for(let x=e+2;x<s-2;x+=2){const E=Math.abs(d-h*t[x+1]+c*t[x]);E>v&&(S=x,v=E)}v>(l*w)**2?(this.#r(t,e,S+2,i),this.#r(t,S,s,i)):i.push(n,r)}static#o(t){const e=[],s=t.length;return this.#r(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#h(t,e,s,i,n,r){const a=new Float32Array(r**2),o=-2*i**2,l=r>>1;for(let g=0;g<r;g++){const m=(g-l)**2;for(let b=0;b<r;b++)a[g*r+b]=Math.exp((m+(b-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let g=0;g<256;g++)h[g]=Math.exp(g**2/c);const d=t.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let m=0;m<e;m++){const b=g*e+m,y=t[b];let A=0,w=0;for(let S=0;S<r;S++){const x=g+S-l;if(!(x<0||x>=s))for(let E=0;E<r;E++){const _=m+E-l;if(_<0||_>=e)continue;const k=t[x*e+_],M=a[S*r+E]*h[Math.abs(k-y)];A+=k*M,w+=M}}const v=f[b]=Math.round(A/w);p[v]++}return[f,p]}static#l(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}static#u(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,n=1/0;for(let a=0,o=s.length;a<o;a++){const l=s[a]=t[a<<2];i=Math.max(i,l),n=Math.min(n,l)}const r=255/(i-n);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-n)*r;return s}static#d(t){let e,s=-1/0,i=-1/0;const n=t.findIndex(o=>o!==0);let r=n,a=n;for(e=n;e<256;e++){const o=t[e];o>s&&(e-r>i&&(i=e-r,a=e-1),s=o,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#p(t){const e=t,{width:s,height:i}=t,{maxDim:n}=this.#t;let r=s,a=i;if(s>n||i>n){let d=s,f=i,p=Math.log2(Math.max(s,i)/n);const g=Math.floor(p);p=p===g?g-1:g;for(let b=0;b<p;b++){r=Math.ceil(d/2),a=Math.ceil(f/2);const y=new OffscreenCanvas(r,a);y.getContext("2d").drawImage(t,0,0,d,f,0,0,r,a),d=r,f=a,t!==e&&t.close(),t=y.transferToImageBitmap()}const m=Math.min(n/r,n/a);r=Math.round(r*m),a=Math.round(a*m)}const l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);const h=l.getImageData(0,0,r,a).data;return[this.#u(h),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=200,d=h.font=`${s} ${i} ${c}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:b,fontBoundingBoxDescent:y,width:A}=h.measureText(t),w=1.5,v=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,A)*w),S=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||c,Math.abs(b)+Math.abs(y)||c)*w);l=new OffscreenCanvas(v,S),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,v,S),h.fillStyle="black",h.fillText(t,v*(w-1)/2,S*(3-w)/2);const x=this.#u(h.getImageData(0,0,v,S).data),E=this.#l(x),_=this.#d(E),k=this.#a(x,v,S,_);return this.processDrawnLines({lines:{curves:k,width:v,height:S},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){const[r,a,o]=this.#p(t),[l,h]=this.#h(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),c=this.#d(h),d=this.#a(l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:a}){i%180!==0&&([e,s]=[s,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],f=Math.min(e/l,s/h),p=f/e,g=f/s,m=[];for(const{points:y}of o){const A=r?this.#o(y):y;if(!A)continue;m.push(A);const w=A.length,v=new Float32Array(w),S=new Float32Array(3*(w===2?2:w-2));if(d.push({line:S,points:v}),w===2){v[0]=A[0]*p,v[1]=A[1]*g,S.set([NaN,NaN,NaN,NaN,v[0],v[1]],0);continue}let[x,E,_,k]=A;x*=p,E*=g,_*=p,k*=g,v.set([x,E,_,k],0),S.set([NaN,NaN,NaN,NaN,x,E],0);for(let M=4;M<w;M+=2){const L=v[M]=A[M]*p,H=v[M+1]=A[M+1]*g;S.set(T.createBezierPoints(x,E,_,k,L,H),(M-2)*3),[x,E,_,k]=[_,k,L,H]}}if(d.length===0)return null;const b=a?new ys:new be;return b.build(d,e,s,1,i,a?0:c,n),{outline:b,newCurves:m,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=1/0,a=-1/0,o=0;for(const y of t){o+=y.length;for(let A=2,w=y.length;A<w;A++){const v=y[A]-y[A-2];r=Math.min(r,v),a=Math.max(a,v)}}let l;r>=-128&&a<=127?l=Int8Array:r>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const h=t.length,c=Ee+se*h,d=new Uint32Array(c);let f=0;d[f++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,d[f++]=0,d[f++]=i,d[f++]=n,d[f++]=e?0:1,d[f++]=Math.max(0,Math.floor(s??0)),d[f++]=h,d[f++]=l.BYTES_PER_ELEMENT;for(const y of t)d[f++]=y.length-2,d[f++]=y[0],d[f++]=y[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const m=l.prototype.constructor;for(const y of t){const A=new m(y.length-2);for(let w=2,v=y.length;w<v;w++)A[w-2]=y[w]-y[w-2];g.write(A)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(const A of s)r||=new Uint8Array(new Uint32Array(A.buffer,0,4)[0]),r.set(A,a),a+=A.length;const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const h=o[2],c=o[3],d=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],b=(Ee+se*p)*Uint32Array.BYTES_PER_ELEMENT;let y;switch(g){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(r.buffer,b);break}a=0;for(let A=0;A<p;A++){const w=o[se*A+Ee],v=new Float32Array(w+2);m.push(v);for(let S=0;S<se-1;S++)v[S]=o[se*A+Ee+S+1];for(let S=0;S<w;S++)v[S+2]=v[S]+y[a++]}return{areContours:d,thickness:f,outlines:m,width:h,height:c}}catch(e){return N(`decompressSignature: ${e}`),null}}}class Ls extends Bi{constructor(){super(),super.updateProperties({fill:P._defaultLineColor,"stroke-width":0})}clone(){const t=new Ls;return t.updateAll(this),t}}class Os extends Xe{constructor(t){super(t),super.updateProperties({stroke:P._defaultLineColor,"stroke-width":1})}clone(){const t=new Os(this._viewParameters);return t.updateAll(this),t}}class Et extends ${#t=!1;#e=null;#s=null;#i=null;static _type="signature";static _editorType=R.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){P.initialize(t,e),this._defaultDrawingOptions=new Ls,this._defaultDrawnSignatureOptions=new Os(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return D(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#s){const{lines:i,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:h,pageHeight:c},rotation:d}=this.parent.viewport,f=Kt.processDrawnLines({lines:i,pageWidth:h,pageHeight:c,rotation:d,innerMargin:Et._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(f,l,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#i=t,this.addEditToolbar()}getUuid(){return this.#i}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#s,r=Math.max(i,n),a=Kt.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){const{x:n,y:r}=this,{outline:a}=this.#s=t;this.#t=a instanceof ys,this.description=s;let o;this.#t?o=Et.getDefaultDrawingOptions():(o=Et._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Kt.process(t,e,s,i,Et._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Kt.extractContoursFromText(t,e,s,i,n,Et._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Kt.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:Et._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Et.getDefaultDrawingOptions():(this._drawingOptions=Et._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});return this.addComment(n),t?(n.paths={lines:e,points:s},n.uuid=this.#i,n.isCopy=!0):n.lines=e,this.#e&&(n.accessibilityData={type:"Figure",alt:this.#e}),n}static deserializeDraw(t,e,s,i,n,r){return r.areContours?ys.deserialize(t,e,s,i,n,r):be.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class Zr extends P{#t=null;#e=null;#s=null;#i=null;#n=null;#a="";#r=null;#o=!1;#h=null;#l=!1;#u=!1;static _type="stamp";static _editorType=R.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#i=t.bitmapUrl,this.#n=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){P.initialize(t,e)}static isHandlingMimeForPasting(t){return cs.includes(t)}static paste(t,e){e.pasteEditor({mode:R.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#l=t.isSvg),t.file&&(this.#a=t.file.name),this.#g()}#p(){if(this.#s=null,this._uiManager.enableWaiting(!1),!!this.#r){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{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()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.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.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#m(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#p());return}if(this.#i){const s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#d(i)).finally(()=>this.#p());return}if(this.#n){const s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#d(i)).finally(()=>this.#p());return}const t=document.createElement("input");t.type="file",t.accept=cs.join(",");const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#p()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#h&&(clearTimeout(this.#h),this.#h=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#m();return}super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#m(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#n||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#g():this.#m()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,i&&(this.#t=i),this.#o=!1,this.#g())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#h!==null&&clearTimeout(this.#h);const t=200;this.#h=setTimeout(()=>{this.#h=null,this.#f()},t)}#g(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const o=Math.min(r*i/e,r*n/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);const a=this.#r=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#f(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#a&&this.div.setAttribute("aria-description",this.#a),this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;const{width:i,height:n}=this.#t,r=new Tt;let a=this.#t,o=i,l=n,h=null;if(e){if(i>e||n>e){const S=Math.min(e/i,e/n);o=Math.floor(i*S),l=Math.floor(n*S)}h=document.createElement("canvas");const d=h.width=Math.ceil(o*r.sx),f=h.height=Math.ceil(l*r.sy);this.#l||(a=this.#c(d,f));const p=h.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":an.isDarkMode&&(g="#8f8f9d",m="#42414d");const b=15,y=b*r.sx,A=b*r.sy,w=new OffscreenCanvas(y*2,A*2),v=w.getContext("2d");v.fillStyle=g,v.fillRect(0,0,y*2,A*2),v.fillStyle=m,v.fillRect(0,0,y,A),v.fillRect(y,A,y,A),p.fillStyle=p.createPattern(w,"repeat"),p.fillRect(0,0,d,f),p.drawImage(a,0,0,a.width,a.height,0,0,d,f)}let c=null;if(s){let d,f;if(r.symmetric&&a.width<t&&a.height<t)d=a.width,f=a.height;else if(a=this.#t,i>t||n>t){const m=Math.min(t/i,t/n);d=Math.floor(i*m),f=Math.floor(n*m),this.#l||(a=this.#c(d,f))}const g=new OffscreenCanvas(d,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,d,f),c={width:d,height:f,data:g.getImageData(0,0,d,f).data}}return{canvas:h,width:o,height:l,imageData:c}}#c(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,l=r;n>2*t&&(n=Math.ceil(n/2)),r>2*e&&(r=Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=h.transferToImageBitmap()}return a}#f(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Tt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#r;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#l?this.#t:this.#c(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#y(t){if(t){if(this.#l){const i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#l){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*Zt.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*Zt.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof Oi){const{data:{rect:g,rotation:m,id:b,structParent:y,popupRef:A,richText:w,contentsObj:v,creationDate:S,modificationDate:x},container:E,parent:{page:{pageNumber:_}},canvas:k}=t;let M,L;k?(delete t.canvas,{id:M,bitmap:L}=s.imageManager.getFromCanvas(E.id,k),k.remove()):(n=!0,t._hasNoCanvas=!0);const H=(await e._structTree.getAriaAttributes(`${qt}${b}`))?.get("aria-label")||"";i=t={annotationType:R.STAMP,bitmapId:M,bitmap:L,pageIndex:_-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:H},isSvg:!1,structParent:y,popupRef:A,richText:w,comment:v?.str||null,creationDate:S,modificationDate:x}}const r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;n?(s.addMissingCanvas(t.id,r),r.#o=!0):h&&s.imageManager.isValidId(h)?(r.#e=h,o&&(r.#t=o)):r.#i=l,r.#l=c;const[f,p]=r.pageDimensions;return r.width=(a[2]-a[0])/f,r.height=(a[3]-a[1])/p,d&&(r.altTextData=d),r._initialData=i,t.comment&&r.setCommentData(t),r.#u=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#l});if(this.addComment(s),t)return s.bitmapUrl=this.#y(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const a=this.#A(s);return a.isSame?null:(a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1,s.id=this.annotationElementId,delete s.bitmapId,s)}if(e===null)return s;e.stamps||=new Map;const r=this.#l?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#y(!1);else if(this.#l){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#y(!1))}return s}#A(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Pt{#t;#e=!1;#s=null;#i=null;#n=null;#a=new Map;#r=!1;#o=!1;#h=!1;#l=null;#u=null;#d=null;#p=null;#m=null;#g=-1;#c;static _initialized=!1;static#f=new Map([nt,Fs,Zr,tt,Et].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const c=[...Pt.#f.values()];if(!Pt._initialized){Pt._initialized=!0;for(const d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#c=t,this.pageIndex=e,this.div=s,this.#t=n,this.#s=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=i,this.#c.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===R.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#v(),t){case R.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case R.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case R.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===R.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of Pt.#f.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#y(){return this.#a.size!==0?this.#a.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#h=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#m?.abort(),this.#m=null;const t=new Set;for(const s of this.#y)s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#c.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=this.#s;if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),this.#c.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}this.#h=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#m){this.#m=new AbortController;const i=this.#c.combinedSignal(this.#m);this.#d.div.addEventListener("pointerdown",n=>{const{clientX:a,clientY:o,timeStamp:l}=n,h=this.#g;if(l-h>500){this.#g=l;return}this.#g=-1;const{classList:c}=this.div;c.toggle("getElements",!0);const d=document.elementsFromPoint(a,o);if(c.toggle("getElements",!1),!this.div.contains(d[0]))return;let f;const p=new RegExp(`^${le}[0-9]+$`);for(const m of d)if(p.test(m.id)){f=m.id;break}if(!f)return;const g=this.#a.get(f);g?.annotationElementId===null&&(Q(n),g.dblclick(n))},{signal:i,capture:!0})}const t=this.#s,e=[];if(t){const i=new Map,n=new Map;for(const r of this.#y){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){i.set(r.annotationElementId,r);continue}else n.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(const r of t.getEditableAnnotations()){const{id:a}=r.data;if(this.#c.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=n.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}o=i.get(a),o&&(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(r)&&o.show(!1)),r.show()}}this.#v(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of Pt.#f.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#c.getActive()!==t&&this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#p){this.#p=new AbortController;const t=this.#c.combinedSignal(this.#p);this.#d.div.addEventListener("pointerdown",this.#A.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"))}#A(t){this.#c.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){const{isMac:s}=z.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#c.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),tt.startHighlighting(this,this.#c.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.#c._signal}),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;const t=this.#c.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#a.set(t.id,t);const{annotationElementId:e}=t;e&&this.#c.isDeletedAnnotationElement(e)&&this.#c.removeDeletedAnnotationElement(t)}detach(t){this.#a.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#c.addDeletedAnnotationElement(t),P.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)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#h),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#n&&(t._focusEventsAllowed=!1,this.#n=setTimeout(()=>{this.#n=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),e.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){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of this.#a.values())if(e.uid===t)return e;return null}get#b(){return Pt.#f.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#S(t){const e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);const{offsetX:s,offsetY:i}=this.#E(),n=this.#c.getId(),r=this.#S({parent:this,id:n,x:s,y:i,uiManager:this.#c,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await Pt.#f.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,s={}){const i=this.#c.getId(),n=this.#S({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...s});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#E(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(n+a)/2-t,h=(r+o)/2-e,[c,d]=this.viewport.rotation%180===0?[l,h]:[h,l];return{offsetX:c,offsetY:d}}addNewEditor(t={}){this.createAndAddNewEditor(this.#E(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){const{isMac:e}=z.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#r||(this.#r=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const s=this.#c.getMode();if(s===R.STAMP||s===R.POPUP||s===R.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===R.HIGHLIGHT&&this.enableTextSelection(),this.#r){this.#r=!1;return}const{isMac:e}=z.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#r=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}const s=this.#c.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#l){this.#b.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#l=new AbortController;const e=this.#c.combinedSignal(this.#l);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#b.startDrawing(this,this.#c,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#l?(this.#c.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#b.endDrawing(t)):null}findNewParent(t,e,s){const i=this.#c.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#b.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#c.getActive()?.parent===this&&(this.#c.commitOrRemove(),this.#c.setActiveEditor(null)),this.#n&&(clearTimeout(this.#n),this.#n=null);for(const t of this.#a.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#a.clear(),this.#c.removeLayer(this)}#v(){for(const t of this.#a.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,Ut(this.div,t);for(const e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#v();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Ut(this.div,{rotation:s}),e!==s)for(const i of this.#a.values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}}function ta(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Ce(u){return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):u.parentElement?.closest(".textLayer")||null:null}function ea(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function ci(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return s?.nodeType===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}class O{#t=null;#e=new Map;#s=null;#i=null;#n=null;#a=null;#r=new Map;static#o=0;static#h=0;static#l=null;static#u=new Set;static#d=!1;static#p=new Set;static#m=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#n=e,i){const n=O.#m.get(i);if(n?.selectionDiv&&(n.selectionDiv.remove(),O.#u.delete(n.selectionDiv)),O.#m.set(i,{drawLayer:this}),O.#p.add(i),this.#s=i,this.#a=new MutationObserver(r=>{if(!(!this.#t||!this.#s?.isConnected||!O.#c())){for(const{addedNodes:a}of r)for(const o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){O.#y();return}}}),this.#a.observe(i,{childList:!0}),O.#l===null){O.#l=new AbortController;const{signal:r}=O.#l;document.addEventListener("selectionchange",O.#y.bind(O),{signal:r}),document.addEventListener("pointerdown",()=>{O.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{O.#d=!1},{signal:r}),window.addEventListener("blur",()=>{O.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){this.#t=t,this.#s?.isConnected&&O.#c()&&O.#y();return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#g(t){const e=this.#m.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#c(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#f(){return this.#p.keys().filter(t=>t.isConnected).toArray().sort(ta)}static#y(){const t=document.getSelection();if(!t||t.isCollapsed){for(const r of this.#u)r.remove();this.#u.clear();return}const e=new WeakMap,s=this.#f(),i=[];for(let r=0,a=t.rangeCount;r<a;r++){const o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:h,endContainer:c,endOffset:d}=o,f=Ce(l),p=Ce(c);const g=f===null,m=p===null;if(this.#d&&g!==m)return;if(t.rangeCount===1){const{anchorNode:A,anchorOffset:w,focusNode:v,focusOffset:S}=t,x=Ce(A),E=Ce(v),_=ea(A,w,v,S);x&&E&&_!==null&&(_?(l=A,h=w,f=x,c=v,d=S,p=E):(l=v,h=S,f=E,c=A,d=w,p=x))}const b=s.filter(A=>o.intersectsNode(A));if(b.length===0)continue;let y=!1;if(f||(f=b[0],l=f,h=0,y=!0),p||(p=b.at(-1),c=p,d=p.childNodes.length,y=!0),c.nodeType===Node.ELEMENT_NODE){if(c.classList.contains("endOfContent")){const A=c.previousSibling;if(!A)continue;c=A,d=A.nodeType===Node.TEXT_NODE?A.textContent.length:A.childNodes.length}else if(c.classList.contains("textLayer")&&c.childNodes.length===d){const A=ci(c,d,p);if(!A)continue;c=A.container,d=A.offset}}if(l.nodeType===Node.ELEMENT_NODE){const A=ci(l,h,f);if(!A)continue;l=A.container,h=A.offset}if(f===p&&!y&&b.includes(f)){i.push([o,f]);continue}for(const A of b){const w=A.firstChild;if(!w)continue;const v=document.createRange();if(A===f?v.setStart(l,h):v.setStartBefore(w),A===p)v.setEnd(c,d);else{const S=A.lastChild;if(!S)continue;if(S.nodeType===Node.ELEMENT_NODE&&S.classList.contains("endOfContent")){const x=S.previousSibling;if(!x)continue;v.setEndAfter(x)}else v.setEndAfter(S)}v.collapsed||i.push([v,A])}}const n=new Set(i.map(r=>r[1]));for(const r of this.#p)n.has(r)||this.#g(r);for(const[r,a]of i){const o=O.#m.get(a);if(!o)continue;let l=e.get(a);if(!l){const p=a.getBoundingClientRect();l=(g,m,b,y)=>({x:(g-p.x)/p.width,y:(m-p.y)/p.height,width:b/p.width,height:y/p.height}),e.set(a,l)}const h=[];for(let{x:p,y:g,width:m,height:b}of r.getClientRects())m===0||b===0||({x:p,y:g,width:m,height:b}=l(p,g,m,b),!(m===1&&b===1)&&h.push(`M${p} ${g} h${m} v${b} h-${m} Z`));if(h.length===0)continue;const c=o.drawLayer;let d=o.selectionDiv,f=o.path;if(!d){const p=`clip_selection_${O.#h++}`;d=document.createElement("div"),d.className="selection",d.style.clipPath=`url(#${p})`;const g=c.#i?.createSelectionStyle(c.#n);if(g)for(const[y,A]of Object.entries(g))d.style.setProperty(y,A);const m=O._svgFactory.create(1,1,!0);m.setAttribute("aria-hidden","true"),m.setAttribute("width","100%"),m.setAttribute("height","100%");const b=O._svgFactory.createElement("clipPath");b.setAttribute("id",p),b.setAttribute("clipPathUnits","objectBoundingBox"),f=O._svgFactory.createElement("path"),b.append(f),m.append(b),d.append(m),o.path=f,o.selectionDiv=d}!d.parentNode&&c.#t&&(c.#t.append(d),this.#u.add(d)),f.setAttribute("d",h.join(" "))}}static get _svgFactory(){return D(this,"_svgFactory",new Ie)}static#A(t,[e,s,i,n]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#b(){const t=O._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#S(t,e){const s=O._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=O._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#E(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){const i=O.#o++,n=this.#b(),r=O._svgFactory.createElement("defs");n.append(r);const a=O._svgFactory.createElement("path");r.append(a);const o=`path_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#r.set(i,a);const l=s?this.#S(r,o):null,h=O._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(i,n),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){const s=O.#o++,i=this.#b(),n=O._svgFactory.createElement("defs");i.append(n);const r=O._svgFactory.createElement("path");n.append(r);const a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const c=O._svgFactory.createElement("mask");n.append(c),o=`mask_${s}`,c.setAttribute("id",o),c.setAttribute("maskUnits","objectBoundingBox");const d=O._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const f=O._svgFactory.createElement("use");c.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=O._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return i.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#E(a,s),i&&O.#A(a,i),n){const{classList:o}=a;for(const[l,h]of Object.entries(n))o.toggle(l,h)}if(r){const l=a.firstElementChild.firstElementChild;this.#E(l,r)}}}updateParent(t,e){if(e===this)return;const s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#r.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#r.clear(),this.#a?.disconnect(),this.#a=null,this.#s&&(O.#m.get(this.#s)?.drawLayer===this&&(O.#g(this.#s),O.#m.delete(this.#s),O.#p.delete(this.#s),O.#p.size===0&&(O.#l?.abort(),O.#l=null,O.#d=!1)),this.#s=null)}}function _e(u){return`${(u*100).toFixed(2)}%`}class De{#t=[];#e=new Map;#s=null;#i=0;#n=0;#a=0;static#r=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#n=s.rawDims.pageWidth,this.#a=s.rawDims.pageHeight,this.#s=i}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){const s=this.#o(this.#t.subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=this.#e.get(s);if(!i)return;const n=De.#r?.deref();if(n===s)return;n&&(n.width=0,n.height=0),De.#r=new WeakRef(s);const{inverseTransform:r,x1:a,y1:o,width:l,height:h}=i,c=this.#s(),d=Math.ceil(a*c.width),f=Math.ceil(o*c.height),p=Math.floor((a+l/this.#n)*c.width),g=Math.floor((o+h/this.#a)*c.height);s.width=p-d,s.height=g-f;const m=s.getContext("2d");m.setTransform(...r),m.translate(-d,-f),m.drawImage(c,0,0)}),t}#o([t,e,s,i,n,r]){const a=Math.hypot((n-t)*this.#n,(r-e)*this.#a),o=Math.hypot((s-t)*this.#n,(i-e)*this.#a);if(a<this.#i||o<this.#i)return null;const l=[(n-t)*this.#n/a,(r-e)*this.#a/a,(s-t)*this.#n/o,(i-e)*this.#a/o,0,0],h=C.inverseTransform(l),c=document.createElement("canvas");return c.className="textLayerImagePlaceholder",c.width=0,c.height=0,Object.assign(c.style,{opacity:0,position:"absolute",left:_e(t),top:_e(e),width:_e(a/this.#n),height:_e(o/this.#a),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(c,{inverseTransform:h,width:a,height:o,x1:t,y1:e}),c}}globalThis._pdfjsTestingUtils={HighlightOutliner:ms};globalThis.pdfjsLib={AbortException:Dt,AnnotationEditorLayer:Pt,AnnotationEditorParamsType:B,AnnotationEditorType:R,AnnotationEditorUIManager:Ft,AnnotationLayer:Ds,AnnotationMode:It,AnnotationType:q,applyOpacity:ln,build:kr,ColorPicker:At,createValidAbsoluteUrl:di,CSSConstants:on,DOMSVGFactory:Ie,DrawLayer:O,FeatureTest:z,fetchData:vs,findContrastColor:hn,getDocument:xr,getFilenameFromUrl:sn,getPdfFilenameFromUrl:nn,getRGB:me,getRGBA:ge,getUuid:fi,GlobalWorkerOptions:oe,ImageKind:Te,InvalidPDFException:os,isDataScheme:Ne,isPdfFile:Ss,isValidExplicitDest:In,makeArr:fe,makeMap:As,makeObj:ls,makeSet:Zi,MathClamp:X,noContextMenu:vt,normalizeUnicode:Qi,OPS:Ct,OutputScale:Tt,PasswordException:as,PasswordResponses:zi,PDFDataRangeTransport:Ii,PDFDateString:hs,PDFWorker:rt,PermissionFlag:ji,PixelsPerInch:Zt,RenderingCancelledException:ws,renderRichText:gi,ResponseException:Pe,setLayerDimensions:Ut,shadow:D,SignatureExtractor:Kt,stopEvent:Q,SupportedImageMimeTypes:cs,TextLayer:ft,TextLayerImages:De,TouchManager:Be,updateUrlHash:ui,Util:C,VerbosityLevel:Fe,version:Tr,XfaLayer:pi};const sa="/assets/pdf.worker.min-CHFwMXne.mjs";export{oe as G,rt as P,xr as g,sa as w};
|
|
55
|
+
`)){const n=document.createElement("div");n.append(i?document.createTextNode(i):document.createElement("br")),e.append(n)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class T{static PRECISION=1e-4;toSVGPath(){G("Abstract method `toSVGPath` must be implemented.")}get box(){G("Abstract getter `box` must be implemented.")}serialize(t,e){G("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}class Ht{#t;#e=[];#s;#i;#n=[];#a=new Float32Array(18);#r;#o;#h;#l;#u;#d;#p=[];static#m=8;static#g=2;static#c=Ht.#m+Ht.#g;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#i=r,this.#a.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#l=Ht.#m*i,this.#h=Ht.#c*i,this.#u=i,this.#p.push(t,e)}isEmpty(){return isNaN(this.#a[8])}#f(){const t=this.#a.subarray(4,6),e=this.#a.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#o=e;const[s,i,n,r]=this.#t;let[a,o,l,h]=this.#a.subarray(8,12);const c=t-l,d=e-h,f=Math.hypot(c,d);if(f<this.#h)return!1;const p=f-this.#l,g=p/f,m=g*c,b=g*d;let y=a,A=o;a=l,o=h,l+=m,h+=b,this.#p?.push(t,e);const w=-b/p,v=m/p,S=w*this.#d,x=v*this.#d;return this.#a.set(this.#a.subarray(2,8),0),this.#a.set([l+S,h+x],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([l-S,h-x],16),isNaN(this.#a[6])?(this.#n.length===0&&(this.#a.set([a+S,o+x],2),this.#n.push(NaN,NaN,NaN,NaN,(a+S-s)/n,(o+x-i)/r),this.#a.set([a-S,o-x],14),this.#e.push(NaN,NaN,NaN,NaN,(a-S-s)/n,(o-x-i)/r)),this.#a.set([y,A,a,o,l,h],6),!this.isEmpty()):(this.#a.set([y,A,a,o,l,h],6),Math.abs(Math.atan2(A-o,y-a)-Math.atan2(b,m))<Math.PI/2?([a,o,l,h]=this.#a.subarray(2,6),this.#n.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/n,((o+h)/2-i)/r),[a,o,y,A]=this.#a.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-s)/n,((A+o)/2-i)/r),!0):([y,A,a,o,l,h]=this.#a.subarray(0,6),this.#n.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),[l,h,a,o,y,A]=this.#a.subarray(12,18),this.#e.push(((y+5*a)/6-s)/n,((A+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#n,e=this.#e;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#y();const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#A(s),s.join(" ")}#y(){const[t,e,s,i]=this.#t,[n,r,a,o]=this.#f();return`M${(this.#a[2]-t)/s} ${(this.#a[3]-e)/i} L${(this.#a[4]-t)/s} ${(this.#a[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#a[16]-t)/s} ${(this.#a[17]-e)/i} L${(this.#a[14]-t)/s} ${(this.#a[15]-e)/i} Z`}#A(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){const[e,s,i,n]=this.#t,r=this.#a.subarray(4,6),a=this.#a.subarray(16,18),[o,l,h,c]=this.#f();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Ni(t,e,s,i,n,r)}getOutlines(){const t=this.#n,e=this.#e,s=this.#a,[i,n,r,a]=this.#t,o=new Float32Array((this.#p?.length??0)+2);for(let c=0,d=o.length-2;c<d;c+=2)o[c]=(this.#p[c]-i)/r,o[c+1]=(this.#p[c+1]-n)/a;if(o[o.length-2]=(this.#r-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#S(o);const l=new Float32Array(this.#n.length+24+this.#e.length);let h=t.length;for(let c=0;c<h;c+=2){if(isNaN(t[c])){l[c]=l[c+1]=NaN;continue}l[c]=t[c],l[c+1]=t[c+1]}h=this.#v(l,h);for(let c=e.length-6;c>=6;c-=6)for(let d=0;d<6;d+=2){if(isNaN(e[c+d])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[c+d],l[h+1]=e[c+d+1],h+=2}return this.#E(l,h),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#S(t){const e=this.#a,[s,i,n,r]=this.#t,[a,o,l,h]=this.#f(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(c,t,this.#t,this.#u,this.#s,this.#i)}#E(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#v(t,e){const s=this.#a.subarray(4,6),i=this.#a.subarray(16,18),[n,r,a,o]=this.#t,[l,h,c,d]=this.#f();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}}class Ni extends T{#t;#e=new Float32Array(4);#s;#i;#n;#a;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#n=e,this.#t=s,this.#a=i,this.#s=n,this.#i=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);const[a,o,l,h]=this.#e;for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,l;switch(n){case 0:o=T._rescale(this.#r,t,i,r,-a),l=T._rescale(this.#n,t,i,r,-a);break;case 90:o=T._rescaleAndSwap(this.#r,t,e,r,a),l=T._rescaleAndSwap(this.#n,t,e,r,a);break;case 180:o=T._rescale(this.#r,s,e,-r,a),l=T._rescale(this.#n,s,e,-r,a);break;case 270:o=T._rescaleAndSwap(this.#r,s,i,-r,-a),l=T._rescaleAndSwap(this.#n,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){const e=this.#r;let s=e[4],i=e[5];const n=[s,i,s,i];let r=s,a=i,o=s,l=i;const h=t?Math.max:Math.min,c=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){const g=e[f+4],m=e[f+5];isNaN(e[f])?(C.pointBoundingBox(g,m,n),a>m?(r=g,a=m):a===m&&(r=h(r,g)),l<m?(o=g,l=m):l===m&&(o=h(o,g))):(c.set(Mt,0),C.bezierBoundingBox(s,i,...e.slice(f,f+6),c),C.rectBoundingBox(...c,n),a>c[1]?(r=c[0],a=c[1]):a===c[1]&&(r=h(r,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),s=g,i=m}const d=this.#e;d[0]=n[0]-this.#s,d[1]=n[1]-this.#s,d[2]=n[2]-n[0]+2*this.#s,d[3]=n[3]-n[1]+2*this.#s,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,n,r=0){return new Ht(t,e,s,i,n,r)}getNewOutline(t,e){const[s,i,n,r]=this.#e,[a,o,l,h]=this.#t,c=n*l,d=r*h,f=s*l+a,p=i*h+o,g=this.newOutliner({x:this.#n[0]*c+f,y:this.#n[1]*d+p},this.#t,this.#a,t,this.#i,e??this.#s);for(let m=2;m<this.#n.length;m+=2)g.add({x:this.#n[m]*c+f,y:this.#n[m+1]*d+p});return g.getOutlines()}}class ms{#t;#e;#s;#i=[];#n=[];constructor(t,e=0,s=0,i=!0){const n=Mt.slice(),r=10**-4;for(const{x:g,y:m,width:b,height:y}of t){const A=Math.floor((g-e)/r)*r,w=Math.ceil((g+b+e)/r)*r,v=Math.floor((m-e)/r)*r,S=Math.ceil((m+y+e)/r)*r,x=[A,v,S,!0],E=[w,v,S,!1];this.#i.push(x,E),C.rectBoundingBox(A,v,w,S,n)}const a=n[2]-n[0]+2*s,o=n[3]-n[1]+2*s,l=n[0]-s,h=n[1]-s;let c=i?-1/0:1/0,d=1/0;const f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(const g of this.#i){const[m,b,y,A]=g;!A&&i?b<d?(d=b,c=m):b===d&&(c=Math.max(c,m)):A&&!i&&(b<d?(d=b,c=m):b===d&&(c=Math.min(c,m))),g[0]=(m-l)/a,g[1]=(b-h)/o,g[2]=(y-h)/o}this.#t=new Float32Array([l,h,a,o]),this.#e=[c,d],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#i)e[3]?(t.push(...this.#l(e)),this.#o(e)):(this.#h(e),t.push(...this.#l(e)));return this.#a(t)}#a(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,l,h,c]=r;s.delete(r);let d=a,f=o;for(n=[a,l],i.push(n);;){let p;if(s.has(h))p=h;else if(s.has(c))p=c;else break;s.delete(p),[a,o,l,h,c]=p,d!==a&&(n.push(d,f,a,f===o?o:l),d=a),f=f===o?l:o}n.push(d,f)}return new qr(i,this.#t,this.#e,this.#s)}#r(t){const e=this.#n;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#o([,t,e]){const s=this.#r(t);this.#n.splice(s,0,[t,e])}#h([,t,e]){const s=this.#r(t);for(let i=s;i<this.#n.length;i++){const[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}}#l(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#r(i);for(let a=0;a<r;a++){const[o,l]=this.#n[a];for(let h=0,c=n.length;h<c;h++){const[,d,f]=n[h];if(!(l<=d||f<=o)){if(d>=o){if(f>l)n[h][1]=l;else{if(c===1)return[];n.splice(h,1),h--,c--}continue}n[h][2]=o,f>l&&n.push([e,l,f])}}}return n}}class qr extends T{#t;#e;constructor(t,e,s,i){super(),this.#e=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-e;for(const l of this.#e){const h=new Array(l.length);for(let c=0;c<l.length;c+=2)h[c]=t+l[c]*a,h[c+1]=i-l[c+1]*o;r.push(h)}return r}get box(){return this.#t}}class bs extends Ht{newFreeDrawOutline(t,e,s,i,n,r){return new Qr(t,e,s,i,n,r)}}class Qr extends Ni{newOutliner(t,e,s,i,n,r=0){return new bs(t,e,s,i,n,r)}}class tt extends P{#t=null;#e=0;#s;#i=null;#n=null;#a=null;#r=null;#o=0;#h=null;#l=null;#u=null;#d=!1;#p=null;#m=null;#g=null;#c="";#f;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=R.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=tt.prototype;return D(this,"_keyboardManager",new gt([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||tt._defaultColor,this.#f=t.thickness||tt._defaultThickness,this.opacity=t.opacity||tt._defaultOpacity,this.#s=t.boxes||null,this.#y=t.methodOfCreation||"",this.#c=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#d=!0,this.#b(t),this.#x()):this.#s&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#o=t.focusOffset,this.#A(),this.#x(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#f,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#A(){const t=new ms(this.#s,.001);this.#l=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;const e=new ms(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#a=e.getOutlines();const{firstPoint:s}=this.#l;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height];const{lastPoint:i}=this.#a;this.#m=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#b({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#l=t;const i=1.5;if(this.#a=t.getNewOutline(this.#f/2+i,.0025),e>=0)this.#u=e,this.#i=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#g=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0);else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:tt.#T(this.#l.box,(c-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#g,{bbox:tt.#T(this.#a.box,c),path:{d:this.#a.toSVGPath()}})}const[n,r,a,o]=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{const[c,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/c,this.height=o*c/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{const[c,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/c,this.height=o*c/d;break}}const{firstPoint:l}=t;this.#p=[(l[0]-n)/a,(l[1]-r)/o];const{lastPoint:h}=this.#a;this.#m=[(h[0]-n)/a,(h[1]-r)/o]}static initialize(t,e){P.initialize(t,e),tt._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:tt._defaultColor=e;break;case B.HIGHLIGHT_THICKNESS:tt._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#m}get commentButtonPosition(){return this.#p}updateParams(t,e){switch(t){case B.HIGHLIGHT_COLOR:this.#S(e);break;case B.HIGHLIGHT_THICKNESS:this.#E(e);break}}static get defaultPropertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,tt._defaultColor],[B.HIGHLIGHT_THICKNESS,tt._defaultThickness]]}get propertiesToUpdate(){return[[B.HIGHLIGHT_COLOR,this.color||tt._defaultColor],[B.HIGHLIGHT_THICKNESS,this.#f||tt._defaultThickness],[B.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#n?.updateColor(this.color),super.onUpdatedColor()}#S(t){const e=(n,r)=>{this.color=n,this.opacity=r,this.onUpdatedColor()},s=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,t,tt._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#E(t){const e=this.#f,s=i=>{this.#f=i,this.#v(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#n=new At({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#k())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#C(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#x(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#C():t&&(this.#x(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#v(t){this.#d&&(this.#b({highlightOutlines:this.#l.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#C(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#g),this.#g=null)}#x(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#i}=t.drawLayer.draw({bbox:this.#l.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#g=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d),this.#h&&(this.#h.style.clipPath=this.#i))}static#T([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){const{drawLayer:e}=this.parent;let s;this.#d?(t=(t-this.rotation+360)%360,s=tt.#T(this.#l.box,t)):s=tt.#T([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#g,{bbox:tt.#T(this.#a.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#c&&(t.setAttribute("aria-label",this.#c),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#P.bind(this),{signal:this._uiManager._signal});const e=this.#h=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#i,this.setDims(),bi(this,this.#h,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1}})}#P(t){tt._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#M(!0);break;case 1:case 3:this.#M(!1);break}}#M(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#o)}select(){super.select(),this.#g&&this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#g&&(this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{selected:!1}}),this.#d||this.#M(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#g,{rootClass:{hidden:!t}}))}#k(){return this.#d?this.rotation:0}#F(){if(this.#d)return null;const[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=this.#s,r=new Float32Array(n.length*8);let a=0;for(const{x:o,y:l,width:h,height:c}of n){const d=o*t+s,f=(1-l)*e+i;r[a]=r[a+4]=d,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=d+h*t,r[a+5]=r[a+7]=f-c*e,a+=8}return r}#L(t){return this.#l.serialize(t,this.#k())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:l}=s.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=f=>{h.abort(),this.#O(t,f)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Q,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",vt,{signal:c}),s.addEventListener("pointermove",this.#D.bind(this,t),{signal:c}),this._freeHighlight=new bs({x:i,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.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#D(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#O(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,s){let i=null;if(t instanceof Li){const{data:{quadPoints:g,rect:m,rotation:b,id:y,color:A,opacity:w,popupRef:v,richText:S,contentsObj:x,creationDate:E,modificationDate:_},parent:{page:{pageNumber:k}}}=t;i=t={annotationType:R.HIGHLIGHT,color:Array.from(A),opacity:w,quadPoints:g,boxes:null,pageIndex:k-1,rect:m.slice(0),rotation:b,annotationElementId:y,id:y,deleted:!1,popupRef:v,richText:S,comment:x?.str||null,creationDate:E,modificationDate:_}}else if(t instanceof Is){const{data:{inkLists:g,rect:m,rotation:b,id:y,color:A,borderStyle:{rawWidth:w},popupRef:v,richText:S,contentsObj:x,creationDate:E,modificationDate:_},parent:{page:{pageNumber:k}}}=t;i=t={annotationType:R.HIGHLIGHT,color:Array.from(A),thickness:w,inkLists:g,boxes:null,pageIndex:k-1,rect:m.slice(0),rotation:b,annotationElementId:y,id:y,deleted:!1,popupRef:v,richText:S,comment:x?.str||null,creationDate:E,modificationDate:_}}const{color:n,quadPoints:r,inkLists:a,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,s);h.color=C.makeHexColor(...n),h.opacity=l||1,a&&(h.#f=t.thickness),h._initialData=i,t.comment&&h.setCommentData(t);const[c,d]=h.pageDimensions,[f,p]=h.pageTranslation;if(r){const g=h.#s=[];for(let m=0;m<r.length;m+=8)g.push({x:(r[m]-f)/c,y:1-(r[m+1]-p)/d,width:(r[m+2]-r[m])/c,height:(r[m+1]-r[m+5])/d});h.#A(),h.#x(),h.rotate(h.rotation)}else if(a||o){h.#d=!0;const g=(a||o.points)[0],m={x:g[0]-f,y:d-(g[1]-p)},b=new bs(m,[0,0,c,d],1,h.#f/2,!0,.001);for(let w=0,v=g.length;w<v;w+=2)m.x=g[w]-f,m.y=d-(g[w+1]-p),b.add(m);const{id:y,clipPathId:A}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:b.toSVGPath()}},!0,!0);h.#b({highlightOutlines:b.getOutlines(),highlightId:y,clipPathId:A}),h.#x(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=P._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(t);return Object.assign(s,{color:e,opacity:this.opacity,thickness:this.#f,quadPoints:this.#F(),outlines:this.#L(s.rect)}),this.addComment(s),this.annotationElementId&&!this.#N(s)?null:(s.id=this.annotationElementId,s)}#N(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Bi{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){G("Not implemented")}}class $ extends P{#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#n=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#a(t),this.#h())}#a({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#r(t,this.parent),this.#d(t.box)}#r(t,e){const{id:s}=e.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,n]of Object.entries(e))s.has(i)?Object.assign(t[i],n):t[i]=n;return t}static getDefaultDrawingOptions(t){G("Not implemented")}static get typesMap(){G("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&($.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,n=i[e],r=a=>{i.updateProperty(e,a);const o=this.#t.updateProperty(e,a);o&&this.#d(o),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){const s=this.constructor.typesMap.get(this.colorType),i=this.constructor.typesMap.get(this.opacityType),n=this._drawingOptions,r=n[s],a=n[i],o=(l,h)=>{n.updateProperty(s,l),n.updateProperty(i,h),this.#t.updateProperty(s,l),this.#t.updateProperty(i,h),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,r,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:B.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#u()),{bbox:this.#p()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#u()),{bbox:this.#p()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#p()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#p()}))}_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.#o(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#h(),this.#d(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#o()):t&&(this._uiManager.addShouldRescale(this),this.#h(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#o(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#h(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.#r(this.#t,t)}}#l([t,e,s,i]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#u(){const{x:t,y:e,width:s,height:i,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#d(t){[this.x,this.y,this.width,this.height]=this.#l(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#p(){const{x:t,y:e,width:s,height:i,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((n*4+r)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(a/o),i*(o/a),s*(a/o)];case 5:return[1-e,t,s*(a/o),i*(o/a)];case 6:return[1-t-i*(o/a),1-e,i*(o/a),s*(a/o)];case 7:return[e-s*(a/o),1-t-i*(o/a),s*(a/o),i*(o/a)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/a),e,i*(o/a),s*(a/o)];case 13:return[1-e-s*(a/o),t-i*(o/a),s*(a/o),i*(o/a)];case 14:return[1-t,1-e-s*(a/o),i*(o/a),s*(a/o)];case 15:return[e,1-t,s*(a/o),i*(o/a)];default:return[t,e,s,i]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#p()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");return s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,n){G("Not implemented")}static startDrawing(t,e,s,i){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=i;if(j.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:c,height:d}=n.getBoundingClientRect(),f=$.#i=new AbortController,p=t.combinedSignal(f);if(j.setPointer(l,o),window.addEventListener("pointerup",g=>{j.isSamePointerIdOrRemove(g.pointerId)&&this._endDraw(g)},{signal:p}),window.addEventListener("pointercancel",g=>{j.isSamePointerIdOrRemove(g.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",g=>{j.isSamePointerType(g.pointerType)&&(j.initializeAndAddPointerId(g.pointerId),$.#s.isCancellable()&&($.#s.removeLastElement(),$.#s.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",vt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",g=>{j.isSameTimeStamp(g.timeStamp)&&Q(g)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),$.#s){t.drawLayer.updateProperties(this._currentDrawId,$.#s.startNew(r,a,c,d,h));return}e.updateUIForDefaultProperties(this),$.#s=this.createDrawerInstance(r,a,c,d,h),$.#n=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties($.#n.toSVGProperties(),$.#s.defaultSVGProperties),!0,!1)}static _drawMove(t){if(j.isSameTimeStamp(t.timeStamp),!$.#s)return;const{offsetX:e,offsetY:s,pointerId:i}=t;if(j.isSamePointerId(i)){if(j.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#s.add(e,s)),j.setTimeStamp(t.timeStamp),Q(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,$.#s=null,$.#n=null,j.clearTimeStamp()),$.#i&&($.#i.abort(),$.#i=null,j.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,$.#s.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const s=$.#s,i=this._currentDrawId,n=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:B.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(B.DRAW_STEP),!$.#s.isEmpty()){const{pageDimensions:[s,i],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#s.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:$.#n,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r){G("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,i,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#a({drawOutlines:o}),l.#h(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return this.#t.serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Jr{#t=new Float64Array(6);#e;#s;#i;#n;#a;#r="";#o=0;#h=new be;#l;#u;constructor(t,e,s,i,n,r){this.#l=s,this.#u=i,this.#i=n,this.#n=r,[t,e]=this.#d(t,e);const a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e],this.#s=[{line:a,points:this.#a}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#n=e)}#d(t,e){return T._normalizePoint(t,e,this.#l,this.#u,this.#i)}isEmpty(){return!this.#s?.length}isCancellable(){return this.#a.length<=10}add(t,e){[t,e]=this.#d(t,e);const[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#l*a,this.#u*o)<=2?null:(this.#a.push(t,e),isNaN(s)?(this.#t.set([n,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,i,n,r,t,e],0),this.#e.push(...T.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){this.#l=s,this.#u=i,this.#i=n,[t,e]=this.#d(t,e);const r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e];const a=this.#s.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#s.push({line:r,points:this.#a}),this.#t.set(r,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#s.at(-1)}setLastElement(t){return this.#s?(this.#s.push(t),this.#e=t.line,this.#a=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(t)}removeLastElement(){if(!this.#s)return this.#h.removeLastElement();this.#s.pop(),this.#r="";for(let t=0,e=this.#s.length;t<e;t++){const{line:s,points:i}=this.#s[t];this.#e=s,this.#a=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#r}}}toSVGPath(){const t=T.svgRound(this.#e[4]),e=T.svgRound(this.#e[5]);if(this.#a.length===2)return this.#r=`${this.#r} M ${t} ${e} Z`,this.#r;if(this.#a.length<=6){const i=this.#r.lastIndexOf("M");this.#r=`${this.#r.slice(0,i)} M ${t} ${e}`,this.#o=6}if(this.#a.length===4){const i=T.svgRound(this.#e[10]),n=T.svgRound(this.#e[11]);return this.#r=`${this.#r} L ${i} ${n}`,this.#o=12,this.#r}const s=[];this.#o===0&&(s.push(`M ${t} ${e}`),this.#o=6);for(let i=this.#o,n=this.#e.length;i<n;i+=6){const[r,a,o,l,h,c]=this.#e.slice(i,i+6).map(T.svgRound);s.push(`C${r} ${a} ${o} ${l} ${h} ${c}`)}return this.#r+=s.join(" "),this.#o=this.#e.length,this.#r}getOutlines(t,e,s,i){const n=this.#s.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#s,t,e,s,this.#i,this.#n,i),this.#t=null,this.#e=null,this.#s=null,this.#r=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class be extends T{#t;#e=0;#s;#i;#n;#a;#r;#o;#h;build(t,e,s,i,n,r,a){this.#n=e,this.#a=s,this.#r=i,this.#o=n,this.#h=r,this.#s=a??0,this.#i=t,this.#d()}get thickness(){return this.#h}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#i){if(t.push(`M${T.svgRound(e[4])} ${T.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${T.svgRound(e[10])} ${T.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){const[n,r,a,o,l,h]=e.subarray(s,s+6).map(T.svgRound);t.push(`C${n} ${r} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,s,i],n){const r=[],a=[],[o,l,h,c]=this.#u();let d,f,p,g,m,b,y,A,w;switch(this.#o){case 0:w=T._rescale,d=t,f=e+i,p=s,g=-i,m=t+o*s,b=e+(1-l-c)*i,y=t+(o+h)*s,A=e+(1-l)*i;break;case 90:w=T._rescaleAndSwap,d=t,f=e,p=s,g=i,m=t+l*s,b=e+o*i,y=t+(l+c)*s,A=e+(o+h)*i;break;case 180:w=T._rescale,d=t+s,f=e,p=-s,g=i,m=t+(1-o-h)*s,b=e+l*i,y=t+(1-o)*s,A=e+(l+c)*i;break;case 270:w=T._rescaleAndSwap,d=t+s,f=e+i,p=-s,g=-i,m=t+(1-l-c)*s,b=e+(1-o-h)*i,y=t+(1-l)*s,A=e+(1-o)*i;break}for(const{line:v,points:S}of this.#i)r.push(w(v,d,f,p,g,n?new Array(v.length):null)),a.push(w(S,d,f,p,g,n?new Array(S.length):null));return{lines:r,points:a,rect:[m,b,y,A]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,f,p,g;switch(o){case 0:g=T._rescale,c=-t/s,d=e/i+1,f=1/s,p=-1/i;break;case 90:g=T._rescaleAndSwap,c=-e/i,d=-t/s,f=1/i,p=1/s;break;case 180:g=T._rescale,c=t/s+1,d=-e/i,f=-1/s,p=1/i;break;case 270:g=T._rescaleAndSwap,c=e/i+1,d=t/s+1,f=-1/i,p=-1/s;break}if(!r){r=[];for(const b of a){const y=b.length;if(y===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1]]));continue}if(y===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1],NaN,NaN,NaN,NaN,b[2],b[3]]));continue}const A=new Float32Array(3*(y-2));r.push(A);let[w,v,S,x]=b.subarray(0,4);A.set([NaN,NaN,NaN,NaN,w,v],0);for(let E=4;E<y;E+=2){const _=b[E],k=b[E+1];A.set(T.createBezierPoints(w,v,S,x,_,k),(E-2)*3),[w,v,S,x]=[S,x,_,k]}}}for(let b=0,y=r.length;b<y;b++)h.push({line:g(r[b].map(A=>A??NaN),c,d,f,p),points:g(a[b].map(A=>A??NaN),c,d,f,p)});const m=new this.prototype.constructor;return m.build(h,s,i,1,o,l,n),m}#l(t=this.#h){const e=this.#s+t/2*this.#r;return this.#o%180===0?[e/this.#n,e/this.#a]:[e/this.#a,e/this.#n]}#u(){const[t,e,s,i]=this.#t,[n,r]=this.#l(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){const t=this.#t=Bt.slice();for(const{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)C.pointBoundingBox(i[a],i[a+1],t);continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){const[l,h,c,d,f,p]=i.subarray(a,a+6);C.bezierBoundingBox(n,r,l,h,c,d,f,p,t),n=f,r=p}}const[e,s]=this.#l();t[0]=X(t[0]-e,0,1),t[1]=X(t[1]-s,0,1),t[2]=X(t[2]+e,0,1),t[3]=X(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#p(e):null}#p(t){const[e,s]=this.#l();this.#h=t;const[i,n]=this.#l(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){const[i,n]=this.#l();this.#n=t,this.#a=e,this.#r=s;const[r,a]=this.#l(),o=r-i,l=a-n,h=this.#t;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(T.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${T.svgRound(a)} ${T.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){const[n,r]=this.#l(),[a,o,l,h]=this.#t;if(Math.abs(l-n)<=T.PRECISION||Math.abs(h-r)<=T.PRECISION){const g=t+s/2-(a+l/2),m=e+i/2-(o+h/2);return{path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}const c=(s-2*n)/(l-2*n),d=(i-2*r)/(h-2*r),f=l/s,p=h/i;return{path:{"transform-origin":`${T.svgRound(a)} ${T.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${T.svgRound(n)} ${T.svgRound(r)}) scale(${c} ${d}) translate(${T.svgRound(-n)} ${T.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[n,r]=this.#l(),a=this.#t,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(h-n)<=T.PRECISION||Math.abs(c-r)<=T.PRECISION){const m=t+s/2-(o+h/2),b=e+i/2-(l+c/2);for(const{line:y,points:A}of this.#i)T._translate(y,m,b,y),T._translate(A,m,b,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(s-2*n)/(h-2*n),f=(i-2*r)/(c-2*r),p=-d*(o+n)+t+n,g=-f*(l+r)+e+r;if(d!==1||f!==1||p!==0||g!==0)for(const{line:m,points:b}of this.#i)T._rescale(m,p,g,d,f,m),T._rescale(b,p,g,d,f,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#n===i&&this.#a===n)for(const{line:l,points:h}of this.#i)T._translate(l,a,o,l),T._translate(h,a,o,h);else{const l=this.#n/i,h=this.#a/n;this.#n=i,this.#a=n;for(const{line:c,points:d}of this.#i)T._rescale(c,a,o,l,h,c),T._rescale(d,a,o,l,h,d);r[2]*=l,r[3]*=h}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${T.svgRound(t)} ${T.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${T.svgRound(t[0])} ${T.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Xe extends Bi{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:P._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Xe(this._viewParameters);return t.updateAll(this),t}}class Fs extends ${static _type="ink";static _editorType=R.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){P.initialize(t,e),this._defaultDrawingOptions=new Xe(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return D(this,"typesMap",new Map([[B.INK_THICKNESS,"stroke-width"],[B.INK_COLOR,"stroke"],[B.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new Jr(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return be.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof Is){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,opacity:c,borderStyle:{rawWidth:d},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:b},parent:{page:{pageNumber:y}}}=t;i=t={annotationType:R.INK,color:Array.from(h),thickness:d,opacity:c,paths:{points:r},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:b}}const n=await super.deserialize(t,e,s);return n._initialData=i,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new ue(this),[["colorPicker",this._colorPicker]]}get colorType(){return B.INK_COLOR}get colorAndOpacityType(){return B.INK_COLOR_AND_OPACITY}get opacityType(){return B.INK_OPACITY}updateParams(t,e){if(t===B.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===B.INK_COLOR_AND_OPACITY){super.updateDefaultParams(B.INK_COLOR,e.color),super.updateDefaultParams(B.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=Fs.getDefaultDrawingOptions({stroke:C.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:P._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class ys extends be{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Ee=8,se=3;class Kt{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,n,r,a){const o=this.#e(s,i,n,r);for(let l=0;l<8;l++){const h=(-l+o-a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#n(t,e,s,i,n,r,a){const o=this.#e(s,i,n,r);for(let l=0;l<8;l++){const h=(l+o+a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#a(t,e,s,i){const n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*s-1-h]=0;let a=1,o;const l=[];for(let h=1;h<s-1;h++){o=1;for(let c=1;c<e-1;c++){const d=h*e+c,f=r[d];if(f===0)continue;let p=h,g=c;if(f===1&&r[d-1]===0)a+=1,g-=1;else if(f>=1&&r[d+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}const m=[c,h],b=g===c+1,y={isHole:b,points:m,id:a,parent:0};l.push(y);let A;for(const M of l)if(M.id===o){A=M;break}A?A.isHole?y.parent=b?A.parent:o:y.parent=b?o:A.parent:y.parent=b?o:0;const w=this.#i(r,e,h,c,p,g,0);if(w===-1){r[d]=-a,r[d]!==1&&(o=Math.abs(r[d]));continue}let v=this.#s[2*w],S=this.#s[2*w+1];const x=h+v,E=c+S;p=x,g=E;let _=h,k=c;for(;;){const M=this.#n(r,e,_,k,p,g,1);v=this.#s[2*M],S=this.#s[2*M+1];const L=_+v,H=k+S;m.push(H,L);const U=_*e+k;if(r[U+1]===0?r[U]=-a:r[U]===1&&(r[U]=a),L===h&&H===c&&_===x&&k===E){r[d]!==1&&(o=Math.abs(r[d]));break}else p=_,g=k,_=L,k=H}}}return l}static#r(t,e,s,i){if(s-e<=4){for(let x=e;x<s-2;x+=2)i.push(t[x],t[x+1]);return}const n=t[e],r=t[e+1],a=t[s-4]-n,o=t[s-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,f=o/a,p=1/l,g=Math.atan(f),m=Math.cos(g),b=Math.sin(g),y=p*(Math.abs(m)+Math.abs(b)),A=p*(1-y+y**2),w=Math.max(Math.atan(Math.abs(b+m)*A),Math.atan(Math.abs(b-m)*A));let v=0,S=e;for(let x=e+2;x<s-2;x+=2){const E=Math.abs(d-h*t[x+1]+c*t[x]);E>v&&(S=x,v=E)}v>(l*w)**2?(this.#r(t,e,S+2,i),this.#r(t,S,s,i)):i.push(n,r)}static#o(t){const e=[],s=t.length;return this.#r(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#h(t,e,s,i,n,r){const a=new Float32Array(r**2),o=-2*i**2,l=r>>1;for(let g=0;g<r;g++){const m=(g-l)**2;for(let b=0;b<r;b++)a[g*r+b]=Math.exp((m+(b-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let g=0;g<256;g++)h[g]=Math.exp(g**2/c);const d=t.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let m=0;m<e;m++){const b=g*e+m,y=t[b];let A=0,w=0;for(let S=0;S<r;S++){const x=g+S-l;if(!(x<0||x>=s))for(let E=0;E<r;E++){const _=m+E-l;if(_<0||_>=e)continue;const k=t[x*e+_],M=a[S*r+E]*h[Math.abs(k-y)];A+=k*M,w+=M}}const v=f[b]=Math.round(A/w);p[v]++}return[f,p]}static#l(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}static#u(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,n=1/0;for(let a=0,o=s.length;a<o;a++){const l=s[a]=t[a<<2];i=Math.max(i,l),n=Math.min(n,l)}const r=255/(i-n);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-n)*r;return s}static#d(t){let e,s=-1/0,i=-1/0;const n=t.findIndex(o=>o!==0);let r=n,a=n;for(e=n;e<256;e++){const o=t[e];o>s&&(e-r>i&&(i=e-r,a=e-1),s=o,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#p(t){const e=t,{width:s,height:i}=t,{maxDim:n}=this.#t;let r=s,a=i;if(s>n||i>n){let d=s,f=i,p=Math.log2(Math.max(s,i)/n);const g=Math.floor(p);p=p===g?g-1:g;for(let b=0;b<p;b++){r=Math.ceil(d/2),a=Math.ceil(f/2);const y=new OffscreenCanvas(r,a);y.getContext("2d").drawImage(t,0,0,d,f,0,0,r,a),d=r,f=a,t!==e&&t.close(),t=y.transferToImageBitmap()}const m=Math.min(n/r,n/a);r=Math.round(r*m),a=Math.round(a*m)}const l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);const h=l.getImageData(0,0,r,a).data;return[this.#u(h),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=200,d=h.font=`${s} ${i} ${c}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:b,fontBoundingBoxDescent:y,width:A}=h.measureText(t),w=1.5,v=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,A)*w),S=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||c,Math.abs(b)+Math.abs(y)||c)*w);l=new OffscreenCanvas(v,S),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,v,S),h.fillStyle="black",h.fillText(t,v*(w-1)/2,S*(3-w)/2);const x=this.#u(h.getImageData(0,0,v,S).data),E=this.#l(x),_=this.#d(E),k=this.#a(x,v,S,_);return this.processDrawnLines({lines:{curves:k,width:v,height:S},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){const[r,a,o]=this.#p(t),[l,h]=this.#h(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),c=this.#d(h),d=this.#a(l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:a}){i%180!==0&&([e,s]=[s,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],f=Math.min(e/l,s/h),p=f/e,g=f/s,m=[];for(const{points:y}of o){const A=r?this.#o(y):y;if(!A)continue;m.push(A);const w=A.length,v=new Float32Array(w),S=new Float32Array(3*(w===2?2:w-2));if(d.push({line:S,points:v}),w===2){v[0]=A[0]*p,v[1]=A[1]*g,S.set([NaN,NaN,NaN,NaN,v[0],v[1]],0);continue}let[x,E,_,k]=A;x*=p,E*=g,_*=p,k*=g,v.set([x,E,_,k],0),S.set([NaN,NaN,NaN,NaN,x,E],0);for(let M=4;M<w;M+=2){const L=v[M]=A[M]*p,H=v[M+1]=A[M+1]*g;S.set(T.createBezierPoints(x,E,_,k,L,H),(M-2)*3),[x,E,_,k]=[_,k,L,H]}}if(d.length===0)return null;const b=a?new ys:new be;return b.build(d,e,s,1,i,a?0:c,n),{outline:b,newCurves:m,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=1/0,a=-1/0,o=0;for(const y of t){o+=y.length;for(let A=2,w=y.length;A<w;A++){const v=y[A]-y[A-2];r=Math.min(r,v),a=Math.max(a,v)}}let l;r>=-128&&a<=127?l=Int8Array:r>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const h=t.length,c=Ee+se*h,d=new Uint32Array(c);let f=0;d[f++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,d[f++]=0,d[f++]=i,d[f++]=n,d[f++]=e?0:1,d[f++]=Math.max(0,Math.floor(s??0)),d[f++]=h,d[f++]=l.BYTES_PER_ELEMENT;for(const y of t)d[f++]=y.length-2,d[f++]=y[0],d[f++]=y[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const m=l.prototype.constructor;for(const y of t){const A=new m(y.length-2);for(let w=2,v=y.length;w<v;w++)A[w-2]=y[w]-y[w-2];g.write(A)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(const A of s)r||=new Uint8Array(new Uint32Array(A.buffer,0,4)[0]),r.set(A,a),a+=A.length;const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const h=o[2],c=o[3],d=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],b=(Ee+se*p)*Uint32Array.BYTES_PER_ELEMENT;let y;switch(g){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(r.buffer,b);break}a=0;for(let A=0;A<p;A++){const w=o[se*A+Ee],v=new Float32Array(w+2);m.push(v);for(let S=0;S<se-1;S++)v[S]=o[se*A+Ee+S+1];for(let S=0;S<w;S++)v[S+2]=v[S]+y[a++]}return{areContours:d,thickness:f,outlines:m,width:h,height:c}}catch(e){return N(`decompressSignature: ${e}`),null}}}class Ls extends Bi{constructor(){super(),super.updateProperties({fill:P._defaultLineColor,"stroke-width":0})}clone(){const t=new Ls;return t.updateAll(this),t}}class Os extends Xe{constructor(t){super(t),super.updateProperties({stroke:P._defaultLineColor,"stroke-width":1})}clone(){const t=new Os(this._viewParameters);return t.updateAll(this),t}}class Et extends ${#t=!1;#e=null;#s=null;#i=null;static _type="signature";static _editorType=R.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){P.initialize(t,e),this._defaultDrawingOptions=new Ls,this._defaultDrawnSignatureOptions=new Os(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return D(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#s){const{lines:i,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:h,pageHeight:c},rotation:d}=this.parent.viewport,f=Kt.processDrawnLines({lines:i,pageWidth:h,pageHeight:c,rotation:d,innerMargin:Et._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(f,l,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#i=t,this.addEditToolbar()}getUuid(){return this.#i}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#s,r=Math.max(i,n),a=Kt.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){const{x:n,y:r}=this,{outline:a}=this.#s=t;this.#t=a instanceof ys,this.description=s;let o;this.#t?o=Et.getDefaultDrawingOptions():(o=Et._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Kt.process(t,e,s,i,Et._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Kt.extractContoursFromText(t,e,s,i,n,Et._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Kt.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:Et._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Et.getDefaultDrawingOptions():(this._drawingOptions=Et._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});return this.addComment(n),t?(n.paths={lines:e,points:s},n.uuid=this.#i,n.isCopy=!0):n.lines=e,this.#e&&(n.accessibilityData={type:"Figure",alt:this.#e}),n}static deserializeDraw(t,e,s,i,n,r){return r.areContours?ys.deserialize(t,e,s,i,n,r):be.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class Zr extends P{#t=null;#e=null;#s=null;#i=null;#n=null;#a="";#r=null;#o=!1;#h=null;#l=!1;#u=!1;static _type="stamp";static _editorType=R.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#i=t.bitmapUrl,this.#n=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){P.initialize(t,e)}static isHandlingMimeForPasting(t){return cs.includes(t)}static paste(t,e){e.pasteEditor({mode:R.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#l=t.isSvg),t.file&&(this.#a=t.file.name),this.#g()}#p(){if(this.#s=null,this._uiManager.enableWaiting(!1),!!this.#r){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{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()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.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.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#m(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#p());return}if(this.#i){const s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#d(i)).finally(()=>this.#p());return}if(this.#n){const s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#d(i)).finally(()=>this.#p());return}const t=document.createElement("input");t.type="file",t.accept=cs.join(",");const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#p()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#h&&(clearTimeout(this.#h),this.#h=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#m();return}super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#m(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#n||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#g():this.#m()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,i&&(this.#t=i),this.#o=!1,this.#g())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#h!==null&&clearTimeout(this.#h);const t=200;this.#h=setTimeout(()=>{this.#h=null,this.#f()},t)}#g(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const o=Math.min(r*i/e,r*n/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);const a=this.#r=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#f(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#a&&this.div.setAttribute("aria-description",this.#a),this.annotationElementId||this._uiManager.a11yAlert(P._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;const{width:i,height:n}=this.#t,r=new Tt;let a=this.#t,o=i,l=n,h=null;if(e){if(i>e||n>e){const S=Math.min(e/i,e/n);o=Math.floor(i*S),l=Math.floor(n*S)}h=document.createElement("canvas");const d=h.width=Math.ceil(o*r.sx),f=h.height=Math.ceil(l*r.sy);this.#l||(a=this.#c(d,f));const p=h.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":an.isDarkMode&&(g="#8f8f9d",m="#42414d");const b=15,y=b*r.sx,A=b*r.sy,w=new OffscreenCanvas(y*2,A*2),v=w.getContext("2d");v.fillStyle=g,v.fillRect(0,0,y*2,A*2),v.fillStyle=m,v.fillRect(0,0,y,A),v.fillRect(y,A,y,A),p.fillStyle=p.createPattern(w,"repeat"),p.fillRect(0,0,d,f),p.drawImage(a,0,0,a.width,a.height,0,0,d,f)}let c=null;if(s){let d,f;if(r.symmetric&&a.width<t&&a.height<t)d=a.width,f=a.height;else if(a=this.#t,i>t||n>t){const m=Math.min(t/i,t/n);d=Math.floor(i*m),f=Math.floor(n*m),this.#l||(a=this.#c(d,f))}const g=new OffscreenCanvas(d,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,d,f),c={width:d,height:f,data:g.getImageData(0,0,d,f).data}}return{canvas:h,width:o,height:l,imageData:c}}#c(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,l=r;n>2*t&&(n=Math.ceil(n/2)),r>2*e&&(r=Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=h.transferToImageBitmap()}return a}#f(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Tt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#r;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#l?this.#t:this.#c(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#y(t){if(t){if(this.#l){const i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#l){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*Zt.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*Zt.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof Oi){const{data:{rect:g,rotation:m,id:b,structParent:y,popupRef:A,richText:w,contentsObj:v,creationDate:S,modificationDate:x},container:E,parent:{page:{pageNumber:_}},canvas:k}=t;let M,L;k?(delete t.canvas,{id:M,bitmap:L}=s.imageManager.getFromCanvas(E.id,k),k.remove()):(n=!0,t._hasNoCanvas=!0);const H=(await e._structTree.getAriaAttributes(`${qt}${b}`))?.get("aria-label")||"";i=t={annotationType:R.STAMP,bitmapId:M,bitmap:L,pageIndex:_-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:H},isSvg:!1,structParent:y,popupRef:A,richText:w,comment:v?.str||null,creationDate:S,modificationDate:x}}const r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;n?(s.addMissingCanvas(t.id,r),r.#o=!0):h&&s.imageManager.isValidId(h)?(r.#e=h,o&&(r.#t=o)):r.#i=l,r.#l=c;const[f,p]=r.pageDimensions;return r.width=(a[2]-a[0])/f,r.height=(a[3]-a[1])/p,d&&(r.altTextData=d),r._initialData=i,t.comment&&r.setCommentData(t),r.#u=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#l});if(this.addComment(s),t)return s.bitmapUrl=this.#y(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const a=this.#A(s);return a.isSame?null:(a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1,s.id=this.annotationElementId,delete s.bitmapId,s)}if(e===null)return s;e.stamps||=new Map;const r=this.#l?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#y(!1);else if(this.#l){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#y(!1))}return s}#A(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Pt{#t;#e=!1;#s=null;#i=null;#n=null;#a=new Map;#r=!1;#o=!1;#h=!1;#l=null;#u=null;#d=null;#p=null;#m=null;#g=-1;#c;static _initialized=!1;static#f=new Map([nt,Fs,Zr,tt,Et].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const c=[...Pt.#f.values()];if(!Pt._initialized){Pt._initialized=!0;for(const d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#c=t,this.pageIndex=e,this.div=s,this.#t=n,this.#s=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=i,this.#c.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===R.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#v(),t){case R.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case R.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case R.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===R.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of Pt.#f.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#y(){return this.#a.size!==0?this.#a.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#h=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#m?.abort(),this.#m=null;const t=new Set;for(const s of this.#y)s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#c.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=this.#s;if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),this.#c.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}this.#h=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#m){this.#m=new AbortController;const i=this.#c.combinedSignal(this.#m);this.#d.div.addEventListener("pointerdown",n=>{const{clientX:a,clientY:o,timeStamp:l}=n,h=this.#g;if(l-h>500){this.#g=l;return}this.#g=-1;const{classList:c}=this.div;c.toggle("getElements",!0);const d=document.elementsFromPoint(a,o);if(c.toggle("getElements",!1),!this.div.contains(d[0]))return;let f;const p=new RegExp(`^${le}[0-9]+$`);for(const m of d)if(p.test(m.id)){f=m.id;break}if(!f)return;const g=this.#a.get(f);g?.annotationElementId===null&&(Q(n),g.dblclick(n))},{signal:i,capture:!0})}const t=this.#s,e=[];if(t){const i=new Map,n=new Map;for(const r of this.#y){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){i.set(r.annotationElementId,r);continue}else n.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(const r of t.getEditableAnnotations()){const{id:a}=r.data;if(this.#c.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=n.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}o=i.get(a),o&&(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(r)&&o.show(!1)),r.show()}}this.#v(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of Pt.#f.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#c.getActive()!==t&&this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#p){this.#p=new AbortController;const t=this.#c.combinedSignal(this.#p);this.#d.div.addEventListener("pointerdown",this.#A.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"))}#A(t){this.#c.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){const{isMac:s}=z.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#c.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),tt.startHighlighting(this,this.#c.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.#c._signal}),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;const t=this.#c.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#a.set(t.id,t);const{annotationElementId:e}=t;e&&this.#c.isDeletedAnnotationElement(e)&&this.#c.removeDeletedAnnotationElement(t)}detach(t){this.#a.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#c.addDeletedAnnotationElement(t),P.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)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#h),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#n&&(t._focusEventsAllowed=!1,this.#n=setTimeout(()=>{this.#n=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),e.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){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of this.#a.values())if(e.uid===t)return e;return null}get#b(){return Pt.#f.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#S(t){const e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);const{offsetX:s,offsetY:i}=this.#E(),n=this.#c.getId(),r=this.#S({parent:this,id:n,x:s,y:i,uiManager:this.#c,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await Pt.#f.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,s={}){const i=this.#c.getId(),n=this.#S({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...s});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#E(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(n+a)/2-t,h=(r+o)/2-e,[c,d]=this.viewport.rotation%180===0?[l,h]:[h,l];return{offsetX:c,offsetY:d}}addNewEditor(t={}){this.createAndAddNewEditor(this.#E(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){const{isMac:e}=z.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#r||(this.#r=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const s=this.#c.getMode();if(s===R.STAMP||s===R.POPUP||s===R.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===R.HIGHLIGHT&&this.enableTextSelection(),this.#r){this.#r=!1;return}const{isMac:e}=z.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#r=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}const s=this.#c.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#l){this.#b.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#l=new AbortController;const e=this.#c.combinedSignal(this.#l);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#b.startDrawing(this,this.#c,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#l?(this.#c.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#b.endDrawing(t)):null}findNewParent(t,e,s){const i=this.#c.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#b.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#c.getActive()?.parent===this&&(this.#c.commitOrRemove(),this.#c.setActiveEditor(null)),this.#n&&(clearTimeout(this.#n),this.#n=null);for(const t of this.#a.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#a.clear(),this.#c.removeLayer(this)}#v(){for(const t of this.#a.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,Ut(this.div,t);for(const e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#v();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Ut(this.div,{rotation:s}),e!==s)for(const i of this.#a.values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}}function ta(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Ce(u){return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):u.parentElement?.closest(".textLayer")||null:null}function ea(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function ci(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return s?.nodeType===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}class O{#t=null;#e=new Map;#s=null;#i=null;#n=null;#a=null;#r=new Map;static#o=0;static#h=0;static#l=null;static#u=new Set;static#d=!1;static#p=new Set;static#m=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#n=e,i){const n=O.#m.get(i);if(n?.selectionDiv&&(n.selectionDiv.remove(),O.#u.delete(n.selectionDiv)),O.#m.set(i,{drawLayer:this}),O.#p.add(i),this.#s=i,this.#a=new MutationObserver(r=>{if(!(!this.#t||!this.#s?.isConnected||!O.#c())){for(const{addedNodes:a}of r)for(const o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){O.#y();return}}}),this.#a.observe(i,{childList:!0}),O.#l===null){O.#l=new AbortController;const{signal:r}=O.#l;document.addEventListener("selectionchange",O.#y.bind(O),{signal:r}),document.addEventListener("pointerdown",()=>{O.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{O.#d=!1},{signal:r}),window.addEventListener("blur",()=>{O.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){this.#t=t,this.#s?.isConnected&&O.#c()&&O.#y();return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#g(t){const e=this.#m.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#c(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#f(){return this.#p.keys().filter(t=>t.isConnected).toArray().sort(ta)}static#y(){const t=document.getSelection();if(!t||t.isCollapsed){for(const r of this.#u)r.remove();this.#u.clear();return}const e=new WeakMap,s=this.#f(),i=[];for(let r=0,a=t.rangeCount;r<a;r++){const o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:h,endContainer:c,endOffset:d}=o,f=Ce(l),p=Ce(c);const g=f===null,m=p===null;if(this.#d&&g!==m)return;if(t.rangeCount===1){const{anchorNode:A,anchorOffset:w,focusNode:v,focusOffset:S}=t,x=Ce(A),E=Ce(v),_=ea(A,w,v,S);x&&E&&_!==null&&(_?(l=A,h=w,f=x,c=v,d=S,p=E):(l=v,h=S,f=E,c=A,d=w,p=x))}const b=s.filter(A=>o.intersectsNode(A));if(b.length===0)continue;let y=!1;if(f||(f=b[0],l=f,h=0,y=!0),p||(p=b.at(-1),c=p,d=p.childNodes.length,y=!0),c.nodeType===Node.ELEMENT_NODE){if(c.classList.contains("endOfContent")){const A=c.previousSibling;if(!A)continue;c=A,d=A.nodeType===Node.TEXT_NODE?A.textContent.length:A.childNodes.length}else if(c.classList.contains("textLayer")&&c.childNodes.length===d){const A=ci(c,d,p);if(!A)continue;c=A.container,d=A.offset}}if(l.nodeType===Node.ELEMENT_NODE){const A=ci(l,h,f);if(!A)continue;l=A.container,h=A.offset}if(f===p&&!y&&b.includes(f)){i.push([o,f]);continue}for(const A of b){const w=A.firstChild;if(!w)continue;const v=document.createRange();if(A===f?v.setStart(l,h):v.setStartBefore(w),A===p)v.setEnd(c,d);else{const S=A.lastChild;if(!S)continue;if(S.nodeType===Node.ELEMENT_NODE&&S.classList.contains("endOfContent")){const x=S.previousSibling;if(!x)continue;v.setEndAfter(x)}else v.setEndAfter(S)}v.collapsed||i.push([v,A])}}const n=new Set(i.map(r=>r[1]));for(const r of this.#p)n.has(r)||this.#g(r);for(const[r,a]of i){const o=O.#m.get(a);if(!o)continue;let l=e.get(a);if(!l){const p=a.getBoundingClientRect();l=(g,m,b,y)=>({x:(g-p.x)/p.width,y:(m-p.y)/p.height,width:b/p.width,height:y/p.height}),e.set(a,l)}const h=[];for(let{x:p,y:g,width:m,height:b}of r.getClientRects())m===0||b===0||({x:p,y:g,width:m,height:b}=l(p,g,m,b),!(m===1&&b===1)&&h.push(`M${p} ${g} h${m} v${b} h-${m} Z`));if(h.length===0)continue;const c=o.drawLayer;let d=o.selectionDiv,f=o.path;if(!d){const p=`clip_selection_${O.#h++}`;d=document.createElement("div"),d.className="selection",d.style.clipPath=`url(#${p})`;const g=c.#i?.createSelectionStyle(c.#n);if(g)for(const[y,A]of Object.entries(g))d.style.setProperty(y,A);const m=O._svgFactory.create(1,1,!0);m.setAttribute("aria-hidden","true"),m.setAttribute("width","100%"),m.setAttribute("height","100%");const b=O._svgFactory.createElement("clipPath");b.setAttribute("id",p),b.setAttribute("clipPathUnits","objectBoundingBox"),f=O._svgFactory.createElement("path"),b.append(f),m.append(b),d.append(m),o.path=f,o.selectionDiv=d}!d.parentNode&&c.#t&&(c.#t.append(d),this.#u.add(d)),f.setAttribute("d",h.join(" "))}}static get _svgFactory(){return D(this,"_svgFactory",new Ie)}static#A(t,[e,s,i,n]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#b(){const t=O._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#S(t,e){const s=O._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=O._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#E(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){const i=O.#o++,n=this.#b(),r=O._svgFactory.createElement("defs");n.append(r);const a=O._svgFactory.createElement("path");r.append(a);const o=`path_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#r.set(i,a);const l=s?this.#S(r,o):null,h=O._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(i,n),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){const s=O.#o++,i=this.#b(),n=O._svgFactory.createElement("defs");i.append(n);const r=O._svgFactory.createElement("path");n.append(r);const a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const c=O._svgFactory.createElement("mask");n.append(c),o=`mask_${s}`,c.setAttribute("id",o),c.setAttribute("maskUnits","objectBoundingBox");const d=O._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const f=O._svgFactory.createElement("use");c.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=O._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return i.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#E(a,s),i&&O.#A(a,i),n){const{classList:o}=a;for(const[l,h]of Object.entries(n))o.toggle(l,h)}if(r){const l=a.firstElementChild.firstElementChild;this.#E(l,r)}}}updateParent(t,e){if(e===this)return;const s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#r.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#r.clear(),this.#a?.disconnect(),this.#a=null,this.#s&&(O.#m.get(this.#s)?.drawLayer===this&&(O.#g(this.#s),O.#m.delete(this.#s),O.#p.delete(this.#s),O.#p.size===0&&(O.#l?.abort(),O.#l=null,O.#d=!1)),this.#s=null)}}function _e(u){return`${(u*100).toFixed(2)}%`}class De{#t=[];#e=new Map;#s=null;#i=0;#n=0;#a=0;static#r=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#n=s.rawDims.pageWidth,this.#a=s.rawDims.pageHeight,this.#s=i}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){const s=this.#o(this.#t.subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=this.#e.get(s);if(!i)return;const n=De.#r?.deref();if(n===s)return;n&&(n.width=0,n.height=0),De.#r=new WeakRef(s);const{inverseTransform:r,x1:a,y1:o,width:l,height:h}=i,c=this.#s(),d=Math.ceil(a*c.width),f=Math.ceil(o*c.height),p=Math.floor((a+l/this.#n)*c.width),g=Math.floor((o+h/this.#a)*c.height);s.width=p-d,s.height=g-f;const m=s.getContext("2d");m.setTransform(...r),m.translate(-d,-f),m.drawImage(c,0,0)}),t}#o([t,e,s,i,n,r]){const a=Math.hypot((n-t)*this.#n,(r-e)*this.#a),o=Math.hypot((s-t)*this.#n,(i-e)*this.#a);if(a<this.#i||o<this.#i)return null;const l=[(n-t)*this.#n/a,(r-e)*this.#a/a,(s-t)*this.#n/o,(i-e)*this.#a/o,0,0],h=C.inverseTransform(l),c=document.createElement("canvas");return c.className="textLayerImagePlaceholder",c.width=0,c.height=0,Object.assign(c.style,{opacity:0,position:"absolute",left:_e(t),top:_e(e),width:_e(a/this.#n),height:_e(o/this.#a),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(c,{inverseTransform:h,width:a,height:o,x1:t,y1:e}),c}}globalThis._pdfjsTestingUtils={HighlightOutliner:ms};globalThis.pdfjsLib={AbortException:Dt,AnnotationEditorLayer:Pt,AnnotationEditorParamsType:B,AnnotationEditorType:R,AnnotationEditorUIManager:Ft,AnnotationLayer:Ds,AnnotationMode:It,AnnotationType:q,applyOpacity:ln,build:kr,ColorPicker:At,createValidAbsoluteUrl:di,CSSConstants:on,DOMSVGFactory:Ie,DrawLayer:O,FeatureTest:z,fetchData:vs,findContrastColor:hn,getDocument:xr,getFilenameFromUrl:sn,getPdfFilenameFromUrl:nn,getRGB:me,getRGBA:ge,getUuid:fi,GlobalWorkerOptions:oe,ImageKind:Te,InvalidPDFException:os,isDataScheme:Ne,isPdfFile:Ss,isValidExplicitDest:In,makeArr:fe,makeMap:As,makeObj:ls,makeSet:Zi,MathClamp:X,noContextMenu:vt,normalizeUnicode:Qi,OPS:Ct,OutputScale:Tt,PasswordException:as,PasswordResponses:zi,PDFDataRangeTransport:Ii,PDFDateString:hs,PDFWorker:rt,PermissionFlag:ji,PixelsPerInch:Zt,RenderingCancelledException:ws,renderRichText:gi,ResponseException:Pe,setLayerDimensions:Ut,shadow:D,SignatureExtractor:Kt,stopEvent:Q,SupportedImageMimeTypes:cs,TextLayer:ft,TextLayerImages:De,TouchManager:Be,updateUrlHash:ui,Util:C,VerbosityLevel:Fe,version:Tr,XfaLayer:pi};const sa=""+new URL("pdf.worker.min-CHFwMXne.mjs",import.meta.url).href;export{oe as G,rt as P,xr as g,sa as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-DIM_KiG2.js";const a=e("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);export{a as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-DIM_KiG2.js";const t=e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);export{t as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c}from"./index-
|
|
1
|
+
import{c}from"./index-DIM_KiG2.js";const r=c("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);export{r as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./index-
|
|
1
|
+
import{c as a}from"./index-DIM_KiG2.js";const e=a("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);export{e as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as w,A as L}from"./index-DIM_KiG2.js";import{s as y,c as S}from"./ProjectWorkspace-iNqXZlsj.js";import"./react-BVUjbTTn.js";import"./check-C3GZh6a1.js";import"./x-CSzFikn2.js";import"./search-CrDJjHoj.js";import"./user-plus-gQ6q5Nom.js";import"./refresh-cw-CDFNL-qu.js";const k=5,f=new Map,C=12,x=S();let E=0;class p extends Error{constructor(){super("A newer writing check replaced this request."),this.name="HarperLintSupersededError"}}function I(e){return e instanceof p}function $(e){const t=[0];let r=0;for(const n of e)r+=n.length,t.push(r);return t}function d(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort((t,r)=>t.localeCompare(r)).join("\0")}async function v(e,t,r,n){try{return(await w(`/api/projects/${e}/spellcheck`,{method:"POST",body:JSON.stringify({path:t,source:r,clientId:x,sequence:n})})).lints}catch(o){throw o instanceof L&&o.code==="SPELLCHECK_SUPERSEDED"?new p:o}}function A(e,t,r){if(!t.problem)return null;const n={from:t.start,to:t.end},o={from:r[t.start]??-1,to:r[t.end]??-1},i=c=>c.from>=0&&c.to>c.from&&c.to<=e.length,a=c=>i(c)&&e.slice(c.from,c.to)===t.problem;return a(o)?o:a(n)?n:null}function H(e,t,r){const n=A(e,t,r);if(!n)return null;const{from:o,to:i}=n,a=e.slice(o,i);if(!a.trim()||!/[A-Za-z]/.test(a)||t.kind==="Formatting")return null;const c=t.kind==="Spelling"||t.kind==="Typo"?"spelling":"grammar",u=t.suggestions.filter((m,s,l)=>s<k&&l.indexOf(m)===s);return{from:o,to:i,word:a,kind:c,message:t.message,suggestions:u}}function h(e,t){let r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return`${e}\0${t.length}:${r>>>0}`}function g(e,t,r){const n=h(e,t),o=f.get(n);return!o||o.path!==e||o.source!==t||o.dictionary!==r?null:(f.delete(n),f.set(n,o),o.issues)}function R(e,t,r,n){const o=h(e,t);for(f.set(o,{path:e,source:t,dictionary:r,issues:n});f.size>C;){const i=f.keys().next().value;if(i===void 0)break;f.delete(i)}}async function b(e,t,r,n="main.tex"){const o=d(t),i=g(n,e,o);if(i)return i;const a=$(e),c=new Set(t.map(s=>s.trim().toLocaleLowerCase("en-US")).filter(Boolean)),u=new Set,m=r.map(s=>H(e,s,a)).filter(s=>!!s).filter(s=>s.kind!=="spelling"||!c.has(s.word.trim().toLocaleLowerCase("en-US"))).filter(s=>{const l=`${s.from}:${s.to}:${s.kind}`;return u.has(l)?!1:(u.add(l),!0)}).sort((s,l)=>s.from-l.from||s.to-l.to);return R(n,e,o,m),m}async function P(e,t,r,n){const o=d(n),i=g(t,r,o);if(i)return i;const a=await v(e,t,r,++E);return b(r,n,a,t)}function N(e,t,r,n=[]){return y(t)?P(e,t,r,n):Promise.resolve([])}export{p as HarperLintSupersededError,I as isHarperLintSupersededError,N as lintLatex,b as mapLatexLints};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./index-
|
|
1
|
+
import{c as a}from"./index-DIM_KiG2.js";const e=a("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);export{e as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-DIM_KiG2.js";const n=e("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);export{n as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-DIM_KiG2.js";const c=e("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);export{c as U};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./index-
|
|
1
|
+
import{c as a}from"./index-DIM_KiG2.js";const t=a("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const h=a("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const y=a("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);const k=a("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const d=a("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const c=a("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const p=a("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);const s=a("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);const r=a("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const l=a("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const o=a("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const n=a("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const M=a("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const i=a("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);const v=a("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const x=a("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const H=a("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);const m=a("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const u=a("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const q=a("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);const g=a("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const A=a("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);export{h as A,y as B,d as C,c as D,s as F,M as G,i as L,v as M,x as P,H as S,m as T,g as U,A as X,l as a,n as b,k as c,r as d,t as e,q as f,o as g,p as h,u as i};
|
package/dist/client/index.html
CHANGED
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="color-scheme" content="light" />
|
|
7
|
+
<base href="/" />
|
|
8
|
+
<meta name="texlite-base-path" content="/" />
|
|
7
9
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
10
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
11
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&family=Source+Code+Pro:wght@400;500;600&display=swap" />
|
|
10
12
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/iosevka@5.2.5/400.css" />
|
|
11
|
-
<link rel="icon" type="image/svg+xml" href="
|
|
13
|
+
<link rel="icon" type="image/svg+xml" href="logo.svg" />
|
|
12
14
|
<title>TexLite</title>
|
|
13
|
-
<script type="module" crossorigin src="
|
|
14
|
-
<link rel="modulepreload" crossorigin href="
|
|
15
|
-
<link rel="stylesheet" crossorigin href="
|
|
15
|
+
<script type="module" crossorigin src="./assets/index-DIM_KiG2.js"></script>
|
|
16
|
+
<link rel="modulepreload" crossorigin href="./assets/react-BVUjbTTn.js">
|
|
17
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CrlfruX_.css">
|
|
16
18
|
</head>
|
|
17
19
|
<body>
|
|
18
20
|
<div id="root"></div>
|