@quoreadmin/ui 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +15 -4
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -128,7 +128,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
128
128
|
`),position:b,pageIndex:y-1,rect:u.slice(0),rotation:f,id:h,deleted:!1,popupRef:p}}const s=await super.deserialize(t,r,i);return M(s,Hr,t.fontSize),M(s,Hi,ye.makeHexColor(...t.color)),M(s,zr,I(l=ut,Ps,g9).call(l,t.value)),s.annotationElementId=t.id||null,s._initialData=o,s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r=ut._internalPadding*this.parentScale,i=this.getRect(r,r),o=Ct._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:m(this,Hi)),s={annotationType:De.FREETEXT,color:o,fontSize:m(this,Hr),value:I(this,zt,CD).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?s:this.annotationElementId&&!I(this,zt,SD).call(this,s)?null:(s.id=this.annotationElementId,s)}renderAnnotationElement(t){const r=super.renderAnnotationElement(t);if(this.deleted)return r;const{style:i}=r;i.fontSize=`calc(${m(this,Hr)}px * var(--scale-factor))`,i.color=m(this,Hi),r.replaceChildren();for(const s of m(this,zr).split(`
|
|
129
129
|
`)){const l=document.createElement("div");l.append(s?document.createTextNode(s):document.createElement("br")),r.append(l)}const o=ut._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(o,o),popupContent:m(this,zr)}),r}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};Hi=new WeakMap,zr=new WeakMap,uh=new WeakMap,Yl=new WeakMap,Hr=new WeakMap,zt=new WeakSet,bD=function(t){const r=o=>{this.editorDiv.style.fontSize=`calc(${o}px * var(--scale-factor))`,this.translate(0,-(o-m(this,Hr))*this.parentScale),M(this,Hr,o),I(this,zt,jg).call(this)},i=m(this,Hr);this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},wD=function(t){const r=o=>{M(this,Hi,this.editorDiv.style.color=o)},i=m(this,Hi);this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},vD=function(){var i;const t=[];this.editorDiv.normalize();let r=null;for(const o of this.editorDiv.childNodes)((r==null?void 0:r.nodeType)!==Node.TEXT_NODE||o.nodeName!=="BR")&&(t.push(I(i=ut,Ps,zg).call(i,o)),r=o);return t.join(`
|
|
130
130
|
`)},jg=function(){const[t,r]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:o,div:s}=this,l=s.style.display,c=s.classList.contains("hidden");s.classList.remove("hidden"),s.style.display="hidden",o.div.append(this.div),i=s.getBoundingClientRect(),s.remove(),s.style.display=l,s.classList.toggle("hidden",c)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/r):(this.width=i.height/t,this.height=i.width/r),this.fixAndSetPosition()},Ps=new WeakSet,zg=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(im,"")},Hg=function(){if(this.editorDiv.replaceChildren(),m(this,zr))for(const t of m(this,zr).split(`
|
|
131
|
-
`)){const r=document.createElement("div");r.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(r)}},CD=function(){return m(this,zr).replaceAll(" "," ")},g9=function(t){return t.replaceAll(" "," ")},SD=function(t){const{value:r,fontSize:i,color:o,pageIndex:s}=this._initialData;return this._hasBeenMoved||t.value!==r||t.fontSize!==i||t.color.some((l,c)=>l!==o[c])||t.pageIndex!==s},T(ut,Ps),ve(ut,"_freeTextDefaultContent",""),ve(ut,"_internalPadding",0),ve(ut,"_defaultColor",null),ve(ut,"_defaultFontSize",10),ve(ut,"_type","freetext"),ve(ut,"_editorType",De.FREETEXT);let v6=ut;class de{toSVGPath(){ct("Abstract method `toSVGPath` must be implemented.")}get box(){ct("Abstract getter `box` must be implemented.")}serialize(e,t){ct("Abstract method `serialize` must be implemented.")}static _rescale(e,t,r,i,o,s){s||(s=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)s[l]=t+e[l]*i,s[l+1]=r+e[l+1]*o;return s}static _rescaleAndSwap(e,t,r,i,o,s){s||(s=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)s[l]=t+e[l+1]*i,s[l+1]=r+e[l]*o;return s}static _translate(e,t,r,i){i||(i=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)i[o]=t+e[o],i[o+1]=r+e[o+1];return i}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,r,i,o){switch(o){case 90:return[1-t/r,e/i];case 180:return[1-e/r,1-t/i];case 270:return[t/r,1-e/i];default:return[e/r,t/i]}}static _normalizePagePoint(e,t,r){switch(r){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,r,i,o,s){return[(e+5*r)/6,(t+5*i)/6,(5*r+o)/6,(5*i+s)/6,(r+o)/2,(i+s)/2]}}ve(de,"PRECISION",1e-4);const Ls=class Ls{constructor({x:e,y:t},r,i,o,s,l=0){T(this,Wt);T(this,Ur);T(this,Ui,[]);T(this,o1);T(this,s1);T(this,Do,[]);T(this,Re,new Float32Array(18));T(this,Ql);T(this,Xl);T(this,fh);T(this,hh);T(this,a1);T(this,l1);T(this,n0,[]);M(this,Ur,r),M(this,l1,o*i),M(this,s1,s),m(this,Re).set([NaN,NaN,NaN,NaN,e,t],6),M(this,o1,l),M(this,hh,m(Ls,ph)*i),M(this,fh,m(Ls,bg)*i),M(this,a1,i),m(this,n0).push(e,t)}isEmpty(){return isNaN(m(this,Re)[8])}add({x:e,y:t}){var E;M(this,Ql,e),M(this,Xl,t);const[r,i,o,s]=m(this,Ur);let[l,c,d,u]=m(this,Re).subarray(8,12);const f=e-d,h=t-u,p=Math.hypot(f,h);if(p<m(this,fh))return!1;const g=p-m(this,hh),b=g/p,y=b*f,w=b*h;let v=l,S=c;l=d,c=u,d+=y,u+=w,(E=m(this,n0))==null||E.push(e,t);const C=y/g,A=-w/g*m(this,l1),k=C*m(this,l1);return m(this,Re).set(m(this,Re).subarray(2,8),0),m(this,Re).set([d+A,u+k],4),m(this,Re).set(m(this,Re).subarray(14,18),12),m(this,Re).set([d-A,u-k],16),isNaN(m(this,Re)[6])?(m(this,Do).length===0&&(m(this,Re).set([l+A,c+k],2),m(this,Do).push(NaN,NaN,NaN,NaN,(l+A-r)/o,(c+k-i)/s),m(this,Re).set([l-A,c-k],14),m(this,Ui).push(NaN,NaN,NaN,NaN,(l-A-r)/o,(c-k-i)/s)),m(this,Re).set([v,S,l,c,d,u],6),!this.isEmpty()):(m(this,Re).set([v,S,l,c,d,u],6),Math.abs(Math.atan2(S-c,v-l)-Math.atan2(w,y))<Math.PI/2?([l,c,d,u]=m(this,Re).subarray(2,6),m(this,Do).push(NaN,NaN,NaN,NaN,((l+d)/2-r)/o,((c+u)/2-i)/s),[l,c,v,S]=m(this,Re).subarray(14,18),m(this,Ui).push(NaN,NaN,NaN,NaN,((v+l)/2-r)/o,((S+c)/2-i)/s),!0):([v,S,l,c,d,u]=m(this,Re).subarray(0,6),m(this,Do).push(((v+5*l)/6-r)/o,((S+5*c)/6-i)/s,((5*l+d)/6-r)/o,((5*c+u)/6-i)/s,((l+d)/2-r)/o,((c+u)/2-i)/s),[d,u,l,c,v,S]=m(this,Re).subarray(12,18),m(this,Ui).push(((v+5*l)/6-r)/o,((S+5*c)/6-i)/s,((5*l+d)/6-r)/o,((5*c+u)/6-i)/s,((l+d)/2-r)/o,((c+u)/2-i)/s),!0))}toSVGPath(){if(this.isEmpty())return"";const e=m(this,Do),t=m(this,Ui);if(isNaN(m(this,Re)[6])&&!this.isEmpty())return I(this,Wt,kD).call(this);const r=[];r.push(`M${e[4]} ${e[5]}`);for(let i=6;i<e.length;i+=6)isNaN(e[i])?r.push(`L${e[i+4]} ${e[i+5]}`):r.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);I(this,Wt,ED).call(this,r);for(let i=t.length-6;i>=6;i-=6)isNaN(t[i])?r.push(`L${t[i+4]} ${t[i+5]}`):r.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return I(this,Wt,MD).call(this,r),r.join(" ")}newFreeDrawOutline(e,t,r,i,o,s){return new Ak(e,t,r,i,o,s)}getOutlines(){var f;const e=m(this,Do),t=m(this,Ui),r=m(this,Re),[i,o,s,l]=m(this,Ur),c=new Float32Array((((f=m(this,n0))==null?void 0:f.length)??0)+2);for(let h=0,p=c.length-2;h<p;h+=2)c[h]=(m(this,n0)[h]-i)/s,c[h+1]=(m(this,n0)[h+1]-o)/l;if(c[c.length-2]=(m(this,Ql)-i)/s,c[c.length-1]=(m(this,Xl)-o)/l,isNaN(r[6])&&!this.isEmpty())return I(this,Wt,AD).call(this,c);const d=new Float32Array(m(this,Do).length+24+m(this,Ui).length);let u=e.length;for(let h=0;h<u;h+=2)isNaN(e[h])?d[h]=d[h+1]=NaN:(d[h]=e[h],d[h+1]=e[h+1]);u=I(this,Wt,ID).call(this,d,u);for(let h=t.length-6;h>=6;h-=6)for(let p=0;p<6;p+=2)isNaN(t[h+p])?(d[u]=d[u+1]=NaN,u+=2):(d[u]=t[h+p],d[u+1]=t[h+p+1],u+=2);return I(this,Wt,TD).call(this,d,u),this.newFreeDrawOutline(d,c,m(this,Ur),m(this,a1),m(this,o1),m(this,s1))}};Ur=new WeakMap,Ui=new WeakMap,o1=new WeakMap,s1=new WeakMap,Do=new WeakMap,Re=new WeakMap,Ql=new WeakMap,Xl=new WeakMap,fh=new WeakMap,hh=new WeakMap,a1=new WeakMap,l1=new WeakMap,n0=new WeakMap,ph=new WeakMap,yg=new WeakMap,bg=new WeakMap,Wt=new WeakSet,Fh=function(){const e=m(this,Re).subarray(4,6),t=m(this,Re).subarray(16,18),[r,i,o,s]=m(this,Ur);return[(m(this,Ql)+(e[0]-t[0])/2-r)/o,(m(this,Xl)+(e[1]-t[1])/2-i)/s,(m(this,Ql)+(t[0]-e[0])/2-r)/o,(m(this,Xl)+(t[1]-e[1])/2-i)/s]},kD=function(){const[e,t,r,i]=m(this,Ur),[o,s,l,c]=I(this,Wt,Fh).call(this);return`M${(m(this,Re)[2]-e)/r} ${(m(this,Re)[3]-t)/i} L${(m(this,Re)[4]-e)/r} ${(m(this,Re)[5]-t)/i} L${o} ${s} L${l} ${c} L${(m(this,Re)[16]-e)/r} ${(m(this,Re)[17]-t)/i} L${(m(this,Re)[14]-e)/r} ${(m(this,Re)[15]-t)/i} Z`},MD=function(e){const t=m(this,Ui);e.push(`L${t[4]} ${t[5]} Z`)},ED=function(e){const[t,r,i,o]=m(this,Ur),s=m(this,Re).subarray(4,6),l=m(this,Re).subarray(16,18),[c,d,u,f]=I(this,Wt,Fh).call(this);e.push(`L${(s[0]-t)/i} ${(s[1]-r)/o} L${c} ${d} L${u} ${f} L${(l[0]-t)/i} ${(l[1]-r)/o}`)},AD=function(e){const t=m(this,Re),[r,i,o,s]=m(this,Ur),[l,c,d,u]=I(this,Wt,Fh).call(this),f=new Float32Array(36);return f.set([NaN,NaN,NaN,NaN,(t[2]-r)/o,(t[3]-i)/s,NaN,NaN,NaN,NaN,(t[4]-r)/o,(t[5]-i)/s,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(t[16]-r)/o,(t[17]-i)/s,NaN,NaN,NaN,NaN,(t[14]-r)/o,(t[15]-i)/s],0),this.newFreeDrawOutline(f,e,m(this,Ur),m(this,a1),m(this,o1),m(this,s1))},TD=function(e,t){const r=m(this,Ui);return e.set([NaN,NaN,NaN,NaN,r[4],r[5]],t),t+6},ID=function(e,t){const r=m(this,Re).subarray(4,6),i=m(this,Re).subarray(16,18),[o,s,l,c]=m(this,Ur),[d,u,f,h]=I(this,Wt,Fh).call(this);return e.set([NaN,NaN,NaN,NaN,(r[0]-o)/l,(r[1]-s)/c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,(i[0]-o)/l,(i[1]-s)/c],t),t+24},T(Ls,ph,8),T(Ls,yg,2),T(Ls,bg,m(Ls,ph)+m(Ls,yg));let om=Ls;class Ak extends de{constructor(t,r,i,o,s,l){super();T(this,wg);T(this,c1);T(this,Jl,new Float32Array(4));T(this,Bs);T(this,mh);T(this,Zr);T(this,gh);T(this,Bt);M(this,Bt,t),M(this,Zr,r),M(this,c1,i),M(this,gh,o),M(this,Bs,s),M(this,mh,l),this.lastPoint=[NaN,NaN],I(this,wg,xD).call(this,l);const[c,d,u,f]=m(this,Jl);for(let h=0,p=t.length;h<p;h+=2)t[h]=(t[h]-c)/u,t[h+1]=(t[h+1]-d)/f;for(let h=0,p=r.length;h<p;h+=2)r[h]=(r[h]-c)/u,r[h+1]=(r[h+1]-d)/f}toSVGPath(){const t=[`M${m(this,Bt)[4]} ${m(this,Bt)[5]}`];for(let r=6,i=m(this,Bt).length;r<i;r+=6)isNaN(m(this,Bt)[r])?t.push(`L${m(this,Bt)[r+4]} ${m(this,Bt)[r+5]}`):t.push(`C${m(this,Bt)[r]} ${m(this,Bt)[r+1]} ${m(this,Bt)[r+2]} ${m(this,Bt)[r+3]} ${m(this,Bt)[r+4]} ${m(this,Bt)[r+5]}`);return t.push("Z"),t.join(" ")}serialize([t,r,i,o],s){const l=i-t,c=o-r;let d,u;switch(s){case 0:d=de._rescale(m(this,Bt),t,o,l,-c),u=de._rescale(m(this,Zr),t,o,l,-c);break;case 90:d=de._rescaleAndSwap(m(this,Bt),t,r,l,c),u=de._rescaleAndSwap(m(this,Zr),t,r,l,c);break;case 180:d=de._rescale(m(this,Bt),i,r,-l,c),u=de._rescale(m(this,Zr),i,r,-l,c);break;case 270:d=de._rescaleAndSwap(m(this,Bt),i,o,-l,-c),u=de._rescaleAndSwap(m(this,Zr),i,o,-l,-c)}return{outline:Array.from(d),points:[Array.from(u)]}}get box(){return m(this,Jl)}newOutliner(t,r,i,o,s,l=0){return new om(t,r,i,o,s,l)}getNewOutline(t,r){const[i,o,s,l]=m(this,Jl),[c,d,u,f]=m(this,c1),h=s*u,p=l*f,g=i*u+c,b=o*f+d,y=this.newOutliner({x:m(this,Zr)[0]*h+g,y:m(this,Zr)[1]*p+b},m(this,c1),m(this,gh),t,m(this,mh),r??m(this,Bs));for(let w=2;w<m(this,Zr).length;w+=2)y.add({x:m(this,Zr)[w]*h+g,y:m(this,Zr)[w+1]*p+b});return y.getOutlines()}}c1=new WeakMap,Jl=new WeakMap,Bs=new WeakMap,mh=new WeakMap,Zr=new WeakMap,gh=new WeakMap,Bt=new WeakMap,wg=new WeakSet,xD=function(t){const r=m(this,Bt);let i=r[4],o=r[5],s=i,l=o,c=i,d=o,u=i,f=o;const h=t?Math.max:Math.min;for(let g=6,b=r.length;g<b;g+=6){if(isNaN(r[g]))s=Math.min(s,r[g+4]),l=Math.min(l,r[g+5]),c=Math.max(c,r[g+4]),d=Math.max(d,r[g+5]),f<r[g+5]?(u=r[g+4],f=r[g+5]):f===r[g+5]&&(u=h(u,r[g+4]));else{const y=ye.bezierBoundingBox(i,o,...r.slice(g,g+6));s=Math.min(s,y[0]),l=Math.min(l,y[1]),c=Math.max(c,y[2]),d=Math.max(d,y[3]),f<y[3]?(u=y[2],f=y[3]):f===y[3]&&(u=h(u,y[2]))}i=r[g+4],o=r[g+5]}const p=m(this,Jl);p[0]=s-m(this,Bs),p[1]=l-m(this,Bs),p[2]=c-s+2*m(this,Bs),p[3]=d-l+2*m(this,Bs),this.lastPoint=[u,f]};class C6{constructor(e,t=0,r=0,i=!0){T(this,Xn);T(this,yh);T(this,bh);T(this,r0,[]);T(this,Zi,[]);let o=1/0,s=-1/0,l=1/0,c=-1/0;const d=10**-4;for(const{x:y,y:w,width:v,height:S}of e){const C=Math.floor((y-t)/d)*d,A=Math.ceil((y+v+t)/d)*d,k=Math.floor((w-t)/d)*d,E=Math.ceil((w+S+t)/d)*d,O=[C,k,E,!0],x=[A,k,E,!1];m(this,r0).push(O,x),o=Math.min(o,C),s=Math.max(s,A),l=Math.min(l,k),c=Math.max(c,E)}const u=s-o+2*r,f=c-l+2*r,h=o-r,p=l-r,g=m(this,r0).at(i?-1:-2),b=[g[0],g[2]];for(const y of m(this,r0)){const[w,v,S]=y;y[0]=(w-h)/u,y[1]=(v-p)/f,y[2]=(S-p)/f}M(this,yh,new Float32Array([h,p,u,f])),M(this,bh,b)}getOutlines(){m(this,r0).sort((t,r)=>t[0]-r[0]||t[1]-r[1]||t[2]-r[2]);const e=[];for(const t of m(this,r0))t[3]?(e.push(...I(this,Xn,y9).call(this,t)),I(this,Xn,DD).call(this,t)):(I(this,Xn,ND).call(this,t),e.push(...I(this,Xn,y9).call(this,t)));return I(this,Xn,OD).call(this,e)}}yh=new WeakMap,bh=new WeakMap,r0=new WeakMap,Zi=new WeakMap,Xn=new WeakSet,OD=function(e){const t=[],r=new Set;for(const s of e){const[l,c,d]=s;t.push([l,c,s],[l,d,s])}t.sort((s,l)=>s[1]-l[1]||s[0]-l[0]);for(let s=0,l=t.length;s<l;s+=2){const c=t[s][2],d=t[s+1][2];c.push(d),d.push(c),r.add(c),r.add(d)}const i=[];let o;for(;r.size>0;){const s=r.values().next().value;let[l,c,d,u,f]=s;r.delete(s);let h=l,p=c;for(o=[l,d],i.push(o);;){let g;if(r.has(u))g=u;else{if(!r.has(f))break;g=f}r.delete(g),[l,c,d,u,f]=g,h!==l&&(o.push(h,p,l,p===c?c:d),h=l),p=p===c?d:c}o.push(h,p)}return new zU(i,m(this,yh),m(this,bh))},Ug=function(e){const t=m(this,Zi);let r=0,i=t.length-1;for(;r<=i;){const o=r+i>>1,s=t[o][0];if(s===e)return o;s<e?r=o+1:i=o-1}return i+1},DD=function([,e,t]){const r=I(this,Xn,Ug).call(this,e);m(this,Zi).splice(r,0,[e,t])},ND=function([,e,t]){const r=I(this,Xn,Ug).call(this,e);for(let i=r;i<m(this,Zi).length;i++){const[o,s]=m(this,Zi)[i];if(o!==e)break;if(o===e&&s===t){m(this,Zi).splice(i,1);return}}for(let i=r-1;i>=0;i--){const[o,s]=m(this,Zi)[i];if(o!==e)break;if(o===e&&s===t){m(this,Zi).splice(i,1);return}}},y9=function(e){const[t,r,i]=e,o=[[t,r,i]],s=I(this,Xn,Ug).call(this,i);for(let l=0;l<s;l++){const[c,d]=m(this,Zi)[l];for(let u=0,f=o.length;u<f;u++){const[,h,p]=o[u];if(!(d<=h||p<=c))if(h>=c)if(p>d)o[u][1]=d;else{if(f===1)return[];o.splice(u,1),u--,f--}else o[u][2]=c,p>d&&o.push([t,d,p])}}return o};class zU extends de{constructor(t,r,i){super();T(this,wh);T(this,d1);M(this,d1,t),M(this,wh,r),this.lastPoint=i}toSVGPath(){const t=[];for(const r of m(this,d1)){let[i,o]=r;t.push(`M${i} ${o}`);for(let s=2;s<r.length;s+=2){const l=r[s],c=r[s+1];l===i?(t.push(`V${c}`),o=c):c===o&&(t.push(`H${l}`),i=l)}t.push("Z")}return t.join(" ")}serialize([t,r,i,o],s){const l=[],c=i-t,d=o-r;for(const u of m(this,d1)){const f=new Array(u.length);for(let h=0;h<u.length;h+=2)f[h]=t+u[h]*c,f[h+1]=o-u[h+1]*d;l.push(f)}return l}get box(){return m(this,wh)}get classNamesForOutlining(){return["highlightOutline"]}}wh=new WeakMap,d1=new WeakMap;class S6 extends om{newFreeDrawOutline(e,t,r,i,o,s){return new HU(e,t,r,i,o,s)}}class HU extends Ak{newOutliner(e,t,r,i,o,s=0){return new S6(e,t,r,i,o,s)}}const Mr=class Mr{constructor({editor:e=null,uiManager:t=null}){T(this,st);T(this,Wi,null);T(this,e2,null);T(this,u1);T(this,Gt,null);T(this,vh,!1);T(this,f1,!1);T(this,Ch,null);T(this,Sh);T(this,i0,null);T(this,Gi,null);T(this,h1);var r;e?(M(this,f1,!1),M(this,h1,Ve.HIGHLIGHT_COLOR),M(this,Ch,e)):(M(this,f1,!0),M(this,h1,Ve.HIGHLIGHT_DEFAULT_COLOR)),M(this,Gi,(e==null?void 0:e._uiManager)||t),M(this,Sh,m(this,Gi)._eventBus),M(this,u1,(e==null?void 0:e.color)||((r=m(this,Gi))==null?void 0:r.highlightColors.values().next().value)||"#FFFF98"),m(Mr,kh)||M(Mr,kh,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return _e(this,"_keyboardManager",new Ld([[["Escape","mac+Escape"],Mr.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Mr.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Mr.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Mr.prototype._moveToPrevious],[["Home","mac+Home"],Mr.prototype._moveToBeginning],[["End","mac+End"],Mr.prototype._moveToEnd]]))}renderButton(){const e=M(this,Wi,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=m(this,Gi)._signal;e.addEventListener("click",I(this,st,g2).bind(this),{signal:t}),e.addEventListener("keydown",I(this,st,v9).bind(this),{signal:t});const r=M(this,e2,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=m(this,u1),e.append(r),e}renderMainDropdown(){const e=M(this,Gt,I(this,st,b9).call(this));return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}_colorSelectFromKeyboard(e){if(e.target===m(this,Wi)){I(this,st,g2).call(this,e);return}const t=e.target.getAttribute("data-color");t&&I(this,st,w9).call(this,t,e)}_moveToNext(e){var t,r;m(this,st,m0)?e.target!==m(this,Wi)?(t=e.target.nextSibling)==null||t.focus():(r=m(this,Gt).firstChild)==null||r.focus():I(this,st,g2).call(this,e)}_moveToPrevious(e){var t,r;e.target!==((t=m(this,Gt))==null?void 0:t.firstChild)&&e.target!==m(this,Wi)?(m(this,st,m0)||I(this,st,g2).call(this,e),(r=e.target.previousSibling)==null||r.focus()):m(this,st,m0)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){var t;m(this,st,m0)?(t=m(this,Gt).firstChild)==null||t.focus():I(this,st,g2).call(this,e)}_moveToEnd(e){var t;m(this,st,m0)?(t=m(this,Gt).lastChild)==null||t.focus():I(this,st,g2).call(this,e)}hideDropdown(){var e,t;(e=m(this,Gt))==null||e.classList.add("hidden"),(t=m(this,i0))==null||t.abort(),M(this,i0,null)}_hideDropdownFromKeyboard(){var e;m(this,f1)||(m(this,st,m0)?(this.hideDropdown(),m(this,Wi).focus({preventScroll:!0,focusVisible:m(this,vh)})):(e=m(this,Ch))==null||e.unselect())}updateColor(e){if(m(this,e2)&&(m(this,e2).style.backgroundColor=e),!m(this,Gt))return;const t=m(this,Gi).highlightColors.values();for(const r of m(this,Gt).children)r.setAttribute("aria-selected",t.next().value===e)}destroy(){var e,t;(e=m(this,Wi))==null||e.remove(),M(this,Wi,null),M(this,e2,null),(t=m(this,Gt))==null||t.remove(),M(this,Gt,null)}};Wi=new WeakMap,e2=new WeakMap,u1=new WeakMap,Gt=new WeakMap,vh=new WeakMap,f1=new WeakMap,Ch=new WeakMap,Sh=new WeakMap,i0=new WeakMap,Gi=new WeakMap,h1=new WeakMap,kh=new WeakMap,st=new WeakSet,b9=function(){const e=document.createElement("div"),t=m(this,Gi)._signal;e.addEventListener("contextmenu",Di,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[r,i]of m(this,Gi).highlightColors){const o=document.createElement("button");o.tabIndex="0",o.role="option",o.setAttribute("data-color",i),o.title=r,o.setAttribute("data-l10n-id",m(Mr,kh)[r]);const s=document.createElement("span");o.append(s),s.className="swatch",s.style.backgroundColor=i,o.setAttribute("aria-selected",i===m(this,u1)),o.addEventListener("click",I(this,st,w9).bind(this,i),{signal:t}),e.append(o)}return e.addEventListener("keydown",I(this,st,v9).bind(this),{signal:t}),e},w9=function(e,t){t.stopPropagation(),m(this,Sh).dispatch("switchannotationeditorparams",{source:this,type:m(this,h1),value:e})},v9=function(e){Mr._keyboardManager.exec(this,e)},g2=function(e){if(m(this,st,m0)){this.hideDropdown();return}if(M(this,vh,e.detail===0),m(this,i0)||(M(this,i0,new AbortController),window.addEventListener("pointerdown",I(this,st,PD).bind(this),{signal:m(this,Gi).combinedSignal(m(this,i0))})),m(this,Gt)){m(this,Gt).classList.remove("hidden");return}const t=M(this,Gt,I(this,st,b9).call(this));m(this,Wi).append(t)},PD=function(e){var t;(t=m(this,Gt))!=null&&t.contains(e.target)||this.hideDropdown()},m0=function(){return m(this,Gt)&&!m(this,Gt).classList.contains("hidden")},T(Mr,kh,null);let sm=Mr;const Ye=class Ye extends Ct{constructor(t){super({...t,name:"highlightEditor"});T(this,xe);T(this,p1,null);T(this,Mh,0);T(this,_s);T(this,t2,null);T(this,m1,null);T(this,Er,null);T(this,Eh,null);T(this,Ah,0);T(this,n2,null);T(this,bi,null);T(this,Wr,null);T(this,vn,!1);T(this,g1,null);T(this,Rs);T(this,Bn,null);T(this,y1,"");T(this,wi);T(this,Th,"");this.color=t.color||Ye._defaultColor,M(this,wi,t.thickness||Ye._defaultThickness),M(this,Rs,t.opacity||Ye._defaultOpacity),M(this,_s,t.boxes||null),M(this,Th,t.methodOfCreation||""),M(this,y1,t.text||""),this._isDraggable=!1,t.highlightId>-1?(M(this,vn,!0),I(this,xe,Zg).call(this,t),I(this,xe,y2).call(this)):m(this,_s)&&(M(this,p1,t.anchorNode),M(this,Mh,t.anchorOffset),M(this,Eh,t.focusNode),M(this,Ah,t.focusOffset),I(this,xe,C9).call(this),I(this,xe,y2).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=Ye.prototype;return _e(this,"_keyboardManager",new Ld([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:m(this,vn)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:m(this,wi),methodOfCreation:m(this,Th)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,r){var i;Ct.initialize(t,r),Ye._defaultColor||(Ye._defaultColor=((i=r.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,r){switch(t){case Ve.HIGHLIGHT_DEFAULT_COLOR:Ye._defaultColor=r;break;case Ve.HIGHLIGHT_THICKNESS:Ye._defaultThickness=r}}translateInPage(t,r){}get toolbarPosition(){return m(this,g1)}updateParams(t,r){switch(t){case Ve.HIGHLIGHT_COLOR:I(this,xe,LD).call(this,r);break;case Ve.HIGHLIGHT_THICKNESS:I(this,xe,BD).call(this,r)}}static get defaultPropertiesToUpdate(){return[[Ve.HIGHLIGHT_DEFAULT_COLOR,Ye._defaultColor],[Ve.HIGHLIGHT_THICKNESS,Ye._defaultThickness]]}get propertiesToUpdate(){return[[Ve.HIGHLIGHT_COLOR,this.color||Ye._defaultColor],[Ve.HIGHLIGHT_THICKNESS,m(this,wi)||Ye._defaultThickness],[Ve.HIGHLIGHT_FREE,m(this,vn)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(M(this,m1,new sm({editor:this})),t.addColorPicker(m(this,m1))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(I(this,xe,jh).call(this))}getBaseTranslation(){return[0,0]}getRect(t,r){return super.getRect(t,r,I(this,xe,jh).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){I(this,xe,S9).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,xe,y2).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?I(this,xe,S9).call(this):t&&(I(this,xe,y2).call(this,t),r=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),r&&this.select()}rotate(t){var o,s,l;const{drawLayer:r}=this.parent;let i;m(this,vn)?(t=(t-this.rotation+360)%360,i=I(o=Ye,vi,R1).call(o,m(this,bi).box,t)):i=I(s=Ye,vi,R1).call(s,[this.x,this.y,this.width,this.height],t),r.updateProperties(m(this,Wr),{bbox:i,root:{"data-main-rotation":t}}),r.updateProperties(m(this,Bn),{bbox:I(l=Ye,vi,R1).call(l,m(this,Er).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();m(this,y1)&&(t.setAttribute("aria-label",m(this,y1)),t.setAttribute("role","mark")),m(this,vn)?t.classList.add("free"):this.div.addEventListener("keydown",I(this,xe,RD).bind(this),{signal:this._uiManager._signal});const r=M(this,n2,document.createElement("div"));t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",r.style.clipPath=m(this,t2);const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),Kp(this,m(this,n2),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:I(this,xe,Wg).call(this,!0);break;case 1:case 3:I(this,xe,Wg).call(this,!1)}}select(){var t;super.select(),m(this,Bn)&&((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),m(this,Bn)&&((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{selected:!1}}),m(this,vn)||I(this,xe,Wg).call(this,!1))}get _mustFixPosition(){return!m(this,vn)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(m(this,Wr),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(m(this,Bn),{rootClass:{hidden:!t}}))}static startHighlighting(t,r,{target:i,x:o,y:s}){const{x:l,y:c,width:d,height:u}=i.getBoundingClientRect(),f=new AbortController,h=t.combinedSignal(f),p=g=>{f.abort(),I(this,vi,jD).call(this,t,g)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",Ir,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",Di,{signal:h}),i.addEventListener("pointermove",I(this,vi,FD).bind(this,t),{signal:h}),this._freeHighlight=new S6({x:o,y:s},[l,c,d,u],t.scale,this._defaultThickness/2,r,.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 async deserialize(t,r,i){var b,y,w,v;let o=null;if(t instanceof Mk){const{data:{quadPoints:S,rect:C,rotation:A,id:k,color:E,opacity:O,popupRef:x},parent:{page:{pageNumber:N}}}=t;o=t={annotationType:De.HIGHLIGHT,color:Array.from(E),opacity:O,quadPoints:S,boxes:null,pageIndex:N-1,rect:C.slice(0),rotation:A,id:k,deleted:!1,popupRef:x}}else if(t instanceof w6){const{data:{inkLists:S,rect:C,rotation:A,id:k,color:E,borderStyle:{rawWidth:O},popupRef:x},parent:{page:{pageNumber:N}}}=t;o=t={annotationType:De.HIGHLIGHT,color:Array.from(E),thickness:O,inkLists:S,boxes:null,pageIndex:N-1,rect:C.slice(0),rotation:A,id:k,deleted:!1,popupRef:x}}const{color:s,quadPoints:l,inkLists:c,opacity:d}=t,u=await super.deserialize(t,r,i);u.color=ye.makeHexColor(...s),M(u,Rs,d||1),c&&M(u,wi,t.thickness),u.annotationElementId=t.id||null,u._initialData=o;const[f,h]=u.pageDimensions,[p,g]=u.pageTranslation;if(l){const S=M(u,_s,[]);for(let C=0;C<l.length;C+=8)S.push({x:(l[C]-p)/f,y:1-(l[C+1]-g)/h,width:(l[C+2]-l[C])/f,height:(l[C+1]-l[C+5])/h});I(b=u,xe,C9).call(b),I(y=u,xe,y2).call(y),u.rotate(u.rotation)}else if(c){M(u,vn,!0);const S=c[0],C={x:S[0]-p,y:h-(S[1]-g)},A=new S6(C,[0,0,f,h],1,m(u,wi)/2,!0,.001);for(let O=0,x=S.length;O<x;O+=2)C.x=S[O]-p,C.y=h-(S[O+1]-g),A.add(C);const{id:k,clipPathId:E}=r.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:A.toSVGPath()}},!0,!0);I(w=u,xe,Zg).call(w,{highlightOutlines:A.getOutlines(),highlightId:k,clipPathId:E}),I(v=u,xe,y2).call(v)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const r=this.getRect(0,0),i=Ct._colorManager.convert(this.color),o={annotationType:De.HIGHLIGHT,color:i,opacity:m(this,Rs),thickness:m(this,wi),quadPoints:I(this,xe,VD).call(this),outlines:I(this,xe,$D).call(this,r),pageIndex:this.pageIndex,rect:r,rotation:I(this,xe,jh).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!I(this,xe,zD).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};p1=new WeakMap,Mh=new WeakMap,_s=new WeakMap,t2=new WeakMap,m1=new WeakMap,Er=new WeakMap,Eh=new WeakMap,Ah=new WeakMap,n2=new WeakMap,bi=new WeakMap,Wr=new WeakMap,vn=new WeakMap,g1=new WeakMap,Rs=new WeakMap,Bn=new WeakMap,y1=new WeakMap,wi=new WeakMap,Th=new WeakMap,xe=new WeakSet,C9=function(){const t=new C6(m(this,_s),.001);M(this,bi,t.getOutlines()),[this.x,this.y,this.width,this.height]=m(this,bi).box;const r=new C6(m(this,_s),.0025,.001,this._uiManager.direction==="ltr");M(this,Er,r.getOutlines());const{lastPoint:i}=m(this,Er);M(this,g1,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Zg=function({highlightOutlines:t,highlightId:r,clipPathId:i}){var u,f;if(M(this,bi,t),M(this,Er,t.getNewOutline(m(this,wi)/2+1.5,.0025)),r>=0)M(this,Wr,r),M(this,t2,i),this.parent.drawLayer.finalizeDraw(r,{bbox:t.box,path:{d:t.toSVGPath()}}),M(this,Bn,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:m(this,Er).box,path:{d:m(this,Er).toSVGPath()}},!0));else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(m(this,Wr),{bbox:I(u=Ye,vi,R1).call(u,m(this,bi).box,(h-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(m(this,Bn),{bbox:I(f=Ye,vi,R1).call(f,m(this,Er).box,h),path:{d:m(this,Er).toSVGPath()}})}const[o,s,l,c]=t.box;switch(this.rotation){case 0:this.x=o,this.y=s,this.width=l,this.height=c;break;case 90:{const[h,p]=this.parentDimensions;this.x=s,this.y=1-o,this.width=l*p/h,this.height=c*h/p;break}case 180:this.x=1-o,this.y=1-s,this.width=l,this.height=c;break;case 270:{const[h,p]=this.parentDimensions;this.x=1-s,this.y=o,this.width=l*p/h,this.height=c*h/p;break}}const{lastPoint:d}=m(this,Er);M(this,g1,[(d[0]-o)/l,(d[1]-s)/c])},LD=function(t){const r=(s,l)=>{var c,d;this.color=s,M(this,Rs,l),(c=this.parent)==null||c.drawLayer.updateProperties(m(this,Wr),{root:{fill:s,"fill-opacity":l}}),(d=m(this,m1))==null||d.updateColor(s)},i=this.color,o=m(this,Rs);this.addCommands({cmd:r.bind(this,t,Ye._defaultOpacity),undo:r.bind(this,i,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},BD=function(t){const r=m(this,wi),i=o=>{M(this,wi,o),I(this,xe,_D).call(this,o)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},_D=function(t){if(!m(this,vn))return;I(this,xe,Zg).call(this,{highlightOutlines:m(this,bi).getNewOutline(t/2)}),this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)},S9=function(){m(this,Wr)!==null&&this.parent&&(this.parent.drawLayer.remove(m(this,Wr)),M(this,Wr,null),this.parent.drawLayer.remove(m(this,Bn)),M(this,Bn,null))},y2=function(t=this.parent){m(this,Wr)===null&&({id:ir(this,Wr)._,clipPathId:ir(this,t2)._}=t.drawLayer.draw({bbox:m(this,bi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":m(this,Rs)},rootClass:{highlight:!0,free:m(this,vn)},path:{d:m(this,bi).toSVGPath()}},!1,!0),M(this,Bn,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:m(this,vn)},bbox:m(this,Er).box,path:{d:m(this,Er).toSVGPath()}},m(this,vn))),m(this,n2)&&(m(this,n2).style.clipPath=m(this,t2)))},vi=new WeakSet,R1=function([t,r,i,o],s){switch(s){case 90:return[1-r-o,t,o,i];case 180:return[1-t-i,1-r-o,i,o];case 270:return[r,1-t-i,o,i]}return[t,r,i,o]},RD=function(t){Ye._keyboardManager.exec(this,t)},Wg=function(t){if(!m(this,p1))return;const r=window.getSelection();t?r.setPosition(m(this,p1),m(this,Mh)):r.setPosition(m(this,Eh),m(this,Ah))},jh=function(){return m(this,vn)?this.rotation:0},VD=function(){if(m(this,vn))return null;const[t,r]=this.pageDimensions,[i,o]=this.pageTranslation,s=m(this,_s),l=new Float32Array(8*s.length);let c=0;for(const{x:d,y:u,width:f,height:h}of s){const p=d*t+i,g=(1-u)*r+o;l[c]=l[c+4]=p,l[c+1]=l[c+3]=g,l[c+2]=l[c+6]=p+f*t,l[c+5]=l[c+7]=g-h*r,c+=8}return l},$D=function(t){return m(this,bi).serialize(t,I(this,xe,jh).call(this))},FD=function(t,r){this._freeHighlight.add(r)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},jD=function(t,r){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(r,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},zD=function(t){const{color:r}=this._initialData;return t.color.some((i,o)=>i!==r[o])},T(Ye,vi),ve(Ye,"_defaultColor",null),ve(Ye,"_defaultOpacity",1),ve(Ye,"_defaultThickness",12),ve(Ye,"_type","highlight"),ve(Ye,"_editorType",De.HIGHLIGHT),ve(Ye,"_freeHighlightId",-1),ve(Ye,"_freeHighlight",null),ve(Ye,"_freeHighlightClipId","");let am=Ye;class UU{constructor(){T(this,r2,Object.create(null))}updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,r]of Object.entries(e))this.updateProperty(t,r)}updateSVGProperty(e,t){m(this,r2)[e]=t}toSVGProperties(){const e=m(this,r2);return M(this,r2,Object.create(null)),{root:e}}reset(){M(this,r2,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){ct("Not implemented")}}r2=new WeakMap;const ue=class ue extends Ct{constructor(t){super(t);T(this,He);T(this,Gr,null);T(this,b1);ve(this,"_drawId",null);M(this,b1,t.mustBeCommitted||!1),t.drawOutlines&&(I(this,He,k9).call(this,t),I(this,He,zh).call(this))}static _mergeSVGProperties(t,r){const i=new Set(Object.keys(t));for(const[o,s]of Object.entries(r))i.has(o)?Object.assign(t[o],s):t[o]=s;return t}static getDefaultDrawingOptions(t){ct("Not implemented")}static get typesMap(){ct("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,r){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,r),this._currentParent&&(m(ue,an).updateProperty(i,r),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,r){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,r)}static get defaultPropertiesToUpdate(){const t=[],r=this._defaultDrawingOptions;for(const[i,o]of this.typesMap)t.push([i,r[o]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:r}=this;for(const[i,o]of this.constructor.typesMap)t.push([i,r[o]]);return t}_updateProperty(t,r,i){const o=this._drawingOptions,s=o[r],l=c=>{var u;o.updateProperty(r,c);const d=m(this,Gr).updateProperty(r,c);d&&I(this,He,Hh).call(this,d),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,o.toSVGProperties())};this.addCommands({cmd:l.bind(this,i),undo:l.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathResizingSVGProperties(I(this,He,Gg).call(this)),{bbox:I(this,He,V1).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathResizedSVGProperties(I(this,He,Gg).call(this)),{bbox:I(this,He,V1).call(this)}))}_onTranslating(t,r){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:I(this,He,V1).call(this,t,r)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathTranslatedSVGProperties(I(this,He,Gg).call(this),this.parentDimensions),{bbox:I(this,He,V1).call(this)}))}_onStartDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;(t=this.parent)==null||t.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,m(this,b1)&&(M(this,b1,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){I(this,He,E9).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,He,zh).call(this),I(this,He,Hh).call(this,m(this,Gr).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),I(this,He,E9).call(this)):t&&(this._uiManager.addShouldRescale(this),I(this,He,zh).call(this,t),r=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),r&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties({bbox:I(this,He,V1).call(this)},m(this,Gr).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&I(this,He,Hh).call(this,m(this,Gr).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const r=document.createElement("div");t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,r,i,o,s){ct("Not implemented")}static startDrawing(t,r,i,o){var y;const{target:s,offsetX:l,offsetY:c,pointerId:d,pointerType:u}=o;if(m(ue,s0)&&m(ue,s0)!==u)return;const{viewport:{rotation:f}}=t,{width:h,height:p}=s.getBoundingClientRect(),g=M(ue,i2,new AbortController),b=t.combinedSignal(g);m(ue,o0)||M(ue,o0,d),m(ue,s0)??M(ue,s0,u),window.addEventListener("pointerup",w=>{var v;m(ue,o0)===w.pointerId?this._endDraw(w):(v=m(ue,a0))==null||v.delete(w.pointerId)},{signal:b}),window.addEventListener("pointercancel",w=>{var v;m(ue,o0)===w.pointerId?this._currentParent.endDrawingSession():(v=m(ue,a0))==null||v.delete(w.pointerId)},{signal:b}),window.addEventListener("pointerdown",w=>{m(ue,s0)===w.pointerType&&((m(ue,a0)||M(ue,a0,new Set)).add(w.pointerId),m(ue,an).isCancellable()&&(m(ue,an).removeLastElement(),m(ue,an).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",Di,{signal:b}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),s.addEventListener("touchmove",w=>{w.timeStamp===m(ue,s2)&&Ir(w)},{signal:b}),t.toggleDrawing(),(y=r._editorUndoBar)==null||y.hide(),m(ue,an)?t.drawLayer.updateProperties(this._currentDrawId,m(ue,an).startNew(l,c,h,p,f)):(r.updateUIForDefaultProperties(this),M(ue,an,this.createDrawerInstance(l,c,h,p,f)),M(ue,o2,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(m(ue,o2).toSVGProperties(),m(ue,an).defaultSVGProperties),!0,!1))}static _drawMove(t){var s;if(M(ue,s2,-1),!m(ue,an))return;const{offsetX:r,offsetY:i,pointerId:o}=t;m(ue,o0)===o&&(((s=m(ue,a0))==null?void 0:s.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,m(ue,an).add(r,i)),M(ue,s2,t.timeStamp),Ir(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,M(ue,an,null),M(ue,o2,null),M(ue,s0,null),M(ue,s2,NaN)),m(ue,i2)&&(m(ue,i2).abort(),M(ue,i2,null),M(ue,o0,NaN),M(ue,a0,null))}static _endDraw(t){const r=this._currentParent;if(r)if(r.toggleDrawing(!0),this._cleanup(!1),t&&r.drawLayer.updateProperties(this._currentDrawId,m(ue,an).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const i=m(ue,an),o=this._currentDrawId,s=i.getLastElement();r.addCommands({cmd:()=>{r.drawLayer.updateProperties(o,i.setLastElement(s))},undo:()=>{r.drawLayer.updateProperties(o,i.removeLastElement())},mustExec:!1,type:Ve.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const r=this._currentParent;if(!r)return null;if(r.toggleDrawing(!0),r.cleanUndoStack(Ve.DRAW_STEP),!m(ue,an).isEmpty()){const{pageDimensions:[i,o],scale:s}=r,l=r.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:m(ue,an).getOutlines(i*s,o*s,s,this._INNER_MARGIN),drawingOptions:m(ue,o2),mustBeCommitted:!t});return this._cleanup(!0),l}return r.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,r,i,o,s,l){ct("Not implemented")}static async deserialize(t,r,i){var f,h;const{rawDims:{pageWidth:o,pageHeight:s,pageX:l,pageY:c}}=r.viewport,d=this.deserializeDraw(l,c,o,s,this._INNER_MARGIN,t),u=await super.deserialize(t,r,i);return u.createDrawingOptions(t),I(f=u,He,k9).call(f,{drawOutlines:d}),I(h=u,He,zh).call(h),u.onScaleChanging(),u.rotate(),u}serializeDraw(t){const[r,i]=this.pageTranslation,[o,s]=this.pageDimensions;return m(this,Gr).serialize([r,i,o,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Gr=new WeakMap,b1=new WeakMap,an=new WeakMap,i2=new WeakMap,o2=new WeakMap,o0=new WeakMap,s0=new WeakMap,a0=new WeakMap,s2=new WeakMap,He=new WeakSet,k9=function({drawOutlines:t,drawId:r,drawingOptions:i}){M(this,Gr,t),this._drawingOptions||(this._drawingOptions=i),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,t.defaultProperties)):this._drawId=I(this,He,M9).call(this,t,this.parent),I(this,He,Hh).call(this,t.box)},M9=function(t,r){const{id:i}=r.drawLayer.draw(ue._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i},E9=function(){this._drawId!==null&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},zh=function(t=this.parent){(this._drawId===null||this.parent!==t)&&(this._drawId===null?(this._drawingOptions.updateAll(),this._drawId=I(this,He,M9).call(this,m(this,Gr),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},HD=function([t,r,i,o]){const{parentDimensions:[s,l],rotation:c}=this;switch(c){case 90:return[r,1-t,i*(l/s),o*(s/l)];case 180:return[1-t,1-r,i,o];case 270:return[1-r,t,i*(l/s),o*(s/l)];default:return[t,r,i,o]}},Gg=function(){const{x:t,y:r,width:i,height:o,parentDimensions:[s,l],rotation:c}=this;switch(c){case 90:return[1-r,t,i*(s/l),o*(l/s)];case 180:return[1-t,1-r,i,o];case 270:return[r,1-t,i*(s/l),o*(l/s)];default:return[t,r,i,o]}},Hh=function(t){if([this.x,this.y,this.width,this.height]=I(this,He,HD).call(this,t),this.div){this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)}this._onResized()},V1=function(){const{x:t,y:r,width:i,height:o,rotation:s,parentRotation:l,parentDimensions:[c,d]}=this;switch((4*s+l)/90){case 1:return[1-r-o,t,o,i];case 2:return[1-t-i,1-r-o,i,o];case 3:return[r,1-t-i,o,i];case 4:return[t,r-i*(c/d),o*(d/c),i*(c/d)];case 5:return[1-r,t,i*(c/d),o*(d/c)];case 6:return[1-t-o*(d/c),1-r,o*(d/c),i*(c/d)];case 7:return[r-i*(c/d),1-t-o*(d/c),i*(c/d),o*(d/c)];case 8:return[t-i,r-o,i,o];case 9:return[1-r,t-i,o,i];case 10:return[1-t,1-r,i,o];case 11:return[r-o,1-t,o,i];case 12:return[t-o*(d/c),r,o*(d/c),i*(c/d)];case 13:return[1-r-i*(c/d),t-o*(d/c),i*(c/d),o*(d/c)];case 14:return[1-t,1-r-i*(c/d),o*(d/c),i*(c/d)];case 15:return[r,1-t,i*(c/d),o*(d/c)];default:return[t,r,i,o]}},ve(ue,"_currentDrawId",-1),ve(ue,"_currentParent",null),T(ue,an,null),T(ue,i2,null),T(ue,o2,null),T(ue,o0,NaN),T(ue,s0,null),T(ue,a0,null),T(ue,s2,NaN),ve(ue,"_INNER_MARGIN",3);let k6=ue;class ZU{constructor(e,t,r,i,o,s){T(this,v1);T(this,No,new Float64Array(6));T(this,ln);T(this,cn);T(this,a2);T(this,w1);T(this,Jn);T(this,Cn,"");T(this,Ci,0);T(this,l2,new lm);T(this,c2);T(this,d2);M(this,c2,r),M(this,d2,i),M(this,a2,o),M(this,w1,s),[e,t]=I(this,v1,qg).call(this,e,t);const l=M(this,ln,[NaN,NaN,NaN,NaN,e,t]);M(this,Jn,[e,t]),M(this,cn,[{line:l,points:m(this,Jn)}]),m(this,No).set(l,0)}updateProperty(e,t){e==="stroke-width"&&M(this,w1,t)}isEmpty(){return!m(this,cn)||m(this,cn).length===0}isCancellable(){return m(this,Jn).length<=10}add(e,t){[e,t]=I(this,v1,qg).call(this,e,t);const[r,i,o,s]=m(this,No).subarray(2,6),l=e-o,c=t-s;return Math.hypot(m(this,c2)*l,m(this,d2)*c)<=2?null:(m(this,Jn).push(e,t),isNaN(r)?(m(this,No).set([o,s,e,t],2),m(this,ln).push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(m(this,No)[0])&&m(this,ln).splice(6,6),m(this,No).set([r,i,o,s,e,t],0),m(this,ln).push(...de.createBezierPoints(r,i,o,s,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(m(this,Jn).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,r,i,o){M(this,c2,r),M(this,d2,i),M(this,a2,o),[e,t]=I(this,v1,qg).call(this,e,t);const s=M(this,ln,[NaN,NaN,NaN,NaN,e,t]);M(this,Jn,[e,t]);const l=m(this,cn).at(-1);return l&&(l.line=new Float32Array(l.line),l.points=new Float32Array(l.points)),m(this,cn).push({line:s,points:m(this,Jn)}),m(this,No).set(s,0),M(this,Ci,0),this.toSVGPath(),null}getLastElement(){return m(this,cn).at(-1)}setLastElement(e){return m(this,cn)?(m(this,cn).push(e),M(this,ln,e.line),M(this,Jn,e.points),M(this,Ci,0),{path:{d:this.toSVGPath()}}):m(this,l2).setLastElement(e)}removeLastElement(){if(!m(this,cn))return m(this,l2).removeLastElement();m(this,cn).pop(),M(this,Cn,"");for(let e=0,t=m(this,cn).length;e<t;e++){const{line:r,points:i}=m(this,cn)[e];M(this,ln,r),M(this,Jn,i),M(this,Ci,0),this.toSVGPath()}return{path:{d:m(this,Cn)}}}toSVGPath(){const e=de.svgRound(m(this,ln)[4]),t=de.svgRound(m(this,ln)[5]);if(m(this,Jn).length===2)return M(this,Cn,`${m(this,Cn)} M ${e} ${t} Z`),m(this,Cn);if(m(this,Jn).length<=6){const i=m(this,Cn).lastIndexOf("M");M(this,Cn,`${m(this,Cn).slice(0,i)} M ${e} ${t}`),M(this,Ci,6)}if(m(this,Jn).length===4){const i=de.svgRound(m(this,ln)[10]),o=de.svgRound(m(this,ln)[11]);return M(this,Cn,`${m(this,Cn)} L ${i} ${o}`),M(this,Ci,12),m(this,Cn)}const r=[];m(this,Ci)===0&&(r.push(`M ${e} ${t}`),M(this,Ci,6));for(let i=m(this,Ci),o=m(this,ln).length;i<o;i+=6){const[s,l,c,d,u,f]=m(this,ln).slice(i,i+6).map(de.svgRound);r.push(`C${s} ${l} ${c} ${d} ${u} ${f}`)}return M(this,Cn,m(this,Cn)+r.join(" ")),M(this,Ci,m(this,ln).length),m(this,Cn)}getOutlines(e,t,r,i){const o=m(this,cn).at(-1);return o.line=new Float32Array(o.line),o.points=new Float32Array(o.points),m(this,l2).build(m(this,cn),e,t,r,m(this,a2),m(this,w1),i),M(this,No,null),M(this,ln,null),M(this,cn,null),M(this,Cn,null),m(this,l2)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}No=new WeakMap,ln=new WeakMap,cn=new WeakMap,a2=new WeakMap,w1=new WeakMap,Jn=new WeakMap,Cn=new WeakMap,Ci=new WeakMap,l2=new WeakMap,c2=new WeakMap,d2=new WeakMap,v1=new WeakSet,qg=function(e,t){return de._normalizePoint(e,t,m(this,c2),m(this,d2),m(this,a2))};const Ly=class Ly extends de{constructor(){super(...arguments);T(this,Sn);T(this,er);T(this,Ih,0);T(this,xh);T(this,qr);T(this,Po);T(this,Lo);T(this,C1);T(this,S1);T(this,k1)}build(t,r,i,o,s,l,c){M(this,Po,r),M(this,Lo,i),M(this,C1,o),M(this,S1,s),M(this,k1,l),M(this,xh,c??0),M(this,qr,t),I(this,Sn,ZD).call(this)}setLastElement(t){return m(this,qr).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return m(this,qr).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:r}of m(this,qr))if(t.push(`M${de.svgRound(r[4])} ${de.svgRound(r[5])}`),r.length!==6)if(r.length!==12)for(let i=6,o=r.length;i<o;i+=6){const[s,l,c,d,u,f]=r.subarray(i,i+6).map(de.svgRound);t.push(`C${s} ${l} ${c} ${d} ${u} ${f}`)}else t.push(`L${de.svgRound(r[10])} ${de.svgRound(r[11])}`);else t.push("Z");return t.join("")}serialize([t,r,i,o],s){const l=[],c=[],[d,u,f,h]=I(this,Sn,UD).call(this);let p,g,b,y,w,v,S,C,A;switch(m(this,S1)){case 0:A=de._rescale,p=t,g=r+o,b=i,y=-o,w=t+d*i,v=r+(1-u-h)*o,S=t+(d+f)*i,C=r+(1-u)*o;break;case 90:A=de._rescaleAndSwap,p=t,g=r,b=i,y=o,w=t+u*i,v=r+d*o,S=t+(u+h)*i,C=r+(d+f)*o;break;case 180:A=de._rescale,p=t+i,g=r,b=-i,y=o,w=t+(1-d-f)*i,v=r+u*o,S=t+(1-d)*i,C=r+(u+h)*o;break;case 270:A=de._rescaleAndSwap,p=t+i,g=r+o,b=-i,y=-o,w=t+(1-u-h)*i,v=r+(1-d-f)*o,S=t+(1-u)*i,C=r+(1-d)*o}for(const{line:k,points:E}of m(this,qr))l.push(A(k,p,g,b,y,s?new Array(k.length):null)),c.push(A(E,p,g,b,y,s?new Array(E.length):null));return{lines:l,points:c,rect:[w,v,S,C]}}static deserialize(t,r,i,o,s,{paths:{lines:l,points:c},rotation:d,thickness:u}){const f=[];let h,p,g,b,y;switch(d){case 0:y=de._rescale,h=-t/i,p=r/o+1,g=1/i,b=-1/o;break;case 90:y=de._rescaleAndSwap,h=-r/o,p=-t/i,g=1/o,b=1/i;break;case 180:y=de._rescale,h=t/i+1,p=-r/o,g=-1/i,b=1/o;break;case 270:y=de._rescaleAndSwap,h=r/o+1,p=t/i+1,g=-1/o,b=-1/i}if(!l){l=[];for(const v of c){const S=v.length;if(S===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(S===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const C=new Float32Array(3*(S-2));l.push(C);let[A,k,E,O]=v.subarray(0,4);C.set([NaN,NaN,NaN,NaN,A,k],0);for(let x=4;x<S;x+=2){const N=v[x],D=v[x+1];C.set(de.createBezierPoints(A,k,E,O,N,D),3*(x-2)),[A,k,E,O]=[E,O,N,D]}}}for(let v=0,S=l.length;v<S;v++)f.push({line:y(l[v].map(C=>C??NaN),h,p,g,b),points:y(c[v].map(C=>C??NaN),h,p,g,b)});const w=new Ly;return w.build(f,i,o,1,d,u,s),w}get box(){return m(this,er)}updateProperty(t,r){return t==="stroke-width"?I(this,Sn,WD).call(this,r):null}updateParentDimensions([t,r],i){const[o,s]=I(this,Sn,Us).call(this);M(this,Po,t),M(this,Lo,r),M(this,C1,i);const[l,c]=I(this,Sn,Us).call(this),d=l-o,u=c-s,f=m(this,er);return f[0]-=d,f[1]-=u,f[2]+=2*d,f[3]+=2*u,f}updateRotation(t){return M(this,Ih,t),{path:{transform:this.rotationTransform}}}get viewBox(){return m(this,er).map(de.svgRound).join(" ")}get defaultProperties(){const[t,r]=m(this,er);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`}}}get rotationTransform(){const[,,t,r]=m(this,er);let i=0,o=0,s=0,l=0,c=0,d=0;switch(m(this,Ih)){case 90:o=r/t,s=-t/r,c=t;break;case 180:i=-1,l=-1,c=t,d=r;break;case 270:o=-r/t,s=t/r,d=r;break;default:return""}return`matrix(${i} ${o} ${s} ${l} ${de.svgRound(c)} ${de.svgRound(d)})`}getPathResizingSVGProperties([t,r,i,o]){const[s,l]=I(this,Sn,Us).call(this),[c,d,u,f]=m(this,er);if(Math.abs(u-s)<=de.PRECISION||Math.abs(f-l)<=de.PRECISION){const y=t+i/2-(c+u/2),w=r+o/2-(d+f/2);return{path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:`${this.rotationTransform} translate(${y} ${w})`}}}const h=(i-2*s)/(u-2*s),p=(o-2*l)/(f-2*l),g=u/i,b=f/o;return{path:{"transform-origin":`${de.svgRound(c)} ${de.svgRound(d)}`,transform:`${this.rotationTransform} scale(${g} ${b}) translate(${de.svgRound(s)} ${de.svgRound(l)}) scale(${h} ${p}) translate(${de.svgRound(-s)} ${de.svgRound(-l)})`}}}getPathResizedSVGProperties([t,r,i,o]){const[s,l]=I(this,Sn,Us).call(this),c=m(this,er),[d,u,f,h]=c;if(c[0]=t,c[1]=r,c[2]=i,c[3]=o,Math.abs(f-s)<=de.PRECISION||Math.abs(h-l)<=de.PRECISION){const w=t+i/2-(d+f/2),v=r+o/2-(u+h/2);for(const{line:S,points:C}of m(this,qr))de._translate(S,w,v,S),de._translate(C,w,v,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(i-2*s)/(f-2*s),g=(o-2*l)/(h-2*l),b=-p*(d+s)+t+s,y=-g*(u+l)+r+l;if(p!==1||g!==1||b!==0||y!==0)for(const{line:w,points:v}of m(this,qr))de._rescale(w,b,y,p,g,w),de._rescale(v,b,y,p,g,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,r],i){const[o,s]=i,l=m(this,er),c=t-l[0],d=r-l[1];if(m(this,Po)===o&&m(this,Lo)===s)for(const{line:u,points:f}of m(this,qr))de._translate(u,c,d,u),de._translate(f,c,d,f);else{const u=m(this,Po)/o,f=m(this,Lo)/s;M(this,Po,o),M(this,Lo,s);for(const{line:h,points:p}of m(this,qr))de._rescale(h,c,d,u,f,h),de._rescale(p,c,d,u,f,p);l[2]*=u,l[3]*=f}return l[0]=t,l[1]=r,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`}}}get defaultSVGProperties(){const t=m(this,er);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${de.svgRound(t[0])} ${de.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}};er=new WeakMap,Ih=new WeakMap,xh=new WeakMap,qr=new WeakMap,Po=new WeakMap,Lo=new WeakMap,C1=new WeakMap,S1=new WeakMap,k1=new WeakMap,Sn=new WeakSet,Us=function(t=m(this,k1)){const r=m(this,xh)+t/2*m(this,C1);return m(this,S1)%180==0?[r/m(this,Po),r/m(this,Lo)]:[r/m(this,Lo),r/m(this,Po)]},UD=function(){const[t,r,i,o]=m(this,er),[s,l]=I(this,Sn,Us).call(this,0);return[t+s,r+l,i-2*s,o-2*l]},ZD=function(){const t=M(this,er,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:o}of m(this,qr)){if(o.length<=12){for(let c=4,d=o.length;c<d;c+=6){const[u,f]=o.subarray(c,c+2);t[0]=Math.min(t[0],u),t[1]=Math.min(t[1],f),t[2]=Math.max(t[2],u),t[3]=Math.max(t[3],f)}continue}let s=o[4],l=o[5];for(let c=6,d=o.length;c<d;c+=6){const[u,f,h,p,g,b]=o.subarray(c,c+6);ye.bezierBoundingBox(s,l,u,f,h,p,g,b,t),s=g,l=b}}const[r,i]=I(this,Sn,Us).call(this);t[0]=Math.min(1,Math.max(0,t[0]-r)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+r)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]},WD=function(t){const[r,i]=I(this,Sn,Us).call(this);M(this,k1,t);const[o,s]=I(this,Sn,Us).call(this),[l,c]=[o-r,s-i],d=m(this,er);return d[0]-=l,d[1]-=c,d[2]+=2*l,d[3]+=2*c,d};let lm=Ly;const By=class By extends UU{constructor(t){super();T(this,M1);M(this,M1,t),super.updateProperties({fill:"none",stroke:Ct._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,r){t==="stroke-width"&&(r??(r=this["stroke-width"]),r*=m(this,M1).realScale),super.updateSVGProperty(t,r)}clone(){const t=new By(m(this,M1));return t.updateAll(this),t}};M1=new WeakMap;let M6=By;const E1=class E1 extends k6{constructor(t){super({...t,name:"inkEditor"});T(this,vg);this._willKeepAspectRatio=!0}static initialize(t,r){Ct.initialize(t,r),this._defaultDrawingOptions=new M6(r.viewParameters)}static getDefaultDrawingOptions(t){const r=this._defaultDrawingOptions.clone();return r.updateProperties(t),r}static get supportMultipleDrawings(){return!0}static get typesMap(){return _e(this,"typesMap",new Map([[Ve.INK_THICKNESS,"stroke-width"],[Ve.INK_COLOR,"stroke"],[Ve.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,r,i,o,s){return new ZU(t,r,i,o,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,r,i,o,s,l){return lm.deserialize(t,r,i,o,s,l)}static async deserialize(t,r,i){let o=null;if(t instanceof w6){const{data:{inkLists:l,rect:c,rotation:d,id:u,color:f,opacity:h,borderStyle:{rawWidth:p},popupRef:g},parent:{page:{pageNumber:b}}}=t;o=t={annotationType:De.INK,color:Array.from(f),thickness:p,opacity:h,paths:{points:l},boxes:null,pageIndex:b-1,rect:c.slice(0),rotation:d,id:u,deleted:!1,popupRef:g}}const s=await super.deserialize(t,r,i);return s.annotationElementId=t.id||null,s._initialData=o,s}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:r,parent:i}=this;r.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,r.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:r,opacity:i}){this._drawingOptions=E1.getDefaultDrawingOptions({stroke:ye.makeHexColor(...t),"stroke-width":r,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:r,points:i,rect:o}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":l,"stroke-width":c}}=this,d={annotationType:De.INK,color:Ct._colorManager.convert(s),opacity:l,thickness:c,paths:{lines:r,points:i},pageIndex:this.pageIndex,rect:o,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?d:this.annotationElementId&&!I(this,vg,GD).call(this,d)?null:(d.id=this.annotationElementId,d)}renderAnnotationElement(t){const{points:r,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:r}),null}};vg=new WeakSet,GD=function(t){const{color:r,thickness:i,opacity:o,pageIndex:s}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((l,c)=>l!==r[c])||t.thickness!==i||t.opacity!==o||t.pageIndex!==s},ve(E1,"_type","ink"),ve(E1,"_editorType",De.INK),ve(E1,"_defaultDrawingOptions",null);let E6=E1;const Oh=class Oh extends Ct{constructor(t){super({...t,name:"stampEditor"});T(this,qe);T(this,Et,null);T(this,kn,null);T(this,l0,null);T(this,Vs,null);T(this,c0,null);T(this,A1,"");T(this,Bo,null);T(this,_o,null);T(this,Kr,!1);T(this,T1,!1);M(this,Vs,t.bitmapUrl),M(this,c0,t.bitmapFile)}static initialize(t,r){Ct.initialize(t,r)}static get supportedTypes(){return _e(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return _e(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,r){r.pasteEditor(De.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const r=t.get("hasAltText");return{hasAltText:r.get(!0)??0,hasNoAltText:r.get(!1)??0}}async mlGuessAltText(t=null,r=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:o,width:s,height:l}=t||this.copyCanvas(null,null,!0).imageData,c=await i.guess({name:"altText",request:{data:o,width:s,height:l,channels:o.length/(s*l)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const d=c.output;return await this.setGuessedAltText(d),r&&!this.hasAltTextData()&&(this.altTextData={alt:d,decorative:!1}),d}remove(){var t;m(this,kn)&&(M(this,Et,null),this._uiManager.imageManager.deleteId(m(this,kn)),(t=m(this,Bo))==null||t.remove(),M(this,Bo,null),m(this,_o)&&(clearTimeout(m(this,_o)),M(this,_o,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(m(this,kn)&&m(this,Bo)===null&&I(this,qe,Kg).call(this),this.isAttachedToDOM||this.parent.add(this))):m(this,kn)&&I(this,qe,Kg).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(m(this,l0)||m(this,Et)||m(this,Vs)||m(this,c0)||m(this,kn))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,r;if(this.width&&(t=this.x,r=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),m(this,Et)?I(this,qe,A9).call(this):I(this,qe,Kg).call(this),this.width&&!this.annotationElementId){const[i,o]=this.parentDimensions;this.setAt(t*i,r*o,this.width*i,this.height*o)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(m(this,_o)!==null&&clearTimeout(m(this,_o)),M(this,_o,setTimeout(()=>{M(this,_o,null),I(this,qe,T9).call(this)},200)))}copyCanvas(t,r,i=!1){var p;t||(t=224);const{width:o,height:s}=m(this,Et),l=new r6;let c=m(this,Et),d=o,u=s,f=null;if(r){if(o>r||s>r){const O=Math.min(r/o,r/s);d=Math.floor(o*O),u=Math.floor(s*O)}f=document.createElement("canvas");const g=f.width=Math.ceil(d*l.sx),b=f.height=Math.ceil(u*l.sy);m(this,Kr)||(c=I(this,qe,Yg).call(this,g,b));const y=f.getContext("2d");y.filter=this._uiManager.hcmFilter;let w="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",v="#42414d");const S=15,C=S*l.sx,A=S*l.sy,k=new OffscreenCanvas(2*C,2*A),E=k.getContext("2d");E.fillStyle=w,E.fillRect(0,0,2*C,2*A),E.fillStyle=v,E.fillRect(0,0,C,A),E.fillRect(C,A,C,A),y.fillStyle=y.createPattern(k,"repeat"),y.fillRect(0,0,g,b),y.drawImage(c,0,0,c.width,c.height,0,0,g,b)}let h=null;if(i){let g,b;if(l.symmetric&&c.width<t&&c.height<t)g=c.width,b=c.height;else if(c=m(this,Et),o>t||s>t){const w=Math.min(t/o,t/s);g=Math.floor(o*w),b=Math.floor(s*w),m(this,Kr)||(c=I(this,qe,Yg).call(this,g,b))}const y=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});y.drawImage(c,0,0,c.width,c.height,0,0,g,b),h={width:g,height:b,data:y.getImageData(0,0,g,b).data}}return{canvas:f,width:d,height:u,imageData:h}}getImageForAltText(){return m(this,Bo)}static async deserialize(t,r,i){var b;let o=null;if(t instanceof Ek){const{data:{rect:y,rotation:w,id:v,structParent:S,popupRef:C},container:A,parent:{page:{pageNumber:k}}}=t,E=A.querySelector("canvas"),O=i.imageManager.getFromCanvas(A.id,E);E.remove();const x=((b=await r._structTree.getAriaAttributes(`${X4}${v}`))==null?void 0:b.get("aria-label"))||"";o=t={annotationType:De.STAMP,bitmapId:O.id,bitmap:O.bitmap,pageIndex:k-1,rect:y.slice(0),rotation:w,id:v,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:S,popupRef:C}}const s=await super.deserialize(t,r,i),{rect:l,bitmap:c,bitmapUrl:d,bitmapId:u,isSvg:f,accessibilityData:h}=t;u&&i.imageManager.isValidId(u)?(M(s,kn,u),c&&M(s,Et,c)):M(s,Vs,d),M(s,Kr,f);const[p,g]=s.pageDimensions;return s.width=(l[2]-l[0])/p,s.height=(l[3]-l[1])/g,s.annotationElementId=t.id||null,h&&(s.altTextData=h),s._initialData=o,M(s,T1,!!o),s}serialize(t=!1,r=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:De.STAMP,bitmapId:m(this,kn),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:m(this,Kr),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=I(this,qe,Qg).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:o,altText:s}=this.serializeAltText(!1);if(!o&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const c=I(this,qe,qD).call(this,i);if(c.isSame)return null;c.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,r===null)return i;r.stamps||(r.stamps=new Map);const l=m(this,Kr)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(r.stamps.has(m(this,kn))){if(m(this,Kr)){const c=r.stamps.get(m(this,kn));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=I(this,qe,Qg).call(this,!1))}}else r.stamps.set(m(this,kn),{area:l,serialized:i}),i.bitmap=I(this,qe,Qg).call(this,!1);return i}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}};Et=new WeakMap,kn=new WeakMap,l0=new WeakMap,Vs=new WeakMap,c0=new WeakMap,A1=new WeakMap,Bo=new WeakMap,_o=new WeakMap,Kr=new WeakMap,T1=new WeakMap,qe=new WeakSet,Uh=function(t,r=!1){t?(M(this,Et,t.bitmap),r||(M(this,kn,t.id),M(this,Kr,t.isSvg)),t.file&&M(this,A1,t.file.name),I(this,qe,A9).call(this)):this.remove()},Zh=function(){if(M(this,l0,null),this._uiManager.enableWaiting(!1),m(this,Bo))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&m(this,Et))this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&m(this,Et)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Kg=function(){if(m(this,kn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(m(this,kn)).then(i=>I(this,qe,Uh).call(this,i,!0)).finally(()=>I(this,qe,Zh).call(this));return}if(m(this,Vs)){const i=m(this,Vs);M(this,Vs,null),this._uiManager.enableWaiting(!0),M(this,l0,this._uiManager.imageManager.getFromUrl(i).then(o=>I(this,qe,Uh).call(this,o)).finally(()=>I(this,qe,Zh).call(this)));return}if(m(this,c0)){const i=m(this,c0);M(this,c0,null),this._uiManager.enableWaiting(!0),M(this,l0,this._uiManager.imageManager.getFromFile(i).then(o=>I(this,qe,Uh).call(this,o)).finally(()=>I(this,qe,Zh).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Oh.supportedTypesStr;const r=this._uiManager._signal;M(this,l0,new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&t.files.length!==0){this._uiManager.enableWaiting(!0);const o=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),I(this,qe,Uh).call(this,o)}else this.remove();i()},{signal:r}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:r})}).finally(()=>I(this,qe,Zh).call(this))),t.click()},A9=function(){var f;const{div:t}=this;let{width:r,height:i}=m(this,Et);const[o,s]=this.pageDimensions,l=.75;if(this.width)r=this.width*o,i=this.height*s;else if(r>l*o||i>l*s){const h=Math.min(l*o/r,l*s/i);r*=h,i*=h}const[c,d]=this.parentDimensions;this.setDims(r*c/o,i*d/s),this._uiManager.enableWaiting(!1);const u=M(this,Bo,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=r/o,this.height=i/s,(f=this._initialOptions)!=null&&f.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),I(this,qe,T9).call(this),m(this,T1)||(this.parent.addUndoableEditor(this),M(this,T1,!0)),this._reportTelemetry({action:"inserted_image"}),m(this,A1)&&u.setAttribute("aria-label",m(this,A1))},Yg=function(t,r){const{width:i,height:o}=m(this,Et);let s=i,l=o,c=m(this,Et);for(;s>2*t||l>2*r;){const d=s,u=l;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),l>2*r&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const f=new OffscreenCanvas(s,l);f.getContext("2d").drawImage(c,0,0,d,u,0,0,s,l),c=f.transferToImageBitmap()}return c},T9=function(){const[t,r]=this.parentDimensions,{width:i,height:o}=this,s=new r6,l=Math.ceil(i*t*s.sx),c=Math.ceil(o*r*s.sy),d=m(this,Bo);if(!d||d.width===l&&d.height===c)return;d.width=l,d.height=c;const u=m(this,Kr)?m(this,Et):I(this,qe,Yg).call(this,l,c),f=d.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(u,0,0,u.width,u.height,0,0,l,c)},Qg=function(t){if(t){if(m(this,Kr)){const i=this._uiManager.imageManager.getSvgUrl(m(this,kn));if(i)return i}const r=document.createElement("canvas");return{width:r.width,height:r.height}=m(this,Et),r.getContext("2d").drawImage(m(this,Et),0,0),r.toDataURL()}if(m(this,Kr)){const[r,i]=this.pageDimensions,o=Math.round(this.width*r*ra.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*ra.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(o,s);return l.getContext("2d").drawImage(m(this,Et),0,0,m(this,Et).width,m(this,Et).height,0,0,o,s),l.transferToImageBitmap()}return structuredClone(m(this,Et))},qD=function(t){var l;const{pageIndex:r,accessibilityData:{altText:i}}=this._initialData,o=t.pageIndex===r,s=(((l=t.accessibilityData)==null?void 0:l.alt)||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&o&&s,isSameAltText:s}},ve(Oh,"_type","stamp"),ve(Oh,"_editorType",De.STAMP);let A6=Oh;const Ki=class Ki{constructor({uiManager:e,pageIndex:t,div:r,structTreeLayer:i,accessibilityManager:o,annotationLayer:s,drawLayer:l,textLayer:c,viewport:d,l10n:u}){T(this,yt);T(this,u2);T(this,I1,!1);T(this,Ro,null);T(this,d0,null);T(this,$s,null);T(this,Si,new Map);T(this,u0,!1);T(this,x1,!1);T(this,f2,!1);T(this,qi,null);T(this,Fs,null);T(this,_n,null);T(this,js,null);T(this,ge);const f=[...m(Ki,f0).values()];if(!Ki._initialized){Ki._initialized=!0;for(const h of f)h.initialize(u,e)}e.registerEditorTypes(f),M(this,ge,e),this.pageIndex=t,this.div=r,M(this,u2,o),M(this,Ro,s),this.viewport=d,M(this,_n,c),this.drawLayer=l,this._structTree=i,m(this,ge).addLayer(this)}get isEmpty(){return m(this,Si).size===0}get isInvisible(){return this.isEmpty&&m(this,ge).getMode()===De.NONE}updateToolbar(e){m(this,ge).updateToolbar(e)}updateMode(e=m(this,ge).getMode()){switch(I(this,yt,Xg).call(this),e){case De.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case De.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case De.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const r of m(Ki,f0).values())t.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=m(this,_n))==null?void 0:t.div)}setEditingState(e){m(this,ge).setEditingState(e)}addCommands(e){m(this,ge).addCommands(e)}cleanUndoStack(e){m(this,ge).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=m(this,Ro))==null||t.div.classList.toggle("disabled",!e)}async enable(){M(this,f2,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const r of m(this,Si).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(m(this,ge).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!m(this,Ro)){M(this,f2,!1);return}const t=m(this,Ro).getEditableAnnotations();for(const r of t){if(r.hide(),m(this,ge).isDeletedAnnotationElement(r.data.id)||e.has(r.data.id))continue;const i=await this.deserialize(r);i&&(this.addOrRebuild(i),i.enableEditing())}M(this,f2,!1)}disable(){var i;M(this,x1,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const o of m(this,Si).values())o.disableEditing(),o.annotationElementId&&(o.serialize()===null?(t.set(o.annotationElementId,o),(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()):e.set(o.annotationElementId,o));if(m(this,Ro)){const o=m(this,Ro).getEditableAnnotations();for(const s of o){const{id:l}=s.data;if(m(this,ge).isDeletedAnnotationElement(l))continue;let c=t.get(l);c?(c.resetAnnotationElement(s),c.show(!1),s.show()):(c=e.get(l),c&&(m(this,ge).addChangedExistingAnnotation(c),c.renderAnnotationElement(s)&&c.show(!1)),s.show())}}I(this,yt,Xg).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:r}=this.div;for(const o of m(Ki,f0).values())r.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),M(this,x1,!1)}getEditableAnnotation(e){var t;return((t=m(this,Ro))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){m(this,ge).getActive()!==e&&m(this,ge).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=m(this,_n))!=null&&e.div&&!m(this,js)){M(this,js,new AbortController);const t=m(this,ge).combinedSignal(m(this,js));m(this,_n).div.addEventListener("pointerdown",I(this,yt,KD).bind(this),{signal:t}),m(this,_n).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=m(this,_n))!=null&&e.div&&m(this,js)&&(m(this,js).abort(),M(this,js,null),m(this,_n).div.classList.remove("highlighting"))}enableClick(){if(m(this,d0))return;M(this,d0,new AbortController);const e=m(this,ge).combinedSignal(m(this,d0));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){var e;(e=m(this,d0))==null||e.abort(),M(this,d0,null)}attach(e){m(this,Si).set(e.id,e);const{annotationElementId:t}=e;t&&m(this,ge).isDeletedAnnotationElement(t)&&m(this,ge).removeDeletedAnnotationElement(e)}detach(e){var t;m(this,Si).delete(e.id),(t=m(this,u2))==null||t.removePointerInTextLayer(e.contentDiv),!m(this,x1)&&e.annotationElementId&&m(this,ge).addDeletedAnnotationElement(e)}remove(e){this.detach(e),m(this,ge).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(m(this,ge).addDeletedAnnotationElement(e.annotationElementId),Ct.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),m(this,ge).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!m(this,f2)),m(this,ge).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var r;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!m(this,$s)&&(e._focusEventsAllowed=!1,M(this,$s,setTimeout(()=>{M(this,$s,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:m(this,ge)._signal}),t.focus())},0))),e._structTreeParentId=(r=m(this,u2))==null?void 0:r.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return m(this,ge).getId()}combinedSignal(e){return m(this,ge).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=m(this,yt,jo))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){m(this,ge).updateToolbar(e),m(this,ge).updateMode(e);const{offsetX:r,offsetY:i}=I(this,yt,x9).call(this),o=this.getNextId(),s=I(this,yt,I9).call(this,{parent:this,id:o,x:r,y:i,uiManager:m(this,ge),isCentered:!0,...t});s&&this.add(s)}async deserialize(e){var t;return await((t=m(Ki,f0).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,m(this,ge)))||null}createAndAddNewEditor(e,t,r={}){const i=this.getNextId(),o=I(this,yt,I9).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:m(this,ge),isCentered:t,...r});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(I(this,yt,x9).call(this),!0)}setSelected(e){m(this,ge).setSelected(e)}toggleSelected(e){m(this,ge).toggleSelected(e)}unselect(e){m(this,ge).unselect(e)}pointerup(e){var r;const{isMac:t}=Un.platform;!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&m(this,u0)&&(M(this,u0,!1),(r=m(this,yt,jo))!=null&&r.isDrawer&&m(this,yt,jo).supportMultipleDrawings||(m(this,I1)?m(this,ge).getMode()!==De.STAMP?this.createAndAddNewEditor(e,!1):m(this,ge).unselectAll():M(this,I1,!0)))}pointerdown(e){var i;if(m(this,ge).getMode()===De.HIGHLIGHT&&this.enableTextSelection(),m(this,u0)){M(this,u0,!1);return}const{isMac:t}=Un.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;if(M(this,u0,!0),(i=m(this,yt,jo))!=null&&i.isDrawer){this.startDrawingSession(e);return}const r=m(this,ge).getActive();M(this,I1,!r||r.isEmpty())}startDrawingSession(e){if(this.div.focus(),m(this,qi)){m(this,yt,jo).startDrawing(this,m(this,ge),!1,e);return}m(this,ge).setCurrentDrawingSession(this),M(this,qi,new AbortController);const t=m(this,ge).combinedSignal(m(this,qi));this.div.addEventListener("blur",({relatedTarget:r})=>{r&&!this.div.contains(r)&&(M(this,Fs,null),this.commitOrRemove())},{signal:t}),m(this,yt,jo).startDrawing(this,m(this,ge),!1,e)}pause(e){if(e){const{activeElement:t}=document;this.div.contains(t)&&M(this,Fs,t)}else m(this,Fs)&&setTimeout(()=>{var t;(t=m(this,Fs))==null||t.focus(),M(this,Fs,null)},0)}endDrawingSession(e=!1){return m(this,qi)?(m(this,ge).setCurrentDrawingSession(null),m(this,qi).abort(),M(this,qi,null),M(this,Fs,null),m(this,yt,jo).endDrawing(e)):null}findNewParent(e,t,r){const i=m(this,ge).findParent(t,r);return i===null||i===this?!1:(i.changeParent(e),!0)}commitOrRemove(){return m(this,qi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){m(this,qi)&&m(this,yt,jo).onScaleChangingWhenDrawing(this)}destroy(){var e,t;this.commitOrRemove(),((e=m(this,ge).getActive())==null?void 0:e.parent)===this&&(m(this,ge).commitOrRemove(),m(this,ge).setActiveEditor(null)),m(this,$s)&&(clearTimeout(m(this,$s)),M(this,$s,null));for(const r of m(this,Si).values())(t=m(this,u2))==null||t.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,m(this,Si).clear(),m(this,ge).removeLayer(this)}render({viewport:e}){this.viewport=e,P0(this.div,e);for(const t of m(this,ge).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){m(this,ge).commitOrRemove(),I(this,yt,Xg).call(this);const t=this.viewport.rotation,r=e.rotation;if(this.viewport=e,P0(this.div,{rotation:r}),t!==r)for(const i of m(this,Si).values())i.rotate(r)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return m(this,ge).viewParameters.realScale}};u2=new WeakMap,I1=new WeakMap,Ro=new WeakMap,d0=new WeakMap,$s=new WeakMap,Si=new WeakMap,u0=new WeakMap,x1=new WeakMap,f2=new WeakMap,qi=new WeakMap,Fs=new WeakMap,_n=new WeakMap,js=new WeakMap,ge=new WeakMap,f0=new WeakMap,yt=new WeakSet,KD=function(e){m(this,ge).unselectAll();const{target:t}=e;if(t===m(this,_n).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent"))&&m(this,_n).div.contains(t)){const{isMac:r}=Un.platform;if(e.button!==0||e.ctrlKey&&r)return;m(this,ge).showAllEditors("highlight",!0,!0),m(this,_n).div.classList.add("free"),this.toggleDrawing(),am.startHighlighting(this,m(this,ge).direction==="ltr",{target:m(this,_n).div,x:e.x,y:e.y}),m(this,_n).div.addEventListener("pointerup",()=>{m(this,_n).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:m(this,ge)._signal}),e.preventDefault()}},jo=function(){return m(Ki,f0).get(m(this,ge).getMode())},I9=function(e){const t=m(this,yt,jo);return t?new t.prototype.constructor(e):null},x9=function(){const{x:e,y:t,width:r,height:i}=this.div.getBoundingClientRect(),o=Math.max(0,e),s=Math.max(0,t),l=(o+Math.min(window.innerWidth,e+r))/2-e,c=(s+Math.min(window.innerHeight,t+i))/2-t,[d,u]=this.viewport.rotation%180==0?[l,c]:[c,l];return{offsetX:d,offsetY:u}},Xg=function(){for(const e of m(this,Si).values())e.isEmpty()&&e.remove()},ve(Ki,"_initialized",!1),T(Ki,f0,new Map([v6,E6,A6,am].map(e=>[e._editorType,e])));let T6=Ki;const Rn=class Rn{constructor({pageIndex:e}){T(this,Vo);T(this,Yi,null);T(this,Dh,0);T(this,tr,new Map);T(this,h2,new Map);this.pageIndex=e}setParent(e){if(m(this,Yi)){if(m(this,Yi)!==e){if(m(this,tr).size>0)for(const t of m(this,tr).values())t.remove(),e.append(t);M(this,Yi,e)}}else M(this,Yi,e)}static get _svgFactory(){return _e(this,"_svgFactory",new y6)}draw(e,t=!1,r=!1){const i=ir(this,Dh)._++,o=I(this,Vo,O9).call(this),s=Rn._svgFactory.createElement("defs");o.append(s);const l=Rn._svgFactory.createElement("path");s.append(l);const c=`path_p${this.pageIndex}_${i}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke"),t&&m(this,h2).set(i,l);const d=r?I(this,Vo,QD).call(this,s,c):null,u=Rn._svgFactory.createElement("use");return o.append(u),u.setAttribute("href",`#${c}`),this.updateProperties(o,e),m(this,tr).set(i,o),{id:i,clipPathId:`url(#${d})`}}drawOutline(e,t){const r=ir(this,Dh)._++,i=I(this,Vo,O9).call(this),o=Rn._svgFactory.createElement("defs");i.append(o);const s=Rn._svgFactory.createElement("path");o.append(s);const l=`path_p${this.pageIndex}_${r}`;s.setAttribute("id",l),s.setAttribute("vector-effect","non-scaling-stroke");let c;if(t){const f=Rn._svgFactory.createElement("mask");o.append(f),c=`mask_p${this.pageIndex}_${r}`,f.setAttribute("id",c),f.setAttribute("maskUnits","objectBoundingBox");const h=Rn._svgFactory.createElement("rect");f.append(h),h.setAttribute("width","1"),h.setAttribute("height","1"),h.setAttribute("fill","white");const p=Rn._svgFactory.createElement("use");f.append(p),p.setAttribute("href",`#${l}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const d=Rn._svgFactory.createElement("use");i.append(d),d.setAttribute("href",`#${l}`),c&&d.setAttribute("mask",`url(#${c})`);const u=d.cloneNode();return i.append(u),d.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(i,e),m(this,tr).set(r,i),r}finalizeDraw(e,t){m(this,h2).delete(e),this.updateProperties(e,t)}updateProperties(e,t){var c;if(!t)return;const{root:r,bbox:i,rootClass:o,path:s}=t,l=typeof e=="number"?m(this,tr).get(e):e;if(l){if(r&&I(this,Vo,D9).call(this,l,r),i&&I(c=Rn,Cg,YD).call(c,l,i),o){const{classList:d}=l;for(const[u,f]of Object.entries(o))d.toggle(u,f)}if(s){const d=l.firstChild.firstChild;I(this,Vo,D9).call(this,d,s)}}}updateParent(e,t){if(t===this)return;const r=m(this,tr).get(e);r&&(m(t,Yi).append(r),m(this,tr).delete(e),m(t,tr).set(e,r))}remove(e){m(this,h2).delete(e),m(this,Yi)!==null&&(m(this,tr).get(e).remove(),m(this,tr).delete(e))}destroy(){M(this,Yi,null);for(const e of m(this,tr).values())e.remove();m(this,tr).clear(),m(this,h2).clear()}};Yi=new WeakMap,Dh=new WeakMap,tr=new WeakMap,h2=new WeakMap,Cg=new WeakSet,YD=function(e,[t,r,i,o]){const{style:s}=e;s.top=100*r+"%",s.left=100*t+"%",s.width=100*i+"%",s.height=100*o+"%"},Vo=new WeakSet,O9=function(){const e=Rn._svgFactory.create(1,1,!0);return m(this,Yi).append(e),e.setAttribute("aria-hidden",!0),e},QD=function(e,t){const r=Rn._svgFactory.createElement("clipPath");e.append(r);const i=`clip_${t}`;r.setAttribute("id",i),r.setAttribute("clipPathUnits","objectBoundingBox");const o=Rn._svgFactory.createElement("use");return r.append(o),o.setAttribute("href",`#${t}`),o.classList.add("clip"),i},D9=function(e,t){for(const[r,i]of Object.entries(t))i===null?e.removeAttribute(r):e.setAttribute(r,i)},T(Rn,Cg);let I6=Rn;globalThis.pdfjsTestingUtils={HighlightOutliner:C6},ke.AbortException,ke.AnnotationEditorLayer,ke.AnnotationEditorParamsType,ke.AnnotationEditorType,ke.AnnotationEditorUIManager,ke.AnnotationLayer,ke.AnnotationMode,ke.ColorPicker,ke.DOMSVGFactory,ke.DrawLayer,ke.FeatureTest;var WU=ke.GlobalWorkerOptions;ke.ImageKind,ke.InvalidPDFException,ke.MissingPDFException,ke.OPS,ke.OutputScale,ke.PDFDataRangeTransport,ke.PDFDateString,ke.PDFWorker,ke.PasswordResponses,ke.PermissionFlag,ke.PixelsPerInch,ke.RenderingCancelledException,ke.TextLayer,ke.TouchManager,ke.UnexpectedResponseException,ke.Util,ke.VerbosityLevel,ke.XfaLayer,ke.build,ke.createValidAbsoluteUrl,ke.fetchData;var GU=ke.getDocument;ke.getFilenameFromUrl,ke.getPdfFilenameFromUrl,ke.getXfaPageViewport,ke.isDataScheme,ke.isPdfFile,ke.noContextMenu,ke.normalizeUnicode,ke.setLayerDimensions,ke.shadow,ke.stopEvent;var qU=ke.version;const KU=a.defineComponent({name:"QModal",components:{QIcon:C0},props:{id:{type:String,default:"q-modal"},closeButtonClass:{type:String,default:""},containerClass:{type:String,default:"h-fit min-h-fit"},dismissible:{type:Boolean,default:!0},dismissibleOverlay:{type:Boolean,default:!0},dismissText:{type:String,default:""},overlay:{type:String,default:"white-transparent"},size:{type:String,default:"md"},showCancelLink:{type:Boolean,default:!1},hasBuildingBg:{type:Boolean,default:!1}},emits:["close"],setup(n,{emit:e}){a.provide("size",n.size);const t=()=>{n.dismissible&&e("close")};return a.onUnmounted(()=>{document.body.classList.remove("scroll-disabled")}),a.onMounted(()=>{document.body.classList.add("scroll-disabled")}),{onCloseModal:t}}});function YU(n,e,t,r,i,o){const s=a.resolveComponent("q-icon");return a.openBlock(),a.createElementBlock("div",{ref:"currentModal",class:a.normalizeClass(["q-modal",n.overlay]),onKeydown:e[3]||(e[3]=a.withKeys((...l)=>n.onCloseModal&&n.onCloseModal(...l),["escape"]))},[a.createElementVNode("div",a.mergeProps({class:"overlay"},{[a.toHandlerKey(n.dismissibleOverlay&&"click")]:e[0]||(e[0]=(...l)=>n.onCloseModal&&n.onCloseModal(...l))}),null,16),a.createElementVNode("div",{class:a.normalizeClass(["modal-container flex flex-col relative","modal-"+n.size,n.containerClass,{"building-background":n.hasBuildingBg}])},[n.dismissible?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["modal-close-button",n.closeButtonClass]),onClick:e[1]||(e[1]=(...l)=>n.onCloseModal&&n.onCloseModal(...l))},[a.createVNode(s,{icon:"close",type:"line",color:"gray-40"})],2)):a.createCommentVNode("",!0),a.renderSlot(n.$slots,"default",{},void 0,!0),n.showCancelLink?(a.openBlock(),a.createElementBlock("a",{key:1,class:"modal-close-link",href:"#",onClick:e[2]||(e[2]=a.withModifiers(l=>n.$emit("close"),["prevent"]))},a.toDisplayString(n.$t("HC_CANCEL")),1)):a.createCommentVNode("",!0)],2)],34)}const cm=Se(KU,[["render",YU],["__scopeId","data-v-8867a052"]]),QU=a.defineComponent({name:"QErrorModal",components:{QModal:cm},props:{toggle:{type:Boolean,default:!1,required:!0}},emits:["update:toggle"],setup(n,{emit:e}){return{toggleModal:a.computed({get:()=>n.toggle,set:r=>{e("update:toggle",r)}}),mq:fn}}}),XU={class:"flex flex-col gap-2 text-center"},JU={class:"text-lg font-bold text-inkwell-30 leading-6"},eZ={class:"text-inkwell-0 mb-2 md:mb-6"};function tZ(n,e,t,r,i,o){const s=a.resolveComponent("q-icon"),l=a.resolveComponent("q-button"),c=a.resolveComponent("q-modal-content"),d=a.resolveComponent("q-modal");return a.openBlock(),a.createBlock(a.Transition,{name:n.mq.md?"fade":"slide-up"},{default:a.withCtx(()=>[n.toggleModal?(a.openBlock(),a.createBlock(d,{key:0,id:"error-modal",dismissible:!1,overlay:n.mq.md?"white-transparent":"black-transparent",class:"!z-[170]",onClose:e[1]||(e[1]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(c,null,{body:a.withCtx(()=>[a.createElementVNode("div",XU,[a.createVNode(s,{icon:"exclamation-circle",type:"outline",size:"xl",color:"red-30",class:"shrink-0 self-center mb-4"}),a.createElementVNode("h2",JU,[a.renderSlot(n.$slots,"headline",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_ERROR")),1)],!0)]),a.createElementVNode("p",eZ,[a.renderSlot(n.$slots,"subtext",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_SORRY_UNEXPECTED_EXIT_MODAL")),1)],!0)])])]),footer:a.withCtx(()=>[a.createVNode(l,{class:a.normalizeClass([n.mq.md?"mx-3":"w-full"]),size:"lg",status:"secondary",onClick:e[0]||(e[0]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_EXIT")),1)]),_:1},8,["class"])]),_:3})]),_:3},8,["overlay"])):a.createCommentVNode("",!0)]),_:3},8,["name"])}const Tk=Se(QU,[["render",tZ],["__scopeId","data-v-3aa658e4"]]);WU.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${qU}/legacy/build/pdf.worker.min.mjs`;const nZ=a.defineComponent({name:"PdfViewer",components:{QErrorModal:Tk},props:{url:{type:String,required:!0}},emits:["pdf-error"],setup(n,{emit:e}){let t=null;const r=2,i=16,o=a.ref([]),s=a.ref(!0),l=a.ref(!1),c=a.ref(0),d=async()=>{try{if(t=await GU(n.url).promise,!t)throw new Error("pdfDoc is null or undefined");c.value=t.numPages,s.value=!1,await a.nextTick(),o.value=Array.from(document.querySelectorAll(".pdf-pages canvas")),await u()}catch(h){l.value=!0,console.log(h),s.value=!1,e("pdf-error",!0)}},u=async()=>{try{for(let h=1;h<=c.value;h++)await f(h)}catch(h){console.log(h),l.value=!0,e("pdf-error",!0)}},f=async h=>{try{const p=await(t==null?void 0:t.getPage(h));if(!p)throw new Error(`Page ${h} does not exist in the PDF document`);const b=p.getViewport({scale:1}),y=o.value[h-1];if(!y)throw new Error(`Canvas for page ${h} does not exist`);const w=y.getContext("2d");if(!w)throw new Error(`Context for page ${h} does not exist`);y.height=b==null?void 0:b.height,y.width=b==null?void 0:b.width;const v={canvasContext:w,viewport:b};await(p==null?void 0:p.render(v))}catch(p){console.log(p),l.value=!0,e("pdf-error",!0)}};return a.onMounted(()=>{d()}),{skeletonColumns:r,skeletonRows:i,canvasRefs:o,loadingMeta:s,showErrorModal:l,totalPages:c,loadPDF:d,renderPage:f}}}),rZ={class:"q-pdf-viewer"},iZ={key:0},oZ={key:1,class:"pdf-pages"};function sZ(n,e,t,r,i,o){const s=a.resolveComponent("q-error-modal");return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",rZ,[n.loadingMeta?(a.openBlock(),a.createElementBlock("div",iZ,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.skeletonRows,l=>(a.openBlock(),a.createElementBlock("div",{key:l,class:"flex items-center p-4"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.skeletonColumns,c=>(a.openBlock(),a.createElementBlock("div",{key:c,class:a.normalizeClass(["h-[1.5rem] border-white w-11/12",(l-1)%2?"bg-gray-10":"bg-gray-30",(l-1)%4||c===1?"animate-shimmer":"!hidden"])},null,2))),128))]))),128))])):(a.openBlock(),a.createElementBlock("div",oZ,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.totalPages,l=>(a.openBlock(),a.createElementBlock("canvas",{key:l,class:"w-full"}))),128))]))]),n.showErrorModal?(a.openBlock(),a.createBlock(s,{key:0,toggle:n.showErrorModal,"onUpdate:toggle":[e[0]||(e[0]=l=>n.showErrorModal=l),e[1]||(e[1]=l=>n.showErrorModal=!1)]},null,8,["toggle"])):a.createCommentVNode("",!0)],64)}const Ik=Se(nZ,[["render",sZ],["__scopeId","data-v-da5da0f5"]]),aZ=a.defineComponent({name:"QTooltip",props:{id:{type:String,default:"tooltip"},color:{type:String,default:"inkwell-30"},disabled:{type:Boolean,default:!1},noWrap:{type:Boolean,default:!0},position:{type:String,default:"bottom"},relative:{type:Boolean,default:!1},show:{type:Boolean,default:!1},tooltipClasses:{type:[String,Array,Object],default:""}}}),lZ=["aria-describedby"],cZ=["id"];function dZ(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["tooltip-container",n.show?"show":""]),"aria-describedby":n.id},[a.renderSlot(n.$slots,"trigger",{},void 0,!0),a.createElementVNode("div",{id:n.id,class:a.normalizeClass(["tooltip",n.color?"bg-"+n.color+" border-"+n.color:"",n.position,n.noWrap?"no-wrap":"",n.relative?"relative":"",n.disabled?"!hidden":"",n.tooltipClasses]),role:"tooltip"},[a.renderSlot(n.$slots,"content",{},void 0,!0)],10,cZ)],10,lZ)}const R2=Se(aZ,[["render",dZ],["__scopeId","data-v-b63dd861"]]),V2=()=>{const n=a.ref(""),e=navigator.userAgent;return e.match("/Android|webOS|iPhone|iPod|BlackBerry/i")?n.value="mobile":e.match("/iPad|Tablet/i")||navigator.maxTouchPoints&&navigator.maxTouchPoints>=0&&!window.matchMedia("(pointer:fine)").matches?n.value="tablet":n.value="desktop",{deviceType:n}},uZ=a.defineComponent({name:"ImageGallery",components:{Galleria:xS,QBadge:Zs,QBottomSheet:Cw,QMenu:z4,QPdfViewer:Ik,QTooltip:R2},props:{id:{type:String,default:"image-gallery"},files:{type:Array,default:()=>[]},thumbnailsVisible:{type:Number,default:4},showOnHover:{type:Boolean,default:!0},showThumbnails:{type:Boolean,default:!0},showRemove:{type:[Boolean,Number],default:!1},baseZIndex:{type:Number,default:1e3},wrap:{type:Boolean,default:!0},processing:{type:Boolean,default:!1}},emits:["update:model-value","update:activeIndex","click:file"],setup(n,{emit:e}){const{t}=no(),{deviceType:r}=V2(),i=[{text:t("HC_CANCEL")}],o=new Set(["doc","eps","mp3","mp4","mov","prt","pdf","ppt","tiff","txt","zip"]),s={docx:"doc",pptx:"ppt",tif:"tiff",xls:"xsl",xlsx:"xsl"},l=a.ref(null),c=a.computed(()=>{var P;return(P=l.value)==null?void 0:P.offsetWidth}),d=a.ref(null),u=a.ref([]),f=a.ref(!1),h=a.ref(null),p=a.ref("0"),g=a.ref(1),b=a.ref(fn.md?1:.9),y=a.ref(0),w=a.ref(null),v=a.ref(),S=a.ref(!1),C=a.ref(!1),A=a.computed(()=>[`z-[${n.baseZIndex+1}]`]),k=a.computed(()=>n.files.map(P=>{const _=P instanceof File,$=_?P.name:P.original.url,Y=G($.toLowerCase()).replace(/^\./,""),oe=Y?o.has(Y)?Y:s[Y]||"txt":"txt";return _?{id:P.lastModified+"-"+P.name.replace(/[\s.]/g,""),originalFile:P,name:P.name,url:URL.createObjectURL(P),type:P.type,extension:Y,icon:oe,isImage:P.type.startsWith("image")&&!P.type.includes("tif")}:{id:P.id,originalFile:P,name:P.original.name,url:P.original.url,type:P.mimetype,extension:Y,icon:oe,isImage:P.mimetype.startsWith("image")&&!P.mimetype.includes("tif")}})),E=a.computed(()=>k.value.filter(P=>P.type.startsWith("image")&&!P.type.includes("tif"))),O=a.computed(()=>["rounded-lg relative mx-auto object-cover grow-1 max-h-[74vh]",{animated:!K}]),x=a.computed(()=>["flex items-center gap-3",n.wrap?"flex-wrap":"flex-nowrap overflow-x-auto shrink-0",{"flex-nowrap overflow-x-auto":r.value!=="desktop"}]),N=a.computed(()=>[{text:t("HC_DELETE_ATTACHMENT"),classes:"!text-red-20",event:H}]),D=P=>{r.value==="desktop"?window.open(P.url,"_blank"):window.open(P.url,"_self")},B=P=>{r.value==="desktop"?D(P):(w.value=P,C.value=!0)},z=P=>{P.event(),f.value=!1},Z=(P,_)=>{!f.value&&_.isImage?U(P,_):!f.value&&!_.isImage&&B(_)},U=(P,_)=>{const $=oe=>oe.url===(_==null?void 0:_.url),Y=E.value.findIndex($);y.value=Y!==-1?Y:P,S.value=!0},H=(P=null)=>{var _;f.value=!1,e("update:model-value",(P==null?void 0:P.originalFile)||((_=h.value)==null?void 0:_.originalFile))},V=P=>{const{keyCode:_}=P;if(S.value)switch(_){case 37:y.value=y.value?y.value-1:E.value.length-1,e("update:activeIndex",y.value);break;case 39:y.value=y.value<E.value.length-1?y.value+1:0,e("update:activeIndex",y.value);break;case 27:S.value=!1;break}},{isSwiping:K,lengthX:R}=qP(d,{passive:!1,onSwipe(){const P=Math.abs(R.value);c.value&&(g.value=1.1-P/c.value,p.value=R.value<0?`${P/4}px`:`-${P/4}px`)},onSwipeEnd(){const P=y.value<=0,_=y.value>=E.value.length-1,$=Math.abs(R.value);c.value&&$/c.value>=.5?(R.value<0?y.value=P?E.value.length-1:y.value-1:y.value=_?0:y.value+1,p.value="0",g.value=1):(p.value="0",g.value=1)}}),G=P=>P.substring(P.lastIndexOf(".")),re=(P,_)=>{P.preventDefault(),h.value=k.value[_],f.value=!0},Q=()=>{f.value=!1,h.value=null},F=()=>{r.value!=="desktop"&&u.value.forEach(P=>{FP(P,_=>{const $=u.value.indexOf(P);re(_,$)},{modifiers:{prevent:!0}})})};return a.onMounted(()=>{window.addEventListener("keyup",V),F()}),a.onUpdated(()=>{F()}),{menuActions:i,linkActions:N,deviceType:r,container:l,containerWidth:c,featuredPhoto:d,longPressRef:u,longPressedHook:f,isSwiping:K,lengthX:R,left:p,opacity:g,scale:b,showCarousel:S,showFileViewer:C,active:y,activeAttachment:w,hoveredIndex:v,closeIconClasses:A,itemClasses:O,images:E,normalizedFiles:k,thumbnailContainerClasses:x,downloadDocument:D,getExtension:G,onAttachmentClick:B,onClickMenuLink:z,onClickThumbnail:Z,onOpenCarousel:U,onRemoveFile:H,onKeyboardNavigation:V,onLongPressCallbackHook:re,resetHook:Q,mq:fn}}}),fZ=["id"],hZ=["id"],pZ=["src","alt"],mZ=["id","alt","src"],gZ=["id","onMouseover","onClick"],yZ=["alt","src"],bZ={key:1,class:"bg-gray-00 cursor-pointer p-3 h-16 max-w-[14rem] rounded-lg border border-gray-20 flex items-center"},wZ={class:"grow text-ellipsis overflow-hidden"},vZ={class:"text-inkwell-30 bold leading-normal text-nowrap text-ellipsis text-sm overflow-hidden -mt-1"},CZ={class:"uppercase text-xxs"},SZ={key:2,class:"image-overlay absolute top-0 left-0 w-full h-full cursor-pointer"},kZ={key:0,class:"absolute top-0 left-0 z-1 w-full h-full cursor-pointer bg-black/50 rounded-lg flex items-center justify-center"},MZ={key:1,width:"100%",height:"auto",controls:"",class:"bg-black"},EZ=["src"],AZ={class:"flex items-center flex-col p-12"},TZ=["src"],IZ=["data","type"],xZ={class:"flex items-center flex-col p-12"};function OZ(n,e,t,r,i,o){const s=a.resolveComponent("q-icon"),l=a.resolveComponent("Galleria"),c=a.resolveComponent("q-badge"),d=a.resolveComponent("q-tooltip"),u=a.resolveComponent("q-menu"),f=a.resolveComponent("q-pdf-viewer"),h=a.resolveComponent("q-bottom-sheet");return a.openBlock(),a.createElementBlock("div",{id:n.id,class:"q-image-gallery flex",ref:"container"},[a.createVNode(l,{activeIndex:n.active,"onUpdate:activeIndex":e[0]||(e[0]=p=>n.active=p),visible:n.showCarousel,"onUpdate:visible":e[1]||(e[1]=p=>n.showCarousel=p),value:n.images,numVisible:n.thumbnailsVisible,circular:!0,fullScreen:!0,showItemNavigators:n.mq.md,showThumbnailNavigators:!0,showThumbnails:n.showThumbnails&&n.mq.md,showIndicators:!n.mq.md,containerStyle:[{height:"100vh"}],"base-z-index":n.baseZIndex},{closeicon:a.withCtx(()=>[a.createVNode(s,{class:a.normalizeClass(n.closeIconClasses),icon:"times-circle",type:"outline",size:"lg",color:"white"},null,8,["class"])]),item:a.withCtx(({item:p})=>[a.createElementVNode("div",{id:`gallery-featured${p.id?"-"+p.id:""}`,ref:"featuredPhoto",class:"featured-image h-[80vh] overflow-hidden flex max-w-screen relative md:h-full w-screen items-center"},[a.createElementVNode("img",{src:p==null?void 0:p.url,alt:p==null?void 0:p.alt,class:a.normalizeClass(n.itemClasses),style:a.normalizeStyle([{left:n.left,opacity:n.opacity},`transform: scale(${n.scale})`])},null,14,pZ)],8,hZ)]),thumbnail:a.withCtx(({item:p})=>[a.createElementVNode("img",{id:`gallery-image-thumbnail${p.id?"-"+p.id:""}`,alt:(p==null?void 0:p.alt)||"",src:p==null?void 0:p.url,class:"rounded-lg block min-h-24 min-w-24 max-w-24 max-h-24 object-cover"},null,8,mZ)]),previousitemicon:a.withCtx(()=>[a.createVNode(s,{icon:"chevron-circle-left",type:"outline",size:"md",color:"white"})]),nextitemicon:a.withCtx(()=>[a.createVNode(s,{icon:"chevron-circle-right",type:"outline",size:"md",color:"white"})]),previousthumbnailicon:a.withCtx(()=>[n.images.length>n.thumbnailsVisible?(a.openBlock(),a.createBlock(s,{key:0,icon:"chevron-left",type:"line",size:"sm",color:"white"})):a.createCommentVNode("",!0)]),nextthumbnailicon:a.withCtx(()=>[n.images.length>n.thumbnailsVisible?(a.openBlock(),a.createBlock(s,{key:0,icon:"chevron-right",type:"line",size:"sm",color:"white"})):a.createCommentVNode("",!0)]),_:1},8,["activeIndex","visible","value","numVisible","showItemNavigators","showThumbnails","showIndicators","base-z-index"]),n.normalizedFiles?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(n.thumbnailContainerClasses)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.normalizedFiles,(p,g)=>(a.openBlock(),a.createElementBlock("div",{ref_for:!0,ref:"longPressRef",key:p.id||p.name||g,id:`gallery-file-thumbnail-${p.id?p.id:g}`,class:a.normalizeClass(["p-0 relative rounded-lg",{"shrink-0":n.deviceType!=="desktop"}]),onMouseover:b=>n.hoveredIndex=g,onMouseleave:e[2]||(e[2]=b=>n.hoveredIndex=null),onClick:b=>n.onClickThumbnail(g,p)},[a.createVNode(d,{position:"top"},{trigger:a.withCtx(()=>[p.type&&p.type.includes("image")&&!p.type.includes("tif")?(a.openBlock(),a.createElementBlock("img",{key:0,alt:p==null?void 0:p.alt,src:p==null?void 0:p.url,class:"rounded-lg cursor-pointer w-16 h-16 object-cover bg-gray-0 border-gray-20 border"},null,8,yZ)):(a.openBlock(),a.createElementBlock("div",bZ,[a.createVNode(s,{icon:p.icon,color:"inkwell-30",class:"h-full -ml-1.5 mt-1 mr-1 rounded-lg shrink-0",size:"xl"},null,8,["icon"]),a.createElementVNode("div",wZ,[a.createElementVNode("div",vZ,a.toDisplayString(p.name),1),a.createElementVNode("div",CZ,a.toDisplayString(p.name.match(/([^.]+$)/)[0]),1)])])),n.deviceType!=="desktop"?(a.openBlock(),a.createElementBlock("div",SZ)):a.createCommentVNode("",!0),n.showRemove&&n.showOnHover&&n.hoveredIndex===g&&n.deviceType==="desktop"&&!n.processing?(a.openBlock(),a.createBlock(c,{key:3,color:"inkwell-30",shape:"circle",class:"cursor-pointer absolute -top-2 -right-2 shadow-solid z-10",onClick:a.withModifiers(b=>n.onRemoveFile(p),["stop"])},{icon:a.withCtx(()=>[a.createVNode(s,{icon:"close",size:"xs",type:"line",color:"white"})]),_:2},1032,["onClick"])):a.createCommentVNode("",!0)]),content:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(p.name),1)]),_:2},1024),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.processing?(a.openBlock(),a.createElementBlock("div",kZ,e[7]||(e[7]=[a.createElementVNode("svg",{class:"animate-spin fill-white",width:"20",height:"20",viewBox:"0 0 24 24"},[a.createElementVNode("path",{d:"M2 12a1 1 0 0 1 2 0 8 8 0 1 0 8-8 1 1 0 0 1 0-2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12z"})],-1)]))):a.createCommentVNode("",!0)]),_:1})],42,gZ))),128)),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.longPressedHook?(a.openBlock(),a.createBlock(u,{key:0,modelValue:n.longPressedHook,"onUpdate:modelValue":e[3]||(e[3]=p=>n.longPressedHook=p),actions:n.menuActions,links:n.linkActions,"links-background":"light-gray","onClick:link":n.onClickMenuLink,"onClick:action":e[4]||(e[4]=p=>n.longPressedHook=!1)},null,8,["modelValue","actions","links","onClick:link"])):a.createCommentVNode("",!0)]),_:1})],2)):a.createCommentVNode("",!0),a.createVNode(a.Transition,{name:"slide-up-fade"},{default:a.withCtx(()=>[n.showFileViewer&&n.activeAttachment?(a.openBlock(),a.createBlock(h,{key:0,id:"gallery-file-viewer",modelValue:n.showFileViewer,"onUpdate:modelValue":e[6]||(e[6]=p=>n.showFileViewer=p),"show-close-button":!1,"content-class":"p-0","header-class":"border-b border-solid border-gray-20","title-class":"min-w-0 truncate"},{header:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.activeAttachment.name),1)]),headerAction:a.withCtx(()=>[!n.activeAttachment.type.includes("video")&&n.activeAttachment.type!=="audio/mpeg"&&n.activeAttachment.type!=="application/pdf"?(a.openBlock(),a.createBlock(s,{key:0,icon:"arrow-to-bottom",type:"line",size:"md",color:"inkwell-40",class:"shrink-0 cursor-pointer",onClick:e[5]||(e[5]=p=>n.downloadDocument(n.activeAttachment))})):a.createCommentVNode("",!0)]),default:a.withCtx(()=>[n.activeAttachment.type==="application/pdf"?(a.openBlock(),a.createBlock(f,{key:0,url:n.activeAttachment.url},null,8,["url"])):n.activeAttachment.type.includes("video")?(a.openBlock(),a.createElementBlock("video",MZ,[a.createElementVNode("source",{src:n.activeAttachment.url,type:"video/mp4"},null,8,EZ),a.createElementVNode("div",AZ,[a.createVNode(s,{color:"inkwell-30",icon:"mp4",size:"xl"}),a.createTextVNode(" "+a.toDisplayString(n.activeAttachment.extension),1)])])):n.activeAttachment.type==="audio/mpeg"?(a.openBlock(),a.createElementBlock("audio",{key:2,controls:"",src:n.activeAttachment.url,class:"mx-auto my-6"},null,8,TZ)):(a.openBlock(),a.createElementBlock("object",{key:3,data:n.activeAttachment.url,type:n.activeAttachment.type,class:"w-full h-auto"},[a.createElementVNode("div",xZ,[a.createVNode(s,{icon:n.activeAttachment.icon,size:"xl",color:"inkwell-30"},null,8,["icon"]),a.createTextVNode(" "+a.toDisplayString(n.activeAttachment.extension),1)])],8,IZ))]),_:1},8,["modelValue"])):a.createCommentVNode("",!0)]),_:1})],8,fZ)}const x6=Se(uZ,[["render",OZ],["__scopeId","data-v-82fb8862"]]),DZ=a.defineComponent({name:"QWarningModal",components:{QModal:cm},props:{toggle:{type:Boolean,default:!1,required:!0},action:{type:Function,default:()=>{}},processing:{type:Boolean,default:!1}},emits:["update:toggle","update:action"],setup(n,{emit:e}){return{toggleModal:a.computed({get:()=>n.toggle,set:r=>{e("update:toggle",r)}}),mq:fn}}}),NZ={key:0,class:"flex flex-col gap-2 text-center"},PZ={class:"text-lg font-bold text-inkwell-30 leading-6"},LZ={class:"text-inkwell-0 mb-6"},BZ={key:1,class:"flex flex-col gap-2 text-center"},_Z={class:"text-[1.25rem] font-bold text-center text-inkwell-30"},RZ={class:"text-sm text-center text-inkwell-0 mb-2"},VZ={class:"flex flex-col items-center justify-center gap-3 md:gap-2"};function $Z(n,e,t,r,i,o){const s=a.resolveComponent("q-button"),l=a.resolveComponent("q-modal-content"),c=a.resolveComponent("q-modal");return a.openBlock(),a.createBlock(a.Transition,{name:n.mq.md?"fade":"slide-up"},{default:a.withCtx(()=>[n.toggleModal?(a.openBlock(),a.createBlock(c,{key:0,class:"warning-modal !z-[170]",dismissible:!1,overlay:n.mq.md?"white-transparent":"black-transparent","container-class":"h-fit min-h-fit",onClose:e[1]||(e[1]=d=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(l,null,{body:a.withCtx(()=>[n.mq.md?(a.openBlock(),a.createElementBlock("div",NZ,[a.createElementVNode("h2",PZ,[a.renderSlot(n.$slots,"desktopHeader",{},void 0,!0)]),a.createElementVNode("p",LZ,[a.renderSlot(n.$slots,"desktopMessage",{},void 0,!0)])])):(a.openBlock(),a.createElementBlock("div",BZ,[a.createElementVNode("h2",_Z,[a.renderSlot(n.$slots,"mobileHeader",{},void 0,!0)]),a.createElementVNode("p",RZ,[a.renderSlot(n.$slots,"mobileMessage",{},void 0,!0)])]))]),footer:a.withCtx(()=>[a.createElementVNode("div",VZ,[a.createVNode(s,{disabled:n.processing,loading:n.processing,class:a.normalizeClass([n.mq.md?"mx-2":"w-full"]),size:"lg",status:"danger",onClick:n.action},{default:a.withCtx(()=>[a.renderSlot(n.$slots,"buttonText",{},void 0,!0)]),_:3},8,["disabled","loading","class","onClick"]),a.createVNode(s,{class:a.normalizeClass([n.mq.md?"mx-2":"w-full"]),disabled:n.processing,status:n.mq.md?"link-secondary":"secondary",size:"lg",onClick:e[0]||(e[0]=d=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.renderSlot(n.$slots,"cancelText",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_CANCEL")),1)],!0)]),_:3},8,["class","disabled","status"])])]),_:3})]),_:3},8,["overlay"])):a.createCommentVNode("",!0)]),_:3},8,["name"])}const xk=Se(DZ,[["render",$Z],["__scopeId","data-v-db0b6069"]]),FZ=a.defineComponent({name:"QPopover",props:{align:{type:String,default:"left"},hasCaret:{type:Boolean,default:!0},modelValue:{type:Boolean,default:!1},position:{type:String,default:"bottom"},reposition:{type:Boolean,default:!0},size:{type:String,default:"md"},trigger:{type:String,default:"click"}},emits:["update:modelValue"],setup(n,{emit:e}){const t=a.ref(!1),r=a.ref(""),i=a.ref(null),o=a.computed(()=>t.value===!0&&n.reposition===!0?l(n.align):n.align),s=a.computed(()=>t.value===!0&&n.reposition===!0?c(n.position):n.position),l=y=>{if(!i.value||d(i.value.children[1]))return y;const w=i.value.children[0].getBoundingClientRect(),v=i.value.children[1].getBoundingClientRect();if(y==="left"||y==="right"||y==="center"){const S=w.left;return window.innerWidth-S<v.width?"right":"left"}else{const S=w.top;return window.innerHeight-S<v.height?"bottom":"top"}},c=y=>{if(!i.value||d(i.value.children[1]))return y;const w=i.value.children[0].getBoundingClientRect(),v=i.value.children[1].getBoundingClientRect();if(y==="top"||y==="bottom"){const S=w.top;return window.innerHeight-S<v.height?"top":"bottom"}else{const S=w.left;return window.innerWidth-S<v.width?"left":"right"}},d=y=>{const w=y.getBoundingClientRect();return w?w.top>=0&&w.left>=0&&w.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&w.right<=(window.innerWidth||document.documentElement.clientWidth):!1},u=()=>{(n.trigger==="click"||n.trigger==="both")&&e("update:modelValue",!n.modelValue)},f=()=>{n.trigger!=="click"&&e("update:modelValue",!1)},h=()=>{n.trigger!=="click"&&e("update:modelValue",!0)},p=()=>{var w;const y=(w=i.value)==null?void 0:w.children[0];if(y){const v=y.clientWidth,S=y.clientHeight;switch(o.value){case"left":r.value=`margin-left: ${v/2-10}px;`;break;case"right":r.value=`margin-right: ${v/2-10}px;`;break;case"top":r.value=`margin-top: ${S/2-10}px;`;break;case"bottom":r.value=`margin-bottom: ${S/2-10}px;`;break}}};Yh(i,()=>{e("update:modelValue",!1)});function g(){t.value=!1}function b(){var y;t.value=!0,!d((y=i.value)==null?void 0:y.children[1])&&n.reposition===!0&&p()}return{entered:t,offsetStyle:r,popover:i,alignment:o,positioning:s,getAlignment:l,getPositioning:c,isElementInView:d,onAfterLeave:g,onClick:u,onClickOutside:Yh,onEnter:b,onMouseLeave:f,onMouseOver:h}}});function jZ(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{ref:"popover",class:"popover-container",onMouseleave:e[0]||(e[0]=(...s)=>n.onMouseLeave&&n.onMouseLeave(...s))},[a.renderSlot(n.$slots,"trigger",{onClick:n.onClick,onMouseOver:n.onMouseOver},void 0,!0),a.createVNode(a.Transition,{name:"fade",onEnter:n.onEnter,onAfterLeave:n.onAfterLeave},{default:a.withCtx(()=>[n.modelValue?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["popover","popover-"+n.alignment,"popover-"+n.size,"popover-on-"+n.positioning,{"has-caret":n.hasCaret}]),style:a.normalizeStyle(n.offsetStyle)},[a.renderSlot(n.$slots,"content",{},void 0,!0)],6)):a.createCommentVNode("",!0)]),_:3},8,["onEnter","onAfterLeave"])],544)}const Ok=Se(FZ,[["render",jZ],["__scopeId","data-v-86f2575d"]]);function mn(n){this.content=n}mn.prototype={constructor:mn,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new mn(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new mn(t)},addToStart:function(n,e){return new mn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new mn(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new mn(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=mn.from(n),n.size?new mn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=mn.from(n),n.size?new mn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=mn.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},mn.from=function(n){if(n instanceof mn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new mn(e)};function Dk(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Dk(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Nk(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),c=s.nodeSize;if(s==l){t-=c,r-=c;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let d=0,u=Math.min(s.text.length,l.text.length);for(;d<u&&s.text[s.text.length-d-1]==l.text[l.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let d=Nk(s.content,l.content,t-1,r-1);if(d)return d}t-=c,r-=c}}class J{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,l=0;l<t;s++){let c=this.content[s],d=l+c.nodeSize;if(d>e&&r(c,i+l,o||null,s)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),r,i+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=d},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new J(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],c=s+l.nodeSize;c>e&&((s<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=c}return new J(r,i)}cutByIndex(e,t){return e==t?J.empty:e==0&&t==this.content.length?this:new J(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new J(i,o)}addToStart(e){return new J([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new J(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Dk(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nk(this,e,t,r)}findIndex(e,t=-1){if(e==0)return dm(0,e);if(e==this.size)return dm(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?dm(r+1,s):dm(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return J.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new J(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return J.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new J(t||e,r)}static from(e){if(!e)return J.empty;if(e instanceof J)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new J([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}J.empty=new J([],0);const O6={index:0,offset:0};function dm(n,e){return O6.index=n,O6.offset=e,O6}function um(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!um(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!um(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let rt=class N9{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&um(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return N9.none;if(e instanceof N9)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};rt.none=[];class fm extends Error{}class le{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Lk(this.content,e+this.openStart,t);return r&&new le(r,this.openStart,this.openEnd)}removeBetween(e,t){return new le(Pk(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return le.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new le(J.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new le(e,r,i)}}le.empty=new le(J.empty,0,0);function Pk(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Pk(o.content,e-i-1,t-i-1)))}function Lk(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Lk(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function zZ(n,e,t){if(t.openStart>n.depth)throw new fm("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fm("Inconsistent open depths");return Bk(n,e,t,0)}function Bk(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Bk(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return $0(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=HZ(t,n);return $0(o,Rk(n,s,l,e,r))}else return $0(o,hm(n,e,r))}function _k(n,e){if(!e.type.compatibleContent(n.type))throw new fm("Cannot join "+e.type.name+" onto "+n.type.name)}function D6(n,e,t){let r=n.node(t);return _k(r,e.node(t)),r}function V0(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hd(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(V0(n.nodeAfter,r),o++));for(let l=o;l<s;l++)V0(i.child(l),r);e&&e.depth==t&&e.textOffset&&V0(e.nodeBefore,r)}function $0(n,e){return n.type.checkContent(e),n.copy(e)}function Rk(n,e,t,r,i){let o=n.depth>i&&D6(n,e,i+1),s=r.depth>i&&D6(t,r,i+1),l=[];return Hd(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(_k(o,s),V0($0(o,Rk(n,e,t,r,i+1)),l)):(o&&V0($0(o,hm(n,e,i+1)),l),Hd(e,t,i,l),s&&V0($0(s,hm(t,r,i+1)),l)),Hd(r,null,i,l),new J(l)}function hm(n,e,t){let r=[];if(Hd(null,n,t,r),n.depth>t){let i=D6(n,e,t+1);V0($0(i,hm(n,e,t+1)),r)}return Hd(e,null,t,r),new J(r)}function HZ(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(J.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ud{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return rt.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new pm(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:c}=s.content.findIndex(o),d=o-c;if(r.push(s,l,i+c),!d||(s=s.child(l),s.isText))break;o=d-1,i+=c+1}return new Ud(t,r,o)}static resolveCached(e,t){for(let i=0;i<N6.length;i++){let o=N6[i];if(o.pos==t&&o.doc==e)return o}let r=N6[P6]=Ud.resolve(e,t);return P6=(P6+1)%UZ,r}}let N6=[],P6=0,UZ=12;class pm{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ZZ=Object.create(null);let F0=class P9{constructor(e,t,r,i=rt.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||J.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&um(this.attrs,t||e.defaultAttrs||ZZ)&&rt.sameSet(this.marks,r||rt.none)}copy(e=null){return e==this.content?this:new P9(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new P9(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return le.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),d=i.node(s).content.cut(i.pos-l,o.pos-l);return new le(d,i.depth-s,o.depth-s)}replace(e,t,r){return zZ(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Ud.resolveCached(this,e)}resolveNoCache(e){return Ud.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Vk(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=J.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;c<o;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=rt.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!rt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=J.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};F0.prototype.text=void 0;class mm extends F0{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Vk(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mm(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mm(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Vk(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class j0{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new WZ(e,t);if(r.next==null)return j0.empty;let i=$k(r);r.next&&r.err("Unexpected trailing text");let o=JZ(XZ(i));return eW(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,l){let c=s.matchFragment(e,r);if(c&&(!t||c.validEnd))return J.from(l.map(d=>d.createAndFill()));for(let d=0;d<s.next.length;d++){let{type:u,next:f}=s.next[d];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,l.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:c}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
131
|
+
`)){const r=document.createElement("div");r.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(r)}},CD=function(){return m(this,zr).replaceAll(" "," ")},g9=function(t){return t.replaceAll(" "," ")},SD=function(t){const{value:r,fontSize:i,color:o,pageIndex:s}=this._initialData;return this._hasBeenMoved||t.value!==r||t.fontSize!==i||t.color.some((l,c)=>l!==o[c])||t.pageIndex!==s},T(ut,Ps),ve(ut,"_freeTextDefaultContent",""),ve(ut,"_internalPadding",0),ve(ut,"_defaultColor",null),ve(ut,"_defaultFontSize",10),ve(ut,"_type","freetext"),ve(ut,"_editorType",De.FREETEXT);let v6=ut;class de{toSVGPath(){ct("Abstract method `toSVGPath` must be implemented.")}get box(){ct("Abstract getter `box` must be implemented.")}serialize(e,t){ct("Abstract method `serialize` must be implemented.")}static _rescale(e,t,r,i,o,s){s||(s=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)s[l]=t+e[l]*i,s[l+1]=r+e[l+1]*o;return s}static _rescaleAndSwap(e,t,r,i,o,s){s||(s=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)s[l]=t+e[l+1]*i,s[l+1]=r+e[l]*o;return s}static _translate(e,t,r,i){i||(i=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)i[o]=t+e[o],i[o+1]=r+e[o+1];return i}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,r,i,o){switch(o){case 90:return[1-t/r,e/i];case 180:return[1-e/r,1-t/i];case 270:return[t/r,1-e/i];default:return[e/r,t/i]}}static _normalizePagePoint(e,t,r){switch(r){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,r,i,o,s){return[(e+5*r)/6,(t+5*i)/6,(5*r+o)/6,(5*i+s)/6,(r+o)/2,(i+s)/2]}}ve(de,"PRECISION",1e-4);const Ls=class Ls{constructor({x:e,y:t},r,i,o,s,l=0){T(this,Wt);T(this,Ur);T(this,Ui,[]);T(this,o1);T(this,s1);T(this,Do,[]);T(this,Re,new Float32Array(18));T(this,Ql);T(this,Xl);T(this,fh);T(this,hh);T(this,a1);T(this,l1);T(this,n0,[]);M(this,Ur,r),M(this,l1,o*i),M(this,s1,s),m(this,Re).set([NaN,NaN,NaN,NaN,e,t],6),M(this,o1,l),M(this,hh,m(Ls,ph)*i),M(this,fh,m(Ls,bg)*i),M(this,a1,i),m(this,n0).push(e,t)}isEmpty(){return isNaN(m(this,Re)[8])}add({x:e,y:t}){var E;M(this,Ql,e),M(this,Xl,t);const[r,i,o,s]=m(this,Ur);let[l,c,d,u]=m(this,Re).subarray(8,12);const f=e-d,h=t-u,p=Math.hypot(f,h);if(p<m(this,fh))return!1;const g=p-m(this,hh),b=g/p,y=b*f,w=b*h;let v=l,S=c;l=d,c=u,d+=y,u+=w,(E=m(this,n0))==null||E.push(e,t);const C=y/g,A=-w/g*m(this,l1),k=C*m(this,l1);return m(this,Re).set(m(this,Re).subarray(2,8),0),m(this,Re).set([d+A,u+k],4),m(this,Re).set(m(this,Re).subarray(14,18),12),m(this,Re).set([d-A,u-k],16),isNaN(m(this,Re)[6])?(m(this,Do).length===0&&(m(this,Re).set([l+A,c+k],2),m(this,Do).push(NaN,NaN,NaN,NaN,(l+A-r)/o,(c+k-i)/s),m(this,Re).set([l-A,c-k],14),m(this,Ui).push(NaN,NaN,NaN,NaN,(l-A-r)/o,(c-k-i)/s)),m(this,Re).set([v,S,l,c,d,u],6),!this.isEmpty()):(m(this,Re).set([v,S,l,c,d,u],6),Math.abs(Math.atan2(S-c,v-l)-Math.atan2(w,y))<Math.PI/2?([l,c,d,u]=m(this,Re).subarray(2,6),m(this,Do).push(NaN,NaN,NaN,NaN,((l+d)/2-r)/o,((c+u)/2-i)/s),[l,c,v,S]=m(this,Re).subarray(14,18),m(this,Ui).push(NaN,NaN,NaN,NaN,((v+l)/2-r)/o,((S+c)/2-i)/s),!0):([v,S,l,c,d,u]=m(this,Re).subarray(0,6),m(this,Do).push(((v+5*l)/6-r)/o,((S+5*c)/6-i)/s,((5*l+d)/6-r)/o,((5*c+u)/6-i)/s,((l+d)/2-r)/o,((c+u)/2-i)/s),[d,u,l,c,v,S]=m(this,Re).subarray(12,18),m(this,Ui).push(((v+5*l)/6-r)/o,((S+5*c)/6-i)/s,((5*l+d)/6-r)/o,((5*c+u)/6-i)/s,((l+d)/2-r)/o,((c+u)/2-i)/s),!0))}toSVGPath(){if(this.isEmpty())return"";const e=m(this,Do),t=m(this,Ui);if(isNaN(m(this,Re)[6])&&!this.isEmpty())return I(this,Wt,kD).call(this);const r=[];r.push(`M${e[4]} ${e[5]}`);for(let i=6;i<e.length;i+=6)isNaN(e[i])?r.push(`L${e[i+4]} ${e[i+5]}`):r.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);I(this,Wt,ED).call(this,r);for(let i=t.length-6;i>=6;i-=6)isNaN(t[i])?r.push(`L${t[i+4]} ${t[i+5]}`):r.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return I(this,Wt,MD).call(this,r),r.join(" ")}newFreeDrawOutline(e,t,r,i,o,s){return new Ak(e,t,r,i,o,s)}getOutlines(){var f;const e=m(this,Do),t=m(this,Ui),r=m(this,Re),[i,o,s,l]=m(this,Ur),c=new Float32Array((((f=m(this,n0))==null?void 0:f.length)??0)+2);for(let h=0,p=c.length-2;h<p;h+=2)c[h]=(m(this,n0)[h]-i)/s,c[h+1]=(m(this,n0)[h+1]-o)/l;if(c[c.length-2]=(m(this,Ql)-i)/s,c[c.length-1]=(m(this,Xl)-o)/l,isNaN(r[6])&&!this.isEmpty())return I(this,Wt,AD).call(this,c);const d=new Float32Array(m(this,Do).length+24+m(this,Ui).length);let u=e.length;for(let h=0;h<u;h+=2)isNaN(e[h])?d[h]=d[h+1]=NaN:(d[h]=e[h],d[h+1]=e[h+1]);u=I(this,Wt,ID).call(this,d,u);for(let h=t.length-6;h>=6;h-=6)for(let p=0;p<6;p+=2)isNaN(t[h+p])?(d[u]=d[u+1]=NaN,u+=2):(d[u]=t[h+p],d[u+1]=t[h+p+1],u+=2);return I(this,Wt,TD).call(this,d,u),this.newFreeDrawOutline(d,c,m(this,Ur),m(this,a1),m(this,o1),m(this,s1))}};Ur=new WeakMap,Ui=new WeakMap,o1=new WeakMap,s1=new WeakMap,Do=new WeakMap,Re=new WeakMap,Ql=new WeakMap,Xl=new WeakMap,fh=new WeakMap,hh=new WeakMap,a1=new WeakMap,l1=new WeakMap,n0=new WeakMap,ph=new WeakMap,yg=new WeakMap,bg=new WeakMap,Wt=new WeakSet,Fh=function(){const e=m(this,Re).subarray(4,6),t=m(this,Re).subarray(16,18),[r,i,o,s]=m(this,Ur);return[(m(this,Ql)+(e[0]-t[0])/2-r)/o,(m(this,Xl)+(e[1]-t[1])/2-i)/s,(m(this,Ql)+(t[0]-e[0])/2-r)/o,(m(this,Xl)+(t[1]-e[1])/2-i)/s]},kD=function(){const[e,t,r,i]=m(this,Ur),[o,s,l,c]=I(this,Wt,Fh).call(this);return`M${(m(this,Re)[2]-e)/r} ${(m(this,Re)[3]-t)/i} L${(m(this,Re)[4]-e)/r} ${(m(this,Re)[5]-t)/i} L${o} ${s} L${l} ${c} L${(m(this,Re)[16]-e)/r} ${(m(this,Re)[17]-t)/i} L${(m(this,Re)[14]-e)/r} ${(m(this,Re)[15]-t)/i} Z`},MD=function(e){const t=m(this,Ui);e.push(`L${t[4]} ${t[5]} Z`)},ED=function(e){const[t,r,i,o]=m(this,Ur),s=m(this,Re).subarray(4,6),l=m(this,Re).subarray(16,18),[c,d,u,f]=I(this,Wt,Fh).call(this);e.push(`L${(s[0]-t)/i} ${(s[1]-r)/o} L${c} ${d} L${u} ${f} L${(l[0]-t)/i} ${(l[1]-r)/o}`)},AD=function(e){const t=m(this,Re),[r,i,o,s]=m(this,Ur),[l,c,d,u]=I(this,Wt,Fh).call(this),f=new Float32Array(36);return f.set([NaN,NaN,NaN,NaN,(t[2]-r)/o,(t[3]-i)/s,NaN,NaN,NaN,NaN,(t[4]-r)/o,(t[5]-i)/s,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(t[16]-r)/o,(t[17]-i)/s,NaN,NaN,NaN,NaN,(t[14]-r)/o,(t[15]-i)/s],0),this.newFreeDrawOutline(f,e,m(this,Ur),m(this,a1),m(this,o1),m(this,s1))},TD=function(e,t){const r=m(this,Ui);return e.set([NaN,NaN,NaN,NaN,r[4],r[5]],t),t+6},ID=function(e,t){const r=m(this,Re).subarray(4,6),i=m(this,Re).subarray(16,18),[o,s,l,c]=m(this,Ur),[d,u,f,h]=I(this,Wt,Fh).call(this);return e.set([NaN,NaN,NaN,NaN,(r[0]-o)/l,(r[1]-s)/c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,(i[0]-o)/l,(i[1]-s)/c],t),t+24},T(Ls,ph,8),T(Ls,yg,2),T(Ls,bg,m(Ls,ph)+m(Ls,yg));let om=Ls;class Ak extends de{constructor(t,r,i,o,s,l){super();T(this,wg);T(this,c1);T(this,Jl,new Float32Array(4));T(this,Bs);T(this,mh);T(this,Zr);T(this,gh);T(this,Bt);M(this,Bt,t),M(this,Zr,r),M(this,c1,i),M(this,gh,o),M(this,Bs,s),M(this,mh,l),this.lastPoint=[NaN,NaN],I(this,wg,xD).call(this,l);const[c,d,u,f]=m(this,Jl);for(let h=0,p=t.length;h<p;h+=2)t[h]=(t[h]-c)/u,t[h+1]=(t[h+1]-d)/f;for(let h=0,p=r.length;h<p;h+=2)r[h]=(r[h]-c)/u,r[h+1]=(r[h+1]-d)/f}toSVGPath(){const t=[`M${m(this,Bt)[4]} ${m(this,Bt)[5]}`];for(let r=6,i=m(this,Bt).length;r<i;r+=6)isNaN(m(this,Bt)[r])?t.push(`L${m(this,Bt)[r+4]} ${m(this,Bt)[r+5]}`):t.push(`C${m(this,Bt)[r]} ${m(this,Bt)[r+1]} ${m(this,Bt)[r+2]} ${m(this,Bt)[r+3]} ${m(this,Bt)[r+4]} ${m(this,Bt)[r+5]}`);return t.push("Z"),t.join(" ")}serialize([t,r,i,o],s){const l=i-t,c=o-r;let d,u;switch(s){case 0:d=de._rescale(m(this,Bt),t,o,l,-c),u=de._rescale(m(this,Zr),t,o,l,-c);break;case 90:d=de._rescaleAndSwap(m(this,Bt),t,r,l,c),u=de._rescaleAndSwap(m(this,Zr),t,r,l,c);break;case 180:d=de._rescale(m(this,Bt),i,r,-l,c),u=de._rescale(m(this,Zr),i,r,-l,c);break;case 270:d=de._rescaleAndSwap(m(this,Bt),i,o,-l,-c),u=de._rescaleAndSwap(m(this,Zr),i,o,-l,-c)}return{outline:Array.from(d),points:[Array.from(u)]}}get box(){return m(this,Jl)}newOutliner(t,r,i,o,s,l=0){return new om(t,r,i,o,s,l)}getNewOutline(t,r){const[i,o,s,l]=m(this,Jl),[c,d,u,f]=m(this,c1),h=s*u,p=l*f,g=i*u+c,b=o*f+d,y=this.newOutliner({x:m(this,Zr)[0]*h+g,y:m(this,Zr)[1]*p+b},m(this,c1),m(this,gh),t,m(this,mh),r??m(this,Bs));for(let w=2;w<m(this,Zr).length;w+=2)y.add({x:m(this,Zr)[w]*h+g,y:m(this,Zr)[w+1]*p+b});return y.getOutlines()}}c1=new WeakMap,Jl=new WeakMap,Bs=new WeakMap,mh=new WeakMap,Zr=new WeakMap,gh=new WeakMap,Bt=new WeakMap,wg=new WeakSet,xD=function(t){const r=m(this,Bt);let i=r[4],o=r[5],s=i,l=o,c=i,d=o,u=i,f=o;const h=t?Math.max:Math.min;for(let g=6,b=r.length;g<b;g+=6){if(isNaN(r[g]))s=Math.min(s,r[g+4]),l=Math.min(l,r[g+5]),c=Math.max(c,r[g+4]),d=Math.max(d,r[g+5]),f<r[g+5]?(u=r[g+4],f=r[g+5]):f===r[g+5]&&(u=h(u,r[g+4]));else{const y=ye.bezierBoundingBox(i,o,...r.slice(g,g+6));s=Math.min(s,y[0]),l=Math.min(l,y[1]),c=Math.max(c,y[2]),d=Math.max(d,y[3]),f<y[3]?(u=y[2],f=y[3]):f===y[3]&&(u=h(u,y[2]))}i=r[g+4],o=r[g+5]}const p=m(this,Jl);p[0]=s-m(this,Bs),p[1]=l-m(this,Bs),p[2]=c-s+2*m(this,Bs),p[3]=d-l+2*m(this,Bs),this.lastPoint=[u,f]};class C6{constructor(e,t=0,r=0,i=!0){T(this,Xn);T(this,yh);T(this,bh);T(this,r0,[]);T(this,Zi,[]);let o=1/0,s=-1/0,l=1/0,c=-1/0;const d=10**-4;for(const{x:y,y:w,width:v,height:S}of e){const C=Math.floor((y-t)/d)*d,A=Math.ceil((y+v+t)/d)*d,k=Math.floor((w-t)/d)*d,E=Math.ceil((w+S+t)/d)*d,O=[C,k,E,!0],x=[A,k,E,!1];m(this,r0).push(O,x),o=Math.min(o,C),s=Math.max(s,A),l=Math.min(l,k),c=Math.max(c,E)}const u=s-o+2*r,f=c-l+2*r,h=o-r,p=l-r,g=m(this,r0).at(i?-1:-2),b=[g[0],g[2]];for(const y of m(this,r0)){const[w,v,S]=y;y[0]=(w-h)/u,y[1]=(v-p)/f,y[2]=(S-p)/f}M(this,yh,new Float32Array([h,p,u,f])),M(this,bh,b)}getOutlines(){m(this,r0).sort((t,r)=>t[0]-r[0]||t[1]-r[1]||t[2]-r[2]);const e=[];for(const t of m(this,r0))t[3]?(e.push(...I(this,Xn,y9).call(this,t)),I(this,Xn,DD).call(this,t)):(I(this,Xn,ND).call(this,t),e.push(...I(this,Xn,y9).call(this,t)));return I(this,Xn,OD).call(this,e)}}yh=new WeakMap,bh=new WeakMap,r0=new WeakMap,Zi=new WeakMap,Xn=new WeakSet,OD=function(e){const t=[],r=new Set;for(const s of e){const[l,c,d]=s;t.push([l,c,s],[l,d,s])}t.sort((s,l)=>s[1]-l[1]||s[0]-l[0]);for(let s=0,l=t.length;s<l;s+=2){const c=t[s][2],d=t[s+1][2];c.push(d),d.push(c),r.add(c),r.add(d)}const i=[];let o;for(;r.size>0;){const s=r.values().next().value;let[l,c,d,u,f]=s;r.delete(s);let h=l,p=c;for(o=[l,d],i.push(o);;){let g;if(r.has(u))g=u;else{if(!r.has(f))break;g=f}r.delete(g),[l,c,d,u,f]=g,h!==l&&(o.push(h,p,l,p===c?c:d),h=l),p=p===c?d:c}o.push(h,p)}return new zU(i,m(this,yh),m(this,bh))},Ug=function(e){const t=m(this,Zi);let r=0,i=t.length-1;for(;r<=i;){const o=r+i>>1,s=t[o][0];if(s===e)return o;s<e?r=o+1:i=o-1}return i+1},DD=function([,e,t]){const r=I(this,Xn,Ug).call(this,e);m(this,Zi).splice(r,0,[e,t])},ND=function([,e,t]){const r=I(this,Xn,Ug).call(this,e);for(let i=r;i<m(this,Zi).length;i++){const[o,s]=m(this,Zi)[i];if(o!==e)break;if(o===e&&s===t){m(this,Zi).splice(i,1);return}}for(let i=r-1;i>=0;i--){const[o,s]=m(this,Zi)[i];if(o!==e)break;if(o===e&&s===t){m(this,Zi).splice(i,1);return}}},y9=function(e){const[t,r,i]=e,o=[[t,r,i]],s=I(this,Xn,Ug).call(this,i);for(let l=0;l<s;l++){const[c,d]=m(this,Zi)[l];for(let u=0,f=o.length;u<f;u++){const[,h,p]=o[u];if(!(d<=h||p<=c))if(h>=c)if(p>d)o[u][1]=d;else{if(f===1)return[];o.splice(u,1),u--,f--}else o[u][2]=c,p>d&&o.push([t,d,p])}}return o};class zU extends de{constructor(t,r,i){super();T(this,wh);T(this,d1);M(this,d1,t),M(this,wh,r),this.lastPoint=i}toSVGPath(){const t=[];for(const r of m(this,d1)){let[i,o]=r;t.push(`M${i} ${o}`);for(let s=2;s<r.length;s+=2){const l=r[s],c=r[s+1];l===i?(t.push(`V${c}`),o=c):c===o&&(t.push(`H${l}`),i=l)}t.push("Z")}return t.join(" ")}serialize([t,r,i,o],s){const l=[],c=i-t,d=o-r;for(const u of m(this,d1)){const f=new Array(u.length);for(let h=0;h<u.length;h+=2)f[h]=t+u[h]*c,f[h+1]=o-u[h+1]*d;l.push(f)}return l}get box(){return m(this,wh)}get classNamesForOutlining(){return["highlightOutline"]}}wh=new WeakMap,d1=new WeakMap;class S6 extends om{newFreeDrawOutline(e,t,r,i,o,s){return new HU(e,t,r,i,o,s)}}class HU extends Ak{newOutliner(e,t,r,i,o,s=0){return new S6(e,t,r,i,o,s)}}const Mr=class Mr{constructor({editor:e=null,uiManager:t=null}){T(this,st);T(this,Wi,null);T(this,e2,null);T(this,u1);T(this,Gt,null);T(this,vh,!1);T(this,f1,!1);T(this,Ch,null);T(this,Sh);T(this,i0,null);T(this,Gi,null);T(this,h1);var r;e?(M(this,f1,!1),M(this,h1,Ve.HIGHLIGHT_COLOR),M(this,Ch,e)):(M(this,f1,!0),M(this,h1,Ve.HIGHLIGHT_DEFAULT_COLOR)),M(this,Gi,(e==null?void 0:e._uiManager)||t),M(this,Sh,m(this,Gi)._eventBus),M(this,u1,(e==null?void 0:e.color)||((r=m(this,Gi))==null?void 0:r.highlightColors.values().next().value)||"#FFFF98"),m(Mr,kh)||M(Mr,kh,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return _e(this,"_keyboardManager",new Ld([[["Escape","mac+Escape"],Mr.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Mr.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Mr.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Mr.prototype._moveToPrevious],[["Home","mac+Home"],Mr.prototype._moveToBeginning],[["End","mac+End"],Mr.prototype._moveToEnd]]))}renderButton(){const e=M(this,Wi,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=m(this,Gi)._signal;e.addEventListener("click",I(this,st,g2).bind(this),{signal:t}),e.addEventListener("keydown",I(this,st,v9).bind(this),{signal:t});const r=M(this,e2,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=m(this,u1),e.append(r),e}renderMainDropdown(){const e=M(this,Gt,I(this,st,b9).call(this));return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}_colorSelectFromKeyboard(e){if(e.target===m(this,Wi)){I(this,st,g2).call(this,e);return}const t=e.target.getAttribute("data-color");t&&I(this,st,w9).call(this,t,e)}_moveToNext(e){var t,r;m(this,st,m0)?e.target!==m(this,Wi)?(t=e.target.nextSibling)==null||t.focus():(r=m(this,Gt).firstChild)==null||r.focus():I(this,st,g2).call(this,e)}_moveToPrevious(e){var t,r;e.target!==((t=m(this,Gt))==null?void 0:t.firstChild)&&e.target!==m(this,Wi)?(m(this,st,m0)||I(this,st,g2).call(this,e),(r=e.target.previousSibling)==null||r.focus()):m(this,st,m0)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){var t;m(this,st,m0)?(t=m(this,Gt).firstChild)==null||t.focus():I(this,st,g2).call(this,e)}_moveToEnd(e){var t;m(this,st,m0)?(t=m(this,Gt).lastChild)==null||t.focus():I(this,st,g2).call(this,e)}hideDropdown(){var e,t;(e=m(this,Gt))==null||e.classList.add("hidden"),(t=m(this,i0))==null||t.abort(),M(this,i0,null)}_hideDropdownFromKeyboard(){var e;m(this,f1)||(m(this,st,m0)?(this.hideDropdown(),m(this,Wi).focus({preventScroll:!0,focusVisible:m(this,vh)})):(e=m(this,Ch))==null||e.unselect())}updateColor(e){if(m(this,e2)&&(m(this,e2).style.backgroundColor=e),!m(this,Gt))return;const t=m(this,Gi).highlightColors.values();for(const r of m(this,Gt).children)r.setAttribute("aria-selected",t.next().value===e)}destroy(){var e,t;(e=m(this,Wi))==null||e.remove(),M(this,Wi,null),M(this,e2,null),(t=m(this,Gt))==null||t.remove(),M(this,Gt,null)}};Wi=new WeakMap,e2=new WeakMap,u1=new WeakMap,Gt=new WeakMap,vh=new WeakMap,f1=new WeakMap,Ch=new WeakMap,Sh=new WeakMap,i0=new WeakMap,Gi=new WeakMap,h1=new WeakMap,kh=new WeakMap,st=new WeakSet,b9=function(){const e=document.createElement("div"),t=m(this,Gi)._signal;e.addEventListener("contextmenu",Di,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[r,i]of m(this,Gi).highlightColors){const o=document.createElement("button");o.tabIndex="0",o.role="option",o.setAttribute("data-color",i),o.title=r,o.setAttribute("data-l10n-id",m(Mr,kh)[r]);const s=document.createElement("span");o.append(s),s.className="swatch",s.style.backgroundColor=i,o.setAttribute("aria-selected",i===m(this,u1)),o.addEventListener("click",I(this,st,w9).bind(this,i),{signal:t}),e.append(o)}return e.addEventListener("keydown",I(this,st,v9).bind(this),{signal:t}),e},w9=function(e,t){t.stopPropagation(),m(this,Sh).dispatch("switchannotationeditorparams",{source:this,type:m(this,h1),value:e})},v9=function(e){Mr._keyboardManager.exec(this,e)},g2=function(e){if(m(this,st,m0)){this.hideDropdown();return}if(M(this,vh,e.detail===0),m(this,i0)||(M(this,i0,new AbortController),window.addEventListener("pointerdown",I(this,st,PD).bind(this),{signal:m(this,Gi).combinedSignal(m(this,i0))})),m(this,Gt)){m(this,Gt).classList.remove("hidden");return}const t=M(this,Gt,I(this,st,b9).call(this));m(this,Wi).append(t)},PD=function(e){var t;(t=m(this,Gt))!=null&&t.contains(e.target)||this.hideDropdown()},m0=function(){return m(this,Gt)&&!m(this,Gt).classList.contains("hidden")},T(Mr,kh,null);let sm=Mr;const Ye=class Ye extends Ct{constructor(t){super({...t,name:"highlightEditor"});T(this,xe);T(this,p1,null);T(this,Mh,0);T(this,_s);T(this,t2,null);T(this,m1,null);T(this,Er,null);T(this,Eh,null);T(this,Ah,0);T(this,n2,null);T(this,bi,null);T(this,Wr,null);T(this,vn,!1);T(this,g1,null);T(this,Rs);T(this,Bn,null);T(this,y1,"");T(this,wi);T(this,Th,"");this.color=t.color||Ye._defaultColor,M(this,wi,t.thickness||Ye._defaultThickness),M(this,Rs,t.opacity||Ye._defaultOpacity),M(this,_s,t.boxes||null),M(this,Th,t.methodOfCreation||""),M(this,y1,t.text||""),this._isDraggable=!1,t.highlightId>-1?(M(this,vn,!0),I(this,xe,Zg).call(this,t),I(this,xe,y2).call(this)):m(this,_s)&&(M(this,p1,t.anchorNode),M(this,Mh,t.anchorOffset),M(this,Eh,t.focusNode),M(this,Ah,t.focusOffset),I(this,xe,C9).call(this),I(this,xe,y2).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=Ye.prototype;return _e(this,"_keyboardManager",new Ld([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:m(this,vn)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:m(this,wi),methodOfCreation:m(this,Th)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,r){var i;Ct.initialize(t,r),Ye._defaultColor||(Ye._defaultColor=((i=r.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,r){switch(t){case Ve.HIGHLIGHT_DEFAULT_COLOR:Ye._defaultColor=r;break;case Ve.HIGHLIGHT_THICKNESS:Ye._defaultThickness=r}}translateInPage(t,r){}get toolbarPosition(){return m(this,g1)}updateParams(t,r){switch(t){case Ve.HIGHLIGHT_COLOR:I(this,xe,LD).call(this,r);break;case Ve.HIGHLIGHT_THICKNESS:I(this,xe,BD).call(this,r)}}static get defaultPropertiesToUpdate(){return[[Ve.HIGHLIGHT_DEFAULT_COLOR,Ye._defaultColor],[Ve.HIGHLIGHT_THICKNESS,Ye._defaultThickness]]}get propertiesToUpdate(){return[[Ve.HIGHLIGHT_COLOR,this.color||Ye._defaultColor],[Ve.HIGHLIGHT_THICKNESS,m(this,wi)||Ye._defaultThickness],[Ve.HIGHLIGHT_FREE,m(this,vn)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(M(this,m1,new sm({editor:this})),t.addColorPicker(m(this,m1))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(I(this,xe,jh).call(this))}getBaseTranslation(){return[0,0]}getRect(t,r){return super.getRect(t,r,I(this,xe,jh).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){I(this,xe,S9).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,xe,y2).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?I(this,xe,S9).call(this):t&&(I(this,xe,y2).call(this,t),r=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),r&&this.select()}rotate(t){var o,s,l;const{drawLayer:r}=this.parent;let i;m(this,vn)?(t=(t-this.rotation+360)%360,i=I(o=Ye,vi,R1).call(o,m(this,bi).box,t)):i=I(s=Ye,vi,R1).call(s,[this.x,this.y,this.width,this.height],t),r.updateProperties(m(this,Wr),{bbox:i,root:{"data-main-rotation":t}}),r.updateProperties(m(this,Bn),{bbox:I(l=Ye,vi,R1).call(l,m(this,Er).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();m(this,y1)&&(t.setAttribute("aria-label",m(this,y1)),t.setAttribute("role","mark")),m(this,vn)?t.classList.add("free"):this.div.addEventListener("keydown",I(this,xe,RD).bind(this),{signal:this._uiManager._signal});const r=M(this,n2,document.createElement("div"));t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",r.style.clipPath=m(this,t2);const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),Kp(this,m(this,n2),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:I(this,xe,Wg).call(this,!0);break;case 1:case 3:I(this,xe,Wg).call(this,!1)}}select(){var t;super.select(),m(this,Bn)&&((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),m(this,Bn)&&((t=this.parent)==null||t.drawLayer.updateProperties(m(this,Bn),{rootClass:{selected:!1}}),m(this,vn)||I(this,xe,Wg).call(this,!1))}get _mustFixPosition(){return!m(this,vn)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(m(this,Wr),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(m(this,Bn),{rootClass:{hidden:!t}}))}static startHighlighting(t,r,{target:i,x:o,y:s}){const{x:l,y:c,width:d,height:u}=i.getBoundingClientRect(),f=new AbortController,h=t.combinedSignal(f),p=g=>{f.abort(),I(this,vi,jD).call(this,t,g)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",Ir,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",Di,{signal:h}),i.addEventListener("pointermove",I(this,vi,FD).bind(this,t),{signal:h}),this._freeHighlight=new S6({x:o,y:s},[l,c,d,u],t.scale,this._defaultThickness/2,r,.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 async deserialize(t,r,i){var b,y,w,v;let o=null;if(t instanceof Mk){const{data:{quadPoints:S,rect:C,rotation:A,id:k,color:E,opacity:O,popupRef:x},parent:{page:{pageNumber:N}}}=t;o=t={annotationType:De.HIGHLIGHT,color:Array.from(E),opacity:O,quadPoints:S,boxes:null,pageIndex:N-1,rect:C.slice(0),rotation:A,id:k,deleted:!1,popupRef:x}}else if(t instanceof w6){const{data:{inkLists:S,rect:C,rotation:A,id:k,color:E,borderStyle:{rawWidth:O},popupRef:x},parent:{page:{pageNumber:N}}}=t;o=t={annotationType:De.HIGHLIGHT,color:Array.from(E),thickness:O,inkLists:S,boxes:null,pageIndex:N-1,rect:C.slice(0),rotation:A,id:k,deleted:!1,popupRef:x}}const{color:s,quadPoints:l,inkLists:c,opacity:d}=t,u=await super.deserialize(t,r,i);u.color=ye.makeHexColor(...s),M(u,Rs,d||1),c&&M(u,wi,t.thickness),u.annotationElementId=t.id||null,u._initialData=o;const[f,h]=u.pageDimensions,[p,g]=u.pageTranslation;if(l){const S=M(u,_s,[]);for(let C=0;C<l.length;C+=8)S.push({x:(l[C]-p)/f,y:1-(l[C+1]-g)/h,width:(l[C+2]-l[C])/f,height:(l[C+1]-l[C+5])/h});I(b=u,xe,C9).call(b),I(y=u,xe,y2).call(y),u.rotate(u.rotation)}else if(c){M(u,vn,!0);const S=c[0],C={x:S[0]-p,y:h-(S[1]-g)},A=new S6(C,[0,0,f,h],1,m(u,wi)/2,!0,.001);for(let O=0,x=S.length;O<x;O+=2)C.x=S[O]-p,C.y=h-(S[O+1]-g),A.add(C);const{id:k,clipPathId:E}=r.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:A.toSVGPath()}},!0,!0);I(w=u,xe,Zg).call(w,{highlightOutlines:A.getOutlines(),highlightId:k,clipPathId:E}),I(v=u,xe,y2).call(v)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const r=this.getRect(0,0),i=Ct._colorManager.convert(this.color),o={annotationType:De.HIGHLIGHT,color:i,opacity:m(this,Rs),thickness:m(this,wi),quadPoints:I(this,xe,VD).call(this),outlines:I(this,xe,$D).call(this,r),pageIndex:this.pageIndex,rect:r,rotation:I(this,xe,jh).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!I(this,xe,zD).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};p1=new WeakMap,Mh=new WeakMap,_s=new WeakMap,t2=new WeakMap,m1=new WeakMap,Er=new WeakMap,Eh=new WeakMap,Ah=new WeakMap,n2=new WeakMap,bi=new WeakMap,Wr=new WeakMap,vn=new WeakMap,g1=new WeakMap,Rs=new WeakMap,Bn=new WeakMap,y1=new WeakMap,wi=new WeakMap,Th=new WeakMap,xe=new WeakSet,C9=function(){const t=new C6(m(this,_s),.001);M(this,bi,t.getOutlines()),[this.x,this.y,this.width,this.height]=m(this,bi).box;const r=new C6(m(this,_s),.0025,.001,this._uiManager.direction==="ltr");M(this,Er,r.getOutlines());const{lastPoint:i}=m(this,Er);M(this,g1,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Zg=function({highlightOutlines:t,highlightId:r,clipPathId:i}){var u,f;if(M(this,bi,t),M(this,Er,t.getNewOutline(m(this,wi)/2+1.5,.0025)),r>=0)M(this,Wr,r),M(this,t2,i),this.parent.drawLayer.finalizeDraw(r,{bbox:t.box,path:{d:t.toSVGPath()}}),M(this,Bn,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:m(this,Er).box,path:{d:m(this,Er).toSVGPath()}},!0));else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(m(this,Wr),{bbox:I(u=Ye,vi,R1).call(u,m(this,bi).box,(h-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(m(this,Bn),{bbox:I(f=Ye,vi,R1).call(f,m(this,Er).box,h),path:{d:m(this,Er).toSVGPath()}})}const[o,s,l,c]=t.box;switch(this.rotation){case 0:this.x=o,this.y=s,this.width=l,this.height=c;break;case 90:{const[h,p]=this.parentDimensions;this.x=s,this.y=1-o,this.width=l*p/h,this.height=c*h/p;break}case 180:this.x=1-o,this.y=1-s,this.width=l,this.height=c;break;case 270:{const[h,p]=this.parentDimensions;this.x=1-s,this.y=o,this.width=l*p/h,this.height=c*h/p;break}}const{lastPoint:d}=m(this,Er);M(this,g1,[(d[0]-o)/l,(d[1]-s)/c])},LD=function(t){const r=(s,l)=>{var c,d;this.color=s,M(this,Rs,l),(c=this.parent)==null||c.drawLayer.updateProperties(m(this,Wr),{root:{fill:s,"fill-opacity":l}}),(d=m(this,m1))==null||d.updateColor(s)},i=this.color,o=m(this,Rs);this.addCommands({cmd:r.bind(this,t,Ye._defaultOpacity),undo:r.bind(this,i,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},BD=function(t){const r=m(this,wi),i=o=>{M(this,wi,o),I(this,xe,_D).call(this,o)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ve.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},_D=function(t){if(!m(this,vn))return;I(this,xe,Zg).call(this,{highlightOutlines:m(this,bi).getNewOutline(t/2)}),this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)},S9=function(){m(this,Wr)!==null&&this.parent&&(this.parent.drawLayer.remove(m(this,Wr)),M(this,Wr,null),this.parent.drawLayer.remove(m(this,Bn)),M(this,Bn,null))},y2=function(t=this.parent){m(this,Wr)===null&&({id:ir(this,Wr)._,clipPathId:ir(this,t2)._}=t.drawLayer.draw({bbox:m(this,bi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":m(this,Rs)},rootClass:{highlight:!0,free:m(this,vn)},path:{d:m(this,bi).toSVGPath()}},!1,!0),M(this,Bn,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:m(this,vn)},bbox:m(this,Er).box,path:{d:m(this,Er).toSVGPath()}},m(this,vn))),m(this,n2)&&(m(this,n2).style.clipPath=m(this,t2)))},vi=new WeakSet,R1=function([t,r,i,o],s){switch(s){case 90:return[1-r-o,t,o,i];case 180:return[1-t-i,1-r-o,i,o];case 270:return[r,1-t-i,o,i]}return[t,r,i,o]},RD=function(t){Ye._keyboardManager.exec(this,t)},Wg=function(t){if(!m(this,p1))return;const r=window.getSelection();t?r.setPosition(m(this,p1),m(this,Mh)):r.setPosition(m(this,Eh),m(this,Ah))},jh=function(){return m(this,vn)?this.rotation:0},VD=function(){if(m(this,vn))return null;const[t,r]=this.pageDimensions,[i,o]=this.pageTranslation,s=m(this,_s),l=new Float32Array(8*s.length);let c=0;for(const{x:d,y:u,width:f,height:h}of s){const p=d*t+i,g=(1-u)*r+o;l[c]=l[c+4]=p,l[c+1]=l[c+3]=g,l[c+2]=l[c+6]=p+f*t,l[c+5]=l[c+7]=g-h*r,c+=8}return l},$D=function(t){return m(this,bi).serialize(t,I(this,xe,jh).call(this))},FD=function(t,r){this._freeHighlight.add(r)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},jD=function(t,r){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(r,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},zD=function(t){const{color:r}=this._initialData;return t.color.some((i,o)=>i!==r[o])},T(Ye,vi),ve(Ye,"_defaultColor",null),ve(Ye,"_defaultOpacity",1),ve(Ye,"_defaultThickness",12),ve(Ye,"_type","highlight"),ve(Ye,"_editorType",De.HIGHLIGHT),ve(Ye,"_freeHighlightId",-1),ve(Ye,"_freeHighlight",null),ve(Ye,"_freeHighlightClipId","");let am=Ye;class UU{constructor(){T(this,r2,Object.create(null))}updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,r]of Object.entries(e))this.updateProperty(t,r)}updateSVGProperty(e,t){m(this,r2)[e]=t}toSVGProperties(){const e=m(this,r2);return M(this,r2,Object.create(null)),{root:e}}reset(){M(this,r2,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){ct("Not implemented")}}r2=new WeakMap;const ue=class ue extends Ct{constructor(t){super(t);T(this,He);T(this,Gr,null);T(this,b1);ve(this,"_drawId",null);M(this,b1,t.mustBeCommitted||!1),t.drawOutlines&&(I(this,He,k9).call(this,t),I(this,He,zh).call(this))}static _mergeSVGProperties(t,r){const i=new Set(Object.keys(t));for(const[o,s]of Object.entries(r))i.has(o)?Object.assign(t[o],s):t[o]=s;return t}static getDefaultDrawingOptions(t){ct("Not implemented")}static get typesMap(){ct("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,r){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,r),this._currentParent&&(m(ue,an).updateProperty(i,r),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,r){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,r)}static get defaultPropertiesToUpdate(){const t=[],r=this._defaultDrawingOptions;for(const[i,o]of this.typesMap)t.push([i,r[o]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:r}=this;for(const[i,o]of this.constructor.typesMap)t.push([i,r[o]]);return t}_updateProperty(t,r,i){const o=this._drawingOptions,s=o[r],l=c=>{var u;o.updateProperty(r,c);const d=m(this,Gr).updateProperty(r,c);d&&I(this,He,Hh).call(this,d),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,o.toSVGProperties())};this.addCommands({cmd:l.bind(this,i),undo:l.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathResizingSVGProperties(I(this,He,Gg).call(this)),{bbox:I(this,He,V1).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathResizedSVGProperties(I(this,He,Gg).call(this)),{bbox:I(this,He,V1).call(this)}))}_onTranslating(t,r){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:I(this,He,V1).call(this,t,r)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties(m(this,Gr).getPathTranslatedSVGProperties(I(this,He,Gg).call(this),this.parentDimensions),{bbox:I(this,He,V1).call(this)}))}_onStartDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;(t=this.parent)==null||t.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,m(this,b1)&&(M(this,b1,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){I(this,He,E9).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,He,zh).call(this),I(this,He,Hh).call(this,m(this,Gr).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),I(this,He,E9).call(this)):t&&(this._uiManager.addShouldRescale(this),I(this,He,zh).call(this,t),r=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),r&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ue._mergeSVGProperties({bbox:I(this,He,V1).call(this)},m(this,Gr).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&I(this,He,Hh).call(this,m(this,Gr).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const r=document.createElement("div");t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,r,i,o,s){ct("Not implemented")}static startDrawing(t,r,i,o){var y;const{target:s,offsetX:l,offsetY:c,pointerId:d,pointerType:u}=o;if(m(ue,s0)&&m(ue,s0)!==u)return;const{viewport:{rotation:f}}=t,{width:h,height:p}=s.getBoundingClientRect(),g=M(ue,i2,new AbortController),b=t.combinedSignal(g);m(ue,o0)||M(ue,o0,d),m(ue,s0)??M(ue,s0,u),window.addEventListener("pointerup",w=>{var v;m(ue,o0)===w.pointerId?this._endDraw(w):(v=m(ue,a0))==null||v.delete(w.pointerId)},{signal:b}),window.addEventListener("pointercancel",w=>{var v;m(ue,o0)===w.pointerId?this._currentParent.endDrawingSession():(v=m(ue,a0))==null||v.delete(w.pointerId)},{signal:b}),window.addEventListener("pointerdown",w=>{m(ue,s0)===w.pointerType&&((m(ue,a0)||M(ue,a0,new Set)).add(w.pointerId),m(ue,an).isCancellable()&&(m(ue,an).removeLastElement(),m(ue,an).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",Di,{signal:b}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),s.addEventListener("touchmove",w=>{w.timeStamp===m(ue,s2)&&Ir(w)},{signal:b}),t.toggleDrawing(),(y=r._editorUndoBar)==null||y.hide(),m(ue,an)?t.drawLayer.updateProperties(this._currentDrawId,m(ue,an).startNew(l,c,h,p,f)):(r.updateUIForDefaultProperties(this),M(ue,an,this.createDrawerInstance(l,c,h,p,f)),M(ue,o2,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(m(ue,o2).toSVGProperties(),m(ue,an).defaultSVGProperties),!0,!1))}static _drawMove(t){var s;if(M(ue,s2,-1),!m(ue,an))return;const{offsetX:r,offsetY:i,pointerId:o}=t;m(ue,o0)===o&&(((s=m(ue,a0))==null?void 0:s.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,m(ue,an).add(r,i)),M(ue,s2,t.timeStamp),Ir(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,M(ue,an,null),M(ue,o2,null),M(ue,s0,null),M(ue,s2,NaN)),m(ue,i2)&&(m(ue,i2).abort(),M(ue,i2,null),M(ue,o0,NaN),M(ue,a0,null))}static _endDraw(t){const r=this._currentParent;if(r)if(r.toggleDrawing(!0),this._cleanup(!1),t&&r.drawLayer.updateProperties(this._currentDrawId,m(ue,an).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const i=m(ue,an),o=this._currentDrawId,s=i.getLastElement();r.addCommands({cmd:()=>{r.drawLayer.updateProperties(o,i.setLastElement(s))},undo:()=>{r.drawLayer.updateProperties(o,i.removeLastElement())},mustExec:!1,type:Ve.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const r=this._currentParent;if(!r)return null;if(r.toggleDrawing(!0),r.cleanUndoStack(Ve.DRAW_STEP),!m(ue,an).isEmpty()){const{pageDimensions:[i,o],scale:s}=r,l=r.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:m(ue,an).getOutlines(i*s,o*s,s,this._INNER_MARGIN),drawingOptions:m(ue,o2),mustBeCommitted:!t});return this._cleanup(!0),l}return r.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,r,i,o,s,l){ct("Not implemented")}static async deserialize(t,r,i){var f,h;const{rawDims:{pageWidth:o,pageHeight:s,pageX:l,pageY:c}}=r.viewport,d=this.deserializeDraw(l,c,o,s,this._INNER_MARGIN,t),u=await super.deserialize(t,r,i);return u.createDrawingOptions(t),I(f=u,He,k9).call(f,{drawOutlines:d}),I(h=u,He,zh).call(h),u.onScaleChanging(),u.rotate(),u}serializeDraw(t){const[r,i]=this.pageTranslation,[o,s]=this.pageDimensions;return m(this,Gr).serialize([r,i,o,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Gr=new WeakMap,b1=new WeakMap,an=new WeakMap,i2=new WeakMap,o2=new WeakMap,o0=new WeakMap,s0=new WeakMap,a0=new WeakMap,s2=new WeakMap,He=new WeakSet,k9=function({drawOutlines:t,drawId:r,drawingOptions:i}){M(this,Gr,t),this._drawingOptions||(this._drawingOptions=i),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,t.defaultProperties)):this._drawId=I(this,He,M9).call(this,t,this.parent),I(this,He,Hh).call(this,t.box)},M9=function(t,r){const{id:i}=r.drawLayer.draw(ue._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i},E9=function(){this._drawId!==null&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},zh=function(t=this.parent){(this._drawId===null||this.parent!==t)&&(this._drawId===null?(this._drawingOptions.updateAll(),this._drawId=I(this,He,M9).call(this,m(this,Gr),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},HD=function([t,r,i,o]){const{parentDimensions:[s,l],rotation:c}=this;switch(c){case 90:return[r,1-t,i*(l/s),o*(s/l)];case 180:return[1-t,1-r,i,o];case 270:return[1-r,t,i*(l/s),o*(s/l)];default:return[t,r,i,o]}},Gg=function(){const{x:t,y:r,width:i,height:o,parentDimensions:[s,l],rotation:c}=this;switch(c){case 90:return[1-r,t,i*(s/l),o*(l/s)];case 180:return[1-t,1-r,i,o];case 270:return[r,1-t,i*(s/l),o*(l/s)];default:return[t,r,i,o]}},Hh=function(t){if([this.x,this.y,this.width,this.height]=I(this,He,HD).call(this,t),this.div){this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)}this._onResized()},V1=function(){const{x:t,y:r,width:i,height:o,rotation:s,parentRotation:l,parentDimensions:[c,d]}=this;switch((4*s+l)/90){case 1:return[1-r-o,t,o,i];case 2:return[1-t-i,1-r-o,i,o];case 3:return[r,1-t-i,o,i];case 4:return[t,r-i*(c/d),o*(d/c),i*(c/d)];case 5:return[1-r,t,i*(c/d),o*(d/c)];case 6:return[1-t-o*(d/c),1-r,o*(d/c),i*(c/d)];case 7:return[r-i*(c/d),1-t-o*(d/c),i*(c/d),o*(d/c)];case 8:return[t-i,r-o,i,o];case 9:return[1-r,t-i,o,i];case 10:return[1-t,1-r,i,o];case 11:return[r-o,1-t,o,i];case 12:return[t-o*(d/c),r,o*(d/c),i*(c/d)];case 13:return[1-r-i*(c/d),t-o*(d/c),i*(c/d),o*(d/c)];case 14:return[1-t,1-r-i*(c/d),o*(d/c),i*(c/d)];case 15:return[r,1-t,i*(c/d),o*(d/c)];default:return[t,r,i,o]}},ve(ue,"_currentDrawId",-1),ve(ue,"_currentParent",null),T(ue,an,null),T(ue,i2,null),T(ue,o2,null),T(ue,o0,NaN),T(ue,s0,null),T(ue,a0,null),T(ue,s2,NaN),ve(ue,"_INNER_MARGIN",3);let k6=ue;class ZU{constructor(e,t,r,i,o,s){T(this,v1);T(this,No,new Float64Array(6));T(this,ln);T(this,cn);T(this,a2);T(this,w1);T(this,Jn);T(this,Cn,"");T(this,Ci,0);T(this,l2,new lm);T(this,c2);T(this,d2);M(this,c2,r),M(this,d2,i),M(this,a2,o),M(this,w1,s),[e,t]=I(this,v1,qg).call(this,e,t);const l=M(this,ln,[NaN,NaN,NaN,NaN,e,t]);M(this,Jn,[e,t]),M(this,cn,[{line:l,points:m(this,Jn)}]),m(this,No).set(l,0)}updateProperty(e,t){e==="stroke-width"&&M(this,w1,t)}isEmpty(){return!m(this,cn)||m(this,cn).length===0}isCancellable(){return m(this,Jn).length<=10}add(e,t){[e,t]=I(this,v1,qg).call(this,e,t);const[r,i,o,s]=m(this,No).subarray(2,6),l=e-o,c=t-s;return Math.hypot(m(this,c2)*l,m(this,d2)*c)<=2?null:(m(this,Jn).push(e,t),isNaN(r)?(m(this,No).set([o,s,e,t],2),m(this,ln).push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(m(this,No)[0])&&m(this,ln).splice(6,6),m(this,No).set([r,i,o,s,e,t],0),m(this,ln).push(...de.createBezierPoints(r,i,o,s,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(m(this,Jn).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,r,i,o){M(this,c2,r),M(this,d2,i),M(this,a2,o),[e,t]=I(this,v1,qg).call(this,e,t);const s=M(this,ln,[NaN,NaN,NaN,NaN,e,t]);M(this,Jn,[e,t]);const l=m(this,cn).at(-1);return l&&(l.line=new Float32Array(l.line),l.points=new Float32Array(l.points)),m(this,cn).push({line:s,points:m(this,Jn)}),m(this,No).set(s,0),M(this,Ci,0),this.toSVGPath(),null}getLastElement(){return m(this,cn).at(-1)}setLastElement(e){return m(this,cn)?(m(this,cn).push(e),M(this,ln,e.line),M(this,Jn,e.points),M(this,Ci,0),{path:{d:this.toSVGPath()}}):m(this,l2).setLastElement(e)}removeLastElement(){if(!m(this,cn))return m(this,l2).removeLastElement();m(this,cn).pop(),M(this,Cn,"");for(let e=0,t=m(this,cn).length;e<t;e++){const{line:r,points:i}=m(this,cn)[e];M(this,ln,r),M(this,Jn,i),M(this,Ci,0),this.toSVGPath()}return{path:{d:m(this,Cn)}}}toSVGPath(){const e=de.svgRound(m(this,ln)[4]),t=de.svgRound(m(this,ln)[5]);if(m(this,Jn).length===2)return M(this,Cn,`${m(this,Cn)} M ${e} ${t} Z`),m(this,Cn);if(m(this,Jn).length<=6){const i=m(this,Cn).lastIndexOf("M");M(this,Cn,`${m(this,Cn).slice(0,i)} M ${e} ${t}`),M(this,Ci,6)}if(m(this,Jn).length===4){const i=de.svgRound(m(this,ln)[10]),o=de.svgRound(m(this,ln)[11]);return M(this,Cn,`${m(this,Cn)} L ${i} ${o}`),M(this,Ci,12),m(this,Cn)}const r=[];m(this,Ci)===0&&(r.push(`M ${e} ${t}`),M(this,Ci,6));for(let i=m(this,Ci),o=m(this,ln).length;i<o;i+=6){const[s,l,c,d,u,f]=m(this,ln).slice(i,i+6).map(de.svgRound);r.push(`C${s} ${l} ${c} ${d} ${u} ${f}`)}return M(this,Cn,m(this,Cn)+r.join(" ")),M(this,Ci,m(this,ln).length),m(this,Cn)}getOutlines(e,t,r,i){const o=m(this,cn).at(-1);return o.line=new Float32Array(o.line),o.points=new Float32Array(o.points),m(this,l2).build(m(this,cn),e,t,r,m(this,a2),m(this,w1),i),M(this,No,null),M(this,ln,null),M(this,cn,null),M(this,Cn,null),m(this,l2)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}No=new WeakMap,ln=new WeakMap,cn=new WeakMap,a2=new WeakMap,w1=new WeakMap,Jn=new WeakMap,Cn=new WeakMap,Ci=new WeakMap,l2=new WeakMap,c2=new WeakMap,d2=new WeakMap,v1=new WeakSet,qg=function(e,t){return de._normalizePoint(e,t,m(this,c2),m(this,d2),m(this,a2))};const Ly=class Ly extends de{constructor(){super(...arguments);T(this,Sn);T(this,er);T(this,Ih,0);T(this,xh);T(this,qr);T(this,Po);T(this,Lo);T(this,C1);T(this,S1);T(this,k1)}build(t,r,i,o,s,l,c){M(this,Po,r),M(this,Lo,i),M(this,C1,o),M(this,S1,s),M(this,k1,l),M(this,xh,c??0),M(this,qr,t),I(this,Sn,ZD).call(this)}setLastElement(t){return m(this,qr).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return m(this,qr).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:r}of m(this,qr))if(t.push(`M${de.svgRound(r[4])} ${de.svgRound(r[5])}`),r.length!==6)if(r.length!==12)for(let i=6,o=r.length;i<o;i+=6){const[s,l,c,d,u,f]=r.subarray(i,i+6).map(de.svgRound);t.push(`C${s} ${l} ${c} ${d} ${u} ${f}`)}else t.push(`L${de.svgRound(r[10])} ${de.svgRound(r[11])}`);else t.push("Z");return t.join("")}serialize([t,r,i,o],s){const l=[],c=[],[d,u,f,h]=I(this,Sn,UD).call(this);let p,g,b,y,w,v,S,C,A;switch(m(this,S1)){case 0:A=de._rescale,p=t,g=r+o,b=i,y=-o,w=t+d*i,v=r+(1-u-h)*o,S=t+(d+f)*i,C=r+(1-u)*o;break;case 90:A=de._rescaleAndSwap,p=t,g=r,b=i,y=o,w=t+u*i,v=r+d*o,S=t+(u+h)*i,C=r+(d+f)*o;break;case 180:A=de._rescale,p=t+i,g=r,b=-i,y=o,w=t+(1-d-f)*i,v=r+u*o,S=t+(1-d)*i,C=r+(u+h)*o;break;case 270:A=de._rescaleAndSwap,p=t+i,g=r+o,b=-i,y=-o,w=t+(1-u-h)*i,v=r+(1-d-f)*o,S=t+(1-u)*i,C=r+(1-d)*o}for(const{line:k,points:E}of m(this,qr))l.push(A(k,p,g,b,y,s?new Array(k.length):null)),c.push(A(E,p,g,b,y,s?new Array(E.length):null));return{lines:l,points:c,rect:[w,v,S,C]}}static deserialize(t,r,i,o,s,{paths:{lines:l,points:c},rotation:d,thickness:u}){const f=[];let h,p,g,b,y;switch(d){case 0:y=de._rescale,h=-t/i,p=r/o+1,g=1/i,b=-1/o;break;case 90:y=de._rescaleAndSwap,h=-r/o,p=-t/i,g=1/o,b=1/i;break;case 180:y=de._rescale,h=t/i+1,p=-r/o,g=-1/i,b=1/o;break;case 270:y=de._rescaleAndSwap,h=r/o+1,p=t/i+1,g=-1/o,b=-1/i}if(!l){l=[];for(const v of c){const S=v.length;if(S===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(S===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const C=new Float32Array(3*(S-2));l.push(C);let[A,k,E,O]=v.subarray(0,4);C.set([NaN,NaN,NaN,NaN,A,k],0);for(let x=4;x<S;x+=2){const N=v[x],D=v[x+1];C.set(de.createBezierPoints(A,k,E,O,N,D),3*(x-2)),[A,k,E,O]=[E,O,N,D]}}}for(let v=0,S=l.length;v<S;v++)f.push({line:y(l[v].map(C=>C??NaN),h,p,g,b),points:y(c[v].map(C=>C??NaN),h,p,g,b)});const w=new Ly;return w.build(f,i,o,1,d,u,s),w}get box(){return m(this,er)}updateProperty(t,r){return t==="stroke-width"?I(this,Sn,WD).call(this,r):null}updateParentDimensions([t,r],i){const[o,s]=I(this,Sn,Us).call(this);M(this,Po,t),M(this,Lo,r),M(this,C1,i);const[l,c]=I(this,Sn,Us).call(this),d=l-o,u=c-s,f=m(this,er);return f[0]-=d,f[1]-=u,f[2]+=2*d,f[3]+=2*u,f}updateRotation(t){return M(this,Ih,t),{path:{transform:this.rotationTransform}}}get viewBox(){return m(this,er).map(de.svgRound).join(" ")}get defaultProperties(){const[t,r]=m(this,er);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`}}}get rotationTransform(){const[,,t,r]=m(this,er);let i=0,o=0,s=0,l=0,c=0,d=0;switch(m(this,Ih)){case 90:o=r/t,s=-t/r,c=t;break;case 180:i=-1,l=-1,c=t,d=r;break;case 270:o=-r/t,s=t/r,d=r;break;default:return""}return`matrix(${i} ${o} ${s} ${l} ${de.svgRound(c)} ${de.svgRound(d)})`}getPathResizingSVGProperties([t,r,i,o]){const[s,l]=I(this,Sn,Us).call(this),[c,d,u,f]=m(this,er);if(Math.abs(u-s)<=de.PRECISION||Math.abs(f-l)<=de.PRECISION){const y=t+i/2-(c+u/2),w=r+o/2-(d+f/2);return{path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:`${this.rotationTransform} translate(${y} ${w})`}}}const h=(i-2*s)/(u-2*s),p=(o-2*l)/(f-2*l),g=u/i,b=f/o;return{path:{"transform-origin":`${de.svgRound(c)} ${de.svgRound(d)}`,transform:`${this.rotationTransform} scale(${g} ${b}) translate(${de.svgRound(s)} ${de.svgRound(l)}) scale(${h} ${p}) translate(${de.svgRound(-s)} ${de.svgRound(-l)})`}}}getPathResizedSVGProperties([t,r,i,o]){const[s,l]=I(this,Sn,Us).call(this),c=m(this,er),[d,u,f,h]=c;if(c[0]=t,c[1]=r,c[2]=i,c[3]=o,Math.abs(f-s)<=de.PRECISION||Math.abs(h-l)<=de.PRECISION){const w=t+i/2-(d+f/2),v=r+o/2-(u+h/2);for(const{line:S,points:C}of m(this,qr))de._translate(S,w,v,S),de._translate(C,w,v,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(i-2*s)/(f-2*s),g=(o-2*l)/(h-2*l),b=-p*(d+s)+t+s,y=-g*(u+l)+r+l;if(p!==1||g!==1||b!==0||y!==0)for(const{line:w,points:v}of m(this,qr))de._rescale(w,b,y,p,g,w),de._rescale(v,b,y,p,g,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,r],i){const[o,s]=i,l=m(this,er),c=t-l[0],d=r-l[1];if(m(this,Po)===o&&m(this,Lo)===s)for(const{line:u,points:f}of m(this,qr))de._translate(u,c,d,u),de._translate(f,c,d,f);else{const u=m(this,Po)/o,f=m(this,Lo)/s;M(this,Po,o),M(this,Lo,s);for(const{line:h,points:p}of m(this,qr))de._rescale(h,c,d,u,f,h),de._rescale(p,c,d,u,f,p);l[2]*=u,l[3]*=f}return l[0]=t,l[1]=r,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${de.svgRound(t)} ${de.svgRound(r)}`}}}get defaultSVGProperties(){const t=m(this,er);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${de.svgRound(t[0])} ${de.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}};er=new WeakMap,Ih=new WeakMap,xh=new WeakMap,qr=new WeakMap,Po=new WeakMap,Lo=new WeakMap,C1=new WeakMap,S1=new WeakMap,k1=new WeakMap,Sn=new WeakSet,Us=function(t=m(this,k1)){const r=m(this,xh)+t/2*m(this,C1);return m(this,S1)%180==0?[r/m(this,Po),r/m(this,Lo)]:[r/m(this,Lo),r/m(this,Po)]},UD=function(){const[t,r,i,o]=m(this,er),[s,l]=I(this,Sn,Us).call(this,0);return[t+s,r+l,i-2*s,o-2*l]},ZD=function(){const t=M(this,er,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:o}of m(this,qr)){if(o.length<=12){for(let c=4,d=o.length;c<d;c+=6){const[u,f]=o.subarray(c,c+2);t[0]=Math.min(t[0],u),t[1]=Math.min(t[1],f),t[2]=Math.max(t[2],u),t[3]=Math.max(t[3],f)}continue}let s=o[4],l=o[5];for(let c=6,d=o.length;c<d;c+=6){const[u,f,h,p,g,b]=o.subarray(c,c+6);ye.bezierBoundingBox(s,l,u,f,h,p,g,b,t),s=g,l=b}}const[r,i]=I(this,Sn,Us).call(this);t[0]=Math.min(1,Math.max(0,t[0]-r)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+r)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]},WD=function(t){const[r,i]=I(this,Sn,Us).call(this);M(this,k1,t);const[o,s]=I(this,Sn,Us).call(this),[l,c]=[o-r,s-i],d=m(this,er);return d[0]-=l,d[1]-=c,d[2]+=2*l,d[3]+=2*c,d};let lm=Ly;const By=class By extends UU{constructor(t){super();T(this,M1);M(this,M1,t),super.updateProperties({fill:"none",stroke:Ct._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,r){t==="stroke-width"&&(r??(r=this["stroke-width"]),r*=m(this,M1).realScale),super.updateSVGProperty(t,r)}clone(){const t=new By(m(this,M1));return t.updateAll(this),t}};M1=new WeakMap;let M6=By;const E1=class E1 extends k6{constructor(t){super({...t,name:"inkEditor"});T(this,vg);this._willKeepAspectRatio=!0}static initialize(t,r){Ct.initialize(t,r),this._defaultDrawingOptions=new M6(r.viewParameters)}static getDefaultDrawingOptions(t){const r=this._defaultDrawingOptions.clone();return r.updateProperties(t),r}static get supportMultipleDrawings(){return!0}static get typesMap(){return _e(this,"typesMap",new Map([[Ve.INK_THICKNESS,"stroke-width"],[Ve.INK_COLOR,"stroke"],[Ve.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,r,i,o,s){return new ZU(t,r,i,o,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,r,i,o,s,l){return lm.deserialize(t,r,i,o,s,l)}static async deserialize(t,r,i){let o=null;if(t instanceof w6){const{data:{inkLists:l,rect:c,rotation:d,id:u,color:f,opacity:h,borderStyle:{rawWidth:p},popupRef:g},parent:{page:{pageNumber:b}}}=t;o=t={annotationType:De.INK,color:Array.from(f),thickness:p,opacity:h,paths:{points:l},boxes:null,pageIndex:b-1,rect:c.slice(0),rotation:d,id:u,deleted:!1,popupRef:g}}const s=await super.deserialize(t,r,i);return s.annotationElementId=t.id||null,s._initialData=o,s}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:r,parent:i}=this;r.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,r.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:r,opacity:i}){this._drawingOptions=E1.getDefaultDrawingOptions({stroke:ye.makeHexColor(...t),"stroke-width":r,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:r,points:i,rect:o}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":l,"stroke-width":c}}=this,d={annotationType:De.INK,color:Ct._colorManager.convert(s),opacity:l,thickness:c,paths:{lines:r,points:i},pageIndex:this.pageIndex,rect:o,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?d:this.annotationElementId&&!I(this,vg,GD).call(this,d)?null:(d.id=this.annotationElementId,d)}renderAnnotationElement(t){const{points:r,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:r}),null}};vg=new WeakSet,GD=function(t){const{color:r,thickness:i,opacity:o,pageIndex:s}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((l,c)=>l!==r[c])||t.thickness!==i||t.opacity!==o||t.pageIndex!==s},ve(E1,"_type","ink"),ve(E1,"_editorType",De.INK),ve(E1,"_defaultDrawingOptions",null);let E6=E1;const Oh=class Oh extends Ct{constructor(t){super({...t,name:"stampEditor"});T(this,qe);T(this,Et,null);T(this,kn,null);T(this,l0,null);T(this,Vs,null);T(this,c0,null);T(this,A1,"");T(this,Bo,null);T(this,_o,null);T(this,Kr,!1);T(this,T1,!1);M(this,Vs,t.bitmapUrl),M(this,c0,t.bitmapFile)}static initialize(t,r){Ct.initialize(t,r)}static get supportedTypes(){return _e(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return _e(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,r){r.pasteEditor(De.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const r=t.get("hasAltText");return{hasAltText:r.get(!0)??0,hasNoAltText:r.get(!1)??0}}async mlGuessAltText(t=null,r=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:o,width:s,height:l}=t||this.copyCanvas(null,null,!0).imageData,c=await i.guess({name:"altText",request:{data:o,width:s,height:l,channels:o.length/(s*l)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const d=c.output;return await this.setGuessedAltText(d),r&&!this.hasAltTextData()&&(this.altTextData={alt:d,decorative:!1}),d}remove(){var t;m(this,kn)&&(M(this,Et,null),this._uiManager.imageManager.deleteId(m(this,kn)),(t=m(this,Bo))==null||t.remove(),M(this,Bo,null),m(this,_o)&&(clearTimeout(m(this,_o)),M(this,_o,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(m(this,kn)&&m(this,Bo)===null&&I(this,qe,Kg).call(this),this.isAttachedToDOM||this.parent.add(this))):m(this,kn)&&I(this,qe,Kg).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(m(this,l0)||m(this,Et)||m(this,Vs)||m(this,c0)||m(this,kn))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,r;if(this.width&&(t=this.x,r=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),m(this,Et)?I(this,qe,A9).call(this):I(this,qe,Kg).call(this),this.width&&!this.annotationElementId){const[i,o]=this.parentDimensions;this.setAt(t*i,r*o,this.width*i,this.height*o)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(m(this,_o)!==null&&clearTimeout(m(this,_o)),M(this,_o,setTimeout(()=>{M(this,_o,null),I(this,qe,T9).call(this)},200)))}copyCanvas(t,r,i=!1){var p;t||(t=224);const{width:o,height:s}=m(this,Et),l=new r6;let c=m(this,Et),d=o,u=s,f=null;if(r){if(o>r||s>r){const O=Math.min(r/o,r/s);d=Math.floor(o*O),u=Math.floor(s*O)}f=document.createElement("canvas");const g=f.width=Math.ceil(d*l.sx),b=f.height=Math.ceil(u*l.sy);m(this,Kr)||(c=I(this,qe,Yg).call(this,g,b));const y=f.getContext("2d");y.filter=this._uiManager.hcmFilter;let w="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",v="#42414d");const S=15,C=S*l.sx,A=S*l.sy,k=new OffscreenCanvas(2*C,2*A),E=k.getContext("2d");E.fillStyle=w,E.fillRect(0,0,2*C,2*A),E.fillStyle=v,E.fillRect(0,0,C,A),E.fillRect(C,A,C,A),y.fillStyle=y.createPattern(k,"repeat"),y.fillRect(0,0,g,b),y.drawImage(c,0,0,c.width,c.height,0,0,g,b)}let h=null;if(i){let g,b;if(l.symmetric&&c.width<t&&c.height<t)g=c.width,b=c.height;else if(c=m(this,Et),o>t||s>t){const w=Math.min(t/o,t/s);g=Math.floor(o*w),b=Math.floor(s*w),m(this,Kr)||(c=I(this,qe,Yg).call(this,g,b))}const y=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});y.drawImage(c,0,0,c.width,c.height,0,0,g,b),h={width:g,height:b,data:y.getImageData(0,0,g,b).data}}return{canvas:f,width:d,height:u,imageData:h}}getImageForAltText(){return m(this,Bo)}static async deserialize(t,r,i){var b;let o=null;if(t instanceof Ek){const{data:{rect:y,rotation:w,id:v,structParent:S,popupRef:C},container:A,parent:{page:{pageNumber:k}}}=t,E=A.querySelector("canvas"),O=i.imageManager.getFromCanvas(A.id,E);E.remove();const x=((b=await r._structTree.getAriaAttributes(`${X4}${v}`))==null?void 0:b.get("aria-label"))||"";o=t={annotationType:De.STAMP,bitmapId:O.id,bitmap:O.bitmap,pageIndex:k-1,rect:y.slice(0),rotation:w,id:v,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:S,popupRef:C}}const s=await super.deserialize(t,r,i),{rect:l,bitmap:c,bitmapUrl:d,bitmapId:u,isSvg:f,accessibilityData:h}=t;u&&i.imageManager.isValidId(u)?(M(s,kn,u),c&&M(s,Et,c)):M(s,Vs,d),M(s,Kr,f);const[p,g]=s.pageDimensions;return s.width=(l[2]-l[0])/p,s.height=(l[3]-l[1])/g,s.annotationElementId=t.id||null,h&&(s.altTextData=h),s._initialData=o,M(s,T1,!!o),s}serialize(t=!1,r=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:De.STAMP,bitmapId:m(this,kn),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:m(this,Kr),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=I(this,qe,Qg).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:o,altText:s}=this.serializeAltText(!1);if(!o&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const c=I(this,qe,qD).call(this,i);if(c.isSame)return null;c.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,r===null)return i;r.stamps||(r.stamps=new Map);const l=m(this,Kr)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(r.stamps.has(m(this,kn))){if(m(this,Kr)){const c=r.stamps.get(m(this,kn));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=I(this,qe,Qg).call(this,!1))}}else r.stamps.set(m(this,kn),{area:l,serialized:i}),i.bitmap=I(this,qe,Qg).call(this,!1);return i}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}};Et=new WeakMap,kn=new WeakMap,l0=new WeakMap,Vs=new WeakMap,c0=new WeakMap,A1=new WeakMap,Bo=new WeakMap,_o=new WeakMap,Kr=new WeakMap,T1=new WeakMap,qe=new WeakSet,Uh=function(t,r=!1){t?(M(this,Et,t.bitmap),r||(M(this,kn,t.id),M(this,Kr,t.isSvg)),t.file&&M(this,A1,t.file.name),I(this,qe,A9).call(this)):this.remove()},Zh=function(){if(M(this,l0,null),this._uiManager.enableWaiting(!1),m(this,Bo))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&m(this,Et))this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&m(this,Et)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Kg=function(){if(m(this,kn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(m(this,kn)).then(i=>I(this,qe,Uh).call(this,i,!0)).finally(()=>I(this,qe,Zh).call(this));return}if(m(this,Vs)){const i=m(this,Vs);M(this,Vs,null),this._uiManager.enableWaiting(!0),M(this,l0,this._uiManager.imageManager.getFromUrl(i).then(o=>I(this,qe,Uh).call(this,o)).finally(()=>I(this,qe,Zh).call(this)));return}if(m(this,c0)){const i=m(this,c0);M(this,c0,null),this._uiManager.enableWaiting(!0),M(this,l0,this._uiManager.imageManager.getFromFile(i).then(o=>I(this,qe,Uh).call(this,o)).finally(()=>I(this,qe,Zh).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Oh.supportedTypesStr;const r=this._uiManager._signal;M(this,l0,new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&t.files.length!==0){this._uiManager.enableWaiting(!0);const o=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),I(this,qe,Uh).call(this,o)}else this.remove();i()},{signal:r}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:r})}).finally(()=>I(this,qe,Zh).call(this))),t.click()},A9=function(){var f;const{div:t}=this;let{width:r,height:i}=m(this,Et);const[o,s]=this.pageDimensions,l=.75;if(this.width)r=this.width*o,i=this.height*s;else if(r>l*o||i>l*s){const h=Math.min(l*o/r,l*s/i);r*=h,i*=h}const[c,d]=this.parentDimensions;this.setDims(r*c/o,i*d/s),this._uiManager.enableWaiting(!1);const u=M(this,Bo,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=r/o,this.height=i/s,(f=this._initialOptions)!=null&&f.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),I(this,qe,T9).call(this),m(this,T1)||(this.parent.addUndoableEditor(this),M(this,T1,!0)),this._reportTelemetry({action:"inserted_image"}),m(this,A1)&&u.setAttribute("aria-label",m(this,A1))},Yg=function(t,r){const{width:i,height:o}=m(this,Et);let s=i,l=o,c=m(this,Et);for(;s>2*t||l>2*r;){const d=s,u=l;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),l>2*r&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const f=new OffscreenCanvas(s,l);f.getContext("2d").drawImage(c,0,0,d,u,0,0,s,l),c=f.transferToImageBitmap()}return c},T9=function(){const[t,r]=this.parentDimensions,{width:i,height:o}=this,s=new r6,l=Math.ceil(i*t*s.sx),c=Math.ceil(o*r*s.sy),d=m(this,Bo);if(!d||d.width===l&&d.height===c)return;d.width=l,d.height=c;const u=m(this,Kr)?m(this,Et):I(this,qe,Yg).call(this,l,c),f=d.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(u,0,0,u.width,u.height,0,0,l,c)},Qg=function(t){if(t){if(m(this,Kr)){const i=this._uiManager.imageManager.getSvgUrl(m(this,kn));if(i)return i}const r=document.createElement("canvas");return{width:r.width,height:r.height}=m(this,Et),r.getContext("2d").drawImage(m(this,Et),0,0),r.toDataURL()}if(m(this,Kr)){const[r,i]=this.pageDimensions,o=Math.round(this.width*r*ra.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*ra.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(o,s);return l.getContext("2d").drawImage(m(this,Et),0,0,m(this,Et).width,m(this,Et).height,0,0,o,s),l.transferToImageBitmap()}return structuredClone(m(this,Et))},qD=function(t){var l;const{pageIndex:r,accessibilityData:{altText:i}}=this._initialData,o=t.pageIndex===r,s=(((l=t.accessibilityData)==null?void 0:l.alt)||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&o&&s,isSameAltText:s}},ve(Oh,"_type","stamp"),ve(Oh,"_editorType",De.STAMP);let A6=Oh;const Ki=class Ki{constructor({uiManager:e,pageIndex:t,div:r,structTreeLayer:i,accessibilityManager:o,annotationLayer:s,drawLayer:l,textLayer:c,viewport:d,l10n:u}){T(this,yt);T(this,u2);T(this,I1,!1);T(this,Ro,null);T(this,d0,null);T(this,$s,null);T(this,Si,new Map);T(this,u0,!1);T(this,x1,!1);T(this,f2,!1);T(this,qi,null);T(this,Fs,null);T(this,_n,null);T(this,js,null);T(this,ge);const f=[...m(Ki,f0).values()];if(!Ki._initialized){Ki._initialized=!0;for(const h of f)h.initialize(u,e)}e.registerEditorTypes(f),M(this,ge,e),this.pageIndex=t,this.div=r,M(this,u2,o),M(this,Ro,s),this.viewport=d,M(this,_n,c),this.drawLayer=l,this._structTree=i,m(this,ge).addLayer(this)}get isEmpty(){return m(this,Si).size===0}get isInvisible(){return this.isEmpty&&m(this,ge).getMode()===De.NONE}updateToolbar(e){m(this,ge).updateToolbar(e)}updateMode(e=m(this,ge).getMode()){switch(I(this,yt,Xg).call(this),e){case De.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case De.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case De.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const r of m(Ki,f0).values())t.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=m(this,_n))==null?void 0:t.div)}setEditingState(e){m(this,ge).setEditingState(e)}addCommands(e){m(this,ge).addCommands(e)}cleanUndoStack(e){m(this,ge).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=m(this,Ro))==null||t.div.classList.toggle("disabled",!e)}async enable(){M(this,f2,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const r of m(this,Si).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(m(this,ge).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!m(this,Ro)){M(this,f2,!1);return}const t=m(this,Ro).getEditableAnnotations();for(const r of t){if(r.hide(),m(this,ge).isDeletedAnnotationElement(r.data.id)||e.has(r.data.id))continue;const i=await this.deserialize(r);i&&(this.addOrRebuild(i),i.enableEditing())}M(this,f2,!1)}disable(){var i;M(this,x1,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const o of m(this,Si).values())o.disableEditing(),o.annotationElementId&&(o.serialize()===null?(t.set(o.annotationElementId,o),(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()):e.set(o.annotationElementId,o));if(m(this,Ro)){const o=m(this,Ro).getEditableAnnotations();for(const s of o){const{id:l}=s.data;if(m(this,ge).isDeletedAnnotationElement(l))continue;let c=t.get(l);c?(c.resetAnnotationElement(s),c.show(!1),s.show()):(c=e.get(l),c&&(m(this,ge).addChangedExistingAnnotation(c),c.renderAnnotationElement(s)&&c.show(!1)),s.show())}}I(this,yt,Xg).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:r}=this.div;for(const o of m(Ki,f0).values())r.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),M(this,x1,!1)}getEditableAnnotation(e){var t;return((t=m(this,Ro))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){m(this,ge).getActive()!==e&&m(this,ge).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=m(this,_n))!=null&&e.div&&!m(this,js)){M(this,js,new AbortController);const t=m(this,ge).combinedSignal(m(this,js));m(this,_n).div.addEventListener("pointerdown",I(this,yt,KD).bind(this),{signal:t}),m(this,_n).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=m(this,_n))!=null&&e.div&&m(this,js)&&(m(this,js).abort(),M(this,js,null),m(this,_n).div.classList.remove("highlighting"))}enableClick(){if(m(this,d0))return;M(this,d0,new AbortController);const e=m(this,ge).combinedSignal(m(this,d0));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){var e;(e=m(this,d0))==null||e.abort(),M(this,d0,null)}attach(e){m(this,Si).set(e.id,e);const{annotationElementId:t}=e;t&&m(this,ge).isDeletedAnnotationElement(t)&&m(this,ge).removeDeletedAnnotationElement(e)}detach(e){var t;m(this,Si).delete(e.id),(t=m(this,u2))==null||t.removePointerInTextLayer(e.contentDiv),!m(this,x1)&&e.annotationElementId&&m(this,ge).addDeletedAnnotationElement(e)}remove(e){this.detach(e),m(this,ge).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(m(this,ge).addDeletedAnnotationElement(e.annotationElementId),Ct.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),m(this,ge).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!m(this,f2)),m(this,ge).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var r;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!m(this,$s)&&(e._focusEventsAllowed=!1,M(this,$s,setTimeout(()=>{M(this,$s,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:m(this,ge)._signal}),t.focus())},0))),e._structTreeParentId=(r=m(this,u2))==null?void 0:r.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return m(this,ge).getId()}combinedSignal(e){return m(this,ge).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=m(this,yt,jo))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){m(this,ge).updateToolbar(e),m(this,ge).updateMode(e);const{offsetX:r,offsetY:i}=I(this,yt,x9).call(this),o=this.getNextId(),s=I(this,yt,I9).call(this,{parent:this,id:o,x:r,y:i,uiManager:m(this,ge),isCentered:!0,...t});s&&this.add(s)}async deserialize(e){var t;return await((t=m(Ki,f0).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,m(this,ge)))||null}createAndAddNewEditor(e,t,r={}){const i=this.getNextId(),o=I(this,yt,I9).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:m(this,ge),isCentered:t,...r});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(I(this,yt,x9).call(this),!0)}setSelected(e){m(this,ge).setSelected(e)}toggleSelected(e){m(this,ge).toggleSelected(e)}unselect(e){m(this,ge).unselect(e)}pointerup(e){var r;const{isMac:t}=Un.platform;!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&m(this,u0)&&(M(this,u0,!1),(r=m(this,yt,jo))!=null&&r.isDrawer&&m(this,yt,jo).supportMultipleDrawings||(m(this,I1)?m(this,ge).getMode()!==De.STAMP?this.createAndAddNewEditor(e,!1):m(this,ge).unselectAll():M(this,I1,!0)))}pointerdown(e){var i;if(m(this,ge).getMode()===De.HIGHLIGHT&&this.enableTextSelection(),m(this,u0)){M(this,u0,!1);return}const{isMac:t}=Un.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;if(M(this,u0,!0),(i=m(this,yt,jo))!=null&&i.isDrawer){this.startDrawingSession(e);return}const r=m(this,ge).getActive();M(this,I1,!r||r.isEmpty())}startDrawingSession(e){if(this.div.focus(),m(this,qi)){m(this,yt,jo).startDrawing(this,m(this,ge),!1,e);return}m(this,ge).setCurrentDrawingSession(this),M(this,qi,new AbortController);const t=m(this,ge).combinedSignal(m(this,qi));this.div.addEventListener("blur",({relatedTarget:r})=>{r&&!this.div.contains(r)&&(M(this,Fs,null),this.commitOrRemove())},{signal:t}),m(this,yt,jo).startDrawing(this,m(this,ge),!1,e)}pause(e){if(e){const{activeElement:t}=document;this.div.contains(t)&&M(this,Fs,t)}else m(this,Fs)&&setTimeout(()=>{var t;(t=m(this,Fs))==null||t.focus(),M(this,Fs,null)},0)}endDrawingSession(e=!1){return m(this,qi)?(m(this,ge).setCurrentDrawingSession(null),m(this,qi).abort(),M(this,qi,null),M(this,Fs,null),m(this,yt,jo).endDrawing(e)):null}findNewParent(e,t,r){const i=m(this,ge).findParent(t,r);return i===null||i===this?!1:(i.changeParent(e),!0)}commitOrRemove(){return m(this,qi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){m(this,qi)&&m(this,yt,jo).onScaleChangingWhenDrawing(this)}destroy(){var e,t;this.commitOrRemove(),((e=m(this,ge).getActive())==null?void 0:e.parent)===this&&(m(this,ge).commitOrRemove(),m(this,ge).setActiveEditor(null)),m(this,$s)&&(clearTimeout(m(this,$s)),M(this,$s,null));for(const r of m(this,Si).values())(t=m(this,u2))==null||t.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,m(this,Si).clear(),m(this,ge).removeLayer(this)}render({viewport:e}){this.viewport=e,P0(this.div,e);for(const t of m(this,ge).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){m(this,ge).commitOrRemove(),I(this,yt,Xg).call(this);const t=this.viewport.rotation,r=e.rotation;if(this.viewport=e,P0(this.div,{rotation:r}),t!==r)for(const i of m(this,Si).values())i.rotate(r)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return m(this,ge).viewParameters.realScale}};u2=new WeakMap,I1=new WeakMap,Ro=new WeakMap,d0=new WeakMap,$s=new WeakMap,Si=new WeakMap,u0=new WeakMap,x1=new WeakMap,f2=new WeakMap,qi=new WeakMap,Fs=new WeakMap,_n=new WeakMap,js=new WeakMap,ge=new WeakMap,f0=new WeakMap,yt=new WeakSet,KD=function(e){m(this,ge).unselectAll();const{target:t}=e;if(t===m(this,_n).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent"))&&m(this,_n).div.contains(t)){const{isMac:r}=Un.platform;if(e.button!==0||e.ctrlKey&&r)return;m(this,ge).showAllEditors("highlight",!0,!0),m(this,_n).div.classList.add("free"),this.toggleDrawing(),am.startHighlighting(this,m(this,ge).direction==="ltr",{target:m(this,_n).div,x:e.x,y:e.y}),m(this,_n).div.addEventListener("pointerup",()=>{m(this,_n).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:m(this,ge)._signal}),e.preventDefault()}},jo=function(){return m(Ki,f0).get(m(this,ge).getMode())},I9=function(e){const t=m(this,yt,jo);return t?new t.prototype.constructor(e):null},x9=function(){const{x:e,y:t,width:r,height:i}=this.div.getBoundingClientRect(),o=Math.max(0,e),s=Math.max(0,t),l=(o+Math.min(window.innerWidth,e+r))/2-e,c=(s+Math.min(window.innerHeight,t+i))/2-t,[d,u]=this.viewport.rotation%180==0?[l,c]:[c,l];return{offsetX:d,offsetY:u}},Xg=function(){for(const e of m(this,Si).values())e.isEmpty()&&e.remove()},ve(Ki,"_initialized",!1),T(Ki,f0,new Map([v6,E6,A6,am].map(e=>[e._editorType,e])));let T6=Ki;const Rn=class Rn{constructor({pageIndex:e}){T(this,Vo);T(this,Yi,null);T(this,Dh,0);T(this,tr,new Map);T(this,h2,new Map);this.pageIndex=e}setParent(e){if(m(this,Yi)){if(m(this,Yi)!==e){if(m(this,tr).size>0)for(const t of m(this,tr).values())t.remove(),e.append(t);M(this,Yi,e)}}else M(this,Yi,e)}static get _svgFactory(){return _e(this,"_svgFactory",new y6)}draw(e,t=!1,r=!1){const i=ir(this,Dh)._++,o=I(this,Vo,O9).call(this),s=Rn._svgFactory.createElement("defs");o.append(s);const l=Rn._svgFactory.createElement("path");s.append(l);const c=`path_p${this.pageIndex}_${i}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke"),t&&m(this,h2).set(i,l);const d=r?I(this,Vo,QD).call(this,s,c):null,u=Rn._svgFactory.createElement("use");return o.append(u),u.setAttribute("href",`#${c}`),this.updateProperties(o,e),m(this,tr).set(i,o),{id:i,clipPathId:`url(#${d})`}}drawOutline(e,t){const r=ir(this,Dh)._++,i=I(this,Vo,O9).call(this),o=Rn._svgFactory.createElement("defs");i.append(o);const s=Rn._svgFactory.createElement("path");o.append(s);const l=`path_p${this.pageIndex}_${r}`;s.setAttribute("id",l),s.setAttribute("vector-effect","non-scaling-stroke");let c;if(t){const f=Rn._svgFactory.createElement("mask");o.append(f),c=`mask_p${this.pageIndex}_${r}`,f.setAttribute("id",c),f.setAttribute("maskUnits","objectBoundingBox");const h=Rn._svgFactory.createElement("rect");f.append(h),h.setAttribute("width","1"),h.setAttribute("height","1"),h.setAttribute("fill","white");const p=Rn._svgFactory.createElement("use");f.append(p),p.setAttribute("href",`#${l}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const d=Rn._svgFactory.createElement("use");i.append(d),d.setAttribute("href",`#${l}`),c&&d.setAttribute("mask",`url(#${c})`);const u=d.cloneNode();return i.append(u),d.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(i,e),m(this,tr).set(r,i),r}finalizeDraw(e,t){m(this,h2).delete(e),this.updateProperties(e,t)}updateProperties(e,t){var c;if(!t)return;const{root:r,bbox:i,rootClass:o,path:s}=t,l=typeof e=="number"?m(this,tr).get(e):e;if(l){if(r&&I(this,Vo,D9).call(this,l,r),i&&I(c=Rn,Cg,YD).call(c,l,i),o){const{classList:d}=l;for(const[u,f]of Object.entries(o))d.toggle(u,f)}if(s){const d=l.firstChild.firstChild;I(this,Vo,D9).call(this,d,s)}}}updateParent(e,t){if(t===this)return;const r=m(this,tr).get(e);r&&(m(t,Yi).append(r),m(this,tr).delete(e),m(t,tr).set(e,r))}remove(e){m(this,h2).delete(e),m(this,Yi)!==null&&(m(this,tr).get(e).remove(),m(this,tr).delete(e))}destroy(){M(this,Yi,null);for(const e of m(this,tr).values())e.remove();m(this,tr).clear(),m(this,h2).clear()}};Yi=new WeakMap,Dh=new WeakMap,tr=new WeakMap,h2=new WeakMap,Cg=new WeakSet,YD=function(e,[t,r,i,o]){const{style:s}=e;s.top=100*r+"%",s.left=100*t+"%",s.width=100*i+"%",s.height=100*o+"%"},Vo=new WeakSet,O9=function(){const e=Rn._svgFactory.create(1,1,!0);return m(this,Yi).append(e),e.setAttribute("aria-hidden",!0),e},QD=function(e,t){const r=Rn._svgFactory.createElement("clipPath");e.append(r);const i=`clip_${t}`;r.setAttribute("id",i),r.setAttribute("clipPathUnits","objectBoundingBox");const o=Rn._svgFactory.createElement("use");return r.append(o),o.setAttribute("href",`#${t}`),o.classList.add("clip"),i},D9=function(e,t){for(const[r,i]of Object.entries(t))i===null?e.removeAttribute(r):e.setAttribute(r,i)},T(Rn,Cg);let I6=Rn;globalThis.pdfjsTestingUtils={HighlightOutliner:C6},ke.AbortException,ke.AnnotationEditorLayer,ke.AnnotationEditorParamsType,ke.AnnotationEditorType,ke.AnnotationEditorUIManager,ke.AnnotationLayer,ke.AnnotationMode,ke.ColorPicker,ke.DOMSVGFactory,ke.DrawLayer,ke.FeatureTest;var WU=ke.GlobalWorkerOptions;ke.ImageKind,ke.InvalidPDFException,ke.MissingPDFException,ke.OPS,ke.OutputScale,ke.PDFDataRangeTransport,ke.PDFDateString,ke.PDFWorker,ke.PasswordResponses,ke.PermissionFlag,ke.PixelsPerInch,ke.RenderingCancelledException,ke.TextLayer,ke.TouchManager,ke.UnexpectedResponseException,ke.Util,ke.VerbosityLevel,ke.XfaLayer,ke.build,ke.createValidAbsoluteUrl,ke.fetchData;var GU=ke.getDocument;ke.getFilenameFromUrl,ke.getPdfFilenameFromUrl,ke.getXfaPageViewport,ke.isDataScheme,ke.isPdfFile,ke.noContextMenu,ke.normalizeUnicode,ke.setLayerDimensions,ke.shadow,ke.stopEvent;var qU=ke.version;const KU=a.defineComponent({name:"QModal",components:{QIcon:C0},props:{id:{type:String,default:"q-modal"},closeButtonClass:{type:String,default:""},containerClass:{type:String,default:"h-fit min-h-fit"},dismissible:{type:Boolean,default:!0},dismissibleOverlay:{type:Boolean,default:!0},dismissText:{type:String,default:""},overlay:{type:String,default:"white-transparent"},size:{type:String,default:"md"},showCancelLink:{type:Boolean,default:!1},hasBuildingBg:{type:Boolean,default:!1}},emits:["close"],setup(n,{emit:e}){a.provide("size",n.size);const t=()=>{n.dismissible&&e("close")};return a.onUnmounted(()=>{document.body.classList.remove("scroll-disabled")}),a.onMounted(()=>{document.body.classList.add("scroll-disabled")}),{onCloseModal:t}}});function YU(n,e,t,r,i,o){const s=a.resolveComponent("q-icon");return a.openBlock(),a.createElementBlock("div",{ref:"currentModal",class:a.normalizeClass(["q-modal",n.overlay]),onKeydown:e[3]||(e[3]=a.withKeys((...l)=>n.onCloseModal&&n.onCloseModal(...l),["escape"]))},[a.createElementVNode("div",a.mergeProps({class:"overlay"},{[a.toHandlerKey(n.dismissibleOverlay&&"click")]:e[0]||(e[0]=(...l)=>n.onCloseModal&&n.onCloseModal(...l))}),null,16),a.createElementVNode("div",{class:a.normalizeClass(["modal-container flex flex-col relative","modal-"+n.size,n.containerClass,{"building-background":n.hasBuildingBg}])},[n.dismissible?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["modal-close-button",n.closeButtonClass]),onClick:e[1]||(e[1]=(...l)=>n.onCloseModal&&n.onCloseModal(...l))},[a.createVNode(s,{icon:"close",type:"line",color:"gray-40"})],2)):a.createCommentVNode("",!0),a.renderSlot(n.$slots,"default",{},void 0,!0),n.showCancelLink?(a.openBlock(),a.createElementBlock("a",{key:1,class:"modal-close-link",href:"#",onClick:e[2]||(e[2]=a.withModifiers(l=>n.$emit("close"),["prevent"]))},a.toDisplayString(n.$t("HC_CANCEL")),1)):a.createCommentVNode("",!0)],2)],34)}const cm=Se(KU,[["render",YU],["__scopeId","data-v-8867a052"]]),QU=a.defineComponent({name:"QErrorModal",components:{QModal:cm},props:{toggle:{type:Boolean,default:!1,required:!0}},emits:["update:toggle"],setup(n,{emit:e}){return{toggleModal:a.computed({get:()=>n.toggle,set:r=>{e("update:toggle",r)}}),mq:fn}}}),XU={class:"flex flex-col gap-2 text-center"},JU={class:"text-lg font-bold text-inkwell-30 leading-6"},eZ={class:"text-inkwell-0 mb-2 md:mb-6"};function tZ(n,e,t,r,i,o){const s=a.resolveComponent("q-icon"),l=a.resolveComponent("q-button"),c=a.resolveComponent("q-modal-content"),d=a.resolveComponent("q-modal");return a.openBlock(),a.createBlock(a.Transition,{name:n.mq.md?"fade":"slide-up"},{default:a.withCtx(()=>[n.toggleModal?(a.openBlock(),a.createBlock(d,{key:0,id:"error-modal",dismissible:!1,overlay:n.mq.md?"white-transparent":"black-transparent",class:"!z-[170]",onClose:e[1]||(e[1]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(c,null,{body:a.withCtx(()=>[a.createElementVNode("div",XU,[a.createVNode(s,{icon:"exclamation-circle",type:"outline",size:"xl",color:"red-30",class:"shrink-0 self-center mb-4"}),a.createElementVNode("h2",JU,[a.renderSlot(n.$slots,"headline",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_ERROR")),1)],!0)]),a.createElementVNode("p",eZ,[a.renderSlot(n.$slots,"subtext",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_SORRY_UNEXPECTED_EXIT_MODAL")),1)],!0)])])]),footer:a.withCtx(()=>[a.createVNode(l,{class:a.normalizeClass([n.mq.md?"mx-3":"w-full"]),size:"lg",status:"secondary",onClick:e[0]||(e[0]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_EXIT")),1)]),_:1},8,["class"])]),_:3})]),_:3},8,["overlay"])):a.createCommentVNode("",!0)]),_:3},8,["name"])}const Tk=Se(QU,[["render",tZ],["__scopeId","data-v-3aa658e4"]]);WU.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${qU}/legacy/build/pdf.worker.min.mjs`;const nZ=a.defineComponent({name:"PdfViewer",components:{QErrorModal:Tk},props:{url:{type:String,required:!0}},emits:["pdf-error"],setup(n,{emit:e}){let t=null;const r=2,i=16,o=a.ref([]),s=a.ref(!0),l=a.ref(!1),c=a.ref(0),d=async()=>{try{if(t=await GU(n.url).promise,!t)throw new Error("pdfDoc is null or undefined");c.value=t.numPages,s.value=!1,await a.nextTick(),o.value=Array.from(document.querySelectorAll(".pdf-pages canvas")),await u()}catch(h){l.value=!0,console.log(h),s.value=!1,e("pdf-error",!0)}},u=async()=>{try{for(let h=1;h<=c.value;h++)await f(h)}catch(h){console.log(h),l.value=!0,e("pdf-error",!0)}},f=async h=>{try{const p=await(t==null?void 0:t.getPage(h));if(!p)throw new Error(`Page ${h} does not exist in the PDF document`);const b=p.getViewport({scale:1}),y=o.value[h-1];if(!y)throw new Error(`Canvas for page ${h} does not exist`);const w=y.getContext("2d");if(!w)throw new Error(`Context for page ${h} does not exist`);y.height=b==null?void 0:b.height,y.width=b==null?void 0:b.width;const v={canvasContext:w,viewport:b};await(p==null?void 0:p.render(v))}catch(p){console.log(p),l.value=!0,e("pdf-error",!0)}};return a.onMounted(()=>{d()}),{skeletonColumns:r,skeletonRows:i,canvasRefs:o,loadingMeta:s,showErrorModal:l,totalPages:c,loadPDF:d,renderPage:f}}}),rZ={class:"q-pdf-viewer"},iZ={key:0},oZ={key:1,class:"pdf-pages"};function sZ(n,e,t,r,i,o){const s=a.resolveComponent("q-error-modal");return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",rZ,[n.loadingMeta?(a.openBlock(),a.createElementBlock("div",iZ,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.skeletonRows,l=>(a.openBlock(),a.createElementBlock("div",{key:l,class:"flex items-center p-4"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.skeletonColumns,c=>(a.openBlock(),a.createElementBlock("div",{key:c,class:a.normalizeClass(["h-[1.5rem] border-white w-11/12",(l-1)%2?"bg-gray-10":"bg-gray-30",(l-1)%4||c===1?"animate-shimmer":"!hidden"])},null,2))),128))]))),128))])):(a.openBlock(),a.createElementBlock("div",oZ,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.totalPages,l=>(a.openBlock(),a.createElementBlock("canvas",{key:l,class:"w-full"}))),128))]))]),n.showErrorModal?(a.openBlock(),a.createBlock(s,{key:0,toggle:n.showErrorModal,"onUpdate:toggle":[e[0]||(e[0]=l=>n.showErrorModal=l),e[1]||(e[1]=l=>n.showErrorModal=!1)]},null,8,["toggle"])):a.createCommentVNode("",!0)],64)}const Ik=Se(nZ,[["render",sZ],["__scopeId","data-v-da5da0f5"]]),aZ=a.defineComponent({name:"QTooltip",props:{id:{type:String,default:"tooltip"},color:{type:String,default:"inkwell-30"},disabled:{type:Boolean,default:!1},noWrap:{type:Boolean,default:!0},position:{type:String,default:"bottom"},relative:{type:Boolean,default:!1},controlled:{type:Boolean,default:!1},tooltipClasses:{type:[String,Array,Object],default:""},visible:{type:Boolean,default:!1}},setup(n){return{isVisible:a.computed(()=>n.controlled?n.visible:!1)}}}),lZ=["aria-describedby"],cZ=["id"];function dZ(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["tooltip-container",n.controlled?"controlled":"",n.isVisible?"is-visible":""]),"aria-describedby":n.id},[a.renderSlot(n.$slots,"trigger",{},void 0,!0),a.createElementVNode("div",{id:n.id,class:a.normalizeClass(["tooltip",n.color?"bg-"+n.color+" border-"+n.color:"",n.position,n.noWrap?"no-wrap":"",n.relative?"relative":"",n.disabled?"!hidden":"",n.tooltipClasses]),role:"tooltip"},[a.renderSlot(n.$slots,"content",{},void 0,!0)],10,cZ)],10,lZ)}const R2=Se(aZ,[["render",dZ],["__scopeId","data-v-fac02047"]]),V2=()=>{const n=a.ref(""),e=navigator.userAgent;return e.match("/Android|webOS|iPhone|iPod|BlackBerry/i")?n.value="mobile":e.match("/iPad|Tablet/i")||navigator.maxTouchPoints&&navigator.maxTouchPoints>=0&&!window.matchMedia("(pointer:fine)").matches?n.value="tablet":n.value="desktop",{deviceType:n}},uZ=a.defineComponent({name:"ImageGallery",components:{Galleria:xS,QBadge:Zs,QBottomSheet:Cw,QMenu:z4,QPdfViewer:Ik,QTooltip:R2},props:{id:{type:String,default:"image-gallery"},files:{type:Array,default:()=>[]},thumbnailsVisible:{type:Number,default:4},showOnHover:{type:Boolean,default:!0},showThumbnails:{type:Boolean,default:!0},showRemove:{type:[Boolean,Number],default:!1},baseZIndex:{type:Number,default:1e3},wrap:{type:Boolean,default:!0},processing:{type:Boolean,default:!1}},emits:["update:model-value","update:activeIndex","click:file"],setup(n,{emit:e}){const{t}=no(),{deviceType:r}=V2(),i=[{text:t("HC_CANCEL")}],o=new Set(["doc","eps","mp3","mp4","mov","prt","pdf","ppt","tiff","txt","zip"]),s={docx:"doc",pptx:"ppt",tif:"tiff",xls:"xsl",xlsx:"xsl"},l=a.ref(null),c=a.computed(()=>{var P;return(P=l.value)==null?void 0:P.offsetWidth}),d=a.ref(null),u=a.ref([]),f=a.ref(!1),h=a.ref(null),p=a.ref("0"),g=a.ref(1),b=a.ref(fn.md?1:.9),y=a.ref(0),w=a.ref(null),v=a.ref(),S=a.ref(!1),C=a.ref(!1),A=a.computed(()=>[`z-[${n.baseZIndex+1}]`]),k=a.computed(()=>n.files.map(P=>{const _=P instanceof File,$=_?P.name:P.original.url,Y=G($.toLowerCase()).replace(/^\./,""),oe=Y?o.has(Y)?Y:s[Y]||"txt":"txt";return _?{id:P.lastModified+"-"+P.name.replace(/[\s.]/g,""),originalFile:P,name:P.name,url:URL.createObjectURL(P),type:P.type,extension:Y,icon:oe,isImage:P.type.startsWith("image")&&!P.type.includes("tif")}:{id:P.id,originalFile:P,name:P.original.name,url:P.original.url,type:P.mimetype,extension:Y,icon:oe,isImage:P.mimetype.startsWith("image")&&!P.mimetype.includes("tif")}})),E=a.computed(()=>k.value.filter(P=>P.type.startsWith("image")&&!P.type.includes("tif"))),O=a.computed(()=>["rounded-lg relative mx-auto object-cover grow-1 max-h-[74vh]",{animated:!K}]),x=a.computed(()=>["flex items-center gap-3",n.wrap?"flex-wrap":"flex-nowrap overflow-x-auto shrink-0",{"flex-nowrap overflow-x-auto":r.value!=="desktop"}]),N=a.computed(()=>[{text:t("HC_DELETE_ATTACHMENT"),classes:"!text-red-20",event:H}]),D=P=>{r.value==="desktop"?window.open(P.url,"_blank"):window.open(P.url,"_self")},B=P=>{r.value==="desktop"?D(P):(w.value=P,C.value=!0)},z=P=>{P.event(),f.value=!1},Z=(P,_)=>{!f.value&&_.isImage?U(P,_):!f.value&&!_.isImage&&B(_)},U=(P,_)=>{const $=oe=>oe.url===(_==null?void 0:_.url),Y=E.value.findIndex($);y.value=Y!==-1?Y:P,S.value=!0},H=(P=null)=>{var _;f.value=!1,e("update:model-value",(P==null?void 0:P.originalFile)||((_=h.value)==null?void 0:_.originalFile))},V=P=>{const{keyCode:_}=P;if(S.value)switch(_){case 37:y.value=y.value?y.value-1:E.value.length-1,e("update:activeIndex",y.value);break;case 39:y.value=y.value<E.value.length-1?y.value+1:0,e("update:activeIndex",y.value);break;case 27:S.value=!1;break}},{isSwiping:K,lengthX:R}=qP(d,{passive:!1,onSwipe(){const P=Math.abs(R.value);c.value&&(g.value=1.1-P/c.value,p.value=R.value<0?`${P/4}px`:`-${P/4}px`)},onSwipeEnd(){const P=y.value<=0,_=y.value>=E.value.length-1,$=Math.abs(R.value);c.value&&$/c.value>=.5?(R.value<0?y.value=P?E.value.length-1:y.value-1:y.value=_?0:y.value+1,p.value="0",g.value=1):(p.value="0",g.value=1)}}),G=P=>P.substring(P.lastIndexOf(".")),re=(P,_)=>{P.preventDefault(),h.value=k.value[_],f.value=!0},Q=()=>{f.value=!1,h.value=null},F=()=>{r.value!=="desktop"&&u.value.forEach(P=>{FP(P,_=>{const $=u.value.indexOf(P);re(_,$)},{modifiers:{prevent:!0}})})};return a.onMounted(()=>{window.addEventListener("keyup",V),F()}),a.onUpdated(()=>{F()}),{menuActions:i,linkActions:N,deviceType:r,container:l,containerWidth:c,featuredPhoto:d,longPressRef:u,longPressedHook:f,isSwiping:K,lengthX:R,left:p,opacity:g,scale:b,showCarousel:S,showFileViewer:C,active:y,activeAttachment:w,hoveredIndex:v,closeIconClasses:A,itemClasses:O,images:E,normalizedFiles:k,thumbnailContainerClasses:x,downloadDocument:D,getExtension:G,onAttachmentClick:B,onClickMenuLink:z,onClickThumbnail:Z,onOpenCarousel:U,onRemoveFile:H,onKeyboardNavigation:V,onLongPressCallbackHook:re,resetHook:Q,mq:fn}}}),fZ=["id"],hZ=["id"],pZ=["src","alt"],mZ=["id","alt","src"],gZ=["id","onMouseover","onClick"],yZ=["alt","src"],bZ={key:1,class:"bg-gray-00 cursor-pointer p-3 h-16 max-w-[14rem] rounded-lg border border-gray-20 flex items-center"},wZ={class:"grow text-ellipsis overflow-hidden"},vZ={class:"text-inkwell-30 bold leading-normal text-nowrap text-ellipsis text-sm overflow-hidden -mt-1"},CZ={class:"uppercase text-xxs"},SZ={key:2,class:"image-overlay absolute top-0 left-0 w-full h-full cursor-pointer"},kZ={key:0,class:"absolute top-0 left-0 z-1 w-full h-full cursor-pointer bg-black/50 rounded-lg flex items-center justify-center"},MZ={key:1,width:"100%",height:"auto",controls:"",class:"bg-black"},EZ=["src"],AZ={class:"flex items-center flex-col p-12"},TZ=["src"],IZ=["data","type"],xZ={class:"flex items-center flex-col p-12"};function OZ(n,e,t,r,i,o){const s=a.resolveComponent("q-icon"),l=a.resolveComponent("Galleria"),c=a.resolveComponent("q-badge"),d=a.resolveComponent("q-tooltip"),u=a.resolveComponent("q-menu"),f=a.resolveComponent("q-pdf-viewer"),h=a.resolveComponent("q-bottom-sheet");return a.openBlock(),a.createElementBlock("div",{id:n.id,class:"q-image-gallery flex",ref:"container"},[a.createVNode(l,{activeIndex:n.active,"onUpdate:activeIndex":e[0]||(e[0]=p=>n.active=p),visible:n.showCarousel,"onUpdate:visible":e[1]||(e[1]=p=>n.showCarousel=p),value:n.images,numVisible:n.thumbnailsVisible,circular:!0,fullScreen:!0,showItemNavigators:n.mq.md,showThumbnailNavigators:!0,showThumbnails:n.showThumbnails&&n.mq.md,showIndicators:!n.mq.md,containerStyle:[{height:"100vh"}],"base-z-index":n.baseZIndex},{closeicon:a.withCtx(()=>[a.createVNode(s,{class:a.normalizeClass(n.closeIconClasses),icon:"times-circle",type:"outline",size:"lg",color:"white"},null,8,["class"])]),item:a.withCtx(({item:p})=>[a.createElementVNode("div",{id:`gallery-featured${p.id?"-"+p.id:""}`,ref:"featuredPhoto",class:"featured-image h-[80vh] overflow-hidden flex max-w-screen relative md:h-full w-screen items-center"},[a.createElementVNode("img",{src:p==null?void 0:p.url,alt:p==null?void 0:p.alt,class:a.normalizeClass(n.itemClasses),style:a.normalizeStyle([{left:n.left,opacity:n.opacity},`transform: scale(${n.scale})`])},null,14,pZ)],8,hZ)]),thumbnail:a.withCtx(({item:p})=>[a.createElementVNode("img",{id:`gallery-image-thumbnail${p.id?"-"+p.id:""}`,alt:(p==null?void 0:p.alt)||"",src:p==null?void 0:p.url,class:"rounded-lg block min-h-24 min-w-24 max-w-24 max-h-24 object-cover"},null,8,mZ)]),previousitemicon:a.withCtx(()=>[a.createVNode(s,{icon:"chevron-circle-left",type:"outline",size:"md",color:"white"})]),nextitemicon:a.withCtx(()=>[a.createVNode(s,{icon:"chevron-circle-right",type:"outline",size:"md",color:"white"})]),previousthumbnailicon:a.withCtx(()=>[n.images.length>n.thumbnailsVisible?(a.openBlock(),a.createBlock(s,{key:0,icon:"chevron-left",type:"line",size:"sm",color:"white"})):a.createCommentVNode("",!0)]),nextthumbnailicon:a.withCtx(()=>[n.images.length>n.thumbnailsVisible?(a.openBlock(),a.createBlock(s,{key:0,icon:"chevron-right",type:"line",size:"sm",color:"white"})):a.createCommentVNode("",!0)]),_:1},8,["activeIndex","visible","value","numVisible","showItemNavigators","showThumbnails","showIndicators","base-z-index"]),n.normalizedFiles?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(n.thumbnailContainerClasses)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.normalizedFiles,(p,g)=>(a.openBlock(),a.createElementBlock("div",{ref_for:!0,ref:"longPressRef",key:p.id||p.name||g,id:`gallery-file-thumbnail-${p.id?p.id:g}`,class:a.normalizeClass(["p-0 relative rounded-lg",{"shrink-0":n.deviceType!=="desktop"}]),onMouseover:b=>n.hoveredIndex=g,onMouseleave:e[2]||(e[2]=b=>n.hoveredIndex=null),onClick:b=>n.onClickThumbnail(g,p)},[a.createVNode(d,{position:"top"},{trigger:a.withCtx(()=>[p.type&&p.type.includes("image")&&!p.type.includes("tif")?(a.openBlock(),a.createElementBlock("img",{key:0,alt:p==null?void 0:p.alt,src:p==null?void 0:p.url,class:"rounded-lg cursor-pointer w-16 h-16 object-cover bg-gray-0 border-gray-20 border"},null,8,yZ)):(a.openBlock(),a.createElementBlock("div",bZ,[a.createVNode(s,{icon:p.icon,color:"inkwell-30",class:"h-full -ml-1.5 mt-1 mr-1 rounded-lg shrink-0",size:"xl"},null,8,["icon"]),a.createElementVNode("div",wZ,[a.createElementVNode("div",vZ,a.toDisplayString(p.name),1),a.createElementVNode("div",CZ,a.toDisplayString(p.name.match(/([^.]+$)/)[0]),1)])])),n.deviceType!=="desktop"?(a.openBlock(),a.createElementBlock("div",SZ)):a.createCommentVNode("",!0),n.showRemove&&n.showOnHover&&n.hoveredIndex===g&&n.deviceType==="desktop"&&!n.processing?(a.openBlock(),a.createBlock(c,{key:3,color:"inkwell-30",shape:"circle",class:"cursor-pointer absolute -top-2 -right-2 shadow-solid z-10",onClick:a.withModifiers(b=>n.onRemoveFile(p),["stop"])},{icon:a.withCtx(()=>[a.createVNode(s,{icon:"close",size:"xs",type:"line",color:"white"})]),_:2},1032,["onClick"])):a.createCommentVNode("",!0)]),content:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(p.name),1)]),_:2},1024),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.processing?(a.openBlock(),a.createElementBlock("div",kZ,e[7]||(e[7]=[a.createElementVNode("svg",{class:"animate-spin fill-white",width:"20",height:"20",viewBox:"0 0 24 24"},[a.createElementVNode("path",{d:"M2 12a1 1 0 0 1 2 0 8 8 0 1 0 8-8 1 1 0 0 1 0-2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12z"})],-1)]))):a.createCommentVNode("",!0)]),_:1})],42,gZ))),128)),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.longPressedHook?(a.openBlock(),a.createBlock(u,{key:0,modelValue:n.longPressedHook,"onUpdate:modelValue":e[3]||(e[3]=p=>n.longPressedHook=p),actions:n.menuActions,links:n.linkActions,"links-background":"light-gray","onClick:link":n.onClickMenuLink,"onClick:action":e[4]||(e[4]=p=>n.longPressedHook=!1)},null,8,["modelValue","actions","links","onClick:link"])):a.createCommentVNode("",!0)]),_:1})],2)):a.createCommentVNode("",!0),a.createVNode(a.Transition,{name:"slide-up-fade"},{default:a.withCtx(()=>[n.showFileViewer&&n.activeAttachment?(a.openBlock(),a.createBlock(h,{key:0,id:"gallery-file-viewer",modelValue:n.showFileViewer,"onUpdate:modelValue":e[6]||(e[6]=p=>n.showFileViewer=p),"show-close-button":!1,"content-class":"p-0","header-class":"border-b border-solid border-gray-20","title-class":"min-w-0 truncate"},{header:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.activeAttachment.name),1)]),headerAction:a.withCtx(()=>[!n.activeAttachment.type.includes("video")&&n.activeAttachment.type!=="audio/mpeg"&&n.activeAttachment.type!=="application/pdf"?(a.openBlock(),a.createBlock(s,{key:0,icon:"arrow-to-bottom",type:"line",size:"md",color:"inkwell-40",class:"shrink-0 cursor-pointer",onClick:e[5]||(e[5]=p=>n.downloadDocument(n.activeAttachment))})):a.createCommentVNode("",!0)]),default:a.withCtx(()=>[n.activeAttachment.type==="application/pdf"?(a.openBlock(),a.createBlock(f,{key:0,url:n.activeAttachment.url},null,8,["url"])):n.activeAttachment.type.includes("video")?(a.openBlock(),a.createElementBlock("video",MZ,[a.createElementVNode("source",{src:n.activeAttachment.url,type:"video/mp4"},null,8,EZ),a.createElementVNode("div",AZ,[a.createVNode(s,{color:"inkwell-30",icon:"mp4",size:"xl"}),a.createTextVNode(" "+a.toDisplayString(n.activeAttachment.extension),1)])])):n.activeAttachment.type==="audio/mpeg"?(a.openBlock(),a.createElementBlock("audio",{key:2,controls:"",src:n.activeAttachment.url,class:"mx-auto my-6"},null,8,TZ)):(a.openBlock(),a.createElementBlock("object",{key:3,data:n.activeAttachment.url,type:n.activeAttachment.type,class:"w-full h-auto"},[a.createElementVNode("div",xZ,[a.createVNode(s,{icon:n.activeAttachment.icon,size:"xl",color:"inkwell-30"},null,8,["icon"]),a.createTextVNode(" "+a.toDisplayString(n.activeAttachment.extension),1)])],8,IZ))]),_:1},8,["modelValue"])):a.createCommentVNode("",!0)]),_:1})],8,fZ)}const x6=Se(uZ,[["render",OZ],["__scopeId","data-v-82fb8862"]]),DZ=a.defineComponent({name:"QWarningModal",components:{QModal:cm},props:{toggle:{type:Boolean,default:!1,required:!0},action:{type:Function,default:()=>{}},processing:{type:Boolean,default:!1}},emits:["update:toggle","update:action"],setup(n,{emit:e}){return{toggleModal:a.computed({get:()=>n.toggle,set:r=>{e("update:toggle",r)}}),mq:fn}}}),NZ={key:0,class:"flex flex-col gap-2 text-center"},PZ={class:"text-lg font-bold text-inkwell-30 leading-6"},LZ={class:"text-inkwell-0 mb-6"},BZ={key:1,class:"flex flex-col gap-2 text-center"},_Z={class:"text-[1.25rem] font-bold text-center text-inkwell-30"},RZ={class:"text-sm text-center text-inkwell-0 mb-2"},VZ={class:"flex flex-col items-center justify-center gap-3 md:gap-2"};function $Z(n,e,t,r,i,o){const s=a.resolveComponent("q-button"),l=a.resolveComponent("q-modal-content"),c=a.resolveComponent("q-modal");return a.openBlock(),a.createBlock(a.Transition,{name:n.mq.md?"fade":"slide-up"},{default:a.withCtx(()=>[n.toggleModal?(a.openBlock(),a.createBlock(c,{key:0,class:"warning-modal !z-[170]",dismissible:!1,overlay:n.mq.md?"white-transparent":"black-transparent","container-class":"h-fit min-h-fit",onClose:e[1]||(e[1]=d=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(l,null,{body:a.withCtx(()=>[n.mq.md?(a.openBlock(),a.createElementBlock("div",NZ,[a.createElementVNode("h2",PZ,[a.renderSlot(n.$slots,"desktopHeader",{},void 0,!0)]),a.createElementVNode("p",LZ,[a.renderSlot(n.$slots,"desktopMessage",{},void 0,!0)])])):(a.openBlock(),a.createElementBlock("div",BZ,[a.createElementVNode("h2",_Z,[a.renderSlot(n.$slots,"mobileHeader",{},void 0,!0)]),a.createElementVNode("p",RZ,[a.renderSlot(n.$slots,"mobileMessage",{},void 0,!0)])]))]),footer:a.withCtx(()=>[a.createElementVNode("div",VZ,[a.createVNode(s,{disabled:n.processing,loading:n.processing,class:a.normalizeClass([n.mq.md?"mx-2":"w-full"]),size:"lg",status:"danger",onClick:n.action},{default:a.withCtx(()=>[a.renderSlot(n.$slots,"buttonText",{},void 0,!0)]),_:3},8,["disabled","loading","class","onClick"]),a.createVNode(s,{class:a.normalizeClass([n.mq.md?"mx-2":"w-full"]),disabled:n.processing,status:n.mq.md?"link-secondary":"secondary",size:"lg",onClick:e[0]||(e[0]=d=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.renderSlot(n.$slots,"cancelText",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_CANCEL")),1)],!0)]),_:3},8,["class","disabled","status"])])]),_:3})]),_:3},8,["overlay"])):a.createCommentVNode("",!0)]),_:3},8,["name"])}const xk=Se(DZ,[["render",$Z],["__scopeId","data-v-db0b6069"]]),FZ=a.defineComponent({name:"QPopover",props:{align:{type:String,default:"left"},hasCaret:{type:Boolean,default:!0},modelValue:{type:Boolean,default:!1},position:{type:String,default:"bottom"},reposition:{type:Boolean,default:!0},size:{type:String,default:"md"},trigger:{type:String,default:"click"}},emits:["update:modelValue"],setup(n,{emit:e}){const t=a.ref(!1),r=a.ref(""),i=a.ref(null),o=a.computed(()=>t.value===!0&&n.reposition===!0?l(n.align):n.align),s=a.computed(()=>t.value===!0&&n.reposition===!0?c(n.position):n.position),l=y=>{if(!i.value||d(i.value.children[1]))return y;const w=i.value.children[0].getBoundingClientRect(),v=i.value.children[1].getBoundingClientRect();if(y==="left"||y==="right"||y==="center"){const S=w.left;return window.innerWidth-S<v.width?"right":"left"}else{const S=w.top;return window.innerHeight-S<v.height?"bottom":"top"}},c=y=>{if(!i.value||d(i.value.children[1]))return y;const w=i.value.children[0].getBoundingClientRect(),v=i.value.children[1].getBoundingClientRect();if(y==="top"||y==="bottom"){const S=w.top;return window.innerHeight-S<v.height?"top":"bottom"}else{const S=w.left;return window.innerWidth-S<v.width?"left":"right"}},d=y=>{const w=y.getBoundingClientRect();return w?w.top>=0&&w.left>=0&&w.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&w.right<=(window.innerWidth||document.documentElement.clientWidth):!1},u=()=>{(n.trigger==="click"||n.trigger==="both")&&e("update:modelValue",!n.modelValue)},f=()=>{n.trigger!=="click"&&e("update:modelValue",!1)},h=()=>{n.trigger!=="click"&&e("update:modelValue",!0)},p=()=>{var w;const y=(w=i.value)==null?void 0:w.children[0];if(y){const v=y.clientWidth,S=y.clientHeight;switch(o.value){case"left":r.value=`margin-left: ${v/2-10}px;`;break;case"right":r.value=`margin-right: ${v/2-10}px;`;break;case"top":r.value=`margin-top: ${S/2-10}px;`;break;case"bottom":r.value=`margin-bottom: ${S/2-10}px;`;break}}};Yh(i,()=>{e("update:modelValue",!1)});function g(){t.value=!1}function b(){var y;t.value=!0,!d((y=i.value)==null?void 0:y.children[1])&&n.reposition===!0&&p()}return{entered:t,offsetStyle:r,popover:i,alignment:o,positioning:s,getAlignment:l,getPositioning:c,isElementInView:d,onAfterLeave:g,onClick:u,onClickOutside:Yh,onEnter:b,onMouseLeave:f,onMouseOver:h}}});function jZ(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{ref:"popover",class:"popover-container",onMouseleave:e[0]||(e[0]=(...s)=>n.onMouseLeave&&n.onMouseLeave(...s))},[a.renderSlot(n.$slots,"trigger",{onClick:n.onClick,onMouseOver:n.onMouseOver},void 0,!0),a.createVNode(a.Transition,{name:"fade",onEnter:n.onEnter,onAfterLeave:n.onAfterLeave},{default:a.withCtx(()=>[n.modelValue?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["popover","popover-"+n.alignment,"popover-"+n.size,"popover-on-"+n.positioning,{"has-caret":n.hasCaret}]),style:a.normalizeStyle(n.offsetStyle)},[a.renderSlot(n.$slots,"content",{},void 0,!0)],6)):a.createCommentVNode("",!0)]),_:3},8,["onEnter","onAfterLeave"])],544)}const Ok=Se(FZ,[["render",jZ],["__scopeId","data-v-86f2575d"]]);function mn(n){this.content=n}mn.prototype={constructor:mn,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new mn(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new mn(t)},addToStart:function(n,e){return new mn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new mn(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new mn(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=mn.from(n),n.size?new mn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=mn.from(n),n.size?new mn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=mn.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},mn.from=function(n){if(n instanceof mn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new mn(e)};function Dk(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Dk(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Nk(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),c=s.nodeSize;if(s==l){t-=c,r-=c;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let d=0,u=Math.min(s.text.length,l.text.length);for(;d<u&&s.text[s.text.length-d-1]==l.text[l.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(s.content.size||l.content.size){let d=Nk(s.content,l.content,t-1,r-1);if(d)return d}t-=c,r-=c}}class J{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,l=0;l<t;s++){let c=this.content[s],d=l+c.nodeSize;if(d>e&&r(c,i+l,o||null,s)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,t-u),r,i+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,t-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=d},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new J(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],c=s+l.nodeSize;c>e&&((s<e||c>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=c}return new J(r,i)}cutByIndex(e,t){return e==t?J.empty:e==0&&t==this.content.length?this:new J(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new J(i,o)}addToStart(e){return new J([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new J(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Dk(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nk(this,e,t,r)}findIndex(e,t=-1){if(e==0)return dm(0,e);if(e==this.size)return dm(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?dm(r+1,s):dm(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return J.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new J(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return J.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new J(t||e,r)}static from(e){if(!e)return J.empty;if(e instanceof J)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new J([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}J.empty=new J([],0);const O6={index:0,offset:0};function dm(n,e){return O6.index=n,O6.offset=e,O6}function um(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!um(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!um(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let rt=class N9{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&um(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return N9.none;if(e instanceof N9)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};rt.none=[];class fm extends Error{}class le{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Lk(this.content,e+this.openStart,t);return r&&new le(r,this.openStart,this.openEnd)}removeBetween(e,t){return new le(Pk(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return le.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new le(J.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new le(e,r,i)}}le.empty=new le(J.empty,0,0);function Pk(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Pk(o.content,e-i-1,t-i-1)))}function Lk(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Lk(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function zZ(n,e,t){if(t.openStart>n.depth)throw new fm("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fm("Inconsistent open depths");return Bk(n,e,t,0)}function Bk(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Bk(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return $0(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=HZ(t,n);return $0(o,Rk(n,s,l,e,r))}else return $0(o,hm(n,e,r))}function _k(n,e){if(!e.type.compatibleContent(n.type))throw new fm("Cannot join "+e.type.name+" onto "+n.type.name)}function D6(n,e,t){let r=n.node(t);return _k(r,e.node(t)),r}function V0(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hd(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(V0(n.nodeAfter,r),o++));for(let l=o;l<s;l++)V0(i.child(l),r);e&&e.depth==t&&e.textOffset&&V0(e.nodeBefore,r)}function $0(n,e){return n.type.checkContent(e),n.copy(e)}function Rk(n,e,t,r,i){let o=n.depth>i&&D6(n,e,i+1),s=r.depth>i&&D6(t,r,i+1),l=[];return Hd(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(_k(o,s),V0($0(o,Rk(n,e,t,r,i+1)),l)):(o&&V0($0(o,hm(n,e,i+1)),l),Hd(e,t,i,l),s&&V0($0(s,hm(t,r,i+1)),l)),Hd(r,null,i,l),new J(l)}function hm(n,e,t){let r=[];if(Hd(null,n,t,r),n.depth>t){let i=D6(n,e,t+1);V0($0(i,hm(n,e,t+1)),r)}return Hd(e,null,t,r),new J(r)}function HZ(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(J.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ud{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return rt.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new pm(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:c}=s.content.findIndex(o),d=o-c;if(r.push(s,l,i+c),!d||(s=s.child(l),s.isText))break;o=d-1,i+=c+1}return new Ud(t,r,o)}static resolveCached(e,t){for(let i=0;i<N6.length;i++){let o=N6[i];if(o.pos==t&&o.doc==e)return o}let r=N6[P6]=Ud.resolve(e,t);return P6=(P6+1)%UZ,r}}let N6=[],P6=0,UZ=12;class pm{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ZZ=Object.create(null);let F0=class P9{constructor(e,t,r,i=rt.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||J.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&um(this.attrs,t||e.defaultAttrs||ZZ)&&rt.sameSet(this.marks,r||rt.none)}copy(e=null){return e==this.content?this:new P9(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new P9(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return le.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),l=i.start(s),d=i.node(s).content.cut(i.pos-l,o.pos-l);return new le(d,i.depth-s,o.depth-s)}replace(e,t,r){return zZ(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Ud.resolveCached(this,e)}resolveNoCache(e){return Ud.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Vk(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=J.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let c=i;c<o;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=rt.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!rt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=J.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};F0.prototype.text=void 0;class mm extends F0{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Vk(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mm(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mm(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Vk(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class j0{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new WZ(e,t);if(r.next==null)return j0.empty;let i=$k(r);r.next&&r.err("Unexpected trailing text");let o=JZ(XZ(i));return eW(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,l){let c=s.matchFragment(e,r);if(c&&(!t||c.validEnd))return J.from(l.map(d=>d.createAndFill()));for(let d=0;d<s.next.length;d++){let{type:u,next:f}=s.next[d];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,l.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:c}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
132
132
|
`)}}j0.empty=new j0(!0);class WZ{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $k(n){let e=[];do e.push(GZ(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function GZ(n){let e=[];do e.push(qZ(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function qZ(n){let e=QZ(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=KZ(n,e);else break;return e}function Fk(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function KZ(n,e){let t=Fk(n),r=t;return n.eat(",")&&(n.next!="}"?r=Fk(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function YZ(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function QZ(n){if(n.eat("(")){let e=$k(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=YZ(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function XZ(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,c){let d={term:c,to:l};return e[s].push(d),d}function i(s,l){s.forEach(c=>c.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((c,d)=>c.concat(o(d,l)),[]);if(s.type=="seq")for(let c=0;;c++){let d=o(s.exprs[c],l);if(c==s.exprs.length-1)return d;i(d,l=t())}else if(s.type=="star"){let c=t();return r(l,c),i(o(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=t();return i(o(s.expr,l),c),i(o(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let c=l;for(let d=0;d<s.min;d++){let u=t();i(o(s.expr,c),u),c=u}if(s.max==-1)i(o(s.expr,c),c);else for(let d=s.min;d<s.max;d++){let u=t();r(c,u),i(o(s.expr,c),u),c=u}return[r(c)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function jk(n,e){return e-n}function zk(n,e){let t=[];return r(e),t.sort(jk);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:c}=o[s];!l&&t.indexOf(c)==-1&&r(c)}}}function JZ(n){let e=Object.create(null);return t(zk(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u<i.length;u++)i[u][0]==l&&(d=i[u][1]);zk(n,c).forEach(u=>{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let o=e[r.join(",")]=new j0(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(jk);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function eW(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:c,next:d}=i.next[l];s.push(c.name),o&&!(c.isText||c.hasRequiredAttrs())&&(o=!1),r.indexOf(d)==-1&&r.push(d)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Hk(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Uk(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Zk(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new tW(n[t]);return e}let Wk=class XD{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Zk(r.attrs),this.defaultAttrs=Hk(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==j0.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Uk(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new F0(this,this.computeAttrs(e),J.from(t),rt.setFrom(r))}createChecked(e=null,t,r){return t=J.from(t),this.checkContent(t),new F0(this,this.computeAttrs(e),t,rt.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=J.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(J.empty,!0);return o?new F0(this,e,t.append(o),rt.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:rt.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new XD(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class tW{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class gm{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Zk(i.attrs),this.excluded=null;let o=Hk(this.attrs);this.instance=o?new rt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new rt(this,Uk(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new gm(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class nW{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=mn.from(e.nodes),t.marks=mn.from(e.marks||{}),this.nodes=Wk.compile(this.spec.nodes,this),this.marks=gm.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;o.contentMatch=r[s]||(r[s]=j0.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=l=="_"?null:l?Gk(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Gk(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Wk){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new mm(r,r.defaultAttrs,e,rt.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return F0.fromJSON(this,e)}markFromJSON(e){return rt.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Gk(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);else for(let l in n.marks){let c=n.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}class $2{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Qk(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Qk(this,t,!0);return r.addAll(e,t.from,t.to),le.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(oW(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let c=s.getAttrs(t);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Xk(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Xk(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $2(e,$2.schemaRules(e)))}}const qk={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rW={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Kk={ol:!0,ul:!0},ym=1,bm=2,wm=4;function Yk(n,e,t){return e!=null?(e?ym:0)|(e==="full"?bm:0):n&&n.whitespace=="pre"?ym|bm:t&-5}class vm{constructor(e,t,r,i,o,s,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=l,this.content=[],this.activeMarks=rt.none,this.stashMarks=[],this.match=s||(l&wm?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(J.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ym)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=J.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(J.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let i=r[t];(this.type?this.type.allowsMarkType(i.type):aW(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!qk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qk{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=Yk(null,t.preserveWhitespace,0)|(r?wm:0);i?o=new vm(i.type,i.attrs,rt.none,rt.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new vm(null,null,rt.none,rt.none,!0,null,s):o=new vm(e.schema.topNodeType,null,rt.none,rt.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,t){let r=e.getAttribute("style");if(!r)return t();let i=this.readStyles(sW(r));if(!i)return;let[o,s]=i,l=this.top;for(let c=0;c<s.length;c++)this.removePendingMark(s[c],l);for(let c=0;c<o.length;c++)this.addPendingMark(o[c]);t();for(let c=0;c<o.length;c++)this.removePendingMark(o[c],l);for(let c=0;c<s.length;c++)this.addPendingMark(s[c])}addTextNode(e){let t=e.nodeValue,r=this.top;if(r.options&bm||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&ym)r.options&bm?t=t.replace(/\r\n?/g,`
|
|
133
133
|
`):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],o=e.previousSibling;(!i||o&&o.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),i;Kk.hasOwnProperty(r)&&this.parser.normalizeLists&&iW(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(o?o.ignore:rW.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let s,l=this.top,c=this.needsBlock;if(qk.hasOwnProperty(r))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),s=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}o&&o.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),s&&this.sync(l),this.needsBlock=c}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,o.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
134
134
|
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=rt.none,r=rt.none;for(let i=0;i<e.length;i+=2)for(let o=void 0;;){let s=this.parser.matchStyle(e[i],e[i+1],this,o);if(!s)break;if(s.ignore)return null;if(s.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(l=>{s.clearMark(l)&&(r=l.addToSet(r))}):t=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(t),s.consuming===!1)o=s;else break}return[t,r]}addElementByRule(e,t,r){let i,o,s;t.node?(o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):i=this.enter(o,t.attrs||null,t.preserveWhitespace)):(s=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(s));let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c));else{let c=e;typeof t.contentElement=="string"?c=e.querySelector(t.contentElement):typeof t.contentElement=="function"?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c)}i&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,t,r){let i=t||0;for(let o=t?e.childNodes[t]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],s=o.findWrapping(e);if(s&&(!t||t.length>s.length)&&(t=s,r=o,!s.length)||o.solid)break}if(!t)return!1;this.sync(r);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,r),i}enterInner(e,t=null,r=!1,i){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let s=Yk(e,i,o.options);o.options&wm&&o.content.length==0&&(s|=wm),this.nodes.push(new vm(e,t,o.activeMarks,o.pendingMarks,r,null,s)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,c)=>{for(;l>=0;l--){let d=t[l];if(d==""){if(l==t.length-1||l==0)continue;for(;c>=o;c--)if(s(l-1,c))return!0;return!1}else{let u=c>0||c==0&&i?this.nodes[c].type:r&&c>=o?r.node(c-o).type:null;if(!u||u.name!=d&&u.groups.indexOf(d)==-1)return!1;c--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=lW(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let s=i.popFromStashMark(e);s&&i.type&&i.type.allowsMarkType(s.type)&&(i.activeMarks=s.addToSet(i.activeMarks))}if(i==t)break}}}function iW(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Kk.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function oW(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function sW(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Xk(n){let e={};for(let t in n)e[t]=n[t];return e}function aW(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:u}=l.edge(c);if(d==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}function lW(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class io{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=L6(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,c=0;for(;l<o.length&&c<s.marks.length;){let d=s.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(o[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<o.length;)i=o.pop()[1];for(;c<s.marks.length;){let d=s.marks[c++],u=this.serializeMark(d,s.isInline,t);u&&(o.push([d,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=io.renderSpec(L6(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&io.renderSpec(L6(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let s,l=r?e.createElementNS(r,i):e.createElement(i),c=t[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?l.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):l.setAttribute(u,c[u])}}for(let u=d;u<t.length;u++){let f=t[u];if(f===0){if(u<t.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=io.renderSpec(e,f,r);if(l.appendChild(h),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new io(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jk(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Jk(e.marks)}}function Jk(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function L6(n){return n.document||window.document}const eM=65535,tM=Math.pow(2,16);function cW(n,e){return n+e*tM}function nM(n){return n&eM}function dW(n){return(n-(n&eM))/tM}const rM=1,iM=2,Cm=4,oM=8;class B6{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&oM)>0}get deletedBefore(){return(this.delInfo&(rM|Cm))>0}get deletedAfter(){return(this.delInfo&(iM|Cm))>0}get deletedAcross(){return(this.delInfo&Cm)>0}}class xr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xr.empty)return xr.empty}recover(e){let t=0,r=nM(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+dW(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let d=this.ranges[l+o],u=this.ranges[l+s],f=c+d;if(e<=f){let h=d?e==c?-1:e==f?1:t:t,p=c+i+(h<0?0:u);if(r)return p;let g=e==(t<0?c:f)?null:cW(l/3,e-c),b=e==c?iM:e==f?rM:Cm;return(t<0?e!=c:e!=f)&&(b|=oM),new B6(p,b,g)}i+=u-d}return r?e+i:new B6(e+i,0,null)}touches(e,t){let r=0,i=nM(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[l+o],u=c+d;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),c=s+(this.inverted?0:o),d=this.ranges[i+t],u=this.ranges[i+r];e(l,l+d,c,c+u),o+=u-d}}invert(){return new xr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xr.empty:new xr(e<0?[0,-e,0]:[0,0,e])}}xr.empty=new xr([]);class F2{constructor(e=[],t,r=0,i=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=i}slice(e=0,t=this.maps.length){return new F2(this.maps,this.mirror,e,t)}copy(){return new F2(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new F2;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this.maps[o],l=s.mapResult(e,t);if(l.recover!=null){let c=this.getMirror(o);if(c!=null&&c>o&&c<this.to){o=c,e=this.maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new B6(e,i,null)}}const _6=Object.create(null);class On{getMap(){return xr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=_6[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in _6)throw new RangeError("Duplicate use of step JSON ID "+e);return _6[e]=t,t.prototype.jsonID=e,t}}class Ft{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ft(e,null)}static fail(e){return new Ft(null,e)}static fromReplace(e,t,r,i){try{return Ft.ok(e.replace(t,r,i))}catch(o){if(o instanceof fm)return Ft.fail(o.message);throw o}}}function R6(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(R6(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return J.fromArray(r)}class sa extends On{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new le(R6(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Ft.fromReplace(e,this.from,this.to,o)}invert(){return new oo(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new sa(t.pos,r.pos,this.mark)}merge(e){return e instanceof sa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sa(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sa(t.from,t.to,e.markFromJSON(t.mark))}}On.jsonID("addMark",sa);class oo extends On{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new le(R6(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Ft.fromReplace(e,this.from,this.to,r)}invert(){return new sa(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new oo(t.pos,r.pos,this.mark)}merge(e){return e instanceof oo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new oo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new oo(t.from,t.to,e.markFromJSON(t.mark))}}On.jsonID("removeMark",oo);class aa extends On{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ft.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ft.fromReplace(e,this.pos,this.pos+1,new le(J.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new aa(this.pos,t.marks[i]);return new aa(this.pos,this.mark)}}return new j2(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new aa(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new aa(t.pos,e.markFromJSON(t.mark))}}On.jsonID("addNodeMark",aa);class j2 extends On{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ft.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ft.fromReplace(e,this.pos,this.pos+1,new le(J.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new aa(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new j2(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new j2(t.pos,e.markFromJSON(t.mark))}}On.jsonID("removeNodeMark",j2);class Yt extends On{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&V6(e,this.from,this.to)?Ft.fail("Structure replace would overwrite content"):Ft.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Yt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Yt(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Yt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?le.empty:new le(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Yt(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?le.empty:new le(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Yt(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Yt(t.from,t.to,le.fromJSON(e,t.slice),!!t.structure)}}On.jsonID("replace",Yt);class Qt extends On{constructor(e,t,r,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(V6(e,this.from,this.gapFrom)||V6(e,this.gapTo,this.to)))return Ft.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ft.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Ft.fromReplace(e,this.from,this.to,r):Ft.fail("Content does not fit in gap")}getMap(){return new xr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Qt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new Qt(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Qt(t.from,t.to,t.gapFrom,t.gapTo,le.fromJSON(e,t.slice),t.insert,!!t.structure)}}On.jsonID("replaceAround",Qt);function V6(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function uW(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(c,d,u)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let h=Math.max(d,e),p=Math.min(d+c.nodeSize,t),g=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(g)||(s&&s.to==h&&s.mark.eq(f[b])?s.to=p:i.push(s=new oo(h,p,f[b])));l&&l.to==h?l.to=p:o.push(l=new sa(h,p,r))}}),i.forEach(c=>n.step(c)),o.forEach(c=>n.step(c))}function fW(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let c=null;if(r instanceof gm){let d=s.marks,u;for(;u=r.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let d=Math.min(l+s.nodeSize,t);for(let u=0;u<c.length;u++){let f=c[u],h;for(let p=0;p<i.length;p++){let g=i[p];g.step==o-1&&f.eq(i[p].style)&&(h=g)}h?(h.to=d,h.step=o):i.push({style:f,from:Math.max(l,e),to:d,step:o})}}}),i.forEach(s=>n.step(new oo(s.from,s.to,s.style)))}function hW(n,e,t,r=t.contentMatch){let i=n.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),d=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Yt(s,d,le.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new oo(s,d,c.marks[f]));if(c.isText&&!t.spec.code){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new le(J.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Yt(s+f.index,s+f.index+f[0].length,p))}}s=d}if(!r.validEnd){let l=r.fillBefore(J.empty,!0);n.replace(s,s,new le(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function pW(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function z2(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(o,s,t))return r;if(r==0||i.type.spec.isolating||!pW(i,o,s))break}return null}function mW(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),c=s,d=l,u=J.empty,f=0;for(let g=o,b=!1;g>t;g--)b||r.index(g)>0?(b=!0,u=J.from(r.node(g).copy(u)),f++):c--;let h=J.empty,p=0;for(let g=o,b=!1;g>t;g--)b||i.after(g+1)<i.end(g)?(b=!0,h=J.from(i.node(g).copy(h)),p++):d++;n.step(new Qt(c,d,s,l,new le(u.append(h),f,p),u.size-f,!0))}function $6(n,e,t=null,r=n){let i=gW(n,e),o=i&&yW(r,e);return o?i.map(sM).concat({type:e,attrs:t}).concat(o.map(sM)):null}function sM(n){return{type:n,attrs:null}}function gW(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function yW(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let c=(s.length?s[s.length-1]:e).contentMatch;for(let d=r;c&&d<i;d++)c=c.matchType(t.child(d).type);return!c||!c.validEnd?null:s}function bW(n,e,t){let r=J.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=J.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new Qt(i,o,i,o,new le(r,0,0),t.length,!0))}function wW(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&vW(n.doc,n.mapping.slice(o).map(l),r)){n.clearIncompatible(n.mapping.slice(o).map(l,1),r);let c=n.mapping.slice(o),d=c.map(l,1),u=c.map(l+s.nodeSize,1);return n.step(new Qt(d,u,d+1,u-1,new le(J.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function vW(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function CW(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Qt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new le(J.from(s),0,0),1,!0))}function Xo(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,u=t-2;d>o;d--,u--){let f=i.node(d),h=i.index(d);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),g=r&&r[u+1];g&&(p=p.replaceChild(0,g.type.create(g.attrs)));let b=r&&r[u]||f;if(!f.canReplace(h+1,f.childCount)||!b.type.validContent(p))return!1}let l=i.indexAfter(o),c=r&&r[0];return i.node(o).canReplaceWith(l,l,c?c.type:i.node(o+1).type)}function SW(n,e,t=1,r){let i=n.doc.resolve(e),o=J.empty,s=J.empty;for(let l=i.depth,c=i.depth-t,d=t-1;l>c;l--,d--){o=J.from(i.node(l).copy(o));let u=r&&r[d];s=J.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new Yt(e,e,new le(o.append(s),t,t),!0))}function la(n,e){let t=n.resolve(e),r=t.index();return aM(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function aM(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Sm(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let o,s,l=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):t>0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&aM(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function kW(n,e,t){let r=new Yt(e-t,e+t,le.empty,!0);n.step(r)}function MW(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function lM(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(l>0?1:0),d=r.node(s),u=!1;if(o==1)u=d.canReplace(c,c,i);else{let f=d.contentMatchAt(c).findWrapping(i.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function km(n,e,t=e,r=le.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return cM(i,o,r)?new Yt(e,t,r):new EW(i,o,r).fit()}function cM(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class EW{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=J.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=J.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let c=new le(o,s,l);return e>-1?new Qt(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new Yt(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=F6(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:d}=this.frontier[l],u,f=null;if(t==1&&(s?d.matchType(s.type)||(f=d.fillBefore(J.from(s),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=d.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&d.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=F6(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new le(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=F6(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new le(Zd(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new le(Zd(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let s=this.unplaced,l=r?r.content:s.content,c=s.openStart-e,d=0,u=[],{match:f,type:h}=this.frontier[t];if(i){for(let b=0;b<i.childCount;b++)u.push(i.child(b));f=f.matchFragment(i)}let p=l.size+e-(s.content.size-s.openEnd);for(;d<l.childCount;){let b=l.child(d),y=f.matchType(b.type);if(!y)break;d++,(d>1||c==0||b.content.size)&&(f=y,u.push(dM(b.mark(h.allowedMarks(b.marks)),d==1?c:0,d==l.childCount?p:-1)))}let g=d==l.childCount;g||(p=-1),this.placed=Wd(this.placed,t,J.from(u)),this.frontier[t].match=f,g&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<p;b++){let w=y.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),y=w.content}this.unplaced=g?e==0?le.empty:new le(Zd(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new le(Zd(s.content,e,d),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!j6(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=j6(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],u=j6(e,l,d,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Wd(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Wd(this.placed,this.depth,J.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(J.empty,!0);t.childCount&&(this.placed=Wd(this.placed,this.frontier.length,t))}}function Zd(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Zd(n.firstChild.content,e-1,t)))}function Wd(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Wd(n.lastChild.content,e-1,t)))}function F6(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function dM(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,dM(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(J.empty,!0)))),n.copy(r)}function j6(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!AW(t,o.content,s)?l:null}function AW(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function TW(n){return n.spec.defining||n.spec.definingForContent}function IW(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(cM(i,o,r))return n.step(new Yt(e,t,r));let s=fM(i,n.doc.resolve(t));s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let g=i.node(h).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;s.indexOf(h)>-1?l=h:i.before(h)==p&&s.splice(1,0,-h)}let c=s.indexOf(l),d=[],u=r.openStart;for(let h=r.content,p=0;;p++){let g=h.firstChild;if(d.push(g),p==r.openStart)break;h=g.content}for(let h=u-1;h>=0;h--){let p=d[h],g=TW(p.type);if(g&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(g||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+u+1)%(r.openStart+1),g=d[p];if(g)for(let b=0;b<s.length;b++){let y=s[(b+c)%s.length],w=!0;y<0&&(w=!1,y=-y);let v=i.node(y-1),S=i.index(y-1);if(v.canReplaceWith(S,S,g.type,g.marks))return n.replace(i.before(y),w?o.after(y):t,new le(uM(r.content,0,r.openStart,p),p,r.openEnd))}}let f=n.steps.length;for(let h=s.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>f));h--){let p=s[h];p<0||(e=i.before(p),t=o.after(p))}}function uM(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(uM(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(J.empty,!0))}return n}function xW(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=MW(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new le(J.from(r),0,0))}function OW(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=fM(r,i);for(let s=0;s<o.length;s++){let l=o[s],c=s==o.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s)return n.delete(r.before(s),t);n.delete(e,t)}function fM(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class H2 extends On{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ft.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Ft.fromReplace(e,this.pos,this.pos+1,new le(J.from(i),0,t.isLeaf?0:1))}getMap(){return xr.empty}invert(e){return new H2(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new H2(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new H2(t.pos,t.attr,t.value)}}On.jsonID("attr",H2);class Gd extends On{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Ft.ok(r)}getMap(){return xr.empty}invert(e){return new Gd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Gd(t.attr,t.value)}}On.jsonID("docAttr",Gd);let U2=class extends Error{};U2=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},U2.prototype=Object.create(Error.prototype),U2.prototype.constructor=U2,U2.prototype.name="TransformError";class hM{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new F2}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new U2(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=le.empty){let i=km(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new le(J.from(r),0,0))}delete(e,t){return this.replace(e,t,le.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return IW(this,e,t,r),this}replaceRangeWith(e,t,r){return xW(this,e,t,r),this}deleteRange(e,t){return OW(this,e,t),this}lift(e,t){return mW(this,e,t),this}join(e,t=1){return kW(this,e,t),this}wrap(e,t){return bW(this,e,t),this}setBlockType(e,t=e,r,i=null){return wW(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return CW(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new H2(e,t,r)),this}setDocAttribute(e,t){return this.step(new Gd(e,t)),this}addNodeMark(e,t){return this.step(new aa(e,t)),this}removeNodeMark(e,t){if(!(t instanceof rt)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new j2(e,t)),this}split(e,t=1,r){return SW(this,e,t,r),this}addMark(e,t,r){return uW(this,e,t,r),this}removeMark(e,t,r){return fW(this,e,t,r),this}clearIncompatible(e,t,r){return hW(this,e,t,r),this}}const z6=Object.create(null);class Ne{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new DW(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=le.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:c,$to:d}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(c.pos),u.map(d.pos),l?le.empty:t),l==0&&gM(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],c=e.mapping.slice(r),d=c.map(s.pos),u=c.map(l.pos);o?e.deleteRange(d,u):(e.replaceRangeWith(d,u,t),gM(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new Ae(e):Z2(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Z2(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Z2(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ti(e.node(0))}static atStart(e){return Z2(e,e,0,0,1)||new ti(e)}static atEnd(e){return Z2(e,e,e.content.size,e.childCount,-1)||new ti(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=z6[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in z6)throw new RangeError("Duplicate use of selection JSON ID "+e);return z6[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Ae.between(this.$anchor,this.$head).getBookmark()}}Ne.prototype.visible=!0;class DW{constructor(e,t){this.$from=e,this.$to=t}}let pM=!1;function mM(n){!pM&&!n.parent.inlineContent&&(pM=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Ae extends Ne{constructor(e,t=e){mM(e),mM(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Ne.near(r);let i=e.resolve(t.map(this.anchor));return new Ae(i.parent.inlineContent?i:r,r)}replace(e,t=le.empty){if(super.replace(e,t),t==le.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ae&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Mm(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ae(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=Ne.findFrom(t,r,!0)||Ne.findFrom(t,-r,!0);if(o)t=o.$head;else return Ne.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(Ne.findFrom(e,-r,!0)||Ne.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new Ae(e,t)}}Ne.jsonID("text",Ae);class Mm{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Mm(e.map(this.anchor),e.map(this.head))}resolve(e){return Ae.between(e.resolve(this.anchor),e.resolve(this.head))}}class be extends Ne{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return r?Ne.near(o):new be(o)}content(){return new le(J.from(this.node),0,0)}eq(e){return e instanceof be&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new H6(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new be(e.resolve(t.anchor))}static create(e,t){return new be(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}be.prototype.visible=!1,Ne.jsonID("node",be);class H6{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Mm(r,r):new H6(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&be.isSelectable(r)?new be(t):Ne.near(t)}}class ti extends Ne{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=le.empty){if(t==le.empty){e.delete(0,e.doc.content.size);let r=Ne.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ti(e)}map(e){return new ti(e)}eq(e){return e instanceof ti}getBookmark(){return NW}}Ne.jsonID("all",ti);const NW={map(){return this},resolve(n){return new ti(n)}};function Z2(n,e,t,r,i,o=!1){if(e.inlineContent)return Ae.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&be.isSelectable(l))return be.create(n,t-(i<0?l.nodeSize:0))}else{let c=Z2(n,l,t+i,i<0?l.childCount:0,i,o);if(c)return c}t+=l.nodeSize*i}return null}function gM(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Yt||i instanceof Qt))return;let o=n.mapping.maps[r],s;o.forEach((l,c,d,u)=>{s==null&&(s=u)}),n.setSelection(Ne.near(n.doc.resolve(s),t))}const yM=1,bM=2,wM=4;class PW extends hM{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|yM)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&yM)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bM,this}ensureMarks(e){return rt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&bM)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||rt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(Ne.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wM,this}get scrolledIntoView(){return(this.updated&wM)>0}}function vM(n,e){return!e||!n?n:n.bind(e)}class qd{constructor(e,t,r){this.name=e,this.init=vM(t.init,r),this.apply=vM(t.apply,r)}}const LW=[new qd("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new qd("selection",{init(n,e){return n.selection||Ne.atStart(e.doc)},apply(n){return n.selection}}),new qd("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new qd("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class U6{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LW.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new qd(r.key,r.spec.state,r))})}}class W2{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let c=i?i[s].n:0,d=i?i[s].state:this,u=c<t.length&&l.spec.appendTransaction.call(l,c?t.slice(c):t,d,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new W2(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new PW(this)}static create(e){let t=new U6(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new W2(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new U6(this.schema,e.plugins),r=t.fields,i=new W2(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new U6(e.schema,e.plugins),o=new W2(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=F0.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=Ne.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],d=c.spec.state;if(c.key==s.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=d.fromJSON.call(c,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function CM(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=CM(i,e,{})),t[r]=i}return t}class Xt{constructor(e){this.spec=e,this.props={},e.props&&CM(e.props,this,this.props),this.key=e.key?e.key.key:SM("plugin")}getState(e){return e[this.key]}}const Z6=Object.create(null);function SM(n){return n in Z6?n+"$"+ ++Z6[n]:(Z6[n]=0,n+"$")}class mr{constructor(e="key"){this.key=SM(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Kd=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let kM=null;const Jo=function(n,e,t){let r=kM||(kM=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},z0=function(n,e,t,r){return t&&(MM(n,e,t,r,-1)||MM(n,e,t,r,1))},BW=/^(img|br|input|textarea|hr)$/i;function MM(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:so(n))){let o=n.parentNode;if(!o||o.nodeType!=1||W6(n)||BW.test(n.nodeName)||n.contentEditable=="false")return!1;e=Zn(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?so(n):0}else return!1}}function so(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function _W(n,e,t){for(let r=e==0,i=e==so(n);r||i;){if(n==t)return!0;let o=Zn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==so(n)}}function W6(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Em=function(n){return n.focusNode&&z0(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function H0(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function RW(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function VW(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:r.startOffset}}}const ao=typeof navigator<"u"?navigator:null,EM=typeof document<"u"?document:null,ca=ao&&ao.userAgent||"",G6=/Edge\/(\d+)/.exec(ca),AM=/MSIE \d/.exec(ca),q6=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ca),gr=!!(AM||q6||G6),da=AM?document.documentMode:q6?+q6[1]:G6?+G6[1]:0,Ni=!gr&&/gecko\/(\d+)/i.test(ca);Ni&&+(/Firefox\/(\d+)/.exec(ca)||[0,0])[1];const K6=!gr&&/Chrome\/(\d+)/.exec(ca),Dn=!!K6,$W=K6?+K6[1]:0,Wn=!gr&&!!ao&&/Apple Computer/.test(ao.vendor),G2=Wn&&(/Mobile\/\w+/.test(ca)||!!ao&&ao.maxTouchPoints>2),ni=G2||(ao?/Mac/.test(ao.platform):!1),FW=ao?/Win/.test(ao.platform):!1,Pi=/Android \d/.test(ca),Yd=!!EM&&"webkitFontSmoothing"in EM.documentElement.style,jW=Yd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zW(n){return{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function es(n,e){return typeof n=="number"?n:n[e]}function HW(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function TM(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=Kd(s)){if(s.nodeType!=1)continue;let l=s,c=l==o.body,d=c?zW(o):HW(l),u=0,f=0;if(e.top<d.top+es(r,"top")?f=-(d.top-e.top+es(i,"top")):e.bottom>d.bottom-es(r,"bottom")&&(f=e.bottom-e.top>d.bottom-d.top?e.top+es(i,"top")-d.top:e.bottom-d.bottom+es(i,"bottom")),e.left<d.left+es(r,"left")?u=-(d.left-e.left+es(i,"left")):e.right>d.right-es(r,"right")&&(u=e.right-d.right+es(i,"right")),u||f)if(c)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,b=l.scrollTop-p;e={left:e.left-g,top:e.top-b,right:e.right-g,bottom:e.bottom-b}}if(c||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function UW(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(o,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=t-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:IM(n.dom)}}function IM(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Kd(r));return e}function ZW({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;xM(t,r==0?0:r-e)}function xM(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let q2=null;function WW(n){if(n.setActive)return n.setActive();if(q2)return n.focus(q2);let e=IM(n);n.focus(q2==null?{get preventScroll(){return q2={preventScroll:!0},!0}}:void 0),q2||(q2=!1,xM(e,0))}function OM(n,e){let t,r=2e8,i,o=0,s=e.top,l=e.top,c,d;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Jo(u).getClientRects();else continue;for(let p=0;p<h.length;p++){let g=h[p];if(g.top<=s&&g.bottom>=l){s=Math.max(g.bottom,s),l=Math.min(g.top,l);let b=g.left>e.left?g.left-e.left:g.right<e.left?e.left-g.right:0;if(b<r){t=u,r=b,i=b&&t.nodeType==3?{left:g.right<e.left?g.right:g.left,top:e.top}:e,u.nodeType==1&&b&&(o=f+(e.left>=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!c&&g.left<=e.left&&g.right>=e.left&&(c=u,d={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!t&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(o=f+1)}}return!t&&c&&(t=c,i=d,r=0),t&&t.nodeType==3?GW(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:OM(t,i)}function GW(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let o=ua(r,1);if(o.top!=o.bottom&&Y6(e,o))return{node:n,offset:i+(e.left>=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Y6(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function qW(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function KW(n,e,t){let{node:r,offset:i}=OM(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function YW(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let c=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,c.left>r.left||c.top>r.top?i=l.posBefore:(c.right<r.left||c.bottom<r.top)&&(i=l.posAfter)),!l.contentDOM&&i<0&&!l.node.isText)return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter}o=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function DM(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let c=0;c<l.length;c++){let d=l[c];if(Y6(e,d))return DM(s,e,d)}}if((o=(o+1)%r)==i)break}return n}function QW(n,e){let t=n.dom.ownerDocument,r,i=0,o=VW(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let d=n.dom.getBoundingClientRect();if(!Y6(e,d)||(s=DM(n.dom,e,d),!s))return null}if(Wn)for(let d=s;r&&d;d=Kd(d))d.draggable&&(r=void 0);if(s=qW(s,e),r){if(Ni&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let d;Yd&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=YW(n,r,i,e))}l==null&&(l=KW(n,s,e));let c=n.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function NM(n){return n.top<n.bottom||n.left<n.right}function ua(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(NM(r))return r}return Array.prototype.find.call(t,NM)||n.getBoundingClientRect()}const XW=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function PM(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Yd||Ni;if(r.nodeType==3)if(s&&(XW.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let c=ua(Jo(r,i,i),t);if(Ni&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=ua(Jo(r,i-1,i-1),-1);if(d.top==c.top){let u=ua(Jo(r,i,i+1),-1);if(u.top!=c.top)return Qd(u,u.left<d.left)}}return c}else{let c=i,d=i,u=t<0?1:-1;return t<0&&!i?(d++,u=-1):t>=0&&i==r.nodeValue.length?(c--,u=1):t<0?c--:d++,Qd(ua(Jo(r,c,d),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==so(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Q6(c.getBoundingClientRect(),!1)}if(o==null&&i<so(r)){let c=r.childNodes[i];if(c.nodeType==1)return Q6(c.getBoundingClientRect(),!0)}return Q6(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==so(r))){let c=r.childNodes[i-1],d=c.nodeType==3?Jo(c,so(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return Qd(ua(d,1),!1)}if(o==null&&i<so(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?Jo(c,0,s?0:1):c.nodeType==1?c:null:null;if(d)return Qd(ua(d,-1),!0)}return Qd(ua(r.nodeType==3?Jo(r):r,-t),t>=0)}function Qd(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Q6(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function LM(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function JW(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return LM(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=PM(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Jo(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const eG=/[\u0590-\u08ac]/;function tG(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return!eG.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:LM(n,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:g,focusOffset:b}=n.domSelectionRange(),y=g&&!p.contains(g.nodeType==1?g:g.parentNode)||c==g&&d==b;try{l.collapse(u,f),c&&(c!=u||d!=f)&&l.extend&&l.extend(c,d)}catch{}return h!=null&&(l.caretBidiLevel=h),y})}let BM=null,_M=null,RM=!1;function nG(n,e,t){return BM==e&&_M==t?RM:(BM=e,_M=t,RM=t=="up"||t=="down"?JW(n,e,t):tG(n,e,t))}const ri=0,VM=1,U0=2,lo=3;class Xd{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ri,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Zn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof jM){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof $M&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?Zn(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?Zn(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let c=this.children[l],d=s+c.size;if(i==-1&&e<=d){let u=s+c.border;if(e>=u&&t<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let h=this.children[f-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=Zn(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(d>t||l==this.children.length-1)){t=d;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=Zn(f.dom);break}t+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],b=p+g.size;if(o>p&&s<b)return g.setSelection(e-p-g.border,t-p-g.border,r,i);p=b}let l=this.domFromPos(e,e?-1:1),c=t==e?l:this.domFromPos(t,t?-1:1),d=r.getSelection(),u=!1;if((Ni||Wn)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|