@quoreadmin/ui 0.28.15 → 0.28.16

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.
@@ -128,7 +128,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
128
128
  `),position:m,pageIndex:b-1,rect:u.slice(0),rotation:f,id:h,deleted:!1}}const s=super.deserialize(t,r,i);return A(s,hr,t.fontSize),A(s,ai,ue.makeHexColor(...t.color)),A(s,fr,I(l=Xe,ch,jv).call(l,t.value)),s.annotationElementId=t.id||null,A(s,Pd,o),s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const r=Xe._internalPadding*this.parentScale,i=this.getRect(r,r),o=He._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:g(this,ai)),s={annotationType:xe.FREETEXT,color:o,fontSize:g(this,hr),value:I(this,w5,qN).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?s:this.annotationElementId&&!I(this,v5,KN).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(${g(this,hr)}px * var(--scale-factor))`,i.color=g(this,ai),r.replaceChildren();for(const s of g(this,fr).split(`
129
129
  `)){const l=document.createElement("div");l.append(s?document.createTextNode(s):document.createElement("br")),r.append(l)}const o=Xe._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(o,o),popupContent:g(this,fr)}),r}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};ai=new WeakMap,fr=new WeakMap,lh=new WeakMap,h0=new WeakMap,hr=new WeakMap,Pd=new WeakMap,g5=new WeakSet,UN=function(t){const r=o=>{this.editorDiv.style.fontSize=`calc(${o}px * var(--scale-factor))`,this.translate(0,-(o-g(this,hr))*this.parentScale),A(this,hr,o),I(this,Ld,yy).call(this)},i=g(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:ye.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},y5=new WeakSet,ZN=function(t){const r=o=>{A(this,ai,this.editorDiv.style.color=o)},i=g(this,ai);this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},b5=new WeakSet,WN=function(){var r;const t=[];this.editorDiv.normalize();for(const i of this.editorDiv.childNodes)t.push(I(r=Xe,Bd,by).call(r,i));return t.join(`
130
130
  `)},Ld=new WeakSet,yy=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()},Bd=new WeakSet,by=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(vm,"")},_d=new WeakSet,wy=function(){if(this.editorDiv.replaceChildren(),g(this,fr))for(const t of g(this,fr).split(`
131
- `)){const r=document.createElement("div");r.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(r)}},w5=new WeakSet,qN=function(){return g(this,fr).replaceAll(" "," ")},ch=new WeakSet,jv=function(t){return t.replaceAll(" "," ")},v5=new WeakSet,KN=function(t){const{value:r,fontSize:i,color:o,pageIndex:s}=g(this,Pd);return this._hasBeenMoved||t.value!==r||t.fontSize!==i||t.color.some((l,c)=>l!==o[c])||t.pageIndex!==s},E(Xe,Bd),E(Xe,ch),be(Xe,"_freeTextDefaultContent",""),be(Xe,"_internalPadding",0),be(Xe,"_defaultColor",null),be(Xe,"_defaultFontSize",10),be(Xe,"_type","freetext"),be(Xe,"_editorType",xe.FREETEXT);let e6=Xe;class lM{constructor(e,t=0,r=0,i=!0){E(this,C5);E(this,Rd);E(this,k5);E(this,S5);E(this,uh);E(this,dh,void 0);E(this,ga,[]);E(this,li,[]);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:k}of e){const C=Math.floor((y-t)/d)*d,T=Math.ceil((y+v+t)/d)*d,S=Math.floor((w-t)/d)*d,M=Math.ceil((w+k+t)/d)*d,x=[C,S,M,!0],O=[T,S,M,!1];g(this,ga).push(x,O),o=Math.min(o,C),s=Math.max(s,T),l=Math.min(l,S),c=Math.max(c,M)}const u=s-o+2*r,f=c-l+2*r,h=o-r,p=l-r,m=g(this,ga).at(i?-1:-2),b=[m[0],m[2]];for(const y of g(this,ga)){const[w,v,k]=y;y[0]=(w-h)/u,y[1]=(v-p)/f,y[2]=(k-p)/f}A(this,dh,{x:h,y:p,width:u,height:f,lastPoint:b})}getOutlines(){g(this,ga).sort((t,r)=>t[0]-r[0]||t[1]-r[1]||t[2]-r[2]);const e=[];for(const t of g(this,ga))t[3]?(e.push(...I(this,uh,zv).call(this,t)),I(this,k5,YN).call(this,t)):(I(this,S5,QN).call(this,t),e.push(...I(this,uh,zv).call(this,t)));return I(this,C5,GN).call(this,e)}}dh=new WeakMap,ga=new WeakMap,li=new WeakMap,C5=new WeakSet,GN=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 m;if(r.has(u))m=u;else{if(!r.has(f))break;m=f}r.delete(m),[l,c,d,u,f]=m,h!==l&&(o.push(h,p,l,p===c?c:d),h=l),p=p===c?d:c}o.push(h,p)}return new bW(i,g(this,dh))},Rd=new WeakSet,vy=function(e){const t=g(this,li);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},k5=new WeakSet,YN=function([,e,t]){const r=I(this,Rd,vy).call(this,e);g(this,li).splice(r,0,[e,t])},S5=new WeakSet,QN=function([,e,t]){const r=I(this,Rd,vy).call(this,e);for(let i=r;i<g(this,li).length;i++){const[o,s]=g(this,li)[i];if(o!==e)break;if(o===e&&s===t){g(this,li).splice(i,1);return}}for(let i=r-1;i>=0;i--){const[o,s]=g(this,li)[i];if(o!==e)break;if(o===e&&s===t){g(this,li).splice(i,1);return}}},uh=new WeakSet,zv=function(e){const[t,r,i]=e,o=[[t,r,i]],s=I(this,Rd,vy).call(this,i);for(let l=0;l<s;l++){const[c,d]=g(this,li)[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 cM{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(e,t){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof t6}}class bW extends cM{constructor(t,r){super();E(this,fh,void 0);E(this,$d,void 0);A(this,$d,t),A(this,fh,r)}toSVGPath(){const t=[];for(const r of g(this,$d)){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 g(this,$d)){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 g(this,fh)}}fh=new WeakMap,$d=new WeakMap;const Ho=class Ho{constructor({x:e,y:t},r,i,o,s,l=0){E(this,gh);E(this,Ki,void 0);E(this,zo,[]);E(this,Vd,void 0);E(this,Fd,void 0);E(this,Gi,[]);E(this,Oe,new Float64Array(18));E(this,p0,void 0);E(this,m0,void 0);E(this,hh,void 0);E(this,ph,void 0);E(this,jd,void 0);E(this,zd,void 0);E(this,ya,[]);A(this,Ki,r),A(this,zd,o*i),A(this,Fd,s),g(this,Oe).set([NaN,NaN,NaN,NaN,e,t],6),A(this,Vd,l),A(this,ph,g(Ho,mh)*i),A(this,hh,g(Ho,M5)*i),A(this,jd,i),g(this,ya).push(e,t)}get free(){return!0}isEmpty(){return isNaN(g(this,Oe)[8])}add({x:e,y:t}){var M;A(this,p0,e),A(this,m0,t);const[r,i,o,s]=g(this,Ki);let[l,c,d,u]=g(this,Oe).subarray(8,12);const f=e-d,h=t-u,p=Math.hypot(f,h);if(p<g(this,hh))return!1;const m=p-g(this,ph),b=m/p,y=b*f,w=b*h;let v=l,k=c;l=d,c=u,d+=y,u+=w,(M=g(this,ya))==null||M.push(e,t);const C=y/m,T=-w/m*g(this,zd),S=C*g(this,zd);return g(this,Oe).set(g(this,Oe).subarray(2,8),0),g(this,Oe).set([d+T,u+S],4),g(this,Oe).set(g(this,Oe).subarray(14,18),12),g(this,Oe).set([d-T,u-S],16),isNaN(g(this,Oe)[6])?(g(this,Gi).length===0&&(g(this,Oe).set([l+T,c+S],2),g(this,Gi).push(NaN,NaN,NaN,NaN,(l+T-r)/o,(c+S-i)/s),g(this,Oe).set([l-T,c-S],14),g(this,zo).push(NaN,NaN,NaN,NaN,(l-T-r)/o,(c-S-i)/s)),g(this,Oe).set([v,k,l,c,d,u],6),!this.isEmpty()):(g(this,Oe).set([v,k,l,c,d,u],6),Math.abs(Math.atan2(k-c,v-l)-Math.atan2(w,y))<Math.PI/2?([l,c,d,u]=g(this,Oe).subarray(2,6),g(this,Gi).push(NaN,NaN,NaN,NaN,((l+d)/2-r)/o,((c+u)/2-i)/s),[l,c,v,k]=g(this,Oe).subarray(14,18),g(this,zo).push(NaN,NaN,NaN,NaN,((v+l)/2-r)/o,((k+c)/2-i)/s),!0):([v,k,l,c,d,u]=g(this,Oe).subarray(0,6),g(this,Gi).push(((v+5*l)/6-r)/o,((k+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,k]=g(this,Oe).subarray(12,18),g(this,zo).push(((v+5*l)/6-r)/o,((k+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=g(this,Gi),t=g(this,zo),r=g(this,Oe).subarray(4,6),i=g(this,Oe).subarray(16,18),[o,s,l,c]=g(this,Ki),[d,u,f,h]=I(this,gh,Hv).call(this);if(isNaN(g(this,Oe)[6])&&!this.isEmpty())return`M${(g(this,Oe)[2]-o)/l} ${(g(this,Oe)[3]-s)/c} L${(g(this,Oe)[4]-o)/l} ${(g(this,Oe)[5]-s)/c} L${d} ${u} L${f} ${h} L${(g(this,Oe)[16]-o)/l} ${(g(this,Oe)[17]-s)/c} L${(g(this,Oe)[14]-o)/l} ${(g(this,Oe)[15]-s)/c} Z`;const p=[];p.push(`M${e[4]} ${e[5]}`);for(let m=6;m<e.length;m+=6)isNaN(e[m])?p.push(`L${e[m+4]} ${e[m+5]}`):p.push(`C${e[m]} ${e[m+1]} ${e[m+2]} ${e[m+3]} ${e[m+4]} ${e[m+5]}`);p.push(`L${(r[0]-o)/l} ${(r[1]-s)/c} L${d} ${u} L${f} ${h} L${(i[0]-o)/l} ${(i[1]-s)/c}`);for(let m=t.length-6;m>=6;m-=6)isNaN(t[m])?p.push(`L${t[m+4]} ${t[m+5]}`):p.push(`C${t[m]} ${t[m+1]} ${t[m+2]} ${t[m+3]} ${t[m+4]} ${t[m+5]}`);return p.push(`L${t[4]} ${t[5]} Z`),p.join(" ")}getOutlines(){var w;const e=g(this,Gi),t=g(this,zo),r=g(this,Oe),i=r.subarray(4,6),o=r.subarray(16,18),[s,l,c,d]=g(this,Ki),u=new Float64Array((((w=g(this,ya))==null?void 0:w.length)??0)+2);for(let v=0,k=u.length-2;v<k;v+=2)u[v]=(g(this,ya)[v]-s)/c,u[v+1]=(g(this,ya)[v+1]-l)/d;u[u.length-2]=(g(this,p0)-s)/c,u[u.length-1]=(g(this,m0)-l)/d;const[f,h,p,m]=I(this,gh,Hv).call(this);if(isNaN(r[6])&&!this.isEmpty()){const v=new Float64Array(36);return v.set([NaN,NaN,NaN,NaN,(r[2]-s)/c,(r[3]-l)/d,NaN,NaN,NaN,NaN,(r[4]-s)/c,(r[5]-l)/d,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(r[16]-s)/c,(r[17]-l)/d,NaN,NaN,NaN,NaN,(r[14]-s)/c,(r[15]-l)/d],0),new t6(v,u,g(this,Ki),g(this,jd),g(this,Vd),g(this,Fd))}const b=new Float64Array(g(this,Gi).length+24+g(this,zo).length);let y=e.length;for(let v=0;v<y;v+=2)isNaN(e[v])?b[v]=b[v+1]=NaN:(b[v]=e[v],b[v+1]=e[v+1]);b.set([NaN,NaN,NaN,NaN,(i[0]-s)/c,(i[1]-l)/d,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(o[0]-s)/c,(o[1]-l)/d],y),y+=24;for(let v=t.length-6;v>=6;v-=6)for(let k=0;k<6;k+=2)isNaN(t[v+k])?(b[y]=b[y+1]=NaN,y+=2):(b[y]=t[v+k],b[y+1]=t[v+k+1],y+=2);return b.set([NaN,NaN,NaN,NaN,t[4],t[5]],y),new t6(b,u,g(this,Ki),g(this,jd),g(this,Vd),g(this,Fd))}};Ki=new WeakMap,zo=new WeakMap,Vd=new WeakMap,Fd=new WeakMap,Gi=new WeakMap,Oe=new WeakMap,p0=new WeakMap,m0=new WeakMap,hh=new WeakMap,ph=new WeakMap,jd=new WeakMap,zd=new WeakMap,ya=new WeakMap,mh=new WeakMap,E5=new WeakMap,M5=new WeakMap,gh=new WeakSet,Hv=function(){const e=g(this,Oe).subarray(4,6),t=g(this,Oe).subarray(16,18),[r,i,o,s]=g(this,Ki);return[(g(this,p0)+(e[0]-t[0])/2-r)/o,(g(this,m0)+(e[1]-t[1])/2-i)/s,(g(this,p0)+(t[0]-e[0])/2-r)/o,(g(this,m0)+(t[1]-e[1])/2-i)/s]},E(Ho,mh,8),E(Ho,E5,2),E(Ho,M5,g(Ho,mh)+g(Ho,E5));let Cm=Ho;class t6 extends cM{constructor(t,r,i,o,s,l){super();E(this,y0);E(this,b0);E(this,A5);E(this,Hd,void 0);E(this,g0,null);E(this,Uo,void 0);E(this,yh,void 0);E(this,pr,void 0);E(this,bh,void 0);E(this,vt,void 0);A(this,vt,t),A(this,pr,r),A(this,Hd,i),A(this,bh,o),A(this,Uo,s),A(this,yh,l),I(this,A5,XN).call(this,l);const{x:c,y:d,width:u,height:f}=g(this,g0);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${g(this,vt)[4]} ${g(this,vt)[5]}`];for(let r=6,i=g(this,vt).length;r<i;r+=6)isNaN(g(this,vt)[r])?t.push(`L${g(this,vt)[r+4]} ${g(this,vt)[r+5]}`):t.push(`C${g(this,vt)[r]} ${g(this,vt)[r+1]} ${g(this,vt)[r+2]} ${g(this,vt)[r+3]} ${g(this,vt)[r+4]} ${g(this,vt)[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=I(this,y0,ip).call(this,g(this,vt),t,o,l,-c),u=I(this,y0,ip).call(this,g(this,pr),t,o,l,-c);break;case 90:d=I(this,b0,op).call(this,g(this,vt),t,r,l,c),u=I(this,b0,op).call(this,g(this,pr),t,r,l,c);break;case 180:d=I(this,y0,ip).call(this,g(this,vt),i,r,-l,c),u=I(this,y0,ip).call(this,g(this,pr),i,r,-l,c);break;case 270:d=I(this,b0,op).call(this,g(this,vt),i,o,-l,-c),u=I(this,b0,op).call(this,g(this,pr),i,o,-l,-c)}return{outline:Array.from(d),points:[Array.from(u)]}}get box(){return g(this,g0)}getNewOutline(t,r){const{x:i,y:o,width:s,height:l}=g(this,g0),[c,d,u,f]=g(this,Hd),h=s*u,p=l*f,m=i*u+c,b=o*f+d,y=new Cm({x:g(this,pr)[0]*h+m,y:g(this,pr)[1]*p+b},g(this,Hd),g(this,bh),t,g(this,yh),r??g(this,Uo));for(let w=2;w<g(this,pr).length;w+=2)y.add({x:g(this,pr)[w]*h+m,y:g(this,pr)[w+1]*p+b});return y.getOutlines()}}Hd=new WeakMap,g0=new WeakMap,Uo=new WeakMap,yh=new WeakMap,pr=new WeakMap,bh=new WeakMap,vt=new WeakMap,y0=new WeakSet,ip=function(t,r,i,o,s){const l=new Float64Array(t.length);for(let c=0,d=t.length;c<d;c+=2)l[c]=r+t[c]*o,l[c+1]=i+t[c+1]*s;return l},b0=new WeakSet,op=function(t,r,i,o,s){const l=new Float64Array(t.length);for(let c=0,d=t.length;c<d;c+=2)l[c]=r+t[c+1]*o,l[c+1]=i+t[c]*s;return l},A5=new WeakSet,XN=function(t){const r=g(this,vt);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 w=6,v=r.length;w<v;w+=6){if(isNaN(r[w]))s=Math.min(s,r[w+4]),l=Math.min(l,r[w+5]),c=Math.max(c,r[w+4]),d=Math.max(d,r[w+5]),f<r[w+5]?(u=r[w+4],f=r[w+5]):f===r[w+5]&&(u=h(u,r[w+4]));else{const k=ue.bezierBoundingBox(i,o,...r.slice(w,w+6));s=Math.min(s,k[0]),l=Math.min(l,k[1]),c=Math.max(c,k[2]),d=Math.max(d,k[3]),f<k[3]?(u=k[2],f=k[3]):f===k[3]&&(u=h(u,k[2]))}i=r[w+4],o=r[w+5]}const p=s-g(this,Uo),m=l-g(this,Uo),b=c-s+2*g(this,Uo),y=d-l+2*g(this,Uo);A(this,g0,{x:p,y:m,width:b,height:y,lastPoint:[u,f]})};const Wo=class Wo{constructor({editor:e=null,uiManager:t=null}){E(this,Eh);E(this,Mh);E(this,T5);E(this,Zo);E(this,I5);E(this,Yi);E(this,wh,I(this,T5,JN).bind(this));E(this,vh,I(this,I5,eP).bind(this));E(this,ci,null);E(this,w0,null);E(this,Ud,void 0);E(this,Dt,null);E(this,Ch,!1);E(this,Zd,!1);E(this,kh,null);E(this,Sh,void 0);E(this,di,null);E(this,Wd,void 0);var r;e?(A(this,Zd,!1),A(this,Wd,ye.HIGHLIGHT_COLOR),A(this,kh,e)):(A(this,Zd,!0),A(this,Wd,ye.HIGHLIGHT_DEFAULT_COLOR)),A(this,di,(e==null?void 0:e._uiManager)||t),A(this,Sh,g(this,di)._eventBus),A(this,Ud,(e==null?void 0:e.color)||((r=g(this,di))==null?void 0:r.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return Ne(this,"_keyboardManager",new p2([[["Escape","mac+Escape"],Wo.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Wo.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Wo.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Wo.prototype._moveToPrevious],[["Home","mac+Home"],Wo.prototype._moveToBeginning],[["End","mac+End"],Wo.prototype._moveToEnd]]))}renderButton(){const e=A(this,ci,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=g(this,di)._signal;e.addEventListener("click",I(this,Zo,$0).bind(this),{signal:t}),e.addEventListener("keydown",g(this,wh),{signal:t});const r=A(this,w0,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=g(this,Ud),e.append(r),e}renderMainDropdown(){const e=A(this,Dt,I(this,Eh,Uv).call(this));return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}_colorSelectFromKeyboard(e){if(e.target===g(this,ci)){I(this,Zo,$0).call(this,e);return}const t=e.target.getAttribute("data-color");t&&I(this,Mh,Zv).call(this,t,e)}_moveToNext(e){var t,r;g(this,Yi,Da)?e.target!==g(this,ci)?(t=e.target.nextSibling)==null||t.focus():(r=g(this,Dt).firstChild)==null||r.focus():I(this,Zo,$0).call(this,e)}_moveToPrevious(e){var t,r;e.target!==((t=g(this,Dt))==null?void 0:t.firstChild)&&e.target!==g(this,ci)?(g(this,Yi,Da)||I(this,Zo,$0).call(this,e),(r=e.target.previousSibling)==null||r.focus()):g(this,Yi,Da)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){var t;g(this,Yi,Da)?(t=g(this,Dt).firstChild)==null||t.focus():I(this,Zo,$0).call(this,e)}_moveToEnd(e){var t;g(this,Yi,Da)?(t=g(this,Dt).lastChild)==null||t.focus():I(this,Zo,$0).call(this,e)}hideDropdown(){var e;(e=g(this,Dt))==null||e.classList.add("hidden"),window.removeEventListener("pointerdown",g(this,vh))}_hideDropdownFromKeyboard(){var e;g(this,Zd)||(g(this,Yi,Da)?(this.hideDropdown(),g(this,ci).focus({preventScroll:!0,focusVisible:g(this,Ch)})):(e=g(this,kh))==null||e.unselect())}updateColor(e){if(g(this,w0)&&(g(this,w0).style.backgroundColor=e),!g(this,Dt))return;const t=g(this,di).highlightColors.values();for(const r of g(this,Dt).children)r.setAttribute("aria-selected",t.next().value===e)}destroy(){var e,t;(e=g(this,ci))==null||e.remove(),A(this,ci,null),A(this,w0,null),(t=g(this,Dt))==null||t.remove(),A(this,Dt,null)}};wh=new WeakMap,vh=new WeakMap,ci=new WeakMap,w0=new WeakMap,Ud=new WeakMap,Dt=new WeakMap,Ch=new WeakMap,Zd=new WeakMap,kh=new WeakMap,Sh=new WeakMap,di=new WeakMap,Wd=new WeakMap,Eh=new WeakSet,Uv=function(){const e=document.createElement("div"),t=g(this,di)._signal;e.addEventListener("contextmenu",kr,{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 g(this,di).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",`pdfjs-editor-colorpicker-${r}`);const s=document.createElement("span");o.append(s),s.className="swatch",s.style.backgroundColor=i,o.setAttribute("aria-selected",i===g(this,Ud)),o.addEventListener("click",I(this,Mh,Zv).bind(this,i),{signal:t}),e.append(o)}return e.addEventListener("keydown",g(this,wh),{signal:t}),e},Mh=new WeakSet,Zv=function(e,t){t.stopPropagation(),g(this,Sh).dispatch("switchannotationeditorparams",{source:this,type:g(this,Wd),value:e})},T5=new WeakSet,JN=function(e){Wo._keyboardManager.exec(this,e)},Zo=new WeakSet,$0=function(e){if(g(this,Yi,Da)){this.hideDropdown();return}if(A(this,Ch,e.detail===0),window.addEventListener("pointerdown",g(this,vh),{signal:g(this,di)._signal}),g(this,Dt)){g(this,Dt).classList.remove("hidden");return}const t=A(this,Dt,I(this,Eh,Uv).call(this));g(this,ci).append(t)},I5=new WeakSet,eP=function(e){var t;(t=g(this,Dt))!=null&&t.contains(e.target)||this.hideDropdown()},Yi=new WeakSet,Da=function(){return g(this,Dt)&&!g(this,Dt).classList.contains("hidden")};let km=Wo;const _e=class _e extends He{constructor(t){super({...t,name:"highlightEditor"});E(this,Oh);E(this,Dh);E(this,x5);E(this,O5);E(this,D5);E(this,Nh);E(this,S0);E(this,N5);E(this,Qd);E(this,E0);E(this,P5);E(this,L5);E(this,qd,null);E(this,Ah,0);E(this,ba,void 0);E(this,v0,null);E(this,Kd,null);E(this,$r,null);E(this,Th,null);E(this,Ih,0);E(this,C0,null);E(this,ui,null);E(this,On,null);E(this,mr,!1);E(this,Gd,null);E(this,k0,void 0);E(this,Nt,null);E(this,Yd,"");E(this,Qi,void 0);E(this,xh,"");this.color=t.color||_e._defaultColor,A(this,Qi,t.thickness||_e._defaultThickness),A(this,k0,t.opacity||_e._defaultOpacity),A(this,ba,t.boxes||null),A(this,xh,t.methodOfCreation||""),A(this,Yd,t.text||""),this._isDraggable=!1,t.highlightId>-1?(A(this,mr,!0),I(this,Dh,qv).call(this,t),I(this,S0,sp).call(this)):(A(this,qd,t.anchorNode),A(this,Ah,t.anchorOffset),A(this,Th,t.focusNode),A(this,Ih,t.focusOffset),I(this,Oh,Wv).call(this),I(this,S0,sp).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=_e.prototype;return Ne(this,"_keyboardManager",new p2([[["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:g(this,mr)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:g(this,Qi),methodOfCreation:g(this,xh)}}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;He.initialize(t,r),_e._defaultColor||(_e._defaultColor=((i=r.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,r){switch(t){case ye.HIGHLIGHT_DEFAULT_COLOR:_e._defaultColor=r;break;case ye.HIGHLIGHT_THICKNESS:_e._defaultThickness=r}}translateInPage(t,r){}get toolbarPosition(){return g(this,Gd)}updateParams(t,r){switch(t){case ye.HIGHLIGHT_COLOR:I(this,x5,tP).call(this,r);break;case ye.HIGHLIGHT_THICKNESS:I(this,O5,nP).call(this,r)}}static get defaultPropertiesToUpdate(){return[[ye.HIGHLIGHT_DEFAULT_COLOR,_e._defaultColor],[ye.HIGHLIGHT_THICKNESS,_e._defaultThickness]]}get propertiesToUpdate(){return[[ye.HIGHLIGHT_COLOR,this.color||_e._defaultColor],[ye.HIGHLIGHT_THICKNESS,g(this,Qi)||_e._defaultThickness],[ye.HIGHLIGHT_FREE,g(this,mr)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(A(this,Kd,new km({editor:this})),t.addColorPicker(g(this,Kd))),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,E0,ap).call(this))}getBaseTranslation(){return[0,0]}getRect(t,r){return super.getRect(t,r,I(this,E0,ap).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){I(this,Nh,Kv).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,S0,sp).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?I(this,Nh,Kv).call(this):t&&(I(this,S0,sp).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;g(this,mr)?(t=(t-this.rotation+360)%360,i=I(o=_e,wa,bu).call(o,g(this,ui).box,t)):i=I(s=_e,wa,bu).call(s,this,t),r.rotate(g(this,On),t),r.rotate(g(this,Nt),t),r.updateBox(g(this,On),i),r.updateBox(g(this,Nt),I(l=_e,wa,bu).call(l,g(this,$r).box,t))}render(){if(this.div)return this.div;const t=super.render();g(this,Yd)&&(t.setAttribute("aria-label",g(this,Yd)),t.setAttribute("role","mark")),g(this,mr)?t.classList.add("free"):this.div.addEventListener("keydown",I(this,N5,iP).bind(this),{signal:this._uiManager._signal});const r=A(this,C0,document.createElement("div"));t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",r.style.clipPath=g(this,v0);const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),hm(this,g(this,C0),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(g(this,Nt),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(g(this,Nt),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:I(this,Qd,Cy).call(this,!0);break;case 1:case 3:I(this,Qd,Cy).call(this,!1)}}select(){var t,r;super.select(),g(this,Nt)&&((t=this.parent)==null||t.drawLayer.removeClass(g(this,Nt),"hovered"),(r=this.parent)==null||r.drawLayer.addClass(g(this,Nt),"selected"))}unselect(){var t;super.unselect(),g(this,Nt)&&((t=this.parent)==null||t.drawLayer.removeClass(g(this,Nt),"selected"),g(this,mr)||I(this,Qd,Cy).call(this,!1))}get _mustFixPosition(){return!g(this,mr)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(g(this,On),t),this.parent.drawLayer.show(g(this,Nt),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=m=>{f.abort(),I(this,_5,lP).call(this,t,m)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",m=>{m.preventDefault(),m.stopPropagation()},{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",kr,{signal:h}),i.addEventListener("pointermove",I(this,B5,aP).bind(this,t),{signal:h}),this._freeHighlight=new Cm({x:o,y:s},[l,c,d,u],t.scale,this._defaultThickness/2,r,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static deserialize(t,r,i){var b;const o=super.deserialize(t,r,i),{rect:[s,l,c,d],color:u,quadPoints:f}=t;o.color=ue.makeHexColor(...u),A(o,k0,t.opacity);const[h,p]=o.pageDimensions;o.width=(c-s)/h,o.height=(d-l)/p;const m=A(o,ba,[]);for(let y=0;y<f.length;y+=8)m.push({x:(f[4]-c)/h,y:(d-(1-f[y+5]))/p,width:(f[y+2]-f[y])/h,height:(f[y+5]-f[y+1])/p});return I(b=o,Oh,Wv).call(b),o}serialize(t=!1){if(this.isEmpty()||t)return null;const r=this.getRect(0,0),i=He._colorManager.convert(this.color);return{annotationType:xe.HIGHLIGHT,color:i,opacity:g(this,k0),thickness:g(this,Qi),quadPoints:I(this,P5,oP).call(this),outlines:I(this,L5,sP).call(this,r),pageIndex:this.pageIndex,rect:r,rotation:I(this,E0,ap).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};qd=new WeakMap,Ah=new WeakMap,ba=new WeakMap,v0=new WeakMap,Kd=new WeakMap,$r=new WeakMap,Th=new WeakMap,Ih=new WeakMap,C0=new WeakMap,ui=new WeakMap,On=new WeakMap,mr=new WeakMap,Gd=new WeakMap,k0=new WeakMap,Nt=new WeakMap,Yd=new WeakMap,Qi=new WeakMap,xh=new WeakMap,Oh=new WeakSet,Wv=function(){const t=new lM(g(this,ba),.001);A(this,ui,t.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=g(this,ui).box;const r=new lM(g(this,ba),.0025,.001,this._uiManager.direction==="ltr");A(this,$r,r.getOutlines());const{lastPoint:i}=g(this,$r).box;A(this,Gd,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Dh=new WeakSet,qv=function({highlightOutlines:t,highlightId:r,clipPathId:i}){var u,f;if(A(this,ui,t),A(this,$r,t.getNewOutline(g(this,Qi)/2+1.5,.0025)),r>=0)A(this,On,r),A(this,v0,i),this.parent.drawLayer.finalizeLine(r,t),A(this,Nt,this.parent.drawLayer.highlightOutline(g(this,$r)));else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(g(this,On),t),this.parent.drawLayer.updateBox(g(this,On),I(u=_e,wa,bu).call(u,g(this,ui).box,(h-this.rotation+360)%360)),this.parent.drawLayer.updateLine(g(this,Nt),g(this,$r)),this.parent.drawLayer.updateBox(g(this,Nt),I(f=_e,wa,bu).call(f,g(this,$r).box,h))}const{x:o,y:s,width:l,height: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}=g(this,$r).box;A(this,Gd,[(d[0]-o)/l,(d[1]-s)/c])},x5=new WeakSet,tP=function(t){const r=o=>{var s,l;this.color=o,(s=this.parent)==null||s.drawLayer.changeColor(g(this,On),o),(l=g(this,Kd))==null||l.updateColor(o)},i=this.color;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},O5=new WeakSet,nP=function(t){const r=g(this,Qi),i=o=>{A(this,Qi,o),I(this,D5,rP).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:ye.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},D5=new WeakSet,rP=function(t){if(!g(this,mr))return;I(this,Dh,qv).call(this,{highlightOutlines:g(this,ui).getNewOutline(t/2)}),this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)},Nh=new WeakSet,Kv=function(){g(this,On)!==null&&this.parent&&(this.parent.drawLayer.remove(g(this,On)),A(this,On,null),this.parent.drawLayer.remove(g(this,Nt)),A(this,Nt,null))},S0=new WeakSet,sp=function(t=this.parent){g(this,On)===null&&({id:Xn(this,On)._,clipPathId:Xn(this,v0)._}=t.drawLayer.highlight(g(this,ui),this.color,g(this,k0)),A(this,Nt,t.drawLayer.highlightOutline(g(this,$r))),g(this,C0)&&(g(this,C0).style.clipPath=g(this,v0)))},wa=new WeakSet,bu=function({x:t,y:r,width:i,height:o},s){switch(s){case 90:return{x:1-r-o,y:t,width:o,height:i};case 180:return{x:1-t-i,y:1-r-o,width:i,height:o};case 270:return{x:r,y:1-t-i,width:o,height:i}}return{x:t,y:r,width:i,height:o}},N5=new WeakSet,iP=function(t){_e._keyboardManager.exec(this,t)},Qd=new WeakSet,Cy=function(t){if(!g(this,qd))return;const r=window.getSelection();t?r.setPosition(g(this,qd),g(this,Ah)):r.setPosition(g(this,Th),g(this,Ih))},E0=new WeakSet,ap=function(){return g(this,mr)?this.rotation:0},P5=new WeakSet,oP=function(){if(g(this,mr))return null;const[t,r]=this.pageDimensions,[i,o]=this.pageTranslation,s=g(this,ba),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,m=(1-u-h)*r+o;l[c]=l[c+4]=p,l[c+1]=l[c+3]=m,l[c+2]=l[c+6]=p+f*t,l[c+5]=l[c+7]=m+h*r,c+=8}return l},L5=new WeakSet,sP=function(t){return g(this,ui).serialize(t,I(this,E0,ap).call(this))},B5=new WeakSet,aP=function(t,r){this._freeHighlight.add(r)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},_5=new WeakSet,lP=function(t,r){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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=""},E(_e,wa),E(_e,B5),E(_e,_5),be(_e,"_defaultColor",null),be(_e,"_defaultOpacity",1),be(_e,"_defaultThickness",12),be(_e,"_l10nPromise"),be(_e,"_type","highlight"),be(_e,"_editorType",xe.HIGHLIGHT),be(_e,"_freeHighlightId",-1),be(_e,"_freeHighlight",null),be(_e,"_freeHighlightClipId","");let Sm=_e;const et=class et extends He{constructor(t){super({...t,name:"inkEditor"});E(this,R5);E(this,$5);E(this,V5);E(this,F5);E(this,Ph);E(this,j5);E(this,Lh);E(this,z5);E(this,H5);E(this,U5);E(this,Z5);E(this,W5);E(this,Go);E(this,Bh);E(this,_h);E(this,Rh);E(this,Jd);E(this,eu);E(this,Ca);E(this,$h);E(this,tu);E(this,G5);E(this,Fh);E(this,nu);E(this,N0);E(this,M0,0);E(this,A0,0);E(this,Xi,null);E(this,qo,new Path2D);E(this,Vr,!1);E(this,T0,null);E(this,I0,!1);E(this,x0,!1);E(this,Ko,null);E(this,Xd,null);E(this,O0,0);E(this,D0,0);E(this,va,null);this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,r){He.initialize(t,r)}static updateDefaultParams(t,r){switch(t){case ye.INK_THICKNESS:et._defaultThickness=r;break;case ye.INK_COLOR:et._defaultColor=r;break;case ye.INK_OPACITY:et._defaultOpacity=r/100}}updateParams(t,r){switch(t){case ye.INK_THICKNESS:I(this,R5,cP).call(this,r);break;case ye.INK_COLOR:I(this,$5,dP).call(this,r);break;case ye.INK_OPACITY:I(this,V5,uP).call(this,r)}}static get defaultPropertiesToUpdate(){return[[ye.INK_THICKNESS,et._defaultThickness],[ye.INK_COLOR,et._defaultColor||He._defaultLineColor],[ye.INK_OPACITY,Math.round(100*et._defaultOpacity)]]}get propertiesToUpdate(){return[[ye.INK_THICKNESS,this.thickness||et._defaultThickness],[ye.INK_COLOR,this.color||et._defaultColor||He._defaultLineColor],[ye.INK_OPACITY,Math.round(100*(this.opacity??et._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(I(this,Jd,ky).call(this),I(this,eu,Sy).call(this)),this.isAttachedToDOM||(this.parent.add(this),I(this,Ca,wu).call(this)),I(this,N0,lp).call(this)))}remove(){var t;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,g(this,Xi)&&(clearTimeout(g(this,Xi)),A(this,Xi,null)),(t=g(this,Ko))==null||t.disconnect(),A(this,Ko,null),super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,r]=this.parentDimensions,i=this.width*t,o=this.height*r;this.setDimensions(i,o)}enableEditMode(){!g(this,Vr)&&this.canvas!==null&&(super.enableEditMode(),this._isDraggable=!1,I(this,Bh,Qv).call(this))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),I(this,_h,Xv).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){g(this,Vr)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,Vr,!0),this.div.classList.add("disabled"),I(this,N0,lp).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button===0&&this.isInEditMode()&&!g(this,Vr)&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),I(this,j5,hP).call(this,t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),I(this,Lh,Yv).call(this,t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),I(this,Rh,Jv).call(this,t)}canvasPointerleave(t){I(this,Rh,Jv).call(this,t)}get isResizable(){return!this.isEmpty()&&g(this,Vr)}render(){if(this.div)return this.div;let t,r;this.width&&(t=this.x,r=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,o,s,l]=I(this,F5,fP).call(this);if(this.setAt(i,o,0,0),this.setDims(s,l),I(this,Jd,ky).call(this),this.width){const[c,d]=this.parentDimensions;this.setAspectRatio(this.width*c,this.height*d),this.setAt(t*c,r*d,this.width*c,this.height*d),A(this,x0,!0),I(this,Ca,wu).call(this),this.setDims(this.width*c,this.height*d),I(this,Go,V0).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return I(this,eu,Sy).call(this),this.div}setDimensions(t,r){const i=Math.round(t),o=Math.round(r);if(g(this,O0)===i&&g(this,D0)===o)return;A(this,O0,i),A(this,D0,o),this.canvas.style.visibility="hidden";const[s,l]=this.parentDimensions;this.width=t/s,this.height=r/l,this.fixAndSetPosition(),g(this,Vr)&&I(this,$h,e8).call(this,t,r),I(this,Ca,wu).call(this),I(this,Go,V0).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(t,r,i){var y,w,v;if(t instanceof sM)return null;const o=super.deserialize(t,r,i);o.thickness=t.thickness,o.color=ue.makeHexColor(...t.color),o.opacity=t.opacity;const[s,l]=o.pageDimensions,c=o.width*s,d=o.height*l,u=o.parentScale,f=t.thickness/2;A(o,Vr,!0),A(o,O0,Math.round(c)),A(o,D0,Math.round(d));const{paths:h,rect:p,rotation:m}=t;for(let{bezier:k}of h){k=I(y=et,K5,vP).call(y,k,p,m);const C=[];o.paths.push(C);let T=u*(k[0]-f),S=u*(k[1]-f);for(let x=2,O=k.length;x<O;x+=6){const P=u*(k[x]-f),N=u*(k[x+1]-f),_=u*(k[x+2]-f),V=u*(k[x+3]-f),H=u*(k[x+4]-f),L=u*(k[x+5]-f);C.push([[T,S],[P,N],[_,V],[H,L]]),T=H,S=L}const M=I(this,q5,wP).call(this,C);o.bezierPath2D.push(M)}const b=I(w=o,Fh,n8).call(w);return A(o,A0,Math.max(He.MIN_SIZE,b[2]-b[0])),A(o,M0,Math.max(He.MIN_SIZE,b[3]-b[1])),I(v=o,$h,e8).call(v,c,d),o}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),r=He._colorManager.convert(this.ctx.strokeStyle);return{annotationType:xe.INK,color:r,thickness:this.thickness,opacity:this.opacity,paths:I(this,G5,CP).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};M0=new WeakMap,A0=new WeakMap,Xi=new WeakMap,qo=new WeakMap,Vr=new WeakMap,T0=new WeakMap,I0=new WeakMap,x0=new WeakMap,Ko=new WeakMap,Xd=new WeakMap,O0=new WeakMap,D0=new WeakMap,va=new WeakMap,R5=new WeakSet,cP=function(t){const r=o=>{this.thickness=o,I(this,N0,lp).call(this)},i=this.thickness;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},$5=new WeakSet,dP=function(t){const r=o=>{this.color=o,I(this,Go,V0).call(this)},i=this.color;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},V5=new WeakSet,uP=function(t){const r=o=>{this.opacity=o,I(this,Go,V0).call(this)};t/=100;const i=this.opacity;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},F5=new WeakSet,fP=function(){const{parentRotation:t,parentDimensions:[r,i]}=this;switch(t){case 90:return[0,i,i,r];case 180:return[r,i,r,i];case 270:return[r,0,i,r];default:return[0,0,r,i]}},Ph=new WeakSet,Gv=function(){const{ctx:t,color:r,opacity:i,thickness:o,parentScale:s,scaleFactor:l}=this;t.lineWidth=o*s/l,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${r}${function(d){return Math.round(Math.min(255,Math.max(1,255*d))).toString(16).padStart(2,"0")}(i)}`},j5=new WeakSet,hP=function(t,r){this.canvas.addEventListener("contextmenu",kr,{signal:this._uiManager._signal}),I(this,_h,Xv).call(this),A(this,T0,new AbortController);const i=this._uiManager.combinedSignal(g(this,T0));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,g(this,x0)||(A(this,x0,!0),I(this,Ca,wu).call(this),this.thickness||(this.thickness=et._defaultThickness),this.color||(this.color=et._defaultColor||He._defaultLineColor),this.opacity??(this.opacity=et._defaultOpacity)),this.currentPath.push([t,r]),A(this,I0,!1),I(this,Ph,Gv).call(this),A(this,va,()=>{I(this,U5,gP).call(this),g(this,va)&&window.requestAnimationFrame(g(this,va))}),window.requestAnimationFrame(g(this,va))},Lh=new WeakSet,Yv=function(t,r){const[i,o]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&r===o)return;const s=this.currentPath;let l=g(this,qo);s.push([t,r]),A(this,I0,!0),s.length<=2?(l.moveTo(...s[0]),l.lineTo(t,r)):(s.length===3&&(A(this,qo,l=new Path2D),l.moveTo(...s[0])),I(this,Z5,yP).call(this,l,...s.at(-3),...s.at(-2),t,r))},z5=new WeakSet,pP=function(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);g(this,qo).lineTo(...t)},H5=new WeakSet,mP=function(t,r){A(this,va,null),t=Math.min(Math.max(t,0),this.canvas.width),r=Math.min(Math.max(r,0),this.canvas.height),I(this,Lh,Yv).call(this,t,r),I(this,z5,pP).call(this);let i;if(this.currentPath.length!==1)i=I(this,W5,bP).call(this);else{const l=[t,r];i=[[l,l.slice(),l.slice(),l]]}const o=g(this,qo),s=this.currentPath;this.currentPath=[],A(this,qo,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(s),this.paths.push(i),this.bezierPath2D.push(o),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(I(this,Jd,ky).call(this),I(this,eu,Sy).call(this)),I(this,N0,lp).call(this))},mustExec:!0})},U5=new WeakSet,gP=function(){if(!g(this,I0))return;A(this,I0,!1),Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),r=t.map(s=>s[0]),i=t.map(s=>s[1]),{ctx:o}=(Math.min(...r),Math.max(...r),Math.min(...i),Math.max(...i),this);o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height);for(const s of this.bezierPath2D)o.stroke(s);o.stroke(g(this,qo)),o.restore()},Z5=new WeakSet,yP=function(t,r,i,o,s,l,c){const d=(r+o)/2,u=(i+s)/2,f=(o+l)/2,h=(s+c)/2;t.bezierCurveTo(d+2*(o-d)/3,u+2*(s-u)/3,f+2*(o-f)/3,h+2*(s-h)/3,f,h)},W5=new WeakSet,bP=function(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const r=[];let i,[o,s]=t[0];for(i=1;i<t.length-2;i++){const[p,m]=t[i],[b,y]=t[i+1],w=(p+b)/2,v=(m+y)/2,k=[o+2*(p-o)/3,s+2*(m-s)/3],C=[w+2*(p-w)/3,v+2*(m-v)/3];r.push([[o,s],k,C,[w,v]]),[o,s]=[w,v]}const[l,c]=t[i],[d,u]=t[i+1],f=[o+2*(l-o)/3,s+2*(c-s)/3],h=[d+2*(l-d)/3,u+2*(c-u)/3];return r.push([[o,s],f,h,[d,u]]),r},Go=new WeakSet,V0=function(){if(this.isEmpty()){I(this,tu,Ey).call(this);return}I(this,Ph,Gv).call(this);const{canvas:t,ctx:r}=this;r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,t.width,t.height),I(this,tu,Ey).call(this);for(const i of this.bezierPath2D)r.stroke(i)},Bh=new WeakSet,Qv=function(){if(g(this,Xd))return;A(this,Xd,new AbortController);const t=this._uiManager.combinedSignal(g(this,Xd));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:t})},_h=new WeakSet,Xv=function(){var t;(t=this.pointerdownAC)==null||t.abort(),this.pointerdownAC=null},Rh=new WeakSet,Jv=function(t){var r;(r=g(this,T0))==null||r.abort(),A(this,T0,null),I(this,Bh,Qv).call(this),g(this,Xi)&&clearTimeout(g(this,Xi)),A(this,Xi,setTimeout(()=>{A(this,Xi,null),this.canvas.removeEventListener("contextmenu",kr)},10)),I(this,H5,mP).call(this,t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Jd=new WeakSet,ky=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},eu=new WeakSet,Sy=function(){A(this,Ko,new ResizeObserver(t=>{const r=t[0].contentRect;r.width&&r.height&&this.setDimensions(r.width,r.height)})),g(this,Ko).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=g(this,Ko))==null||t.disconnect(),A(this,Ko,null)},{once:!0})},Ca=new WeakSet,wu=function(){if(!g(this,x0))return;const[t,r]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*r),I(this,tu,Ey).call(this)},$h=new WeakSet,e8=function(t,r){const i=I(this,nu,My).call(this),o=(t-i)/g(this,A0),s=(r-i)/g(this,M0);this.scaleFactor=Math.min(o,s)},tu=new WeakSet,Ey=function(){const t=I(this,nu,My).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)},q5=new WeakSet,wP=function(t){const r=new Path2D;for(let i=0,o=t.length;i<o;i++){const[s,l,c,d]=t[i];i===0&&r.moveTo(...s),r.bezierCurveTo(l[0],l[1],c[0],c[1],d[0],d[1])}return r},Vh=new WeakSet,t8=function(t,r,i){const[o,s,l,c]=r;switch(i){case 0:for(let d=0,u=t.length;d<u;d+=2)t[d]+=o,t[d+1]=c-t[d+1];break;case 90:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=t[d+1]+o,t[d+1]=f+s}break;case 180:for(let d=0,u=t.length;d<u;d+=2)t[d]=l-t[d],t[d+1]+=s;break;case 270:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=l-t[d+1],t[d+1]=c-f}break;default:throw new Error("Invalid rotation")}return t},K5=new WeakSet,vP=function(t,r,i){const[o,s,l,c]=r;switch(i){case 0:for(let d=0,u=t.length;d<u;d+=2)t[d]-=o,t[d+1]=c-t[d+1];break;case 90:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=t[d+1]-s,t[d+1]=f-o}break;case 180:for(let d=0,u=t.length;d<u;d+=2)t[d]=l-t[d],t[d+1]-=s;break;case 270:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=c-t[d+1],t[d+1]=l-f}break;default:throw new Error("Invalid rotation")}return t},G5=new WeakSet,CP=function(t,r,i,o){var u,f;const s=[],l=this.thickness/2,c=t*r+l,d=t*i+l;for(const h of this.paths){const p=[],m=[];for(let b=0,y=h.length;b<y;b++){const[w,v,k,C]=h[b];if(w[0]===C[0]&&w[1]===C[1]&&y===1){const V=t*w[0]+c,H=t*w[1]+d;p.push(V,H),m.push(V,H);break}const T=t*w[0]+c,S=t*w[1]+d,M=t*v[0]+c,x=t*v[1]+d,O=t*k[0]+c,P=t*k[1]+d,N=t*C[0]+c,_=t*C[1]+d;b===0&&(p.push(T,S),m.push(T,S)),p.push(M,x,O,P,N,_),m.push(M,x),b===y-1&&m.push(N,_)}s.push({bezier:I(u=et,Vh,t8).call(u,p,o,this.rotation),points:I(f=et,Vh,t8).call(f,m,o,this.rotation)})}return s},Fh=new WeakSet,n8=function(){let t=1/0,r=-1/0,i=1/0,o=-1/0;for(const s of this.paths)for(const[l,c,d,u]of s){const f=ue.bezierBoundingBox(...l,...c,...d,...u);t=Math.min(t,f[0]),i=Math.min(i,f[1]),r=Math.max(r,f[2]),o=Math.max(o,f[3])}return[t,i,r,o]},nu=new WeakSet,My=function(){return g(this,Vr)?Math.ceil(this.thickness*this.parentScale):0},N0=new WeakSet,lp=function(t=!1){if(this.isEmpty())return;if(!g(this,Vr)){I(this,Go,V0).call(this);return}const r=I(this,Fh,n8).call(this),i=I(this,nu,My).call(this);A(this,A0,Math.max(He.MIN_SIZE,r[2]-r[0])),A(this,M0,Math.max(He.MIN_SIZE,r[3]-r[1]));const o=Math.ceil(i+g(this,A0)*this.scaleFactor),s=Math.ceil(i+g(this,M0)*this.scaleFactor),[l,c]=this.parentDimensions;this.width=o/l,this.height=s/c,this.setAspectRatio(o,s);const d=this.translationX,u=this.translationY;this.translationX=-r[0],this.translationY=-r[1],I(this,Ca,wu).call(this),I(this,Go,V0).call(this),A(this,O0,o),A(this,D0,s),this.setDims(o,s);const f=t?i/this.scaleFactor/2:0;this.translate(d-this.translationX-f,u-this.translationY-f)},E(et,q5),E(et,Vh),E(et,K5),be(et,"_defaultColor",null),be(et,"_defaultOpacity",1),be(et,"_defaultThickness",1),be(et,"_type","ink"),be(et,"_editorType",xe.INK);let n6=et;const Zh=class Zh extends He{constructor(t){super({...t,name:"stampEditor"});E(this,P0);E(this,L0);E(this,iu);E(this,zh);E(this,Y5);E(this,Hh);E(this,Uh);E(this,ou);E(this,Q5);E(this,Ct,null);E(this,an,null);E(this,ka,null);E(this,Yo,null);E(this,Sa,null);E(this,ru,"");E(this,Ji,null);E(this,Qo,null);E(this,eo,null);E(this,Fr,!1);E(this,jh,!1);A(this,Yo,t.bitmapUrl),A(this,Sa,t.bitmapFile)}static initialize(t,r){He.initialize(t,r)}static get supportedTypes(){return Ne(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return Ne(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,r){r.pasteEditor(xe.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,!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,r;g(this,an)&&(A(this,Ct,null),this._uiManager.imageManager.deleteId(g(this,an)),(t=g(this,Ji))==null||t.remove(),A(this,Ji,null),(r=g(this,Qo))==null||r.disconnect(),A(this,Qo,null),g(this,eo)&&(clearTimeout(g(this,eo)),A(this,eo,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(g(this,an)&&g(this,Ji)===null&&I(this,iu,Ay).call(this),this.isAttachedToDOM||this.parent.add(this))):g(this,an)&&I(this,iu,Ay).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(g(this,ka)||g(this,Ct)||g(this,Yo)||g(this,Sa)||g(this,an))}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.addAltTextButton(),g(this,Ct)?I(this,zh,r8).call(this):I(this,iu,Ay).call(this),this.width){const[i,o]=this.parentDimensions;this.setAt(t*i,r*o,this.width*i,this.height*o)}return this.div}copyCanvas(t,r=!1){var y;t||(t=224);const{width:i,height:o}=g(this,Ct),s=document.createElement("canvas");let l=g(this,Ct),c=i,d=o;if(i>t||o>t){const w=Math.min(t/i,t/o);c=Math.floor(i*w),d=Math.floor(o*w),g(this,Fr)||(l=I(this,Hh,i8).call(this,c,d))}s.width=c,s.height=d;const u=s.getContext("2d");u.filter=this._uiManager.hcmFilter;let f="white",h="#cfcfd8";this._uiManager.hcmFilter!=="none"?h="black":(y=window.matchMedia)!=null&&y.call(window,"(prefers-color-scheme: dark)").matches&&(f="#8f8f9d",h="#42414d");const p=15,m=new OffscreenCanvas(30,30),b=m.getContext("2d");if(b.fillStyle=f,b.fillRect(0,0,30,30),b.fillStyle=h,b.fillRect(0,0,p,p),b.fillRect(p,p,p,p),u.fillStyle=u.createPattern(m,"repeat"),u.fillRect(0,0,c,d),r){const w=new OffscreenCanvas(c,d),v=w.getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,c,d);const k=v.getImageData(0,0,c,d).data;return u.drawImage(w,0,0),{canvas:s,imageData:{width:c,height:d,data:k}}}return u.drawImage(l,0,0,l.width,l.height,0,0,c,d),{canvas:s,imageData:null}}getImageForAltText(){return g(this,Ji)}static deserialize(t,r,i){if(t instanceof aM)return null;const o=super.deserialize(t,r,i),{rect:s,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:u}=t;c&&i.imageManager.isValidId(c)?A(o,an,c):A(o,Yo,l),A(o,Fr,d);const[f,h]=o.pageDimensions;return o.width=(s[2]-s[0])/f,o.height=(s[3]-s[1])/h,u&&(o.altTextData=u),o}serialize(t=!1,r=null){if(this.isEmpty())return null;const i={annotationType:xe.STAMP,bitmapId:g(this,an),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:g(this,Fr),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=I(this,ou,Ty).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}),r===null)return i;r.stamps||(r.stamps=new Map);const l=g(this,Fr)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(r.stamps.has(g(this,an))){if(g(this,Fr)){const c=r.stamps.get(g(this,an));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=I(this,ou,Ty).call(this,!1))}}else r.stamps.set(g(this,an),{area:l,serialized:i}),i.bitmap=I(this,ou,Ty).call(this,!1);return i}};Ct=new WeakMap,an=new WeakMap,ka=new WeakMap,Yo=new WeakMap,Sa=new WeakMap,ru=new WeakMap,Ji=new WeakMap,Qo=new WeakMap,eo=new WeakMap,Fr=new WeakMap,jh=new WeakMap,P0=new WeakSet,cp=function(t,r=!1){t?(A(this,Ct,t.bitmap),r||(A(this,an,t.id),A(this,Fr,t.isSvg)),t.file&&A(this,ru,t.file.name),I(this,zh,r8).call(this)):this.remove()},L0=new WeakSet,dp=function(){if(A(this,ka,null),this._uiManager.enableWaiting(!1),g(this,Ji))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&g(this,Ct))this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&g(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},iu=new WeakSet,Ay=function(){if(g(this,an)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(g(this,an)).then(i=>I(this,P0,cp).call(this,i,!0)).finally(()=>I(this,L0,dp).call(this));return}if(g(this,Yo)){const i=g(this,Yo);A(this,Yo,null),this._uiManager.enableWaiting(!0),A(this,ka,this._uiManager.imageManager.getFromUrl(i).then(o=>I(this,P0,cp).call(this,o)).finally(()=>I(this,L0,dp).call(this)));return}if(g(this,Sa)){const i=g(this,Sa);A(this,Sa,null),this._uiManager.enableWaiting(!0),A(this,ka,this._uiManager.imageManager.getFromFile(i).then(o=>I(this,P0,cp).call(this,o)).finally(()=>I(this,L0,dp).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Zh.supportedTypesStr;const r=this._uiManager._signal;A(this,ka,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,P0,cp).call(this,o)}else this.remove();i()},{signal:r}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:r})}).finally(()=>I(this,L0,dp).call(this))),t.click()},zh=new WeakSet,r8=function(){const{div:t}=this;let{width:r,height:i}=g(this,Ct);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 f=Math.min(l*o/r,l*s/i);r*=f,i*=f}const[c,d]=this.parentDimensions;this.setDims(r*c/o,i*d/s),this._uiManager.enableWaiting(!1);const u=A(this,Ji,document.createElement("canvas"));t.append(u),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow||(t.hidden=!1),I(this,Uh,o8).call(this,r,i),I(this,Q5,SP).call(this),g(this,jh)||(this.parent.addUndoableEditor(this),A(this,jh,!0)),this._reportTelemetry({action:"inserted_image"}),g(this,ru)&&u.setAttribute("aria-label",g(this,ru))},Y5=new WeakSet,kP=function(t,r){var s;const[i,o]=this.parentDimensions;this.width=t/i,this.height=r/o,this.setDims(t,r),(s=this._initialOptions)!=null&&s.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,g(this,eo)!==null&&clearTimeout(g(this,eo)),A(this,eo,setTimeout(()=>{A(this,eo,null),I(this,Uh,o8).call(this,t,r)},200))},Hh=new WeakSet,i8=function(t,r){const{width:i,height:o}=g(this,Ct);let s=i,l=o,c=g(this,Ct);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},Uh=new WeakSet,o8=function(t,r){t=Math.ceil(t),r=Math.ceil(r);const i=g(this,Ji);if(!i||i.width===t&&i.height===r)return;i.width=t,i.height=r;const o=g(this,Fr)?g(this,Ct):I(this,Hh,i8).call(this,t,r),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(o,0,0,o.width,o.height,0,0,t,r)},ou=new WeakSet,Ty=function(t){if(t){if(g(this,Fr)){const i=this._uiManager.imageManager.getSvgUrl(g(this,an));if(i)return i}const r=document.createElement("canvas");return{width:r.width,height:r.height}=g(this,Ct),r.getContext("2d").drawImage(g(this,Ct),0,0),r.toDataURL()}if(g(this,Fr)){const[r,i]=this.pageDimensions,o=Math.round(this.width*r*ms.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*ms.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(o,s);return l.getContext("2d").drawImage(g(this,Ct),0,0,g(this,Ct).width,g(this,Ct).height,0,0,o,s),l.transferToImageBitmap()}return structuredClone(g(this,Ct))},Q5=new WeakSet,SP=function(){this._uiManager._signal&&(A(this,Qo,new ResizeObserver(t=>{const r=t[0].contentRect;r.width&&r.height&&I(this,Y5,kP).call(this,r.width,r.height)})),g(this,Qo).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=g(this,Qo))==null||t.disconnect(),A(this,Qo,null)},{once:!0}))},be(Zh,"_type","stamp"),be(Zh,"_editorType",xe.STAMP);let r6=Zh;const fi=class fi{constructor({uiManager:e,pageIndex:t,div:r,accessibilityManager:i,annotationLayer:o,drawLayer:s,textLayer:l,viewport:c,l10n:d}){E(this,X5);E(this,Wh);E(this,qh);E(this,Kh);E(this,cu);E(this,B0,void 0);E(this,su,!1);E(this,to,null);E(this,Ea,null);E(this,Xo,null);E(this,gr,new Map);E(this,Ma,!1);E(this,au,!1);E(this,lu,!1);E(this,Dn,null);E(this,Jo,null);E(this,fe,void 0);const u=[...g(fi,Aa).values()];if(!fi._initialized){fi._initialized=!0;for(const f of u)f.initialize(d,e)}e.registerEditorTypes(u),A(this,fe,e),this.pageIndex=t,this.div=r,A(this,B0,i),A(this,to,o),this.viewport=c,A(this,Dn,l),this.drawLayer=s,g(this,fe).addLayer(this)}get isEmpty(){return g(this,gr).size===0}get isInvisible(){return this.isEmpty&&g(this,fe).getMode()===xe.NONE}updateToolbar(e){g(this,fe).updateToolbar(e)}updateMode(e=g(this,fe).getMode()){switch(I(this,cu,Iy).call(this),e){case xe.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case xe.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case xe.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 g(fi,Aa).values())t.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=g(this,Dn))==null?void 0:t.div)}addInkEditorIfNeeded(e){if(g(this,fe).getMode()===xe.INK){if(!e){for(const t of g(this,gr).values())if(t.isEmpty()){t.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){g(this,fe).setEditingState(e)}addCommands(e){g(this,fe).addCommands(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=g(this,to))==null||t.div.classList.toggle("disabled",!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const r of g(this,gr).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(g(this,fe).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!g(this,to))return;const t=g(this,to).getEditableAnnotations();for(const r of t){if(r.hide(),g(this,fe).isDeletedAnnotationElement(r.data.id)||e.has(r.data.id))continue;const i=this.deserialize(r);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;A(this,lu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const o of g(this,gr).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(g(this,to)){const o=g(this,to).getEditableAnnotations();for(const s of o){const{id:l}=s.data;if(g(this,fe).isDeletedAnnotationElement(l))continue;let c=t.get(l);c?(c.resetAnnotationElement(s),c.show(!1),s.show()):(c=e.get(l),c&&(g(this,fe).addChangedExistingAnnotation(c),c.renderAnnotationElement(s),c.show(!1)),s.show())}}I(this,cu,Iy).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:r}=this.div;for(const o of g(fi,Aa).values())r.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,lu,!1)}getEditableAnnotation(e){var t;return((t=g(this,to))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){g(this,fe).getActive()!==e&&g(this,fe).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=g(this,Dn))!=null&&e.div&&!g(this,Jo)){A(this,Jo,new AbortController);const t=g(this,fe).combinedSignal(g(this,Jo));g(this,Dn).div.addEventListener("pointerdown",I(this,X5,EP).bind(this),{signal:t}),g(this,Dn).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=g(this,Dn))!=null&&e.div&&g(this,Jo)&&(g(this,Jo).abort(),A(this,Jo,null),g(this,Dn).div.classList.remove("highlighting"))}enableClick(){if(g(this,Ea))return;A(this,Ea,new AbortController);const e=g(this,fe).combinedSignal(g(this,Ea));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:e})}disableClick(){var e;(e=g(this,Ea))==null||e.abort(),A(this,Ea,null)}attach(e){g(this,gr).set(e.id,e);const{annotationElementId:t}=e;t&&g(this,fe).isDeletedAnnotationElement(t)&&g(this,fe).removeDeletedAnnotationElement(e)}detach(e){var t;g(this,gr).delete(e.id),(t=g(this,B0))==null||t.removePointerInTextLayer(e.contentDiv),!g(this,lu)&&e.annotationElementId&&g(this,fe).addDeletedAnnotationElement(e)}remove(e){this.detach(e),g(this,fe).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,g(this,au)||this.addInkEditorIfNeeded(!1)}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(g(this,fe).addDeletedAnnotationElement(e.annotationElementId),He.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),g(this,fe).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),g(this,fe).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var r;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!g(this,Xo)&&(e._focusEventsAllowed=!1,A(this,Xo,setTimeout(()=>{A(this,Xo,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:g(this,fe)._signal}),t.focus())},0))),e._structTreeParentId=(r=g(this,B0))==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 g(this,fe).getId()}combinedSignal(e){return g(this,fe).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=g(this,Wh,s8))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){g(this,fe).updateToolbar(e),g(this,fe).updateMode(e);const{offsetX:r,offsetY:i}=I(this,Kh,l8).call(this),o=this.getNextId(),s=I(this,qh,a8).call(this,{parent:this,id:o,x:r,y:i,uiManager:g(this,fe),isCentered:!0,...t});s&&this.add(s)}deserialize(e){var t;return((t=g(fi,Aa).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,g(this,fe)))||null}createAndAddNewEditor(e,t,r={}){const i=this.getNextId(),o=I(this,qh,a8).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:g(this,fe),isCentered:t,...r});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(I(this,Kh,l8).call(this),!0)}setSelected(e){g(this,fe).setSelected(e)}toggleSelected(e){g(this,fe).toggleSelected(e)}isSelected(e){return g(this,fe).isSelected(e)}unselect(e){g(this,fe).unselect(e)}pointerup(e){const{isMac:t}=jn.platform;!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&g(this,Ma)&&(A(this,Ma,!1),g(this,su)?g(this,fe).getMode()!==xe.STAMP?this.createAndAddNewEditor(e,!1):g(this,fe).unselectAll():A(this,su,!0))}pointerdown(e){if(g(this,fe).getMode()===xe.HIGHLIGHT&&this.enableTextSelection(),g(this,Ma)){A(this,Ma,!1);return}const{isMac:t}=jn.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;A(this,Ma,!0);const r=g(this,fe).getActive();A(this,su,!r||r.isEmpty())}findNewParent(e,t,r){const i=g(this,fe).findParent(t,r);return i===null||i===this?!1:(i.changeParent(e),!0)}destroy(){var e,t;((e=g(this,fe).getActive())==null?void 0:e.parent)===this&&(g(this,fe).commitOrRemove(),g(this,fe).setActiveEditor(null)),g(this,Xo)&&(clearTimeout(g(this,Xo)),A(this,Xo,null));for(const r of g(this,gr).values())(t=g(this,B0))==null||t.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,g(this,gr).clear(),g(this,fe).removeLayer(this)}render({viewport:e}){this.viewport=e,Ga(this.div,e);for(const t of g(this,fe).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){g(this,fe).commitOrRemove(),I(this,cu,Iy).call(this);const t=this.viewport.rotation,r=e.rotation;if(this.viewport=e,Ga(this.div,{rotation:r}),t!==r)for(const i of g(this,gr).values())i.rotate(r);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return g(this,fe).viewParameters.realScale}};B0=new WeakMap,su=new WeakMap,to=new WeakMap,Ea=new WeakMap,Xo=new WeakMap,gr=new WeakMap,Ma=new WeakMap,au=new WeakMap,lu=new WeakMap,Dn=new WeakMap,Jo=new WeakMap,fe=new WeakMap,Aa=new WeakMap,X5=new WeakSet,EP=function(e){g(this,fe).unselectAll();const{target:t}=e;if(t===g(this,Dn).div||t.classList.contains("endOfContent")&&g(this,Dn).div.contains(t)){const{isMac:r}=jn.platform;if(e.button!==0||e.ctrlKey&&r)return;g(this,fe).showAllEditors("highlight",!0,!0),g(this,Dn).div.classList.add("free"),this.toggleDrawing(),Sm.startHighlighting(this,g(this,fe).direction==="ltr",e),g(this,Dn).div.addEventListener("pointerup",()=>{g(this,Dn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:g(this,fe)._signal}),e.preventDefault()}},Wh=new WeakSet,s8=function(){return g(fi,Aa).get(g(this,fe).getMode())},qh=new WeakSet,a8=function(e){const t=g(this,Wh,s8);return t?new t.prototype.constructor(e):null},Kh=new WeakSet,l8=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}},cu=new WeakSet,Iy=function(){A(this,au,!0);for(const e of g(this,gr).values())e.isEmpty()&&e.remove();A(this,au,!1)},be(fi,"_initialized",!1),E(fi,Aa,new Map([e6,n6,r6,Sm].map(e=>[e._editorType,e])));let i6=fi;const ln=class ln{constructor({pageIndex:e}){E(this,Qh);E(this,J5);E(this,no,null);E(this,Gh,0);E(this,Pt,new Map);E(this,Ta,new Map);this.pageIndex=e}setParent(e){if(g(this,no)){if(g(this,no)!==e){if(g(this,Pt).size>0)for(const t of g(this,Pt).values())t.remove(),e.append(t);A(this,no,e)}}else A(this,no,e)}static get _svgFactory(){return Ne(this,"_svgFactory",new Nb)}highlight(e,t,r,i=!1){const o=Xn(this,Gh)._++,s=I(this,Qh,d8).call(this,e.box);s.classList.add("highlight"),e.free&&s.classList.add("free");const l=ln._svgFactory.createElement("defs");s.append(l);const c=ln._svgFactory.createElement("path");l.append(c);const d=`path_p${this.pageIndex}_${o}`;c.setAttribute("id",d),c.setAttribute("d",e.toSVGPath()),i&&g(this,Ta).set(o,c);const u=I(this,J5,MP).call(this,l,d),f=ln._svgFactory.createElement("use");return s.append(f),s.setAttribute("fill",t),s.setAttribute("fill-opacity",r),f.setAttribute("href",`#${d}`),g(this,Pt).set(o,s),{id:o,clipPathId:`url(#${u})`}}highlightOutline(e){const t=Xn(this,Gh)._++,r=I(this,Qh,d8).call(this,e.box);r.classList.add("highlightOutline");const i=ln._svgFactory.createElement("defs");r.append(i);const o=ln._svgFactory.createElement("path");i.append(o);const s=`path_p${this.pageIndex}_${t}`;o.setAttribute("id",s),o.setAttribute("d",e.toSVGPath()),o.setAttribute("vector-effect","non-scaling-stroke");let l;if(e.free){r.classList.add("free");const u=ln._svgFactory.createElement("mask");i.append(u),l=`mask_p${this.pageIndex}_${t}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const f=ln._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const h=ln._svgFactory.createElement("use");u.append(h),h.setAttribute("href",`#${s}`),h.setAttribute("stroke","none"),h.setAttribute("fill","black"),h.setAttribute("fill-rule","nonzero"),h.classList.add("mask")}const c=ln._svgFactory.createElement("use");r.append(c),c.setAttribute("href",`#${s}`),l&&c.setAttribute("mask",`url(#${l})`);const d=c.cloneNode();return r.append(d),c.classList.add("mainOutline"),d.classList.add("secondaryOutline"),g(this,Pt).set(t,r),t}finalizeLine(e,t){const r=g(this,Ta).get(e);g(this,Ta).delete(e),this.updateBox(e,t.box),r.setAttribute("d",t.toSVGPath())}updateLine(e,t){g(this,Pt).get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}removeFreeHighlight(e){this.remove(e),g(this,Ta).delete(e)}updatePath(e,t){g(this,Ta).get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){var r;I(r=ln,Yh,c8).call(r,g(this,Pt).get(e),t)}show(e,t){g(this,Pt).get(e).classList.toggle("hidden",!t)}rotate(e,t){g(this,Pt).get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){g(this,Pt).get(e).setAttribute("fill",t)}changeOpacity(e,t){g(this,Pt).get(e).setAttribute("fill-opacity",t)}addClass(e,t){g(this,Pt).get(e).classList.add(t)}removeClass(e,t){g(this,Pt).get(e).classList.remove(t)}remove(e){g(this,no)!==null&&(g(this,Pt).get(e).remove(),g(this,Pt).delete(e))}destroy(){A(this,no,null);for(const e of g(this,Pt).values())e.remove();g(this,Pt).clear()}};no=new WeakMap,Gh=new WeakMap,Pt=new WeakMap,Ta=new WeakMap,Yh=new WeakSet,c8=function(e,{x:t=0,y:r=0,width:i=1,height:o=1}={}){const{style:s}=e;s.top=100*r+"%",s.left=100*t+"%",s.width=100*i+"%",s.height=100*o+"%"},Qh=new WeakSet,d8=function(e){var r;const t=ln._svgFactory.create(1,1,!0);return g(this,no).append(t),t.setAttribute("aria-hidden",!0),I(r=ln,Yh,c8).call(r,t,e),t},J5=new WeakSet,MP=function(e,t){const r=ln._svgFactory.createElement("clipPath");e.append(r);const i=`clip_${t}`;r.setAttribute("id",i),r.setAttribute("clipPathUnits","objectBoundingBox");const o=ln._svgFactory.createElement("use");return r.append(o),o.setAttribute("href",`#${t}`),o.classList.add("clip"),i},E(ln,Yh);let o6=ln;ve.AbortException,ve.AnnotationEditorLayer,ve.AnnotationEditorParamsType,ve.AnnotationEditorType,ve.AnnotationEditorUIManager,ve.AnnotationLayer,ve.AnnotationMode,ve.CMapCompressionType,ve.ColorPicker,ve.DOMSVGFactory,ve.DrawLayer,ve.FeatureTest;var wW=ve.GlobalWorkerOptions;ve.ImageKind,ve.InvalidPDFException,ve.MissingPDFException,ve.OPS,ve.PDFDataRangeTransport,ve.PDFDateString,ve.PDFWorker,ve.PasswordResponses,ve.PermissionFlag,ve.PixelsPerInch,ve.RenderingCancelledException,ve.TextLayer,ve.UnexpectedResponseException,ve.Util,ve.VerbosityLevel,ve.XfaLayer,ve.build,ve.createValidAbsoluteUrl,ve.fetchData;var vW=ve.getDocument;ve.getFilenameFromUrl,ve.getPdfFilenameFromUrl,ve.getXfaPageViewport,ve.isDataScheme,ve.isPdfFile,ve.noContextMenu,ve.normalizeUnicode,ve.setLayerDimensions,ve.shadow;var CW=ve.version;const kW=a.defineComponent({name:"QModal",components:{QIcon:Ra},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 SW(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 s6=me(kW,[["render",SW],["__scopeId","data-v-8867a052"]]),EW=a.defineComponent({name:"QErrorModal",components:{QModal:s6},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:Qt}}}),MW={class:"flex flex-col gap-2 text-center"},AW={class:"text-lg font-bold text-inkwell-30 leading-6"},TW={class:"text-inkwell-0 mb-2 md:mb-6"};function IW(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]","footer-class":"mt-2 md:mt-6",onClose:e[1]||(e[1]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(c,null,{body:a.withCtx(()=>[a.createElementVNode("div",MW,[a.createVNode(s,{icon:"exclamation-circle",type:"outline",size:"xl",color:"red-30",class:"shrink-0 self-center mb-8"}),a.createElementVNode("h2",AW,[a.renderSlot(n.$slots,"headline",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_ERROR")),1)],!0)]),a.createElementVNode("p",TW,[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 dM=me(EW,[["render",IW],["__scopeId","data-v-72f5c09d"]]);wW.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${CW}/legacy/build/pdf.worker.min.mjs`;const xW=a.defineComponent({name:"PdfViewer",components:{QErrorModal:dM},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 vW(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}}}),OW={class:"q-pdf-viewer"},DW={key:0},NW={key:1,class:"pdf-pages"};function PW(n,e,t,r,i,o){const s=a.resolveComponent("q-error-modal");return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",OW,[n.loadingMeta?(a.openBlock(),a.createElementBlock("div",DW,[(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",NW,[(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 uM=me(xW,[["render",PW],["__scopeId","data-v-da5da0f5"]]),LW=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},tooltipClasses:{type:[String,Array,Object],default:""}}}),BW=["aria-describedby"],_W=["id"];function RW(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{class:"tooltip-container","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,_W)],8,BW)}const rc=me(LW,[["render",RW],["__scopeId","data-v-ca6ae8fe"]]),ic=()=>{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}},$W=a.defineComponent({name:"ImageGallery",components:{Galleria:lE,QBadge:ns,QBottomSheet:eC,QMenu:Cb,QPdfViewer:uM,QTooltip:rc},props:{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}=bi(),{deviceType:r}=ic(),i=[{text:t("HC_CANCEL")}],o=a.ref(null),s=a.computed(()=>{var Y;return(Y=o.value)==null?void 0:Y.offsetWidth}),l=a.ref(null),c=a.ref([]),d=a.ref(!1),u=a.ref(null),f=a.ref("0"),h=a.ref(1),p=a.ref(Qt.md?1:.9),m=a.ref(0),b=a.ref(null),y=a.ref(),w=a.ref(!1),v=a.ref(!1),k=a.computed(()=>{if(b.value)return b.value&&"original"in b.value?{name:b.value.original.name,url:b.value.original.url,type:b.value.mimetype,extension:F(b.value.original.url)}:{name:b.value.name,url:URL.createObjectURL(b.value),type:b.value.type,extension:F(b.value.name)}}),C=a.computed(()=>[`z-[${n.baseZIndex+1}]`]),T=a.computed(()=>n.files.filter(Y=>Y.type.startsWith("image")&&!Y.type.includes("tif"))),S=a.computed(()=>["rounded-lg relative mx-auto object-cover grow-1 max-h-[74vh]",{animated:!D}]),M=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"}]),x=a.computed(()=>[{text:t("HC_DELETE_ATTACHMENT"),classes:"!text-red-20",event:H}]),O=Y=>{const Z=Y instanceof File?URL.createObjectURL(Y):Y.original.url;r.value==="desktop"?window.open(Z,"_blank"):window.open(Z,"_self")},P=Y=>{r.value==="desktop"?O(Y):(b.value=Y,v.value=!0)},N=Y=>{Y.event(),d.value=!1},_=(Y,Z)=>{var $;const j=(($=Z.type)==null?void 0:$.includes("image"))&&!Z.type.includes("tif");!d.value&&j?V(Y,Z):!d.value&&!j&&P(Z)},V=(Y,Z)=>{const j=W=>"original"in W&&"original"in Z?W.original.url===(Z==null?void 0:Z.original.url):Z instanceof File?W.name===(Z==null?void 0:Z.name):!1,$=T.value.findIndex(j);m.value=$!==-1?$:Y,w.value=!0},H=(Y=null)=>{d.value=!1,e("update:model-value",Y||u.value)},L=Y=>{const{keyCode:Z}=Y;if(w.value)switch(Z){case 37:m.value=m.value?m.value-1:T.value.length-1,e("update:activeIndex",m.value);break;case 39:m.value=m.value<T.value.length-1?m.value+1:0,e("update:activeIndex",m.value);break;case 27:w.value=!1;break}},{isSwiping:D,lengthX:U}=vB(l,{passive:!1,onSwipe(){const Y=Math.abs(U.value);s.value&&(h.value=1.1-Y/s.value,f.value=U.value<0?`${Y/4}px`:`-${Y/4}px`)},onSwipeEnd(){const Y=m.value<=0,Z=m.value>=T.value.length-1,j=Math.abs(U.value);s.value&&j/s.value>=.5?(U.value<0?m.value=Y?T.value.length-1:m.value-1:m.value=Z?0:m.value+1,f.value="0",h.value=1):(f.value="0",h.value=1)}}),F=Y=>Y.substring(Y.lastIndexOf(".")),R=(Y,Z)=>{Y.preventDefault(),u.value=n.files[Z],d.value=!0},G=()=>{d.value=!1,u.value=null},ne=()=>{r.value!=="desktop"&&c.value.forEach(Y=>{fB(Y,Z=>{const j=c.value.indexOf(Y);R(Z,j)},{modifiers:{prevent:!0}})})};return a.onMounted(()=>{window.addEventListener("keyup",L),ne()}),a.onUpdated(()=>{ne()}),{menuActions:i,linkActions:x,deviceType:r,container:o,containerWidth:s,featuredPhoto:l,longPressRef:c,longPressedHook:d,isSwiping:D,lengthX:U,left:f,opacity:h,scale:p,showCarousel:w,showFileViewer:v,active:m,activeAttachment:b,hoveredIndex:y,closeIconClasses:C,itemClasses:S,images:T,normalizedAttachment:k,thumbnailContainerClasses:M,downloadDocument:O,getExtension:F,onAttachmentClick:P,onClickMenuLink:N,onClickThumbnail:_,onOpenCarousel:V,onRemoveFile:H,onKeyboardNavigation:L,onLongPressCallbackHook:R,resetHook:G,mq:Qt}}}),VW={class:"q-image-gallery flex",ref:"container"},FW={ref:"featuredPhoto",class:"featured-image h-[80vh] overflow-hidden flex max-w-screen relative md:h-full w-screen items-center"},jW=["src","alt"],zW=["src","alt"],HW=["onMouseover","onClick"],UW=["src","alt"],ZW={key:1,class:"bg-gray-00 cursor-pointer p-3 h-16 max-w-[14rem] rounded-lg border border-gray-20 flex items-center"},WW={class:"grow text-ellipsis overflow-hidden"},qW={class:"text-inkwell-30 bold leading-normal text-nowrap text-ellipsis text-sm overflow-hidden -mt-1"},KW={class:"uppercase text-xxs"},GW={key:2,class:"image-overlay absolute top-0 left-0 w-full h-full cursor-pointer"},YW={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"},QW={key:1,width:"100%",height:"auto",controls:"",class:"bg-black"},XW=["src"],JW={class:"flex items-center flex-col p-12"},eq=["src"],tq=["data","type"],nq={class:"flex items-center flex-col p-12"};function rq(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",VW,[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",FW,[a.createElementVNode("img",{src:(p==null?void 0:p.itemImageSrc)||(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.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,jW)],512)]),thumbnail:a.withCtx(({item:p})=>[a.createElementVNode("img",{src:(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.url),alt:p.alt,class:"rounded-lg block min-h-24 min-w-24 max-w-24 max-h-24 object-cover"},null,8,zW)]),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.files?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(n.thumbnailContainerClasses)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.files,(p,m)=>{var b;return a.openBlock(),a.createElementBlock("div",{ref_for:!0,ref:"longPressRef",key:p.name||((b=p.original)==null?void 0:b.name)||m,class:a.normalizeClass(["p-0 relative rounded-lg",{"shrink-0":n.deviceType!=="desktop"}]),onMouseover:y=>n.hoveredIndex=m,onMouseleave:e[2]||(e[2]=y=>n.hoveredIndex=null),onClick:y=>n.onClickThumbnail(m,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,src:(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.url),alt:p==null?void 0:p.alt,class:"rounded-lg cursor-pointer w-16 h-16 object-cover bg-gray-0 border-gray-20 border"},null,8,UW)):(a.openBlock(),a.createElementBlock("div",ZW,[a.createVNode(s,{icon:"file-document",size:"xl",color:"white",class:"mr-3 shrink-0 p-2 bg-green-20 rounded-lg h-full"}),a.createElementVNode("div",WW,[a.createElementVNode("div",qW,a.toDisplayString(p.name||p.original.name),1),a.createElementVNode("div",KW,a.toDisplayString((p.name||p.original.name).match(/([^.]+$)/)[0]),1)])])),n.deviceType!=="desktop"?(a.openBlock(),a.createElementBlock("div",GW)):a.createCommentVNode("",!0),n.showRemove&&n.showOnHover&&n.hoveredIndex===m&&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(y=>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(()=>{var y;return[a.createTextVNode(a.toDisplayString(p.name||((y=p.original)==null?void 0:y.name)),1)]}),_:2},1024),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.processing?(a.openBlock(),a.createElementBlock("div",YW,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,HW)}),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.normalizedAttachment&&n.activeAttachment?(a.openBlock(),a.createBlock(h,{key:0,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.normalizedAttachment.name),1)]),headerAction:a.withCtx(()=>[!n.normalizedAttachment.type.includes("video")&&n.normalizedAttachment.type!=="audio/mpeg"&&n.normalizedAttachment.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.normalizedAttachment.type==="application/pdf"?(a.openBlock(),a.createBlock(f,{key:0,url:n.normalizedAttachment.url},null,8,["url"])):n.normalizedAttachment.type.includes("video")?(a.openBlock(),a.createElementBlock("video",QW,[a.createElementVNode("source",{src:n.normalizedAttachment.url},null,8,XW),a.createElementVNode("div",JW,[a.createVNode(s,{icon:"file-document",size:"xl",color:"inkwell-30"}),a.createTextVNode(" "+a.toDisplayString(n.normalizedAttachment.extension),1)])])):n.normalizedAttachment.type==="audio/mpeg"?(a.openBlock(),a.createElementBlock("audio",{key:2,controls:"",src:n.normalizedAttachment.url,class:"mx-auto my-6"},null,8,eq)):(a.openBlock(),a.createElementBlock("object",{key:3,data:n.normalizedAttachment.url,type:n.normalizedAttachment.type,class:"w-full h-auto"},[a.createElementVNode("div",nq,[a.createVNode(s,{icon:"file-document",size:"xl",color:"inkwell-30"}),a.createTextVNode(" "+a.toDisplayString(n.normalizedAttachment.extension),1)])],8,tq))]),_:1},8,["modelValue"])):a.createCommentVNode("",!0)]),_:1})],512)}const a6=me($W,[["render",rq],["__scopeId","data-v-ba426870"]]),iq=a.defineComponent({name:"QWarningModal",components:{QModal:s6},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:Qt}}}),oq={key:0,class:"flex flex-col gap-2 text-center"},sq={class:"text-lg font-bold text-inkwell-30 leading-6"},aq={class:"text-inkwell-0 mb-6"},lq={key:1,class:"flex flex-col gap-2 text-center"},cq={class:"text-[1.25rem] font-bold text-center text-inkwell-30"},dq={class:"text-sm text-center text-inkwell-0 mb-2"},uq={class:"flex flex-col items-center justify-center gap-3 md:gap-2"};function fq(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","footer-class":"mt-2 md:mt-6",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",oq,[a.createElementVNode("h2",sq,[a.renderSlot(n.$slots,"desktopHeader",{},void 0,!0)]),a.createElementVNode("p",aq,[a.renderSlot(n.$slots,"desktopMessage",{},void 0,!0)])])):(a.openBlock(),a.createElementBlock("div",lq,[a.createElementVNode("h2",cq,[a.renderSlot(n.$slots,"mobileHeader",{},void 0,!0)]),a.createElementVNode("p",dq,[a.renderSlot(n.$slots,"mobileMessage",{},void 0,!0)])]))]),footer:a.withCtx(()=>[a.createElementVNode("div",uq,[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 fM=me(iq,[["render",fq],["__scopeId","data-v-a8bfc627"]]),hq=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 k=w.left;return window.innerWidth-k<v.width?"right":"left"}else{const k=w.top;return window.innerHeight-k<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 k=w.top;return window.innerHeight-k<v.height?"top":"bottom"}else{const k=w.left;return window.innerWidth-k<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,k=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: ${k/2-10}px;`;break;case"bottom":r.value=`margin-bottom: ${k/2-10}px;`;break}}};mp(i,()=>{e("update:modelValue",!1)});function m(){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:m,onClick:u,onClickOutside:mp,onEnter:b,onMouseLeave:f,onMouseOver:h}}});function pq(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 hM=me(hq,[["render",pq],["__scopeId","data-v-86f2575d"]]);function en(n){this.content=n}en.prototype={constructor:en,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 en(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 en(t)},addToStart:function(n,e){return new en([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new en(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 en(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=en.from(n),n.size?new en(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=en.from(n),n.size?new en(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=en.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}},en.from=function(n){if(n instanceof en)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new en(e)};function pM(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=pM(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function mM(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=mM(s.content,l.content,t-1,r-1);if(d)return d}t-=c,r-=c}}class X{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 X(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 X(r,i)}cutByIndex(e,t){return e==t?X.empty:e==0&&t==this.content.length?this:new X(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 X(i,o)}addToStart(e){return new X([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new X(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 pM(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return mM(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Em(0,e);if(e==this.size)return Em(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?Em(r+1,s):Em(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 X.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return X.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 X(t||e,r)}static from(e){if(!e)return X.empty;if(e instanceof X)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new X([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const l6={index:0,offset:0};function Em(n,e){return l6.index=n,l6.offset=e,l6}function Mm(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(!Mm(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Mm(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ke=class u8{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&&Mm(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 u8.none;if(e instanceof u8)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ke.none=[];class Am extends Error{}class ie{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=yM(this.content,e+this.openStart,t);return r&&new ie(r,this.openStart,this.openEnd)}removeBetween(e,t){return new ie(gM(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 ie.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 ie(X.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 ie(e,r,i)}}ie.empty=new ie(X.empty,0,0);function gM(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(gM(o.content,e-i-1,t-i-1)))}function yM(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=yM(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function mq(n,e,t){if(t.openStart>n.depth)throw new Am("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Am("Inconsistent open depths");return bM(n,e,t,0)}function bM(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=bM(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 tl(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=gq(t,n);return tl(o,vM(n,s,l,e,r))}else return tl(o,Tm(n,e,r))}function wM(n,e){if(!e.type.compatibleContent(n.type))throw new Am("Cannot join "+e.type.name+" onto "+n.type.name)}function c6(n,e,t){let r=n.node(t);return wM(r,e.node(t)),r}function el(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 S2(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&&(el(n.nodeAfter,r),o++));for(let l=o;l<s;l++)el(i.child(l),r);e&&e.depth==t&&e.textOffset&&el(e.nodeBefore,r)}function tl(n,e){return n.type.checkContent(e),n.copy(e)}function vM(n,e,t,r,i){let o=n.depth>i&&c6(n,e,i+1),s=r.depth>i&&c6(t,r,i+1),l=[];return S2(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(wM(o,s),el(tl(o,vM(n,e,t,r,i+1)),l)):(o&&el(tl(o,Tm(n,e,i+1)),l),S2(e,t,i,l),s&&el(tl(s,Tm(t,r,i+1)),l)),S2(r,null,i,l),new X(l)}function Tm(n,e,t){let r=[];if(S2(null,n,t,r),n.depth>t){let i=c6(n,e,t+1);el(tl(i,Tm(n,e,t+1)),r)}return S2(e,null,t,r),new X(r)}function gq(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(X.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class E2{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 Ke.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 Im(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 E2(t,r,o)}static resolveCached(e,t){for(let i=0;i<d6.length;i++){let o=d6[i];if(o.pos==t&&o.doc==e)return o}let r=d6[u6]=E2.resolve(e,t);return u6=(u6+1)%yq,r}}let d6=[],u6=0,yq=12;class Im{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 bq=Object.create(null);let nl=class f8{constructor(e,t,r,i=Ke.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||X.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&&Mm(this.attrs,t||e.defaultAttrs||bq)&&Ke.sameSet(this.marks,r||Ke.none)}copy(e=null){return e==this.content?this:new f8(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new f8(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 ie.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 ie(d,i.depth-s,o.depth-s)}replace(e,t,r){return mq(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 E2.resolveCached(this,e)}resolveNoCache(e){return E2.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()+")"),CM(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=X.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=Ke.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ke.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=X.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};nl.prototype.text=void 0;class xm extends nl{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):CM(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 xm(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xm(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 CM(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class rl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new wq(e,t);if(r.next==null)return rl.empty;let i=kM(r);r.next&&r.err("Unexpected trailing text");let o=Aq(Mq(i));return Tq(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 X.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)}},w5=new WeakSet,qN=function(){return g(this,fr).replaceAll(" "," ")},ch=new WeakSet,jv=function(t){return t.replaceAll(" "," ")},v5=new WeakSet,KN=function(t){const{value:r,fontSize:i,color:o,pageIndex:s}=g(this,Pd);return this._hasBeenMoved||t.value!==r||t.fontSize!==i||t.color.some((l,c)=>l!==o[c])||t.pageIndex!==s},E(Xe,Bd),E(Xe,ch),be(Xe,"_freeTextDefaultContent",""),be(Xe,"_internalPadding",0),be(Xe,"_defaultColor",null),be(Xe,"_defaultFontSize",10),be(Xe,"_type","freetext"),be(Xe,"_editorType",xe.FREETEXT);let e6=Xe;class lM{constructor(e,t=0,r=0,i=!0){E(this,C5);E(this,Rd);E(this,k5);E(this,S5);E(this,uh);E(this,dh,void 0);E(this,ga,[]);E(this,li,[]);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:k}of e){const C=Math.floor((y-t)/d)*d,T=Math.ceil((y+v+t)/d)*d,S=Math.floor((w-t)/d)*d,M=Math.ceil((w+k+t)/d)*d,x=[C,S,M,!0],O=[T,S,M,!1];g(this,ga).push(x,O),o=Math.min(o,C),s=Math.max(s,T),l=Math.min(l,S),c=Math.max(c,M)}const u=s-o+2*r,f=c-l+2*r,h=o-r,p=l-r,m=g(this,ga).at(i?-1:-2),b=[m[0],m[2]];for(const y of g(this,ga)){const[w,v,k]=y;y[0]=(w-h)/u,y[1]=(v-p)/f,y[2]=(k-p)/f}A(this,dh,{x:h,y:p,width:u,height:f,lastPoint:b})}getOutlines(){g(this,ga).sort((t,r)=>t[0]-r[0]||t[1]-r[1]||t[2]-r[2]);const e=[];for(const t of g(this,ga))t[3]?(e.push(...I(this,uh,zv).call(this,t)),I(this,k5,YN).call(this,t)):(I(this,S5,QN).call(this,t),e.push(...I(this,uh,zv).call(this,t)));return I(this,C5,GN).call(this,e)}}dh=new WeakMap,ga=new WeakMap,li=new WeakMap,C5=new WeakSet,GN=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 m;if(r.has(u))m=u;else{if(!r.has(f))break;m=f}r.delete(m),[l,c,d,u,f]=m,h!==l&&(o.push(h,p,l,p===c?c:d),h=l),p=p===c?d:c}o.push(h,p)}return new bW(i,g(this,dh))},Rd=new WeakSet,vy=function(e){const t=g(this,li);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},k5=new WeakSet,YN=function([,e,t]){const r=I(this,Rd,vy).call(this,e);g(this,li).splice(r,0,[e,t])},S5=new WeakSet,QN=function([,e,t]){const r=I(this,Rd,vy).call(this,e);for(let i=r;i<g(this,li).length;i++){const[o,s]=g(this,li)[i];if(o!==e)break;if(o===e&&s===t){g(this,li).splice(i,1);return}}for(let i=r-1;i>=0;i--){const[o,s]=g(this,li)[i];if(o!==e)break;if(o===e&&s===t){g(this,li).splice(i,1);return}}},uh=new WeakSet,zv=function(e){const[t,r,i]=e,o=[[t,r,i]],s=I(this,Rd,vy).call(this,i);for(let l=0;l<s;l++){const[c,d]=g(this,li)[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 cM{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(e,t){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof t6}}class bW extends cM{constructor(t,r){super();E(this,fh,void 0);E(this,$d,void 0);A(this,$d,t),A(this,fh,r)}toSVGPath(){const t=[];for(const r of g(this,$d)){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 g(this,$d)){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 g(this,fh)}}fh=new WeakMap,$d=new WeakMap;const Ho=class Ho{constructor({x:e,y:t},r,i,o,s,l=0){E(this,gh);E(this,Ki,void 0);E(this,zo,[]);E(this,Vd,void 0);E(this,Fd,void 0);E(this,Gi,[]);E(this,Oe,new Float64Array(18));E(this,p0,void 0);E(this,m0,void 0);E(this,hh,void 0);E(this,ph,void 0);E(this,jd,void 0);E(this,zd,void 0);E(this,ya,[]);A(this,Ki,r),A(this,zd,o*i),A(this,Fd,s),g(this,Oe).set([NaN,NaN,NaN,NaN,e,t],6),A(this,Vd,l),A(this,ph,g(Ho,mh)*i),A(this,hh,g(Ho,M5)*i),A(this,jd,i),g(this,ya).push(e,t)}get free(){return!0}isEmpty(){return isNaN(g(this,Oe)[8])}add({x:e,y:t}){var M;A(this,p0,e),A(this,m0,t);const[r,i,o,s]=g(this,Ki);let[l,c,d,u]=g(this,Oe).subarray(8,12);const f=e-d,h=t-u,p=Math.hypot(f,h);if(p<g(this,hh))return!1;const m=p-g(this,ph),b=m/p,y=b*f,w=b*h;let v=l,k=c;l=d,c=u,d+=y,u+=w,(M=g(this,ya))==null||M.push(e,t);const C=y/m,T=-w/m*g(this,zd),S=C*g(this,zd);return g(this,Oe).set(g(this,Oe).subarray(2,8),0),g(this,Oe).set([d+T,u+S],4),g(this,Oe).set(g(this,Oe).subarray(14,18),12),g(this,Oe).set([d-T,u-S],16),isNaN(g(this,Oe)[6])?(g(this,Gi).length===0&&(g(this,Oe).set([l+T,c+S],2),g(this,Gi).push(NaN,NaN,NaN,NaN,(l+T-r)/o,(c+S-i)/s),g(this,Oe).set([l-T,c-S],14),g(this,zo).push(NaN,NaN,NaN,NaN,(l-T-r)/o,(c-S-i)/s)),g(this,Oe).set([v,k,l,c,d,u],6),!this.isEmpty()):(g(this,Oe).set([v,k,l,c,d,u],6),Math.abs(Math.atan2(k-c,v-l)-Math.atan2(w,y))<Math.PI/2?([l,c,d,u]=g(this,Oe).subarray(2,6),g(this,Gi).push(NaN,NaN,NaN,NaN,((l+d)/2-r)/o,((c+u)/2-i)/s),[l,c,v,k]=g(this,Oe).subarray(14,18),g(this,zo).push(NaN,NaN,NaN,NaN,((v+l)/2-r)/o,((k+c)/2-i)/s),!0):([v,k,l,c,d,u]=g(this,Oe).subarray(0,6),g(this,Gi).push(((v+5*l)/6-r)/o,((k+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,k]=g(this,Oe).subarray(12,18),g(this,zo).push(((v+5*l)/6-r)/o,((k+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=g(this,Gi),t=g(this,zo),r=g(this,Oe).subarray(4,6),i=g(this,Oe).subarray(16,18),[o,s,l,c]=g(this,Ki),[d,u,f,h]=I(this,gh,Hv).call(this);if(isNaN(g(this,Oe)[6])&&!this.isEmpty())return`M${(g(this,Oe)[2]-o)/l} ${(g(this,Oe)[3]-s)/c} L${(g(this,Oe)[4]-o)/l} ${(g(this,Oe)[5]-s)/c} L${d} ${u} L${f} ${h} L${(g(this,Oe)[16]-o)/l} ${(g(this,Oe)[17]-s)/c} L${(g(this,Oe)[14]-o)/l} ${(g(this,Oe)[15]-s)/c} Z`;const p=[];p.push(`M${e[4]} ${e[5]}`);for(let m=6;m<e.length;m+=6)isNaN(e[m])?p.push(`L${e[m+4]} ${e[m+5]}`):p.push(`C${e[m]} ${e[m+1]} ${e[m+2]} ${e[m+3]} ${e[m+4]} ${e[m+5]}`);p.push(`L${(r[0]-o)/l} ${(r[1]-s)/c} L${d} ${u} L${f} ${h} L${(i[0]-o)/l} ${(i[1]-s)/c}`);for(let m=t.length-6;m>=6;m-=6)isNaN(t[m])?p.push(`L${t[m+4]} ${t[m+5]}`):p.push(`C${t[m]} ${t[m+1]} ${t[m+2]} ${t[m+3]} ${t[m+4]} ${t[m+5]}`);return p.push(`L${t[4]} ${t[5]} Z`),p.join(" ")}getOutlines(){var w;const e=g(this,Gi),t=g(this,zo),r=g(this,Oe),i=r.subarray(4,6),o=r.subarray(16,18),[s,l,c,d]=g(this,Ki),u=new Float64Array((((w=g(this,ya))==null?void 0:w.length)??0)+2);for(let v=0,k=u.length-2;v<k;v+=2)u[v]=(g(this,ya)[v]-s)/c,u[v+1]=(g(this,ya)[v+1]-l)/d;u[u.length-2]=(g(this,p0)-s)/c,u[u.length-1]=(g(this,m0)-l)/d;const[f,h,p,m]=I(this,gh,Hv).call(this);if(isNaN(r[6])&&!this.isEmpty()){const v=new Float64Array(36);return v.set([NaN,NaN,NaN,NaN,(r[2]-s)/c,(r[3]-l)/d,NaN,NaN,NaN,NaN,(r[4]-s)/c,(r[5]-l)/d,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(r[16]-s)/c,(r[17]-l)/d,NaN,NaN,NaN,NaN,(r[14]-s)/c,(r[15]-l)/d],0),new t6(v,u,g(this,Ki),g(this,jd),g(this,Vd),g(this,Fd))}const b=new Float64Array(g(this,Gi).length+24+g(this,zo).length);let y=e.length;for(let v=0;v<y;v+=2)isNaN(e[v])?b[v]=b[v+1]=NaN:(b[v]=e[v],b[v+1]=e[v+1]);b.set([NaN,NaN,NaN,NaN,(i[0]-s)/c,(i[1]-l)/d,NaN,NaN,NaN,NaN,f,h,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(o[0]-s)/c,(o[1]-l)/d],y),y+=24;for(let v=t.length-6;v>=6;v-=6)for(let k=0;k<6;k+=2)isNaN(t[v+k])?(b[y]=b[y+1]=NaN,y+=2):(b[y]=t[v+k],b[y+1]=t[v+k+1],y+=2);return b.set([NaN,NaN,NaN,NaN,t[4],t[5]],y),new t6(b,u,g(this,Ki),g(this,jd),g(this,Vd),g(this,Fd))}};Ki=new WeakMap,zo=new WeakMap,Vd=new WeakMap,Fd=new WeakMap,Gi=new WeakMap,Oe=new WeakMap,p0=new WeakMap,m0=new WeakMap,hh=new WeakMap,ph=new WeakMap,jd=new WeakMap,zd=new WeakMap,ya=new WeakMap,mh=new WeakMap,E5=new WeakMap,M5=new WeakMap,gh=new WeakSet,Hv=function(){const e=g(this,Oe).subarray(4,6),t=g(this,Oe).subarray(16,18),[r,i,o,s]=g(this,Ki);return[(g(this,p0)+(e[0]-t[0])/2-r)/o,(g(this,m0)+(e[1]-t[1])/2-i)/s,(g(this,p0)+(t[0]-e[0])/2-r)/o,(g(this,m0)+(t[1]-e[1])/2-i)/s]},E(Ho,mh,8),E(Ho,E5,2),E(Ho,M5,g(Ho,mh)+g(Ho,E5));let Cm=Ho;class t6 extends cM{constructor(t,r,i,o,s,l){super();E(this,y0);E(this,b0);E(this,A5);E(this,Hd,void 0);E(this,g0,null);E(this,Uo,void 0);E(this,yh,void 0);E(this,pr,void 0);E(this,bh,void 0);E(this,vt,void 0);A(this,vt,t),A(this,pr,r),A(this,Hd,i),A(this,bh,o),A(this,Uo,s),A(this,yh,l),I(this,A5,XN).call(this,l);const{x:c,y:d,width:u,height:f}=g(this,g0);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${g(this,vt)[4]} ${g(this,vt)[5]}`];for(let r=6,i=g(this,vt).length;r<i;r+=6)isNaN(g(this,vt)[r])?t.push(`L${g(this,vt)[r+4]} ${g(this,vt)[r+5]}`):t.push(`C${g(this,vt)[r]} ${g(this,vt)[r+1]} ${g(this,vt)[r+2]} ${g(this,vt)[r+3]} ${g(this,vt)[r+4]} ${g(this,vt)[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=I(this,y0,ip).call(this,g(this,vt),t,o,l,-c),u=I(this,y0,ip).call(this,g(this,pr),t,o,l,-c);break;case 90:d=I(this,b0,op).call(this,g(this,vt),t,r,l,c),u=I(this,b0,op).call(this,g(this,pr),t,r,l,c);break;case 180:d=I(this,y0,ip).call(this,g(this,vt),i,r,-l,c),u=I(this,y0,ip).call(this,g(this,pr),i,r,-l,c);break;case 270:d=I(this,b0,op).call(this,g(this,vt),i,o,-l,-c),u=I(this,b0,op).call(this,g(this,pr),i,o,-l,-c)}return{outline:Array.from(d),points:[Array.from(u)]}}get box(){return g(this,g0)}getNewOutline(t,r){const{x:i,y:o,width:s,height:l}=g(this,g0),[c,d,u,f]=g(this,Hd),h=s*u,p=l*f,m=i*u+c,b=o*f+d,y=new Cm({x:g(this,pr)[0]*h+m,y:g(this,pr)[1]*p+b},g(this,Hd),g(this,bh),t,g(this,yh),r??g(this,Uo));for(let w=2;w<g(this,pr).length;w+=2)y.add({x:g(this,pr)[w]*h+m,y:g(this,pr)[w+1]*p+b});return y.getOutlines()}}Hd=new WeakMap,g0=new WeakMap,Uo=new WeakMap,yh=new WeakMap,pr=new WeakMap,bh=new WeakMap,vt=new WeakMap,y0=new WeakSet,ip=function(t,r,i,o,s){const l=new Float64Array(t.length);for(let c=0,d=t.length;c<d;c+=2)l[c]=r+t[c]*o,l[c+1]=i+t[c+1]*s;return l},b0=new WeakSet,op=function(t,r,i,o,s){const l=new Float64Array(t.length);for(let c=0,d=t.length;c<d;c+=2)l[c]=r+t[c+1]*o,l[c+1]=i+t[c]*s;return l},A5=new WeakSet,XN=function(t){const r=g(this,vt);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 w=6,v=r.length;w<v;w+=6){if(isNaN(r[w]))s=Math.min(s,r[w+4]),l=Math.min(l,r[w+5]),c=Math.max(c,r[w+4]),d=Math.max(d,r[w+5]),f<r[w+5]?(u=r[w+4],f=r[w+5]):f===r[w+5]&&(u=h(u,r[w+4]));else{const k=ue.bezierBoundingBox(i,o,...r.slice(w,w+6));s=Math.min(s,k[0]),l=Math.min(l,k[1]),c=Math.max(c,k[2]),d=Math.max(d,k[3]),f<k[3]?(u=k[2],f=k[3]):f===k[3]&&(u=h(u,k[2]))}i=r[w+4],o=r[w+5]}const p=s-g(this,Uo),m=l-g(this,Uo),b=c-s+2*g(this,Uo),y=d-l+2*g(this,Uo);A(this,g0,{x:p,y:m,width:b,height:y,lastPoint:[u,f]})};const Wo=class Wo{constructor({editor:e=null,uiManager:t=null}){E(this,Eh);E(this,Mh);E(this,T5);E(this,Zo);E(this,I5);E(this,Yi);E(this,wh,I(this,T5,JN).bind(this));E(this,vh,I(this,I5,eP).bind(this));E(this,ci,null);E(this,w0,null);E(this,Ud,void 0);E(this,Dt,null);E(this,Ch,!1);E(this,Zd,!1);E(this,kh,null);E(this,Sh,void 0);E(this,di,null);E(this,Wd,void 0);var r;e?(A(this,Zd,!1),A(this,Wd,ye.HIGHLIGHT_COLOR),A(this,kh,e)):(A(this,Zd,!0),A(this,Wd,ye.HIGHLIGHT_DEFAULT_COLOR)),A(this,di,(e==null?void 0:e._uiManager)||t),A(this,Sh,g(this,di)._eventBus),A(this,Ud,(e==null?void 0:e.color)||((r=g(this,di))==null?void 0:r.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return Ne(this,"_keyboardManager",new p2([[["Escape","mac+Escape"],Wo.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Wo.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Wo.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Wo.prototype._moveToPrevious],[["Home","mac+Home"],Wo.prototype._moveToBeginning],[["End","mac+End"],Wo.prototype._moveToEnd]]))}renderButton(){const e=A(this,ci,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=g(this,di)._signal;e.addEventListener("click",I(this,Zo,$0).bind(this),{signal:t}),e.addEventListener("keydown",g(this,wh),{signal:t});const r=A(this,w0,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=g(this,Ud),e.append(r),e}renderMainDropdown(){const e=A(this,Dt,I(this,Eh,Uv).call(this));return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}_colorSelectFromKeyboard(e){if(e.target===g(this,ci)){I(this,Zo,$0).call(this,e);return}const t=e.target.getAttribute("data-color");t&&I(this,Mh,Zv).call(this,t,e)}_moveToNext(e){var t,r;g(this,Yi,Da)?e.target!==g(this,ci)?(t=e.target.nextSibling)==null||t.focus():(r=g(this,Dt).firstChild)==null||r.focus():I(this,Zo,$0).call(this,e)}_moveToPrevious(e){var t,r;e.target!==((t=g(this,Dt))==null?void 0:t.firstChild)&&e.target!==g(this,ci)?(g(this,Yi,Da)||I(this,Zo,$0).call(this,e),(r=e.target.previousSibling)==null||r.focus()):g(this,Yi,Da)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){var t;g(this,Yi,Da)?(t=g(this,Dt).firstChild)==null||t.focus():I(this,Zo,$0).call(this,e)}_moveToEnd(e){var t;g(this,Yi,Da)?(t=g(this,Dt).lastChild)==null||t.focus():I(this,Zo,$0).call(this,e)}hideDropdown(){var e;(e=g(this,Dt))==null||e.classList.add("hidden"),window.removeEventListener("pointerdown",g(this,vh))}_hideDropdownFromKeyboard(){var e;g(this,Zd)||(g(this,Yi,Da)?(this.hideDropdown(),g(this,ci).focus({preventScroll:!0,focusVisible:g(this,Ch)})):(e=g(this,kh))==null||e.unselect())}updateColor(e){if(g(this,w0)&&(g(this,w0).style.backgroundColor=e),!g(this,Dt))return;const t=g(this,di).highlightColors.values();for(const r of g(this,Dt).children)r.setAttribute("aria-selected",t.next().value===e)}destroy(){var e,t;(e=g(this,ci))==null||e.remove(),A(this,ci,null),A(this,w0,null),(t=g(this,Dt))==null||t.remove(),A(this,Dt,null)}};wh=new WeakMap,vh=new WeakMap,ci=new WeakMap,w0=new WeakMap,Ud=new WeakMap,Dt=new WeakMap,Ch=new WeakMap,Zd=new WeakMap,kh=new WeakMap,Sh=new WeakMap,di=new WeakMap,Wd=new WeakMap,Eh=new WeakSet,Uv=function(){const e=document.createElement("div"),t=g(this,di)._signal;e.addEventListener("contextmenu",kr,{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 g(this,di).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",`pdfjs-editor-colorpicker-${r}`);const s=document.createElement("span");o.append(s),s.className="swatch",s.style.backgroundColor=i,o.setAttribute("aria-selected",i===g(this,Ud)),o.addEventListener("click",I(this,Mh,Zv).bind(this,i),{signal:t}),e.append(o)}return e.addEventListener("keydown",g(this,wh),{signal:t}),e},Mh=new WeakSet,Zv=function(e,t){t.stopPropagation(),g(this,Sh).dispatch("switchannotationeditorparams",{source:this,type:g(this,Wd),value:e})},T5=new WeakSet,JN=function(e){Wo._keyboardManager.exec(this,e)},Zo=new WeakSet,$0=function(e){if(g(this,Yi,Da)){this.hideDropdown();return}if(A(this,Ch,e.detail===0),window.addEventListener("pointerdown",g(this,vh),{signal:g(this,di)._signal}),g(this,Dt)){g(this,Dt).classList.remove("hidden");return}const t=A(this,Dt,I(this,Eh,Uv).call(this));g(this,ci).append(t)},I5=new WeakSet,eP=function(e){var t;(t=g(this,Dt))!=null&&t.contains(e.target)||this.hideDropdown()},Yi=new WeakSet,Da=function(){return g(this,Dt)&&!g(this,Dt).classList.contains("hidden")};let km=Wo;const _e=class _e extends He{constructor(t){super({...t,name:"highlightEditor"});E(this,Oh);E(this,Dh);E(this,x5);E(this,O5);E(this,D5);E(this,Nh);E(this,S0);E(this,N5);E(this,Qd);E(this,E0);E(this,P5);E(this,L5);E(this,qd,null);E(this,Ah,0);E(this,ba,void 0);E(this,v0,null);E(this,Kd,null);E(this,$r,null);E(this,Th,null);E(this,Ih,0);E(this,C0,null);E(this,ui,null);E(this,On,null);E(this,mr,!1);E(this,Gd,null);E(this,k0,void 0);E(this,Nt,null);E(this,Yd,"");E(this,Qi,void 0);E(this,xh,"");this.color=t.color||_e._defaultColor,A(this,Qi,t.thickness||_e._defaultThickness),A(this,k0,t.opacity||_e._defaultOpacity),A(this,ba,t.boxes||null),A(this,xh,t.methodOfCreation||""),A(this,Yd,t.text||""),this._isDraggable=!1,t.highlightId>-1?(A(this,mr,!0),I(this,Dh,qv).call(this,t),I(this,S0,sp).call(this)):(A(this,qd,t.anchorNode),A(this,Ah,t.anchorOffset),A(this,Th,t.focusNode),A(this,Ih,t.focusOffset),I(this,Oh,Wv).call(this),I(this,S0,sp).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=_e.prototype;return Ne(this,"_keyboardManager",new p2([[["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:g(this,mr)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:g(this,Qi),methodOfCreation:g(this,xh)}}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;He.initialize(t,r),_e._defaultColor||(_e._defaultColor=((i=r.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,r){switch(t){case ye.HIGHLIGHT_DEFAULT_COLOR:_e._defaultColor=r;break;case ye.HIGHLIGHT_THICKNESS:_e._defaultThickness=r}}translateInPage(t,r){}get toolbarPosition(){return g(this,Gd)}updateParams(t,r){switch(t){case ye.HIGHLIGHT_COLOR:I(this,x5,tP).call(this,r);break;case ye.HIGHLIGHT_THICKNESS:I(this,O5,nP).call(this,r)}}static get defaultPropertiesToUpdate(){return[[ye.HIGHLIGHT_DEFAULT_COLOR,_e._defaultColor],[ye.HIGHLIGHT_THICKNESS,_e._defaultThickness]]}get propertiesToUpdate(){return[[ye.HIGHLIGHT_COLOR,this.color||_e._defaultColor],[ye.HIGHLIGHT_THICKNESS,g(this,Qi)||_e._defaultThickness],[ye.HIGHLIGHT_FREE,g(this,mr)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(A(this,Kd,new km({editor:this})),t.addColorPicker(g(this,Kd))),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,E0,ap).call(this))}getBaseTranslation(){return[0,0]}getRect(t,r){return super.getRect(t,r,I(this,E0,ap).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){I(this,Nh,Kv).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(I(this,S0,sp).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let r=!1;this.parent&&!t?I(this,Nh,Kv).call(this):t&&(I(this,S0,sp).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;g(this,mr)?(t=(t-this.rotation+360)%360,i=I(o=_e,wa,bu).call(o,g(this,ui).box,t)):i=I(s=_e,wa,bu).call(s,this,t),r.rotate(g(this,On),t),r.rotate(g(this,Nt),t),r.updateBox(g(this,On),i),r.updateBox(g(this,Nt),I(l=_e,wa,bu).call(l,g(this,$r).box,t))}render(){if(this.div)return this.div;const t=super.render();g(this,Yd)&&(t.setAttribute("aria-label",g(this,Yd)),t.setAttribute("role","mark")),g(this,mr)?t.classList.add("free"):this.div.addEventListener("keydown",I(this,N5,iP).bind(this),{signal:this._uiManager._signal});const r=A(this,C0,document.createElement("div"));t.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",r.style.clipPath=g(this,v0);const[i,o]=this.parentDimensions;return this.setDims(this.width*i,this.height*o),hm(this,g(this,C0),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(g(this,Nt),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(g(this,Nt),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:I(this,Qd,Cy).call(this,!0);break;case 1:case 3:I(this,Qd,Cy).call(this,!1)}}select(){var t,r;super.select(),g(this,Nt)&&((t=this.parent)==null||t.drawLayer.removeClass(g(this,Nt),"hovered"),(r=this.parent)==null||r.drawLayer.addClass(g(this,Nt),"selected"))}unselect(){var t;super.unselect(),g(this,Nt)&&((t=this.parent)==null||t.drawLayer.removeClass(g(this,Nt),"selected"),g(this,mr)||I(this,Qd,Cy).call(this,!1))}get _mustFixPosition(){return!g(this,mr)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(g(this,On),t),this.parent.drawLayer.show(g(this,Nt),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=m=>{f.abort(),I(this,_5,lP).call(this,t,m)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",m=>{m.preventDefault(),m.stopPropagation()},{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",kr,{signal:h}),i.addEventListener("pointermove",I(this,B5,aP).bind(this,t),{signal:h}),this._freeHighlight=new Cm({x:o,y:s},[l,c,d,u],t.scale,this._defaultThickness/2,r,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static deserialize(t,r,i){var b;const o=super.deserialize(t,r,i),{rect:[s,l,c,d],color:u,quadPoints:f}=t;o.color=ue.makeHexColor(...u),A(o,k0,t.opacity);const[h,p]=o.pageDimensions;o.width=(c-s)/h,o.height=(d-l)/p;const m=A(o,ba,[]);for(let y=0;y<f.length;y+=8)m.push({x:(f[4]-c)/h,y:(d-(1-f[y+5]))/p,width:(f[y+2]-f[y])/h,height:(f[y+5]-f[y+1])/p});return I(b=o,Oh,Wv).call(b),o}serialize(t=!1){if(this.isEmpty()||t)return null;const r=this.getRect(0,0),i=He._colorManager.convert(this.color);return{annotationType:xe.HIGHLIGHT,color:i,opacity:g(this,k0),thickness:g(this,Qi),quadPoints:I(this,P5,oP).call(this),outlines:I(this,L5,sP).call(this,r),pageIndex:this.pageIndex,rect:r,rotation:I(this,E0,ap).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};qd=new WeakMap,Ah=new WeakMap,ba=new WeakMap,v0=new WeakMap,Kd=new WeakMap,$r=new WeakMap,Th=new WeakMap,Ih=new WeakMap,C0=new WeakMap,ui=new WeakMap,On=new WeakMap,mr=new WeakMap,Gd=new WeakMap,k0=new WeakMap,Nt=new WeakMap,Yd=new WeakMap,Qi=new WeakMap,xh=new WeakMap,Oh=new WeakSet,Wv=function(){const t=new lM(g(this,ba),.001);A(this,ui,t.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=g(this,ui).box;const r=new lM(g(this,ba),.0025,.001,this._uiManager.direction==="ltr");A(this,$r,r.getOutlines());const{lastPoint:i}=g(this,$r).box;A(this,Gd,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Dh=new WeakSet,qv=function({highlightOutlines:t,highlightId:r,clipPathId:i}){var u,f;if(A(this,ui,t),A(this,$r,t.getNewOutline(g(this,Qi)/2+1.5,.0025)),r>=0)A(this,On,r),A(this,v0,i),this.parent.drawLayer.finalizeLine(r,t),A(this,Nt,this.parent.drawLayer.highlightOutline(g(this,$r)));else if(this.parent){const h=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(g(this,On),t),this.parent.drawLayer.updateBox(g(this,On),I(u=_e,wa,bu).call(u,g(this,ui).box,(h-this.rotation+360)%360)),this.parent.drawLayer.updateLine(g(this,Nt),g(this,$r)),this.parent.drawLayer.updateBox(g(this,Nt),I(f=_e,wa,bu).call(f,g(this,$r).box,h))}const{x:o,y:s,width:l,height: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}=g(this,$r).box;A(this,Gd,[(d[0]-o)/l,(d[1]-s)/c])},x5=new WeakSet,tP=function(t){const r=o=>{var s,l;this.color=o,(s=this.parent)==null||s.drawLayer.changeColor(g(this,On),o),(l=g(this,Kd))==null||l.updateColor(o)},i=this.color;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)},O5=new WeakSet,nP=function(t){const r=g(this,Qi),i=o=>{A(this,Qi,o),I(this,D5,rP).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:ye.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},D5=new WeakSet,rP=function(t){if(!g(this,mr))return;I(this,Dh,qv).call(this,{highlightOutlines:g(this,ui).getNewOutline(t/2)}),this.fixAndSetPosition();const[r,i]=this.parentDimensions;this.setDims(this.width*r,this.height*i)},Nh=new WeakSet,Kv=function(){g(this,On)!==null&&this.parent&&(this.parent.drawLayer.remove(g(this,On)),A(this,On,null),this.parent.drawLayer.remove(g(this,Nt)),A(this,Nt,null))},S0=new WeakSet,sp=function(t=this.parent){g(this,On)===null&&({id:Xn(this,On)._,clipPathId:Xn(this,v0)._}=t.drawLayer.highlight(g(this,ui),this.color,g(this,k0)),A(this,Nt,t.drawLayer.highlightOutline(g(this,$r))),g(this,C0)&&(g(this,C0).style.clipPath=g(this,v0)))},wa=new WeakSet,bu=function({x:t,y:r,width:i,height:o},s){switch(s){case 90:return{x:1-r-o,y:t,width:o,height:i};case 180:return{x:1-t-i,y:1-r-o,width:i,height:o};case 270:return{x:r,y:1-t-i,width:o,height:i}}return{x:t,y:r,width:i,height:o}},N5=new WeakSet,iP=function(t){_e._keyboardManager.exec(this,t)},Qd=new WeakSet,Cy=function(t){if(!g(this,qd))return;const r=window.getSelection();t?r.setPosition(g(this,qd),g(this,Ah)):r.setPosition(g(this,Th),g(this,Ih))},E0=new WeakSet,ap=function(){return g(this,mr)?this.rotation:0},P5=new WeakSet,oP=function(){if(g(this,mr))return null;const[t,r]=this.pageDimensions,[i,o]=this.pageTranslation,s=g(this,ba),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,m=(1-u-h)*r+o;l[c]=l[c+4]=p,l[c+1]=l[c+3]=m,l[c+2]=l[c+6]=p+f*t,l[c+5]=l[c+7]=m+h*r,c+=8}return l},L5=new WeakSet,sP=function(t){return g(this,ui).serialize(t,I(this,E0,ap).call(this))},B5=new WeakSet,aP=function(t,r){this._freeHighlight.add(r)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},_5=new WeakSet,lP=function(t,r){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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=""},E(_e,wa),E(_e,B5),E(_e,_5),be(_e,"_defaultColor",null),be(_e,"_defaultOpacity",1),be(_e,"_defaultThickness",12),be(_e,"_l10nPromise"),be(_e,"_type","highlight"),be(_e,"_editorType",xe.HIGHLIGHT),be(_e,"_freeHighlightId",-1),be(_e,"_freeHighlight",null),be(_e,"_freeHighlightClipId","");let Sm=_e;const et=class et extends He{constructor(t){super({...t,name:"inkEditor"});E(this,R5);E(this,$5);E(this,V5);E(this,F5);E(this,Ph);E(this,j5);E(this,Lh);E(this,z5);E(this,H5);E(this,U5);E(this,Z5);E(this,W5);E(this,Go);E(this,Bh);E(this,_h);E(this,Rh);E(this,Jd);E(this,eu);E(this,Ca);E(this,$h);E(this,tu);E(this,G5);E(this,Fh);E(this,nu);E(this,N0);E(this,M0,0);E(this,A0,0);E(this,Xi,null);E(this,qo,new Path2D);E(this,Vr,!1);E(this,T0,null);E(this,I0,!1);E(this,x0,!1);E(this,Ko,null);E(this,Xd,null);E(this,O0,0);E(this,D0,0);E(this,va,null);this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,r){He.initialize(t,r)}static updateDefaultParams(t,r){switch(t){case ye.INK_THICKNESS:et._defaultThickness=r;break;case ye.INK_COLOR:et._defaultColor=r;break;case ye.INK_OPACITY:et._defaultOpacity=r/100}}updateParams(t,r){switch(t){case ye.INK_THICKNESS:I(this,R5,cP).call(this,r);break;case ye.INK_COLOR:I(this,$5,dP).call(this,r);break;case ye.INK_OPACITY:I(this,V5,uP).call(this,r)}}static get defaultPropertiesToUpdate(){return[[ye.INK_THICKNESS,et._defaultThickness],[ye.INK_COLOR,et._defaultColor||He._defaultLineColor],[ye.INK_OPACITY,Math.round(100*et._defaultOpacity)]]}get propertiesToUpdate(){return[[ye.INK_THICKNESS,this.thickness||et._defaultThickness],[ye.INK_COLOR,this.color||et._defaultColor||He._defaultLineColor],[ye.INK_OPACITY,Math.round(100*(this.opacity??et._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(I(this,Jd,ky).call(this),I(this,eu,Sy).call(this)),this.isAttachedToDOM||(this.parent.add(this),I(this,Ca,wu).call(this)),I(this,N0,lp).call(this)))}remove(){var t;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,g(this,Xi)&&(clearTimeout(g(this,Xi)),A(this,Xi,null)),(t=g(this,Ko))==null||t.disconnect(),A(this,Ko,null),super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,r]=this.parentDimensions,i=this.width*t,o=this.height*r;this.setDimensions(i,o)}enableEditMode(){!g(this,Vr)&&this.canvas!==null&&(super.enableEditMode(),this._isDraggable=!1,I(this,Bh,Qv).call(this))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),I(this,_h,Xv).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){g(this,Vr)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,Vr,!0),this.div.classList.add("disabled"),I(this,N0,lp).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button===0&&this.isInEditMode()&&!g(this,Vr)&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),I(this,j5,hP).call(this,t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),I(this,Lh,Yv).call(this,t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),I(this,Rh,Jv).call(this,t)}canvasPointerleave(t){I(this,Rh,Jv).call(this,t)}get isResizable(){return!this.isEmpty()&&g(this,Vr)}render(){if(this.div)return this.div;let t,r;this.width&&(t=this.x,r=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,o,s,l]=I(this,F5,fP).call(this);if(this.setAt(i,o,0,0),this.setDims(s,l),I(this,Jd,ky).call(this),this.width){const[c,d]=this.parentDimensions;this.setAspectRatio(this.width*c,this.height*d),this.setAt(t*c,r*d,this.width*c,this.height*d),A(this,x0,!0),I(this,Ca,wu).call(this),this.setDims(this.width*c,this.height*d),I(this,Go,V0).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return I(this,eu,Sy).call(this),this.div}setDimensions(t,r){const i=Math.round(t),o=Math.round(r);if(g(this,O0)===i&&g(this,D0)===o)return;A(this,O0,i),A(this,D0,o),this.canvas.style.visibility="hidden";const[s,l]=this.parentDimensions;this.width=t/s,this.height=r/l,this.fixAndSetPosition(),g(this,Vr)&&I(this,$h,e8).call(this,t,r),I(this,Ca,wu).call(this),I(this,Go,V0).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(t,r,i){var y,w,v;if(t instanceof sM)return null;const o=super.deserialize(t,r,i);o.thickness=t.thickness,o.color=ue.makeHexColor(...t.color),o.opacity=t.opacity;const[s,l]=o.pageDimensions,c=o.width*s,d=o.height*l,u=o.parentScale,f=t.thickness/2;A(o,Vr,!0),A(o,O0,Math.round(c)),A(o,D0,Math.round(d));const{paths:h,rect:p,rotation:m}=t;for(let{bezier:k}of h){k=I(y=et,K5,vP).call(y,k,p,m);const C=[];o.paths.push(C);let T=u*(k[0]-f),S=u*(k[1]-f);for(let x=2,O=k.length;x<O;x+=6){const P=u*(k[x]-f),N=u*(k[x+1]-f),_=u*(k[x+2]-f),V=u*(k[x+3]-f),H=u*(k[x+4]-f),L=u*(k[x+5]-f);C.push([[T,S],[P,N],[_,V],[H,L]]),T=H,S=L}const M=I(this,q5,wP).call(this,C);o.bezierPath2D.push(M)}const b=I(w=o,Fh,n8).call(w);return A(o,A0,Math.max(He.MIN_SIZE,b[2]-b[0])),A(o,M0,Math.max(He.MIN_SIZE,b[3]-b[1])),I(v=o,$h,e8).call(v,c,d),o}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),r=He._colorManager.convert(this.ctx.strokeStyle);return{annotationType:xe.INK,color:r,thickness:this.thickness,opacity:this.opacity,paths:I(this,G5,CP).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};M0=new WeakMap,A0=new WeakMap,Xi=new WeakMap,qo=new WeakMap,Vr=new WeakMap,T0=new WeakMap,I0=new WeakMap,x0=new WeakMap,Ko=new WeakMap,Xd=new WeakMap,O0=new WeakMap,D0=new WeakMap,va=new WeakMap,R5=new WeakSet,cP=function(t){const r=o=>{this.thickness=o,I(this,N0,lp).call(this)},i=this.thickness;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},$5=new WeakSet,dP=function(t){const r=o=>{this.color=o,I(this,Go,V0).call(this)},i=this.color;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},V5=new WeakSet,uP=function(t){const r=o=>{this.opacity=o,I(this,Go,V0).call(this)};t/=100;const i=this.opacity;this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ye.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},F5=new WeakSet,fP=function(){const{parentRotation:t,parentDimensions:[r,i]}=this;switch(t){case 90:return[0,i,i,r];case 180:return[r,i,r,i];case 270:return[r,0,i,r];default:return[0,0,r,i]}},Ph=new WeakSet,Gv=function(){const{ctx:t,color:r,opacity:i,thickness:o,parentScale:s,scaleFactor:l}=this;t.lineWidth=o*s/l,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${r}${function(d){return Math.round(Math.min(255,Math.max(1,255*d))).toString(16).padStart(2,"0")}(i)}`},j5=new WeakSet,hP=function(t,r){this.canvas.addEventListener("contextmenu",kr,{signal:this._uiManager._signal}),I(this,_h,Xv).call(this),A(this,T0,new AbortController);const i=this._uiManager.combinedSignal(g(this,T0));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,g(this,x0)||(A(this,x0,!0),I(this,Ca,wu).call(this),this.thickness||(this.thickness=et._defaultThickness),this.color||(this.color=et._defaultColor||He._defaultLineColor),this.opacity??(this.opacity=et._defaultOpacity)),this.currentPath.push([t,r]),A(this,I0,!1),I(this,Ph,Gv).call(this),A(this,va,()=>{I(this,U5,gP).call(this),g(this,va)&&window.requestAnimationFrame(g(this,va))}),window.requestAnimationFrame(g(this,va))},Lh=new WeakSet,Yv=function(t,r){const[i,o]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&r===o)return;const s=this.currentPath;let l=g(this,qo);s.push([t,r]),A(this,I0,!0),s.length<=2?(l.moveTo(...s[0]),l.lineTo(t,r)):(s.length===3&&(A(this,qo,l=new Path2D),l.moveTo(...s[0])),I(this,Z5,yP).call(this,l,...s.at(-3),...s.at(-2),t,r))},z5=new WeakSet,pP=function(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);g(this,qo).lineTo(...t)},H5=new WeakSet,mP=function(t,r){A(this,va,null),t=Math.min(Math.max(t,0),this.canvas.width),r=Math.min(Math.max(r,0),this.canvas.height),I(this,Lh,Yv).call(this,t,r),I(this,z5,pP).call(this);let i;if(this.currentPath.length!==1)i=I(this,W5,bP).call(this);else{const l=[t,r];i=[[l,l.slice(),l.slice(),l]]}const o=g(this,qo),s=this.currentPath;this.currentPath=[],A(this,qo,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(s),this.paths.push(i),this.bezierPath2D.push(o),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(I(this,Jd,ky).call(this),I(this,eu,Sy).call(this)),I(this,N0,lp).call(this))},mustExec:!0})},U5=new WeakSet,gP=function(){if(!g(this,I0))return;A(this,I0,!1),Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),r=t.map(s=>s[0]),i=t.map(s=>s[1]),{ctx:o}=(Math.min(...r),Math.max(...r),Math.min(...i),Math.max(...i),this);o.save(),o.clearRect(0,0,this.canvas.width,this.canvas.height);for(const s of this.bezierPath2D)o.stroke(s);o.stroke(g(this,qo)),o.restore()},Z5=new WeakSet,yP=function(t,r,i,o,s,l,c){const d=(r+o)/2,u=(i+s)/2,f=(o+l)/2,h=(s+c)/2;t.bezierCurveTo(d+2*(o-d)/3,u+2*(s-u)/3,f+2*(o-f)/3,h+2*(s-h)/3,f,h)},W5=new WeakSet,bP=function(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const r=[];let i,[o,s]=t[0];for(i=1;i<t.length-2;i++){const[p,m]=t[i],[b,y]=t[i+1],w=(p+b)/2,v=(m+y)/2,k=[o+2*(p-o)/3,s+2*(m-s)/3],C=[w+2*(p-w)/3,v+2*(m-v)/3];r.push([[o,s],k,C,[w,v]]),[o,s]=[w,v]}const[l,c]=t[i],[d,u]=t[i+1],f=[o+2*(l-o)/3,s+2*(c-s)/3],h=[d+2*(l-d)/3,u+2*(c-u)/3];return r.push([[o,s],f,h,[d,u]]),r},Go=new WeakSet,V0=function(){if(this.isEmpty()){I(this,tu,Ey).call(this);return}I(this,Ph,Gv).call(this);const{canvas:t,ctx:r}=this;r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,t.width,t.height),I(this,tu,Ey).call(this);for(const i of this.bezierPath2D)r.stroke(i)},Bh=new WeakSet,Qv=function(){if(g(this,Xd))return;A(this,Xd,new AbortController);const t=this._uiManager.combinedSignal(g(this,Xd));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:t})},_h=new WeakSet,Xv=function(){var t;(t=this.pointerdownAC)==null||t.abort(),this.pointerdownAC=null},Rh=new WeakSet,Jv=function(t){var r;(r=g(this,T0))==null||r.abort(),A(this,T0,null),I(this,Bh,Qv).call(this),g(this,Xi)&&clearTimeout(g(this,Xi)),A(this,Xi,setTimeout(()=>{A(this,Xi,null),this.canvas.removeEventListener("contextmenu",kr)},10)),I(this,H5,mP).call(this,t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Jd=new WeakSet,ky=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},eu=new WeakSet,Sy=function(){A(this,Ko,new ResizeObserver(t=>{const r=t[0].contentRect;r.width&&r.height&&this.setDimensions(r.width,r.height)})),g(this,Ko).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=g(this,Ko))==null||t.disconnect(),A(this,Ko,null)},{once:!0})},Ca=new WeakSet,wu=function(){if(!g(this,x0))return;const[t,r]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*r),I(this,tu,Ey).call(this)},$h=new WeakSet,e8=function(t,r){const i=I(this,nu,My).call(this),o=(t-i)/g(this,A0),s=(r-i)/g(this,M0);this.scaleFactor=Math.min(o,s)},tu=new WeakSet,Ey=function(){const t=I(this,nu,My).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)},q5=new WeakSet,wP=function(t){const r=new Path2D;for(let i=0,o=t.length;i<o;i++){const[s,l,c,d]=t[i];i===0&&r.moveTo(...s),r.bezierCurveTo(l[0],l[1],c[0],c[1],d[0],d[1])}return r},Vh=new WeakSet,t8=function(t,r,i){const[o,s,l,c]=r;switch(i){case 0:for(let d=0,u=t.length;d<u;d+=2)t[d]+=o,t[d+1]=c-t[d+1];break;case 90:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=t[d+1]+o,t[d+1]=f+s}break;case 180:for(let d=0,u=t.length;d<u;d+=2)t[d]=l-t[d],t[d+1]+=s;break;case 270:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=l-t[d+1],t[d+1]=c-f}break;default:throw new Error("Invalid rotation")}return t},K5=new WeakSet,vP=function(t,r,i){const[o,s,l,c]=r;switch(i){case 0:for(let d=0,u=t.length;d<u;d+=2)t[d]-=o,t[d+1]=c-t[d+1];break;case 90:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=t[d+1]-s,t[d+1]=f-o}break;case 180:for(let d=0,u=t.length;d<u;d+=2)t[d]=l-t[d],t[d+1]-=s;break;case 270:for(let d=0,u=t.length;d<u;d+=2){const f=t[d];t[d]=c-t[d+1],t[d+1]=l-f}break;default:throw new Error("Invalid rotation")}return t},G5=new WeakSet,CP=function(t,r,i,o){var u,f;const s=[],l=this.thickness/2,c=t*r+l,d=t*i+l;for(const h of this.paths){const p=[],m=[];for(let b=0,y=h.length;b<y;b++){const[w,v,k,C]=h[b];if(w[0]===C[0]&&w[1]===C[1]&&y===1){const V=t*w[0]+c,H=t*w[1]+d;p.push(V,H),m.push(V,H);break}const T=t*w[0]+c,S=t*w[1]+d,M=t*v[0]+c,x=t*v[1]+d,O=t*k[0]+c,P=t*k[1]+d,N=t*C[0]+c,_=t*C[1]+d;b===0&&(p.push(T,S),m.push(T,S)),p.push(M,x,O,P,N,_),m.push(M,x),b===y-1&&m.push(N,_)}s.push({bezier:I(u=et,Vh,t8).call(u,p,o,this.rotation),points:I(f=et,Vh,t8).call(f,m,o,this.rotation)})}return s},Fh=new WeakSet,n8=function(){let t=1/0,r=-1/0,i=1/0,o=-1/0;for(const s of this.paths)for(const[l,c,d,u]of s){const f=ue.bezierBoundingBox(...l,...c,...d,...u);t=Math.min(t,f[0]),i=Math.min(i,f[1]),r=Math.max(r,f[2]),o=Math.max(o,f[3])}return[t,i,r,o]},nu=new WeakSet,My=function(){return g(this,Vr)?Math.ceil(this.thickness*this.parentScale):0},N0=new WeakSet,lp=function(t=!1){if(this.isEmpty())return;if(!g(this,Vr)){I(this,Go,V0).call(this);return}const r=I(this,Fh,n8).call(this),i=I(this,nu,My).call(this);A(this,A0,Math.max(He.MIN_SIZE,r[2]-r[0])),A(this,M0,Math.max(He.MIN_SIZE,r[3]-r[1]));const o=Math.ceil(i+g(this,A0)*this.scaleFactor),s=Math.ceil(i+g(this,M0)*this.scaleFactor),[l,c]=this.parentDimensions;this.width=o/l,this.height=s/c,this.setAspectRatio(o,s);const d=this.translationX,u=this.translationY;this.translationX=-r[0],this.translationY=-r[1],I(this,Ca,wu).call(this),I(this,Go,V0).call(this),A(this,O0,o),A(this,D0,s),this.setDims(o,s);const f=t?i/this.scaleFactor/2:0;this.translate(d-this.translationX-f,u-this.translationY-f)},E(et,q5),E(et,Vh),E(et,K5),be(et,"_defaultColor",null),be(et,"_defaultOpacity",1),be(et,"_defaultThickness",1),be(et,"_type","ink"),be(et,"_editorType",xe.INK);let n6=et;const Zh=class Zh extends He{constructor(t){super({...t,name:"stampEditor"});E(this,P0);E(this,L0);E(this,iu);E(this,zh);E(this,Y5);E(this,Hh);E(this,Uh);E(this,ou);E(this,Q5);E(this,Ct,null);E(this,an,null);E(this,ka,null);E(this,Yo,null);E(this,Sa,null);E(this,ru,"");E(this,Ji,null);E(this,Qo,null);E(this,eo,null);E(this,Fr,!1);E(this,jh,!1);A(this,Yo,t.bitmapUrl),A(this,Sa,t.bitmapFile)}static initialize(t,r){He.initialize(t,r)}static get supportedTypes(){return Ne(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return Ne(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,r){r.pasteEditor(xe.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,!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,r;g(this,an)&&(A(this,Ct,null),this._uiManager.imageManager.deleteId(g(this,an)),(t=g(this,Ji))==null||t.remove(),A(this,Ji,null),(r=g(this,Qo))==null||r.disconnect(),A(this,Qo,null),g(this,eo)&&(clearTimeout(g(this,eo)),A(this,eo,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(g(this,an)&&g(this,Ji)===null&&I(this,iu,Ay).call(this),this.isAttachedToDOM||this.parent.add(this))):g(this,an)&&I(this,iu,Ay).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(g(this,ka)||g(this,Ct)||g(this,Yo)||g(this,Sa)||g(this,an))}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.addAltTextButton(),g(this,Ct)?I(this,zh,r8).call(this):I(this,iu,Ay).call(this),this.width){const[i,o]=this.parentDimensions;this.setAt(t*i,r*o,this.width*i,this.height*o)}return this.div}copyCanvas(t,r=!1){var y;t||(t=224);const{width:i,height:o}=g(this,Ct),s=document.createElement("canvas");let l=g(this,Ct),c=i,d=o;if(i>t||o>t){const w=Math.min(t/i,t/o);c=Math.floor(i*w),d=Math.floor(o*w),g(this,Fr)||(l=I(this,Hh,i8).call(this,c,d))}s.width=c,s.height=d;const u=s.getContext("2d");u.filter=this._uiManager.hcmFilter;let f="white",h="#cfcfd8";this._uiManager.hcmFilter!=="none"?h="black":(y=window.matchMedia)!=null&&y.call(window,"(prefers-color-scheme: dark)").matches&&(f="#8f8f9d",h="#42414d");const p=15,m=new OffscreenCanvas(30,30),b=m.getContext("2d");if(b.fillStyle=f,b.fillRect(0,0,30,30),b.fillStyle=h,b.fillRect(0,0,p,p),b.fillRect(p,p,p,p),u.fillStyle=u.createPattern(m,"repeat"),u.fillRect(0,0,c,d),r){const w=new OffscreenCanvas(c,d),v=w.getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,c,d);const k=v.getImageData(0,0,c,d).data;return u.drawImage(w,0,0),{canvas:s,imageData:{width:c,height:d,data:k}}}return u.drawImage(l,0,0,l.width,l.height,0,0,c,d),{canvas:s,imageData:null}}getImageForAltText(){return g(this,Ji)}static deserialize(t,r,i){if(t instanceof aM)return null;const o=super.deserialize(t,r,i),{rect:s,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:u}=t;c&&i.imageManager.isValidId(c)?A(o,an,c):A(o,Yo,l),A(o,Fr,d);const[f,h]=o.pageDimensions;return o.width=(s[2]-s[0])/f,o.height=(s[3]-s[1])/h,u&&(o.altTextData=u),o}serialize(t=!1,r=null){if(this.isEmpty())return null;const i={annotationType:xe.STAMP,bitmapId:g(this,an),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:g(this,Fr),structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=I(this,ou,Ty).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}),r===null)return i;r.stamps||(r.stamps=new Map);const l=g(this,Fr)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(r.stamps.has(g(this,an))){if(g(this,Fr)){const c=r.stamps.get(g(this,an));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=I(this,ou,Ty).call(this,!1))}}else r.stamps.set(g(this,an),{area:l,serialized:i}),i.bitmap=I(this,ou,Ty).call(this,!1);return i}};Ct=new WeakMap,an=new WeakMap,ka=new WeakMap,Yo=new WeakMap,Sa=new WeakMap,ru=new WeakMap,Ji=new WeakMap,Qo=new WeakMap,eo=new WeakMap,Fr=new WeakMap,jh=new WeakMap,P0=new WeakSet,cp=function(t,r=!1){t?(A(this,Ct,t.bitmap),r||(A(this,an,t.id),A(this,Fr,t.isSvg)),t.file&&A(this,ru,t.file.name),I(this,zh,r8).call(this)):this.remove()},L0=new WeakSet,dp=function(){if(A(this,ka,null),this._uiManager.enableWaiting(!1),g(this,Ji))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&g(this,Ct))this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&g(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},iu=new WeakSet,Ay=function(){if(g(this,an)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(g(this,an)).then(i=>I(this,P0,cp).call(this,i,!0)).finally(()=>I(this,L0,dp).call(this));return}if(g(this,Yo)){const i=g(this,Yo);A(this,Yo,null),this._uiManager.enableWaiting(!0),A(this,ka,this._uiManager.imageManager.getFromUrl(i).then(o=>I(this,P0,cp).call(this,o)).finally(()=>I(this,L0,dp).call(this)));return}if(g(this,Sa)){const i=g(this,Sa);A(this,Sa,null),this._uiManager.enableWaiting(!0),A(this,ka,this._uiManager.imageManager.getFromFile(i).then(o=>I(this,P0,cp).call(this,o)).finally(()=>I(this,L0,dp).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=Zh.supportedTypesStr;const r=this._uiManager._signal;A(this,ka,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,P0,cp).call(this,o)}else this.remove();i()},{signal:r}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:r})}).finally(()=>I(this,L0,dp).call(this))),t.click()},zh=new WeakSet,r8=function(){const{div:t}=this;let{width:r,height:i}=g(this,Ct);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 f=Math.min(l*o/r,l*s/i);r*=f,i*=f}const[c,d]=this.parentDimensions;this.setDims(r*c/o,i*d/s),this._uiManager.enableWaiting(!1);const u=A(this,Ji,document.createElement("canvas"));t.append(u),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow||(t.hidden=!1),I(this,Uh,o8).call(this,r,i),I(this,Q5,SP).call(this),g(this,jh)||(this.parent.addUndoableEditor(this),A(this,jh,!0)),this._reportTelemetry({action:"inserted_image"}),g(this,ru)&&u.setAttribute("aria-label",g(this,ru))},Y5=new WeakSet,kP=function(t,r){var s;const[i,o]=this.parentDimensions;this.width=t/i,this.height=r/o,this.setDims(t,r),(s=this._initialOptions)!=null&&s.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,g(this,eo)!==null&&clearTimeout(g(this,eo)),A(this,eo,setTimeout(()=>{A(this,eo,null),I(this,Uh,o8).call(this,t,r)},200))},Hh=new WeakSet,i8=function(t,r){const{width:i,height:o}=g(this,Ct);let s=i,l=o,c=g(this,Ct);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},Uh=new WeakSet,o8=function(t,r){t=Math.ceil(t),r=Math.ceil(r);const i=g(this,Ji);if(!i||i.width===t&&i.height===r)return;i.width=t,i.height=r;const o=g(this,Fr)?g(this,Ct):I(this,Hh,i8).call(this,t,r),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(o,0,0,o.width,o.height,0,0,t,r)},ou=new WeakSet,Ty=function(t){if(t){if(g(this,Fr)){const i=this._uiManager.imageManager.getSvgUrl(g(this,an));if(i)return i}const r=document.createElement("canvas");return{width:r.width,height:r.height}=g(this,Ct),r.getContext("2d").drawImage(g(this,Ct),0,0),r.toDataURL()}if(g(this,Fr)){const[r,i]=this.pageDimensions,o=Math.round(this.width*r*ms.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*ms.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(o,s);return l.getContext("2d").drawImage(g(this,Ct),0,0,g(this,Ct).width,g(this,Ct).height,0,0,o,s),l.transferToImageBitmap()}return structuredClone(g(this,Ct))},Q5=new WeakSet,SP=function(){this._uiManager._signal&&(A(this,Qo,new ResizeObserver(t=>{const r=t[0].contentRect;r.width&&r.height&&I(this,Y5,kP).call(this,r.width,r.height)})),g(this,Qo).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var t;(t=g(this,Qo))==null||t.disconnect(),A(this,Qo,null)},{once:!0}))},be(Zh,"_type","stamp"),be(Zh,"_editorType",xe.STAMP);let r6=Zh;const fi=class fi{constructor({uiManager:e,pageIndex:t,div:r,accessibilityManager:i,annotationLayer:o,drawLayer:s,textLayer:l,viewport:c,l10n:d}){E(this,X5);E(this,Wh);E(this,qh);E(this,Kh);E(this,cu);E(this,B0,void 0);E(this,su,!1);E(this,to,null);E(this,Ea,null);E(this,Xo,null);E(this,gr,new Map);E(this,Ma,!1);E(this,au,!1);E(this,lu,!1);E(this,Dn,null);E(this,Jo,null);E(this,fe,void 0);const u=[...g(fi,Aa).values()];if(!fi._initialized){fi._initialized=!0;for(const f of u)f.initialize(d,e)}e.registerEditorTypes(u),A(this,fe,e),this.pageIndex=t,this.div=r,A(this,B0,i),A(this,to,o),this.viewport=c,A(this,Dn,l),this.drawLayer=s,g(this,fe).addLayer(this)}get isEmpty(){return g(this,gr).size===0}get isInvisible(){return this.isEmpty&&g(this,fe).getMode()===xe.NONE}updateToolbar(e){g(this,fe).updateToolbar(e)}updateMode(e=g(this,fe).getMode()){switch(I(this,cu,Iy).call(this),e){case xe.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case xe.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case xe.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 g(fi,Aa).values())t.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=g(this,Dn))==null?void 0:t.div)}addInkEditorIfNeeded(e){if(g(this,fe).getMode()===xe.INK){if(!e){for(const t of g(this,gr).values())if(t.isEmpty()){t.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){g(this,fe).setEditingState(e)}addCommands(e){g(this,fe).addCommands(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=g(this,to))==null||t.div.classList.toggle("disabled",!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const r of g(this,gr).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(g(this,fe).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!g(this,to))return;const t=g(this,to).getEditableAnnotations();for(const r of t){if(r.hide(),g(this,fe).isDeletedAnnotationElement(r.data.id)||e.has(r.data.id))continue;const i=this.deserialize(r);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;A(this,lu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const o of g(this,gr).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(g(this,to)){const o=g(this,to).getEditableAnnotations();for(const s of o){const{id:l}=s.data;if(g(this,fe).isDeletedAnnotationElement(l))continue;let c=t.get(l);c?(c.resetAnnotationElement(s),c.show(!1),s.show()):(c=e.get(l),c&&(g(this,fe).addChangedExistingAnnotation(c),c.renderAnnotationElement(s),c.show(!1)),s.show())}}I(this,cu,Iy).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:r}=this.div;for(const o of g(fi,Aa).values())r.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,lu,!1)}getEditableAnnotation(e){var t;return((t=g(this,to))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){g(this,fe).getActive()!==e&&g(this,fe).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=g(this,Dn))!=null&&e.div&&!g(this,Jo)){A(this,Jo,new AbortController);const t=g(this,fe).combinedSignal(g(this,Jo));g(this,Dn).div.addEventListener("pointerdown",I(this,X5,EP).bind(this),{signal:t}),g(this,Dn).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=g(this,Dn))!=null&&e.div&&g(this,Jo)&&(g(this,Jo).abort(),A(this,Jo,null),g(this,Dn).div.classList.remove("highlighting"))}enableClick(){if(g(this,Ea))return;A(this,Ea,new AbortController);const e=g(this,fe).combinedSignal(g(this,Ea));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:e})}disableClick(){var e;(e=g(this,Ea))==null||e.abort(),A(this,Ea,null)}attach(e){g(this,gr).set(e.id,e);const{annotationElementId:t}=e;t&&g(this,fe).isDeletedAnnotationElement(t)&&g(this,fe).removeDeletedAnnotationElement(e)}detach(e){var t;g(this,gr).delete(e.id),(t=g(this,B0))==null||t.removePointerInTextLayer(e.contentDiv),!g(this,lu)&&e.annotationElementId&&g(this,fe).addDeletedAnnotationElement(e)}remove(e){this.detach(e),g(this,fe).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,g(this,au)||this.addInkEditorIfNeeded(!1)}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(g(this,fe).addDeletedAnnotationElement(e.annotationElementId),He.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),g(this,fe).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),g(this,fe).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var r;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!g(this,Xo)&&(e._focusEventsAllowed=!1,A(this,Xo,setTimeout(()=>{A(this,Xo,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:g(this,fe)._signal}),t.focus())},0))),e._structTreeParentId=(r=g(this,B0))==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 g(this,fe).getId()}combinedSignal(e){return g(this,fe).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=g(this,Wh,s8))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){g(this,fe).updateToolbar(e),g(this,fe).updateMode(e);const{offsetX:r,offsetY:i}=I(this,Kh,l8).call(this),o=this.getNextId(),s=I(this,qh,a8).call(this,{parent:this,id:o,x:r,y:i,uiManager:g(this,fe),isCentered:!0,...t});s&&this.add(s)}deserialize(e){var t;return((t=g(fi,Aa).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,g(this,fe)))||null}createAndAddNewEditor(e,t,r={}){const i=this.getNextId(),o=I(this,qh,a8).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:g(this,fe),isCentered:t,...r});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(I(this,Kh,l8).call(this),!0)}setSelected(e){g(this,fe).setSelected(e)}toggleSelected(e){g(this,fe).toggleSelected(e)}isSelected(e){return g(this,fe).isSelected(e)}unselect(e){g(this,fe).unselect(e)}pointerup(e){const{isMac:t}=jn.platform;!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&g(this,Ma)&&(A(this,Ma,!1),g(this,su)?g(this,fe).getMode()!==xe.STAMP?this.createAndAddNewEditor(e,!1):g(this,fe).unselectAll():A(this,su,!0))}pointerdown(e){if(g(this,fe).getMode()===xe.HIGHLIGHT&&this.enableTextSelection(),g(this,Ma)){A(this,Ma,!1);return}const{isMac:t}=jn.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;A(this,Ma,!0);const r=g(this,fe).getActive();A(this,su,!r||r.isEmpty())}findNewParent(e,t,r){const i=g(this,fe).findParent(t,r);return i===null||i===this?!1:(i.changeParent(e),!0)}destroy(){var e,t;((e=g(this,fe).getActive())==null?void 0:e.parent)===this&&(g(this,fe).commitOrRemove(),g(this,fe).setActiveEditor(null)),g(this,Xo)&&(clearTimeout(g(this,Xo)),A(this,Xo,null));for(const r of g(this,gr).values())(t=g(this,B0))==null||t.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,g(this,gr).clear(),g(this,fe).removeLayer(this)}render({viewport:e}){this.viewport=e,Ga(this.div,e);for(const t of g(this,fe).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){g(this,fe).commitOrRemove(),I(this,cu,Iy).call(this);const t=this.viewport.rotation,r=e.rotation;if(this.viewport=e,Ga(this.div,{rotation:r}),t!==r)for(const i of g(this,gr).values())i.rotate(r);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return g(this,fe).viewParameters.realScale}};B0=new WeakMap,su=new WeakMap,to=new WeakMap,Ea=new WeakMap,Xo=new WeakMap,gr=new WeakMap,Ma=new WeakMap,au=new WeakMap,lu=new WeakMap,Dn=new WeakMap,Jo=new WeakMap,fe=new WeakMap,Aa=new WeakMap,X5=new WeakSet,EP=function(e){g(this,fe).unselectAll();const{target:t}=e;if(t===g(this,Dn).div||t.classList.contains("endOfContent")&&g(this,Dn).div.contains(t)){const{isMac:r}=jn.platform;if(e.button!==0||e.ctrlKey&&r)return;g(this,fe).showAllEditors("highlight",!0,!0),g(this,Dn).div.classList.add("free"),this.toggleDrawing(),Sm.startHighlighting(this,g(this,fe).direction==="ltr",e),g(this,Dn).div.addEventListener("pointerup",()=>{g(this,Dn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:g(this,fe)._signal}),e.preventDefault()}},Wh=new WeakSet,s8=function(){return g(fi,Aa).get(g(this,fe).getMode())},qh=new WeakSet,a8=function(e){const t=g(this,Wh,s8);return t?new t.prototype.constructor(e):null},Kh=new WeakSet,l8=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}},cu=new WeakSet,Iy=function(){A(this,au,!0);for(const e of g(this,gr).values())e.isEmpty()&&e.remove();A(this,au,!1)},be(fi,"_initialized",!1),E(fi,Aa,new Map([e6,n6,r6,Sm].map(e=>[e._editorType,e])));let i6=fi;const ln=class ln{constructor({pageIndex:e}){E(this,Qh);E(this,J5);E(this,no,null);E(this,Gh,0);E(this,Pt,new Map);E(this,Ta,new Map);this.pageIndex=e}setParent(e){if(g(this,no)){if(g(this,no)!==e){if(g(this,Pt).size>0)for(const t of g(this,Pt).values())t.remove(),e.append(t);A(this,no,e)}}else A(this,no,e)}static get _svgFactory(){return Ne(this,"_svgFactory",new Nb)}highlight(e,t,r,i=!1){const o=Xn(this,Gh)._++,s=I(this,Qh,d8).call(this,e.box);s.classList.add("highlight"),e.free&&s.classList.add("free");const l=ln._svgFactory.createElement("defs");s.append(l);const c=ln._svgFactory.createElement("path");l.append(c);const d=`path_p${this.pageIndex}_${o}`;c.setAttribute("id",d),c.setAttribute("d",e.toSVGPath()),i&&g(this,Ta).set(o,c);const u=I(this,J5,MP).call(this,l,d),f=ln._svgFactory.createElement("use");return s.append(f),s.setAttribute("fill",t),s.setAttribute("fill-opacity",r),f.setAttribute("href",`#${d}`),g(this,Pt).set(o,s),{id:o,clipPathId:`url(#${u})`}}highlightOutline(e){const t=Xn(this,Gh)._++,r=I(this,Qh,d8).call(this,e.box);r.classList.add("highlightOutline");const i=ln._svgFactory.createElement("defs");r.append(i);const o=ln._svgFactory.createElement("path");i.append(o);const s=`path_p${this.pageIndex}_${t}`;o.setAttribute("id",s),o.setAttribute("d",e.toSVGPath()),o.setAttribute("vector-effect","non-scaling-stroke");let l;if(e.free){r.classList.add("free");const u=ln._svgFactory.createElement("mask");i.append(u),l=`mask_p${this.pageIndex}_${t}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const f=ln._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const h=ln._svgFactory.createElement("use");u.append(h),h.setAttribute("href",`#${s}`),h.setAttribute("stroke","none"),h.setAttribute("fill","black"),h.setAttribute("fill-rule","nonzero"),h.classList.add("mask")}const c=ln._svgFactory.createElement("use");r.append(c),c.setAttribute("href",`#${s}`),l&&c.setAttribute("mask",`url(#${l})`);const d=c.cloneNode();return r.append(d),c.classList.add("mainOutline"),d.classList.add("secondaryOutline"),g(this,Pt).set(t,r),t}finalizeLine(e,t){const r=g(this,Ta).get(e);g(this,Ta).delete(e),this.updateBox(e,t.box),r.setAttribute("d",t.toSVGPath())}updateLine(e,t){g(this,Pt).get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}removeFreeHighlight(e){this.remove(e),g(this,Ta).delete(e)}updatePath(e,t){g(this,Ta).get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){var r;I(r=ln,Yh,c8).call(r,g(this,Pt).get(e),t)}show(e,t){g(this,Pt).get(e).classList.toggle("hidden",!t)}rotate(e,t){g(this,Pt).get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){g(this,Pt).get(e).setAttribute("fill",t)}changeOpacity(e,t){g(this,Pt).get(e).setAttribute("fill-opacity",t)}addClass(e,t){g(this,Pt).get(e).classList.add(t)}removeClass(e,t){g(this,Pt).get(e).classList.remove(t)}remove(e){g(this,no)!==null&&(g(this,Pt).get(e).remove(),g(this,Pt).delete(e))}destroy(){A(this,no,null);for(const e of g(this,Pt).values())e.remove();g(this,Pt).clear()}};no=new WeakMap,Gh=new WeakMap,Pt=new WeakMap,Ta=new WeakMap,Yh=new WeakSet,c8=function(e,{x:t=0,y:r=0,width:i=1,height:o=1}={}){const{style:s}=e;s.top=100*r+"%",s.left=100*t+"%",s.width=100*i+"%",s.height=100*o+"%"},Qh=new WeakSet,d8=function(e){var r;const t=ln._svgFactory.create(1,1,!0);return g(this,no).append(t),t.setAttribute("aria-hidden",!0),I(r=ln,Yh,c8).call(r,t,e),t},J5=new WeakSet,MP=function(e,t){const r=ln._svgFactory.createElement("clipPath");e.append(r);const i=`clip_${t}`;r.setAttribute("id",i),r.setAttribute("clipPathUnits","objectBoundingBox");const o=ln._svgFactory.createElement("use");return r.append(o),o.setAttribute("href",`#${t}`),o.classList.add("clip"),i},E(ln,Yh);let o6=ln;ve.AbortException,ve.AnnotationEditorLayer,ve.AnnotationEditorParamsType,ve.AnnotationEditorType,ve.AnnotationEditorUIManager,ve.AnnotationLayer,ve.AnnotationMode,ve.CMapCompressionType,ve.ColorPicker,ve.DOMSVGFactory,ve.DrawLayer,ve.FeatureTest;var wW=ve.GlobalWorkerOptions;ve.ImageKind,ve.InvalidPDFException,ve.MissingPDFException,ve.OPS,ve.PDFDataRangeTransport,ve.PDFDateString,ve.PDFWorker,ve.PasswordResponses,ve.PermissionFlag,ve.PixelsPerInch,ve.RenderingCancelledException,ve.TextLayer,ve.UnexpectedResponseException,ve.Util,ve.VerbosityLevel,ve.XfaLayer,ve.build,ve.createValidAbsoluteUrl,ve.fetchData;var vW=ve.getDocument;ve.getFilenameFromUrl,ve.getPdfFilenameFromUrl,ve.getXfaPageViewport,ve.isDataScheme,ve.isPdfFile,ve.noContextMenu,ve.normalizeUnicode,ve.setLayerDimensions,ve.shadow;var CW=ve.version;const kW=a.defineComponent({name:"QModal",components:{QIcon:Ra},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 SW(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 s6=me(kW,[["render",SW],["__scopeId","data-v-8867a052"]]),EW=a.defineComponent({name:"QErrorModal",components:{QModal:s6},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:Qt}}}),MW={class:"flex flex-col gap-2 text-center"},AW={class:"text-lg font-bold text-inkwell-30 leading-6"},TW={class:"text-inkwell-0 mb-2 md:mb-6"};function IW(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]","footer-class":"mt-2 md:mt-6",onClose:e[1]||(e[1]=u=>n.toggleModal=!1)},{default:a.withCtx(()=>[a.createVNode(c,null,{body:a.withCtx(()=>[a.createElementVNode("div",MW,[a.createVNode(s,{icon:"exclamation-circle",type:"outline",size:"xl",color:"red-30",class:"shrink-0 self-center mb-8"}),a.createElementVNode("h2",AW,[a.renderSlot(n.$slots,"headline",{},()=>[a.createTextVNode(a.toDisplayString(n.$t("HC_ERROR")),1)],!0)]),a.createElementVNode("p",TW,[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 dM=me(EW,[["render",IW],["__scopeId","data-v-72f5c09d"]]);wW.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${CW}/legacy/build/pdf.worker.min.mjs`;const xW=a.defineComponent({name:"PdfViewer",components:{QErrorModal:dM},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 vW(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}}}),OW={class:"q-pdf-viewer"},DW={key:0},NW={key:1,class:"pdf-pages"};function PW(n,e,t,r,i,o){const s=a.resolveComponent("q-error-modal");return a.openBlock(),a.createElementBlock(a.Fragment,null,[a.createElementVNode("div",OW,[n.loadingMeta?(a.openBlock(),a.createElementBlock("div",DW,[(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",NW,[(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 uM=me(xW,[["render",PW],["__scopeId","data-v-da5da0f5"]]),LW=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},tooltipClasses:{type:[String,Array,Object],default:""}}}),BW=["aria-describedby"],_W=["id"];function RW(n,e,t,r,i,o){return a.openBlock(),a.createElementBlock("div",{class:"tooltip-container","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,_W)],8,BW)}const rc=me(LW,[["render",RW],["__scopeId","data-v-ca6ae8fe"]]),ic=()=>{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}},$W=a.defineComponent({name:"ImageGallery",components:{Galleria:lE,QBadge:ns,QBottomSheet:eC,QMenu:Cb,QPdfViewer:uM,QTooltip:rc},props:{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}=bi(),{deviceType:r}=ic(),i=[{text:t("HC_CANCEL")}],o=a.ref(null),s=a.computed(()=>{var Y;return(Y=o.value)==null?void 0:Y.offsetWidth}),l=a.ref(null),c=a.ref([]),d=a.ref(!1),u=a.ref(null),f=a.ref("0"),h=a.ref(1),p=a.ref(Qt.md?1:.9),m=a.ref(0),b=a.ref(null),y=a.ref(),w=a.ref(!1),v=a.ref(!1),k=a.computed(()=>{if(b.value)return b.value&&"original"in b.value?{name:b.value.original.name,url:b.value.original.url,type:b.value.mimetype,extension:F(b.value.original.url)}:{name:b.value.name,url:URL.createObjectURL(b.value),type:b.value.type,extension:F(b.value.name)}}),C=a.computed(()=>[`z-[${n.baseZIndex+1}]`]),T=a.computed(()=>n.files.filter(Y=>Y.type.startsWith("image")&&!Y.type.includes("tif"))),S=a.computed(()=>["rounded-lg relative mx-auto object-cover grow-1 max-h-[74vh]",{animated:!D}]),M=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"}]),x=a.computed(()=>[{text:t("HC_DELETE_ATTACHMENT"),classes:"!text-red-20",event:H}]),O=Y=>{const Z=Y instanceof File?URL.createObjectURL(Y):Y.original.url;r.value==="desktop"?window.open(Z,"_blank"):window.open(Z,"_self")},P=Y=>{r.value==="desktop"?O(Y):(b.value=Y,v.value=!0)},N=Y=>{Y.event(),d.value=!1},_=(Y,Z)=>{var $;const j=(($=Z.type)==null?void 0:$.includes("image"))&&!Z.type.includes("tif");!d.value&&j?V(Y,Z):!d.value&&!j&&P(Z)},V=(Y,Z)=>{const j=W=>"original"in W&&"original"in Z?W.original.url===(Z==null?void 0:Z.original.url):Z instanceof File?W.name===(Z==null?void 0:Z.name):!1,$=T.value.findIndex(j);m.value=$!==-1?$:Y,w.value=!0},H=(Y=null)=>{d.value=!1,e("update:model-value",Y||u.value)},L=Y=>{const{keyCode:Z}=Y;if(w.value)switch(Z){case 37:m.value=m.value?m.value-1:T.value.length-1,e("update:activeIndex",m.value);break;case 39:m.value=m.value<T.value.length-1?m.value+1:0,e("update:activeIndex",m.value);break;case 27:w.value=!1;break}},{isSwiping:D,lengthX:U}=vB(l,{passive:!1,onSwipe(){const Y=Math.abs(U.value);s.value&&(h.value=1.1-Y/s.value,f.value=U.value<0?`${Y/4}px`:`-${Y/4}px`)},onSwipeEnd(){const Y=m.value<=0,Z=m.value>=T.value.length-1,j=Math.abs(U.value);s.value&&j/s.value>=.5?(U.value<0?m.value=Y?T.value.length-1:m.value-1:m.value=Z?0:m.value+1,f.value="0",h.value=1):(f.value="0",h.value=1)}}),F=Y=>Y.substring(Y.lastIndexOf(".")),R=(Y,Z)=>{Y.preventDefault(),u.value=n.files[Z],d.value=!0},G=()=>{d.value=!1,u.value=null},ne=()=>{r.value!=="desktop"&&c.value.forEach(Y=>{fB(Y,Z=>{const j=c.value.indexOf(Y);R(Z,j)},{modifiers:{prevent:!0}})})};return a.onMounted(()=>{window.addEventListener("keyup",L),ne()}),a.onUpdated(()=>{ne()}),{menuActions:i,linkActions:x,deviceType:r,container:o,containerWidth:s,featuredPhoto:l,longPressRef:c,longPressedHook:d,isSwiping:D,lengthX:U,left:f,opacity:h,scale:p,showCarousel:w,showFileViewer:v,active:m,activeAttachment:b,hoveredIndex:y,closeIconClasses:C,itemClasses:S,images:T,normalizedAttachment:k,thumbnailContainerClasses:M,downloadDocument:O,getExtension:F,onAttachmentClick:P,onClickMenuLink:N,onClickThumbnail:_,onOpenCarousel:V,onRemoveFile:H,onKeyboardNavigation:L,onLongPressCallbackHook:R,resetHook:G,mq:Qt}}}),VW={class:"q-image-gallery flex",ref:"container"},FW={ref:"featuredPhoto",class:"featured-image h-[80vh] overflow-hidden flex max-w-screen relative md:h-full w-screen items-center"},jW=["src","alt"],zW=["src","alt"],HW=["onMouseover","onClick"],UW=["src","alt"],ZW={key:1,class:"bg-gray-00 cursor-pointer p-3 h-16 max-w-[14rem] rounded-lg border border-gray-20 flex items-center"},WW={class:"grow text-ellipsis overflow-hidden"},qW={class:"text-inkwell-30 bold leading-normal text-nowrap text-ellipsis text-sm overflow-hidden -mt-1"},KW={class:"uppercase text-xxs"},GW={key:2,class:"image-overlay absolute top-0 left-0 w-full h-full cursor-pointer"},YW={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"},QW={key:1,width:"100%",height:"auto",controls:"",class:"bg-black"},XW=["src"],JW={class:"flex items-center flex-col p-12"},eq=["src"],tq=["data","type"],nq={class:"flex items-center flex-col p-12"};function rq(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",VW,[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",FW,[a.createElementVNode("img",{src:(p==null?void 0:p.itemImageSrc)||(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.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,jW)],512)]),thumbnail:a.withCtx(({item:p})=>[a.createElementVNode("img",{src:(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.url),alt:p.alt,class:"rounded-lg block min-h-24 min-w-24 max-w-24 max-h-24 object-cover"},null,8,zW)]),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.files?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(n.thumbnailContainerClasses)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.files,(p,m)=>{var b;return a.openBlock(),a.createElementBlock("div",{ref_for:!0,ref:"longPressRef",key:p.name||((b=p.original)==null?void 0:b.name)||m,class:a.normalizeClass(["p-0 relative rounded-lg",{"shrink-0":n.deviceType!=="desktop"}]),onMouseover:y=>n.hoveredIndex=m,onMouseleave:e[2]||(e[2]=y=>n.hoveredIndex=null),onClick:y=>n.onClickThumbnail(m,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,src:(p==null?void 0:p.objectURL)||(p==null?void 0:p.original.url),alt:p==null?void 0:p.alt,class:"rounded-lg cursor-pointer w-16 h-16 object-cover bg-gray-0 border-gray-20 border"},null,8,UW)):(a.openBlock(),a.createElementBlock("div",ZW,[a.createVNode(s,{icon:"file-document",size:"xl",color:"white",class:"mr-3 shrink-0 p-2 bg-green-20 rounded-lg h-full"}),a.createElementVNode("div",WW,[a.createElementVNode("div",qW,a.toDisplayString(p.name||p.original.name),1),a.createElementVNode("div",KW,a.toDisplayString((p.name||p.original.name).match(/([^.]+$)/)[0]),1)])])),n.deviceType!=="desktop"?(a.openBlock(),a.createElementBlock("div",GW)):a.createCommentVNode("",!0),n.showRemove&&n.showOnHover&&n.hoveredIndex===m&&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(y=>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(()=>{var y;return[a.createTextVNode(a.toDisplayString(p.name||((y=p.original)==null?void 0:y.name)),1)]}),_:2},1024),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>[n.processing?(a.openBlock(),a.createElementBlock("div",YW,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,HW)}),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.normalizedAttachment&&n.activeAttachment?(a.openBlock(),a.createBlock(h,{key:0,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.normalizedAttachment.name),1)]),headerAction:a.withCtx(()=>[!n.normalizedAttachment.type.includes("video")&&n.normalizedAttachment.type!=="audio/mpeg"&&n.normalizedAttachment.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.normalizedAttachment.type==="application/pdf"?(a.openBlock(),a.createBlock(f,{key:0,url:n.normalizedAttachment.url},null,8,["url"])):n.normalizedAttachment.type.includes("video")?(a.openBlock(),a.createElementBlock("video",QW,[a.createElementVNode("source",{src:n.normalizedAttachment.url,type:"video/mp4"},null,8,XW),a.createElementVNode("div",JW,[a.createVNode(s,{icon:"file-document",size:"xl",color:"inkwell-30"}),a.createTextVNode(" "+a.toDisplayString(n.normalizedAttachment.extension),1)])])):n.normalizedAttachment.type==="audio/mpeg"?(a.openBlock(),a.createElementBlock("audio",{key:2,controls:"",src:n.normalizedAttachment.url,class:"mx-auto my-6"},null,8,eq)):(a.openBlock(),a.createElementBlock("object",{key:3,data:n.normalizedAttachment.url,type:n.normalizedAttachment.type,class:"w-full h-auto"},[a.createElementVNode("div",nq,[a.createVNode(s,{icon:"file-document",size:"xl",color:"inkwell-30"}),a.createTextVNode(" "+a.toDisplayString(n.normalizedAttachment.extension),1)])],8,tq))]),_:1},8,["modelValue"])):a.createCommentVNode("",!0)]),_:1})],512)}const a6=me($W,[["render",rq],["__scopeId","data-v-5efcef01"]]),iq=a.defineComponent({name:"QWarningModal",components:{QModal:s6},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:Qt}}}),oq={key:0,class:"flex flex-col gap-2 text-center"},sq={class:"text-lg font-bold text-inkwell-30 leading-6"},aq={class:"text-inkwell-0 mb-6"},lq={key:1,class:"flex flex-col gap-2 text-center"},cq={class:"text-[1.25rem] font-bold text-center text-inkwell-30"},dq={class:"text-sm text-center text-inkwell-0 mb-2"},uq={class:"flex flex-col items-center justify-center gap-3 md:gap-2"};function fq(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","footer-class":"mt-2 md:mt-6",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",oq,[a.createElementVNode("h2",sq,[a.renderSlot(n.$slots,"desktopHeader",{},void 0,!0)]),a.createElementVNode("p",aq,[a.renderSlot(n.$slots,"desktopMessage",{},void 0,!0)])])):(a.openBlock(),a.createElementBlock("div",lq,[a.createElementVNode("h2",cq,[a.renderSlot(n.$slots,"mobileHeader",{},void 0,!0)]),a.createElementVNode("p",dq,[a.renderSlot(n.$slots,"mobileMessage",{},void 0,!0)])]))]),footer:a.withCtx(()=>[a.createElementVNode("div",uq,[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 fM=me(iq,[["render",fq],["__scopeId","data-v-a8bfc627"]]),hq=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 k=w.left;return window.innerWidth-k<v.width?"right":"left"}else{const k=w.top;return window.innerHeight-k<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 k=w.top;return window.innerHeight-k<v.height?"top":"bottom"}else{const k=w.left;return window.innerWidth-k<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,k=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: ${k/2-10}px;`;break;case"bottom":r.value=`margin-bottom: ${k/2-10}px;`;break}}};mp(i,()=>{e("update:modelValue",!1)});function m(){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:m,onClick:u,onClickOutside:mp,onEnter:b,onMouseLeave:f,onMouseOver:h}}});function pq(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 hM=me(hq,[["render",pq],["__scopeId","data-v-86f2575d"]]);function en(n){this.content=n}en.prototype={constructor:en,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 en(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 en(t)},addToStart:function(n,e){return new en([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new en(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 en(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=en.from(n),n.size?new en(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=en.from(n),n.size?new en(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=en.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}},en.from=function(n){if(n instanceof en)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new en(e)};function pM(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=pM(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function mM(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=mM(s.content,l.content,t-1,r-1);if(d)return d}t-=c,r-=c}}class X{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 X(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 X(r,i)}cutByIndex(e,t){return e==t?X.empty:e==0&&t==this.content.length?this:new X(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 X(i,o)}addToStart(e){return new X([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new X(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 pM(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return mM(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Em(0,e);if(e==this.size)return Em(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?Em(r+1,s):Em(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 X.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return X.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 X(t||e,r)}static from(e){if(!e)return X.empty;if(e instanceof X)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new X([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const l6={index:0,offset:0};function Em(n,e){return l6.index=n,l6.offset=e,l6}function Mm(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(!Mm(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Mm(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ke=class u8{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&&Mm(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 u8.none;if(e instanceof u8)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ke.none=[];class Am extends Error{}class ie{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=yM(this.content,e+this.openStart,t);return r&&new ie(r,this.openStart,this.openEnd)}removeBetween(e,t){return new ie(gM(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 ie.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 ie(X.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 ie(e,r,i)}}ie.empty=new ie(X.empty,0,0);function gM(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(gM(o.content,e-i-1,t-i-1)))}function yM(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=yM(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function mq(n,e,t){if(t.openStart>n.depth)throw new Am("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Am("Inconsistent open depths");return bM(n,e,t,0)}function bM(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=bM(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 tl(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=gq(t,n);return tl(o,vM(n,s,l,e,r))}else return tl(o,Tm(n,e,r))}function wM(n,e){if(!e.type.compatibleContent(n.type))throw new Am("Cannot join "+e.type.name+" onto "+n.type.name)}function c6(n,e,t){let r=n.node(t);return wM(r,e.node(t)),r}function el(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 S2(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&&(el(n.nodeAfter,r),o++));for(let l=o;l<s;l++)el(i.child(l),r);e&&e.depth==t&&e.textOffset&&el(e.nodeBefore,r)}function tl(n,e){return n.type.checkContent(e),n.copy(e)}function vM(n,e,t,r,i){let o=n.depth>i&&c6(n,e,i+1),s=r.depth>i&&c6(t,r,i+1),l=[];return S2(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(wM(o,s),el(tl(o,vM(n,e,t,r,i+1)),l)):(o&&el(tl(o,Tm(n,e,i+1)),l),S2(e,t,i,l),s&&el(tl(s,Tm(t,r,i+1)),l)),S2(r,null,i,l),new X(l)}function Tm(n,e,t){let r=[];if(S2(null,n,t,r),n.depth>t){let i=c6(n,e,t+1);el(tl(i,Tm(n,e,t+1)),r)}return S2(e,null,t,r),new X(r)}function gq(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(X.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class E2{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 Ke.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 Im(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 E2(t,r,o)}static resolveCached(e,t){for(let i=0;i<d6.length;i++){let o=d6[i];if(o.pos==t&&o.doc==e)return o}let r=d6[u6]=E2.resolve(e,t);return u6=(u6+1)%yq,r}}let d6=[],u6=0,yq=12;class Im{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 bq=Object.create(null);let nl=class f8{constructor(e,t,r,i=Ke.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||X.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&&Mm(this.attrs,t||e.defaultAttrs||bq)&&Ke.sameSet(this.marks,r||Ke.none)}copy(e=null){return e==this.content?this:new f8(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new f8(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 ie.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 ie(d,i.depth-s,o.depth-s)}replace(e,t,r){return mq(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 E2.resolveCached(this,e)}resolveNoCache(e){return E2.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()+")"),CM(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=X.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=Ke.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ke.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=X.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};nl.prototype.text=void 0;class xm extends nl{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):CM(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 xm(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xm(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 CM(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class rl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new wq(e,t);if(r.next==null)return rl.empty;let i=kM(r);r.next&&r.err("Unexpected trailing text");let o=Aq(Mq(i));return Tq(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 X.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
  `)}}rl.empty=new rl(!0);class wq{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 kM(n){let e=[];do e.push(vq(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function vq(n){let e=[];do e.push(Cq(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Cq(n){let e=Eq(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=kq(n,e);else break;return e}function SM(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function kq(n,e){let t=SM(n),r=t;return n.eat(",")&&(n.next!="}"?r=SM(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Sq(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 Eq(n){if(n.eat("(")){let e=kM(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=Sq(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 Mq(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 EM(n,e){return e-n}function MM(n,e){let t=[];return r(e),t.sort(EM);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 Aq(n){let e=Object.create(null);return t(MM(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]);MM(n,c).forEach(u=>{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let o=e[r.join(",")]=new rl(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(EM);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function Tq(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 AM(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 TM(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 IM(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new Iq(n[t]);return e}let xM=class AP{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=IM(r.attrs),this.defaultAttrs=AM(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==rl.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:TM(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nl(this,this.computeAttrs(e),X.from(t),Ke.setFrom(r))}createChecked(e=null,t,r){return t=X.from(t),this.checkContent(t),new nl(this,this.computeAttrs(e),t,Ke.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=X.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(X.empty,!0);return o?new nl(this,e,t.append(o),Ke.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:Ke.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new AP(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 Iq{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Om{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=IM(i.attrs),this.excluded=null;let o=AM(this.attrs);this.instance=o?new Ke(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ke(this,TM(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Om(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 xq{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=en.from(e.nodes),t.marks=en.from(e.marks||{}),this.nodes=xM.compile(this.spec.nodes,this),this.marks=Om.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]=rl.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=l=="_"?null:l?OM(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==""?[]:OM(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 xM){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 xm(r,r.defaultAttrs,e,Ke.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return nl.fromJSON(this,e)}markFromJSON(e){return Ke.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function OM(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 oc{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 LM(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new LM(this,t,!0);return r.addAll(e,t.from,t.to),ie.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(Nq(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=BM(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=BM(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new oc(e,oc.schemaRules(e)))}}const DM={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},Oq={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},NM={ol:!0,ul:!0},Dm=1,Nm=2,M2=4;function PM(n,e,t){return e!=null?(e?Dm:0)|(e==="full"?Nm:0):n&&n.whitespace=="pre"?Dm|Nm:t&~M2}class Pm{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=Ke.none,this.stashMarks=[],this.match=s||(l&M2?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(X.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&Dm)){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=X.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(X.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):Lq(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&&!DM.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class LM{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,o,s=PM(null,t.preserveWhitespace,0)|(r?M2:0);i?o=new Pm(i.type,i.attrs,Ke.none,Ke.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Pm(null,null,Ke.none,Ke.none,!0,null,s):o=new Pm(e.schema.topNodeType,null,Ke.none,Ke.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(Pq(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&Nm||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&Dm)r.options&Nm?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;NM.hasOwnProperty(r)&&this.parser.normalizeLists&&Dq(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(o?o.ignore:Oq.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(DM.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=Ke.none,r=Ke.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=PM(e,i,o.options);o.options&M2&&o.content.length==0&&(s|=M2),this.nodes.push(new Pm(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=Bq(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 Dq(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&NM.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Nq(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Pq(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 BM(n){let e={};for(let t in n)e[t]=n[t];return e}function Lq(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 Bq(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class wi{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=f6(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}=wi.renderSpec(f6(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&&wi.renderSpec(f6(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}=wi.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 wi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_M(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return _M(e.marks)}}function _M(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function f6(n){return n.document||window.document}const RM=65535,$M=Math.pow(2,16);function _q(n,e){return n+e*$M}function VM(n){return n&RM}function Rq(n){return(n-(n&RM))/$M}const FM=1,jM=2,Lm=4,zM=8;class h6{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&zM)>0}get deletedBefore(){return(this.delInfo&(FM|Lm))>0}get deletedAfter(){return(this.delInfo&(jM|Lm))>0}get deletedAcross(){return(this.delInfo&Lm)>0}}class rr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&rr.empty)return rr.empty}recover(e){let t=0,r=VM(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+Rq(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 m=e==(t<0?c:f)?null:_q(l/3,e-c),b=e==c?jM:e==f?FM:Lm;return(t<0?e!=c:e!=f)&&(b|=zM),new h6(p,b,m)}i+=u-d}return r?e+i:new h6(e+i,0,null)}touches(e,t){let r=0,i=VM(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 rr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?rr.empty:new rr(e<0?[0,-e,0]:[0,0,e])}}rr.empty=new rr([]);class sc{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 sc(this.maps,this.mirror,e,t)}copy(){return new sc(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 sc;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 h6(e,i,null)}}const p6=Object.create(null);class gn{getMap(){return rr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=p6[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 p6)throw new RangeError("Duplicate use of step JSON ID "+e);return p6[e]=t,t.prototype.jsonID=e,t}}class At{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new At(e,null)}static fail(e){return new At(null,e)}static fromReplace(e,t,r,i){try{return At.ok(e.replace(t,r,i))}catch(o){if(o instanceof Am)return At.fail(o.message);throw o}}}function m6(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(m6(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return X.fromArray(r)}class ws extends gn{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 ie(m6(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 At.fromReplace(e,this.from,this.to,o)}invert(){return new vi(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 ws(t.pos,r.pos,this.mark)}merge(e){return e instanceof ws&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ws(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 ws(t.from,t.to,e.markFromJSON(t.mark))}}gn.jsonID("addMark",ws);class vi extends gn{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 ie(m6(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return At.fromReplace(e,this.from,this.to,r)}invert(){return new ws(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 vi(t.pos,r.pos,this.mark)}merge(e){return e instanceof vi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new vi(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 vi(t.from,t.to,e.markFromJSON(t.mark))}}gn.jsonID("removeMark",vi);class vs extends gn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return At.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return At.fromReplace(e,this.pos,this.pos+1,new ie(X.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 vs(this.pos,t.marks[i]);return new vs(this.pos,this.mark)}}return new ac(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new vs(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 vs(t.pos,e.markFromJSON(t.mark))}}gn.jsonID("addNodeMark",vs);class ac extends gn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return At.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return At.fromReplace(e,this.pos,this.pos+1,new ie(X.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new vs(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ac(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 ac(t.pos,e.markFromJSON(t.mark))}}gn.jsonID("removeNodeMark",ac);class _t extends gn{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&g6(e,this.from,this.to)?At.fail("Structure replace would overwrite content"):At.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new rr([this.from,this.to-this.from,this.slice.size])}invert(e){return new _t(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 _t(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof _t)||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?ie.empty:new ie(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _t(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?ie.empty:new ie(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _t(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 _t(t.from,t.to,ie.fromJSON(e,t.slice),!!t.structure)}}gn.jsonID("replace",_t);class Rt extends gn{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&&(g6(e,this.from,this.gapFrom)||g6(e,this.gapTo,this.to)))return At.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return At.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?At.fromReplace(e,this.from,this.to,r):At.fail("Content does not fit in gap")}getMap(){return new rr([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 Rt(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 Rt(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 Rt(t.from,t.to,t.gapFrom,t.gapTo,ie.fromJSON(e,t.slice),t.insert,!!t.structure)}}gn.jsonID("replaceAround",Rt);function g6(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 $q(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),m=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(m)||(s&&s.to==h&&s.mark.eq(f[b])?s.to=p:i.push(s=new vi(h,p,f[b])));l&&l.to==h?l.to=p:o.push(l=new ws(h,p,r))}}),i.forEach(c=>n.step(c)),o.forEach(c=>n.step(c))}function Vq(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 Om){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 m=i[p];m.step==o-1&&f.eq(i[p].style)&&(h=m)}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 vi(s.from,s.to,s.style)))}function Fq(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 _t(s,d,ie.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new vi(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 ie(X.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new _t(s+f.index,s+f.index+f[0].length,p))}}s=d}if(!r.validEnd){let l=r.fillBefore(X.empty,!0);n.replace(s,s,new ie(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function jq(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function lc(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||!jq(i,o,s))break}return null}function zq(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=X.empty,f=0;for(let m=o,b=!1;m>t;m--)b||r.index(m)>0?(b=!0,u=X.from(r.node(m).copy(u)),f++):c--;let h=X.empty,p=0;for(let m=o,b=!1;m>t;m--)b||i.after(m+1)<i.end(m)?(b=!0,h=X.from(i.node(m).copy(h)),p++):d++;n.step(new Rt(c,d,s,l,new ie(u.append(h),f,p),u.size-f,!0))}function y6(n,e,t=null,r=n){let i=Hq(n,e),o=i&&Uq(r,e);return o?i.map(HM).concat({type:e,attrs:t}).concat(o.map(HM)):null}function HM(n){return{type:n,attrs:null}}function Hq(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 Uq(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 Zq(n,e,t){let r=X.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=X.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new Rt(i,o,i,o,new ie(r,0,0),t.length,!0))}function Wq(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)&&qq(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 Rt(d,u,d+1,u-1,new ie(X.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function qq(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Kq(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 Rt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new ie(X.from(s),0,0),1,!0))}function cc(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),m=r&&r[u+1];m&&(p=p.replaceChild(0,m.type.create(m.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 Gq(n,e,t=1,r){let i=n.doc.resolve(e),o=X.empty,s=X.empty;for(let l=i.depth,c=i.depth-t,d=t-1;l>c;l--,d--){o=X.from(i.node(l).copy(o));let u=r&&r[d];s=X.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new _t(e,e,new ie(o.append(s),t,t),!0))}function Cs(n,e){let t=n.resolve(e),r=t.index();return UM(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function UM(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Bm(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&&UM(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 Yq(n,e,t){let r=new _t(e-t,e+t,ie.empty,!0);n.step(r)}function Qq(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 ZM(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 _m(n,e,t=e,r=ie.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return WM(i,o,r)?new _t(e,t,r):new Xq(i,o,r).fit()}function WM(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Xq{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=X.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=X.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 ie(o,s,l);return e>-1?new Rt(r.pos,e,this.$to.pos,this.$to.end(),c,t):c.size||r.pos!=this.$to.pos?new _t(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=b6(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(X.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=b6(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new ie(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=b6(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new ie(A2(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new ie(A2(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(qM(b.mark(h.allowedMarks(b.marks)),d==1?c:0,d==l.childCount?p:-1)))}let m=d==l.childCount;m||(p=-1),this.placed=T2(this.placed,t,X.from(u)),this.frontier[t].match=f,m&&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=m?e==0?ie.empty:new ie(A2(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new ie(A2(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||!w6(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=w6(e,t,i,r,o);if(s){for(let l=t-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],u=w6(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=T2(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=T2(this.placed,this.depth,X.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(X.empty,!0);t.childCount&&(this.placed=T2(this.placed,this.frontier.length,t))}}function A2(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(A2(n.firstChild.content,e-1,t)))}function T2(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(T2(n.lastChild.content,e-1,t)))}function b6(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function qM(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,qM(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(X.empty,!0)))),n.copy(r)}function w6(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&&!Jq(t,o.content,s)?l:null}function Jq(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function eK(n){return n.spec.defining||n.spec.definingForContent}function tK(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(WM(i,o,r))return n.step(new _t(e,t,r));let s=GM(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 m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.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 m=h.firstChild;if(d.push(m),p==r.openStart)break;h=m.content}for(let h=u-1;h>=0;h--){let p=d[h],m=eK(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+u+1)%(r.openStart+1),m=d[p];if(m)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),k=i.index(y-1);if(v.canReplaceWith(k,k,m.type,m.marks))return n.replace(i.before(y),w?o.after(y):t,new ie(KM(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 KM(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(KM(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(X.empty,!0))}return n}function nK(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Qq(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new ie(X.from(r),0,0))}function rK(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=GM(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 GM(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 dc extends gn{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 At.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 At.fromReplace(e,this.pos,this.pos+1,new ie(X.from(i),0,t.isLeaf?0:1))}getMap(){return rr.empty}invert(e){return new dc(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 dc(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 dc(t.pos,t.attr,t.value)}}gn.jsonID("attr",dc);class I2 extends gn{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 At.ok(r)}getMap(){return rr.empty}invert(e){return new I2(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 I2(t.attr,t.value)}}gn.jsonID("docAttr",I2);let uc=class extends Error{};uc=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},uc.prototype=Object.create(Error.prototype),uc.prototype.constructor=uc,uc.prototype.name="TransformError";class YM{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new sc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new uc(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=ie.empty){let i=_m(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new ie(X.from(r),0,0))}delete(e,t){return this.replace(e,t,ie.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return tK(this,e,t,r),this}replaceRangeWith(e,t,r){return nK(this,e,t,r),this}deleteRange(e,t){return rK(this,e,t),this}lift(e,t){return zq(this,e,t),this}join(e,t=1){return Yq(this,e,t),this}wrap(e,t){return Zq(this,e,t),this}setBlockType(e,t=e,r,i=null){return Wq(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Kq(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new dc(e,t,r)),this}setDocAttribute(e,t){return this.step(new I2(e,t)),this}addNodeMark(e,t){return this.step(new vs(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Ke)){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 ac(e,t)),this}split(e,t=1,r){return Gq(this,e,t,r),this}addMark(e,t,r){return $q(this,e,t,r),this}removeMark(e,t,r){return Vq(this,e,t,r),this}clearIncompatible(e,t,r){return Fq(this,e,t,r),this}}const v6=Object.create(null);class Me{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new iK(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=ie.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?ie.empty:t),l==0&&JM(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),JM(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new ke(e):fc(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?fc(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):fc(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 Gr(e.node(0))}static atStart(e){return fc(e,e,0,0,1)||new Gr(e)}static atEnd(e){return fc(e,e,e.content.size,e.childCount,-1)||new Gr(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=v6[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 v6)throw new RangeError("Duplicate use of selection JSON ID "+e);return v6[e]=t,t.prototype.jsonID=e,t}getBookmark(){return ke.between(this.$anchor,this.$head).getBookmark()}}Me.prototype.visible=!0;class iK{constructor(e,t){this.$from=e,this.$to=t}}let QM=!1;function XM(n){!QM&&!n.parent.inlineContent&&(QM=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class ke extends Me{constructor(e,t=e){XM(e),XM(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 Me.near(r);let i=e.resolve(t.map(this.anchor));return new ke(i.parent.inlineContent?i:r,r)}replace(e,t=ie.empty){if(super.replace(e,t),t==ie.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ke&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Rm(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 ke(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=Me.findFrom(t,r,!0)||Me.findFrom(t,-r,!0);if(o)t=o.$head;else return Me.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(Me.findFrom(e,-r,!0)||Me.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new ke(e,t)}}Me.jsonID("text",ke);class Rm{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Rm(e.map(this.anchor),e.map(this.head))}resolve(e){return ke.between(e.resolve(this.anchor),e.resolve(this.head))}}class he extends Me{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?Me.near(o):new he(o)}content(){return new ie(X.from(this.node),0,0)}eq(e){return e instanceof he&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new C6(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new he(e.resolve(t.anchor))}static create(e,t){return new he(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}he.prototype.visible=!1,Me.jsonID("node",he);class C6{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Rm(r,r):new C6(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&he.isSelectable(r)?new he(t):Me.near(t)}}class Gr extends Me{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ie.empty){if(t==ie.empty){e.delete(0,e.doc.content.size);let r=Me.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Gr(e)}map(e){return new Gr(e)}eq(e){return e instanceof Gr}getBookmark(){return oK}}Me.jsonID("all",Gr);const oK={map(){return this},resolve(n){return new Gr(n)}};function fc(n,e,t,r,i,o=!1){if(e.inlineContent)return ke.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&&he.isSelectable(l))return he.create(n,t-(i<0?l.nodeSize:0))}else{let c=fc(n,l,t+i,i<0?l.childCount:0,i,o);if(c)return c}t+=l.nodeSize*i}return null}function JM(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof _t||i instanceof Rt))return;let o=n.mapping.maps[r],s;o.forEach((l,c,d,u)=>{s==null&&(s=u)}),n.setSelection(Me.near(n.doc.resolve(s),t))}const eA=1,$m=2,tA=4;class sK extends YM{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|eA)&~$m,this.storedMarks=null,this}get selectionSet(){return(this.updated&eA)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$m,this}ensureMarks(e){return Ke.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&$m)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~$m,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)||Ke.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(Me.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|=tA,this}get scrolledIntoView(){return(this.updated&tA)>0}}function nA(n,e){return!e||!n?n:n.bind(e)}class x2{constructor(e,t,r){this.name=e,this.init=nA(t.init,r),this.apply=nA(t.apply,r)}}const aK=[new x2("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new x2("selection",{init(n,e){return n.selection||Me.atStart(e.doc)},apply(n){return n.selection}}),new x2("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new x2("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class k6{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=aK.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 x2(r.key,r.spec.state,r))})}}class hc{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 hc(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 sK(this)}static create(e){let t=new k6(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new hc(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 k6(this.schema,e.plugins),r=t.fields,i=new hc(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 k6(e.schema,e.plugins),o=new hc(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=nl.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=Me.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 rA(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=rA(i,e,{})),t[r]=i}return t}class $t{constructor(e){this.spec=e,this.props={},e.props&&rA(e.props,this,this.props),this.key=e.key?e.key.key:iA("plugin")}getState(e){return e[this.key]}}const S6=Object.create(null);function iA(n){return n in S6?n+"$"+ ++S6[n]:(S6[n]=0,n+"$")}class Hn{constructor(e="key"){this.key=iA(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Mn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},O2=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let oA=null;const go=function(n,e,t){let r=oA||(oA=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},il=function(n,e,t,r){return t&&(sA(n,e,t,r,-1)||sA(n,e,t,r,1))},lK=/^(img|br|input|textarea|hr)$/i;function sA(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ci(n))){let o=n.parentNode;if(!o||o.nodeType!=1||E6(n)||lK.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mn(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?Ci(n):0}else return!1}}function Ci(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function cK(n,e,t){for(let r=e==0,i=e==Ci(n);r||i;){if(n==t)return!0;let o=Mn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Ci(n)}}function E6(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 Vm=function(n){return n.focusNode&&il(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ol(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function dK(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function uK(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 ki=typeof navigator<"u"?navigator:null,aA=typeof document<"u"?document:null,ks=ki&&ki.userAgent||"",M6=/Edge\/(\d+)/.exec(ks),lA=/MSIE \d/.exec(ks),A6=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ks),Un=!!(lA||A6||M6),Ss=lA?document.documentMode:A6?+A6[1]:M6?+M6[1]:0,Yr=!Un&&/gecko\/(\d+)/i.test(ks);Yr&&+(/Firefox\/(\d+)/.exec(ks)||[0,0])[1];const T6=!Un&&/Chrome\/(\d+)/.exec(ks),yn=!!T6,fK=T6?+T6[1]:0,An=!Un&&!!ki&&/Apple Computer/.test(ki.vendor),pc=An&&(/Mobile\/\w+/.test(ks)||!!ki&&ki.maxTouchPoints>2),Er=pc||(ki?/Mac/.test(ki.platform):!1),hK=ki?/Win/.test(ki.platform):!1,Qr=/Android \d/.test(ks),D2=!!aA&&"webkitFontSmoothing"in aA.documentElement.style,pK=D2?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mK(n){return{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function yo(n,e){return typeof n=="number"?n:n[e]}function gK(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 cA(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=O2(s)){if(s.nodeType!=1)continue;let l=s,c=l==o.body,d=c?mK(o):gK(l),u=0,f=0;if(e.top<d.top+yo(r,"top")?f=-(d.top-e.top+yo(i,"top")):e.bottom>d.bottom-yo(r,"bottom")&&(f=e.bottom-e.top>d.bottom-d.top?e.top+yo(i,"top")-d.top:e.bottom-d.bottom+yo(i,"bottom")),e.left<d.left+yo(r,"left")?u=-(d.left-e.left+yo(i,"left")):e.right>d.right-yo(r,"right")&&(u=e.right-d.right+yo(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 m=l.scrollLeft-h,b=l.scrollTop-p;e={left:e.left-m,top:e.top-b,right:e.right-m,bottom:e.bottom-b}}if(c||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function yK(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:dA(n.dom)}}function dA(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=O2(r));return e}function bK({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;uA(t,r==0?0:r-e)}function uA(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 mc=null;function wK(n){if(n.setActive)return n.setActive();if(mc)return n.focus(mc);let e=dA(n);n.focus(mc==null?{get preventScroll(){return mc={preventScroll:!0},!0}}:void 0),mc||(mc=!1,uA(e,0))}function fA(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=go(u).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=s&&m.bottom>=l){s=Math.max(m.bottom,s),l=Math.min(m.top,l);let b=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(b<r){t=u,r=b,i=b&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&b&&(o=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!c&&m.left<=e.left&&m.right>=e.left&&(c=u,d={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=f+1)}}return!t&&c&&(t=c,i=d,r=0),t&&t.nodeType==3?vK(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:fA(t,i)}function vK(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=Es(r,1);if(o.top!=o.bottom&&I6(e,o))return{node:n,offset:i+(e.left>=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function I6(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function CK(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function kK(n,e,t){let{node:r,offset:i}=fA(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 SK(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 hA(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(I6(e,d))return hA(s,e,d)}}if((o=(o+1)%r)==i)break}return n}function EK(n,e){let t=n.dom.ownerDocument,r,i=0,o=uK(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(!I6(e,d)||(s=hA(n.dom,e,d),!s))return null}if(An)for(let d=s;r&&d;d=O2(d))d.draggable&&(r=void 0);if(s=CK(s,e),r){if(Yr&&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;D2&&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=SK(n,r,i,e))}l==null&&(l=kK(n,s,e));let c=n.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function pA(n){return n.top<n.bottom||n.left<n.right}function Es(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(pA(r))return r}return Array.prototype.find.call(t,pA)||n.getBoundingClientRect()}const MK=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function mA(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=D2||Yr;if(r.nodeType==3)if(s&&(MK.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let c=Es(go(r,i,i),t);if(Yr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=Es(go(r,i-1,i-1),-1);if(d.top==c.top){let u=Es(go(r,i,i+1),-1);if(u.top!=c.top)return N2(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++,N2(Es(go(r,c,d),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Ci(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return x6(c.getBoundingClientRect(),!1)}if(o==null&&i<Ci(r)){let c=r.childNodes[i];if(c.nodeType==1)return x6(c.getBoundingClientRect(),!0)}return x6(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==Ci(r))){let c=r.childNodes[i-1],d=c.nodeType==3?go(c,Ci(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return N2(Es(d,1),!1)}if(o==null&&i<Ci(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?go(c,0,s?0:1):c.nodeType==1?c:null:null;if(d)return N2(Es(d,-1),!0)}return N2(Es(r.nodeType==3?go(r):r,-t),t>=0)}function N2(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 x6(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 gA(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 AK(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return gA(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=mA(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=go(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 TK=/[\u0590-\u08ac]/;function IK(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!TK.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:gA(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:m,focusOffset:b}=n.domSelectionRange(),y=m&&!p.contains(m.nodeType==1?m:m.parentNode)||c==m&&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 yA=null,bA=null,wA=!1;function xK(n,e,t){return yA==e&&bA==t?wA:(yA=e,bA=t,wA=t=="up"||t=="down"?AK(n,e,t):IK(n,e,t))}const Mr=0,vA=1,sl=2,Si=3;class P2{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Mr,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>Mn(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 SA){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 CA&&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?Mn(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?Mn(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=Mn(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=Mn(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 m=this.children[h],b=p+m.size;if(o>p&&s<b)return m.setSelection(e-p-m.border,t-p-m.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((Yr||An)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`