@harbour-enterprises/superdoc 1.31.0 → 1.31.1

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.
@@ -2,7 +2,7 @@ var SuperDoc=(function(){var qze=Object.create,B_=Object.defineProperty,Yze=Obje
2
2
  `)}},vB=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[lT]?lne(e,t):N0(e)?QF(e,n=>$F(t,r=>vB(n,r))):OWe(e)?mv(e,(n,r)=>vB(n,t[r])):!1,Nl=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),vB(t,n)}equals(e){return this.constructor===e.constructor&&gv(this.shape,e.shape)}[gGe](){return!0}[lT](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Su()}get nullable(){return yv(this,O2)}get optional(){return new Tne(this)}cast(e){return Bne(e,this),e}expect(e){return Bne(e,this),e}},wB=class extends Nl{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}};const Ds=(e,t=null)=>new wB(e,t),rGn=Ds(wB);var AB=class extends Nl{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape(e);return!n&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}};const ma=e=>new AB(e),iGn=Ds(AB);var P2=class extends Nl{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape.some(r=>r===e);return!n&&t?.extend(null,this.shape.join(" | "),e.toString()),n}};const L2=(...e)=>new P2(e),Sne=Ds(P2);var bGe=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),xne=e=>{if(vv.check(e))return[bGe(e)];if(Sne.check(e))return e.shape.map(t=>t+"");if(Dne.check(e))return["[+-]?\\d+.?\\d*"];if(One.check(e))return[".*"];if(N2.check(e))return e.shape.map(xne).flat(1);Pl()},vGe=class extends Nl{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(xne).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}};const oGn=Ds(vGe);var wGe=Symbol("optional"),Tne=class extends Nl{constructor(e){super(),this.shape=e}check(e,t){const n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,"undefined (optional)","()"),n}get[wGe](){return!0}};const AGe=Ds(Tne);var Ine=class extends Nl{check(e,t){return t?.extend(null,"never",typeof e),!1}};const sGn=new Ine,aGn=Ds(Ine);var kne=class WHe extends Nl{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new WHe(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):mv(this.shape,(r,i)=>{const o=this._isPartial&&!uB(t,i)||r.check(t[i],n);return!o&&n?.extend(i.toString(),r.toString(),typeof t[i],"Object property does not match"),o})}};const SGe=e=>new kne(e),xGe=Ds(kne),TGe=ma(e=>e!=null&&(e.constructor===Object||e.constructor==null));var Ene=class extends Nl{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&mv(e,(n,r)=>{const i=this.shape.keys.check(r,t);return!i&&t?.extend(r+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(n,t)})}};const Cne=(e,t)=>new Ene(e,t),IGe=Ds(Ene);var _ne=class extends Nl{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&mv(this.shape,(n,r)=>{const i=n.check(e[r],t);return!i&&t?.extend(r.toString(),"Tuple",typeof n),i})}};const kGe=(...e)=>new _ne(e),lGn=Ds(_ne);var Rne=class extends Nl{constructor(e){super(),this.shape=e.length===1?e[0]:new SB(e)}check(e,t){const n=N0(e)&&QF(e,r=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}};const Pne=(...e)=>new Rne(e),EGe=Ds(Rne),CGe=ma(e=>N0(e));var Lne=class extends Nl{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}};const _Ge=(e,t=null)=>new Lne(e,t),cGn=Ds(Lne),RGe=_Ge(Nl);var PGe=class extends Nl{constructor(e){super(),this.len=e.length-1,this.args=kGe(...e.slice(-1)),this.res=e[this.len]}check(e,t){const n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,"function",typeof e),n}};const LGe=Ds(PGe),NGe=ma(e=>typeof e=="function");var MGe=class extends Nl{constructor(e){super(),this.shape=e}check(e,t){const n=QF(this.shape,r=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}};const uGn=Ds(MGe,e=>e.shape.length>0);var SB=class extends Nl{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=$F(this.shape,r=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}};const yv=(...e)=>e.findIndex(t=>N2.check(t))>=0?yv(...e.map(t=>cT(t)).map(t=>N2.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new SB(e),N2=Ds(SB);var Nne=()=>!0;const M2=ma(Nne),DGe=Ds(AB,e=>e.shape===Nne),xB=ma(e=>typeof e=="bigint"),OGe=ma(e=>e===xB),Mne=ma(e=>typeof e=="symbol"),dGn=ma(e=>e===Mne),bv=ma(e=>typeof e=="number"),Dne=ma(e=>e===bv),vv=ma(e=>typeof e=="string"),One=ma(e=>e===vv),D2=ma(e=>typeof e=="boolean"),FGe=ma(e=>e===D2),Fne=L2(void 0),fGn=Ds(P2,e=>e.shape.length===1&&e.shape[0]===void 0),hGn=L2(void 0),O2=L2(null),BGe=Ds(P2,e=>e.shape.length===1&&e.shape[0]===null),pGn=Ds(Uint8Array),mGn=Ds(wB,e=>e.shape===Uint8Array),HGe=yv(bv,vv,O2,Fne,xB,D2,Mne),gGn=(()=>{const e=Pne(M2),t=Cne(vv,M2),n=yv(bv,vv,O2,D2,e,t);return e.shape=n,t.shape.values=n,n})(),cT=e=>{if(RGe.check(e))return e;if(TGe.check(e)){const t={};for(const n in e)t[n]=cT(e[n]);return SGe(t)}else{if(CGe.check(e))return yv(...e.map(cT));if(HGe.check(e))return L2(e);if(NGe.check(e))return Ds(e)}Pl()},Bne=YWe?()=>{}:(e,t)=>{const n=new yGe;if(!t.check(e,n))throw xf(`Expected value to be of type ${t.constructor.name}.
3
3
  ${n.toString()}`)};var zGe=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:cT(e),h:t}),this}else(e){return this.if(M2,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw xf("Unhandled pattern")}}},Hne=(e=>new zGe(e))(M2).if(Dne,(e,t)=>gB(t,Kte,A2)).if(One,(e,t)=>mGe(t)).if(FGe,(e,t)=>wne(t)).if(OGe,(e,t)=>BigInt(gB(t,Kte,A2))).if(N2,(e,t)=>wv(t,bB(t,e.shape))).if(xGe,(e,t)=>{const n={};for(const r in e.shape){let i=e.shape[r];if(AGe.check(i)){if(wne(t))continue;i=i.shape}n[r]=Hne(i,t)}return n}).if(EGe,(e,t)=>{const n=[],r=Ane(t,0,42);for(let i=0;i<r;i++)n.push(wv(t,e.shape));return n}).if(Sne,(e,t)=>bB(t,e.shape)).if(BGe,(e,t)=>null).if(LGe,(e,t)=>{const n=wv(t,e.res);return()=>n}).if(DGe,(e,t)=>wv(t,bB(t,[bv,vv,O2,Fne,xB,D2,Pne(bv),Cne(yv("a","b","c"),bv)]))).if(IGe,(e,t)=>{const n={},r=gB(t,0,3);for(let i=0;i<r;i++){const o=wv(t,e.shape.keys);n[o]=wv(t,e.shape.values)}return n}).done();const wv=(e,t)=>Hne(cT(t),e),ym=typeof document<"u"?document:{},bGn=ma(e=>e.nodeType===jGe),vGn=typeof DOMParser<"u"?new DOMParser:null,wGn=ma(e=>e.nodeType===VGe),AGn=ma(e=>e.nodeType===WGe),UGe=e=>PWe(e,(t,n)=>`${n}:${t};`).join(""),VGe=ym.ELEMENT_NODE,WGe=ym.TEXT_NODE,SGn=ym.CDATA_SECTION_NODE,xGn=ym.COMMENT_NODE,GGe=ym.DOCUMENT_NODE,TGn=ym.DOCUMENT_TYPE_NODE,jGe=ym.DOCUMENT_FRAGMENT_NODE,IGn=ma(e=>e.nodeType===GGe);var F2=e=>class{constructor(n){this._=n}destroy(){e(this._)}},qGe=F2(clearTimeout);const TB=(e,t)=>new qGe(setTimeout(t,e));var kGn=F2(clearInterval);const EGn=F2(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var CGn=F2(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));const Wh=Symbol,zne=Wh(),Une=Wh(),YGe=Wh(),KGe=Wh(),XGe=Wh(),Vne=Wh(),JGe=Wh(),IB=Wh(),ZGe=Wh(),QGe=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let r=0;for(;r<e.length;r++){const i=e[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)t.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){const i=e[r];i instanceof Symbol||n.push(i)}return n};var _Gn=xd(),$Ge={[zne]:Vh("font-weight","bold"),[Une]:Vh("font-weight","normal"),[YGe]:Vh("color","blue"),[XGe]:Vh("color","green"),[KGe]:Vh("color","grey"),[Vne]:Vh("color","red"),[JGe]:Vh("color","purple"),[IB]:Vh("color","orange"),[ZGe]:Vh("color","black")},eje=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=Ll();let i=[],o=0;for(;o<e.length;o++){const s=e[o],a=$Ge[s];if(a!==void 0)r.set(a.left,a.right);else{if(s===void 0)break;if(s.constructor===String||s.constructor===Number){const l=UGe(r);o>0||l.length>0?(t.push("%c"+s),n.push(l)):t.push(s)}else break}}for(o>0&&(i=n,i.unshift(t.join("")));o<e.length;o++){const s=e[o];s instanceof Symbol||i.push(s)}return i},Wne=XWe?eje:QGe;const tje=(...e)=>{console.log(...Wne(e)),jne.forEach(t=>t.print(e))},Gne=(...e)=>{console.warn(...Wne(e)),e.unshift(IB),jne.forEach(t=>t.print(e))},jne=Hh(),qne=e=>({[Symbol.iterator](){return this},next:e}),nje=(e,t)=>qne(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),kB=(e,t)=>qne(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var B2=class{constructor(e,t){this.clock=e,this.len=t}},Av=class{constructor(){this.clients=new Map}},bm=(e,t,n)=>t.clients.forEach((r,i)=>{const o=e.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])dre(e,o,c.clock,c.len,n)}}),rje=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const i=Au((n+r)/2),o=e[i],s=o.clock;if(s<=t){if(t<s+o.len)return i;n=i+1}else r=i-1}return null},Sv=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&rje(n,t.clock)!==null},EB=e=>{e.clients.forEach(t=>{t.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n<t.length;n++){const i=t[r-1],o=t[n];i.clock+i.len>=o.clock?t[r-1]=new B2(i.clock,Sd(i.len,o.clock+o.len-i.clock)):(r<n&&(t[r]=o),r++)}t.length=r})},CB=e=>{const t=new Av;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){const o=r.slice();for(let s=n+1;s<e.length;s++)nWe(o,e[s].clients.get(i)||[]);t.clients.set(i,o)}});return EB(t),t},uT=(e,t,n,r)=>{xu(e.clients,t,()=>[]).push(new B2(n,r))},_B=()=>new Av,Yne=e=>{const t=_B();return e.clients.forEach((n,r)=>{const i=[];for(let o=0;o<n.length;o++){const s=n[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;i.push(new B2(a,l))}}i.length>0&&t.clients.set(r,i)}),t},xv=(e,t)=>{xn(e.restEncoder,t.clients.size),zh(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),xn(e.restEncoder,n);const i=r.length;xn(e.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];e.writeDsClock(s.clock),e.writeDsLen(s.len)}})},RB=e=>{const t=new Av,n=Sr(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const i=Sr(e.restDecoder),o=Sr(e.restDecoder);if(o>0){const s=xu(t.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new B2(e.readDsClock(),e.readDsLen()))}}return t},Kne=(e,t,n)=>{const r=new Av,i=Sr(e.restDecoder);for(let o=0;o<i;o++){e.resetDsCurVal();const s=Sr(e.restDecoder),a=Sr(e.restDecoder),l=n.clients.get(s)||[],c=bs(n,s);for(let u=0;u<a;u++){const d=e.readDsClock(),f=d+e.readDsLen();if(d<c){c<f&&uT(r,s,c,f-c);let h=Td(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,Q2(t,p,d-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&l.splice(h,0,Q2(t,p,f-p.id.clock)),p.delete(t))}else uT(r,s,d,f-d)}}if(r.clients.size>0){const o=new D0;return xn(o.restEncoder,0),xv(o,r),o.toUint8Array()}return null},Xne=bne,Gh=class GHe extends mB{constructor({guid:t=fGe(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=Xne(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new lre,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=vne(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>vne(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&so(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(zh(this.subdocs).map(t=>t.guid))}transact(t,n=null){return so(this,t,n)}get(t,n=ga){const r=xu(this.share,t,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==ga&&i!==n)if(i===ga){const o=new n;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(t,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,X2)}getText(t=""){return this.get(t,bT)}getMap(t=""){return this.get(t,Fa)}getXmlElement(t=""){return this.get(t,Tu)}getXmlFragment(t=""){return this.get(t,_v)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,zh(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new GHe({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,so(t.parent.doc,r=>{const i=n.doc;t.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Jne=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Sr(this.restDecoder)}readDsLen(){return Sr(this.restDecoder)}},Zne=class extends Jne{readLeftID(){return Nr(Sr(this.restDecoder),Sr(this.restDecoder))}readRightID(){return Nr(Sr(this.restDecoder),Sr(this.restDecoder))}readClient(){return Sr(this.restDecoder)}readInfo(){return pv(this.restDecoder)}readString(){return Wc(this.restDecoder)}readParentInfo(){return Sr(this.restDecoder)===1}readTypeRef(){return Sr(this.restDecoder)}readLen(){return Sr(this.restDecoder)}readAny(){return aT(this.restDecoder)}readBuf(){return rGe(Oa(this.restDecoder))}readJSON(){return JSON.parse(Wc(this.restDecoder))}readKey(){return Wc(this.restDecoder)}},ije=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Sr(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Sr(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Tv=class extends ije{constructor(e){super(e),this.keys=[],Sr(e),this.keyClockDecoder=new aB(Oa(e)),this.clientDecoder=new E2(Oa(e)),this.leftClockDecoder=new aB(Oa(e)),this.rightClockDecoder=new aB(Oa(e)),this.infoDecoder=new nne(Oa(e),pv),this.stringDecoder=new IWe(Oa(e)),this.parentInfoDecoder=new nne(Oa(e),pv),this.typeRefDecoder=new E2(Oa(e)),this.lenDecoder=new E2(Oa(e))}readLeftID(){return new Iv(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Iv(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return aT(this.restDecoder)}readBuf(){return Oa(this.restDecoder)}readJSON(){return aT(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}},Qne=class{constructor(){this.restEncoder=Xs()}toUint8Array(){return To(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){xn(this.restEncoder,e)}writeDsLen(e){xn(this.restEncoder,e)}},dT=class extends Qne{writeLeftID(e){xn(this.restEncoder,e.client),xn(this.restEncoder,e.clock)}writeRightID(e){xn(this.restEncoder,e.client),xn(this.restEncoder,e.clock)}writeClient(e){xn(this.restEncoder,e)}writeInfo(e){tB(this.restEncoder,e)}writeString(e){pa(this.restEncoder,e)}writeParentInfo(e){xn(this.restEncoder,e?1:0)}writeTypeRef(e){xn(this.restEncoder,e)}writeLen(e){xn(this.restEncoder,e)}writeAny(e){hv(this.restEncoder,e)}writeBuf(e){Ko(this.restEncoder,e)}writeJSON(e){pa(this.restEncoder,JSON.stringify(e))}writeKey(e){pa(this.restEncoder,e)}},$ne=class{constructor(){this.restEncoder=Xs(),this.dsCurrVal=0}toUint8Array(){return To(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,xn(this.restEncoder,t)}writeDsLen(e){e===0&&Pl(),xn(this.restEncoder,e-1),this.dsCurrVal+=e}},D0=class extends $ne{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new oB,this.clientEncoder=new T2,this.leftClockEncoder=new oB,this.rightClockEncoder=new oB,this.infoEncoder=new Zte(tB),this.stringEncoder=new wWe,this.parentInfoEncoder=new Zte(tB),this.typeRefEncoder=new T2,this.lenEncoder=new T2}toUint8Array(){const e=Xs();return xn(e,0),Ko(e,this.keyClockEncoder.toUint8Array()),Ko(e,this.clientEncoder.toUint8Array()),Ko(e,this.leftClockEncoder.toUint8Array()),Ko(e,this.rightClockEncoder.toUint8Array()),Ko(e,To(this.infoEncoder)),Ko(e,this.stringEncoder.toUint8Array()),Ko(e,To(this.parentInfoEncoder)),Ko(e,this.typeRefEncoder.toUint8Array()),Ko(e,this.lenEncoder.toUint8Array()),x2(e,To(this.restEncoder)),To(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){hv(this.restEncoder,e)}writeBuf(e){Ko(this.restEncoder,e)}writeJSON(e){hv(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},oje=(e,t,n,r)=>{r=Sd(r,t[0].id.clock);const i=Td(t,r);xn(e.restEncoder,t.length-i),e.writeClient(n),xn(e.restEncoder,r);const o=t[i];o.write(e,r-o.id.clock);for(let s=i+1;s<t.length;s++)t[s].write(e,0)},PB=(e,t,n)=>{const r=new Map;n.forEach((i,o)=>{bs(t,o)>i&&r.set(o,i)}),mT(t).forEach((i,o)=>{n.has(o)||r.set(o,0)}),xn(e.restEncoder,r.size),zh(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{oje(e,t.clients.get(i),i,o)})},sje=(e,t)=>{const n=Ll(),r=Sr(e.restDecoder);for(let i=0;i<r;i++){const o=Sr(e.restDecoder),s=new Array(o),a=e.readClient();let l=Sr(e.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const u=e.readInfo();switch(31&u){case 0:{const d=e.readLen();s[c]=new Iu(Nr(a,l),d),l+=d;break}case 10:{const d=Sr(e.restDecoder);s[c]=new ku(Nr(a,l),d),l+=d;break}default:{const d=(u&192)===0,f=new Io(Nr(a,l),null,(u&128)===128?e.readLeftID():null,null,(u&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(u&32)===32?e.readString():null,Wre(e,u));s[c]=f,l+=f.length}}}}return n},aje=(e,t,n)=>{const r=[];let i=zh(n.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let h=n.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=n.get(i[i.length-1]);else return null;return h};let s=o();if(s===null)return null;const a=new lre,l=new Map,c=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let u=s.refs[s.i++];const d=new Map,f=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),i=i.filter(g=>g!==p)}r.length=0};for(;;){if(u.constructor!==ku){const h=xu(d,u.id.client,()=>bs(t,u.id.client))-u.id.clock;if(h<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const p=u.getMissing(e,t);if(p!==null){r.push(u);const m=n.get(p)||{refs:[],i:0};if(m.refs.length===m.i)c(p,bs(t,p)),f();else{u=m.refs[m.i++];continue}}else(h===0||h<u.length)&&(u.integrate(e,h),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(s!==null&&s.i<s.refs.length)u=s.refs[s.i++];else{if(s=o(),s===null)break;u=s.refs[s.i++]}}if(a.clients.size>0){const h=new D0;return PB(h,a,new Map),xn(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},lje=(e,t)=>PB(e,t.doc.store,t.beforeState),cje=(e,t,n,r=new Tv(e))=>so(t,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=aje(i,a,sje(r,s)),c=a.pendingStructs;if(c){for(const[d,f]of c.missing)if(f<bs(a,d)){o=!0;break}if(l){for(const[d,f]of l.missing){const h=c.missing.get(d);(h==null||h>f)&&c.missing.set(d,f)}c.update=V2([c.update,l.update])}}else a.pendingStructs=l;const u=Kne(r,i,a);if(a.pendingDs){const d=new Tv(Uh(a.pendingDs));Sr(d.restDecoder);const f=Kne(d,i,a);u&&f?a.pendingDs=V2([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(o){const d=a.pendingStructs.update;a.pendingStructs=null,H2(i.doc,d)}},n,!1),H2=(e,t,n,r=Tv)=>{const i=Uh(t);cje(i,e,n,new r(i))},ere=(e,t,n)=>H2(e,t,n,Zne),uje=(e,t,n=new Map)=>{PB(e,t.store,n),xv(e,Yne(t.store))},dje=(e,t=new Uint8Array([0]),n=new D0)=>{uje(n,e,tre(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Rje(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===dT)return Cje(r.map((i,o)=>o===0?i:Lje(i)));if(n.constructor===D0)return V2(r)}return r[0]},LB=(e,t)=>dje(e,t,new dT),fje=e=>{const t=new Map,n=Sr(e.restDecoder);for(let r=0;r<n;r++){const i=Sr(e.restDecoder),o=Sr(e.restDecoder);t.set(i,o)}return t},tre=e=>fje(new Jne(Uh(e))),nre=(e,t)=>(xn(e.restEncoder,t.size),zh(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{xn(e.restEncoder,n),xn(e.restEncoder,r)}),e),hje=(e,t)=>nre(e,mT(t.store)),pje=(e,t=new $ne)=>(e instanceof Map?nre(t,e):hje(t,e),t.toUint8Array()),mje=e=>pje(e,new Qne),gje=class{constructor(){this.l=[]}},rre=()=>new gje,ire=(e,t)=>e.l.push(t),ore=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter(i=>t!==i),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},sre=(e,t,n)=>dB(e.l,[t,n]),Iv=class{constructor(e,t){this.client=e,this.clock=t}},kv=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Nr=(e,t)=>new Iv(e,t),fT=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw Pl()},hT=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},pT=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},O0=e=>new pT(e.type==null?null:Nr(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Nr(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),yje=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},bje=(e,t,n=0)=>new yje(e,t,n),z2=(e,t,n)=>{let r=null,i=null;return e._item===null?i=fT(e):r=Nr(e._item.id.client,e._item.id.clock),new pT(r,i,t,n)},NB=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return z2(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return z2(e,Nr(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return z2(e,r.lastId,n);r=r.right}return z2(e,null,n)},vje=(e,t)=>{const n=Ev(e,t);return{item:n,diff:t.clock-n.id.clock}},wje=(e,t,n=!0)=>{const r=t.store,i=e.item,o=e.type,s=e.tname,a=e.assoc;let l=null,c=0;if(i!==null){if(bs(r,i.client)<=i.clock)return null;const u=n?ZB(r,i):vje(r,i),d=u.item;if(!(d instanceof Io))return null;if(l=d.parent,l._item===null||!l._item.deleted){c=d.deleted||!d.countable?0:u.diff+(a>=0?0:1);let f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(s!==null)l=t.get(s);else if(o!==null){if(bs(r,o.client)<=o.clock)return null;const{item:u}=n?ZB(r,o):{item:Ev(r,o)};if(u instanceof Io&&u.content instanceof jh)l=u.content.type;else return null}else throw Pl();a>=0?c=l._length:c=0}return bje(l,c,e.assoc)},are=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&kv(e.item,t.item)&&kv(e.type,t.type)&&e.assoc===t.assoc,MB=class{constructor(e,t){this.ds=e,this.sv=t}},DB=(e,t)=>new MB(e,t),RGn=DB(_B(),new Map),OB=e=>DB(Yne(e.store),mT(e.store)),F0=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Sv(t.ds,e.id),FB=(e,t)=>{const n=xu(e.meta,FB,Hh),r=e.doc.store;n.has(t)||(t.sv.forEach((i,o)=>{i<bs(r,o)&&hc(e,Nr(o,i))}),bm(e,t.ds,i=>{}),n.add(t))},lre=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},mT=e=>{const t=new Map;return e.clients.forEach((n,r)=>{const i=n[n.length-1];t.set(r,i.id.clock+i.length)}),t},bs=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},cre=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw Pl()}n.push(t)},Td=(e,t)=>{let n=0,r=e.length-1,i=e[r],o=i.id.clock;if(o===t)return r;let s=Au(t/(o+i.length-1)*r);for(;n<=r;){if(i=e[s],o=i.id.clock,o<=t){if(t<o+i.length)return s;n=s+1}else r=s-1;s=Au((n+r)/2)}throw Pl()},Aje=(e,t)=>{const n=e.clients.get(t.client);return n[Td(n,t.clock)]},Ev=Aje,BB=(e,t,n)=>{const r=Td(t,n),i=t[r];return i.id.clock<n&&i instanceof Io?(t.splice(r+1,0,Q2(e,i,n-i.id.clock)),r+1):r},hc=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[BB(e,n,t.clock)]},ure=(e,t,n)=>{const r=t.clients.get(n.client),i=Td(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Iu&&r.splice(i+1,0,Q2(e,o,n.clock-o.id.clock+1)),o},Sje=(e,t,n)=>{const r=e.clients.get(t.id.client);r[Td(r,t.id.clock)]=n},dre=(e,t,n,r,i)=>{if(r===0)return;const o=n+r;let s=BB(e,t,n),a;do a=t[s++],o<a.id.clock+a.length&&BB(e,t,o),i(a);while(s<t.length&&t[s].id.clock<o)},xje=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Av,this.beforeState=mT(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},fre=(e,t)=>t.deleteSet.clients.size===0&&!LWe(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(EB(t.deleteSet),lje(e,t),xv(e,t.deleteSet),!0),hre=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&xu(e.changed,t,Hh).add(n)},U2=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Io&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=t-i;return o&&e.splice(t+1-o,o),o},Tje=(e,t,n)=>{for(const[r,i]of e.clients.entries()){const o=t.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=Td(o,a.clock),u=o[c];c<o.length&&u.id.clock<l;u=o[++c]){const d=o[c];if(a.clock+a.len<=d.id.clock)break;d instanceof Io&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},Ije=(e,t)=>{e.clients.forEach((n,r)=>{const i=t.clients.get(r);for(let o=n.length-1;o>=0;o--){const s=n[o],a=Sf(i.length-1,1+Td(i,s.clock+s.len-1));for(let l=a,c=i[l];l>0&&c.id.clock>=s.clock;c=i[l])l-=1+U2(i,l)}})},pre=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{EB(o),n.afterState=mT(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),a.push(()=>{sre(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&qje(n)})}),dB(a,[])}finally{r.gc&&Tje(o,i,r.gcFilter),Ije(o,i),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=Sd(Td(h,f),1);for(let m=h.length-1;m>=p;)m-=1+U2(h,m)}});for(let u=s.length-1;u>=0;u--){const{client:d,clock:f}=s[u].id,h=i.clients.get(d),p=Td(h,f);p+1<h.length&&U2(h,p+1)>1||p>0&&U2(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(tje(IB,zne,"[yjs] ",Une,Vne,"Changed the client-id because another client seems to be using it."),r.clientID=Xne()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new dT;fre(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new D0;fre(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(u=>u.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):pre(e,t+1)}}},so=(e,t,n=null,r=!0)=>{const i=e._transactionCleanups;let o=!1,s=null;e._transaction===null&&(o=!0,e._transaction=new xje(e,n,r),i.push(e._transaction),i.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(o){const a=e._transaction===i[0];e._transaction=null,a&&pre(i,0)}}return s},kje=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},mre=(e,t,n)=>{bm(e,n.deletions,r=>{r instanceof Io&&t.scope.some(i=>i===e.doc||hT(i,r))&&QB(r,!1)})},gre=(e,t,n)=>{let r=null;const i=e.doc,o=e.scope;so(i,a=>{for(;t.length>0&&e.currStackItem===null;){const l=i.store,c=t.pop(),u=new Set,d=[];let f=!1;bm(a,c.insertions,h=>{if(h instanceof Io){if(h.redone!==null){let{item:p,diff:m}=ZB(l,h.id);m>0&&(p=hc(a,Nr(p.id.client,p.id.clock+m))),h=p}!h.deleted&&o.some(p=>p===a.doc||hT(p,h))&&d.push(h)}}),bm(a,c.deletions,h=>{h instanceof Io&&o.some(p=>p===a.doc||hT(p,h))&&!Sv(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=Vre(a,h,u,c.insertions,e.ignoreRemoteMapChanges,e)!==null||f});for(let h=d.length-1;h>=0;h--){const p=d[h];e.deleteFilter(p)&&(p.delete(a),f=!0)}e.currStackItem=f?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},e);const s=e.currStackItem;if(s!=null){const a=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:a,origin:e},e]),e.currStackItem=null}return s},yre=class extends mB{constructor(e,{captureTimeout:t=500,captureTransaction:n=a=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:s=N0(e)?e[0].doc:e instanceof Gh?e:e.doc}={}){super(),this.scope=[],this.doc=s,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(m=>a.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const l=this.undoing,c=this.redoing,u=l?this.redoStack:this.undoStack;l?this.stopCapturing():c||this.clear(!1,!0);const d=new Av;a.afterState.forEach((m,g)=>{const y=a.beforeState.get(g)||0,v=m-y;v>0&&uT(d,g,y,v)});const f=xd();let h=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!l&&!c){const m=u[u.length-1];m.deletions=CB([m.deletions,a.deleteSet]),m.insertions=CB([m.insertions,d])}else u.push(new kje(a.deleteSet,d)),h=!0;!l&&!c&&(this.lastChange=f),bm(a,a.deleteSet,m=>{m instanceof Io&&this.scope.some(g=>g===a.doc||hT(g,m))&&QB(m,!0)});const p=[{stackItem:u[u.length-1],origin:a.origin,type:l?"redo":"undo",changedParentTypes:a.changedParentTypes},this];h?this.emit("stack-item-added",p):this.emit("stack-item-updated",p)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=N0(e)?e:[e],e.forEach(n=>{t.has(n)||(t.add(n),(n instanceof ga?n.doc!==this.doc:n!==this.doc)&&Gne("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(r=>mre(n,this,r)),this.undoStack=[]),t&&(this.redoStack.forEach(r=>mre(n,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=gre(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=gre(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*Eje(e){const t=Sr(e.restDecoder);for(let n=0;n<t;n++){const r=Sr(e.restDecoder),i=e.readClient();let o=Sr(e.restDecoder);for(let s=0;s<r;s++){const a=e.readInfo();if(a===10){const l=Sr(e.restDecoder);yield new ku(Nr(i,o),l),o+=l}else if((31&a)!==0){const l=(a&192)===0,c=new Io(Nr(i,o),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(a&32)===32?e.readString():null,Wre(e,a));yield c,o+=c.length}else{const l=e.readLen();yield new Iu(Nr(i,o),l),o+=l}}}}var HB=class{constructor(e,t){this.gen=Eje(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ku);return this.curr}},zB=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Cje=e=>V2(e,Zne,dT),_je=(e,t)=>{if(e.constructor===Iu){const{client:n,clock:r}=e.id;return new Iu(Nr(n,r+t),e.length-t)}else if(e.constructor===ku){const{client:n,clock:r}=e.id;return new ku(Nr(n,r+t),e.length-t)}else{const n=e,{client:r,clock:i}=n.id;return new Io(Nr(r,i+t),null,Nr(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},V2=(e,t=Tv,n=D0)=>{if(e.length===1)return e[0];const r=e.map(l=>new t(Uh(l)));let i=r.map(l=>new HB(l,!0)),o=null;const s=new n,a=new zB(s);for(;i=i.filter(u=>u.curr!==null),i.sort((u,d)=>{if(u.curr.id.client===d.curr.id.client){const f=u.curr.id.clock-d.curr.id.clock;return f===0?u.curr.constructor===d.curr.constructor?0:u.curr.constructor===ku?1:-1:f}else return d.curr.id.client-u.curr.id.client}),i.length!==0;){const l=i[0],c=l.curr.id.client;if(o!==null){let u=l.curr,d=!1;for(;u!==null&&u.id.clock+u.length<=o.struct.id.clock+o.struct.length&&u.id.client>=o.struct.id.client;)u=l.next(),d=!0;if(u===null||u.id.client!==c||d&&u.id.clock>o.struct.id.clock+o.struct.length)continue;if(c!==o.struct.id.client)vm(a,o.struct,o.offset),o={struct:u,offset:0},l.next();else if(o.struct.id.clock+o.struct.length<u.id.clock)if(o.struct.constructor===ku)o.struct.length=u.id.clock+u.length-o.struct.id.clock;else{vm(a,o.struct,o.offset);const f=u.id.clock-o.struct.id.clock-o.struct.length;o={struct:new ku(Nr(c,o.struct.id.clock+o.struct.length),f),offset:0}}else{const f=o.struct.id.clock+o.struct.length-u.id.clock;f>0&&(o.struct.constructor===ku?o.struct.length-=f:u=_je(u,f)),o.struct.mergeWith(u)||(vm(a,o.struct,o.offset),o={struct:u,offset:0},l.next())}}else o={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===c&&u.id.clock===o.struct.id.clock+o.struct.length&&u.constructor!==ku;u=l.next())vm(a,o.struct,o.offset),o={struct:u,offset:0}}return o!==null&&(vm(a,o.struct,o.offset),o=null),UB(a),xv(s,CB(r.map(l=>RB(l)))),s.toUint8Array()},Rje=(e,t,n=Tv,r=D0)=>{const i=tre(t),o=new r,s=new zB(o),a=new n(Uh(e)),l=new HB(a,!1);for(;l.curr;){const c=l.curr,u=c.id.client,d=i.get(u)||0;if(l.curr.constructor===ku){l.next();continue}if(c.id.clock+c.length>d)for(vm(s,c,Sd(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)vm(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}return UB(s),xv(o,RB(a)),o.toUint8Array()},bre=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:To(e.encoder.restEncoder)}),e.encoder.restEncoder=Xs(),e.written=0)},vm=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&bre(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),xn(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},UB=e=>{bre(e);const t=e.encoder.restEncoder;xn(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];xn(t,r.written),x2(t,r.restEncoder)}},Pje=(e,t,n,r)=>{const i=new n(Uh(e)),o=new HB(i,!1),s=new r,a=new zB(s);for(let l=o.curr;l!==null;l=o.next())vm(a,t(l),0);return UB(a),xv(s,RB(i)),s.toUint8Array()},Lje=e=>Pje(e,WWe,Tv,dT),vre="You must not compute changes after the event-handler fired.",W2=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Nje(this.currentTarget,this.target))}deletes(e){return Sv(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw xf(vre);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const r=t._map.get(n);let i,o;if(this.adds(r)){let s=r.left;for(;s!==null&&this.adds(s);)s=s.left;if(this.deletes(r))if(s!==null&&this.deletes(s))i="delete",o=ZF(s.content.getContent());else return;else s!==null&&this.deletes(s)?(i="update",o=ZF(s.content.getContent())):(i="add",o=void 0)}else if(this.deletes(r))i="delete",o=ZF(r.content.getContent());else return;e.set(n,{action:i,oldValue:o})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw xf(vre);const t=this.target,n=Hh(),r=Hh(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let o=null;const s=()=>{o&&i.push(o)};for(let a=t._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((o===null||o.delete===void 0)&&(s(),o={delete:0}),o.delete+=a.length,r.add(a)):this.adds(a)?((o===null||o.insert===void 0)&&(s(),o={insert:[]}),o.insert=o.insert.concat(a.content.getContent()),n.add(a)):((o===null||o.retain===void 0)&&(s(),o={retain:0}),o.retain+=a.length);o!==null&&o.retain===void 0&&s()}this._changes=e}return e}},Nje=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,i=t._item.parent._start;for(;i!==t._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}t=t._item.parent}return n},ol=()=>{Gne("Invalid access: Add Yjs type to a document before reading data.")},wre=80,VB=0,Mje=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=VB++}},Dje=e=>{e.timestamp=VB++},Are=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=VB++},Oje=(e,t,n)=>{if(e.length>=wre){const r=e.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Are(r,t,n),r}else{const r=new Mje(t,n);return e.push(r),r}},G2=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,s)=>w2(t-o.index)<w2(t-s.index)?o:s);let r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Dje(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&w2(n.index-i)<r.parent.length/wre?(Are(n,r,i),n):Oje(e._searchMarker,r,i)},gT=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const i=e[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){e.splice(r,1);continue}i.p=o,o.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Sd(t,i.index+n))}},j2=(e,t,n)=>{const r=e,i=t.changedParentTypes;for(;xu(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;sre(r._eH,n,t)},ga=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=rre(),this._dEH=rre(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Su()}clone(){throw Su()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ire(this._eH,e)}observeDeep(e){ire(this._dEH,e)}unobserve(e){ore(this._eH,e)}unobserveDeep(e){ore(this._dEH,e)}toJSON(){}},Sre=(e,t,n)=>{e.doc??ol(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const i=[];let o=e._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=t)t-=s.length;else{for(let a=t;a<s.length&&r>0;a++)i.push(s[a]),r--;t=0}}o=o.right}return i},xre=e=>{e.doc??ol();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)t.push(r[i])}n=n.right}return t},Tre=(e,t)=>{const n=[];let r=e._start;for(;r!==null;){if(r.countable&&F0(r,t)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},yT=(e,t)=>{let n=0,r=e._start;for(e.doc??ol();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)t(i[o],n++,e)}r=r.right}},Ire=(e,t)=>{const n=[];return yT(e,(r,i)=>{n.push(t(r,i,e))}),n},Fje=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},kre=(e,t)=>{e.doc??ol();const n=G2(e,t);let r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},q2=(e,t,n,r)=>{let i=n;const o=e.doc,s=o.clientID,a=o.store,l=n===null?t._start:n.right;let c=[];const u=()=>{c.length>0&&(i=new Io(Nr(s,bs(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new Z2(c)),i.integrate(e,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:i=new Io(Nr(s,bs(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new XB(new Uint8Array(d))),i.integrate(e,0);break;case Gh:i=new Io(Nr(s,bs(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new JB(d)),i.integrate(e,0);break;default:if(d instanceof ga)i=new Io(Nr(s,bs(a,s)),i,i&&i.lastId,l,l&&l.id,t,null,new jh(d)),i.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Ere=()=>xf("Length exceeded!"),Cre=(e,t,n,r)=>{if(n>t._length)throw Ere();if(n===0)return t._searchMarker&&gT(t._searchMarker,n,r.length),q2(e,t,null,r);const i=n,o=G2(t,n);let s=t._start;for(o!==null&&(s=o.p,n-=o.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&hc(e,Nr(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&gT(t._searchMarker,i,r.length),q2(e,t,s,r)},Bje=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return q2(e,t,r,n)},_re=(e,t,n,r)=>{if(r===0)return;const i=n,o=r,s=G2(t,n);let a=t._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&hc(e,Nr(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&hc(e,Nr(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw Ere();t._searchMarker&&gT(t._searchMarker,i,-o+r)},Y2=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},WB=(e,t,n,r)=>{const i=t._map.get(n)||null,o=e.doc,s=o.clientID;let a;if(r==null)a=new Z2([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Z2([r]);break;case Uint8Array:a=new XB(r);break;case Gh:a=new JB(r);break;default:if(r instanceof ga)a=new jh(r);else throw new Error("Unexpected content type")}new Io(Nr(s,bs(o.store,s)),i,i&&i.lastId,null,null,t,n,a).integrate(e,0)},GB=(e,t)=>{e.doc??ol();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Rre=e=>{const t={};return e.doc??ol(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},Pre=(e,t)=>{e.doc??ol();const n=e._map.get(t);return n!==void 0&&!n.deleted},Hje=(e,t)=>{const n={};return e._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;o!==null&&F0(o,t)&&(n[i]=o.content.getContent()[o.length-1])}),n},K2=e=>(e.doc??ol(),nje(e._map.entries(),t=>!t[1].deleted)),zje=class extends W2{},X2=class p6 extends ga{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new p6;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new p6}clone(){const t=new p6;return t.insert(0,this.toArray().map(n=>n instanceof ga?n.clone():n)),t}get length(){return this.doc??ol(),this._length}_callObserver(t,n){super._callObserver(t,n),j2(this,t,new zje(this,t))}insert(t,n){this.doc!==null?so(this.doc,r=>{Cre(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?so(this.doc,n=>{Bje(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?so(this.doc,r=>{_re(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return kre(this,t)}toArray(){return xre(this)}slice(t=0,n=this.length){return Sre(this,t,n)}toJSON(){return this.map(t=>t instanceof ga?t.toJSON():t)}map(t){return Ire(this,t)}forEach(t){yT(this,t)}[Symbol.iterator](){return Fje(this)}_write(t){t.writeTypeRef(hqe)}},Uje=e=>new X2,Vje=class extends W2{constructor(e,t,n){super(e,t),this.keysChanged=n}},Fa=class jQ extends ga{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new jQ}clone(){const t=new jQ;return this.forEach((n,r)=>{t.set(r,n instanceof ga?n.clone():n)}),t}_callObserver(t,n){j2(this,t,new Vje(this,t,n))}toJSON(){this.doc??ol();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];t[r]=i instanceof ga?i.toJSON():i}}),t}get size(){return[...K2(this)].length}keys(){return kB(K2(this),t=>t[0])}values(){return kB(K2(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return kB(K2(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??ol(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?so(this.doc,n=>{Y2(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?so(this.doc,r=>{WB(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return GB(this,t)}has(t){return Pre(this,t)}clear(){this.doc!==null?so(this.doc,t=>{this.forEach(function(n,r,i){Y2(t,i,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(pqe)}},Wje=e=>new Fa,wm=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&UWe(e,t),jB=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){this.right===null&&Pl(),this.right.content.constructor===ya?this.right.deleted||Cv(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Lre=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===ya?t.right.deleted||Cv(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&hc(e,Nr(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},J2=(e,t,n,r)=>{const i=new Map,o=r?G2(t,n):null;return o?Lre(e,new jB(o.p.left,o.p,o.index,i),n-o.index):Lre(e,new jB(null,t._start,0,i),n)},Nre=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===ya&&wm(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=e.doc,o=i.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,u=new Io(Nr(o,bs(i.store,o)),l,l&&l.lastId,c,c&&c.id,t,null,new ya(a,s));u.integrate(e,0),n.right=u,n.forward()})},Cv=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Mre=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===ya&&wm(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Dre=(e,t,n,r)=>{const i=e.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!wm(c,l)){s.set(a,c);const{left:u,right:d}=n;n.right=new Io(Nr(o,bs(i.store,o)),u,u&&u.lastId,d,d&&d.id,t,null,new ya(a,l)),n.right.integrate(e,0),n.forward()}}return s},qB=(e,t,n,r,i)=>{n.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const o=e.doc,s=o.clientID;Mre(n,i);const a=Dre(e,t,n,i),l=r.constructor===String?new Am(r):r instanceof ga?new jh(r):new vT(r);let{left:c,right:u,index:d}=n;t._searchMarker&&gT(t._searchMarker,n.index,l.getLength()),u=new Io(Nr(s,bs(o.store,s)),c,c&&c.lastId,u,u&&u.id,t,null,l),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Nre(e,t,n,a)},Ore=(e,t,n,r,i)=>{const o=e.doc,s=o.clientID;Mre(n,i);const a=Dre(e,t,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===ya));){if(!n.right.deleted)switch(n.right.content.constructor){case ya:{const{key:l,value:c}=n.right.content,u=i[l];if(u!==void 0){if(wm(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(e)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&hc(e,Nr(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
4
4
  `;n.right=new Io(Nr(s,bs(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Am(l)),n.right.integrate(e,0),n.forward()}Nre(e,t,n,a)},Fre=(e,t,n,r,i)=>{let o=t;const s=Ll();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===ya){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;t!==o;){if(n===t&&(l=!0),!t.deleted){const c=t.content;if(c.constructor===ya){const{key:u,value:d}=c,f=r.get(u)??null;(s.get(u)!==c||f===d)&&(t.delete(e),a++,!l&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!l&&!t.deleted&&Cv(i,c)}}t=t.right}return a},Gje=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===ya){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},jje=e=>{let t=0;return so(e.doc,n=>{let r=e._start,i=e._start,o=Ll();const s=lB(o);for(;i;)i.deleted===!1&&(i.content.constructor===ya?Cv(s,i.content):(t+=Fre(n,r,i,o,s),o=lB(s),r=i)),i=i.right}),t},qje=e=>{const t=new Set,n=e.doc;for(const[r,i]of e.afterState.entries()){const o=e.beforeState.get(r)||0;i!==o&&dre(e,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===ya&&s.constructor!==Iu&&t.add(s.parent)})}so(n,r=>{bm(e,e.deleteSet,i=>{if(i instanceof Iu||!i.parent._hasFormatting||t.has(i.parent))return;const o=i.parent;i.content.constructor===ya?t.add(o):Gje(r,i)});for(const i of t)jje(i)})},Bre=(e,t,n)=>{const r=n,i=lB(t.currentAttributes),o=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case jh:case vT:case Am:n<t.right.length&&hc(e,Nr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}o&&Fre(e,o,t.right,i,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&gT(s._searchMarker,t.index,-r+n),t},Yje=class extends W2{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];so(e,n=>{const r=new Map,i=new Map;let o=this.target._start,s=null;const a={};let l="",c=0,u=0;const d=()=>{if(s!==null){let f=null;switch(s){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},r.size>0&&(f.attributes={},r.forEach((h,p)=>{h!==null&&(f.attributes[p]=h)}))),l="";break;case"retain":c>0&&(f={retain:c},zWe(a)||(f.attributes=FWe({},a))),c=0;break}f&&t.push(f),s=null}};for(;o!==null;){switch(o.content.constructor){case jh:case vT:this.adds(o)?this.deletes(o)||(d(),s="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(s!=="delete"&&(d(),s="delete"),u+=1):o.deleted||(s!=="retain"&&(d(),s="retain"),c+=1);break;case Am:this.adds(o)?this.deletes(o)||(s!=="insert"&&(d(),s="insert"),l+=o.content.str):this.deletes(o)?(s!=="delete"&&(d(),s="delete"),u+=o.length):o.deleted||(s!=="retain"&&(d(),s="retain"),c+=o.length);break;case ya:{const{key:f,value:h}=o.content;if(this.adds(o))this.deletes(o)||(wm(r.get(f)??null,h)?h!==null&&o.delete(n):(s==="retain"&&d(),wm(h,i.get(f)??null)?delete a[f]:a[f]=h));else if(this.deletes(o)){i.set(f,h);const p=r.get(f)??null;wm(p,h)||(s==="retain"&&d(),a[f]=p)}else if(!o.deleted){i.set(f,h);const p=a[f];p!==void 0&&(wm(p,h)?p!==null&&o.delete(n):(s==="retain"&&d(),h===null?delete a[f]:a[f]=h))}o.deleted||(s==="insert"&&d(),Cv(r,o.content));break}}o=o.right}for(d();t.length>0;){const f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},bT=class qQ extends ga{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ol(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new qQ}clone(){const t=new qQ;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new Yje(this,t,n);j2(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??ol();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Am&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?so(this.doc,r=>{const i=new jB(null,this._start,0,new Map);for(let o=0;o<t.length;o++){const s=t[o];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&o===t.length-1&&i.right===null&&s.insert.slice(-1)===`
5
- `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&qB(r,this,i,a,s.attributes||{})}else s.retain!==void 0?Ore(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&Bre(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??ol();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;o.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),i.push(h),a=""}}const u=()=>{for(;l!==null;){if(F0(l,t)||n!==void 0&&F0(l,n))switch(l.content.constructor){case Am:{const d=o.get("ychange");t!==void 0&&!F0(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!F0(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case jh:case vT:{c();const d={insert:l.content.getContent()[0]};if(o.size>0){const f={};d.attributes=f,o.forEach((h,p)=>{f[p]=h})}i.push(d);break}case ya:F0(l,t)&&(c(),Cv(o,l.content));break}l=l.right}c()};return t||n?so(s,d=>{t&&FB(d,t),n&&FB(d,n),u()},"cleanup"):u(),i}insert(t,n,r){if(n.length<=0)return;const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),qB(o,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!r);qB(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;const r=this.doc;r!==null?so(r,i=>{Bre(i,J2(i,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!1);s.right!==null&&Ore(o,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?so(this.doc,n=>{Y2(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?so(this.doc,r=>{WB(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return GB(this,t)}getAttributes(){return Rre(this)}_write(t){t.writeTypeRef(mqe)}},Kje=e=>new bT,YB=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ol()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Tu||t.constructor===_v)&&t._start!==null)e=t._start;else for(;e!==null;){const n=e.next;if(n!==null){e=n;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},_v=class YQ extends ga{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new YQ}clone(){const t=new YQ;return t.insert(0,this.toArray().map(n=>n instanceof ga?n.clone():n)),t}get length(){return this.doc??ol(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new YB(this,t)}querySelector(t){t=t.toUpperCase();const n=new YB(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),zh(new YB(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){j2(this,t,new Zje(this,n,t))}toString(){return Ire(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const i=t.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),yT(this,o=>{i.insertBefore(o.toDOM(t,n,r),null)}),i}insert(t,n){this.doc!==null?so(this.doc,r=>{Cre(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)so(this.doc,r=>{const i=t&&t instanceof ga?t._item:t;q2(r,this,i,n)});else{const r=this._prelimContent,i=t===null?0:r.findIndex(o=>o===t)+1;if(i===0&&t!==null)throw xf("Reference item not found");r.splice(i,0,...n)}}delete(t,n=1){this.doc!==null?so(this.doc,r=>{_re(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return xre(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return kre(this,t)}slice(t=0,n=this.length){return Sre(this,t,n)}forEach(t){yT(this,t)}_write(t){t.writeTypeRef(yqe)}},Xje=e=>new _v,Tu=class KQ extends _v{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new KQ(this.nodeName)}clone(){const t=new KQ(this.nodeName),n=this.getAttributes();return BWe(n,(r,i)=>{t.setAttribute(i,r)}),t.insert(0,this.toArray().map(r=>r instanceof ga?r.clone():r)),t}toString(){const t=this.getAttributes(),n=[],r=[];for(const s in t)r.push(s);r.sort();const i=r.length;for(let s=0;s<i;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?so(this.doc,n=>{Y2(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?so(this.doc,r=>{WB(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return GB(this,t)}hasAttribute(t){return Pre(this,t)}getAttributes(t){return t?Hje(this,t):Rre(this)}toDOM(t=document,n={},r){const i=t.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return yT(this,s=>{i.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(gqe),t.writeKey(this.nodeName)}},Jje=e=>new Tu(e.readKey()),Zje=class extends W2{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}},Qje=class XQ extends Fa{constructor(t){super(),this.hookName=t}_copy(){return new XQ(this.hookName)}clone(){const t=new XQ(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(bqe),t.writeKey(this.hookName)}},$je=e=>new Qje(e.readKey()),If=class JQ extends bT{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new JQ}clone(){const t=new JQ;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const i=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(t=>{const n=[];for(const i in t.attributes){const o=[];for(const s in t.attributes[i])o.push({key:s,value:t.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(vqe)}},eqe=e=>new If,KB=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Su()}mergeWith(e){return!1}write(e,t,n){throw Su()}integrate(e,t){throw Su()}},tqe=0,Iu=class extends KB{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),cre(e.doc.store,this)}write(e,t){e.writeInfo(tqe),e.writeLen(this.length-t)}getMissing(e,t){return null}},XB=class jHe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new jHe(this.content)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},nqe=e=>new XB(e.readBuf()),Hre=class ZQ{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ZQ(this.len)}splice(t){const n=new ZQ(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){uT(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},rqe=e=>new Hre(e.readLen()),zre=(e,t)=>new Gh({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),JB=class qHe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new qHe(zre(this.doc.guid,this.opts))}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},iqe=e=>new JB(zre(e.readString(),e.readAny())),vT=class YHe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new YHe(this.embed)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},oqe=e=>new vT(e.readJSON()),ya=class KHe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new KHe(this.key,this.value)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},sqe=e=>new ya(e.readKey(),e.readJSON()),aqe=class QQ{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new QQ(this.arr)}splice(t){const n=new QQ(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},lqe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const i=e.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new aqe(n)},cqe=R2("node_env")==="development",Z2=class $Q{constructor(t){this.arr=t,cqe&&une(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new $Q(this.arr)}splice(t){const n=new $Q(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeAny(o)}}getRef(){return 8}},uqe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Z2(n)},Am=class e${constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e$(this.str)}splice(t){const n=new e$(this.str.slice(t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},dqe=e=>new Am(e.readString()),fqe=[Uje,Wje,Kje,Jje,Xje,$je,eqe],hqe=0,pqe=1,mqe=2,gqe=3,yqe=4,bqe=5,vqe=6,jh=class XHe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new XHe(this.type._copy())}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},wqe=e=>new jh(fqe[e.readTypeRef()](e)),ZB=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Nr(n.client,n.clock+r)),i=Ev(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Io);return{item:i,diff:r}},QB=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Q2=(e,t,n)=>{const{client:r,clock:i}=t.id,o=new Io(Nr(r,i+n),t,Nr(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=Nr(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},Ure=(e,t)=>$F(e,n=>Sv(n.deletions,t)),Vre=(e,t,n,r,i,o)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return hc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Vre(e,u,n,r,i,o)===null))return null;for(;u.redone!==null;)u=hc(e,u.redone)}const h=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let g=d;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:hc(e,g.redone);if(g!==null&&g.parent._item===u){d=g;break}d=d.left}for(;f!==null;){let g=f;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:hc(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Sv(r,d.right.id)||Ure(o.undoStack,d.right.id)||Ure(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=hc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Nr(l,bs(a,l)),m=new Io(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,QB(m,!0),m.integrate(e,0),m},Io=class t$ extends KB{constructor(t,n,r,i,o,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bs(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bs(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Iv&&this.id.client!==this.parent.client&&this.parent.clock>=bs(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ure(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=hc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Iu||this.right&&this.right.constructor===Iu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===t$?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===t$&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Iv){const r=Ev(n,this.parent);r.constructor===Iu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ure(t,t.doc.store,Nr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),kv(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(kv(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Ev(t.doc.store,i.origin)))o.has(Ev(t.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),cre(t.doc.store,this),this.content.integrate(t,this),hre(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Iu(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Nr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&kv(t.origin,this.lastId)&&this.right===t&&kv(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),uT(t.deleteSet,this.id.client,this.id.clock,this.length),hre(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Pl();this.content.gc(t),n?Sje(t,this,new Iu(this.id,this.length)):this.content=new Hre(this.length)}write(t,n){const r=n>0?Nr(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(o===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),i!==null&&t.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=fT(a);t.writeParentInfo(!0),t.writeString(c)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else a.constructor===String?(t.writeParentInfo(!0),t.writeString(a)):a.constructor===Iv?(t.writeParentInfo(!1),t.writeLeftID(a)):Pl();o!==null&&t.writeString(o)}this.content.write(t,n)}},Wre=(e,t)=>Aqe[t&31](e),Aqe=[()=>{Pl()},rqe,lqe,nqe,dqe,oqe,sqe,wqe,uqe,iqe,()=>{Pl()}],Sqe=10,ku=class extends KB{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Pl()}write(e,t){e.writeInfo(Sqe),xn(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Gre=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},jre="__ $YJS$ __";Gre[jre]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Gre[jre]=!0;const xqe=3e4;var qre=class extends aGe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=xd();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,i)=>{i!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(i)&&n.push(i)}),n.length>0&&Rv(this,n,"timeout")},Au(xqe/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:xd()});const o=[],s=[],a=[],l=[];e===null?l.push(t):i==null?e!=null&&o.push(t):(s.push(t),gv(i,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const Rv=(e,t,n)=>{const r=[];for(let i=0;i<t.length;i++){const o=t[i];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){const s=e.meta.get(o);e.meta.set(o,{clock:s.clock+1,lastUpdated:xd()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Sm=(e,t,n=e.states)=>{const r=t.length,i=Xs();xn(i,r);for(let o=0;o<r;o++){const s=t[o],a=n.get(s)||null,l=e.meta.get(s).clock;xn(i,s),xn(i,l),pa(i,JSON.stringify(a))}return To(i)},Yre=(e,t,n)=>{const r=Uh(t),i=xd(),o=[],s=[],a=[],l=[],c=Sr(r);for(let u=0;u<c;u++){const d=Sr(r);let f=Sr(r);const h=JSON.parse(Wc(r)),p=e.meta.get(d),m=e.states.get(d),g=p===void 0?0:p.clock;(g<f||g===f&&h===null&&e.states.has(d))&&(h===null?d===e.clientID&&e.getLocalState()!=null?f++:e.states.delete(d):e.states.set(d,h),e.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?o.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(gv(h,m)||a.push(d),s.push(d)))}(o.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:o,updated:s,removed:l},n])};var Kre=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function Tqe(e){return e||(e={}),{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function $B(e){return new Promise(t=>setTimeout(t,e))}function Iqe(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=Math.pow(t.factor,e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){const r=Math.ceil(t.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function kqe(e,t){const n=Tqe(t);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Iqe;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await $B(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const u=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(d){c(d)}else{const d=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);d.code="ATTEMPT_TIMEOUT",c(d)}},n.timeout);e(r,n).then(d=>{clearTimeout(u),l(d)}).catch(d=>{clearTimeout(u),a(d).then(l).catch(c)})}):e(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await $B(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await $B(a)}return o()}const Xre=e=>HWe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let sl=(function(e){return e[e.Sync=0]="Sync",e[e.Awareness=1]="Awareness",e[e.Auth=2]="Auth",e[e.QueryAwareness=3]="QueryAwareness",e[e.Stateless=5]="Stateless",e[e.CLOSE=7]="CLOSE",e[e.SyncStatus=8]="SyncStatus",e})({}),al=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var $2=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=Xs(),this.decoder=Uh(new Uint8Array(this.data))}peekVarString(){return xWe(this.decoder)}readVarUint(){return Sr(this.decoder)}readVarString(){return Wc(this.decoder)}readVarUint8Array(){return Oa(this.decoder)}writeVarUint(e){return xn(this.encoder,e)}writeVarString(e){return pa(this.encoder,e)}writeVarUint8Array(e){return Ko(this.encoder,e)}length(){return S2(this.encoder)}},Jre=class extends Kre{messageQueue=[];configuration={url:"",document:void 0,WebSocketPolyfill:void 0,parameters:{},connect:!0,broadcast:!0,forceSyncInterval:!1,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,quiet:!1,providerMap:new Map};webSocket=null;webSocketHandlers={};shouldConnect=!0;status=al.Disconnected;lastMessageReceived=0;identifier=0;intervals={forceSync:null,connectionChecker:null};connectionAttempt=null;constructor(e){super(),this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("status",this.onStatus.bind(this)),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),typeof e.connect<"u"&&(this.shouldConnect=e.connect),this.shouldConnect&&this.connect()}receivedOnOpenPayload=void 0;receivedOnStatusPayload=void 0;async onOpen(e){this.receivedOnOpenPayload=e}async onStatus(e){this.receivedOnStatusPayload=e}attach(e){let t;return this.configuration.providerMap.set(e.configuration.name,e),this.status===al.Disconnected&&this.shouldConnect&&(t=this.connect()),this.receivedOnOpenPayload&&e.onOpen(this.receivedOnOpenPayload),this.receivedOnStatusPayload&&e.onStatus(this.receivedOnStatusPayload),t}detach(e){this.configuration.providerMap.delete(e.configuration.name)}setConfiguration(e={}){this.configuration={...this.configuration,...e}}cancelWebsocketRetry;async connect(){if(this.status===al.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.receivedOnStatusPayload=void 0,this.shouldConnect=!0;const e=()=>{let r=!1;return{retryPromise:kqe(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,beforeAttempt:i=>{(!this.shouldConnect||r)&&i.abort()}}).catch(i=>{if(i&&i.code!=="ATTEMPT_ABORTED")throw i}),cancelFunc:()=>{r=!0}}},{retryPromise:t,cancelFunc:n}=e();return this.cancelWebsocketRetry=n,t}attachWebSocketListeners(e,t){const{identifier:n}=e,r=l=>this.emit("message",l),i=l=>this.emit("close",{event:l}),o=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:i,open:o,error:s};const a=this.webSocketHandlers[e.identifier];Object.keys(a).forEach(l=>{e.addEventListener(l,a[l])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType="arraybuffer",n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=al.Connecting,this.emit("status",{status:al.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=xd();const t=new $2(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=al.Connected,this.emit("status",{status:al.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}closeTries=0;checkConnection(){this.status===al.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=xd()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){for(;this.configuration.url[this.configuration.url.length-1]==="/";)return this.configuration.url.slice(0,this.configuration.url.length-1);return this.configuration.url}get url(){const e=Xre(this.configuration.parameters);return`${this.serverUrl}${e.length===0?"":`?${e}`}`}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch{}}send(e){this.webSocket?.readyState===RWe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===al.Connected&&(this.status=al.Disconnected,this.emit("status",{status:al.Disconnected}),this.emit("disconnect",{event:e})),e.code===rne.code&&(e.reason===rne.reason?console.warn("[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again."):console.warn(`[HocuspocusProvider] Connection closed with status Unauthorized: ${e.reason}`),this.shouldConnect=!1),e.code===_We.code&&!this.configuration.quiet){console.warn("[HocuspocusProvider] The provided authentication token isn’t allowed to connect to this server. Will try again.");return}e.code===CWe.code&&(console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${e.reason}`),this.shouldConnect=!1),this.connectionAttempt?this.rejectConnectionAttempt():this.shouldConnect&&this.connect(),!this.shouldConnect&&this.status!==al.Disconnected&&(this.status=al.Disconnected,this.emit("status",{status:al.Disconnected}),this.emit("disconnect",{event:e}))}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}};const PGn=0,LGn=1,NGn=2,e1=(e,t)=>{xn(e,0);const n=mje(t);Ko(e,n)},e8=(e,t,n)=>{xn(e,1),Ko(e,LB(t,n))},Eqe=(e,t,n)=>e8(t,n,Oa(e)),Zre=(e,t,n,r)=>{try{ere(t,Oa(e),n)}catch(i){r?.(i),console.error("Caught error while handling a Yjs update",i)}},Qre=(e,t)=>{xn(e,2),Ko(e,t)},Cqe=Zre,$re=(e,t,n,r,i)=>{const o=Sr(e);switch(o){case 0:Eqe(e,t,n);break;case 1:Zre(e,n,r,i);break;case 2:Cqe(e,n,r,i);break;default:throw new Error("Unknown message type")}return o};var kf=class{encoder;type;constructor(){this.encoder=Xs()}get(e){return e.encoder}toUint8Array(){return To(this.encoder)}},eie=class{message;broadcasted=!1;constructor(e){this.message=e}setBroadcasted(e){return this.broadcasted=e,this}apply(e,t){const{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case sl.Sync:this.applySyncMessage(e,t);break;case sl.Awareness:this.applyAwarenessMessage(e);break;case sl.Auth:this.applyAuthMessage(e);break;case sl.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case sl.Stateless:e.receiveStateless(Wc(n.decoder));break;case sl.SyncStatus:this.applySyncStatusMessage(e,k2(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&(this.broadcasted?e.broadcast(kf,{encoder:n.encoder}):e.send(kf,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(sl.Sync);const r=$re(n.decoder,n.encoder,e.document,e);t&&r===1&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;Yre(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;EWe(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(sl.Awareness),t.writeVarUint8Array(Sm(e.awareness,Array.from(e.awareness.getStates().keys())))}},tie=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return To(this.encoder)}send(e){e?.send(this.create())}broadcast(e){M0(e,this.create())}},_qe=class extends kf{type=sl.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),kWe(this.encoder,e.token),this.encoder}},t1=class extends kf{type=sl.Awareness;description="Awareness states update";get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");pa(this.encoder,e.documentName),xn(this.encoder,this.type);let t;return e.states===void 0?t=Sm(e.awareness,e.clients):t=Sm(e.awareness,e.clients,e.states),Ko(this.encoder,t),this.encoder}},Rqe=class extends kf{type=sl.CLOSE;description="Ask the server to close the connection";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),this.encoder}},Pqe=class extends kf{type=sl.QueryAwareness;description="Queries awareness states";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),this.encoder}},Lqe=class extends kf{type=sl.Stateless;description="A stateless message";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),pa(this.encoder,e.payload??""),this.encoder}},t8=class extends kf{type=sl.Sync;description="First sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),e1(this.encoder,e.document),this.encoder}},Nqe=class extends kf{type=sl.Sync;description="Second sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step two message requires document as an argument");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),e8(this.encoder,e.document),this.encoder}},Mqe=class extends kf{type=sl.Sync;description="A document update";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),Qre(this.encoder,e.update),this.encoder}},Dqe=class extends Error{code=1001},Oqe=class extends Kre{configuration={name:"",document:void 0,awareness:void 0,token:null,parameters:{},broadcast:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onSynced:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,quiet:!1,connect:!0,preserveConnection:!0};subscribedToBroadcastChannel=!1;isSynced=!1;unsyncedChanges=0;status=al.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=yne();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Gh,this.configuration.awareness=e.awareness!==void 0?e.awareness:new qre(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("open",this.forwardOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("status",this.boundOnStatus),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.awareness?.on("update",()=>{this.emit("awarenessUpdate",{states:ine(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:ine(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),this.awareness?.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.configuration.websocketProvider.attach(this)}boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this);boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this);boundBroadcastChannelSubscriber=this.broadcastChannelSubscriber.bind(this);boundPageHide=this.pageHide.bind(this);boundOnOpen=this.onOpen.bind(this);boundOnClose=this.onClose.bind(this);boundOnStatus=this.onStatus.bind(this);forwardConnect=e=>this.emit("connect",e);forwardOpen=e=>this.emit("open",e);forwardClose=e=>this.emit("close",e);forwardDisconnect=e=>this.emit("disconnect",e);forwardDestroy=e=>this.emit("destroy",e);onStatus({status:e}){this.status=e,this.configuration.onStatus({status:e}),this.emit("status",{status:e})}setConfiguration(e={}){if(!e.websocketProvider&&e.url){const t=e;this.configuration.websocketProvider=new Jre({url:t.url,connect:t.connect,parameters:t.parameters})}this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",this.unsyncedChanges)}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",this.unsyncedChanges)}decrementUnsyncedChanges(){this.unsyncedChanges-=1,this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",this.unsyncedChanges)}forceSync(){this.resetUnsyncedChanges(),this.send(t8,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Rv(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(Lqe,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Mqe,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const i=e.concat(t).concat(n);this.send(t1,{awareness:this.awareness,clients:i,documentName:this.configuration.name},!0)}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,this.emit("synced",{state:e}),this.emit("sync",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}get isAuthenticationRequired(){return!!this.configuration.token&&!this.isAuthenticated}async connect(){return this.configuration.broadcast&&this.subscribeToBroadcastChannel(),this.configuration.websocketProvider.shouldConnect=!0,this.configuration.websocketProvider.attach(this)}disconnect(){this.disconnectBroadcastChannel(),this.configuration.websocketProvider.detach(this),this.isConnected=!1,this.configuration.preserveConnection||this.configuration.websocketProvider.disconnect()}async onOpen(e){this.isAuthenticated=!1,this.isConnected=!0,this.emit("open",{event:e});let t;try{t=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token: ${n}`);return}this.isAuthenticationRequired&&this.send(_qe,{token:t,documentName:this.configuration.name}),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(t8,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(t1,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t,n=!1){if(!this.isConnected)return;n&&this.mux(()=>{this.broadcast(e,t)});const r=new tie(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new $2(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new $2(e.data)}),new eie(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Rv(this.awareness,Array.from(this.awareness.getStates().keys()).filter(t=>t!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Rv(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("open",this.forwardOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("status",this.boundOnStatus),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.send(Rqe,{documentName:this.configuration.name}),this.disconnect(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1,this.disconnect(),this.status=al.Disconnected}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated")}get broadcastChannel(){return`${this.configuration.name}`}broadcastChannelSubscriber(e){this.mux(()=>{const t=new $2(e),n=t.readVarString();t.writeVarString(n),new eie(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(mne(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(t8,{document:this.document,documentName:this.configuration.name}),this.broadcast(Nqe,{document:this.document,documentName:this.configuration.name}),this.broadcast(Pqe,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(t1,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(t1,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(gne(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new tie(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new Dqe(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};const pc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",wT="application/pdf",n1="text/html",Fqe={docx:pc,pdf:wT,html:n1},n8=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),vs={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};var Bqe=(e,t)=>qh(e,t,r8),nie=(e,t)=>qh(e,t,Jqe),Hqe=(e,t)=>{const n=nie(e,t);return n?n.toLowerCase():null},rie=(e,t)=>qh(e,t,Zqe),zqe=(e,t)=>{const n=rie(e,t);return n?n.toLowerCase():null},Uqe=(e,t)=>qh(e,t,Yqe),Vqe=(e,t,n)=>Xqe(e,t,n),Wqe=(e,t)=>qh(e,t,Qqe),Gqe=(e,t)=>qh(e,t,Kqe),jqe={decimal:Bqe,decimalZero:Gqe,lowerRoman:Hqe,upperRoman:nie,lowerLetter:zqe,upperLetter:rie,ordinal:Uqe,custom:Vqe,japaneseCounting:Wqe};const iie=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const i=jqe[n];return i?i(e,t,r):null};var qqe=(e,t)=>typeof t!="string"?"":e.reduce((n,r,i)=>Number(r)>9?n.replace(/^0/,"").replace(`%${i+1}`,r):n.replace(`%${i+1}`,r),t),qh=(e,t,n)=>qqe(e.map((r,i)=>n(r,i)),t),Yqe=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},Kqe=(e,t)=>e>=10||t===0?String(e):`0${e}`,Xqe=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return qh(e,t,r8);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const i=r[1].length;return qh(e,t,o=>String(o).padStart(i,"0"))},r8=e=>String(e),Jqe=e=>{const t=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}];let n="",r=e;for(const{value:i,numeral:o}of t)for(;r>=i;)n+=o,r-=i;return n},Zqe=e=>{let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let r=e;for(;r>0;)t=n[(r-1)%26]+t,r=Math.floor((r-1)/26);return t};const Qqe=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",i=e,o=0;for(;i>0;){const s=i%10;if(s!==0?r=(s===1&&o>0?"":t[s])+(o>0?n[o]:"")+r:r&&i>0&&!r.startsWith("零")&&i%100!==0&&(r="零"+r),i=Math.floor(i/10),o+=1,o>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var $qe=new Set(["","","○","o","■","□"]);const i8=e=>!e||!$qe.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var oie=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim().length>0){const t=Number(e);if(Number.isFinite(t))return t}};const o8=e=>{if(!Array.isArray(e)||e.length===0)return;const t=oie(e[e.length-1]);return t!=null&&t>0?t:void 0},r1=e=>{if(!e||typeof e!="object")return;const t=e,n=typeof t.markerText=="string"?t.markerText:void 0,r=typeof t.numberingType=="string"?t.numberingType:void 0,i=typeof t.customFormat=="string"?t.customFormat:void 0,o=Array.isArray(t.path)?t.path.map(oie).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!o||o.length===0)))return{markerText:n,numberingType:r,...o&&o.length>0?{path:o}:{},...i?{customFormat:i}:{}}};function eYe(e){return typeof e.captureStackTrace=="function"}var i1=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",eYe(Error)&&Error.captureStackTrace(this,this.constructor)}},tYe=class extends i1{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},nYe=class extends i1{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const o1=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const o=e.split(",");if(o.length!==2)throw new tYe(e);const s=atob(o[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new nYe(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const i=await r.blob();return new File([i],t,{type:n})}catch(r){throw r instanceof i1?r:new i1("Failed to create file object",r)}};function rYe(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const o=n[i]||0,s=r[i]||0;if(o>s)return 1;if(o<s)return-1}return 0}var s8={mounted(e,t){const n=r=>{e.contains(r.target)||t.value?.(r)};document.addEventListener("click",n),e.__clickOutsideHandler=n},unmounted(e){e.__clickOutsideHandler&&(document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler)}};function iYe(e){return e[1].user!==void 0}const oYe=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(iYe).filter(([,r])=>{const i=r.user.email;return n.has(i)?!1:(n.add(i),!0)}).map(([r,i])=>{const o=i.user.email;let s=e.userColorMap.get(o);return s||(s=i.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(o,s),e.colorIndex++),{clientId:r,...i.user,color:s}})},sYe=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};var aYe="https://ingest.superdoc.dev/v1/collect";const MGn="community-and-eval-agplv3";function lYe(){try{return"1.31.0"}catch{return"unknown"}}var cYe=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||aYe,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=lYe()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}};function uYe(e,t){return e.type.name===t}function dYe(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function fYe(e,t){return e.type.name===t}function Zn(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function ao(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var qn=class JHe{constructor(t){this.type="node",this.name="node",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.group=this.config.group,this.config.addOptions?this.options=ao(Zn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=ao(Zn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new JHe(t)}};function hYe(e){return qn.create(e)}var ll=class ZHe{constructor(t){this.type="mark",this.name="mark",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.isExternal=!!this.config.isExternal,this.config.addOptions?this.options=ao(Zn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=ao(Zn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new ZHe(t)}};function pYe(e){return ll.create(e)}var a8=Hi(((e,t)=>{t.exports={}})),mYe=Hi((e=>{(function(t){t.parser=function(G,D){return new r(G,D)},t.SAXParser=r,t.SAXStream=d,t.createStream=c,t.MAX_BUFFER_LENGTH=64*1024;var n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(G,D){if(!(this instanceof r))return new r(G,D);var N=this;o(N),N.q=N.c="",N.bufferCheckPosition=t.MAX_BUFFER_LENGTH,N.encoding=null,N.opt=D||{},N.opt.lowercase=N.opt.lowercase||N.opt.lowercasetags,N.looseCase=N.opt.lowercase?"toLowerCase":"toUpperCase",N.opt.maxEntityCount=N.opt.maxEntityCount||512,N.opt.maxEntityDepth=N.opt.maxEntityDepth||4,N.entityCount=N.entityDepth=0,N.tags=[],N.closed=N.closedRoot=N.sawRoot=!1,N.tag=N.error=null,N.strict=!!G,N.noscript=!!(G||N.opt.noscript),N.state=_.BEGIN,N.strictEntities=N.opt.strictEntities,N.ENTITIES=N.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),N.attribList=[],N.opt.xmlns&&(N.ns=Object.create(g)),N.opt.unquotedAttributeValues===void 0&&(N.opt.unquotedAttributeValues=!G),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),E(N,"onready")}Object.create||(Object.create=function(G){function D(){}return D.prototype=G,new D}),Object.keys||(Object.keys=function(G){var D=[];for(var N in G)G.hasOwnProperty(N)&&D.push(N);return D});function i(G){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,X=0,ce=n.length;X<ce;X++){var te=G[n[X]].length;if(te>D)switch(n[X]){case"textNode":j(G);break;case"cdata":B(G,"oncdata",G.cdata),G.cdata="";break;case"script":B(G,"onscript",G.script),G.script="";break;default:z(G,"Max buffer length exceeded: "+n[X])}N=Math.max(N,te)}G.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+G.position}function o(G){for(var D=0,N=n.length;D<N;D++)G[n[D]]=""}function s(G){j(G),G.cdata!==""&&(B(G,"oncdata",G.cdata),G.cdata=""),G.script!==""&&(B(G,"onscript",G.script),G.script="")}r.prototype={end:function(){$(this)},write:Ae,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=a8().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(G){return G!=="error"&&G!=="end"});function c(G,D){return new d(G,D)}function u(G,D){if(G.length>=2){if(G[0]===255&&G[1]===254)return"utf-16le";if(G[0]===254&&G[1]===255)return"utf-16be"}return G.length>=3&&G[0]===239&&G[1]===187&&G[2]===191?"utf8":G.length>=4?G[0]===60&&G[1]===0&&G[2]===63&&G[3]===0?"utf-16le":G[0]===0&&G[1]===60&&G[2]===0&&G[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(G,D){if(!(this instanceof d))return new d(G,D);a.apply(this),this._parser=new r(G,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(X){N.emit("error",X),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(X){Object.defineProperty(N,"on"+X,{get:function(){return N._parser["on"+X]},set:function(ce){if(!ce)return N.removeAllListeners(X),N._parser["on"+X]=ce,ce;N.on(X,ce)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(G,D){if(this._decoderBuffer&&(G=Buffer.concat([this._decoderBuffer,G]),this._decoderBuffer=null),!this._decoder){var N=u(G,D);if(!N)return this._decoderBuffer=G,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(G,{stream:!D})},d.prototype.write=function(G){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(G))G=this._decodeBuffer(G,!1);else if(this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}return this._parser.write(G.toString()),this.emit("data",G),!0},d.prototype.end=function(G){if(G&&G.length&&this.write(G),this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}else if(this._decoder){var N=this._decoder.decode();N&&(this._parser.write(N),this.emit("data",N))}return this._parser.end(),!0},d.prototype.on=function(G,D){var N=this;return!N._parser["on"+G]&&l.indexOf(G)!==-1&&(N._parser["on"+G]=function(){var X=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);X.splice(0,0,G),N.emit.apply(N,X)}),a.prototype.on.call(N,G,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(G){return G===" "||G===`
5
+ `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&qB(r,this,i,a,s.attributes||{})}else s.retain!==void 0?Ore(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&Bre(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??ol();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;o.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),i.push(h),a=""}}const u=()=>{for(;l!==null;){if(F0(l,t)||n!==void 0&&F0(l,n))switch(l.content.constructor){case Am:{const d=o.get("ychange");t!==void 0&&!F0(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!F0(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case jh:case vT:{c();const d={insert:l.content.getContent()[0]};if(o.size>0){const f={};d.attributes=f,o.forEach((h,p)=>{f[p]=h})}i.push(d);break}case ya:F0(l,t)&&(c(),Cv(o,l.content));break}l=l.right}c()};return t||n?so(s,d=>{t&&FB(d,t),n&&FB(d,n),u()},"cleanup"):u(),i}insert(t,n,r){if(n.length<=0)return;const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),qB(o,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!r);qB(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;const r=this.doc;r!==null?so(r,i=>{Bre(i,J2(i,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const i=this.doc;i!==null?so(i,o=>{const s=J2(o,this,t,!1);s.right!==null&&Ore(o,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?so(this.doc,n=>{Y2(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?so(this.doc,r=>{WB(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return GB(this,t)}getAttributes(){return Rre(this)}_write(t){t.writeTypeRef(mqe)}},Kje=e=>new bT,YB=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ol()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Tu||t.constructor===_v)&&t._start!==null)e=t._start;else for(;e!==null;){const n=e.next;if(n!==null){e=n;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},_v=class YQ extends ga{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new YQ}clone(){const t=new YQ;return t.insert(0,this.toArray().map(n=>n instanceof ga?n.clone():n)),t}get length(){return this.doc??ol(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new YB(this,t)}querySelector(t){t=t.toUpperCase();const n=new YB(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),zh(new YB(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){j2(this,t,new Zje(this,n,t))}toString(){return Ire(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const i=t.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),yT(this,o=>{i.insertBefore(o.toDOM(t,n,r),null)}),i}insert(t,n){this.doc!==null?so(this.doc,r=>{Cre(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)so(this.doc,r=>{const i=t&&t instanceof ga?t._item:t;q2(r,this,i,n)});else{const r=this._prelimContent,i=t===null?0:r.findIndex(o=>o===t)+1;if(i===0&&t!==null)throw xf("Reference item not found");r.splice(i,0,...n)}}delete(t,n=1){this.doc!==null?so(this.doc,r=>{_re(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return xre(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return kre(this,t)}slice(t=0,n=this.length){return Sre(this,t,n)}forEach(t){yT(this,t)}_write(t){t.writeTypeRef(yqe)}},Xje=e=>new _v,Tu=class KQ extends _v{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new KQ(this.nodeName)}clone(){const t=new KQ(this.nodeName),n=this.getAttributes();return BWe(n,(r,i)=>{t.setAttribute(i,r)}),t.insert(0,this.toArray().map(r=>r instanceof ga?r.clone():r)),t}toString(){const t=this.getAttributes(),n=[],r=[];for(const s in t)r.push(s);r.sort();const i=r.length;for(let s=0;s<i;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?so(this.doc,n=>{Y2(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?so(this.doc,r=>{WB(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return GB(this,t)}hasAttribute(t){return Pre(this,t)}getAttributes(t){return t?Hje(this,t):Rre(this)}toDOM(t=document,n={},r){const i=t.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return yT(this,s=>{i.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(gqe),t.writeKey(this.nodeName)}},Jje=e=>new Tu(e.readKey()),Zje=class extends W2{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}},Qje=class XQ extends Fa{constructor(t){super(),this.hookName=t}_copy(){return new XQ(this.hookName)}clone(){const t=new XQ(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(bqe),t.writeKey(this.hookName)}},$je=e=>new Qje(e.readKey()),If=class JQ extends bT{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new JQ}clone(){const t=new JQ;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const i=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(t=>{const n=[];for(const i in t.attributes){const o=[];for(const s in t.attributes[i])o.push({key:s,value:t.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(vqe)}},eqe=e=>new If,KB=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Su()}mergeWith(e){return!1}write(e,t,n){throw Su()}integrate(e,t){throw Su()}},tqe=0,Iu=class extends KB{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),cre(e.doc.store,this)}write(e,t){e.writeInfo(tqe),e.writeLen(this.length-t)}getMissing(e,t){return null}},XB=class jHe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new jHe(this.content)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},nqe=e=>new XB(e.readBuf()),Hre=class ZQ{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ZQ(this.len)}splice(t){const n=new ZQ(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){uT(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},rqe=e=>new Hre(e.readLen()),zre=(e,t)=>new Gh({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),JB=class qHe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new qHe(zre(this.doc.guid,this.opts))}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},iqe=e=>new JB(zre(e.readString(),e.readAny())),vT=class YHe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new YHe(this.embed)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},oqe=e=>new vT(e.readJSON()),ya=class KHe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new KHe(this.key,this.value)}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},sqe=e=>new ya(e.readKey(),e.readJSON()),aqe=class QQ{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new QQ(this.arr)}splice(t){const n=new QQ(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}},lqe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const i=e.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new aqe(n)},cqe=R2("node_env")==="development",Z2=class $Q{constructor(t){this.arr=t,cqe&&une(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new $Q(this.arr)}splice(t){const n=new $Q(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];t.writeAny(o)}}getRef(){return 8}},uqe=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Z2(n)},Am=class e${constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e$(this.str)}splice(t){const n=new e$(this.str.slice(t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},dqe=e=>new Am(e.readString()),fqe=[Uje,Wje,Kje,Jje,Xje,$je,eqe],hqe=0,pqe=1,mqe=2,gqe=3,yqe=4,bqe=5,vqe=6,jh=class XHe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new XHe(this.type._copy())}splice(t){throw Su()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},wqe=e=>new jh(fqe[e.readTypeRef()](e)),ZB=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Nr(n.client,n.clock+r)),i=Ev(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Io);return{item:i,diff:r}},QB=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Q2=(e,t,n)=>{const{client:r,clock:i}=t.id,o=new Io(Nr(r,i+n),t,Nr(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=Nr(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},Ure=(e,t)=>$F(e,n=>Sv(n.deletions,t)),Vre=(e,t,n,r,i,o)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return hc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Vre(e,u,n,r,i,o)===null))return null;for(;u.redone!==null;)u=hc(e,u.redone)}const h=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let g=d;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:hc(e,g.redone);if(g!==null&&g.parent._item===u){d=g;break}d=d.left}for(;f!==null;){let g=f;for(;g!==null&&g.parent._item!==u;)g=g.redone===null?null:hc(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Sv(r,d.right.id)||Ure(o.undoStack,d.right.id)||Ure(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=hc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Nr(l,bs(a,l)),m=new Io(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,QB(m,!0),m.integrate(e,0),m},Io=class t$ extends KB{constructor(t,n,r,i,o,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bs(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bs(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Iv&&this.id.client!==this.parent.client&&this.parent.clock>=bs(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ure(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=hc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Iu||this.right&&this.right.constructor===Iu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===t$?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===t$&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Iv){const r=Ev(n,this.parent);r.constructor===Iu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ure(t,t.doc.store,Nr(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),kv(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(kv(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Ev(t.doc.store,i.origin)))o.has(Ev(t.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),cre(t.doc.store,this),this.content.integrate(t,this),hre(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Iu(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:Nr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&kv(t.origin,this.lastId)&&this.right===t&&kv(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),uT(t.deleteSet,this.id.client,this.id.clock,this.length),hre(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Pl();this.content.gc(t),n?Sje(t,this,new Iu(this.id,this.length)):this.content=new Hre(this.length)}write(t,n){const r=n>0?Nr(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(i===null?0:64)|(o===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),i!==null&&t.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=fT(a);t.writeParentInfo(!0),t.writeString(c)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else a.constructor===String?(t.writeParentInfo(!0),t.writeString(a)):a.constructor===Iv?(t.writeParentInfo(!1),t.writeLeftID(a)):Pl();o!==null&&t.writeString(o)}this.content.write(t,n)}},Wre=(e,t)=>Aqe[t&31](e),Aqe=[()=>{Pl()},rqe,lqe,nqe,dqe,oqe,sqe,wqe,uqe,iqe,()=>{Pl()}],Sqe=10,ku=class extends KB{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Pl()}write(e,t){e.writeInfo(Sqe),xn(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Gre=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},jre="__ $YJS$ __";Gre[jre]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Gre[jre]=!0;const xqe=3e4;var qre=class extends aGe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=xd();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,i)=>{i!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(i)&&n.push(i)}),n.length>0&&Rv(this,n,"timeout")},Au(xqe/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:xd()});const o=[],s=[],a=[],l=[];e===null?l.push(t):i==null?e!=null&&o.push(t):(s.push(t),gv(i,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const Rv=(e,t,n)=>{const r=[];for(let i=0;i<t.length;i++){const o=t[i];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){const s=e.meta.get(o);e.meta.set(o,{clock:s.clock+1,lastUpdated:xd()})}r.push(o)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Sm=(e,t,n=e.states)=>{const r=t.length,i=Xs();xn(i,r);for(let o=0;o<r;o++){const s=t[o],a=n.get(s)||null,l=e.meta.get(s).clock;xn(i,s),xn(i,l),pa(i,JSON.stringify(a))}return To(i)},Yre=(e,t,n)=>{const r=Uh(t),i=xd(),o=[],s=[],a=[],l=[],c=Sr(r);for(let u=0;u<c;u++){const d=Sr(r);let f=Sr(r);const h=JSON.parse(Wc(r)),p=e.meta.get(d),m=e.states.get(d),g=p===void 0?0:p.clock;(g<f||g===f&&h===null&&e.states.has(d))&&(h===null?d===e.clientID&&e.getLocalState()!=null?f++:e.states.delete(d):e.states.set(d,h),e.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?o.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(gv(h,m)||a.push(d),s.push(d)))}(o.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:o,updated:s,removed:l},n])};var Kre=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(r=>r.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(r=>r!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function Tqe(e){return e||(e={}),{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function $B(e){return new Promise(t=>setTimeout(t,e))}function Iqe(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=Math.pow(t.factor,e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){const r=Math.ceil(t.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function kqe(e,t){const n=Tqe(t);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Iqe;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await $B(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const u=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(d){c(d)}else{const d=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);d.code="ATTEMPT_TIMEOUT",c(d)}},n.timeout);e(r,n).then(d=>{clearTimeout(u),l(d)}).catch(d=>{clearTimeout(u),a(d).then(l).catch(c)})}):e(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await $B(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await $B(a)}return o()}const Xre=e=>HWe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let sl=(function(e){return e[e.Sync=0]="Sync",e[e.Awareness=1]="Awareness",e[e.Auth=2]="Auth",e[e.QueryAwareness=3]="QueryAwareness",e[e.Stateless=5]="Stateless",e[e.CLOSE=7]="CLOSE",e[e.SyncStatus=8]="SyncStatus",e})({}),al=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var $2=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=Xs(),this.decoder=Uh(new Uint8Array(this.data))}peekVarString(){return xWe(this.decoder)}readVarUint(){return Sr(this.decoder)}readVarString(){return Wc(this.decoder)}readVarUint8Array(){return Oa(this.decoder)}writeVarUint(e){return xn(this.encoder,e)}writeVarString(e){return pa(this.encoder,e)}writeVarUint8Array(e){return Ko(this.encoder,e)}length(){return S2(this.encoder)}},Jre=class extends Kre{messageQueue=[];configuration={url:"",document:void 0,WebSocketPolyfill:void 0,parameters:{},connect:!0,broadcast:!0,forceSyncInterval:!1,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,quiet:!1,providerMap:new Map};webSocket=null;webSocketHandlers={};shouldConnect=!0;status=al.Disconnected;lastMessageReceived=0;identifier=0;intervals={forceSync:null,connectionChecker:null};connectionAttempt=null;constructor(e){super(),this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("status",this.onStatus.bind(this)),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),typeof e.connect<"u"&&(this.shouldConnect=e.connect),this.shouldConnect&&this.connect()}receivedOnOpenPayload=void 0;receivedOnStatusPayload=void 0;async onOpen(e){this.receivedOnOpenPayload=e}async onStatus(e){this.receivedOnStatusPayload=e}attach(e){let t;return this.configuration.providerMap.set(e.configuration.name,e),this.status===al.Disconnected&&this.shouldConnect&&(t=this.connect()),this.receivedOnOpenPayload&&e.onOpen(this.receivedOnOpenPayload),this.receivedOnStatusPayload&&e.onStatus(this.receivedOnStatusPayload),t}detach(e){this.configuration.providerMap.delete(e.configuration.name)}setConfiguration(e={}){this.configuration={...this.configuration,...e}}cancelWebsocketRetry;async connect(){if(this.status===al.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.receivedOnStatusPayload=void 0,this.shouldConnect=!0;const e=()=>{let r=!1;return{retryPromise:kqe(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,beforeAttempt:i=>{(!this.shouldConnect||r)&&i.abort()}}).catch(i=>{if(i&&i.code!=="ATTEMPT_ABORTED")throw i}),cancelFunc:()=>{r=!0}}},{retryPromise:t,cancelFunc:n}=e();return this.cancelWebsocketRetry=n,t}attachWebSocketListeners(e,t){const{identifier:n}=e,r=l=>this.emit("message",l),i=l=>this.emit("close",{event:l}),o=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:i,open:o,error:s};const a=this.webSocketHandlers[e.identifier];Object.keys(a).forEach(l=>{e.addEventListener(l,a[l])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType="arraybuffer",n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=al.Connecting,this.emit("status",{status:al.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=xd();const t=new $2(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=al.Connected,this.emit("status",{status:al.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}closeTries=0;checkConnection(){this.status===al.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=xd()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){for(;this.configuration.url[this.configuration.url.length-1]==="/";)return this.configuration.url.slice(0,this.configuration.url.length-1);return this.configuration.url}get url(){const e=Xre(this.configuration.parameters);return`${this.serverUrl}${e.length===0?"":`?${e}`}`}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch{}}send(e){this.webSocket?.readyState===RWe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===al.Connected&&(this.status=al.Disconnected,this.emit("status",{status:al.Disconnected}),this.emit("disconnect",{event:e})),e.code===rne.code&&(e.reason===rne.reason?console.warn("[HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again."):console.warn(`[HocuspocusProvider] Connection closed with status Unauthorized: ${e.reason}`),this.shouldConnect=!1),e.code===_We.code&&!this.configuration.quiet){console.warn("[HocuspocusProvider] The provided authentication token isn’t allowed to connect to this server. Will try again.");return}e.code===CWe.code&&(console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${e.reason}`),this.shouldConnect=!1),this.connectionAttempt?this.rejectConnectionAttempt():this.shouldConnect&&this.connect(),!this.shouldConnect&&this.status!==al.Disconnected&&(this.status=al.Disconnected,this.emit("status",{status:al.Disconnected}),this.emit("disconnect",{event:e}))}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}};const PGn=0,LGn=1,NGn=2,e1=(e,t)=>{xn(e,0);const n=mje(t);Ko(e,n)},e8=(e,t,n)=>{xn(e,1),Ko(e,LB(t,n))},Eqe=(e,t,n)=>e8(t,n,Oa(e)),Zre=(e,t,n,r)=>{try{ere(t,Oa(e),n)}catch(i){r?.(i),console.error("Caught error while handling a Yjs update",i)}},Qre=(e,t)=>{xn(e,2),Ko(e,t)},Cqe=Zre,$re=(e,t,n,r,i)=>{const o=Sr(e);switch(o){case 0:Eqe(e,t,n);break;case 1:Zre(e,n,r,i);break;case 2:Cqe(e,n,r,i);break;default:throw new Error("Unknown message type")}return o};var kf=class{encoder;type;constructor(){this.encoder=Xs()}get(e){return e.encoder}toUint8Array(){return To(this.encoder)}},eie=class{message;broadcasted=!1;constructor(e){this.message=e}setBroadcasted(e){return this.broadcasted=e,this}apply(e,t){const{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case sl.Sync:this.applySyncMessage(e,t);break;case sl.Awareness:this.applyAwarenessMessage(e);break;case sl.Auth:this.applyAuthMessage(e);break;case sl.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case sl.Stateless:e.receiveStateless(Wc(n.decoder));break;case sl.SyncStatus:this.applySyncStatusMessage(e,k2(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&(this.broadcasted?e.broadcast(kf,{encoder:n.encoder}):e.send(kf,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(sl.Sync);const r=$re(n.decoder,n.encoder,e.document,e);t&&r===1&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;Yre(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;EWe(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(sl.Awareness),t.writeVarUint8Array(Sm(e.awareness,Array.from(e.awareness.getStates().keys())))}},tie=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return To(this.encoder)}send(e){e?.send(this.create())}broadcast(e){M0(e,this.create())}},_qe=class extends kf{type=sl.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),kWe(this.encoder,e.token),this.encoder}},t1=class extends kf{type=sl.Awareness;description="Awareness states update";get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");pa(this.encoder,e.documentName),xn(this.encoder,this.type);let t;return e.states===void 0?t=Sm(e.awareness,e.clients):t=Sm(e.awareness,e.clients,e.states),Ko(this.encoder,t),this.encoder}},Rqe=class extends kf{type=sl.CLOSE;description="Ask the server to close the connection";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),this.encoder}},Pqe=class extends kf{type=sl.QueryAwareness;description="Queries awareness states";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),this.encoder}},Lqe=class extends kf{type=sl.Stateless;description="A stateless message";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),pa(this.encoder,e.payload??""),this.encoder}},t8=class extends kf{type=sl.Sync;description="First sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),e1(this.encoder,e.document),this.encoder}},Nqe=class extends kf{type=sl.Sync;description="Second sync step";get(e){if(typeof e.document>"u")throw new Error("The sync step two message requires document as an argument");return pa(this.encoder,e.documentName),xn(this.encoder,this.type),e8(this.encoder,e.document),this.encoder}},Mqe=class extends kf{type=sl.Sync;description="A document update";get(e){return pa(this.encoder,e.documentName),xn(this.encoder,this.type),Qre(this.encoder,e.update),this.encoder}},Dqe=class extends Error{code=1001},Oqe=class extends Kre{configuration={name:"",document:void 0,awareness:void 0,token:null,parameters:{},broadcast:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onSynced:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,quiet:!1,connect:!0,preserveConnection:!0};subscribedToBroadcastChannel=!1;isSynced=!1;unsyncedChanges=0;status=al.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=yne();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Gh,this.configuration.awareness=e.awareness!==void 0?e.awareness:new qre(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("open",this.forwardOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("status",this.boundOnStatus),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.awareness?.on("update",()=>{this.emit("awarenessUpdate",{states:ine(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:ine(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),this.awareness?.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.configuration.websocketProvider.attach(this)}boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this);boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this);boundBroadcastChannelSubscriber=this.broadcastChannelSubscriber.bind(this);boundPageHide=this.pageHide.bind(this);boundOnOpen=this.onOpen.bind(this);boundOnClose=this.onClose.bind(this);boundOnStatus=this.onStatus.bind(this);forwardConnect=e=>this.emit("connect",e);forwardOpen=e=>this.emit("open",e);forwardClose=e=>this.emit("close",e);forwardDisconnect=e=>this.emit("disconnect",e);forwardDestroy=e=>this.emit("destroy",e);onStatus({status:e}){this.status=e,this.configuration.onStatus({status:e}),this.emit("status",{status:e})}setConfiguration(e={}){if(!e.websocketProvider&&e.url){const t=e;this.configuration.websocketProvider=new Jre({url:t.url,connect:t.connect,parameters:t.parameters})}this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",this.unsyncedChanges)}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",this.unsyncedChanges)}decrementUnsyncedChanges(){this.unsyncedChanges-=1,this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",this.unsyncedChanges)}forceSync(){this.resetUnsyncedChanges(),this.send(t8,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Rv(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(Lqe,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Mqe,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const i=e.concat(t).concat(n);this.send(t1,{awareness:this.awareness,clients:i,documentName:this.configuration.name},!0)}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,this.emit("synced",{state:e}),this.emit("sync",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}get isAuthenticationRequired(){return!!this.configuration.token&&!this.isAuthenticated}async connect(){return this.configuration.broadcast&&this.subscribeToBroadcastChannel(),this.configuration.websocketProvider.shouldConnect=!0,this.configuration.websocketProvider.attach(this)}disconnect(){this.disconnectBroadcastChannel(),this.configuration.websocketProvider.detach(this),this.isConnected=!1,this.configuration.preserveConnection||this.configuration.websocketProvider.disconnect()}async onOpen(e){this.isAuthenticated=!1,this.isConnected=!0,this.emit("open",{event:e});let t;try{t=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token: ${n}`);return}this.isAuthenticationRequired&&this.send(_qe,{token:t,documentName:this.configuration.name}),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(t8,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(t1,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t,n=!1){if(!this.isConnected)return;n&&this.mux(()=>{this.broadcast(e,t)});const r=new tie(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new $2(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new $2(e.data)}),new eie(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Rv(this.awareness,Array.from(this.awareness.getStates().keys()).filter(t=>t!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Rv(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("open",this.forwardOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("status",this.boundOnStatus),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.send(Rqe,{documentName:this.configuration.name}),this.disconnect(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1,this.disconnect(),this.status=al.Disconnected}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated")}get broadcastChannel(){return`${this.configuration.name}`}broadcastChannelSubscriber(e){this.mux(()=>{const t=new $2(e),n=t.readVarString();t.writeVarString(n),new eie(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(mne(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(t8,{document:this.document,documentName:this.configuration.name}),this.broadcast(Nqe,{document:this.document,documentName:this.configuration.name}),this.broadcast(Pqe,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(t1,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(t1,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(gne(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new tie(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new Dqe(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}};const pc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",wT="application/pdf",n1="text/html",Fqe={docx:pc,pdf:wT,html:n1},n8=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),vs={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};var Bqe=(e,t)=>qh(e,t,r8),nie=(e,t)=>qh(e,t,Jqe),Hqe=(e,t)=>{const n=nie(e,t);return n?n.toLowerCase():null},rie=(e,t)=>qh(e,t,Zqe),zqe=(e,t)=>{const n=rie(e,t);return n?n.toLowerCase():null},Uqe=(e,t)=>qh(e,t,Yqe),Vqe=(e,t,n)=>Xqe(e,t,n),Wqe=(e,t)=>qh(e,t,Qqe),Gqe=(e,t)=>qh(e,t,Kqe),jqe={decimal:Bqe,decimalZero:Gqe,lowerRoman:Hqe,upperRoman:nie,lowerLetter:zqe,upperLetter:rie,ordinal:Uqe,custom:Vqe,japaneseCounting:Wqe};const iie=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const i=jqe[n];return i?i(e,t,r):null};var qqe=(e,t)=>typeof t!="string"?"":e.reduce((n,r,i)=>Number(r)>9?n.replace(/^0/,"").replace(`%${i+1}`,r):n.replace(`%${i+1}`,r),t),qh=(e,t,n)=>qqe(e.map((r,i)=>n(r,i)),t),Yqe=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},Kqe=(e,t)=>e>=10||t===0?String(e):`0${e}`,Xqe=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return qh(e,t,r8);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const i=r[1].length;return qh(e,t,o=>String(o).padStart(i,"0"))},r8=e=>String(e),Jqe=e=>{const t=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}];let n="",r=e;for(const{value:i,numeral:o}of t)for(;r>=i;)n+=o,r-=i;return n},Zqe=e=>{let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";let r=e;for(;r>0;)t=n[(r-1)%26]+t,r=Math.floor((r-1)/26);return t};const Qqe=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",i=e,o=0;for(;i>0;){const s=i%10;if(s!==0?r=(s===1&&o>0?"":t[s])+(o>0?n[o]:"")+r:r&&i>0&&!r.startsWith("零")&&i%100!==0&&(r="零"+r),i=Math.floor(i/10),o+=1,o>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var $qe=new Set(["","","○","o","■","□"]);const i8=e=>!e||!$qe.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var oie=e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim().length>0){const t=Number(e);if(Number.isFinite(t))return t}};const o8=e=>{if(!Array.isArray(e)||e.length===0)return;const t=oie(e[e.length-1]);return t!=null&&t>0?t:void 0},r1=e=>{if(!e||typeof e!="object")return;const t=e,n=typeof t.markerText=="string"?t.markerText:void 0,r=typeof t.numberingType=="string"?t.numberingType:void 0,i=typeof t.customFormat=="string"?t.customFormat:void 0,o=Array.isArray(t.path)?t.path.map(oie).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!o||o.length===0)))return{markerText:n,numberingType:r,...o&&o.length>0?{path:o}:{},...i?{customFormat:i}:{}}};function eYe(e){return typeof e.captureStackTrace=="function"}var i1=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",eYe(Error)&&Error.captureStackTrace(this,this.constructor)}},tYe=class extends i1{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},nYe=class extends i1{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const o1=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const o=e.split(",");if(o.length!==2)throw new tYe(e);const s=atob(o[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new nYe(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const i=await r.blob();return new File([i],t,{type:n})}catch(r){throw r instanceof i1?r:new i1("Failed to create file object",r)}};function rYe(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const o=n[i]||0,s=r[i]||0;if(o>s)return 1;if(o<s)return-1}return 0}var s8={mounted(e,t){const n=r=>{e.contains(r.target)||t.value?.(r)};document.addEventListener("click",n),e.__clickOutsideHandler=n},unmounted(e){e.__clickOutsideHandler&&(document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler)}};function iYe(e){return e[1].user!==void 0}const oYe=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(iYe).filter(([,r])=>{const i=r.user.email;return n.has(i)?!1:(n.add(i),!0)}).map(([r,i])=>{const o=i.user.email;let s=e.userColorMap.get(o);return s||(s=i.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(o,s),e.colorIndex++),{clientId:r,...i.user,color:s}})},sYe=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};var aYe="https://ingest.superdoc.dev/v1/collect";const MGn="community-and-eval-agplv3";function lYe(){try{return"1.31.1"}catch{return"unknown"}}var cYe=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||aYe,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=lYe()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}};function uYe(e,t){return e.type.name===t}function dYe(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function fYe(e,t){return e.type.name===t}function Zn(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function ao(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var qn=class JHe{constructor(t){this.type="node",this.name="node",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.group=this.config.group,this.config.addOptions?this.options=ao(Zn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=ao(Zn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new JHe(t)}};function hYe(e){return qn.create(e)}var ll=class ZHe{constructor(t){this.type="mark",this.name="mark",this.config={...t,name:t.name||this.name},this.name=this.config.name,this.isExternal=!!this.config.isExternal,this.config.addOptions?this.options=ao(Zn(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=ao(Zn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new ZHe(t)}};function pYe(e){return ll.create(e)}var a8=Hi(((e,t)=>{t.exports={}})),mYe=Hi((e=>{(function(t){t.parser=function(G,D){return new r(G,D)},t.SAXParser=r,t.SAXStream=d,t.createStream=c,t.MAX_BUFFER_LENGTH=64*1024;var n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(G,D){if(!(this instanceof r))return new r(G,D);var N=this;o(N),N.q=N.c="",N.bufferCheckPosition=t.MAX_BUFFER_LENGTH,N.encoding=null,N.opt=D||{},N.opt.lowercase=N.opt.lowercase||N.opt.lowercasetags,N.looseCase=N.opt.lowercase?"toLowerCase":"toUpperCase",N.opt.maxEntityCount=N.opt.maxEntityCount||512,N.opt.maxEntityDepth=N.opt.maxEntityDepth||4,N.entityCount=N.entityDepth=0,N.tags=[],N.closed=N.closedRoot=N.sawRoot=!1,N.tag=N.error=null,N.strict=!!G,N.noscript=!!(G||N.opt.noscript),N.state=_.BEGIN,N.strictEntities=N.opt.strictEntities,N.ENTITIES=N.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),N.attribList=[],N.opt.xmlns&&(N.ns=Object.create(g)),N.opt.unquotedAttributeValues===void 0&&(N.opt.unquotedAttributeValues=!G),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),E(N,"onready")}Object.create||(Object.create=function(G){function D(){}return D.prototype=G,new D}),Object.keys||(Object.keys=function(G){var D=[];for(var N in G)G.hasOwnProperty(N)&&D.push(N);return D});function i(G){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,X=0,ce=n.length;X<ce;X++){var te=G[n[X]].length;if(te>D)switch(n[X]){case"textNode":j(G);break;case"cdata":B(G,"oncdata",G.cdata),G.cdata="";break;case"script":B(G,"onscript",G.script),G.script="";break;default:z(G,"Max buffer length exceeded: "+n[X])}N=Math.max(N,te)}G.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+G.position}function o(G){for(var D=0,N=n.length;D<N;D++)G[n[D]]=""}function s(G){j(G),G.cdata!==""&&(B(G,"oncdata",G.cdata),G.cdata=""),G.script!==""&&(B(G,"onscript",G.script),G.script="")}r.prototype={end:function(){$(this)},write:Ae,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=a8().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(G){return G!=="error"&&G!=="end"});function c(G,D){return new d(G,D)}function u(G,D){if(G.length>=2){if(G[0]===255&&G[1]===254)return"utf-16le";if(G[0]===254&&G[1]===255)return"utf-16be"}return G.length>=3&&G[0]===239&&G[1]===187&&G[2]===191?"utf8":G.length>=4?G[0]===60&&G[1]===0&&G[2]===63&&G[3]===0?"utf-16le":G[0]===0&&G[1]===60&&G[2]===0&&G[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(G,D){if(!(this instanceof d))return new d(G,D);a.apply(this),this._parser=new r(G,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(X){N.emit("error",X),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(X){Object.defineProperty(N,"on"+X,{get:function(){return N._parser["on"+X]},set:function(ce){if(!ce)return N.removeAllListeners(X),N._parser["on"+X]=ce,ce;N.on(X,ce)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(G,D){if(this._decoderBuffer&&(G=Buffer.concat([this._decoderBuffer,G]),this._decoderBuffer=null),!this._decoder){var N=u(G,D);if(!N)return this._decoderBuffer=G,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(G,{stream:!D})},d.prototype.write=function(G){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(G))G=this._decodeBuffer(G,!1);else if(this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}return this._parser.write(G.toString()),this.emit("data",G),!0},d.prototype.end=function(G){if(G&&G.length&&this.write(G),this._decoderBuffer){var D=this._decodeBuffer(Buffer.alloc(0),!0);D&&(this._parser.write(D),this.emit("data",D))}else if(this._decoder){var N=this._decoder.decode();N&&(this._parser.write(N),this.emit("data",N))}return this._parser.end(),!0},d.prototype.on=function(G,D){var N=this;return!N._parser["on"+G]&&l.indexOf(G)!==-1&&(N._parser["on"+G]=function(){var X=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);X.splice(0,0,G),N.emit.apply(N,X)}),a.prototype.on.call(N,G,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function x(G){return G===" "||G===`
6
6
  `||G==="\r"||G===" "}function S(G){return G==='"'||G==="'"}function T(G){return G===">"||x(G)}function k(G,D){return G.test(D)}function C(G,D){return!k(G,D)}var _=0;t.STATE={BEGIN:_++,BEGIN_WHITESPACE:_++,TEXT:_++,TEXT_ENTITY:_++,OPEN_WAKA:_++,SGML_DECL:_++,SGML_DECL_QUOTED:_++,DOCTYPE:_++,DOCTYPE_QUOTED:_++,DOCTYPE_DTD:_++,DOCTYPE_DTD_QUOTED:_++,COMMENT_STARTING:_++,COMMENT:_++,COMMENT_ENDING:_++,COMMENT_ENDED:_++,CDATA:_++,CDATA_ENDING:_++,CDATA_ENDING_2:_++,PROC_INST:_++,PROC_INST_BODY:_++,PROC_INST_ENDING:_++,OPEN_TAG:_++,OPEN_TAG_SLASH:_++,ATTRIB:_++,ATTRIB_NAME:_++,ATTRIB_NAME_SAW_WHITE:_++,ATTRIB_VALUE:_++,ATTRIB_VALUE_QUOTED:_++,ATTRIB_VALUE_CLOSED:_++,ATTRIB_VALUE_UNQUOTED:_++,ATTRIB_VALUE_ENTITY_Q:_++,ATTRIB_VALUE_ENTITY_U:_++,CLOSE_TAG:_++,CLOSE_TAG_SAW_WHITE:_++,SCRIPT:_++,SCRIPT_ENDING:_++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(G){var D=t.ENTITIES[G],N=typeof D=="number"?String.fromCharCode(D):D;t.ENTITIES[G]=N});for(var P in t.STATE)t.STATE[t.STATE[P]]=P;_=t.STATE;function E(G,D,N){G[D]&&G[D](N)}function L(G){var D=G&&G.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return D?D[2]:null}function R(G){return G?G.toLowerCase().replace(/[^a-z0-9]/g,""):null}function O(G,D){const N=R(G),X=R(D);return!N||!X?!0:X==="utf16"?N==="utf16le"||N==="utf16be":N===X}function F(G,D){if(!(!G.strict||!G.encoding||!D||D.name!=="xml")){var N=L(D.body);N&&!O(G.encoding,N)&&K(G,"XML declaration encoding "+N+" does not match detected stream encoding "+G.encoding.toUpperCase())}}function B(G,D,N){G.textNode&&j(G),E(G,D,N)}function j(G){G.textNode=M(G.opt,G.textNode),G.textNode&&E(G,"ontext",G.textNode),G.textNode=""}function M(G,D){return G.trim&&(D=D.trim()),G.normalize&&(D=D.replace(/\s+/g," ")),D}function z(G,D){return j(G),G.trackPosition&&(D+=`
7
7
  Line: `+G.line+`
8
8
  Column: `+G.column+`
@@ -86,7 +86,7 @@ Actual: `+G.attribValue);else{var ce=G.tag,te=G.tags[G.tags.length-1]||G;ce.ns==
86
86
  `,`
87
87
  `);Qo({editor:e,partId:i.partId,operation:"mutate",source:`story-runtime:commit:${n.storyType}`,mutate({part:c}){ewe(c,i,n.noteId,l)}})}function gMt(e,t,n){const r=t?e.footnotes:e.endnotes;if(!Array.isArray(r))return null;const i=r.find(o=>String(o.id)===String(n));return i?Array.isArray(i.content)?Oy({type:"doc",content:i.content.length>0?i.content:[{type:"paragraph"}]}):i.doc&&typeof i.doc=="object"?Oy(i.doc):i.type==="doc"||i.type==="footnoteBody"||i.type==="endnoteBody"?Oy(i):null:null}function yMt(e,t,n,r){const i=rN(e,t.childElementName).find(s=>s.attributes?.["w:id"]===n);if(!i)return!1;const o=r;return zU(o,t.childElementName),i.elements=o,!0}var UU=new WeakMap;function bMt(e){const t=UU.get(e);if(t)return t;const n={counters:new Map};return UU.set(e,n),n}function vMt(e){return UU.get(e)}function wMt(e,t){const n=e.counters.get(t)??0;return String(n)}function AMt(e,t){const n=(e.counters.get(t)??0)+1;return e.counters.set(t,n),String(n)}var Bw=new WeakMap;function SMt(e){let t=Bw.get(e);return t||(t=new Map,Bw.set(e,t)),t}function lwe(e){const{runtime:t,editor:n}=e;return{...t,editor:n,cacheable:!1,commit:t.commitEditor==null?t.commit:r=>{t.commitEditor?.(r,n)}}}function xMt(e,t,n){const r=SMt(e),i=t.storyKey;return r.set(i,{storyKey:i,editor:n,runtime:t}),()=>{IMt(e,i,n)}}function VU(e,t){const n=Bw.get(e)?.get(t);return n?lwe(n):null}function TMt(e){const t=Bw.get(e);if(!t||t.size===0)return 0;let n=0;for(const r of[...t.values()])lwe(r).commit?.(e),n+=1;return n}function IMt(e,t,n){const r=Bw.get(e);if(!r)return;const i=r.get(t);i&&(n&&i.editor!==n||(r.delete(t),r.size===0&&Bw.delete(e)))}var mk=new WeakMap,WU=new WeakMap;function kMt(e,t){return WU.get(e)?.has(t)??!1}function EMt(e,t){let n=WU.get(e);n||(n=new Set,WU.set(e,n)),n.add(t)}function cwe(e){let t=mk.get(e);return t||(t=new wPt,mk.set(e,t),CMt(e)),t}function CMt(e){typeof e.on=="function"&&(e.on("notes-part-changed",()=>{const t=mk.get(e);t&&(t.invalidateByPrefix("fn:"),t.invalidateByPrefix("en:"))}),e.on("partChanged",t=>{const n=mk.get(e);n&&t.parts.some(r=>Dy(r.partId))&&n.invalidateByPrefix("hf:")}))}var _Mt={kind:"story",storyType:"body"};function RMt(e){return{locator:_Mt,storyKey:qf,editor:e,kind:"body"}}function ja(e,t,n={}){if(t===void 0||t.storyType==="body")return PMt(e);const r=Eo(t),i=VU(e,r);if(i)return i;const o=cwe(e),s=o.get(r);if(s)return s;let a;switch(t.storyType){case"headerFooterSlot":a=ZNt(e,t,n);break;case"headerFooterPart":a=QNt(e,t);break;case"footnote":case"endnote":a=mMt(e,t);break;default:{const c=t;throw new Oe("INVALID_INPUT",`Unknown story type on locator: ${JSON.stringify(c)}`)}}Y4(a.editor);const l=vMt(e);if(l){const c=wMt(l,r);Uhe(a.editor,c)}return K4(a.editor),l&&!kMt(a.editor,r)&&(EMt(a.editor,r),a.editor.on("transaction",({transaction:c})=>{c.docChanged&&AMt(l,r)})),a.cacheable!==!1&&o.set(r,a),a}function PMt(e){const t=cwe(e),n=t.get(qf);if(n)return n;const r=RMt(e);return t.set(qf,r),r}function LMt(e){return mk.get(e)}function GU(e,t){const n=ja(e,t.in).editor.state.doc;return FL(n,0,n.content.size,`
88
88
  `,`
89
- `)}var NMt=ls({findChildren:()=>fwe,findInlineNodes:()=>hwe,findMarkPosition:()=>uwe,flatten:()=>dwe},1);const uwe=(e,t,n)=>{const r=e.resolve(t),i=r.parent,o=i.childAfter(r.parentOffset);if(!o.node)return null;const s=o.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+o.offset;for(;a>0&&s.isInSet(i.child(a-1).marks);)l-=i.child(--a).nodeSize;let c=r.index()+1,u=r.start()+o.offset+o.node.nodeSize;for(;c<i.childCount&&s.isInSet(i.child(c).marks);)u+=i.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},dwe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,i)=>{if(n.push({node:r,pos:i}),!t)return!1}),n},fwe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return dwe(e,n).filter(r=>t(r.node))},hwe=(e,t)=>fwe(e,n=>n.isInline,t),nu=(e,t=null)=>{const n=[],r=hwe(e.doc);return r.length?(r.forEach(({node:i,pos:o})=>{const{marks:s}=i,a=[Ul,Ts,Ha];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,from:o,to:o+i.nodeSize})})}),t?n.filter(({mark:i})=>i.attrs.id===t):n):n};var MMt=24;function DMt(e){try{const t=nu(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function OMt(e){let t=2166136261,n=16777619,r=3735928559;for(let i=0;i<e.length;i++){const o=e.charCodeAt(i);t=Math.imul(t^o,16777619),n=Math.imul(n^o,1540483477),r=Math.imul(r^o,461845907)}return t=Math.imul(t^t>>>16,2246822507),n=Math.imul(n^n>>>16,3432918353),r=Math.imul(r^r>>>16,461845907),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")).slice(0,MMt)}function FMt(e,t){const n=jU(t),r=DL(e.state.doc.textBetween(t.from,t.to," ",""))??"",i=$o(t.attrs.author)??"",o=$o(t.attrs.authorEmail)??"",s=$o(t.attrs.date)??"";return OMt(`${n}|${t.from}|${t.to}|${i}|${o}|${s}|${r}`)}function jU(e){return e.hasFormat?"format":e.hasDelete&&!e.hasInsert?"delete":"insert"}var pwe=new WeakMap;function mwe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function BMt(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function Hw(e){const t=e.state.doc,n=pwe.get(e);if(n&&n.doc===t)return n.grouped;const r=DMt(e),i=new Map;for(const s of r){const a=s.mark?.attrs??{},l=$o(a.id);if(!l)continue;const c=i.get(l),u=s.mark.type.name,d=u===Ul,f=u===Ts,h=u===Ha,p=$o(a.sourceId),m=BMt(u);if(!c){i.set(l,{rawId:l,from:s.from,to:s.to,hasInsert:d,hasDelete:f,hasFormat:h,attrs:{...a},wordRevisionIds:m?mwe(void 0,m,p??void 0):void 0});continue}c.from=Math.min(c.from,s.from),c.to=Math.max(c.to,s.to),c.hasInsert=c.hasInsert||d,c.hasDelete=c.hasDelete||f,c.hasFormat=c.hasFormat||h,Object.keys(c.attrs).length===0&&Object.keys(a).length>0&&(c.attrs={...a}),m&&(c.wordRevisionIds=mwe(c.wordRevisionIds,m,p??void 0))}const o=Array.from(i.values()).map(s=>({...s,id:FMt(e,s)})).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return pwe.set(e,{doc:t,grouped:o}),o}function gwe(e,t){return Hw(e).find(n=>n.id===t)??null}function ywe(e){const t=Hw(e),n=new Map;for(const r of t)n.set(r.rawId,r.id),n.set(r.id,r.id);return n}function HMt(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function iN(e,t){const n=HMt(t),r=n.entityId,i=n.story??{kind:"story",storyType:"body"};if((n.story?Eo(n.story):"body")==="body"){const a=bwe(e,r);return a?{editor:e,story:i,runtimeRef:{storyKey:qf,rawId:a.rawId},change:a}:null}let o;try{o=ja(e,i)}catch{return null}const s=bwe(o.editor,r);return s?{editor:o.editor,story:o.locator,runtimeRef:{storyKey:o.storyKey,rawId:s.rawId},change:s,commit:o.commit}:null}function bwe(e,t){return Hw(e).find(n=>n.id===t||n.rawId===t)??null}const zMt=["structuredContent","structuredContentBlock"],gk="structuredContentBlock";function yk(e){return zMt.includes(e.type.name)}function zw(e){const t=[];return e.descendants((n,r)=>(yk(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function An(e,t){const n=t.nodeId,r=zw(e).filter(i=>String(i.node.attrs.id)===n);if(r.length===0)throw new Oe("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new Oe("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function na(e,t){return e?.elements?.find(n=>n.name===t)}function vwe(e,t){return na(e,t)?.attributes}function oN(e,t,n){const r=e.elements?[...e.elements]:[],i=r.findIndex(o=>o.name===t);return i>=0?r[i]=n:r.push(n),{...e,elements:r}}function wwe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}function Fy(e,t,n){const r=e.commands?.updateStructuredContentById;return typeof r!="function"?!1:!!r(t,{attrs:n})}function qd(e,t,n,r){const i=An(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},o=r(na(i,n));let s;return o===null?s=wwe(i,n):s=oN(i,n,o),Fy(e,t.nodeId,{sdtPr:s})}function qU(e,t,n,r,i,o){return qd(e,t,n,s=>{const a=s??{name:n,type:"element",elements:[]},l=a.elements?[...a.elements]:[],c=l.findIndex(d=>d.name===r),u={name:r,type:"element",attributes:{[i]:o}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[i]:o}}:l.push(u),{...a,elements:l}})}function UMt(e,t,n,r){return qd(e,t,n,i=>({name:n,type:"element",...i,elements:r}))}var VMt=["text","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],WMt=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],GMt=["boundingBox","tags","hidden"];function gp(e){const t=e.controlType??e.type;return typeof t=="string"&&VMt.includes(t)?t:"unknown"}function sN(e){const t=e.lockMode;return typeof t=="string"&&WMt.includes(t)?t:"unlocked"}function Awe(e){const t=e.appearance;if(typeof t=="string"&&GMt.includes(t))return t}function Swe(e){const t=e.sdtPr;if(!t)return;const n=vwe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],i=n["w:xpath"];if(!(!r||!i))return{storeItemId:r,xpath:i,prefixMappings:n["w:prefixMappings"]}}function Ci(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function YU(e){const t=(na(e,"w14:checkbox")??na(e,"w:checkbox"))?.elements?.find(r=>r.name==="w14:checked"||r.name==="w:checked"),n=t?.attributes?.["w14:val"]??t?.attributes?.["w:val"];return n==="1"||n==="true"||n===!0}function KU(e,t){const n=na(e,`w:${t}`);return{items:(n?.elements?.filter(r=>r.name==="w:listItem")??[]).map(r=>({displayText:String(r.attributes?.["w:displayText"]??""),value:String(r.attributes?.["w:value"]??"")})),selectedValue:n?.attributes?.["w:lastValue"]}}function jMt(e,t){if(!t)return{};switch(e){case"text":{const n=vwe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=na(t,"w:date");if(!n)return{};const r=na(n,"w:dateFormat"),i=na(n,"w:lid"),o=na(n,"w:storeMappedDataAs"),s=na(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:i?.attributes?.["w:val"],storageFormat:o?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=na(t,"w14:checkbox")??na(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(o=>o.name==="w14:checkedState"),i=n.elements?.find(o=>o.name==="w14:uncheckedState");return{checked:YU(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:i?{font:String(i.attributes?.["w14:font"]??""),char:String(i.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return KU(t,e);case"repeatingSection":{const n=na(t,"w15:repeatingSection")??na(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(o=>o.name==="w15:allowInsertDeleteSection"||o.name==="w:allowInsertDeleteSection"),i=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:i==="1"||i==="true"||i===!0}}default:return{}}}function cg(e){const t=e.node.attrs,n=String(t.id??""),r=gp(t),i=sN(t),o=typeof t.sdtPr=="object"&&t.sdtPr!==null?t.sdtPr:void 0;let s;try{s=e.node.textContent||void 0}catch{s=void 0}const a=jMt(r,o);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:i,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:Awe(t),placeholder:typeof t.placeholder=="string"?t.placeholder:void 0,color:typeof t.color=="string"?t.color:void 0,showingPlaceholder:typeof t.showingPlaceholder=="boolean"?t.showingPlaceholder:void 0,temporary:typeof t.temporary=="boolean"?t.temporary:void 0,tabIndex:typeof t.tabIndex=="number"?t.tabIndex:void 0,...a},binding:Swe(t),raw:o,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function qMt(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:gp(n),lockMode:sN(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:Awe(n),placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,color:typeof n.color=="string"?n.color:void 0,showingPlaceholder:typeof n.showingPlaceholder=="boolean"?n.showingPlaceholder:void 0,temporary:typeof n.temporary=="boolean"?n.temporary:void 0,tabIndex:typeof n.tabIndex=="number"?n.tabIndex:void 0},target:{kind:t,nodeType:"sdt",nodeId:r}}}function qa(e,t){const n=sN(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new Oe("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Xf(e,t){const n=sN(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new Oe("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function ra(e,t,n){const r=gp(e.node.attrs),i=Array.isArray(t)?t:[t];if(!i.includes(r))throw new Oe("TYPE_MISMATCH",`Operation "${n}" requires control type ${i.join(" or ")}, but found "${r}".`,{expected:i,actual:r,operation:n})}function xwe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function Jf(e,t){return{success:!1,failure:{code:e,message:t}}}function bk(e,t){const n=e.length,r=t?.offset??0,i=t?.limit??n;return{items:e.slice(r,r+i),total:n}}function vk(e,t){const n=jn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new Oe("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new Oe("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function Twe(e,t,n){const r=vk(e,t),i=vk(e,n);if(r.pos>i.pos)throw new Oe("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return jn(e).candidates.filter(o=>(o.nodeType==="paragraph"||o.nodeType==="listItem")&&o.pos>=r.pos&&o.pos<=i.pos)}function Gu(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const i=r.elements.find(o=>o.name==="w:abstractNumId")?.attributes?.["w:val"];return i!=null?Number(i):void 0}function Uw(e){return jn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>aN(e,t))}function bl(e,t){if(t.numId==null)return[t];const n=Uw(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const i=t.numId;let o=r;for(let a=r-1;a>=0&&n[a].numId===i;a--)o=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===i;a++)s=a;return n.slice(o,s+1)}function Iwe(e,t){const n=bl(e,t),r=n.findIndex(i=>i.address.nodeId===t.address.nodeId);return n.slice(r)}function kwe(e,t){const n=bl(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function YMt(e,t){if(t.numId==null)return"";const n=bl(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function Ewe(e){const t=new Map;let n,r;for(const i of e){if(i.numId==null){t.set(i.address.nodeId,""),n=void 0,r=void 0;continue}i.numId!==n&&(n=i.numId,r=i.address.nodeId),t.set(i.address.nodeId,`${n}:${r}`)}return t}function Vw(e,t,n){if(t.numId==null)return null;const r=Uw(e),i=bl(e,t);if(n==="withNext"){const o=i[i.length-1],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:bl(e,l),numId:l.numId,abstractNumId:Gu(e,l.numId)}}}else{const o=i[0],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:bl(e,l),numId:l.numId,abstractNumId:Gu(e,l.numId)}}}return null}function KMt(e,t){if(t.numId==null)return null;const n=Gu(e,t.numId);if(n==null)return null;const r=Uw(e),i=bl(e,t)[0],o=r.findIndex(s=>s.address.nodeId===i.address.nodeId);for(let s=o-1;s>=0;s--){const a=r[s];if(a.numId!=null&&Gu(e,a.numId)===n&&a.numId!==t.numId)return{sequence:bl(e,a),numId:a.numId}}return null}function Cwe(e,t,n){const r=Vw(e,t,n);if(!r)return{canJoin:!1,reason:"NO_ADJACENT_SEQUENCE"};if(r.numId===t.numId)return{canJoin:!1,reason:"ALREADY_SAME_SEQUENCE"};const i=t.numId!=null?Gu(e,t.numId):void 0;if(i==null||r.abstractNumId==null||i!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const o=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${o}`}}function _we(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=Gu(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=Uw(e),i=bl(e,t)[0],o=r.findIndex(a=>a.address.nodeId===i.address.nodeId);let s=!1;for(let a=o-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,Gu(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=bl(e,l)[0]?.address.nodeId??l.address.nodeId;return{canContinue:!0,previousListId:`${l.numId}:${c}`}}return s?{canContinue:!1,reason:"INCOMPATIBLE_DEFINITIONS"}:{canContinue:!1,reason:"NO_PREVIOUS_LIST"}}function XMt(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:NL(n?.numId??r?.numId),level:NL(n?.ilvl??r?.ilvl)}}function JMt(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=ur.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),i=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":void 0}catch{return}}function ZMt(e,t,n,r){const i=(t.node.attrs??{}).listRendering?.numberingType;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":JMt(e,n,r)}function QMt(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function aN(e,t){const n=t.node.attrs??{},{numId:r,level:i}=XMt(t.node),o=r1(n.listRendering),s=o?.path,a=o8(s),l=o?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:i,kind:ZMt(e,t,r,i),marker:l,path:s,ordinal:a,text:QMt(t)}}function Rwe(e,t){return{address:e.address,listId:t,marker:e.marker,ordinal:e.ordinal,path:e.path,level:e.level,kind:e.kind,text:e.text}}function $Mt(e,t){return t?!(t.kind&&e.kind!==t.kind||t.level!=null&&e.level!==t.level||t.ordinal!=null&&e.ordinal!==t.ordinal):!0}function eDt(e,t){if(!t)return;const n=e.candidates.filter(r=>r.nodeType===t.nodeType&&r.nodeId===t.nodeId);if(n.length===0)throw new Oe("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new Oe("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function tDt(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function nDt(e,t){if(t?.within&&t.within.kind!=="block")throw new Oe("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});ig(t?.offset,t?.limit);const n=jn(e),r=eDt(n,t?.within),i=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>aN(e,f)),o=i.filter(f=>tDt(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=cr(e),c=Ewe(i);let u=0;const d=[];for(const f of o){if(!$Mt(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=Rwe(f,p),g=Do(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:w,level:x,kind:S,text:T}=m;d.push(ds(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:w,level:x,kind:S,text:T}))}return Uo({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function Wo(e,t){const n=jn(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new Oe("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new Oe("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return aN(e,n[0])}var rDt=new Set(["text","date","checkbox","comboBox","dropDownList"]),Pwe=new WeakMap;function iDt(e){const t=e.state.doc,n=Pwe.get(e),r=Dwe(e);if(n&&n.doc===t)return Lwe(n.counts,r);const i=oDt(e);return Pwe.set(e,{doc:t,counts:i}),Lwe(i,r)}function oDt(e){const t=GU(e,{}),n=jn(e),r=rg(e),i=sDt(n),o=aDt(r);return{words:Nwe(t),characters:t.length,paragraphs:i.paragraphs,headings:i.headings,tables:i.tables,images:i.blockImages+o,comments:lDt(r),trackedChanges:cDt(e),sdtFields:uDt(e),lists:dDt(e,n)}}function Lwe(e,t){return t!=null?{...e,pages:t}:{...e}}function Nwe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function sDt(e){let t=0,n=0,r=0,i=0;for(const o of e.candidates)switch(o.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":i++;break}return{paragraphs:t,headings:n,tables:r,blockImages:i}}function aDt(e){return e.byType.get("image")?.length??0}function lDt(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const i=ML(r.attrs??{});i&&n.add(i)}return n.size}function cDt(e){return Hw(e).length}function uDt(e){return zw(e.state.doc).filter(t=>rDt.has(gp(t.node.attrs??{}))).length}function dDt(e,t){const n=fDt(e,t);if(n.length===0)return 0;const r=Ewe(n);let i=0,o,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==o&&(i+=1),o=l,s=void 0;continue}o=void 0,(!s||hDt(s,a))&&(i+=1),s=a}return i}function fDt(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>aN(e,n))}function hDt(e,t){return pDt(e,t)?!0:mDt(e,t)}function pDt(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function mDt(e,t){const n=Mwe(e),r=Mwe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Mwe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Dwe(e){return e.currentTotalPages}function Ww(e){const t=GU(e,{});return{words:Nwe(t),characters:gDt(t),charactersWithSpaces:yDt(t),pages:Dwe(e)}}function lN(e,t){switch(e){case"NUMWORDS":return String(t.words);case"NUMCHARS":return String(t.characters);case"NUMPAGES":return t.pages!=null?String(t.pages):null;default:return null}}function By(e){return e.options?.parentEditor??e}function gDt(e){return e.replace(/\s/g,"").length}function yDt(e){return e.replace(/\n/g,"").length}function Owe(e){const t=new Map,n=Ww(By(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const i=lN(r,n);i!=null&&t.set(r,i)}return t}const XU="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",bDt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",vDt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var Fwe="/APA.XSL",Bwe="APA",Hwe="6",zwe=Object.freeze({book:"Book",journalArticle:"JournalArticle",conferenceProceedings:"ConferenceProceedings",report:"Report",website:"InternetSite",patent:"Patent",case:"Case",statute:"Case",thesis:"Report",film:"Film",interview:"Interview",misc:"Misc"}),wDt=Object.freeze({book:"book",journalarticle:"journalArticle",conferenceproceedings:"conferenceProceedings",report:"report",internetsite:"website",documentfrominternetsite:"website",articleinaperiodical:"journalArticle",patent:"patent",case:"case",statute:"statute",thesis:"thesis",film:"film",interview:"interview",misc:"misc"}),JU=Object.freeze({title:"Title",year:"Year",publisher:"Publisher",city:"City",journalName:"JournalName",volume:"Volume",issue:"Issue",pages:"Pages",url:"URL",doi:"DOI",edition:"Edition",medium:"Medium",shortTitle:"ShortTitle",standardNumber:"StandardNumber"}),ADt=Object.freeze(Object.fromEntries(Object.entries(JU).map(([e,t])=>[t,e])));function ug(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function cN(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function Gw(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function uN(e,t){const n=t??Rbe;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Uwe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(ug(n.name)==="Person"){t.push(n);continue}Uwe(n,t)}}}function SDt(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=ug(n.name),i=cN(n);i&&(r==="First"&&(t.first=i),r==="Middle"&&(t.middle=i),r==="Last"&&(t.last=i))}return typeof t.last=="string"&&t.last.length>0?t:null}function ZU(e,t){const n=(e?.elements??[]).find(i=>i?.type==="element"&&ug(i.name)===t);if(!n)return[];const r=[];return Uwe(n,r),r.map(SDt).filter(Boolean)}function xDt(e){if(!e||typeof e.last!="string"||e.last.trim().length===0)return null;const t=[],n=e.last.trim(),r=typeof e.first=="string"?e.first.trim():"",i=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(Gw("b:Last",n)),r&&t.push(Gw("b:First",r)),i&&t.push(Gw("b:Middle",i)),{type:"element",name:"b:Person",elements:t}}function TDt(e){const t=(e??[]).map(xDt).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function QU(e,t){const n=TDt(t);return n?e==="Author"?{type:"element",name:"b:Author",elements:[{type:"element",name:"b:Author",elements:[n]}]}:{type:"element",name:`b:${e}`,elements:[n]}:null}function IDt(e){return zwe[typeof e=="string"?e.trim():""]??zwe.misc}function kDt(e){return wDt[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function $U(e){if(!e||typeof e!="object")return null;const t=e.tag??e.sourceId,n=typeof t=="string"?t.trim():"";if(!n)return null;const r=typeof e.type=="string"?e.type:"misc",i=e.fields&&typeof e.fields=="object"?e.fields:{},o={};for(const s of Object.keys(JU)){const a=i[s];typeof a=="string"&&a.trim().length>0&&(o[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=i[s];if(!Array.isArray(a))continue;const l=a.map(c=>{if(!c||typeof c!="object")return null;const u={first:typeof c.first=="string"?c.first.trim():void 0,middle:typeof c.middle=="string"?c.middle.trim():void 0,last:typeof c.last=="string"?c.last.trim():void 0};return u.last?u:null}).filter(Boolean);l.length>0&&(o[s]=l)}return{tag:n,type:r,fields:o}}function EDt(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=ug(a.name);if(l==="Tag"){n=cN(a);continue}if(l==="SourceType"){r=kDt(cN(a));continue}const c=ADt[l];if(!c)continue;const u=cN(a);u&&(t[c]=u)}const i=ZU(e,"Author");i.length>0&&(t.authors=i);const o=ZU(e,"Editor");o.length>0&&(t.editor=o);const s=ZU(e,"Translator");return s.length>0&&(t.translator=s),$U({tag:n,type:r,fields:t})}function CDt(e){const t=$U(e);if(!t)return null;const n=[Gw("b:Tag",t.tag),Gw("b:SourceType",IDt(t.type))];for(const[s,a]of Object.entries(JU)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(Gw(`b:${a}`,l))}const r=QU("Author",t.fields?.authors);r&&n.push(r);const i=QU("Editor",t.fields?.editor);i&&n.push(i);const o=QU("Translator",t.fields?.translator);return o&&n.push(o),{type:"element",name:"b:Source",elements:n}}function _Dt(e){if(!e||e.type!=="element"||ug(e.name)!=="Sources")return!1;const t=e.attributes?.xmlns,n=e.attributes?.["xmlns:b"];return t==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"||n==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"}function Vwe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function RDt(e){return e.startsWith("customXml/")?`../${e}`:e}function PDt(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>ug(n.name)==="Relationships")||null}function LDt(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=uN({type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}));const t=e["word/_rels/document.xml.rels"];t.elements??=[];let n=t.elements.find(r=>ug(r.name)==="Relationships");return n||(n={type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]},t.elements.push(n)),n.elements??=[],n}function NDt(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const i=/^rId(\d+)$/.exec(r);return i?Number.parseInt(i[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function MDt(e){const t=new Set;for(const r of Object.keys(e??{})){const i=/customXml\/item(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10));const o=/customXml\/itemProps(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function DDt(e,t){const n=e.map(CDt).filter(Boolean),r=t.selectedStyle||Fwe,i=t.styleName||Bwe,o=t.version||Hwe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":XU,xmlns:XU,SelectedStyle:r,StyleName:i,Version:o},elements:n}}function ODt(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function FDt(e){return{type:"element",name:"ds:datastoreItem",attributes:{"ds:itemID":e,"xmlns:ds":"http://schemas.openxmlformats.org/officeDocument/2006/customXml"},elements:[{type:"element",name:"ds:schemaRefs",elements:[{type:"element",name:"ds:schemaRef",attributes:{"ds:uri":XU}}]}]}}function BDt(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:vDt,Target:e}}]}}function Wwe(e){const t=new Map;for(const n of e){const r=$U(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function eV(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Gwe(e){const t=eV(),n=PDt(e);if(!n?.elements?.length)return t;const r=[];for(const i of n.elements){if(i?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const o=i?.attributes?.Target,s=V0(o,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(_Dt(a)){if(!t.partPath){t.partPath=s,t.selectedStyle=a.attributes?.SelectedStyle??null,t.styleName=a.attributes?.StyleName??null,t.version=a.attributes?.Version??null;const l=Vwe(s);if(l!=null){const c=`customXml/itemProps${l}.xml`,u=`customXml/_rels/item${l}.xml.rels`;t.itemPropsPath=e[c]?c:null,t.itemRelsPath=e[u]?u:null}}for(const l of a.elements??[]){if(!l||l.type!=="element"||ug(l.name)!=="Source")continue;const c=EDt(l);c&&r.push(c)}}}return t.sources=Wwe(r),t}function HDt(e,t){const n=Gwe(e),r=Wwe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...eV(),sources:[]};const i=t?.partPath||n.partPath,o=Vwe(i),s=o??MDt(e),a=o?i:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??Fwe,d=t?.styleName??n.styleName??Bwe,f=t?.version??n.version??Hwe,h=e[a]?.declaration;e[a]=uN(DDt(r,{selectedStyle:u,styleName:d,version:f}),h);const p=LDt(e),m=RDt(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:V0(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:NDt(p),Type:bDt,Target:m}});const g=e[l],y=g?.declaration;e[l]=uN(FDt(ODt(g)||`{${wn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=uN(BDt(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function zDt(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}function UDt(e){const t=new Set;function n(r){if(Array.isArray(r))for(const i of r)!i||typeof i!="object"||(i.name==="w:numId"&&i.attributes?.["w:val"]!=null&&t.add(Number(i.attributes["w:val"])),i.elements&&n(i.elements))}for(const[r,i]of Object.entries(e))r.startsWith("word/")&&r!=="word/numbering.xml"&&i?.elements&&n(i.elements);return t}function VDt(e){const t=e.elements?.find(n=>n.name==="w:abstractNumId");if(t?.attributes?.["w:val"]!=null)return Number(t.attributes["w:val"])}function WDt(e,t){const n=Object.values(e.definitions).filter(i=>t.has(Number(i.attributes?.["w:numId"]))),r=new Set;for(const i of n){const o=VDt(i);o!=null&&r.add(o)}return{liveAbstracts:Object.values(e.abstracts).filter(i=>r.has(Number(i.attributes?.["w:abstractNumId"]))),liveDefinitions:n}}var GDt=md(Pv(),1),jDt=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),jwe="sans-serif",qDt=10,YDt="1.31.0",qwe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:i})=>{if(!e?.elements?.length||!i)return;const o=e.elements.find(l=>l.name==="w:rFonts");if(o?.attributes){const l=o.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!i.typeface)&&u.typeface&&(i.typeface=u.typeface),(t||!i.panose)&&u.panose&&(i.panose=u.panose)}const c=o.attributes["w:ascii"];(t||!i.typeface)&&c&&(i.typeface=c)}const s=e.elements.find(l=>l.name==="w:sz");if(s?.attributes?.["w:val"]){const l=Number(s.attributes["w:val"]);if(Number.isFinite(l)){i.fallbackSzTwips===void 0&&(i.fallbackSzTwips=l);const c=l/2;(n||i.fontSizePt===void 0)&&(i.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||i.kern===void 0)&&(i.kern=a.attributes["w:val"])},ju=class wo{static allowedElements=Object.freeze({"w:document":"doc","w:body":"body","w:p":"paragraph","w:r":"run","w:t":"text","w:delText":"text","w:br":"lineBreak","w:tbl":"table","w:tr":"tableRow","w:tc":"tableCell","w:drawing":"drawing","w:bookmarkStart":"bookmarkStart","w:sectPr":"sectionProperties","w:rPr":"runProperties","w:commentRangeStart":"commentRangeStart","w:commentRangeEnd":"commentRangeEnd","w:commentReference":"commentReference"});static markTypes=[{name:"w:b",type:"bold",property:"value"},{name:"w:i",type:"italic"},{name:"w:u",type:"underline",mark:"underline",property:"underlineType"},{name:"w:strike",type:"strike",mark:"strike",property:"value"},{name:"w:color",type:"color",mark:"textStyle",property:"color"},{name:"w:sz",type:"fontSize",mark:"textStyle",property:"fontSize"},{name:"w:rFonts",type:"fontFamily",mark:"textStyle",property:"fontFamily"},{name:"w:rStyle",type:"styleId",mark:"textStyle",property:"styleId"},{name:"w:jc",type:"textAlign",mark:"textStyle",property:"textAlign"},{name:"w:ind",type:"textIndent",mark:"textStyle",property:"textIndent"},{name:"w:spacing",type:"lineHeight",mark:"textStyle",property:"lineHeight"},{name:"w:spacing",type:"letterSpacing",mark:"textStyle",property:"letterSpacing"},{name:"link",type:"link",mark:"link",property:"href"},{name:"w:highlight",type:"highlight",mark:"highlight",property:"color"},{name:"w:shd",type:"highlight",mark:"highlight",property:"color"},{name:"w:caps",type:"textTransform",mark:"textStyle",property:"textTransform"}];static propertyTypes=Object.freeze({"w:pPr":"paragraphProperties","w:rPr":"runProperties","w:sectPr":"sectionProperties","w:numPr":"numberingProperties","w:tcPr":"tableCellProperties"});static elements=new Set(["w:document","w:body","w:p","w:r","w:t","w:delText"]);static getFontTableEntry(t,n){if(!t||!n)return null;const r=t["word/fontTable.xml"];if(!r?.elements?.length)return null;const i=r.elements.find(o=>o.name==="w:fonts");return i?.elements?.length&&i.elements.find(o=>o?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=wo.getFontTableEntry(t,n)?.elements?.find(i=>i.name==="w:family")?.attributes?.["w:val"];return r?jDt[r.toLowerCase()]||jwe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=wo.getFallbackFromFontTable(n,t)||jwe;return r.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(t.trim().toLowerCase())?r:`${t}, ${r}`}constructor(t=null){this.debug=t?.debug||!1,this.domEnvironment={mockWindow:t?.mockWindow||null,mockDocument:t?.mockDocument||null},this.declaration=null,this.documentAttributes=null,this.convertedXml={},this.docx=t?.docx||[],this.media=t?.media||{},this.fonts=t?.fonts||{},this.trackedChangesOptions=t?.trackedChangesOptions||null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=eV(),this.viewSetting=null,this.inlineDocumentFonts=[],this.commentThreadingProfile=null,this.exportWarnings=[],this.docHiglightColors=new Set([]),this.xml=t?.xml,this.declaration=null,this.numbering={},this.translatedNumbering={},this.numbering=null,this.pageStyles=null,this.themeColors=null,this.initialJSON=null,this.headers={},this.headerIds={default:null,even:null,odd:null,first:null},this.headerEditors=[],this.footers={},this.footerIds={default:null,even:null,odd:null,first:null},this.footerEditors=[],this.importedBodyHasHeaderRef=!1,this.importedBodyHasFooterRef=!1,this.headerFooterModified=!1,this.linkedStyles=[],this.translatedLinkedStyles={},this.json=t?.json,this.tagsNotInSchema=["w:body"],this.savedTagsToRestore=[],this.documentInternalId=null,this.fileSource=t?.fileSource||null,this.documentId=t?.documentId||null,this.documentGuid=null,this.documentUniqueIdentifier=null,this.documentModified=!1,this.isBlankDoc=t?.isNewFile||!1,(this.docx.length||this.xml)&&this.parseFromXml()}get docxHelpers(){return r1t}parseFromXml(){if(this.docx?.forEach(t=>{this.convertedXml[t.name]=this.parseXmlToJson(t.content),t.name==="word/document.xml"&&(this.documentAttributes=this.convertedXml[t.name].elements[0]?.attributes),t.name==="word/styles.xml"&&(this.convertedXml[t.name]=gbe(this.convertedXml[t.name]))}),!this.convertedXml["word/styles.xml"]){for(let t=1;t<=5;t+=1)if(this.convertedXml[`word/styles${t}.xml`]!=null){this.convertedXml["word/styles.xml"]=gbe(this.convertedXml[`word/styles${t}.xml`]);break}}this.initialJSON=this.convertedXml["word/document.xml"],this.initialJSON||(this.initialJSON=this.parseXmlToJson(this.xml)),this.declaration=this.initialJSON?.declaration,this.resolveDocumentGuid()}parseXmlToJson(t){const n=t.replace(/(<w:(?:t|delText)(?:\s[^>]*)?>)(\s+)(<\/w:(?:t|delText)>)/g,"$1[[sdspace]]$2[[sdspace]]$3");return JSON.parse(GDt.xml2json(n,null,2))}static _matchesElementName(t,n){return!t||typeof t!="string"||!n?!1:t===n?!0:t.endsWith(`:${n}`)?t.slice(0,-(n.length+1)).length>0:!1}static _extractNamespacePrefix(t){if(!t||typeof t!="string")return"";const n=t.indexOf(":");return n>0?t.slice(0,n):""}static getStoredCustomProperty(t,n){try{const r=t.find(l=>l.name==="docProps/custom.xml");if(!r)return null;const i=new wo,o=r.content,s=i.parseXmlToJson(o)?.elements?.find(l=>wo._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>wo._matchesElementName(l.name,"property")&&l.attributes?.name===n);return a?a.elements?.[0]?.elements?.[0]?.text?a.elements[0].elements[0].text:(console.warn(`Malformed property structure for "${n}"`),null):null}catch(r){return console.warn(`Error getting custom property ${n}:`,r),null}}static setStoredCustomProperty(t,n,r,i=!1){try{const o="docProps/custom.xml";t[o]||(t[o]=KDt());const s=t[o].elements?.find(d=>wo._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=wo._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>wo._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&i)return c.elements?.[0]?.elements?.[0]?.text?c.elements[0].elements[0].text:(console.warn(`Malformed existing property structure for "${n}"`),null);const u=typeof r=="function"?r():r;if(c)wo._extractNamespacePrefix(c.name)!==a&&(c.name=l),c.elements?.[0]?.elements?.[0]?c.elements[0].elements[0].text=u:(console.warn(`Malformed property structure for "${n}", recreating structure`),c.elements=[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]);else{const d=s.elements.filter(f=>f.attributes?.pid).map(f=>parseInt(f.attributes.pid,10)).filter(Number.isInteger);c={type:"element",name:l,attributes:{name:n,fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:d.length>0?Math.max(...d)+1:2},elements:[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]},s.elements.push(c)}return u}catch(o){return console.warn(`Error setting custom property ${n}:`,o),null}}static getStoredSuperdocVersion(t){return wo.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=YDt){return wo.setStoredCustomProperty(t,"SuperdocVersion",n,!1)}static generateWordTimestamp(){const t=new Date;return t.setSeconds(0,0),t.toISOString().split(".")[0]+"Z"}getDocumentCreatedTimestamp(){const t=this.convertedXml["docProps/core.xml"];if(!t)return null;const n=t.elements?.find(r=>r.name==="cp:coreProperties"||wo._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||wo._matchesElementName(r.name,"created"))?.elements?.[0]?.text||null}setDocumentCreatedTimestamp(t){const n=this.convertedXml["docProps/core.xml"];if(!n)return;const r=n.elements?.find(o=>o.name==="cp:coreProperties"||wo._matchesElementName(o.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let i=r.elements.find(o=>o.name==="dcterms:created"||wo._matchesElementName(o.name,"created"));i?.elements?.[0]?i.elements[0].text=t:(i={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(i))}static extractDocumentGuid(t){try{const n=t.find(o=>o.name==="word/settings.xml");if(!n)return null;const r=new wo().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const i=r.elements?.find(o=>o.name==="w15:docId");if(i?.attributes?.["w15:val"])return i.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return wo.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?wo.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=wo.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(wo.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Vie(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`;try{let t;if(ArrayBuffer.isView(this.fileSource)){const n=this.fileSource;t=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}else if(this.fileSource instanceof ArrayBuffer)t=new Uint8Array(this.fileSource);else if(this.fileSource instanceof Blob||this.fileSource instanceof File){const n=await this.fileSource.arrayBuffer();t=new Uint8Array(n)}else return`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Vie(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`}}async getDocumentIdentifier(){if(this.documentUniqueIdentifier)return this.documentUniqueIdentifier;const t=!!this.documentGuid,n=!!this.getDocumentCreatedTimestamp();return t&&n?this.documentUniqueIdentifier=this.#e():(t||(this.documentGuid=wn()),n||this.setDocumentCreatedTimestamp(wo.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||wn(),this.documentModified=!0,this.documentUniqueIdentifier=null,this.documentGuid)}getDocumentDefaultStyles(){const t=this.convertedXml["word/styles.xml"]?.elements?.[0]?.elements||[];if(!t.length)return{};const n=t.find(l=>l.name==="w:docDefaults"),r=t.find(l=>l.name==="w:style"&&l.attributes?.["w:styleId"]==="Normal"),i={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},o=n?.elements?.find(l=>l.name==="w:rPrDefault");qwe(o?.elements?.find(l=>l.name==="w:rPr")??o,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),qwe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),i.fontSizePt===void 0&&(Number.isFinite(i.fallbackSzTwips)?i.fontSizePt=i.fallbackSzTwips/2:i.fontSizePt=qDt);const s=i.typeface?wo.toCssFontFamily(i.typeface,this.convertedXml):void 0,a={};return i.fontSizePt!==void 0&&(a.fontSizePt=i.fontSizePt),i.kern!==void 0&&(a.kern=i.kern),i.typeface&&(a.typeface=i.typeface),i.panose&&(a.panose=i.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,i=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,o=r||(i?i.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return o&&!f.includes(o)&&f.push(o),f},a=this.convertedXml["word/fontTable.xml"];if(!a)return s(t);const l=a.elements?.find(d=>d.name==="w:fonts");if(!l||!l.elements)return s(t);const c=l.elements.filter(d=>d.name==="w:font").map(d=>d.attributes["w:name"]),u=[...t,...c];return s([...new Set(u)])}getFontFaceImportString(){const t=this.convertedXml["word/fontTable.xml"];if(!t||!Object.keys(this.fonts).length)return;const n=t.elements.find(s=>s.name==="w:fonts")?.elements.filter(s=>s.elements?.some(a=>a?.attributes&&a.attributes["r:id"]&&a.attributes["w:fontKey"]))?.reduce((s,a)=>{const l=a.elements.filter(c=>c.name.startsWith("w:embed"))?.map(c=>({...c,fontFamily:a.attributes["w:name"]}));return[...s,...l]},[]),{elements:r}=this.convertedXml["word/_rels/fontTable.xml.rels"]?.elements.find(s=>s.name==="Relationships")||{},i=[];let o="";for(const s of n){const a=r.find(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=fKe(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";i.includes(s.fontFamily)||i.push(s.fontFamily),o+=`
89
+ `)}var NMt=ls({findChildren:()=>fwe,findInlineNodes:()=>hwe,findMarkPosition:()=>uwe,flatten:()=>dwe},1);const uwe=(e,t,n)=>{const r=e.resolve(t),i=r.parent,o=i.childAfter(r.parentOffset);if(!o.node)return null;const s=o.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+o.offset;for(;a>0&&s.isInSet(i.child(a-1).marks);)l-=i.child(--a).nodeSize;let c=r.index()+1,u=r.start()+o.offset+o.node.nodeSize;for(;c<i.childCount&&s.isInSet(i.child(c).marks);)u+=i.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},dwe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,i)=>{if(n.push({node:r,pos:i}),!t)return!1}),n},fwe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return dwe(e,n).filter(r=>t(r.node))},hwe=(e,t)=>fwe(e,n=>n.isInline,t),nu=(e,t=null)=>{const n=[],r=hwe(e.doc);return r.length?(r.forEach(({node:i,pos:o})=>{const{marks:s}=i,a=[Ul,Ts,Ha];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,from:o,to:o+i.nodeSize})})}),t?n.filter(({mark:i})=>i.attrs.id===t):n):n};var MMt=24;function DMt(e){try{const t=nu(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function OMt(e){let t=2166136261,n=16777619,r=3735928559;for(let i=0;i<e.length;i++){const o=e.charCodeAt(i);t=Math.imul(t^o,16777619),n=Math.imul(n^o,1540483477),r=Math.imul(r^o,461845907)}return t=Math.imul(t^t>>>16,2246822507),n=Math.imul(n^n>>>16,3432918353),r=Math.imul(r^r>>>16,461845907),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")).slice(0,MMt)}function FMt(e,t){const n=jU(t),r=DL(e.state.doc.textBetween(t.from,t.to," ",""))??"",i=$o(t.attrs.author)??"",o=$o(t.attrs.authorEmail)??"",s=$o(t.attrs.date)??"";return OMt(`${n}|${t.from}|${t.to}|${i}|${o}|${s}|${r}`)}function jU(e){return e.hasFormat?"format":e.hasDelete&&!e.hasInsert?"delete":"insert"}var pwe=new WeakMap;function mwe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function BMt(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function Hw(e){const t=e.state.doc,n=pwe.get(e);if(n&&n.doc===t)return n.grouped;const r=DMt(e),i=new Map;for(const s of r){const a=s.mark?.attrs??{},l=$o(a.id);if(!l)continue;const c=i.get(l),u=s.mark.type.name,d=u===Ul,f=u===Ts,h=u===Ha,p=$o(a.sourceId),m=BMt(u);if(!c){i.set(l,{rawId:l,from:s.from,to:s.to,hasInsert:d,hasDelete:f,hasFormat:h,attrs:{...a},wordRevisionIds:m?mwe(void 0,m,p??void 0):void 0});continue}c.from=Math.min(c.from,s.from),c.to=Math.max(c.to,s.to),c.hasInsert=c.hasInsert||d,c.hasDelete=c.hasDelete||f,c.hasFormat=c.hasFormat||h,Object.keys(c.attrs).length===0&&Object.keys(a).length>0&&(c.attrs={...a}),m&&(c.wordRevisionIds=mwe(c.wordRevisionIds,m,p??void 0))}const o=Array.from(i.values()).map(s=>({...s,id:FMt(e,s)})).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return pwe.set(e,{doc:t,grouped:o}),o}function gwe(e,t){return Hw(e).find(n=>n.id===t)??null}function ywe(e){const t=Hw(e),n=new Map;for(const r of t)n.set(r.rawId,r.id),n.set(r.id,r.id);return n}function HMt(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function iN(e,t){const n=HMt(t),r=n.entityId,i=n.story??{kind:"story",storyType:"body"};if((n.story?Eo(n.story):"body")==="body"){const a=bwe(e,r);return a?{editor:e,story:i,runtimeRef:{storyKey:qf,rawId:a.rawId},change:a}:null}let o;try{o=ja(e,i)}catch{return null}const s=bwe(o.editor,r);return s?{editor:o.editor,story:o.locator,runtimeRef:{storyKey:o.storyKey,rawId:s.rawId},change:s,commit:o.commit}:null}function bwe(e,t){return Hw(e).find(n=>n.id===t||n.rawId===t)??null}const zMt=["structuredContent","structuredContentBlock"],gk="structuredContentBlock";function yk(e){return zMt.includes(e.type.name)}function zw(e){const t=[];return e.descendants((n,r)=>(yk(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function An(e,t){const n=t.nodeId,r=zw(e).filter(i=>String(i.node.attrs.id)===n);if(r.length===0)throw new Oe("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new Oe("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function na(e,t){return e?.elements?.find(n=>n.name===t)}function vwe(e,t){return na(e,t)?.attributes}function oN(e,t,n){const r=e.elements?[...e.elements]:[],i=r.findIndex(o=>o.name===t);return i>=0?r[i]=n:r.push(n),{...e,elements:r}}function wwe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}function Fy(e,t,n){const r=e.commands?.updateStructuredContentById;return typeof r!="function"?!1:!!r(t,{attrs:n})}function qd(e,t,n,r){const i=An(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},o=r(na(i,n));let s;return o===null?s=wwe(i,n):s=oN(i,n,o),Fy(e,t.nodeId,{sdtPr:s})}function qU(e,t,n,r,i,o){return qd(e,t,n,s=>{const a=s??{name:n,type:"element",elements:[]},l=a.elements?[...a.elements]:[],c=l.findIndex(d=>d.name===r),u={name:r,type:"element",attributes:{[i]:o}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[i]:o}}:l.push(u),{...a,elements:l}})}function UMt(e,t,n,r){return qd(e,t,n,i=>({name:n,type:"element",...i,elements:r}))}var VMt=["text","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],WMt=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],GMt=["boundingBox","tags","hidden"];function gp(e){const t=e.controlType??e.type;return typeof t=="string"&&VMt.includes(t)?t:"unknown"}function sN(e){const t=e.lockMode;return typeof t=="string"&&WMt.includes(t)?t:"unlocked"}function Awe(e){const t=e.appearance;if(typeof t=="string"&&GMt.includes(t))return t}function Swe(e){const t=e.sdtPr;if(!t)return;const n=vwe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],i=n["w:xpath"];if(!(!r||!i))return{storeItemId:r,xpath:i,prefixMappings:n["w:prefixMappings"]}}function Ci(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function YU(e){const t=(na(e,"w14:checkbox")??na(e,"w:checkbox"))?.elements?.find(r=>r.name==="w14:checked"||r.name==="w:checked"),n=t?.attributes?.["w14:val"]??t?.attributes?.["w:val"];return n==="1"||n==="true"||n===!0}function KU(e,t){const n=na(e,`w:${t}`);return{items:(n?.elements?.filter(r=>r.name==="w:listItem")??[]).map(r=>({displayText:String(r.attributes?.["w:displayText"]??""),value:String(r.attributes?.["w:value"]??"")})),selectedValue:n?.attributes?.["w:lastValue"]}}function jMt(e,t){if(!t)return{};switch(e){case"text":{const n=vwe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=na(t,"w:date");if(!n)return{};const r=na(n,"w:dateFormat"),i=na(n,"w:lid"),o=na(n,"w:storeMappedDataAs"),s=na(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:i?.attributes?.["w:val"],storageFormat:o?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=na(t,"w14:checkbox")??na(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(o=>o.name==="w14:checkedState"),i=n.elements?.find(o=>o.name==="w14:uncheckedState");return{checked:YU(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:i?{font:String(i.attributes?.["w14:font"]??""),char:String(i.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return KU(t,e);case"repeatingSection":{const n=na(t,"w15:repeatingSection")??na(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(o=>o.name==="w15:allowInsertDeleteSection"||o.name==="w:allowInsertDeleteSection"),i=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:i==="1"||i==="true"||i===!0}}default:return{}}}function cg(e){const t=e.node.attrs,n=String(t.id??""),r=gp(t),i=sN(t),o=typeof t.sdtPr=="object"&&t.sdtPr!==null?t.sdtPr:void 0;let s;try{s=e.node.textContent||void 0}catch{s=void 0}const a=jMt(r,o);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:i,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:Awe(t),placeholder:typeof t.placeholder=="string"?t.placeholder:void 0,color:typeof t.color=="string"?t.color:void 0,showingPlaceholder:typeof t.showingPlaceholder=="boolean"?t.showingPlaceholder:void 0,temporary:typeof t.temporary=="boolean"?t.temporary:void 0,tabIndex:typeof t.tabIndex=="number"?t.tabIndex:void 0,...a},binding:Swe(t),raw:o,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function qMt(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:gp(n),lockMode:sN(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:Awe(n),placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,color:typeof n.color=="string"?n.color:void 0,showingPlaceholder:typeof n.showingPlaceholder=="boolean"?n.showingPlaceholder:void 0,temporary:typeof n.temporary=="boolean"?n.temporary:void 0,tabIndex:typeof n.tabIndex=="number"?n.tabIndex:void 0},target:{kind:t,nodeType:"sdt",nodeId:r}}}function qa(e,t){const n=sN(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new Oe("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Xf(e,t){const n=sN(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new Oe("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function ra(e,t,n){const r=gp(e.node.attrs),i=Array.isArray(t)?t:[t];if(!i.includes(r))throw new Oe("TYPE_MISMATCH",`Operation "${n}" requires control type ${i.join(" or ")}, but found "${r}".`,{expected:i,actual:r,operation:n})}function xwe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function Jf(e,t){return{success:!1,failure:{code:e,message:t}}}function bk(e,t){const n=e.length,r=t?.offset??0,i=t?.limit??n;return{items:e.slice(r,r+i),total:n}}function vk(e,t){const n=jn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new Oe("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new Oe("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function Twe(e,t,n){const r=vk(e,t),i=vk(e,n);if(r.pos>i.pos)throw new Oe("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return jn(e).candidates.filter(o=>(o.nodeType==="paragraph"||o.nodeType==="listItem")&&o.pos>=r.pos&&o.pos<=i.pos)}function Gu(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const i=r.elements.find(o=>o.name==="w:abstractNumId")?.attributes?.["w:val"];return i!=null?Number(i):void 0}function Uw(e){return jn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>aN(e,t))}function bl(e,t){if(t.numId==null)return[t];const n=Uw(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const i=t.numId;let o=r;for(let a=r-1;a>=0&&n[a].numId===i;a--)o=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===i;a++)s=a;return n.slice(o,s+1)}function Iwe(e,t){const n=bl(e,t),r=n.findIndex(i=>i.address.nodeId===t.address.nodeId);return n.slice(r)}function kwe(e,t){const n=bl(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function YMt(e,t){if(t.numId==null)return"";const n=bl(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function Ewe(e){const t=new Map;let n,r;for(const i of e){if(i.numId==null){t.set(i.address.nodeId,""),n=void 0,r=void 0;continue}i.numId!==n&&(n=i.numId,r=i.address.nodeId),t.set(i.address.nodeId,`${n}:${r}`)}return t}function Vw(e,t,n){if(t.numId==null)return null;const r=Uw(e),i=bl(e,t);if(n==="withNext"){const o=i[i.length-1],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:bl(e,l),numId:l.numId,abstractNumId:Gu(e,l.numId)}}}else{const o=i[0],s=r.findIndex(a=>a.address.nodeId===o.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:bl(e,l),numId:l.numId,abstractNumId:Gu(e,l.numId)}}}return null}function KMt(e,t){if(t.numId==null)return null;const n=Gu(e,t.numId);if(n==null)return null;const r=Uw(e),i=bl(e,t)[0],o=r.findIndex(s=>s.address.nodeId===i.address.nodeId);for(let s=o-1;s>=0;s--){const a=r[s];if(a.numId!=null&&Gu(e,a.numId)===n&&a.numId!==t.numId)return{sequence:bl(e,a),numId:a.numId}}return null}function Cwe(e,t,n){const r=Vw(e,t,n);if(!r)return{canJoin:!1,reason:"NO_ADJACENT_SEQUENCE"};if(r.numId===t.numId)return{canJoin:!1,reason:"ALREADY_SAME_SEQUENCE"};const i=t.numId!=null?Gu(e,t.numId):void 0;if(i==null||r.abstractNumId==null||i!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const o=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${o}`}}function _we(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=Gu(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=Uw(e),i=bl(e,t)[0],o=r.findIndex(a=>a.address.nodeId===i.address.nodeId);let s=!1;for(let a=o-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,Gu(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=bl(e,l)[0]?.address.nodeId??l.address.nodeId;return{canContinue:!0,previousListId:`${l.numId}:${c}`}}return s?{canContinue:!1,reason:"INCOMPATIBLE_DEFINITIONS"}:{canContinue:!1,reason:"NO_PREVIOUS_LIST"}}function XMt(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:NL(n?.numId??r?.numId),level:NL(n?.ilvl??r?.ilvl)}}function JMt(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=ur.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),i=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":void 0}catch{return}}function ZMt(e,t,n,r){const i=(t.node.attrs??{}).listRendering?.numberingType;return i==="bullet"?"bullet":typeof i=="string"&&i.length>0?"ordered":JMt(e,n,r)}function QMt(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function aN(e,t){const n=t.node.attrs??{},{numId:r,level:i}=XMt(t.node),o=r1(n.listRendering),s=o?.path,a=o8(s),l=o?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:i,kind:ZMt(e,t,r,i),marker:l,path:s,ordinal:a,text:QMt(t)}}function Rwe(e,t){return{address:e.address,listId:t,marker:e.marker,ordinal:e.ordinal,path:e.path,level:e.level,kind:e.kind,text:e.text}}function $Mt(e,t){return t?!(t.kind&&e.kind!==t.kind||t.level!=null&&e.level!==t.level||t.ordinal!=null&&e.ordinal!==t.ordinal):!0}function eDt(e,t){if(!t)return;const n=e.candidates.filter(r=>r.nodeType===t.nodeType&&r.nodeId===t.nodeId);if(n.length===0)throw new Oe("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new Oe("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function tDt(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function nDt(e,t){if(t?.within&&t.within.kind!=="block")throw new Oe("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});ig(t?.offset,t?.limit);const n=jn(e),r=eDt(n,t?.within),i=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>aN(e,f)),o=i.filter(f=>tDt(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=cr(e),c=Ewe(i);let u=0;const d=[];for(const f of o){if(!$Mt(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=Rwe(f,p),g=Do(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:w,level:x,kind:S,text:T}=m;d.push(ds(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:w,level:x,kind:S,text:T}))}return Uo({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function Wo(e,t){const n=jn(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new Oe("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new Oe("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return aN(e,n[0])}var rDt=new Set(["text","date","checkbox","comboBox","dropDownList"]),Pwe=new WeakMap;function iDt(e){const t=e.state.doc,n=Pwe.get(e),r=Dwe(e);if(n&&n.doc===t)return Lwe(n.counts,r);const i=oDt(e);return Pwe.set(e,{doc:t,counts:i}),Lwe(i,r)}function oDt(e){const t=GU(e,{}),n=jn(e),r=rg(e),i=sDt(n),o=aDt(r);return{words:Nwe(t),characters:t.length,paragraphs:i.paragraphs,headings:i.headings,tables:i.tables,images:i.blockImages+o,comments:lDt(r),trackedChanges:cDt(e),sdtFields:uDt(e),lists:dDt(e,n)}}function Lwe(e,t){return t!=null?{...e,pages:t}:{...e}}function Nwe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function sDt(e){let t=0,n=0,r=0,i=0;for(const o of e.candidates)switch(o.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":i++;break}return{paragraphs:t,headings:n,tables:r,blockImages:i}}function aDt(e){return e.byType.get("image")?.length??0}function lDt(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const i=ML(r.attrs??{});i&&n.add(i)}return n.size}function cDt(e){return Hw(e).length}function uDt(e){return zw(e.state.doc).filter(t=>rDt.has(gp(t.node.attrs??{}))).length}function dDt(e,t){const n=fDt(e,t);if(n.length===0)return 0;const r=Ewe(n);let i=0,o,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==o&&(i+=1),o=l,s=void 0;continue}o=void 0,(!s||hDt(s,a))&&(i+=1),s=a}return i}function fDt(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>aN(e,n))}function hDt(e,t){return pDt(e,t)?!0:mDt(e,t)}function pDt(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function mDt(e,t){const n=Mwe(e),r=Mwe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Mwe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Dwe(e){return e.currentTotalPages}function Ww(e){const t=GU(e,{});return{words:Nwe(t),characters:gDt(t),charactersWithSpaces:yDt(t),pages:Dwe(e)}}function lN(e,t){switch(e){case"NUMWORDS":return String(t.words);case"NUMCHARS":return String(t.characters);case"NUMPAGES":return t.pages!=null?String(t.pages):null;default:return null}}function By(e){return e.options?.parentEditor??e}function gDt(e){return e.replace(/\s/g,"").length}function yDt(e){return e.replace(/\n/g,"").length}function Owe(e){const t=new Map,n=Ww(By(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const i=lN(r,n);i!=null&&t.set(r,i)}return t}const XU="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",bDt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",vDt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var Fwe="/APA.XSL",Bwe="APA",Hwe="6",zwe=Object.freeze({book:"Book",journalArticle:"JournalArticle",conferenceProceedings:"ConferenceProceedings",report:"Report",website:"InternetSite",patent:"Patent",case:"Case",statute:"Case",thesis:"Report",film:"Film",interview:"Interview",misc:"Misc"}),wDt=Object.freeze({book:"book",journalarticle:"journalArticle",conferenceproceedings:"conferenceProceedings",report:"report",internetsite:"website",documentfrominternetsite:"website",articleinaperiodical:"journalArticle",patent:"patent",case:"case",statute:"statute",thesis:"thesis",film:"film",interview:"interview",misc:"misc"}),JU=Object.freeze({title:"Title",year:"Year",publisher:"Publisher",city:"City",journalName:"JournalName",volume:"Volume",issue:"Issue",pages:"Pages",url:"URL",doi:"DOI",edition:"Edition",medium:"Medium",shortTitle:"ShortTitle",standardNumber:"StandardNumber"}),ADt=Object.freeze(Object.fromEntries(Object.entries(JU).map(([e,t])=>[t,e])));function ug(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function cN(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function Gw(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function uN(e,t){const n=t??Rbe;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Uwe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(ug(n.name)==="Person"){t.push(n);continue}Uwe(n,t)}}}function SDt(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=ug(n.name),i=cN(n);i&&(r==="First"&&(t.first=i),r==="Middle"&&(t.middle=i),r==="Last"&&(t.last=i))}return typeof t.last=="string"&&t.last.length>0?t:null}function ZU(e,t){const n=(e?.elements??[]).find(i=>i?.type==="element"&&ug(i.name)===t);if(!n)return[];const r=[];return Uwe(n,r),r.map(SDt).filter(Boolean)}function xDt(e){if(!e||typeof e.last!="string"||e.last.trim().length===0)return null;const t=[],n=e.last.trim(),r=typeof e.first=="string"?e.first.trim():"",i=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(Gw("b:Last",n)),r&&t.push(Gw("b:First",r)),i&&t.push(Gw("b:Middle",i)),{type:"element",name:"b:Person",elements:t}}function TDt(e){const t=(e??[]).map(xDt).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function QU(e,t){const n=TDt(t);return n?e==="Author"?{type:"element",name:"b:Author",elements:[{type:"element",name:"b:Author",elements:[n]}]}:{type:"element",name:`b:${e}`,elements:[n]}:null}function IDt(e){return zwe[typeof e=="string"?e.trim():""]??zwe.misc}function kDt(e){return wDt[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function $U(e){if(!e||typeof e!="object")return null;const t=e.tag??e.sourceId,n=typeof t=="string"?t.trim():"";if(!n)return null;const r=typeof e.type=="string"?e.type:"misc",i=e.fields&&typeof e.fields=="object"?e.fields:{},o={};for(const s of Object.keys(JU)){const a=i[s];typeof a=="string"&&a.trim().length>0&&(o[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=i[s];if(!Array.isArray(a))continue;const l=a.map(c=>{if(!c||typeof c!="object")return null;const u={first:typeof c.first=="string"?c.first.trim():void 0,middle:typeof c.middle=="string"?c.middle.trim():void 0,last:typeof c.last=="string"?c.last.trim():void 0};return u.last?u:null}).filter(Boolean);l.length>0&&(o[s]=l)}return{tag:n,type:r,fields:o}}function EDt(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=ug(a.name);if(l==="Tag"){n=cN(a);continue}if(l==="SourceType"){r=kDt(cN(a));continue}const c=ADt[l];if(!c)continue;const u=cN(a);u&&(t[c]=u)}const i=ZU(e,"Author");i.length>0&&(t.authors=i);const o=ZU(e,"Editor");o.length>0&&(t.editor=o);const s=ZU(e,"Translator");return s.length>0&&(t.translator=s),$U({tag:n,type:r,fields:t})}function CDt(e){const t=$U(e);if(!t)return null;const n=[Gw("b:Tag",t.tag),Gw("b:SourceType",IDt(t.type))];for(const[s,a]of Object.entries(JU)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(Gw(`b:${a}`,l))}const r=QU("Author",t.fields?.authors);r&&n.push(r);const i=QU("Editor",t.fields?.editor);i&&n.push(i);const o=QU("Translator",t.fields?.translator);return o&&n.push(o),{type:"element",name:"b:Source",elements:n}}function _Dt(e){if(!e||e.type!=="element"||ug(e.name)!=="Sources")return!1;const t=e.attributes?.xmlns,n=e.attributes?.["xmlns:b"];return t==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"||n==="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"}function Vwe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function RDt(e){return e.startsWith("customXml/")?`../${e}`:e}function PDt(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>ug(n.name)==="Relationships")||null}function LDt(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=uN({type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}));const t=e["word/_rels/document.xml.rels"];t.elements??=[];let n=t.elements.find(r=>ug(r.name)==="Relationships");return n||(n={type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]},t.elements.push(n)),n.elements??=[],n}function NDt(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const i=/^rId(\d+)$/.exec(r);return i?Number.parseInt(i[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function MDt(e){const t=new Set;for(const r of Object.keys(e??{})){const i=/customXml\/item(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10));const o=/customXml\/itemProps(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function DDt(e,t){const n=e.map(CDt).filter(Boolean),r=t.selectedStyle||Fwe,i=t.styleName||Bwe,o=t.version||Hwe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":XU,xmlns:XU,SelectedStyle:r,StyleName:i,Version:o},elements:n}}function ODt(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function FDt(e){return{type:"element",name:"ds:datastoreItem",attributes:{"ds:itemID":e,"xmlns:ds":"http://schemas.openxmlformats.org/officeDocument/2006/customXml"},elements:[{type:"element",name:"ds:schemaRefs",elements:[{type:"element",name:"ds:schemaRef",attributes:{"ds:uri":XU}}]}]}}function BDt(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:vDt,Target:e}}]}}function Wwe(e){const t=new Map;for(const n of e){const r=$U(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function eV(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Gwe(e){const t=eV(),n=PDt(e);if(!n?.elements?.length)return t;const r=[];for(const i of n.elements){if(i?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const o=i?.attributes?.Target,s=V0(o,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(_Dt(a)){if(!t.partPath){t.partPath=s,t.selectedStyle=a.attributes?.SelectedStyle??null,t.styleName=a.attributes?.StyleName??null,t.version=a.attributes?.Version??null;const l=Vwe(s);if(l!=null){const c=`customXml/itemProps${l}.xml`,u=`customXml/_rels/item${l}.xml.rels`;t.itemPropsPath=e[c]?c:null,t.itemRelsPath=e[u]?u:null}}for(const l of a.elements??[]){if(!l||l.type!=="element"||ug(l.name)!=="Source")continue;const c=EDt(l);c&&r.push(c)}}}return t.sources=Wwe(r),t}function HDt(e,t){const n=Gwe(e),r=Wwe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...eV(),sources:[]};const i=t?.partPath||n.partPath,o=Vwe(i),s=o??MDt(e),a=o?i:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??Fwe,d=t?.styleName??n.styleName??Bwe,f=t?.version??n.version??Hwe,h=e[a]?.declaration;e[a]=uN(DDt(r,{selectedStyle:u,styleName:d,version:f}),h);const p=LDt(e),m=RDt(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:V0(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:NDt(p),Type:bDt,Target:m}});const g=e[l],y=g?.declaration;e[l]=uN(FDt(ODt(g)||`{${wn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=uN(BDt(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function zDt(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}function UDt(e){const t=new Set;function n(r){if(Array.isArray(r))for(const i of r)!i||typeof i!="object"||(i.name==="w:numId"&&i.attributes?.["w:val"]!=null&&t.add(Number(i.attributes["w:val"])),i.elements&&n(i.elements))}for(const[r,i]of Object.entries(e))r.startsWith("word/")&&r!=="word/numbering.xml"&&i?.elements&&n(i.elements);return t}function VDt(e){const t=e.elements?.find(n=>n.name==="w:abstractNumId");if(t?.attributes?.["w:val"]!=null)return Number(t.attributes["w:val"])}function WDt(e,t){const n=Object.values(e.definitions).filter(i=>t.has(Number(i.attributes?.["w:numId"]))),r=new Set;for(const i of n){const o=VDt(i);o!=null&&r.add(o)}return{liveAbstracts:Object.values(e.abstracts).filter(i=>r.has(Number(i.attributes?.["w:abstractNumId"]))),liveDefinitions:n}}var GDt=md(Pv(),1),jDt=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),jwe="sans-serif",qDt=10,YDt="1.31.1",qwe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:i})=>{if(!e?.elements?.length||!i)return;const o=e.elements.find(l=>l.name==="w:rFonts");if(o?.attributes){const l=o.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!i.typeface)&&u.typeface&&(i.typeface=u.typeface),(t||!i.panose)&&u.panose&&(i.panose=u.panose)}const c=o.attributes["w:ascii"];(t||!i.typeface)&&c&&(i.typeface=c)}const s=e.elements.find(l=>l.name==="w:sz");if(s?.attributes?.["w:val"]){const l=Number(s.attributes["w:val"]);if(Number.isFinite(l)){i.fallbackSzTwips===void 0&&(i.fallbackSzTwips=l);const c=l/2;(n||i.fontSizePt===void 0)&&(i.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||i.kern===void 0)&&(i.kern=a.attributes["w:val"])},ju=class wo{static allowedElements=Object.freeze({"w:document":"doc","w:body":"body","w:p":"paragraph","w:r":"run","w:t":"text","w:delText":"text","w:br":"lineBreak","w:tbl":"table","w:tr":"tableRow","w:tc":"tableCell","w:drawing":"drawing","w:bookmarkStart":"bookmarkStart","w:sectPr":"sectionProperties","w:rPr":"runProperties","w:commentRangeStart":"commentRangeStart","w:commentRangeEnd":"commentRangeEnd","w:commentReference":"commentReference"});static markTypes=[{name:"w:b",type:"bold",property:"value"},{name:"w:i",type:"italic"},{name:"w:u",type:"underline",mark:"underline",property:"underlineType"},{name:"w:strike",type:"strike",mark:"strike",property:"value"},{name:"w:color",type:"color",mark:"textStyle",property:"color"},{name:"w:sz",type:"fontSize",mark:"textStyle",property:"fontSize"},{name:"w:rFonts",type:"fontFamily",mark:"textStyle",property:"fontFamily"},{name:"w:rStyle",type:"styleId",mark:"textStyle",property:"styleId"},{name:"w:jc",type:"textAlign",mark:"textStyle",property:"textAlign"},{name:"w:ind",type:"textIndent",mark:"textStyle",property:"textIndent"},{name:"w:spacing",type:"lineHeight",mark:"textStyle",property:"lineHeight"},{name:"w:spacing",type:"letterSpacing",mark:"textStyle",property:"letterSpacing"},{name:"link",type:"link",mark:"link",property:"href"},{name:"w:highlight",type:"highlight",mark:"highlight",property:"color"},{name:"w:shd",type:"highlight",mark:"highlight",property:"color"},{name:"w:caps",type:"textTransform",mark:"textStyle",property:"textTransform"}];static propertyTypes=Object.freeze({"w:pPr":"paragraphProperties","w:rPr":"runProperties","w:sectPr":"sectionProperties","w:numPr":"numberingProperties","w:tcPr":"tableCellProperties"});static elements=new Set(["w:document","w:body","w:p","w:r","w:t","w:delText"]);static getFontTableEntry(t,n){if(!t||!n)return null;const r=t["word/fontTable.xml"];if(!r?.elements?.length)return null;const i=r.elements.find(o=>o.name==="w:fonts");return i?.elements?.length&&i.elements.find(o=>o?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=wo.getFontTableEntry(t,n)?.elements?.find(i=>i.name==="w:family")?.attributes?.["w:val"];return r?jDt[r.toLowerCase()]||jwe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=wo.getFallbackFromFontTable(n,t)||jwe;return r.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(t.trim().toLowerCase())?r:`${t}, ${r}`}constructor(t=null){this.debug=t?.debug||!1,this.domEnvironment={mockWindow:t?.mockWindow||null,mockDocument:t?.mockDocument||null},this.declaration=null,this.documentAttributes=null,this.convertedXml={},this.docx=t?.docx||[],this.media=t?.media||{},this.fonts=t?.fonts||{},this.trackedChangesOptions=t?.trackedChangesOptions||null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=eV(),this.viewSetting=null,this.inlineDocumentFonts=[],this.commentThreadingProfile=null,this.exportWarnings=[],this.docHiglightColors=new Set([]),this.xml=t?.xml,this.declaration=null,this.numbering={},this.translatedNumbering={},this.numbering=null,this.pageStyles=null,this.themeColors=null,this.initialJSON=null,this.headers={},this.headerIds={default:null,even:null,odd:null,first:null},this.headerEditors=[],this.footers={},this.footerIds={default:null,even:null,odd:null,first:null},this.footerEditors=[],this.importedBodyHasHeaderRef=!1,this.importedBodyHasFooterRef=!1,this.headerFooterModified=!1,this.linkedStyles=[],this.translatedLinkedStyles={},this.json=t?.json,this.tagsNotInSchema=["w:body"],this.savedTagsToRestore=[],this.documentInternalId=null,this.fileSource=t?.fileSource||null,this.documentId=t?.documentId||null,this.documentGuid=null,this.documentUniqueIdentifier=null,this.documentModified=!1,this.isBlankDoc=t?.isNewFile||!1,(this.docx.length||this.xml)&&this.parseFromXml()}get docxHelpers(){return r1t}parseFromXml(){if(this.docx?.forEach(t=>{this.convertedXml[t.name]=this.parseXmlToJson(t.content),t.name==="word/document.xml"&&(this.documentAttributes=this.convertedXml[t.name].elements[0]?.attributes),t.name==="word/styles.xml"&&(this.convertedXml[t.name]=gbe(this.convertedXml[t.name]))}),!this.convertedXml["word/styles.xml"]){for(let t=1;t<=5;t+=1)if(this.convertedXml[`word/styles${t}.xml`]!=null){this.convertedXml["word/styles.xml"]=gbe(this.convertedXml[`word/styles${t}.xml`]);break}}this.initialJSON=this.convertedXml["word/document.xml"],this.initialJSON||(this.initialJSON=this.parseXmlToJson(this.xml)),this.declaration=this.initialJSON?.declaration,this.resolveDocumentGuid()}parseXmlToJson(t){const n=t.replace(/(<w:(?:t|delText)(?:\s[^>]*)?>)(\s+)(<\/w:(?:t|delText)>)/g,"$1[[sdspace]]$2[[sdspace]]$3");return JSON.parse(GDt.xml2json(n,null,2))}static _matchesElementName(t,n){return!t||typeof t!="string"||!n?!1:t===n?!0:t.endsWith(`:${n}`)?t.slice(0,-(n.length+1)).length>0:!1}static _extractNamespacePrefix(t){if(!t||typeof t!="string")return"";const n=t.indexOf(":");return n>0?t.slice(0,n):""}static getStoredCustomProperty(t,n){try{const r=t.find(l=>l.name==="docProps/custom.xml");if(!r)return null;const i=new wo,o=r.content,s=i.parseXmlToJson(o)?.elements?.find(l=>wo._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>wo._matchesElementName(l.name,"property")&&l.attributes?.name===n);return a?a.elements?.[0]?.elements?.[0]?.text?a.elements[0].elements[0].text:(console.warn(`Malformed property structure for "${n}"`),null):null}catch(r){return console.warn(`Error getting custom property ${n}:`,r),null}}static setStoredCustomProperty(t,n,r,i=!1){try{const o="docProps/custom.xml";t[o]||(t[o]=KDt());const s=t[o].elements?.find(d=>wo._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=wo._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>wo._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&i)return c.elements?.[0]?.elements?.[0]?.text?c.elements[0].elements[0].text:(console.warn(`Malformed existing property structure for "${n}"`),null);const u=typeof r=="function"?r():r;if(c)wo._extractNamespacePrefix(c.name)!==a&&(c.name=l),c.elements?.[0]?.elements?.[0]?c.elements[0].elements[0].text=u:(console.warn(`Malformed property structure for "${n}", recreating structure`),c.elements=[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]);else{const d=s.elements.filter(f=>f.attributes?.pid).map(f=>parseInt(f.attributes.pid,10)).filter(Number.isInteger);c={type:"element",name:l,attributes:{name:n,fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:d.length>0?Math.max(...d)+1:2},elements:[{type:"element",name:"vt:lpwstr",elements:[{type:"text",text:u}]}]},s.elements.push(c)}return u}catch(o){return console.warn(`Error setting custom property ${n}:`,o),null}}static getStoredSuperdocVersion(t){return wo.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=YDt){return wo.setStoredCustomProperty(t,"SuperdocVersion",n,!1)}static generateWordTimestamp(){const t=new Date;return t.setSeconds(0,0),t.toISOString().split(".")[0]+"Z"}getDocumentCreatedTimestamp(){const t=this.convertedXml["docProps/core.xml"];if(!t)return null;const n=t.elements?.find(r=>r.name==="cp:coreProperties"||wo._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||wo._matchesElementName(r.name,"created"))?.elements?.[0]?.text||null}setDocumentCreatedTimestamp(t){const n=this.convertedXml["docProps/core.xml"];if(!n)return;const r=n.elements?.find(o=>o.name==="cp:coreProperties"||wo._matchesElementName(o.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let i=r.elements.find(o=>o.name==="dcterms:created"||wo._matchesElementName(o.name,"created"));i?.elements?.[0]?i.elements[0].text=t:(i={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(i))}static extractDocumentGuid(t){try{const n=t.find(o=>o.name==="word/settings.xml");if(!n)return null;const r=new wo().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const i=r.elements?.find(o=>o.name==="w15:docId");if(i?.attributes?.["w15:val"])return i.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return wo.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?wo.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=wo.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(wo.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Vie(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`;try{let t;if(ArrayBuffer.isView(this.fileSource)){const n=this.fileSource;t=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}else if(this.fileSource instanceof ArrayBuffer)t=new Uint8Array(this.fileSource);else if(this.fileSource instanceof Blob||this.fileSource instanceof File){const n=await this.fileSource.arrayBuffer();t=new Uint8Array(n)}else return`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Vie(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${wn().replace(/-/g,"").substring(0,8).toUpperCase()}`}}async getDocumentIdentifier(){if(this.documentUniqueIdentifier)return this.documentUniqueIdentifier;const t=!!this.documentGuid,n=!!this.getDocumentCreatedTimestamp();return t&&n?this.documentUniqueIdentifier=this.#e():(t||(this.documentGuid=wn()),n||this.setDocumentCreatedTimestamp(wo.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||wn(),this.documentModified=!0,this.documentUniqueIdentifier=null,this.documentGuid)}getDocumentDefaultStyles(){const t=this.convertedXml["word/styles.xml"]?.elements?.[0]?.elements||[];if(!t.length)return{};const n=t.find(l=>l.name==="w:docDefaults"),r=t.find(l=>l.name==="w:style"&&l.attributes?.["w:styleId"]==="Normal"),i={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},o=n?.elements?.find(l=>l.name==="w:rPrDefault");qwe(o?.elements?.find(l=>l.name==="w:rPr")??o,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),qwe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:i}),i.fontSizePt===void 0&&(Number.isFinite(i.fallbackSzTwips)?i.fontSizePt=i.fallbackSzTwips/2:i.fontSizePt=qDt);const s=i.typeface?wo.toCssFontFamily(i.typeface,this.convertedXml):void 0,a={};return i.fontSizePt!==void 0&&(a.fontSizePt=i.fontSizePt),i.kern!==void 0&&(a.kern=i.kern),i.typeface&&(a.typeface=i.typeface),i.panose&&(a.panose=i.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,i=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,o=r||(i?i.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return o&&!f.includes(o)&&f.push(o),f},a=this.convertedXml["word/fontTable.xml"];if(!a)return s(t);const l=a.elements?.find(d=>d.name==="w:fonts");if(!l||!l.elements)return s(t);const c=l.elements.filter(d=>d.name==="w:font").map(d=>d.attributes["w:name"]),u=[...t,...c];return s([...new Set(u)])}getFontFaceImportString(){const t=this.convertedXml["word/fontTable.xml"];if(!t||!Object.keys(this.fonts).length)return;const n=t.elements.find(s=>s.name==="w:fonts")?.elements.filter(s=>s.elements?.some(a=>a?.attributes&&a.attributes["r:id"]&&a.attributes["w:fontKey"]))?.reduce((s,a)=>{const l=a.elements.filter(c=>c.name.startsWith("w:embed"))?.map(c=>({...c,fontFamily:a.attributes["w:name"]}));return[...s,...l]},[]),{elements:r}=this.convertedXml["word/_rels/fontTable.xml.rels"]?.elements.find(s=>s.name==="Relationships")||{},i=[];let o="";for(const s of n){const a=r.find(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=fKe(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";i.includes(s.fontFamily)||i.push(s.fontFamily),o+=`
90
90
  @font-face {
91
91
  font-style: ${p?"italic":"normal"};
92
92
  font-weight: ${g};
@@ -319,7 +319,7 @@ function print() { __p += __j.call(arguments, '') }
319
319
  `;const vl={undo:RGt,redo:PGt,bold:gGt,italic:yGt,underline:bGt,color:OGt,link:iG,image:SGt,alignLeft:xGt,alignRight:IGt,alignCenter:TGt,alignJustify:kGt,bulletList:rEe,bulletListDisc:rEe,bulletListCircle:vGt,bulletListSquare:wGt,numberedList:AGt,indentLeft:CGt,indentRight:EGt,pageBreak:FGt,copyFormat:iEe,clearFormatting:_Gt,trackChanges:MGt,trackChangesFinal:DGt,trackChangesOriginal:sEe,trackChangesAccept:LGt,trackChangesReject:NGt,documentMode:oEe,documentEditingMode:oEe,documentSuggestingMode:aEe,documentViewingMode:sEe,colorOption:BGt,colorOptionCheck:AM,linkInput:iG,removeLink:oG,openLink:HGt,overflow:lEe,dropdownCaretUp:zGt,dropdownCaretDown:cEe,ruler:UGt,paintbrush:VGt,highlight:WGt,ai:uEe,table:dEe,tableActions:GGt,splitCell:fEe,mergeCells:hEe,addRowBefore:Ep,addRowAfter:Ep,addColumnBefore:Ep,addColumnAfter:Ep,deleteRow:$y,deleteColumn:$y,deleteTable:$y,deleteBorders:mEe,fixTables:pEe,lineHeight:jGt,search:qGt,cut:gEe,copy:yEe,paste:bEe,strikethrough:YGt};en(),Wn();var KGt=["onClick","innerHTML","aria-label","onKeydown"],XGt={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=kp(),r=t,i=Me([]),o=[{key:"left",ariaLabel:"Align left",icon:vl.alignLeft},{key:"center",ariaLabel:"Align center",icon:vl.alignCenter},{key:"right",ariaLabel:"Align right",icon:vl.alignRight},{key:"justify",ariaLabel:"Justify",icon:vl.alignJustify}],s=u=>{r("select",u)},a=u=>{if(u===i.value.length-1)return;const d=i.value[u+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=u=>{if(u===0)return;const d=i.value[u-1];d&&(d.setAttribute("tabindex","0"),d.focus())},c=(u,d)=>{switch(u.key){case"ArrowLeft":l(d);break;case"ArrowRight":a(d);break;case"Enter":s(o[d].key);break;default:break}};return Si(()=>{const u=i.value[0];u&&(u.setAttribute("tabindex","0"),u.focus())}),(u,d)=>(ze(),Ze("div",{class:wr(["alignment-buttons",{"high-contrast":Et(n)}])},[(ze(),Ze(Cn,null,gi(o,(f,h)=>ut("div",{key:f.key,class:"button-icon",onClick:p=>s(f.key),innerHTML:f.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":f.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:i,onKeydown:Jn(p=>c(p,h),["prevent"])},null,40,KGt)),64))],2))}},JGt=Hn(XGt,[["__scopeId","data-v-3f7f0d98"]]);en(),Wn();var ZGt=["onClick","innerHTML","aria-label","onKeydown"],QGt={__name:"BulletStyleButtons",props:{selectedStyle:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=kp(),r=t,i=e,o=Me([]),s=[{key:"disc",icon:vl.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:vl.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:vl.bulletListSquare,ariaLabel:"Opaque square"}],a=d=>{r("select",d)},l=d=>{if(d===o.value.length-1)return;const f=o.value[d+1];f&&(f.setAttribute("tabindex","0"),f.focus())},c=d=>{if(d===0)return;const f=o.value[d-1];f&&(f.setAttribute("tabindex","0"),f.focus())},u=(d,f)=>{switch(d.key){case"ArrowLeft":c(f);break;case"ArrowRight":l(f);break;case"Enter":a(s[f].key);break;default:break}};return Si(()=>{const d=o.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,f)=>(ze(),Ze("div",{class:wr(["bullet-style-buttons",{"high-contrast":Et(n)}])},[(ze(),Ze(Cn,null,gi(s,(h,p)=>ut("div",{key:h.key,class:wr(["button-icon",{selected:i.selectedStyle===h.key}]),onClick:m=>a(h.key),innerHTML:h.icon,role:"menuitem","aria-label":h.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:o,onKeydown:Jn(m=>u(m,p),["prevent"])},null,42,ZGt)),64))],2))}},$Gt=Hn(QGt,[["__scopeId","data-v-e1b3c81e"]]);en(),Wn();var ejt=["onClick","onKeydown"],tjt={class:"document-mode-column icon-column"},njt=["innerHTML"],rjt={class:"document-mode-column text-column"},ijt={class:"document-mode-type"},ojt={class:"document-mode-description"},sjt={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=Me([]),{isHighContrastMode:i}=kp(),o=e,s=u=>{n("select",u)},a=u=>{if(u===r.value.length-1)return;const d=r.value[u+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=u=>{if(u===0)return;const d=r.value[u-1];d&&(d.setAttribute("tabindex","0"),d.focus())},c=(u,d)=>{switch(u.key){case"ArrowDown":a(d);break;case"ArrowUp":l(d);break;case"Enter":s(o.options[d]);break;default:break}};return Si(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(u,d)=>(ze(),Ze("div",{class:wr(["document-mode",{"high-contrast":Et(i)}])},[(ze(!0),Ze(Cn,null,gi(e.options,(f,h)=>(ze(),Ze("div",{class:wr(["option-item",{disabled:f.disabled}]),onClick:p=>s(f),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:Jn(p=>c(p,h),["prevent"])},[ut("div",tjt,[ut("div",{class:"icon-column__icon",innerHTML:f.icon},null,8,njt)]),ut("div",rjt,[ut("div",ijt,Xn(f.label),1),ut("div",ojt,Xn(f.description),1)])],42,ejt))),256))],2))}},ajt=Hn(sjt,[["__scopeId","data-v-8587478e"]]);en(),Wn();var ljt={key:0,class:"linked-style-buttons","data-editor-ui-surface":""},cjt=["onClick","onKeydown","aria-label"],ujt={__name:"LinkedStyle",props:{editor:{type:Object,required:!0},selectedOption:{type:String}},emits:["select"],setup(e,{emit:t}){const n=t,r=Me([]),i=e,o=c=>{n("select",c)},s=c=>{if(c===r.value.length-1)return;const u=r.value[c+1];u.setAttribute("tabindex","0"),u.focus()},a=c=>{if(c===0)return;const u=r.value[c-1];u.setAttribute("tabindex","0"),u.focus()},l=(c,u,d)=>{switch(c.key){case"ArrowDown":s(u);break;case"ArrowUp":a(u);break;case"Enter":c.preventDefault(),o(d);break;default:break}};return Si(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,u)=>i.editor?(ze(),Ze("div",ljt,[(ze(!0),Ze(Cn,null,gi(Et($V)(e.editor),(d,f)=>(ze(),Ze("div",{class:wr(["style-item",{selected:e.selectedOption===d.id}]),onClick:h=>o(d),onKeydown:h=>l(h,f,d),"aria-label":`Linked style - ${d.id}`,ref_for:!0,ref_key:"styleRefs",ref:r},[ut("div",{class:"style-name",style:Dn(Et(eW)(d,null,null,!1)),"data-item":"btn-linkedStyles-option"},Xn(d.definition.attrs.name),5)],42,cjt))),256))])):Bt("",!0)}},djt=Hn(ujt,[["__scopeId","data-v-80e74746"]]);en(),Wn();var fjt={key:0,class:"link-title"},hjt={key:1,class:"link-title"},pjt={key:2,class:"link-title"},mjt={key:3,class:"link-title"},gjt={key:4,class:"link-input-wrapper"},yjt={class:"input-row text-input-row"},bjt=["readonly"],vjt={class:"input-row url-input-row"},wjt=["innerHTML"],Ajt=["readonly","onKeydown"],Sjt=["innerHTML"],xjt={key:0,class:"input-row link-buttons"},Tjt=["innerHTML"],Ijt={key:5,class:"input-row go-to-anchor clickable"},kjt={__name:"LinkInput",props:{showInput:{type:Boolean,default:!0},showLink:{type:Boolean,default:!0},goToAnchor:{type:Function,default:()=>{}},editor:{type:Object,required:!0},closePopover:{type:Function,default:()=>{}}},setup(e){const t=e,{isHighContrastMode:n}=kp(),r=Me(!1),i=()=>{if(!t.editor||!t.editor.state)return"";const{state:S}=t.editor,{selection:T}=S,k=S.schema.marks.link;if(T.empty){const P=tp(T.$from,k);return P?S.doc.textBetween(P.from,P.to," "):""}const C=tp(T.$from,k),_=tp(T.$to,k);if(C||_){const P=C||_;return S.doc.textBetween(P.from,P.to," ")}return S.doc.textBetween(T.from,T.to," ")},o=()=>{if(!t.editor||!t.editor.state)return"";const{state:S}=t.editor,{schema:T,selection:k}=S,C=T.marks.link;if(!C)return"";let _="";const{$from:P,empty:E}=k;if(E){let L=(S.storedMarks||P.marks()).find(R=>R.type===C);if(!L){const R=P.nodeAfter,O=P.nodeBefore,F=R&&Array.isArray(R.marks)?R.marks:[],B=O&&Array.isArray(O.marks)?O.marks:[];L=F.find(j=>j.type===C)||B.find(j=>j.type===C)}L&&L.attrs&&L.attrs.href&&(_=L.attrs.href)}else S.doc.nodesBetween(k.from,k.to,L=>{if(L.marks){const R=L.marks.find(O=>O.type===C);R&&R.attrs&&R.attrs.href&&(_=R.attrs.href)}});return _||""},s=Me(""),a=Me(""),l=Me(!1),c=/^[a-z][a-z0-9+.-]*:/i,u=ct(()=>a.value?a.value.startsWith("#")||c.test(a.value)?a.value:"https://"+a.value:""),d=ct(()=>u.value?zu(u.value):null),f=ct(()=>d.value!==null),h=ct(()=>!l.value&&!!o()),p=ct(()=>!f.value),m=ct(()=>t.editor?.options?.documentMode==="viewing"),g=()=>{const S=d.value?.href;S&&window.open(S,"_blank")},y=()=>{s.value=i(),a.value=o()};Vn(()=>t.editor?.state?.selection,()=>{y()},{immediate:!0});const v=()=>{const S=document.querySelector(".link-input-ctn input");S&&S.focus()};Si(()=>{y(),l.value=a.value.startsWith("#"),t.showInput&&v()});const b=()=>{if(m.value)return;const S=t.editor;if(!S)return;if(!a.value){S.commands?.unsetLink&&S.commands.unsetLink(),t.closePopover();return}if(!f.value){r.value=!0;return}const T=d.value?.href;if(!T){r.value=!0;return}const k=s.value||T;S.commands?.toggleLink&&S.commands.toggleLink({href:T,text:k});const C=S.view.state.selection.$to.pos;S.view.dispatch(S.view.state.tr.setSelection(new It(S.view.state.doc.resolve(C)))),setTimeout(()=>S.view.focus(),100),t.closePopover()},w=()=>{t.editor&&t.editor.commands&&t.editor.commands.unsetLink&&(t.editor.commands.unsetLink(),t.closePopover())},x=S=>{const T=t.editor?.presentationEditor??null;T?T.goToAnchor(S):t.goToAnchor&&t.goToAnchor(S)};return(S,T)=>(ze(),Ze("div",{class:wr(["link-input-ctn",{"high-contrast":Et(n)}])},[l.value?(ze(),Ze("div",fjt,"Page anchor")):m.value?(ze(),Ze("div",hjt,"Link details")):h.value?(ze(),Ze("div",pjt,"Edit link")):(ze(),Ze("div",mjt,"Add link")),e.showInput&&!l.value?(ze(),Ze("div",gjt,[ut("div",yjt,[T[5]||(T[5]=ut("div",{class:"input-icon text-input-icon"},"T",-1)),vd(ut("input",{type:"text",name:"text",placeholder:"Text","onUpdate:modelValue":T[0]||(T[0]=k=>s.value=k),readonly:m.value,onKeydown:T[1]||(T[1]=Af(Jn(k=>!m.value&&b,["stop","prevent"]),["enter"]))},null,40,bjt),[[Bh,s.value]])]),ut("div",vjt,[ut("div",{class:"input-icon",innerHTML:Et(vl).linkInput},null,8,wjt),vd(ut("input",{type:"text",name:"link",placeholder:"Type or paste a link",class:wr({error:r.value}),"onUpdate:modelValue":T[2]||(T[2]=k=>a.value=k),readonly:m.value,onKeydown:[Af(Jn(b,["stop","prevent"]),["enter"]),T[3]||(T[3]=k=>r.value=!1)]},null,42,Ajt),[[Bh,a.value]]),ut("div",{class:wr(["open-link-icon",{disabled:!f.value}]),innerHTML:Et(vl).openLink,onClick:g,"data-item":"btn-link-open"},null,10,Sjt)]),m.value?Bt("",!0):(ze(),Ze("div",xjt,[h.value?(ze(),Ze("button",{key:0,class:"remove-btn",onClick:w,"data-item":"btn-link-remove"},[ut("div",{class:"remove-btn__icon",innerHTML:Et(vl).removeLink},null,8,Tjt),T[6]||(T[6]=E0(" Remove ",-1))])):Bt("",!0),ut("button",{class:wr(["submit-btn",{"disable-btn":p.value}]),onClick:b,"data-item":"btn-link-apply"}," Apply ",2)]))])):l.value?(ze(),Ze("div",Ijt,[ut("a",{onClick:T[4]||(T[4]=Jn(k=>x(a.value),["stop","prevent"]))},"Go to "+Xn(a.value.startsWith("#_")?a.value.substring(2):a.value),1)])):Bt("",!0)],2))}},jk=Hn(kjt,[["__scopeId","data-v-56a53c8c"]]);en(),Wn();var Ejt=["aria-label","onClick","onKeydown"],Cjt=["innerHTML"],_jt=["innerHTML"],SM=7,Rjt={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,i=ct(()=>p=>r.activeColor.value?r.activeColor.value.toUpperCase()===p.value:!1),o=(p,m)=>m===5||["#FFFFFF","#FAFF09"].includes(p)?{color:"#000"}:{color:"#FFF"},s=p=>{n("select",p.value)},a=Me([]),l=Me([]);Si(()=>{if(!r.icons.every(m=>Array.isArray(m)))throw new Error("icon props must be 2d array");const p=l.value[0];p&&(p.setAttribute("tabindex","0"),p.focus())});const c=(p,m)=>{const g=SM*p+m+1,y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},u=(p,m)=>{const g=SM*p+m-1,y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},d=(p,m)=>{const g=m+SM*(p+1),y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},f=(p,m)=>{const g=m+SM*(p-1),y=l.value[g];y&&(y.setAttribute("tabindex","0"),y.focus())},h=(p,m,g,y)=>{switch(p.key){case"ArrowRight":c(m,g);break;case"ArrowLeft":u(m,g);break;case"ArrowDown":d(m,g);break;case"ArrowUp":f(m,g);break;case"Enter":s(y);break;case"Escape":n("clickoutside");break;default:break}};return(p,m)=>(ze(!0),Ze(Cn,null,gi(e.icons,(g,y)=>(ze(),Ze("div",{class:"option-row",key:y,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(ze(!0),Ze(Cn,null,gi(g,(v,b)=>(ze(),Ze("div",{class:"option",key:b,"aria-label":v.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:Jn(w=>s(v),["stop","prevent"]),onKeydown:Jn(w=>h(w,y,b,v),["prevent"])},[ut("div",{class:"option__icon",innerHTML:v.icon,style:Dn(v.style)},null,12,Cjt),i.value(v)?(ze(),Ze("div",{key:0,class:"option__check",innerHTML:Et(vl).colorOptionCheck,style:Dn(o(v.value,b))},null,12,_jt)):Bt("",!0)],40,Ejt))),128))]))),128))}},vEe=Hn(Rjt,[["__scopeId","data-v-59855ce7"]]),Pjt=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
320
320
  `;en(),Wn();var Ljt={class:"options-grid-wrap"},Njt=["innerHTML"],Mjt={class:"option-grid-ctn"},Djt={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=i=>{n("select",i)};return(i,o)=>(ze(),Ze("div",Ljt,[e.hasNoneIcon?(ze(),Ze("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:o[0]||(o[0]=s=>r("none"))},[ut("span",{innerHTML:Et(Pjt),class:"none-icon"},null,8,Njt),o[1]||(o[1]=E0(" None ",-1))])):Bt("",!0),ut("div",Mjt,[Ar(vEe,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(ze(),Ze(Cn,{key:0},[o[2]||(o[2]=ut("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),Ar(vEe,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):Bt("",!0)])]))}},wEe=Hn(Djt,[["__scopeId","data-v-b243fab8"]]);en();var Ojt=e=>{e.expand.value=!1};const zn=(e,t=null)=>({label:t,icon:vl.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),sG=(e,t,n=[],r=!1)=>{const i=o=>{t.iconColor.value=o,e.emitCommand({item:t,argument:o}),Ojt(t)};return Ks("div",{},[Ks(wEe,{icons:aG,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:i})])},aG=[[zn("#111111","black"),zn("#333333","dark gray"),zn("#5C5C5C","medium gray"),zn("#858585","light gray"),zn("#ADADAD","very light gray"),zn("#D6D6D6","transparent gray"),zn("#FFFFFF","white")],[zn("#860028","dark red"),zn("#D2003F","red"),zn("#DB3365","coral red"),zn("#E4668C","light red"),zn("#ED99B2","pale pink"),zn("#F6CCD9","transparent pink"),zn("#FF004D","bright pink")],[zn("#83015E","dark purple"),zn("#CD0194","purple"),zn("#D734A9","orchid"),zn("#E167BF","light purple"),zn("#EB99D4","lavender"),zn("#F5CCEA","transparent pink"),zn("#FF00A8","neon pink")],[zn("#8E220A","maroon"),zn("#DD340F","red-orange"),zn("#E45C3F","burnt orange"),zn("#EB856F","peach"),zn("#F1AE9F","pale peach"),zn("#F8D6CF","transparent peach"),zn("#FF7A00","orange")],[zn("#947D02","olive"),zn("#E7C302","mustard yellow"),zn("#ECCF35","yellow"),zn("#F1DB67","light yellow"),zn("#F5E79A","very pale yellow"),zn("#FAF3CC","transparent yellow"),zn("#FAFF09","neon yellow")],[zn("#055432","forest green"),zn("#07834F","green"),zn("#399C72","medium green"),zn("#6AB595","light green"),zn("#9CCDB9","mint"),zn("#CDE6DC","transparent mint"),zn("#05F38F","bright teal")],[zn("#063E7E","navy blue"),zn("#0A60C5","blue"),zn("#3B80D1","sky blue"),zn("#6CA0DC","cornflower blue"),zn("#9DBFE8","light blue"),zn("#CEDFF3","very light blue"),zn("#21c8ce","cyan")],[zn("#3E027A","deep purple"),zn("#6103BF","indigo"),zn("#8136CC","violet"),zn("#A068D9","lavender pink"),zn("#C09AE6","light lilac"),zn("#DFCDF2","transparent lilac"),zn("#A91DFF","neon purple")]],Fjt=()=>aG.flat().map(e=>e.value);en(),Wn();var Bjt=["data-cols","data-rows","onKeydown","onClick"],Hjt=["aria-valuetext"],xM=5,zjt={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=Me(0),i=Me(0),{isHighContrastMode:o}=kp(),s=Me([]),a=d=>{let f=d.target;f.dataset.grid||l([...f.parentElement.querySelectorAll("[data-item]")],parseInt(f.dataset.cols,10),parseInt(f.dataset.rows,10))},l=(d,f,h)=>{i.value=f,r.value=h;for(let p=0;p<d.length;p++){let m=d[p],g=parseInt(m.dataset.cols,10),y=parseInt(m.dataset.rows,10);g<=f&&y<=h?m.classList.add("selected"):m.classList.remove("selected")}},c=({cols:d,rows:f})=>{n("select",{cols:d,rows:f})},u=(d,f,h)=>{let p=f-1,m=h-1;switch(d.key){case"ArrowRight":{if(p>=4)return;const g=m*xM;s.value[g+p+1].setAttribute("tabindex","0"),s.value[g+p+1].focus(),l(s.value,f+1,h);break}case"ArrowLeft":{if(p<=0)return;const g=m*xM;s.value[g+p-1].setAttribute("tabindex","0"),s.value[g+p-1].focus(),l(s.value,f-1,h);break}case"ArrowDown":{if(m>=4)return;const g=(m+1)*xM;s.value[g+p].setAttribute("tabindex","0"),s.value[g+p].focus(),l(s.value,f,h+1);break}case"ArrowUp":{if(m<=0)return;const g=(m-1)*xM;s.value[g+p].setAttribute("tabindex","0"),s.value[g+p].focus(),l(s.value,f,h-1);break}case"Enter":c({cols:f,rows:h});break;default:break}};return Si(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(d,f)=>(ze(),Ze("div",{class:wr(["toolbar-table-grid-wrapper",{"high-contrast":Et(o)}])},[ut("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(ze(),Ze(Cn,null,gi(5,h=>(ze(),Ze(Cn,{key:h},[(ze(),Ze(Cn,null,gi(5,p=>ut("div",{class:"toolbar-table-grid__item",key:`${h}_${p}`,"data-cols":p,"data-rows":h,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:Jn(m=>u(m,p,h),["prevent"]),onClick:Jn(m=>c({cols:p,rows:h}),["stop","prevent"])},null,40,Bjt)),64))],64))),64))],32),ut("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${i.value}`},Xn(r.value)+" x "+Xn(i.value),9,Hjt)],2))}},AEe=Hn(zjt,[["__scopeId","data-v-5cefb109"]]);en(),Wn();var Ujt={class:"toolbar-table-actions"},Vjt=["onClick","data-item","ariaLabel"],Wjt={class:"toolbar-table-actions__icon"},Gjt=["innerHTML"],jjt={class:"toolbar-table-actions__label"},qjt={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=i=>{n("select",{command:i.command})};return(i,o)=>(ze(),Ze("div",Ujt,[(ze(!0),Ze(Cn,null,gi(e.options,s=>(ze(),Ze("div",{class:wr(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[ut("div",Wjt,[ut("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,Gjt)]),ut("div",jjt,Xn(s.label),1)],10,Vjt))),256))]))}},SEe=Hn(qjt,[["__scopeId","data-v-652015c8"]]);function Yjt(e){let t=e;for(;t;){const n=window.getComputedStyle(t).overflowY;if(/(auto|scroll)/.test(n)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return document.scrollingElement||document.documentElement}function Kjt(e,t={behavior:"smooth",block:"start"}){if(!e)return;const n=Yjt(e),r=n.getBoundingClientRect(),i=e.getBoundingClientRect().top-r.top+n.scrollTop;n.scrollTo({top:t.block==="start"?i:i-n.clientHeight+e.offsetHeight,behavior:t.behavior})}var Xjt=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
321
321
  `;en(),Wn();var Jjt={class:"search-input-ctn"},Zjt={class:"row"},Qjt=["onKeydown"],$jt={__name:"SearchInput",props:{searchRef:{type:Object}},emits:["submit"],setup(e,{emit:t}){const n=Me(""),r=t,i=()=>{r("submit",{value:n.value})};return(o,s)=>(ze(),Ze("div",Jjt,[ut("div",Zjt,[vd(ut("input",{ref:e.searchRef,"onUpdate:modelValue":s[0]||(s[0]=a=>n.value=a),class:"search-input",type:"text",name:"search",placeholder:"Type search string",onKeydown:Af(Jn(i,["stop","prevent"]),["enter"])},null,40,Qjt),[[Bh,n.value]])]),ut("div",{class:"row submit"},[ut("button",{class:"submit-btn",onClick:i},"Apply")])]))}},eqt=Hn($jt,[["__scopeId","data-v-bfe34b7b"]]);const tqt=[{label:"Georgia",key:"Georgia, serif",fontWeight:400,props:{style:{fontFamily:"Georgia, serif"},"data-item":"btn-fontFamily-option"}},{label:"Arial",key:"Arial, sans-serif",fontWeight:400,props:{style:{fontFamily:"Arial, sans-serif"},"data-item":"btn-fontFamily-option"}},{label:"Courier New",key:"Courier New, monospace",fontWeight:400,props:{style:{fontFamily:"Courier New, monospace"},"data-item":"btn-fontFamily-option"}},{label:"Times New Roman",key:"Times New Roman, serif",fontWeight:400,props:{style:{fontFamily:"Times New Roman, serif"},"data-item":"btn-fontFamily-option"}}],nqt=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],qk={sm:768,md:1024,lg:1280,xl:1410},TM={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",zoom:"zoom",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",clearFormatting:"clear-formatting",copyFormat:"copy-format"},xEe={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},TEe=Object.values(xEe),rqt=[...new Set([...Object.values(TM),...TEe])];var iqt=new Set(["link"]);const IEe=new Set(Object.keys(TM).filter(e=>!iqt.has(e)));en();var Cp=e=>{e.expand.value=!1};const oqt=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:i,availableWidth:o,role:s,isDev:a=!1}={})=>{const l=Ii({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??tqt).map(tGt),u=Ii({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:c,onActivate:({fontFamily:ge})=>{if(!ge)return;ge=ge.split(",")[0],u.label.value=ge;const pe=c.find(oe=>oe.label===u.defaultLabel.value),we=c.find(oe=>oe.label===ge);we?u.selectedValue.value=we.key:pe?u.selectedValue.value=pe.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const ge=c.find(pe=>pe.label===u.defaultLabel.value);ge?u.selectedValue.value=ge.key:u.selectedValue.value=""}}),d=Ii({type:"dropdown",dropdownStyles:{padding:0,outline:"none"},name:"ai",tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>{let ge="";if(e.activeEditor){const{state:we}=e.activeEditor,{from:oe,to:je,empty:Y}=we.selection;ge=Y?"":we.doc.textBetween(oe,je)}return Ks("div",{},[Ks(wM,{handleClose:()=>{Cp(d)},selectedText:ge,editor:e.activeEditor,apiKey:e.config.aiApiKey,endpoint:e.config.aiEndpoint,superToolbar:e})])}}]}),f=nqt,h=Ii({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",minWidth:"50px",markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:f,onActivate:({fontSize:ge},pe=!1)=>{if(pe){h.label.value="",h.selectedValue.value="";return}const we=f.find(Te=>Te.label===String(h.defaultLabel.value));if(!ge){h.label.value=h.defaultLabel.value,we?h.selectedValue.value=we.key:h.selectedValue.value="";return}let oe=$Wt(ge,12);oe<8&&(oe=8),oe>96&&(oe=96);let je=String(oe);const Y=f.find(Te=>Te.label===je||Te.key===je);Y?h.selectedValue.value=Y.key:h.selectedValue.value="",h.label.value=je},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const ge=f.find(pe=>pe.label===String(h.defaultLabel.value));ge?h.selectedValue.value=ge.key:h.selectedValue.value=""}}),p=Ii({type:"separator",name:"separator",isNarrow:!0}),m=Ii({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),g=Ii({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),y=Ii({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),v=Ii({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>sG(e,v,[],!0)}],onActivate:({color:ge})=>{v.iconColor.value=ge||""},onDeactivate:()=>v.iconColor.value=""}),b=Ii({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>sG(e,b)}],onActivate:({color:ge})=>{b.iconColor.value=ge},onDeactivate:()=>b.iconColor.value="#000"}),w=Me(null),x=Ii({type:"dropdown",name:"search",active:!1,icon:t.search,tooltip:n.search,group:"right",inputRef:w,attributes:{ariaLabel:"Search"},options:[{type:"render",key:"searchDropdown",render:()=>S()}]}),S=()=>Ks("div",{},[Ks(eqt,{onSubmit:({value:pe})=>{e.activeEditor.commands.search(pe,{searchModel:"visible"})},searchRef:w})]),T=Ii({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>k(T)}],onActivate:({href:ge})=>{ge?T.attributes.value={href:ge}:T.attributes.value={}},onDeactivate:()=>{T.attributes.value={},T.expand.value=!1}});function k(ge){return Ks("div",{},[Ks(jk,{editor:e.activeEditor,closePopover:()=>Cp(ge),goToAnchor:()=>{if(Cp(ge),!e.activeEditor||!ge.attributes.value?.href)return;const pe=ge.attributes.value?.href?.slice(1),we=e.activeEditor.element.querySelector(`a[name='${pe}']`);we&&Kjt(we)}})])}const C=Ii({type:"options",name:"linkInput",command:"toggleLink",active:!1});T.childItem=C,C.parentItem=T;const _=Ii({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),P=Ii({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>E(P)}]});function E(ge){return Ks("div",{},[Ks(AEe,{onSelect:we=>{e.emitCommand({item:ge,argument:we}),Cp(ge)}})])}const L=Ii({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>O(L)}]}),R=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function O(ge){return Ks(SEe,{options:R,onSelect:pe=>{Cp(ge);const{command:we}=pe;e.emitCommand({item:ge,argument:{command:we}})}})}const F=Ii({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Ks("div",{},[Ks(JGt,{onSelect:pe=>{Cp(F);const we={...F,command:"setTextAlign"};we.command="setTextAlign",e.emitCommand({item:we,argument:pe}),B(F,pe)}})]),key:"alignment"}],onActivate:({textAlign:ge})=>{B(F,ge)},onDeactivate:()=>{B(F,"left")}}),B=(ge,pe)=>{let we=pe==="both"?"justify":pe,oe={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},je=oe[we]??oe.left;ge.icon.value=je},j=Ii({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const ge=pe=>{Cp(j);const we={...j,command:"toggleBulletListStyle"};e.emitCommand({item:we,argument:pe})};return Ks($Gt,{selectedStyle:j.selectedValue.value,onSelect:ge})}}]}),M=Ii({type:"button",name:"numberedlist",command:"toggleOrderedList",icon:t.numberedList,active:!1,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"}}),z=Ii({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),$=Ii({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),K=Ii({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),U=Ii({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:ge})=>{ge&&(U.label.value=ge)}}),fe=Ii({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),ee=Ii({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Z=Ii({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),re=Ii({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),ve=Ii({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),J=Ii({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),ke=(ge,pe)=>ge==="editor"?pe:ge==="suggester"?pe.filter(we=>we.value==="suggesting"):pe.filter(we=>we.value==="viewing"),Ae=ge=>ge==="editor"?"Editing":ge==="suggester"?"Suggesting":"Viewing",G=Ii({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Ae(s),label:Ae(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>N(G)}]}),D=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function N(ge){return Ks(ajt,{options:ke(s,D),onSelect:pe=>{Cp(ge);const{label:we,icon:oe}=pe;G.label.value=we,G.icon.value=oe,e.emitCommand({item:G,argument:we})}})}const X=new Map([["separator",20],["zoom",71],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["ai",32],["default",32]]),ce=Ii({type:"button",name:"ruler",command:"toggleRuler",icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),te=Me(null),ie=Ii({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const ge=pe=>{Cp(ie);const we={...ie,command:"setLinkedStyle"};e.emitCommand({item:we,argument:pe}),te.value=pe.id};return Ks("div",{},[Ks(djt,{editor:e.activeEditor,onSelect:ge,selectedOption:te.value})])}}],onActivate:({styleId:ge})=>{const pe=$V(e.activeEditor)?.find(we=>we.id===ge);ie.label.value=pe&&pe.id!=="Normal"?pe.definition.attrs.name:n.formatText,ie.disabled.value=!1},onDeactivate:()=>{ie.disabled.value=!0,ie.label.value=n.formatText}}),q=(ge,pe)=>{if(pe.value==ge)return Ks("div",{innerHTML:Xjt,class:"dropdown-select-icon"})},Q=Ii({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(ge=>({label:ge.toFixed(2),key:ge,icon:()=>q(ge,Q.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),le=20,se=120,me=32,Se=["linkedStyles","clearFormatting","copyFormat","ruler"],Ee=["zoom","fontFamily","fontSize","redo"],be=o<=qk.lg;be&&(G.attributes.value={...G.attributes.value,className:`${G.attributes.value.className} toolbar-item--doc-mode-compact`}),be&&(ie.attributes.value={...ie.attributes.value,className:`${ie.attributes.value.className} toolbar-item--linked-styles-compact`});let ue=[fe,ee,Z,re,U,u,p,h,p,l,m,g,y,b,v,p,T,_,P,L,p,F,j,M,z,$,Q,p,ie,p,ce,J,ve,d,K,G];if(e.config?.superdoc?.config?.modules?.ai||(ue=ue.filter(ge=>ge.name.value!=="ai")),o<=qk.md&&i&&(ue=ue.filter(ge=>ge.type!=="separator")),e.config.mode!=="docx"){const ge=ue.findIndex(we=>we.name.value==="linkedStyles");ue.splice(ge-1,2);const pe=["ruler","zoom","undo","redo"];ue=ue.filter(we=>!pe.includes(we.name.value))}const Ie=[];a||(s==="viewer"&&Ie.push(Z,re),ue=ue.filter(ge=>!Ie.includes(ge)));const Le=[x,fe,K,G].map(ge=>ge.name),Xe=ge=>Le.includes(ge.name),nt=[],he=[];let xe=me+se;return ue.forEach(ge=>{const pe=X.get(ge.name.value)||X.get("default");if(o<qk.xl+le&&Se.includes(ge.name.value)&&i){if(nt.push(ge),ge.name.value==="linkedStyles"){const we=ue.findIndex(oe=>oe.name.value==="linkedStyles");ue.splice(we+1,1)}return}if(o<qk.sm&&Ee.includes(ge.name.value)&&i){nt.push(ge);return}if(Xe(ge)){he.push(ge),xe+=pe;return}xe<o||!i?(he.push(ge),xe+=pe):nt.push(ge)}),{defaultItems:he,overflowItems:nt.filter(ge=>ge.type!=="separator")}};en(),Wn();var sqt={class:"toolbar-icon"},aqt=["innerHTML"],lqt={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ct(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ct(()=>["color","highlight"].includes(t.name));return(i,o)=>(ze(),Ze("div",sqt,[ut("div",{class:wr(["toolbar-icon__icon",[`toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,aqt),r.value?(ze(),Ze("div",{key:0,class:"color-bar",style:Dn(n.value)},null,4)):Bt("",!0)]))}},kEe=Hn(lqt,[["__scopeId","data-v-8c30c125"]]);en(),Wn();var cqt=["role","aria-label"],uqt=["data-item"],dqt=["data-item"],fqt={key:1,class:"button-label"},hqt=["data-item","aria-label"],pqt=["innerHTML"],mqt={key:1,class:"button-label"},gqt={key:2},yqt=["onKeydown","id"],bqt=["placeholder","onKeydown","id"],vqt=["innerHTML"],wqt={"aria-live":"polite",class:"visually-hidden"},Aqt={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,r=e,{name:i,active:o,icon:s,label:a,hideLabel:l,iconColor:c,hasCaret:u,splitButton:d,disabled:f,inlineTextInputVisible:h,hasInlineTextInput:p,minWidth:m,style:g,attributes:y}=r.toolbarItem,v=ct(()=>!!d?.value&&!!u?.value),b=Me(a),w=Me(null),{isHighContrastMode:x}=kp(),S=()=>{p&&er(()=>{w.value?.focus(),w.value?.select()}),n("buttonClick")},T=L=>{f?.value||(L?.stopPropagation(),n("mainClick"))},k=()=>{v.value||S()},C=L=>{if(v.value){T(L);return}S()},_=()=>{const L=b.value,R=L.match(/^\d+(\.5)?$/)?L:Math.floor(parseFloat(L)).toString();n("textSubmit",R),b.value=R},P=ct(()=>g.value?g.value:{minWidth:r.minWidth}),E=ct(()=>o.value?vl.dropdownCaretUp:vl.dropdownCaretDown);return(L,R)=>(ze(),Ze("div",{class:wr(["toolbar-item",Et(y).className]),style:Dn(P.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Et(y).ariaLabel,onClick:k,onKeydown:R[3]||(R[3]=Af(Jn(O=>C(O),["stop"]),["enter"])),tabindex:"0"},[ut("div",{class:wr(["toolbar-button",{active:Et(o),disabled:Et(f),narrow:e.isNarrow,wide:e.isWide,split:v.value,"has-inline-text-input":Et(p),"high-contrast":Et(x)}]),"data-item":`btn-${Et(i)||""}`},[v.value?(ze(),Ze("div",{key:0,class:"toolbar-button__main","data-item":`btn-${Et(i)||""}-main`,onClick:R[0]||(R[0]=O=>T(O))},[Et(s)?(ze(),br(kEe,{key:0,color:Et(c),class:"toolbar-icon",icon:Et(s),name:Et(i)},null,8,["color","icon","name"])):Bt("",!0),Et(a)&&!Et(l)&&!Et(h)?(ze(),Ze("div",fqt,Xn(Et(a)),1)):Bt("",!0)],8,dqt)):Bt("",!0),v.value?(ze(),Ze("div",{key:1,class:"toolbar-button__caret","data-item":`btn-${Et(i)||""}-caret`,"aria-label":`${Et(y).ariaLabel} options`,role:"button"},[ut("div",{class:"dropdown-caret",innerHTML:E.value,style:Dn({opacity:Et(f)?.6:1})},null,12,pqt)],8,hqt)):(ze(),Ze(Cn,{key:2},[Et(s)?(ze(),br(kEe,{key:0,color:Et(c),class:"toolbar-icon",icon:Et(s),name:Et(i)},null,8,["color","icon","name"])):Bt("",!0),Et(a)&&!Et(l)&&!Et(h)?(ze(),Ze("div",mqt,Xn(Et(a)),1)):Bt("",!0),Et(h)?(ze(),Ze("span",gqt,[Et(i)==="fontSize"?vd((ze(),Ze("input",{key:0,"onUpdate:modelValue":R[1]||(R[1]=O=>b.value=O),onKeydown:Af(Jn(_,["prevent"]),["enter"]),type:"text",class:wr(["button-text-input button-text-input--font-size",{"high-contrast":Et(x)}]),id:"inlineTextInput-"+Et(i),autocomplete:"off",ref_key:"inlineInput",ref:w},null,42,yqt)),[[Bh,b.value]]):vd((ze(),Ze("input",{key:1,"onUpdate:modelValue":R[2]||(R[2]=O=>b.value=O),placeholder:Et(a),onKeydown:Af(Jn(_,["prevent"]),["enter"]),type:"text",class:"button-text-input",id:"inlineTextInput-"+Et(i),autocomplete:"off",ref_key:"inlineInput",ref:w},null,40,bqt)),[[Bh,b.value]])])):Bt("",!0),Et(u)?(ze(),Ze("div",{key:3,class:"dropdown-caret",innerHTML:E.value,style:Dn({opacity:Et(f)?.6:1})},null,12,vqt)):Bt("",!0)],64)),ut("div",wqt,Xn(`${Et(y).ariaLabel} ${Et(o)?"selected":"unset"}`),1)],10,uqt)],46,cqt))}},lG=Hn(Aqt,[["__scopeId","data-v-fdaeb82f"]]);en(),Wn();var Sqt={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},xqt={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=kp(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(i,o)=>(ze(),Ze("div",Sqt,[ut("div",{class:"separator-inner",style:Dn({backgroundColor:r()})},null,4)]))}},Tqt=Hn(xqt,[["__scopeId","data-v-d027f7fc"]]);en(),Wn();var Iqt={class:"overflow-menu"},kqt={class:"overflow-menu-trigger"},Eqt={key:0,class:"overflow-menu_items",role:"group"},Cqt={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=fc(),r=t,i=e,o=ct(()=>i.toolbarItem.expand.value),s=Me(!1),a=ct(()=>({...i.toolbarItem,active:o.value})),l=()=>{r("buttonClick",i.toolbarItem)},c=({item:d,argument:f})=>{n.$toolbar.emitCommand({item:d,argument:f})},u=d=>{d.key==="Escape"&&o.value&&!s.value&&(d.preventDefault(),r("close"))};return Si(()=>{document.addEventListener("keydown",u,!0)}),xo(()=>{document.removeEventListener("keydown",u,!0)}),(d,f)=>(ze(),Ze("div",Iqt,[ut("div",kqt,[Ar(lG,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),o.value?(ze(),Ze("div",Eqt,[Ar(IM,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:c,onDropdownUpdateShow:f[0]||(f[0]=h=>s.value=h)},null,8,["toolbar-items"])])):Bt("",!0)]))}},_qt=Hn(Cqt,[["__scopeId","data-v-35b48dff"]]);en(),Wn();var Rqt={class:"toolbar-dropdown"},Pqt=["onClick"],Lqt={key:0,class:"toolbar-dropdown-option__icon"},Nqt={class:"toolbar-dropdown-option__label"},Mqt={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null}},emits:["update:show","select"],setup(e,{emit:t}){const n=e,r=t,i=Me(null),o=Me(null),s=Me({top:"0px",left:"0px"}),a=Me([]),l=Me(-1),c=ct(()=>!!n.show),u=ct(()=>n.options.some(K=>K?.type==="render")),d=ct(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),f=ct(()=>{const{class:K,style:U,...fe}=d.value;return fe}),h=ct(()=>{const K=d.value.class,U=n.options.length>0&&n.options.every(fe=>fe&&fe.type==="render");return["toolbar-dropdown-menu",K,{"toolbar-dropdown-menu--render-only":U}]}),p=ct(()=>{const K=d.value.style||{};return{...n.contentStyle,...K}}),m=ct(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,zIndex:2e3})),g=K=>{r("update:show",K)},y=()=>{c.value&&g(!1)},v=()=>{if(!i.value)return;const K=i.value.getBoundingClientRect(),U=o.value?.offsetWidth??0,fe=window.innerWidth||document.documentElement.clientWidth||0,ee=8;let Z=K.left;n.placement==="bottom-end"&&(Z=K.right-U);const re=Math.max(ee,fe-U-ee);Z=Math.min(Math.max(ee,Z),re),s.value={top:`${K.bottom+4}px`,left:`${Z}px`}},b=()=>{n.disabled||g(!c.value)},w=K=>typeof n.nodeProps!="function"?{}:n.nodeProps(K)||{},x=K=>{K?.disabled||K?.type!=="render"&&(r("select",K?.key,K),y())},S=K=>K?.type==="render",T=K=>!K?.disabled&&K?.type!=="render",k=K=>typeof K?.icon=="function"||!!K?.icon,C=K=>typeof K?.icon=="function"?K.icon(K):K?.icon||null,_=K=>K?typeof K=="string"?K.split(/\s+/).includes("selected"):Array.isArray(K)?K.some(_):typeof K=="object"?!!K.selected:!1:!1,P=K=>_(K?.props?.class)||_(K?.class),E=()=>n.options.map((K,U)=>T(K)?U:-1).filter(K=>K>=0),L=()=>{const K=n.options.findIndex(U=>T(U)&&P(U));return K>=0?K:E()[0]??-1},R=(K,U)=>{if(!K){delete a.value[U];return}a.value[U]=K},O=()=>{a.value.forEach((U,fe)=>{U&&U.setAttribute("tabindex",fe===l.value?"0":"-1")});const K=a.value[l.value];K&&typeof K.focus=="function"&&K.focus()},F=K=>{const U=E();if(!U.length){l.value=-1;return}const fe=U.indexOf(l.value);if(fe<0){l.value=K>0?U[0]:U[U.length-1];return}l.value=U[(fe+K+U.length)%U.length]},B=()=>{let K=n.options[l.value];if(!T(K)){const U=E()[0];K=U===void 0?null:n.options[U]}K&&x(K)},j=ev({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(K){return()=>typeof K.option.render!="function"?null:K.option.render()}}),M=ev({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(K){return()=>C(K.option)}}),z=K=>{if(!c.value)return;const U=K.target;if(!(U instanceof Element))return;const fe=i.value?.contains(U),ee=o.value?.contains(U);fe||ee||y()},$=K=>{if(!c.value)return;const{key:U}=K;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(U)){if(U==="Escape"){y();return}if(!u.value){if(K.preventDefault(),U==="ArrowDown"){F(1),O();return}if(U==="ArrowUp"){F(-1),O();return}U==="Enter"&&B()}}};return Vn(c,async K=>{if(!K){l.value=-1,a.value=[];return}await er(),v(),!u.value&&(l.value=L(),O())},{immediate:!0}),Vn(c,K=>{K?(document.addEventListener("pointerdown",z,!0),document.addEventListener("keydown",$,!0),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)):(document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",$,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0))},{immediate:!0}),xo(()=>{document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",$,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),(K,U)=>(ze(),Ze("div",Rqt,[ut("div",{ref_key:"triggerRef",ref:i,class:"toolbar-dropdown-trigger",onClick:b},[Yx(K.$slots,"trigger",{},void 0,!0)],512),(ze(),br(nv,{to:"body"},[Ar(HF,{name:"fade-in-scale-up-transition"},{default:bd(()=>[c.value?(ze(),Ze("div",dm({key:0,ref_key:"menuRef",ref:o,class:h.value,style:m.value},f.value),[(ze(!0),Ze(Cn,null,gi(e.options,(fe,ee)=>(ze(),Ze("div",dm({key:fe.key,ref_for:!0,ref:Z=>R(Z,ee),class:["toolbar-dropdown-option",[fe.class,fe.props?.class,{disabled:fe.disabled,render:S(fe)}]],tabindex:"-1",onClick:Z=>x(fe)},{ref_for:!0},{...fe.props,...w(fe)}),[S(fe)?(ze(),br(Et(j),{key:0,option:fe},null,8,["option"])):(ze(),Ze(Cn,{key:1},[k(fe)?(ze(),Ze("span",Lqt,[Ar(Et(M),{option:fe},null,8,["option"])])):Bt("",!0),ut("span",Nqt,Xn(fe.label),1)],64))],16,Pqt))),128))],16)):Bt("",!0)]),_:1})]))]))}},Dqt=Hn(Mqt,[["__scopeId","data-v-8eeadaa0"]]);en(),Wn();var Oqt=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=KUe(),r=Me(!1),i=Me(null),o=Me(null),s=Me({top:"0px",left:"0px"});let a=null,l=null;const c=ct(()=>["sd-tooltip-content",n.class]),u=ct(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),d=()=>{a&&(window.clearTimeout(a),a=null)},f=()=>{l&&(window.clearTimeout(l),l=null)},h=()=>{if(!i.value||!o.value)return;const T=i.value.getBoundingClientRect(),k=o.value.offsetWidth,C=o.value.offsetHeight,_=window.innerWidth||document.documentElement.clientWidth||0,P=8;let E=T.left+T.width/2-k/2;E=Math.max(P,Math.min(E,_-k-P)),s.value={top:`${T.top-C-10}px`,left:`${E}px`}},p=async()=>{t.disabled||(d(),f(),!r.value&&(r.value=!0,await er(),h()))},m=()=>{f(),d(),r.value&&(r.value=!1)},g=()=>{if(d(),f(),!r.value){if(t.delay===0){p();return}l=window.setTimeout(()=>{l=null,p()},t.delay)}},y=()=>{if(f(),d(),!!r.value){if(t.duration===0){m();return}a=window.setTimeout(()=>{a=null,m()},t.duration)}},v=()=>{t.trigger==="hover"&&g()},b=()=>{t.trigger==="hover"&&y()},w=()=>{f(),d()},x=()=>{y()},S=T=>{T.key==="Escape"&&m()};return Vn(()=>t.disabled,T=>{T&&m()}),Vn(r,T=>{T?(window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),document.addEventListener("keydown",S,!0)):(window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",S,!0))}),xo(()=>{f(),d(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",S,!0)}),(T,k)=>(ze(),Ze(Cn,null,[ut("span",{ref_key:"triggerRef",ref:i,class:"sd-tooltip-trigger",onMouseenter:v,onMouseleave:b,onFocusin:v,onFocusout:b},[Yx(T.$slots,"trigger",{},void 0,!0)],544),(ze(),br(nv,{to:"body"},[Ar(HF,{name:"fade-in-scale-up-transition"},{default:bd(()=>[r.value&&!e.disabled?(ze(),Ze("div",{key:0,ref_key:"contentRef",ref:o,class:wr(c.value),style:Dn(u.value),onMouseenter:w,onMouseleave:x},[k[0]||(k[0]=ut("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),Yx(T.$slots,"default",{},void 0,!0)],38)):Bt("",!0)]),_:3})]))],64))}}),EEe=Hn(Oqt,[["__scopeId","data-v-d8dd2f5a"]]);en(),Wn();var Fqt=["onKeydown","tabindex","data-item-id"],Bqt={key:0},Hqt={key:0},zqt={key:0},Uqt={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=fc(),i=Me([]),o=Me(null),s=e,a=Me(null),{isHighContrastMode:l}=kp(),c=window.matchMedia("(max-width: 768px)").matches,u=ct(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:c?0:1,justifyContent:"center"}),d=B=>B.type==="button",f=B=>B.type==="dropdown",h=B=>B.type==="separator",p=B=>B.type==="overflow",m=B=>{if(!B)return!1;const j=B.expand;return typeof j=="object"&&j!==null&&"value"in j?!!j.value:!!j},g=(B,j)=>{B?.expand&&(B.expand.value=j)},y=(B,j=null)=>{if(!B.disabled.value){if(p(B)){const M=!m(B);M&&w(),g(B,M),a.value=M?B:null,n("item-clicked");return}f(B)||(a.value&&f(a.value)&&m(a.value)&&w(),n("item-clicked"),n("command",{item:B,argument:j}))}},v=(B,j)=>{B.disabled.value||(a.value=null,n("command",{item:B,argument:j}))},b=B=>{if(B.disabled.value)return;w();const j=B.splitButtonCommand,M=B.command,z=j||M;if(!z)return;const $={...B,command:z};n("item-clicked"),n("command",{item:$,argument:null})},w=()=>{const B=r?.$toolbar?.toolbarItems||[],j=r?.$toolbar?.overflowItems||[],M=[...B,...j];(M.length?M:s.toolbarItems).forEach(z=>{const $=p(z)&&!s.fromOverflow;(f(z)||$)&&g(z,!1)}),a.value=null},x=(B,j)=>{w(),n("command",{item:B,argument:B.dropdownValueKey.value?j[B.dropdownValueKey.value]:j.label,option:j}),B.selectedValue.value=j.key},S=B=>B.nestedOptions?.value?.length?B.nestedOptions.value.map(j=>{const M=j?.type!=="render"&&B.selectedValue.value===j.key;return{...j,props:{...j.props,class:M?"selected":""}}}):[],T=(B,j)=>({role:"menuitem",ariaLabel:`${j.attributes.value.ariaLabel} - ${B.label}`}),k=B=>{const j=B.target,M=B.target.closest(".toolbar-item-ctn").nextElementSibling;M&&(j.setAttribute("tabindex","-1"),M.setAttribute("tabindex","0"),M.focus())},C=B=>{const j=B.target,M=B.target.closest(".toolbar-item-ctn").previousElementSibling;M&&(j.setAttribute("tabindex","-1"),M.setAttribute("tabindex","0"),M.focus())},_=B=>{const j=B.target.closest(".button-group").nextElementSibling;if(j)j.setAttribute("tabindex","0"),j.focus();else{const M=document.querySelector(".ProseMirror");M&&M.focus()}},P=B=>{const j=B.target.closest(".button-group").previousElementSibling;j&&(j.setAttribute("tabindex","0"),j.focus())},E=(B,j)=>{const M=B.target.nodeName==="INPUT"||B.target.nodeName==="TEXTAREA",z=j.name.value==="fontSize";if(!(M&&z))switch(B.preventDefault(),B.key){case"Enter":y(j,null,!1);break;case"Escape":w();break;case"ArrowRight":w(),k(B);break;case"ArrowLeft":w(),C(B);break;case"Tab":B.shiftKey?P(B):_(B);break;default:break}},L=B=>{const j=i.value.find(M=>!M.classList.contains("disabled"));j&&(j.setAttribute("tabindex","0"),j.focus())},R=(B,j)=>{if(n("item-clicked"),!B){w(),n("dropdown-update-show",!1);return}w(),a.value=j,g(j,!0),n("dropdown-update-show",!0)},O=B=>{if(!a.value)return;const j=B.target;j instanceof Element&&(j.closest(".sd-toolbar-dropdown-menu")||o.value?.contains(j)||w())};return Vn(()=>m(a.value),B=>{B?document.addEventListener("pointerdown",O,!0):document.removeEventListener("pointerdown",O,!0)},{immediate:!0}),xo(()=>{document.removeEventListener("pointerdown",O,!0)}),(B,j)=>(ze(),Ze("div",{style:Dn(u.value),class:"button-group",role:"group",onFocus:L,ref_key:"buttonGroupRef",ref:o},[(ze(!0),Ze(Cn,null,gi(e.toolbarItems,(M,z)=>(ze(),Ze("div",{key:M.id.value,class:wr([{narrow:M.isNarrow.value,wide:M.isWide.value,disabled:M.disabled.value},"toolbar-item-ctn"]),onKeydown:$=>E($,M),ref_for:!0,ref_key:"toolbarItemRefs",ref:i,tabindex:z===0?0:-1,"data-item-id":M.id.value},[h(M)?(ze(),br(Tqt,{key:0,style:{width:"20px"}})):Bt("",!0),f(M)&&M.nestedOptions?.value?.length?(ze(),br(Dqt,{key:1,options:S(M),disabled:M.disabled.value,show:m(M),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"toolbar-button sd-editor-toolbar-dropdown",onSelect:($,K)=>x(M,K),"onUpdate:show":$=>R($,M),style:Dn(M.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Et(l)}]}),"node-props":$=>T($,M)},{trigger:bd(()=>[Ar(EEe,{trigger:"hover",disabled:!M.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:bd(()=>[Ar(lG,{"toolbar-item":M,disabled:M.disabled.value,onTextSubmit:$=>v(M,$),onMainClick:$=>b(M)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:bd(()=>[ut("div",null,[E0(Xn(M.tooltip)+" ",1),M.disabled.value?(ze(),Ze("span",Bqt,"(disabled)")):Bt("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(M)?(ze(),br(EEe,{key:2,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:bd(()=>[Ar(lG,{"toolbar-item":M,"is-overflow-item":e.fromOverflow,onTextSubmit:$=>v(M,$),onButtonClick:$=>y(M)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:bd(()=>[M.tooltip?(ze(),Ze("div",Hqt,[E0(Xn(M.tooltip)+" ",1),M.disabled.value?(ze(),Ze("span",zqt,"(disabled)")):Bt("",!0)])):Bt("",!0)]),_:2},1032,["content-style"])):Bt("",!0),p(M)&&e.overflowItems.length?(ze(),br(_qt,{key:3,"toolbar-item":M,onButtonClick:$=>y(M),"overflow-items":e.overflowItems,onClose:w},null,8,["toolbar-item","onButtonClick","overflow-items"])):Bt("",!0)],42,Fqt))),128))],36))}},IM=Hn(Uqt,[["__scopeId","data-v-7dc120d3"]]);en(),Wn();var Vqt="Arial, Helvetica, sans-serif",Wqt={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=fc();let r=Me(1);const i=Me(!1);let o=null;const s=ct(()=>{const w=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof w=="string"&&w.trim()?w.trim():Vqt}),a=n.$toolbar.config?.toolbarGroups?.includes("left"),l=n.$toolbar.config?.toolbarGroups?.includes("right"),c=n.$toolbar.config?.toolbarButtonsExclude||[],u=w=>n.$toolbar.getToolbarItemByGroup(w).filter(x=>!c.includes(x.name.value)),d=()=>{i.value=n.$toolbar.getAvailableWidth()<=qk.lg},f=async w=>{if(w.metaKey&&w.key==="f"){const x=n.$toolbar.getToolbarItemByName("search");x&&(w.preventDefault(),x.expand.value=!0,await er(),x.inputRef.value&&x.inputRef.value.focus())}},p=eGt(async()=>{await n.$toolbar.onToolbarResize(),d(),r.value+=1},300);function m(){window.removeEventListener("resize",p),window.removeEventListener("keydown",f),o?.disconnect(),o=null}function g(){m(),window.addEventListener("resize",p),window.addEventListener("keydown",f),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(o=new ResizeObserver(()=>{p()}),o.observe(n.$toolbar.toolbarContainer)),d()}Si(g),vee(g),wee(m),xo(m);const y=({item:w,argument:x,option:S})=>{n.$toolbar.emitCommand({item:w,argument:x,option:S})},v=()=>{const w=n.$toolbar.activeEditor;w&&(w.options?.isHeaderOrFooter||w.commands?.restoreSelection())},b=w=>{w.target.closest('input, textarea, [contenteditable="true"]')||w.preventDefault()};return(w,x)=>(ze(),Ze("div",{class:"superdoc-toolbar",key:Et(r),role:"toolbar","aria-label":"Toolbar","data-editor-ui-surface":"",onMousedown:b},[Et(a)?(ze(),br(IM,{key:0,tabindex:"0","toolbar-items":u("left"),"compact-side-groups":i.value,"ui-font-family":s.value,position:"left",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Bt("",!0),Ar(IM,{tabindex:"0","toolbar-items":u("center"),"overflow-items":Et(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":s.value,position:"center",onCommand:y,onItemClicked:v},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Et(l)?(ze(),br(IM,{key:1,tabindex:"0","toolbar-items":u("right"),"compact-side-groups":i.value,"ui-font-family":s.value,position:"right",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Bt("",!0)],32))}},CEe=Hn(Wqt,[["__scopeId","data-v-bae4cd8a"]]);const _Ee={bold:"Bold",fontFamily:"Font",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",zoom:"Zoom",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},Gqt=(e,t={})=>{const n=e?.runProperties?.fontFamily;if(!n)return null;const[r]=sy({fontFamily:n},t);return r?.attrs?.fontFamily??null},jqt=e=>{let t=null;return e&&(e.startsWith("#")||e.startsWith(".")?t=document.querySelector(e):t=document.getElementById(e),!t)?null:t};en();var REe=class p$ extends v6.default{static#e=new Set(["bold","italic","underline","strike","highlight","color","fontSize","fontFamily"]);config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...vl},texts:{..._Ee},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,editor:null,aiApiKey:null,aiEndpoint:null,customButtons:[]};constructor(t){if(super(),this.config={...this.config,...t},this.toolbarItems=[],this.overflowItems=[],this.isDev=t.isDev||!1,this.superdoc=t.superdoc,this.role=t.role||"editor",this.toolbarContainer=null,this.controller=null,this.snapshot=null,this._unsubscribeController=null,this.config.editor&&(this.config.mode=this.config.editor.options.mode),this.config.icons={...vl,...t.icons},this.config.texts={..._Ee,...t.texts},this.config.hideButtons=t.hideButtons??!0,this.config.responsiveToContainer=t.responsiveToContainer??!1,this.pendingMarkCommands=[],this.stickyStoredMarks=null,this._boundEditorHandlers={transaction:null,selectionUpdate:null,focus:null},this._restoreFocusTimeoutId=null,!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=jqt(this.config.selector),this.toolbarContainer){const n=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",n)}this.#t(),this.#i({superToolbar:this,icons:this.config.icons,texts:this.config.texts,fonts:this.config.fonts,hideButtons:this.config.hideButtons,isDev:t.isDev}),!(this.config.selector&&!this.toolbarContainer)&&(this.app=rT(CEe),this.app.directive("click-outside",s8),this.app.config.globalProperties.$toolbar=this,this.toolbarContainer&&(this.toolbar=this.app.mount(this.toolbarContainer)),this.activeEditor=t.editor||null,this.initHeadlessToolbar(),this.updateToolbarState())}createHeadlessToolbar(){return this.superdoc?QWt({superdoc:this.superdoc,commands:rqt}):null}initHeadlessToolbar(){this.superdoc&&(this.destroyHeadlessToolbar(),this.controller=this.createHeadlessToolbar(),this.snapshot=this.controller.getSnapshot(),this._unsubscribeController=this.controller.subscribe(({snapshot:t})=>{this.snapshot=t,this.updateToolbarState()}))}destroyHeadlessToolbar(){this._unsubscribeController?.(),this.controller?.destroy(),this.controller=null,this.snapshot=null,this._unsubscribeController=null}#t(){this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}setActiveEditor(t){this.activeEditor&&this._boundEditorHandlers.transaction&&(this.activeEditor.off("transaction",this._boundEditorHandlers.transaction),this.activeEditor.off("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.off("focus",this._boundEditorHandlers.focus),this._boundEditorHandlers.transaction=null,this._boundEditorHandlers.selectionUpdate=null,this._boundEditorHandlers.focus=null),this.activeEditor=t,t&&(this._boundEditorHandlers.transaction=this.onEditorTransaction.bind(this),this._boundEditorHandlers.selectionUpdate=this.onEditorSelectionUpdate.bind(this),this._boundEditorHandlers.focus=this.onEditorFocus.bind(this),this.activeEditor.on("transaction",this._boundEditorHandlers.transaction),this.activeEditor.on("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.on("focus",this._boundEditorHandlers.focus))}getToolbarItemByGroup(t){return this.toolbarItems.filter(n=>(n.group?.value||"center")===t)}getToolbarItemByName(t){return this.toolbarItems.find(n=>n.name.value===t)}getAvailableWidth(){const t=document.documentElement.clientWidth,n=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?n:t}#i({superToolbar:t,icons:n,texts:r,fonts:i,hideButtons:o,isDev:s=!1}={}){const{defaultItems:a,overflowItems:l}=oqt({superToolbar:t,toolbarIcons:n,toolbarTexts:r,toolbarFonts:i,hideButtons:o,availableWidth:this.getAvailableWidth(),role:this.role,isDev:s}),c=this.config.customButtons||[];c.length&&a.push(...c.map(d=>Ii({...d})));let u=[...a.map(d=>d.name.value),...l.map(d=>d.name.value)];this.config.groups&&(u=Object.values(this.config.groups).flatMap(d=>d)),this.toolbarItems=a.filter(d=>u.includes(d.name.value)).filter(d=>!this.config.excludeItems.includes(d.name.value)),this.overflowItems=l.filter(d=>u.includes(d.name.value))}#n(){if(!this.activeEditor||!this.activeEditor.converter)return;const{typeface:t="Arial",fontSizePt:n=12}=this.activeEditor.converter.getDocumentDefaultStyles()??{},r=this.toolbarItems.find(o=>o.name.value==="fontSize");r&&(r.defaultLabel.value=n);const i=this.toolbarItems.find(o=>o.name.value==="fontFamily");i&&(i.defaultLabel.value=t)}#r(){if(!this.activeEditor||!this.activeEditor.converter||!this.activeEditor.converter.docHiglightColors.size)return;const t=this.toolbarItems.find(s=>s.name.value==="highlight");if(!t)return;const n=Fjt(),r=7,i=Array.from(this.activeEditor.converter.docHiglightColors).reduce((s,a,l)=>{const c=Math.floor(l/r);return s[c]||(s[c]=[]),n.includes(a)||s[c].push(zn(a)),s},[]),o={key:"color",type:"render",render:()=>sG(this,t,i,!0)};t.nestedOptions.value=[o]}#o(){const t=this.getToolbarItemByName("documentMode");if(!t)return;const n=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),r=this.config.texts||{},i=this.config.icons||{},o={editing:{label:r.documentEditingMode||"Editing",icon:i.documentEditingMode||i.documentMode},suggesting:{label:r.documentSuggestingMode||"Suggesting",icon:i.documentSuggestingMode||i.documentMode},viewing:{label:r.documentViewingMode||"Viewing",icon:i.documentViewingMode||i.documentMode}},s=o[n]||o.editing;t.label?.value!==void 0&&(t.label.value=s.label),t.defaultLabel?.value!==void 0&&(t.defaultLabel.value=s.label),t.icon?.value!==void 0&&s.icon&&(t.icon.value=s.icon)}#a(){if(!this.activeEditor?.state)return null;const{state:t}=this.activeEditor,n=t.selection;if(!n?.empty)return null;const r=Wl(i=>i.type.name==="paragraph")(n);return!r||r.node?.content?.size!==0?null:Gqt(zf(this.activeEditor,r.node,t.doc.resolve(r.pos)),this.activeEditor?.converter?.convertedXml??{})||null}#c(t){return!!t?.active&&t?.value==null}#u(t){if(t.name.value==="tableActions"){const a=TEe.map(l=>this.snapshot?.commands?.[l]).some(l=>l&&!l.disabled);return t.setDisabled(!a),!0}const n=TM[t.name.value];if(!n)return!1;const r=this.snapshot?.commands?.[n],i=()=>{t.setDisabled(!!r?.disabled)},o={textAlign:()=>{r?.value?t.activate({textAlign:r.value}):t.deactivate()},lineHeight:()=>{t.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const a=typeof r.value=="number"?`${r.value}%`:String(r.value);t.onActivate({zoom:a})}},documentMode:()=>{this.#o()},link:()=>{t.active.value=!!r?.active,t.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){t.activate({fontFamily:r.value});return}const a=this.#a();if(a){t.activate({fontFamily:a});return}t.deactivate()},fontSize:()=>{if(r?.value!=null){t.activate({fontSize:r.value});return}if(this.#c(r)){t.activate({},!0);return}t.deactivate()},color:()=>{r?.value!=null?t.activate({color:r.value}):t.deactivate()},highlight:()=>{r?.value!=null?t.activate({color:r.value}):t.deactivate()},linkedStyles:()=>{r?.value!=null?t.activate({styleId:r.value}):t.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(t.activate(),t.selectedValue.value=vpe(r.value)):(t.deactivate(),t.selectedValue.value=null)},default:()=>{r?.active?t.activate():t.deactivate()}},s=o[t.name.value]??o.default;return i(),s(),!0}#d(t,n){const r=t?.name?.value==="tableActions",i=r?xEe[n?.command]:TM[t?.name?.value];return!i||!this.controller?.execute?!1:(r?this.controller.execute(i):this.controller.execute(i,n),!0)}updateToolbarState(){this.#o(),this.#n(),this.#r();const t=this.snapshot?.commands?.["document-mode"]?.value||"editing";if(!this.activeEditor||t==="viewing"){this.#f();return}const{state:n}=this.activeEditor;if(!n){this.#f();return}this.toolbarItems.forEach(r=>{r.resetDisabled(),this.#u(r)})}onToolbarResize=()=>{this.#i({superToolbar:this,icons:this.config.icons,texts:this.config.texts,fonts:this.config.fonts,hideButtons:this.config.hideButtons,isDev:this.isDev}),this.role==="viewer"&&this.#f(),this.updateToolbarState()};#f(){this.activeEditor=null,this.toolbarItems.forEach(t=>{const{allowWithoutEditor:n}=t;n.value||t.setDisabled(!0)})}onEditorTransaction({transaction:t}){!t.docChanged&&!t.selectionSet||this.updateToolbarState()}#l(){!this.activeEditor||this.activeEditor.options.isHeaderOrFooter||(clearTimeout(this._restoreFocusTimeoutId),this._restoreFocusTimeoutId=setTimeout(()=>{this._restoreFocusTimeoutId=null,!(!this.activeEditor||this.activeEditor.options.isHeaderOrFooter)&&this.activeEditor.focus()},0))}emitCommand({item:t,argument:n,option:r}){const i=this.activeEditor?.view?.hasFocus,o=!!(typeof i=="function"&&i.call(this.activeEditor.view)),{command:s}=t,a=this.isMarkToggle(t),l=!!t?.restoreEditorFocus,c=n!=null,u=t?.type==="dropdown"&&!c,d=t?.command==="setFontFamily"||t?.command==="setFontSize";if(!(u&&d)){if(!o&&a&&!this.activeEditor?.options?.isHeaderOrFooter){this.pendingMarkCommands.push({command:s,argument:n,item:t});const f=t?.labelAttr?.value;f&&n?t?.activate?.({[f]:n}):t?.activate?.(),this.activeEditor&&!this.activeEditor.options.isHeaderOrFooter&&this.activeEditor.focus();return}if(this.activeEditor&&!this.activeEditor.options.isHeaderOrFooter&&this.activeEditor.focus(),!!s){if(t?.name?.value==="tableActions"&&this.#d(t,n)){this.updateToolbarState();return}if(IEe.has(t?.name?.value)&&this.#d(t,n)){a&&this.#s(),this.updateToolbarState(),l&&this.#l();return}if(this.activeEditor&&this.activeEditor.commands&&s in this.activeEditor.commands)this.activeEditor.commands[s](n);else if(typeof s=="function")s({item:t,argument:n,option:r});else{const f=new Error(`[super-toolbar 🎨] Command not found: ${s}`);throw this.emit("exception",{error:f,editor:this.activeEditor}),f}a&&this.#s(),this.updateToolbarState(),l&&this.#l()}}}onEditorSelectionUpdate(){if(this.activeEditor){if(this.pendingMarkCommands.length){const t=this.pendingMarkCommands;this.pendingMarkCommands=[],t.forEach(({command:n,argument:r,item:i})=>{if(n)try{if(IEe.has(i?.name?.value)&&this.#d(i,r)){this.#b({command:n,argument:r});return}this.activeEditor.commands&&n in this.activeEditor.commands&&this.activeEditor.commands[n](r),this.#b({command:n,argument:r})}catch(o){const s=new Error(`[super-toolbar 🎨] Failed to execute pending command: ${n}`);this.emit("exception",{error:s,editor:this.activeEditor,originalError:o}),console.error(s,o)}}),this.#s(),this.updateToolbarState();return}this.#w()&&this.updateToolbarState()}}onEditorFocus(){if(this.pendingMarkCommands.length){this.onEditorSelectionUpdate();return}this.#w()&&this.updateToolbarState()}isMarkToggle(t){const n=t?.name?.value;return p$.#e.has(n)}#s(){if(!this.activeEditor)return;const{selection:t,storedMarks:n}=this.activeEditor.state||{};t?.empty&&(this.stickyStoredMarks=n?.length?[...n]:null)}#w(){if(!this.activeEditor||!this.stickyStoredMarks?.length)return!1;const{state:t,view:n}=this.activeEditor,{selection:r,storedMarks:i}=t||{};if(!r?.empty||i?.length||!n?.dispatch||!t?.tr||Hu(this.activeEditor).some(s=>p$.#e.has(s.name)))return!1;const o=t.tr.setStoredMarks(this.stickyStoredMarks);return n.dispatch(o),!0}#b({command:t,argument:n}){if(!this.activeEditor||!this.activeEditor.state?.selection?.empty||this.activeEditor.state?.storedMarks?.length||t!=="setFontSize")return;const{state:r,view:i}=this.activeEditor,o=r.schema?.marks?.textStyle;if(!o||!i?.dispatch||!r?.tr)return;const[s,a]=Ef(n??"");if(Number.isNaN(s))return;const l=Math.min(96,Math.max(8,Number(s))),c=a||"pt",u=o.create({fontSize:`${l}${c}`}),d=r.tr.setStoredMarks([u]);i.dispatch(d)}destroy(){this._restoreFocusTimeoutId!==null&&(clearTimeout(this._restoreFocusTimeoutId),this._restoreFocusTimeoutId=null),this.destroyHeadlessToolbar(),this.app?.unmount()}},qqt=class m${static createSchemaByExtensions(t,n){const r=t.filter(a=>a.type==="node"),i=t.filter(a=>a.type==="mark"),o=r.find(a=>Zn(a,"topNode"))?.name,s=cn.getAttributesFromExtensions(t);return new Pie({topNode:o,nodes:m$.#e(r,s,n),marks:m$.#t(i,s,n)})}static#e(t,n,r){const i=t.map(o=>{const s=n.filter(p=>p.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:r},l=Object.fromEntries(s.map(p=>[p.name,{default:p?.attribute?.default}])),c=t.reduce((p,m)=>{const g=Zn(m,"extendNodeSchema",a);return{...p,...g?g(o):{}}},{}),u=Y7({content:ao(Zn(o,"content",a)),group:ao(Zn(o,"group",a)),marks:ao(Zn(o,"marks",a)),inline:ao(Zn(o,"inline",a)),atom:ao(Zn(o,"atom",a)),selectable:ao(Zn(o,"selectable",a)),draggable:ao(Zn(o,"draggable",a)),code:ao(Zn(o,"code",a)),defining:ao(Zn(o,"defining",a)),isolating:ao(Zn(o,"isolating",a)),summary:Zn(o,"summary",a),attrs:l,...c});(typeof o.validChildren=="function"||Array.isArray(o.validChildren))&&Object.defineProperty(u,"validChildren",{enumerable:!1,configurable:!1,get:()=>o.validChildren});const d=ao(Zn(o,"parseDOM",a));d&&(u.parseDOM=d.map(p=>cn.insertExtensionAttrsToParseRule(p,s)));const f=Zn(o,"renderDOM",a);f&&(u.toDOM=p=>f({node:p,htmlAttributes:cn.getAttributesToRender(p,s)}));const h=Zn(o,"renderText",a);return h&&(u.toText=h),[o.name,u]});return Object.fromEntries(i)}static#t(t,n,r){const i=t.map(o=>{const s=n.filter(f=>f.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:r},l=Object.fromEntries(s.map(f=>[f.name,{default:f?.attribute?.default}])),c=Y7({group:ao(Zn(o,"group",a)),inclusive:ao(Zn(o,"inclusive",a)),excludes:ao(Zn(o,"excludes",a)),spanning:ao(Zn(o,"spanning",a)),code:ao(Zn(o,"code",a)),attrs:l}),u=ao(Zn(o,"parseDOM",a));u&&(c.parseDOM=u.map(f=>cn.insertExtensionAttrsToParseRule(f,s)));const d=Zn(o,"renderDOM",a);return d&&(c.toDOM=f=>d({mark:f,htmlAttributes:cn.getAttributesToRender(f,s)})),[o.name,c]});return Object.fromEntries(i)}},bA,PEe,LEe,NEe,MEe,Yqt=Pe((()=>{bA=class extends Error{constructor(e){super(e),this.name="EditorError"}},PEe=class extends bA{constructor(e){super(e),this.name="InvalidStateError"}},LEe=class extends bA{constructor(e){super(e),this.name="NoSourcePathError"}},NEe=class extends bA{constructor(e){super(e),this.name="FileSystemNotAvailableError"}},MEe=class extends bA{constructor(e,t){super(e),this.name="DocumentLoadError",this.cause=t}}})),ia,Go,Yk=Pe((()=>{Yqt(),ia={PASSWORD_REQUIRED:"DOCX_PASSWORD_REQUIRED",PASSWORD_INVALID:"DOCX_PASSWORD_INVALID",ENCRYPTION_UNSUPPORTED:"DOCX_ENCRYPTION_UNSUPPORTED",DECRYPTION_FAILED:"DOCX_DECRYPTION_FAILED"},Go=class extends bA{constructor(e,t,n){super(t),this.name="DocxEncryptionError",this.code=e,this.cause=n}}}));const Kqt=li.create({name:"commands",addCommands(){return{...R6t}}});var cG=e=>{const t=e?.state?.tr;t&&e.dispatch?.(vP(t))};const Xqt=e=>{const{view:t}=e;return cG(t),e.commands.first(({commands:n})=>[()=>n.splitRunToParagraph?.()??!1,()=>n.newlineInCode(),()=>n.createParagraphNear(),()=>n.liftEmptyBlock(),()=>n.splitBlock()])},Kk=e=>{const{view:t}=e;return cG(t),e.commands.first(({commands:n,tr:r})=>[()=>n.undoInputRule(),()=>(r.setMeta("inputType","deleteContentBackward"),!1),()=>n.backspaceEmptyRunParagraph(),()=>n.backspaceSkipEmptyRun(),()=>n.backspaceNextToRun(),()=>n.backspaceAcrossRuns(),()=>n.deleteSelection(),()=>n.removeNumberingProperties(),()=>n.joinBackward(),()=>n.selectNodeBackward()])},vA=e=>{const{view:t}=e;return cG(t),e.commands.first(({commands:n})=>[()=>n.deleteSkipEmptyRun(),()=>n.deleteNextToRun(),()=>n.deleteSelection(),()=>n.joinForward(),()=>n.selectNodeForward()])},Jqt=li.create({name:"keymap",addShortcuts(){const e={Enter:()=>Xqt(this.editor),"Shift-Enter":()=>this.editor.commands.insertLineBreak(),"Mod-Enter":()=>this.editor.commands.insertPageBreak(),Backspace:()=>Kk(this.editor),"Mod-Backspace":()=>Kk(this.editor),"Shift-Backspace":()=>Kk(this.editor),Delete:()=>vA(this.editor),"Mod-Delete":()=>vA(this.editor),"Mod-a":()=>this.editor.commands.selectAll(),Tab:()=>this.editor.commands.insertTabNode(),ArrowLeft:()=>this.editor.commands.skipTab(-1),ArrowRight:()=>this.editor.commands.skipTab(1)},t={...e},n={...e,"Ctrl-h":()=>Kk(this.editor),"Alt-Backspace":()=>Kk(this.editor),"Ctrl-d":()=>vA(this.editor),"Ctrl-Alt-Backspace":()=>vA(this.editor),"Alt-Delete":()=>vA(this.editor),"Alt-d":()=>vA(this.editor),"Ctrl-a":()=>this.editor.commands.selectAll(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd(),"Ctrl-t":()=>this.editor.commands.insertTabChar()};return u8()||wYe()?n:t}});var Zqt=e=>{const t=globalThis;if(t.__SD_DEBUG_STORY_INPUT__!==!0)return;const n=Array.isArray(t.__SD_DEBUG_STORY_INPUT_LOG__)?t.__SD_DEBUG_STORY_INPUT_LOG__:[];n.push(e),n.length>200&&n.splice(0,n.length-200),t.__SD_DEBUG_STORY_INPUT_LOG__=n},DEe=e=>{const t=e?.options?.documentId??"";return t.startsWith("hf:")||t.startsWith("fn:")||t.startsWith("en:")||e?.options?.isHeaderOrFooter===!0||e?.options?.headerFooterType==="header"||e?.options?.headerFooterType==="footer"},wA=(e,t,n,r,i={})=>{if(!DEe(n))return;let o=null;const s=e?.dom?.ownerDocument?.getSelection?.()??null;try{e?.dom&&s?.anchorNode&&e.dom.contains(s.anchorNode)&&(o=e.posAtDOM(s.anchorNode,s.anchorOffset,-1))}catch{o=null}Zqt({phase:r,documentId:n?.options?.documentId??null,inputType:t?.inputType??null,data:t?.data??null,cancelable:t?.cancelable??null,defaultPrevented:t?.defaultPrevented??null,selectionFrom:e?.state?.selection?.from??null,selectionTo:e?.state?.selection?.to??null,domAnchorPos:o,...i})},Qqt=(e,t,n)=>{const r=t?.inputType==="insertText",i=typeof t?.data=="string"&&t.data.length>0,o=t?.isComposing===!0;if(wA(e,t,n,"beforeinput:start",{isInsertTextInput:r,hasTextData:i,isComposing:o}),!r||!i||o)return wA(e,t,n,"beforeinput:skip"),!1;const s=e.state.selection;if(s.empty&&!DEe(n))return wA(e,t,n,"beforeinput:skip-empty-selection"),!1;const a=e.state.tr.insertText(t.data,s.from,s.to),l=Math.max(0,Math.min(s.from+t.data.length,a.doc.content.size));try{a.setSelection(It.create(a.doc,l))}catch{a.setSelection(In.near(a.doc.resolve(l),1))}return a.setMeta("inputType","insertText"),e.dispatch(a),t.preventDefault(),wA(e,t,n,"beforeinput:handled"),!0},$qt=(e,t)=>{if(!e.composing||t?.isComposing)return!1;const n=t?.inputType??null;return n?!["insertCompositionText","deleteCompositionText"].includes(n):!1},eYt=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);const tYt=li.create({name:"editable",addPmPlugins(){const e=this.editor,t=()=>!e.options.editable&&!e.options.allowSelectionInViewMode,n=(r,i)=>e.options.editable?!1:(i.preventDefault(),!0);return[new xr({key:new Wr("editable"),props:{editable:()=>e.options.editable,handleDOMEvents:{beforeinput:(r,i)=>(wA(r,i,e,"dom:beforeinput"),e.options.editable?($qt(r,i)&&Npt(r),!!Qqt(r,i,e)):(i.preventDefault(),!0)),input:(r,i)=>(wA(r,i,e,"dom:input"),!1),compositionstart:(r,i)=>n(r,i),compositionupdate:(r,i)=>n(r,i),compositionend:(r,i)=>n(r,i),mousedown:(r,i)=>t()?(i.preventDefault(),!0):!1,focus:(r,i)=>t()?(i.preventDefault(),r.dom.blur(),!0):!1},handleClick:()=>t(),handleDoubleClick:()=>t(),handleTripleClick:()=>t(),handleKeyDown:(r,i)=>e.options.editable?!1:!(e.options.allowSelectionInViewMode&&(eYt.has(i.key)||(i.ctrlKey||i.metaKey)&&["c","a"].includes(i.key.toLowerCase()))),handlePaste:()=>!e.options.editable,handleDrop:()=>!e.options.editable}})]}}),nYt=li.create({name:"editorFocus",addPmPlugins(){const e=this.editor;return[new xr({key:new Wr("editorFocus"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),rYt=li.create({name:"positionTracker",addStorage(){return{tracker:null}},addPmPlugins(){return[hzt()]},onCreate(){const e=this.editor?.positionTracker??this.storage.tracker;if(e){this.storage.tracker=e,this.editor.positionTracker=e;return}const t=new FIe(this.editor);this.storage.tracker=t,this.editor.positionTracker=t},onDestroy(){this.editor?.positionTracker===this.storage.tracker&&(this.editor.positionTracker=null),this.storage.tracker=null}}),iYt=li.create({name:"selectionHandle",addPmPlugins(){return[QDt()]}});var Xk=class{#e=new Map;on(e,t){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}emit(e,...t){const n=this.#e.get(e);if(n)for(const r of n)r.apply(this,t)}safeEmit(e,...t){const n=this.#e.get(e);if(!n)return[];const r=[];for(const i of n)try{i.apply(this,t)}catch(o){r.push(o instanceof Error?o:new Error(String(o)))}return r}off(e,t){const n=this.#e.get(e);n&&(t?this.#e.set(e,n.filter(r=>r!==t)):this.#e.delete(e))}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};this.on(e,n)}removeAllListeners(){this.#e=new Map}};function oYt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}var sYt=class O_{editor;schema;extensions;externalExtensions=[];splittableMarks=[];constructor(t,n,r){this.editor=r,this.externalExtensions=n||[],this.externalExtensions=this.externalExtensions.map(i=>({...i,isExternal:!0})),this.extensions=O_.getResolvedExtensions([...t,...this.externalExtensions]),this.schema=qqt.createSchemaByExtensions(this.extensions,r),this.#e()}static create(...t){return new O_(...t)}static getResolvedExtensions(t){return O_.sortByPriority(t)}static sortByPriority(t){return t.sort((r,i)=>{const o=Zn(r,"priority")||100,s=Zn(i,"priority")||100;return o>s?-1:o<s?1:0})}get attributes(){return cn.getAttributesFromExtensions(this.extensions)}get commands(){let t={};for(const n of this.extensions){const r=Zn(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:aw(n.name,this.schema)});r&&(t={...t,...r()})}return t}get helpers(){const t={};for(const n of this.extensions){const r=n.name;if(!r)continue;const i=Zn(n,"addHelpers",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:aw(n.name,this.schema)});i&&(t[r]=i())}return t}get plugins(){const t=this.editor,n=O_.sortByPriority([...this.extensions].reverse()),r=[],i=n.map(o=>{const s={name:o.name,options:o.options,storage:o.storage,editor:t,type:aw(o.name,this.schema)},a=[],l=Zn(o,"addShortcuts",s);let c={};if(l){const f=Object.entries(l()).map(([h,p])=>[h,(...m)=>p({editor:t,keymapArgs:m})]);c={...Object.fromEntries(f)}}a.push(Wpt(c));const u=Zn(o,"addInputRules",s);oYt(o,t.options.enableInputRules)&&u&&r.push(...u());const d=Zn(o,"addPmPlugins",s);return d&&a.push(...d()),a}).flat();return[abt({editor:t,rules:r}),...i]}get nodeViews(){const{editor:t}=this,n=this.extensions.filter(r=>r.type==="node").filter(r=>!!Zn(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o=Zn(r,"addNodeView",{name:r.name,options:r.options,storage:r.storage,editor:t,type:Jc(r.name,this.schema)});if(!o)return null;const s=o();if(!s)return null;const a=(l,c,u,d)=>s({editor:t,node:l,getPos:u,decorations:d,htmlAttributes:cn.getAttributesToRender(l,i),extension:r,extensionAttrs:i});return[r.name,a]}).filter(Boolean);return Object.fromEntries(n)}#e(){for(const t of this.extensions){this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:aw(t.name,this.schema)};t.type==="mark"&&(ao(Zn(t,"keepOnSplit",n))??!0)&&this.splittableMarks.push(t.name),this.#t(t)}}#t(t){const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:aw(t.name,this.schema)},r=Zn(t,"onBeforeCreate",n),i=Zn(t,"onCreate",n),o=Zn(t,"onUpdate",n),s=Zn(t,"onSelectionUpdate",n),a=Zn(t,"onTransaction",n),l=Zn(t,"onFocus",n),c=Zn(t,"onBlur",n),u=Zn(t,"onDestroy",n);r&&this.editor.on("beforeCreate",r),i&&this.editor.on("create",i),o&&this.editor.on("update",o),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),u&&this.editor.on("destroy",u)}},aYt={initial:e=>{const{state:t}=e,n=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),{tr:r}=t;if(n)return t.doc.descendants((i,o)=>{if(i.type.name==="paragraph"){const{attrs:s}=i,{spacing:a}=s;if(!a)return;const l={line:U0(ba(a.line)),lineSpaceBefore:U0(ba(a.lineSpaceBefore)),lineSpaceAfter:U0(ba(a.lineSpaceAfter))};r.setNodeMarkup(o,void 0,{...s,spacing:{...a,...l}})}}),n(r),!0}};const OEe=e=>{if(e==="initial"||e==="0.4.14")return Object.values(aYt)};var FEe=Hi(((e,t)=>{(function(n){typeof e=="object"&&typeof t<"u"?t.exports=n():typeof define=="function"&&define.amd?define([],n):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=n()})(function(){return(function n(r,i,o){function s(c,u){if(!i[c]){if(!r[c]){var d=typeof require=="function"&&require;if(!u&&d)return d(c,!0);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var h=i[c]={exports:{}};r[c][0].call(h.exports,function(p){var m=r[c][1][p];return s(m||p)},h,h.exports,n,r,i,o)}return i[c].exports}for(var a=typeof require=="function"&&require,l=0;l<o.length;l++)s(o[l]);return s})({1:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,u,d,f,h,p,m,g=[],y=0,v=l.length,b=v,w=o.getTypeOf(l)!=="string";y<l.length;)b=v-y,d=w?(c=l[y++],u=y<v?l[y++]:0,y<v?l[y++]:0):(c=l.charCodeAt(y++),u=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),f=c>>2,h=(3&c)<<4|u>>4,p=1<b?(15&u)<<2|d>>6:64,m=2<b?63&d:64,g.push(a.charAt(f)+a.charAt(h)+a.charAt(p)+a.charAt(m));return g.join("")},i.decode=function(l){var c,u,d,f,h,p,m=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var v,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=s.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)c=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,u=(15&f)<<4|(h=a.indexOf(l.charAt(m++)))>>2,d=(3&h)<<6|(p=a.indexOf(l.charAt(m++))),v[g++]=c,h!==64&&(v[g++]=u),p!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(n,r,i){"use strict";var o=n("./external"),s=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,d,f,h,p){this.compressedSize=u,this.uncompressedSize=d,this.crc32=f,this.compression=h,this.compressedContent=p}c.prototype={getContentWorker:function(){var u=new s(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new s(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,d,f){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){"use strict";var o=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){"use strict";var o=n("./utils"),s=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();r.exports=function(a,l){return a!==void 0&&a.length?o.getTypeOf(a)!=="string"?(function(c,u,d,f){var h=s,p=f+d;c^=-1;for(var m=f;m<p;m++)c=c>>>8^h[255&(c^u[m])];return-1^c})(0|l,a,a.length,0):(function(c,u,d,f){var h=s,p=f+d;c^=-1;for(var m=f;m<p;m++)c=c>>>8^h[255&(c^u.charCodeAt(m))];return-1^c})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,i){"use strict";i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){"use strict";var o=null;o=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:o}},{lie:37}],7:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=o?"uint8array":"array";function u(d,f){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=f,this.meta={}}i.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(f){d.push({data:f,meta:d.meta})}},i.compressWorker=function(d){return new u("Deflate",d)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){"use strict";function o(h,p){var m,g="";for(m=0;m<p;m++)g+=String.fromCharCode(255&h),h>>>=8;return g}function s(h,p,m,g,y,v){var b,w,x=h.file,S=h.compression,T=v!==c.utf8encode,k=a.transformTo("string",v(x.name)),C=a.transformTo("string",c.utf8encode(x.name)),_=x.comment,P=a.transformTo("string",v(_)),E=a.transformTo("string",c.utf8encode(_)),L=C.length!==x.name.length,R=E.length!==_.length,O="",F="",B="",j=x.dir,M=x.date,z={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(z.crc32=h.crc32,z.compressedSize=h.compressedSize,z.uncompressedSize=h.uncompressedSize);var $=0;p&&($|=8),T||!L&&!R||($|=2048);var K=0,U=0;j&&(K|=16),y==="UNIX"?(U=798,K|=(function(ee,Z){var re=ee;return ee||(re=Z?16893:33204),(65535&re)<<16})(x.unixPermissions,j)):(U=20,K|=(function(ee){return 63&(ee||0)})(x.dosPermissions)),b=M.getUTCHours(),b<<=6,b|=M.getUTCMinutes(),b<<=5,b|=M.getUTCSeconds()/2,w=M.getUTCFullYear()-1980,w<<=4,w|=M.getUTCMonth()+1,w<<=5,w|=M.getUTCDate(),L&&(F=o(1,1)+o(u(k),4)+C,O+="up"+o(F.length,2)+F),R&&(B=o(1,1)+o(u(P),4)+E,O+="uc"+o(B.length,2)+B);var fe="";return fe+=`
322
- \0`,fe+=o($,2),fe+=S.magic,fe+=o(b,2),fe+=o(w,2),fe+=o(z.crc32,4),fe+=o(z.compressedSize,4),fe+=o(z.uncompressedSize,4),fe+=o(k.length,2),fe+=o(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+fe+k+O,dirRecord:d.CENTRAL_FILE_HEADER+o(U,2)+fe+o(P.length,2)+"\0\0\0\0"+o(K,4)+o(g,4)+k+O+P}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function f(h,p,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var m=s(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,m=s(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(g){return d.DATA_DESCRIPTOR+o(g.crc32,4)+o(g.compressedSize,4)+o(g.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-h,g=(function(y,v,b,w,x){var S=a.transformTo("string",x(w));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(y,2)+o(y,2)+o(v,4)+o(b,4)+o(S.length,2)+S})(this.dirRecords.length,m,h,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(h){this._sources.push(h);var p=this;return h.on("data",function(m){p.processChunk(m)}),h.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),h.on("error",function(m){p.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(h){var p=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var m=0;m<p.length;m++)try{p[m].error(h)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,p=0;p<h.length;p++)h[p].lock()},r.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){"use strict";var o=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(a,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(f,h){d++;var p=(function(v,b){var w=v||b,x=o[w];if(!x)throw new Error(w+" is not a valid compression method !");return x})(h.options.compression,l.compression),m=h.options.compressionOptions||l.compressionOptions||{},g=h.dir,y=h.date;h._compressWorker(p,m).withStreamInfo("file",{name:f,dir:g,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){"use strict";function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new o;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(o.prototype=n("./object")).loadAsync=n("./load"),o.support=n("./support"),o.defaults=n("./defaults"),o.version="3.10.1",o.loadAsync=function(s,a){return new o().loadAsync(s,a)},o.external=n("./external"),r.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function d(f){return new s.Promise(function(h,p){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){p(g)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(f,h){var p=this;return h=o.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",f,!0,h.optimizedBinaryString,h.base64).then(function(m){var g=new l(h);return g.load(m),g}).then(function(m){var g=[s.Promise.resolve(m)],y=m.files;if(h.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,x=o.resolve(b.fileNameStr);p.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(x).unsafeOriginalName=w)}return g.zipComment.length&&(p.comment=g.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../stream/GenericWorker");function a(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}o.inherits(a,s),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){"use strict";var o=n("readable-stream").Readable;function s(a,l,c){o.call(this,l),this._helper=a;var u=this;a.on("data",function(d,f){u.push(d)||u._helper.pause(),c&&c(f)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,o),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,s);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,s)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var s=new Buffer(o);return s.fill(0),s},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(n,r,i){"use strict";function o(w,x,S){var T,k=a.getTypeOf(x),C=a.extend(S||{},u);C.date=C.date||new Date,C.compression!==null&&(C.compression=C.compression.toUpperCase()),typeof C.unixPermissions=="string"&&(C.unixPermissions=parseInt(C.unixPermissions,8)),C.unixPermissions&&16384&C.unixPermissions&&(C.dir=!0),C.dosPermissions&&16&C.dosPermissions&&(C.dir=!0),C.dir&&(w=y(w)),C.createFolders&&(T=g(w))&&v.call(this,T,!0);var _=k==="string"&&C.binary===!1&&C.base64===!1;S&&S.binary!==void 0||(C.binary=!_),(x instanceof d&&x.uncompressedSize===0||C.dir||!x||x.length===0)&&(C.base64=!1,C.binary=!0,x="",C.compression="STORE",k="string");var P=null;P=x instanceof d||x instanceof l?x:p.isNode&&p.isStream(x)?new m(w,x):a.prepareContent(w,x,C.binary,C.optimizedBinaryString,C.base64);var E=new f(w,P,C);this.files[w]=E}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),d=n("./compressedObject"),f=n("./zipObject"),h=n("./generate"),p=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),g=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var x=w.lastIndexOf("/");return 0<x?w.substring(0,x):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},v=function(w,x){return x=x!==void 0?x:u.createFolders,w=y(w),this.files[w]||o.call(this,w,null,{dir:!0,createFolders:x}),this.files[w]};function b(w){return Object.prototype.toString.call(w)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var x,S,T;for(x in this.files)T=this.files[x],(S=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&w(S,T)},filter:function(w){var x=[];return this.forEach(function(S,T){w(S,T)&&x.push(T)}),x},file:function(w,x,S){if(arguments.length!==1)return w=this.root+w,o.call(this,w,x,S),this;if(b(w)){var T=w;return this.filter(function(C,_){return!_.dir&&T.test(C)})}var k=this.files[this.root+w];return k&&!k.dir?k:null},folder:function(w){if(!w)return this;if(b(w))return this.filter(function(k,C){return C.dir&&w.test(k)});var x=this.root+w,S=v.call(this,x),T=this.clone();return T.root=S.name,T},remove:function(w){w=this.root+w;var x=this.files[w];if(x||(w.slice(-1)!=="/"&&(w+="/"),x=this.files[w]),x&&!x.dir)delete this.files[w];else for(var S=this.filter(function(k,C){return C.name.slice(0,w.length)===w}),T=0;T<S.length;T++)delete this.files[S[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var x,S={};try{if((S=a.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var T=S.comment||this.comment||"";x=h.generateWorker(this,S,T)}catch(k){(x=new l("error")).error(k)}return new c(x,S.type||"string",S.mimeType)},generateAsync:function(w,x){return this.generateInternalStream(w).accumulate(x)},generateNodeStream:function(w,x){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===d)return f-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&d===f[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){"use strict";var o=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return o.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){"use strict";var o=n("./Uint8ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){"use strict";var o=n("./ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var f=o.getTypeOf(d);return o.checkSupport(f),f!=="string"||s.uint8array?f==="nodebuffer"?new c(d):s.uint8array?new u(o.transformTo("uint8array",d)):new a(o.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){"use strict";i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../utils");function a(l){o.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,o),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../crc32");function a(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,o),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}o.inherits(a,s),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=o.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}o.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){"use strict";function o(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=o},{}],29:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,m){return new u.Promise(function(g,y){var v=[],b=p._internalType,w=p._outputType,x=p._mimeType;p.on("data",function(S,T){v.push(S),m&&m(T)}).on("error",function(S){v=[],y(S)}).on("end",function(){try{g((function(S,T,k){switch(S){case"blob":return o.newBlob(o.transformTo("arraybuffer",T),k);case"base64":return l.encode(T);default:return o.transformTo(S,T)}})(w,(function(S,T){var k,C=0,_=null,P=0;for(k=0;k<T.length;k++)P+=T[k].length;switch(S){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(_=new Uint8Array(P),k=0;k<T.length;k++)_.set(T[k],C),C+=T[k].length;return _;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+S+"'")}})(b,v),x))}catch(S){y(S)}v=[]}).resume()})}function h(p,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,o.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}h.prototype={accumulate:function(p){return f(this,p)},on:function(p,m){var g=this;return p==="data"?this._worker.on(p,function(y){m.call(g,y.data,y.meta)}):this._worker.on(p,function(){o.delay(m,arguments,g)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},p)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){"use strict";if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){"use strict";for(var o=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(p){var m,g,y,v,b,w=p.length,x=0;for(v=0;v<w;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),x+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(x):new Array(x),v=b=0;b<x;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(h)},i.utf8decode=function(h){return s.nodebuffer?o.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,v,b=p.length,w=new Array(2*b);for(m=g=0;m<b;)if((y=p[m++])<128)w[g++]=y;else if(4<(v=c[y]))w[g++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&p[m++],v--;1<v?w[g++]=65533:y<65536?w[g++]=y:(y-=65536,w[g++]=55296|y>>10&1023,w[g++]=56320|1023&y)}return w.length!==g&&(w.subarray?w=w.subarray(0,g):w.length=g),o.applyFromCharCode(w)})(h=o.transformTo(s.uint8array?"uint8array":"array",h))},o.inherits(d,l),d.prototype.processChunk=function(h){var p=o.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=(function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+c[v[w]]>b?w:b})(p),y=p;g!==p.length&&(s.uint8array?(y=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(y=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,o.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){"use strict";var o=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(m){return m}function u(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}n("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,y){var v=[],b=0,w=m.length;if(w<=y)return String.fromCharCode.apply(null,m);for(;b<w;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=i.getTypeOf(m),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function h(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=f;var p={};p.string={string:c,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,a.allocBuffer(m.length))}},p.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},p.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return h(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},p.nodebuffer={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:c},i.transformTo=function(m,g){return g=g||"",m?(i.checkSupport(m),p[i.getTypeOf(g)][m](g)):g},i.resolve=function(m){for(var g=m.split("/"),y=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":o.nodebuffer&&a.isBuffer(m)?"nodebuffer":o.uint8array&&m instanceof Uint8Array?"uint8array":o.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!o[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,v="";for(y=0;y<(m||"").length;y++)v+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,v,b){return l.Promise.resolve(g).then(function(w){return o.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,S){var T=new FileReader;T.onload=function(k){x(k.target.result)},T.onerror=function(k){S(k.target.error)},T.readAsArrayBuffer(w)}):w}).then(function(w){var x=i.getTypeOf(w);return x?(x==="arraybuffer"?w=i.transformTo("uint8array",w):x==="string"&&(b?w=s.decode(w):y&&v!==!0&&(w=(function(S){return u(S,o.uint8array?new Uint8Array(S.length):new Array(S.length))})(w))),w):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(f)+", expected "+s.pretty(d)+")")}},isSignature:function(d,f){var h=this.reader.index;this.reader.setIndex(d);var p=this.reader.readString(4)===f;return this.reader.setIndex(h),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),f=c.uint8array?"uint8array":"array",h=s.transformTo(f,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,f,h,p=this.zip64EndOfCentralSize-44;0<p;)d=this.reader.readInt(2),f=this.reader.readInt(4),h=this.reader.readData(f),this.zip64ExtensibleData[d]={id:d,length:f,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,f;for(d=0;d<this.files.length;d++)f=this.files[d],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var f=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var p=f-h;if(0<p)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(d){this.reader=o(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),d=n("./support");function f(h,p){this.options=h,this.loadOptions=p}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var p,m;if(h.skip(22),this.fileNameLength=h.readInt(2),m=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(g){for(var y in u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===g)return u[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,p,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var p=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(p),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,m,g,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)p=h.readInt(2),m=h.readInt(2),g=h.readData(m),this.extraFields[p]={id:p,length:m,value:g};h.setIndex(y)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileName)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileComment)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null}},r.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){"use strict";function o(p,m,g){this.name=p,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");o.prototype={internalStream:function(p){var m=null,g="string";try{if(!p)throw new Error("No output type specified.");var y=(g=p.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new u("error")).error(b)}return new s(m,g,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof c&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,p,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)o.prototype[d[h]]=f;r.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(o){"use strict";var s,a,l=o.MutationObserver||o.WebKitMutationObserver;if(l){var c=0,u=new l(p),d=o.document.createTextNode("");u.observe(d,{characterData:!0}),s=function(){d.data=c=++c%2}}else if(o.setImmediate||o.MessageChannel===void 0)s="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var m=o.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},o.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var f=new o.MessageChannel;f.port1.onmessage=p,s=function(){f.port2.postMessage(0)}}var h=[];function p(){var m,g;a=!0;for(var y=h.length;y;){for(g=h,h=[],m=-1;++m<y;)g[m]();y=h.length}a=!1}r.exports=function(m){h.push(m)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){"use strict";var o=n("immediate");function s(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,y!==s&&m(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(y,v,b){o(function(){var w;try{w=v(b)}catch(x){return a.reject(y,x)}w===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,w)})}function p(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function m(y,v){var b=!1;function w(T){b||(b=!0,a.reject(y,T))}function x(T){b||(b=!0,a.resolve(y,T))}var S=g(function(){v(x,w)});S.status==="error"&&w(S.value)}function g(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==u?h(b,this.state===c?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},a.resolve=function(y,v){var b=g(p,v);if(b.status==="error")return a.reject(y,b.value);var w=b.value;if(w)m(y,w);else{y.state=c,y.outcome=v;for(var x=-1,S=y.queue.length;++x<S;)y.queue[x].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var v=new this(s);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=new Array(b),S=0,T=-1,k=new this(s);++T<b;)C(y[T],T);return k;function C(_,P){v.resolve(_).then(function(E){x[P]=E,++S!==b||w||(w=!0,a.resolve(k,x))},function(E){w||(w=!0,a.reject(k,E))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=-1,S=new this(s);++x<b;)T=y[x],v.resolve(T).then(function(k){w||(w=!0,a.resolve(S,k))},function(k){w||(w=!0,a.reject(S,k))});var T;return S}},{immediate:36}],38:[function(n,r,i){"use strict";var o={};(0,n("./lib/utils/common").assign)(o,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){"use strict";var o=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,d=0,f=-1,h=0,p=8;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({level:f,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=o.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&o.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?a.string2buf(v.dictionary):u.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=o.deflateSetDictionary(this.strm,w))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,v){var b,w,x=this.strm,S=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?x.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?x.input=new Uint8Array(y):x.input=y,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(S),x.next_out=0,x.avail_out=S),(b=o.deflate(x,w))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return w===4?(b=o.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):w!==2||(this.onEnd(d),!(x.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){"use strict";var o=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=n("./zlib/gzheader"),f=Object.prototype.toString;function h(m){if(!(this instanceof h))return new h(m);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var y=o.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,o.inflateGetHeader(this.strm,this.header)}function p(m,g){var y=new h(g);if(y.push(m,!0),y.err)throw y.msg||c[y.err];return y.result}h.prototype.push=function(m,g){var y,v,b,w,x,S,T=this.strm,k=this.options.chunkSize,C=this.options.dictionary,_=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?T.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?T.input=new Uint8Array(m):T.input=m,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(k),T.next_out=0,T.avail_out=k),(y=o.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(S=typeof C=="string"?a.string2buf(C):f.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=o.inflateSetDictionary(this.strm,S)),y===l.Z_BUF_ERROR&&_===!0&&(y=l.Z_OK,_=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==l.Z_STREAM_END&&(T.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(T.output,T.next_out),w=T.next_out-b,x=a.buf2string(T.output,b),T.next_out=w,T.avail_out=k-w,w&&s.arraySet(T.output,T.output,b,w,0),this.onData(x)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(_=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=o.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(m){this.chunks.push(m)},h.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=h,i.inflate=p,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,p(m,g)},i.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(l[d]=u[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,d,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+d),f);else for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){var c,u,d,f,h,p;for(c=d=0,u=l.length;c<u;c++)d+=l[c].length;for(p=new Uint8Array(d),c=f=0,u=l.length;c<u;c++)h=l[c],p.set(h,f),f+=h.length;return p}},a={arraySet:function(l,c,u,d,f){for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(o)},{}],42:[function(n,r,i){"use strict";var o=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new o.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(d,f){if(f<65537&&(d.subarray&&a||!d.subarray&&s))return String.fromCharCode.apply(null,o.shrinkBuf(d,f));for(var h="",p=0;p<f;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,i.string2buf=function(d){var f,h,p,m,g,y=d.length,v=0;for(m=0;m<y;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=new o.Buf8(v),m=g=0;g<v;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),h<128?f[g++]=h:(h<2048?f[g++]=192|h>>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(d){return u(d,d.length)},i.binstring2buf=function(d){for(var f=new o.Buf8(d.length),h=0,p=f.length;h<p;h++)f[h]=d.charCodeAt(h);return f},i.buf2string=function(d,f){var h,p,m,g,y=f||d.length,v=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)v[p++]=m;else if(4<(g=l[m]))v[p++]=65533,h+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&h<y;)m=m<<6|63&d[h++],g--;1<g?v[p++]=65533:m<65536?v[p++]=m:(m-=65536,v[p++]=55296|m>>10&1023,v[p++]=56320|1023&m)}return u(v,p)},i.utf8border=function(d,f){var h;for((f=f||d.length)>d.length&&(f=d.length),h=f-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?f:h+l[d[h]]>f?h:f}},{"./common":41}],43:[function(n,r,i){"use strict";r.exports=function(o,s,a,l){for(var c=65535&o|0,u=o>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;u=u+(c=c+s[l++]|0)|0,--d;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){"use strict";var o=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,c){var u=o,d=c+l;s^=-1;for(var f=c;f<d;f++)s=s>>>8^u[255&(s^a[f])];return-1^s}},{}],46:[function(n,r,i){"use strict";var o,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,f=4,h=0,p=-2,m=-1,g=4,y=2,v=8,b=9,w=286,x=30,S=19,T=2*w+1,k=15,C=3,_=258,P=_+C+1,E=42,L=113,R=1,O=2,F=3,B=4;function j(N,X){return N.msg=u[X],X}function M(N){return(N<<1)-(4<N?9:0)}function z(N){for(var X=N.length;0<=--X;)N[X]=0}function $(N){var X=N.state,ce=X.pending;ce>N.avail_out&&(ce=N.avail_out),ce!==0&&(s.arraySet(N.output,X.pending_buf,X.pending_out,ce,N.next_out),N.next_out+=ce,X.pending_out+=ce,N.total_out+=ce,N.avail_out-=ce,X.pending-=ce,X.pending===0&&(X.pending_out=0))}function K(N,X){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,X),N.block_start=N.strstart,$(N.strm)}function U(N,X){N.pending_buf[N.pending++]=X}function fe(N,X){N.pending_buf[N.pending++]=X>>>8&255,N.pending_buf[N.pending++]=255&X}function ee(N,X){var ce,te,ie=N.max_chain_length,q=N.strstart,Q=N.prev_length,le=N.nice_match,se=N.strstart>N.w_size-P?N.strstart-(N.w_size-P):0,me=N.window,Se=N.w_mask,Ee=N.prev,be=N.strstart+_,ue=me[q+Q-1],Ie=me[q+Q];N.prev_length>=N.good_match&&(ie>>=2),le>N.lookahead&&(le=N.lookahead);do if(me[(ce=X)+Q]===Ie&&me[ce+Q-1]===ue&&me[ce]===me[q]&&me[++ce]===me[q+1]){q+=2,ce++;do;while(me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&q<be);if(te=_-(be-q),q=be-_,Q<te){if(N.match_start=X,le<=(Q=te))break;ue=me[q+Q-1],Ie=me[q+Q]}}while((X=Ee[X&Se])>se&&--ie!=0);return Q<=N.lookahead?Q:N.lookahead}function Z(N){var X,ce,te,ie,q,Q,le,se,me,Se,Ee=N.w_size;do{if(ie=N.window_size-N.lookahead-N.strstart,N.strstart>=Ee+(Ee-P)){for(s.arraySet(N.window,N.window,Ee,Ee,0),N.match_start-=Ee,N.strstart-=Ee,N.block_start-=Ee,X=ce=N.hash_size;te=N.head[--X],N.head[X]=Ee<=te?te-Ee:0,--ce;);for(X=ce=Ee;te=N.prev[--X],N.prev[X]=Ee<=te?te-Ee:0,--ce;);ie+=Ee}if(N.strm.avail_in===0)break;if(Q=N.strm,le=N.window,se=N.strstart+N.lookahead,me=ie,Se=void 0,Se=Q.avail_in,me<Se&&(Se=me),ce=Se===0?0:(Q.avail_in-=Se,s.arraySet(le,Q.input,Q.next_in,Se,se),Q.state.wrap===1?Q.adler=l(Q.adler,le,Se,se):Q.state.wrap===2&&(Q.adler=c(Q.adler,le,Se,se)),Q.next_in+=Se,Q.total_in+=Se,Se),N.lookahead+=ce,N.lookahead+N.insert>=C)for(q=N.strstart-N.insert,N.ins_h=N.window[q],N.ins_h=(N.ins_h<<N.hash_shift^N.window[q+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[q+C-1])&N.hash_mask,N.prev[q&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=q,q++,N.insert--,!(N.lookahead+N.insert<C)););}while(N.lookahead<P&&N.strm.avail_in!==0)}function re(N,X){for(var ce,te;;){if(N.lookahead<P){if(Z(N),N.lookahead<P&&X===d)return R;if(N.lookahead===0)break}if(ce=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),ce!==0&&N.strstart-ce<=N.w_size-P&&(N.match_length=ee(N,ce)),N.match_length>=C)if(te=a._tr_tally(N,N.strstart-N.match_start,N.match_length-C),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=C){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart,--N.match_length!=0;);N.strstart++}else N.strstart+=N.match_length,N.match_length=0,N.ins_h=N.window[N.strstart],N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+1])&N.hash_mask;else te=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++;if(te&&(K(N,!1),N.strm.avail_out===0))return R}return N.insert=N.strstart<C-1?N.strstart:C-1,X===f?(K(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(K(N,!1),N.strm.avail_out===0)?R:O}function ve(N,X){for(var ce,te,ie;;){if(N.lookahead<P){if(Z(N),N.lookahead<P&&X===d)return R;if(N.lookahead===0)break}if(ce=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),N.prev_length=N.match_length,N.prev_match=N.match_start,N.match_length=C-1,ce!==0&&N.prev_length<N.max_lazy_match&&N.strstart-ce<=N.w_size-P&&(N.match_length=ee(N,ce),N.match_length<=5&&(N.strategy===1||N.match_length===C&&4096<N.strstart-N.match_start)&&(N.match_length=C-1)),N.prev_length>=C&&N.match_length<=N.prev_length){for(ie=N.strstart+N.lookahead-C,te=a._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-C),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=ie&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),--N.prev_length!=0;);if(N.match_available=0,N.match_length=C-1,N.strstart++,te&&(K(N,!1),N.strm.avail_out===0))return R}else if(N.match_available){if((te=a._tr_tally(N,0,N.window[N.strstart-1]))&&K(N,!1),N.strstart++,N.lookahead--,N.strm.avail_out===0)return R}else N.match_available=1,N.strstart++,N.lookahead--}return N.match_available&&(te=a._tr_tally(N,0,N.window[N.strstart-1]),N.match_available=0),N.insert=N.strstart<C-1?N.strstart:C-1,X===f?(K(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(K(N,!1),N.strm.avail_out===0)?R:O}function J(N,X,ce,te,ie){this.good_length=N,this.max_lazy=X,this.nice_length=ce,this.max_chain=te,this.func=ie}function ke(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*T),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*S+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(k+1),this.heap=new s.Buf16(2*w+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*w+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ae(N){var X;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(X=N.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?E:L,N.adler=X.wrap===2?0:1,X.last_flush=d,a._tr_init(X),h):j(N,p)}function G(N){var X=Ae(N);return X===h&&(function(ce){ce.window_size=2*ce.w_size,z(ce.head),ce.max_lazy_match=o[ce.level].max_lazy,ce.good_match=o[ce.level].good_length,ce.nice_match=o[ce.level].nice_length,ce.max_chain_length=o[ce.level].max_chain,ce.strstart=0,ce.block_start=0,ce.lookahead=0,ce.insert=0,ce.match_length=ce.prev_length=C-1,ce.match_available=0,ce.ins_h=0})(N.state),X}function D(N,X,ce,te,ie,q){if(!N)return p;var Q=1;if(X===m&&(X=6),te<0?(Q=0,te=-te):15<te&&(Q=2,te-=16),ie<1||b<ie||ce!==v||te<8||15<te||X<0||9<X||q<0||g<q)return j(N,p);te===8&&(te=9);var le=new ke;return(N.state=le).strm=N,le.wrap=Q,le.gzhead=null,le.w_bits=te,le.w_size=1<<le.w_bits,le.w_mask=le.w_size-1,le.hash_bits=ie+7,le.hash_size=1<<le.hash_bits,le.hash_mask=le.hash_size-1,le.hash_shift=~~((le.hash_bits+C-1)/C),le.window=new s.Buf8(2*le.w_size),le.head=new s.Buf16(le.hash_size),le.prev=new s.Buf16(le.w_size),le.lit_bufsize=1<<ie+6,le.pending_buf_size=4*le.lit_bufsize,le.pending_buf=new s.Buf8(le.pending_buf_size),le.d_buf=1*le.lit_bufsize,le.l_buf=3*le.lit_bufsize,le.level=X,le.strategy=q,le.method=ce,G(N)}o=[new J(0,0,0,0,function(N,X){var ce=65535;for(ce>N.pending_buf_size-5&&(ce=N.pending_buf_size-5);;){if(N.lookahead<=1){if(Z(N),N.lookahead===0&&X===d)return R;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var te=N.block_start+ce;if((N.strstart===0||N.strstart>=te)&&(N.lookahead=N.strstart-te,N.strstart=te,K(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-P&&(K(N,!1),N.strm.avail_out===0))return R}return N.insert=0,X===f?(K(N,!0),N.strm.avail_out===0?F:B):(N.strstart>N.block_start&&(K(N,!1),N.strm.avail_out),R)}),new J(4,4,8,4,re),new J(4,5,16,8,re),new J(4,6,32,32,re),new J(4,4,16,16,ve),new J(8,16,32,32,ve),new J(8,16,128,128,ve),new J(8,32,128,256,ve),new J(32,128,258,1024,ve),new J(32,258,258,4096,ve)],i.deflateInit=function(N,X){return D(N,X,v,15,8,0)},i.deflateInit2=D,i.deflateReset=G,i.deflateResetKeep=Ae,i.deflateSetHeader=function(N,X){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=X,h):p},i.deflate=function(N,X){var ce,te,ie,q;if(!N||!N.state||5<X||X<0)return N?j(N,p):p;if(te=N.state,!N.output||!N.input&&N.avail_in!==0||te.status===666&&X!==f)return j(N,N.avail_out===0?-5:p);if(te.strm=N,ce=te.last_flush,te.last_flush=X,te.status===E)if(te.wrap===2)N.adler=0,U(te,31),U(te,139),U(te,8),te.gzhead?(U(te,(te.gzhead.text?1:0)+(te.gzhead.hcrc?2:0)+(te.gzhead.extra?4:0)+(te.gzhead.name?8:0)+(te.gzhead.comment?16:0)),U(te,255&te.gzhead.time),U(te,te.gzhead.time>>8&255),U(te,te.gzhead.time>>16&255),U(te,te.gzhead.time>>24&255),U(te,te.level===9?2:2<=te.strategy||te.level<2?4:0),U(te,255&te.gzhead.os),te.gzhead.extra&&te.gzhead.extra.length&&(U(te,255&te.gzhead.extra.length),U(te,te.gzhead.extra.length>>8&255)),te.gzhead.hcrc&&(N.adler=c(N.adler,te.pending_buf,te.pending,0)),te.gzindex=0,te.status=69):(U(te,0),U(te,0),U(te,0),U(te,0),U(te,0),U(te,te.level===9?2:2<=te.strategy||te.level<2?4:0),U(te,3),te.status=L);else{var Q=v+(te.w_bits-8<<4)<<8;Q|=(2<=te.strategy||te.level<2?0:te.level<6?1:te.level===6?2:3)<<6,te.strstart!==0&&(Q|=32),Q+=31-Q%31,te.status=L,fe(te,Q),te.strstart!==0&&(fe(te,N.adler>>>16),fe(te,65535&N.adler)),N.adler=1}if(te.status===69)if(te.gzhead.extra){for(ie=te.pending;te.gzindex<(65535&te.gzhead.extra.length)&&(te.pending!==te.pending_buf_size||(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending!==te.pending_buf_size));)U(te,255&te.gzhead.extra[te.gzindex]),te.gzindex++;te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),te.gzindex===te.gzhead.extra.length&&(te.gzindex=0,te.status=73)}else te.status=73;if(te.status===73)if(te.gzhead.name){ie=te.pending;do{if(te.pending===te.pending_buf_size&&(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending===te.pending_buf_size)){q=1;break}q=te.gzindex<te.gzhead.name.length?255&te.gzhead.name.charCodeAt(te.gzindex++):0,U(te,q)}while(q!==0);te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),q===0&&(te.gzindex=0,te.status=91)}else te.status=91;if(te.status===91)if(te.gzhead.comment){ie=te.pending;do{if(te.pending===te.pending_buf_size&&(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending===te.pending_buf_size)){q=1;break}q=te.gzindex<te.gzhead.comment.length?255&te.gzhead.comment.charCodeAt(te.gzindex++):0,U(te,q)}while(q!==0);te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),q===0&&(te.status=103)}else te.status=103;if(te.status===103&&(te.gzhead.hcrc?(te.pending+2>te.pending_buf_size&&$(N),te.pending+2<=te.pending_buf_size&&(U(te,255&N.adler),U(te,N.adler>>8&255),N.adler=0,te.status=L)):te.status=L),te.pending!==0){if($(N),N.avail_out===0)return te.last_flush=-1,h}else if(N.avail_in===0&&M(X)<=M(ce)&&X!==f)return j(N,-5);if(te.status===666&&N.avail_in!==0)return j(N,-5);if(N.avail_in!==0||te.lookahead!==0||X!==d&&te.status!==666){var le=te.strategy===2?(function(se,me){for(var Se;;){if(se.lookahead===0&&(Z(se),se.lookahead===0)){if(me===d)return R;break}if(se.match_length=0,Se=a._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++,Se&&(K(se,!1),se.strm.avail_out===0))return R}return se.insert=0,me===f?(K(se,!0),se.strm.avail_out===0?F:B):se.last_lit&&(K(se,!1),se.strm.avail_out===0)?R:O})(te,X):te.strategy===3?(function(se,me){for(var Se,Ee,be,ue,Ie=se.window;;){if(se.lookahead<=_){if(Z(se),se.lookahead<=_&&me===d)return R;if(se.lookahead===0)break}if(se.match_length=0,se.lookahead>=C&&0<se.strstart&&(Ee=Ie[be=se.strstart-1])===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]){ue=se.strstart+_;do;while(Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&be<ue);se.match_length=_-(ue-be),se.match_length>se.lookahead&&(se.match_length=se.lookahead)}if(se.match_length>=C?(Se=a._tr_tally(se,1,se.match_length-C),se.lookahead-=se.match_length,se.strstart+=se.match_length,se.match_length=0):(Se=a._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++),Se&&(K(se,!1),se.strm.avail_out===0))return R}return se.insert=0,me===f?(K(se,!0),se.strm.avail_out===0?F:B):se.last_lit&&(K(se,!1),se.strm.avail_out===0)?R:O})(te,X):o[te.level].func(te,X);if(le!==F&&le!==B||(te.status=666),le===R||le===F)return N.avail_out===0&&(te.last_flush=-1),h;if(le===O&&(X===1?a._tr_align(te):X!==5&&(a._tr_stored_block(te,0,0,!1),X===3&&(z(te.head),te.lookahead===0&&(te.strstart=0,te.block_start=0,te.insert=0))),$(N),N.avail_out===0))return te.last_flush=-1,h}return X!==f?h:te.wrap<=0?1:(te.wrap===2?(U(te,255&N.adler),U(te,N.adler>>8&255),U(te,N.adler>>16&255),U(te,N.adler>>24&255),U(te,255&N.total_in),U(te,N.total_in>>8&255),U(te,N.total_in>>16&255),U(te,N.total_in>>24&255)):(fe(te,N.adler>>>16),fe(te,65535&N.adler)),$(N),0<te.wrap&&(te.wrap=-te.wrap),te.pending!==0?h:1)},i.deflateEnd=function(N){var X;return N&&N.state?(X=N.state.status)!==E&&X!==69&&X!==73&&X!==91&&X!==103&&X!==L&&X!==666?j(N,p):(N.state=null,X===L?j(N,-3):h):p},i.deflateSetDictionary=function(N,X){var ce,te,ie,q,Q,le,se,me,Se=X.length;if(!N||!N.state||(q=(ce=N.state).wrap)===2||q===1&&ce.status!==E||ce.lookahead)return p;for(q===1&&(N.adler=l(N.adler,X,Se,0)),ce.wrap=0,Se>=ce.w_size&&(q===0&&(z(ce.head),ce.strstart=0,ce.block_start=0,ce.insert=0),me=new s.Buf8(ce.w_size),s.arraySet(me,X,Se-ce.w_size,ce.w_size,0),X=me,Se=ce.w_size),Q=N.avail_in,le=N.next_in,se=N.input,N.avail_in=Se,N.next_in=0,N.input=X,Z(ce);ce.lookahead>=C;){for(te=ce.strstart,ie=ce.lookahead-(C-1);ce.ins_h=(ce.ins_h<<ce.hash_shift^ce.window[te+C-1])&ce.hash_mask,ce.prev[te&ce.w_mask]=ce.head[ce.ins_h],ce.head[ce.ins_h]=te,te++,--ie;);ce.strstart=te,ce.lookahead=C-1,Z(ce)}return ce.strstart+=ce.lookahead,ce.block_start=ce.strstart,ce.insert=ce.lookahead,ce.lookahead=0,ce.match_length=ce.prev_length=C-1,ce.match_available=0,N.next_in=le,N.input=se,N.avail_in=Q,ce.wrap=q,h},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){"use strict";r.exports=function(o,s){var a=o.state,l=o.next_in,c,u,d,f,h,p,m,g,y,v,b,w,x,S,T,k,C,_,P,E,L,R=o.input,O;c=l+(o.avail_in-5),u=o.next_out,O=o.output,d=u-(s-o.avail_out),f=u+(o.avail_out-257),h=a.dmax,p=a.wsize,m=a.whave,g=a.wnext,y=a.window,v=a.hold,b=a.bits,w=a.lencode,x=a.distcode,S=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),k=w[v&S];t:for(;;){if(v>>>=C=k>>>24,b-=C,(C=k>>>16&255)===0)O[u++]=65535&k;else{if(!(16&C)){if((64&C)==0){k=w[(65535&k)+(v&(1<<C)-1)];continue t}if(32&C){a.mode=12;break e}o.msg="invalid literal/length code",a.mode=30;break e}_=65535&k,(C&=15)&&(b<C&&(v+=R[l++]<<b,b+=8),_+=v&(1<<C)-1,v>>>=C,b-=C),b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),k=x[v&T];n:for(;;){if(v>>>=C=k>>>24,b-=C,!(16&(C=k>>>16&255))){if((64&C)==0){k=x[(65535&k)+(v&(1<<C)-1)];continue n}o.msg="invalid distance code",a.mode=30;break e}if(P=65535&k,b<(C&=15)&&(v+=R[l++]<<b,(b+=8)<C&&(v+=R[l++]<<b,b+=8)),h<(P+=v&(1<<C)-1)){o.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=C,b-=C,(C=u-d)<P){if(m<(C=P-C)&&a.sane){o.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(E=0)===g){if(E+=p-C,C<_){for(_-=C;O[u++]=y[E++],--C;);E=u-P,L=O}}else if(g<C){if(E+=p+g-C,(C-=g)<_){for(_-=C;O[u++]=y[E++],--C;);if(E=0,g<_){for(_-=C=g;O[u++]=y[E++],--C;);E=u-P,L=O}}}else if(E+=g-C,C<_){for(_-=C;O[u++]=y[E++],--C;);E=u-P,L=O}for(;2<_;)O[u++]=L[E++],O[u++]=L[E++],O[u++]=L[E++],_-=3;_&&(O[u++]=L[E++],1<_&&(O[u++]=L[E++]))}else{for(E=u-P;O[u++]=O[E++],O[u++]=O[E++],O[u++]=O[E++],2<(_-=3););_&&(O[u++]=O[E++],1<_&&(O[u++]=O[E++]))}break}}break}}while(l<c&&u<f);l-=_=b>>3,v&=(1<<(b-=_<<3))-1,o.next_in=l,o.next_out=u,o.avail_in=l<c?c-l+5:5-(l-c),o.avail_out=u<f?f-u+257:257-(u-f),a.hold=v,a.bits=b}},{}],49:[function(n,r,i){"use strict";var o=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,d=2,f=0,h=-2,p=1,m=852,g=592;function y(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(E){var L;return E&&E.state?(L=E.state,E.total_in=E.total_out=L.total=0,E.msg="",L.wrap&&(E.adler=1&L.wrap),L.mode=p,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new o.Buf32(m),L.distcode=L.distdyn=new o.Buf32(g),L.sane=1,L.back=-1,f):h}function w(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,b(E)):h}function x(E,L){var R,O;return E&&E.state?(O=E.state,L<0?(R=0,L=-L):(R=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=R,O.wbits=L,w(E))):h}function S(E,L){var R,O;return E?(O=new v,(E.state=O).window=null,(R=x(E,L))!==f&&(E.state=null),R):h}var T,k,C=!0;function _(E){if(C){var L;for(T=new o.Buf32(512),k=new o.Buf32(32),L=0;L<144;)E.lens[L++]=8;for(;L<256;)E.lens[L++]=9;for(;L<280;)E.lens[L++]=7;for(;L<288;)E.lens[L++]=8;for(c(u,E.lens,0,288,T,0,E.work,{bits:9}),L=0;L<32;)E.lens[L++]=5;c(d,E.lens,0,32,k,0,E.work,{bits:5}),C=!1}E.lencode=T,E.lenbits=9,E.distcode=k,E.distbits=5}function P(E,L,R,O){var F,B=E.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new o.Buf8(B.wsize)),O>=B.wsize?(o.arraySet(B.window,L,R-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(O<(F=B.wsize-B.wnext)&&(F=O),o.arraySet(B.window,L,R-O,F,B.wnext),(O-=F)?(o.arraySet(B.window,L,R-O,O,0),B.wnext=O,B.whave=B.wsize):(B.wnext+=F,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=F))),0}i.inflateReset=w,i.inflateReset2=x,i.inflateResetKeep=b,i.inflateInit=function(E){return S(E,15)},i.inflateInit2=S,i.inflate=function(E,L){var R,O,F,B,j,M,z,$,K,U,fe,ee,Z,re,ve,J,ke,Ae,G,D,N,X,ce,te,ie=0,q=new o.Buf8(4),Q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return h;(R=E.state).mode===12&&(R.mode=13),j=E.next_out,F=E.output,z=E.avail_out,B=E.next_in,O=E.input,M=E.avail_in,$=R.hold,K=R.bits,U=M,fe=z,X=f;e:for(;;)switch(R.mode){case p:if(R.wrap===0){R.mode=13;break}for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(2&R.wrap&&$===35615){q[R.check=0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0),K=$=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&$)<<8)+($>>8))%31){E.msg="incorrect header check",R.mode=30;break}if((15&$)!=8){E.msg="unknown compression method",R.mode=30;break}if(K-=4,N=8+(15&($>>>=4)),R.wbits===0)R.wbits=N;else if(N>R.wbits){E.msg="invalid window size",R.mode=30;break}R.dmax=1<<N,E.adler=R.check=1,R.mode=512&$?10:12,K=$=0;break;case 2:for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(R.flags=$,(255&R.flags)!=8){E.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){E.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=$>>8&1),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0,R.mode=3;case 3:for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.head&&(R.head.time=$),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,q[2]=$>>>16&255,q[3]=$>>>24&255,R.check=a(R.check,q,4,0)),K=$=0,R.mode=4;case 4:for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.head&&(R.head.xflags=255&$,R.head.os=$>>8),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0,R.mode=5;case 5:if(1024&R.flags){for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.length=$,R.head&&(R.head.extra_len=$),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(M<(ee=R.length)&&(ee=M),ee&&(R.head&&(N=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),o.arraySet(R.head.extra,O,B,ee,N)),512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,R.length-=ee),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(M===0)break e;for(ee=0;N=O[B+ee++],R.head&&N&&R.length<65536&&(R.head.name+=String.fromCharCode(N)),N&&ee<M;);if(512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,N)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(M===0)break e;for(ee=0;N=O[B+ee++],R.head&&N&&R.length<65536&&(R.head.comment+=String.fromCharCode(N)),N&&ee<M;);if(512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,N)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($!==(65535&R.check)){E.msg="header crc mismatch",R.mode=30;break}K=$=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),E.adler=R.check=0,R.mode=12;break;case 10:for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}E.adler=R.check=y($),K=$=0,R.mode=11;case 11:if(R.havedict===0)return E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,2;E.adler=R.check=1,R.mode=12;case 12:if(L===5||L===6)break e;case 13:if(R.last){$>>>=7&K,K-=7&K,R.mode=27;break}for(;K<3;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}switch(R.last=1&$,K-=1,3&($>>>=1)){case 0:R.mode=14;break;case 1:if(_(R),R.mode=20,L!==6)break;$>>>=2,K-=2;break e;case 2:R.mode=17;break;case 3:E.msg="invalid block type",R.mode=30}$>>>=2,K-=2;break;case 14:for($>>>=7&K,K-=7&K;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if((65535&$)!=($>>>16^65535)){E.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&$,K=$=0,R.mode=15,L===6)break e;case 15:R.mode=16;case 16:if(ee=R.length){if(M<ee&&(ee=M),z<ee&&(ee=z),ee===0)break e;o.arraySet(F,O,B,ee,j),M-=ee,B+=ee,z-=ee,j+=ee,R.length-=ee;break}R.mode=12;break;case 17:for(;K<14;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(R.nlen=257+(31&$),$>>>=5,K-=5,R.ndist=1+(31&$),$>>>=5,K-=5,R.ncode=4+(15&$),$>>>=4,K-=4,286<R.nlen||30<R.ndist){E.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;K<3;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.lens[Q[R.have++]]=7&$,$>>>=3,K-=3}for(;R.have<19;)R.lens[Q[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ce={bits:R.lenbits},X=c(0,R.lens,0,19,R.lencode,0,R.work,ce),R.lenbits=ce.bits,X){E.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;J=(ie=R.lencode[$&(1<<R.lenbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(ke<16)$>>>=ve,K-=ve,R.lens[R.have++]=ke;else{if(ke===16){for(te=ve+2;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($>>>=ve,K-=ve,R.have===0){E.msg="invalid bit length repeat",R.mode=30;break}N=R.lens[R.have-1],ee=3+(3&$),$>>>=2,K-=2}else if(ke===17){for(te=ve+3;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}K-=ve,N=0,ee=3+(7&($>>>=ve)),$>>>=3,K-=3}else{for(te=ve+7;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}K-=ve,N=0,ee=11+(127&($>>>=ve)),$>>>=7,K-=7}if(R.have+ee>R.nlen+R.ndist){E.msg="invalid bit length repeat",R.mode=30;break}for(;ee--;)R.lens[R.have++]=N}}if(R.mode===30)break;if(R.lens[256]===0){E.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ce={bits:R.lenbits},X=c(u,R.lens,0,R.nlen,R.lencode,0,R.work,ce),R.lenbits=ce.bits,X){E.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ce={bits:R.distbits},X=c(d,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ce),R.distbits=ce.bits,X){E.msg="invalid distances set",R.mode=30;break}if(R.mode=20,L===6)break e;case 20:R.mode=21;case 21:if(6<=M&&258<=z){E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,l(E,fe),j=E.next_out,F=E.output,z=E.avail_out,B=E.next_in,O=E.input,M=E.avail_in,$=R.hold,K=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;J=(ie=R.lencode[$&(1<<R.lenbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(J&&(240&J)==0){for(Ae=ve,G=J,D=ke;J=(ie=R.lencode[D+(($&(1<<Ae+G)-1)>>Ae)])>>>16&255,ke=65535&ie,!(Ae+(ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}$>>>=Ae,K-=Ae,R.back+=Ae}if($>>>=ve,K-=ve,R.back+=ve,R.length=ke,J===0){R.mode=26;break}if(32&J){R.back=-1,R.mode=12;break}if(64&J){E.msg="invalid literal/length code",R.mode=30;break}R.extra=15&J,R.mode=22;case 22:if(R.extra){for(te=R.extra;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.length+=$&(1<<R.extra)-1,$>>>=R.extra,K-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;J=(ie=R.distcode[$&(1<<R.distbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if((240&J)==0){for(Ae=ve,G=J,D=ke;J=(ie=R.distcode[D+(($&(1<<Ae+G)-1)>>Ae)])>>>16&255,ke=65535&ie,!(Ae+(ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}$>>>=Ae,K-=Ae,R.back+=Ae}if($>>>=ve,K-=ve,R.back+=ve,64&J){E.msg="invalid distance code",R.mode=30;break}R.offset=ke,R.extra=15&J,R.mode=24;case 24:if(R.extra){for(te=R.extra;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.offset+=$&(1<<R.extra)-1,$>>>=R.extra,K-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){E.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(z===0)break e;if(ee=fe-z,R.offset>ee){if((ee=R.offset-ee)>R.whave&&R.sane){E.msg="invalid distance too far back",R.mode=30;break}Z=ee>R.wnext?(ee-=R.wnext,R.wsize-ee):R.wnext-ee,ee>R.length&&(ee=R.length),re=R.window}else re=F,Z=j-R.offset,ee=R.length;for(z<ee&&(ee=z),z-=ee,R.length-=ee;F[j++]=re[Z++],--ee;);R.length===0&&(R.mode=21);break;case 26:if(z===0)break e;F[j++]=R.length,z--,R.mode=21;break;case 27:if(R.wrap){for(;K<32;){if(M===0)break e;M--,$|=O[B++]<<K,K+=8}if(fe-=z,E.total_out+=fe,R.total+=fe,fe&&(E.adler=R.check=R.flags?a(R.check,F,fe,j-fe):s(R.check,F,fe,j-fe)),fe=z,(R.flags?$:y($))!==R.check){E.msg="incorrect data check",R.mode=30;break}K=$=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($!==(4294967295&R.total)){E.msg="incorrect length check",R.mode=30;break}K=$=0}R.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;default:return h}return E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,(R.wsize||fe!==E.avail_out&&R.mode<30&&(R.mode<27||L!==4))&&P(E,E.output,E.next_out,fe-E.avail_out)?(R.mode=31,-4):(U-=E.avail_in,fe-=E.avail_out,E.total_in+=U,E.total_out+=fe,R.total+=fe,R.wrap&&fe&&(E.adler=R.check=R.flags?a(R.check,F,fe,E.next_out-fe):s(R.check,F,fe,E.next_out-fe)),E.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(U==0&&fe===0||L===4)&&X===f&&(X=-5),X)},i.inflateEnd=function(E){if(!E||!E.state)return h;var L=E.state;return L.window&&(L.window=null),E.state=null,f},i.inflateGetHeader=function(E,L){var R;return E&&E.state?(2&(R=E.state).wrap)==0?h:((R.head=L).done=!1,f):h},i.inflateSetDictionary=function(E,L){var R,O=L.length;return E&&E.state?(R=E.state).wrap!==0&&R.mode!==11?h:R.mode===11&&s(1,L,O,0)!==R.check?-3:P(E,L,O,O)?(R.mode=31,-4):(R.havedict=1,f):h},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){"use strict";var o=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,d,f,h,p,m,g,y){var v,b,w,x,S,T,k,C,_,P=y.bits,E=0,L=0,R=0,O=0,F=0,B=0,j=0,M=0,z=0,$=0,K=null,U=0,fe=new o.Buf16(16),ee=new o.Buf16(16),Z=null,re=0;for(E=0;E<=15;E++)fe[E]=0;for(L=0;L<h;L++)fe[d[f+L]]++;for(F=P,O=15;1<=O&&fe[O]===0;O--);if(O<F&&(F=O),O===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(R=1;R<O&&fe[R]===0;R++);for(F<R&&(F=R),E=M=1;E<=15;E++)if(M<<=1,(M-=fe[E])<0)return-1;if(0<M&&(u===0||O!==1))return-1;for(ee[1]=0,E=1;E<15;E++)ee[E+1]=ee[E]+fe[E];for(L=0;L<h;L++)d[f+L]!==0&&(g[ee[d[f+L]]++]=L);if(T=u===0?(K=Z=g,19):u===1?(K=s,U-=257,Z=a,re-=257,256):(K=l,Z=c,-1),E=R,S=m,j=L=$=0,w=-1,x=(z=1<<(B=F))-1,u===1&&852<z||u===2&&592<z)return 1;for(;;){for(k=E-j,_=g[L]<T?(C=0,g[L]):g[L]>T?(C=Z[re+g[L]],K[U+g[L]]):(C=96,0),v=1<<E-j,R=b=1<<B;p[S+($>>j)+(b-=v)]=k<<24|C<<16|_|0,b!==0;);for(v=1<<E-1;$&v;)v>>=1;if(v!==0?($&=v-1,$+=v):$=0,L++,--fe[E]==0){if(E===O)break;E=d[f+g[L]]}if(F<E&&($&x)!==w){for(j===0&&(j=F),S+=R,M=1<<(B=E-j);B+j<O&&!((M-=fe[B+j])<=0);)B++,M<<=1;if(z+=1<<B,u===1&&852<z||u===2&&592<z)return 1;p[w=$&x]=F<<24|B<<16|S-m|0}}return $!==0&&(p[S+$]=E-j<<24|4194304),y.bits=F,0}},{"../utils/common":41}],51:[function(n,r,i){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){"use strict";var o=n("../utils/common"),s=0,a=1;function l(ie){for(var q=ie.length;0<=--q;)ie[q]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,v=7,b=256,w=16,x=17,S=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],P=new Array(2*(f+2));l(P);var E=new Array(2*h);l(E);var L=new Array(512);l(L);var R=new Array(256);l(R);var O=new Array(u);l(O);var F,B,j,M=new Array(h);function z(ie,q,Q,le,se){this.static_tree=ie,this.extra_bits=q,this.extra_base=Q,this.elems=le,this.max_length=se,this.has_stree=ie&&ie.length}function $(ie,q){this.dyn_tree=ie,this.max_code=0,this.stat_desc=q}function K(ie){return ie<256?L[ie]:L[256+(ie>>>7)]}function U(ie,q){ie.pending_buf[ie.pending++]=255&q,ie.pending_buf[ie.pending++]=q>>>8&255}function fe(ie,q,Q){ie.bi_valid>y-Q?(ie.bi_buf|=q<<ie.bi_valid&65535,U(ie,ie.bi_buf),ie.bi_buf=q>>y-ie.bi_valid,ie.bi_valid+=Q-y):(ie.bi_buf|=q<<ie.bi_valid&65535,ie.bi_valid+=Q)}function ee(ie,q,Q){fe(ie,Q[2*q],Q[2*q+1])}function Z(ie,q){for(var Q=0;Q|=1&ie,ie>>>=1,Q<<=1,0<--q;);return Q>>>1}function re(ie,q,Q){var le,se,me=new Array(g+1),Se=0;for(le=1;le<=g;le++)me[le]=Se=Se+Q[le-1]<<1;for(se=0;se<=q;se++){var Ee=ie[2*se+1];Ee!==0&&(ie[2*se]=Z(me[Ee]++,Ee))}}function ve(ie){var q;for(q=0;q<f;q++)ie.dyn_ltree[2*q]=0;for(q=0;q<h;q++)ie.dyn_dtree[2*q]=0;for(q=0;q<p;q++)ie.bl_tree[2*q]=0;ie.dyn_ltree[2*b]=1,ie.opt_len=ie.static_len=0,ie.last_lit=ie.matches=0}function J(ie){8<ie.bi_valid?U(ie,ie.bi_buf):0<ie.bi_valid&&(ie.pending_buf[ie.pending++]=ie.bi_buf),ie.bi_buf=0,ie.bi_valid=0}function ke(ie,q,Q,le){var se=2*q,me=2*Q;return ie[se]<ie[me]||ie[se]===ie[me]&&le[q]<=le[Q]}function Ae(ie,q,Q){for(var le=ie.heap[Q],se=Q<<1;se<=ie.heap_len&&(se<ie.heap_len&&ke(q,ie.heap[se+1],ie.heap[se],ie.depth)&&se++,!ke(q,le,ie.heap[se],ie.depth));)ie.heap[Q]=ie.heap[se],Q=se,se<<=1;ie.heap[Q]=le}function G(ie,q,Q){var le,se,me,Se,Ee=0;if(ie.last_lit!==0)for(;le=ie.pending_buf[ie.d_buf+2*Ee]<<8|ie.pending_buf[ie.d_buf+2*Ee+1],se=ie.pending_buf[ie.l_buf+Ee],Ee++,le===0?ee(ie,se,q):(ee(ie,(me=R[se])+d+1,q),(Se=T[me])!==0&&fe(ie,se-=O[me],Se),ee(ie,me=K(--le),Q),(Se=k[me])!==0&&fe(ie,le-=M[me],Se)),Ee<ie.last_lit;);ee(ie,b,q)}function D(ie,q){var Q,le,se,me=q.dyn_tree,Se=q.stat_desc.static_tree,Ee=q.stat_desc.has_stree,be=q.stat_desc.elems,ue=-1;for(ie.heap_len=0,ie.heap_max=m,Q=0;Q<be;Q++)me[2*Q]!==0?(ie.heap[++ie.heap_len]=ue=Q,ie.depth[Q]=0):me[2*Q+1]=0;for(;ie.heap_len<2;)me[2*(se=ie.heap[++ie.heap_len]=ue<2?++ue:0)]=1,ie.depth[se]=0,ie.opt_len--,Ee&&(ie.static_len-=Se[2*se+1]);for(q.max_code=ue,Q=ie.heap_len>>1;1<=Q;Q--)Ae(ie,me,Q);for(se=be;Q=ie.heap[1],ie.heap[1]=ie.heap[ie.heap_len--],Ae(ie,me,1),le=ie.heap[1],ie.heap[--ie.heap_max]=Q,ie.heap[--ie.heap_max]=le,me[2*se]=me[2*Q]+me[2*le],ie.depth[se]=(ie.depth[Q]>=ie.depth[le]?ie.depth[Q]:ie.depth[le])+1,me[2*Q+1]=me[2*le+1]=se,ie.heap[1]=se++,Ae(ie,me,1),2<=ie.heap_len;);ie.heap[--ie.heap_max]=ie.heap[1],(function(Ie,Le){var Xe,nt,he,xe,ge,pe,we=Le.dyn_tree,oe=Le.max_code,je=Le.stat_desc.static_tree,Y=Le.stat_desc.has_stree,Te=Le.stat_desc.extra_bits,Ke=Le.stat_desc.extra_base,de=Le.stat_desc.max_length,st=0;for(xe=0;xe<=g;xe++)Ie.bl_count[xe]=0;for(we[2*Ie.heap[Ie.heap_max]+1]=0,Xe=Ie.heap_max+1;Xe<m;Xe++)de<(xe=we[2*we[2*(nt=Ie.heap[Xe])+1]+1]+1)&&(xe=de,st++),we[2*nt+1]=xe,oe<nt||(Ie.bl_count[xe]++,ge=0,Ke<=nt&&(ge=Te[nt-Ke]),pe=we[2*nt],Ie.opt_len+=pe*(xe+ge),Y&&(Ie.static_len+=pe*(je[2*nt+1]+ge)));if(st!==0){do{for(xe=de-1;Ie.bl_count[xe]===0;)xe--;Ie.bl_count[xe]--,Ie.bl_count[xe+1]+=2,Ie.bl_count[de]--,st-=2}while(0<st);for(xe=de;xe!==0;xe--)for(nt=Ie.bl_count[xe];nt!==0;)oe<(he=Ie.heap[--Xe])||(we[2*he+1]!==xe&&(Ie.opt_len+=(xe-we[2*he+1])*we[2*he],we[2*he+1]=xe),nt--)}})(ie,q),re(me,ue,ie.bl_count)}function N(ie,q,Q){var le,se,me=-1,Se=q[1],Ee=0,be=7,ue=4;for(Se===0&&(be=138,ue=3),q[2*(Q+1)+1]=65535,le=0;le<=Q;le++)se=Se,Se=q[2*(le+1)+1],++Ee<be&&se===Se||(Ee<ue?ie.bl_tree[2*se]+=Ee:se!==0?(se!==me&&ie.bl_tree[2*se]++,ie.bl_tree[2*w]++):Ee<=10?ie.bl_tree[2*x]++:ie.bl_tree[2*S]++,me=se,ue=(Ee=0)===Se?(be=138,3):se===Se?(be=6,3):(be=7,4))}function X(ie,q,Q){var le,se,me=-1,Se=q[1],Ee=0,be=7,ue=4;for(Se===0&&(be=138,ue=3),le=0;le<=Q;le++)if(se=Se,Se=q[2*(le+1)+1],!(++Ee<be&&se===Se)){if(Ee<ue)for(;ee(ie,se,ie.bl_tree),--Ee!=0;);else se!==0?(se!==me&&(ee(ie,se,ie.bl_tree),Ee--),ee(ie,w,ie.bl_tree),fe(ie,Ee-3,2)):Ee<=10?(ee(ie,x,ie.bl_tree),fe(ie,Ee-3,3)):(ee(ie,S,ie.bl_tree),fe(ie,Ee-11,7));me=se,ue=(Ee=0)===Se?(be=138,3):se===Se?(be=6,3):(be=7,4)}}l(M);var ce=!1;function te(ie,q,Q,le){fe(ie,(c<<1)+(le?1:0),3),(function(se,me,Se,Ee){J(se),Ee&&(U(se,Se),U(se,~Se)),o.arraySet(se.pending_buf,se.window,me,Se,se.pending),se.pending+=Se})(ie,q,Q,!0)}i._tr_init=function(ie){ce||((function(){var q,Q,le,se,me,Se=new Array(g+1);for(se=le=0;se<u-1;se++)for(O[se]=le,q=0;q<1<<T[se];q++)R[le++]=se;for(R[le-1]=se,se=me=0;se<16;se++)for(M[se]=me,q=0;q<1<<k[se];q++)L[me++]=se;for(me>>=7;se<h;se++)for(M[se]=me<<7,q=0;q<1<<k[se]-7;q++)L[256+me++]=se;for(Q=0;Q<=g;Q++)Se[Q]=0;for(q=0;q<=143;)P[2*q+1]=8,q++,Se[8]++;for(;q<=255;)P[2*q+1]=9,q++,Se[9]++;for(;q<=279;)P[2*q+1]=7,q++,Se[7]++;for(;q<=287;)P[2*q+1]=8,q++,Se[8]++;for(re(P,f+1,Se),q=0;q<h;q++)E[2*q+1]=5,E[2*q]=Z(q,5);F=new z(P,T,d+1,f,g),B=new z(E,k,0,h,g),j=new z(new Array(0),C,0,p,v)})(),ce=!0),ie.l_desc=new $(ie.dyn_ltree,F),ie.d_desc=new $(ie.dyn_dtree,B),ie.bl_desc=new $(ie.bl_tree,j),ie.bi_buf=0,ie.bi_valid=0,ve(ie)},i._tr_stored_block=te,i._tr_flush_block=function(ie,q,Q,le){var se,me,Se=0;0<ie.level?(ie.strm.data_type===2&&(ie.strm.data_type=(function(Ee){var be,ue=4093624447;for(be=0;be<=31;be++,ue>>>=1)if(1&ue&&Ee.dyn_ltree[2*be]!==0)return s;if(Ee.dyn_ltree[18]!==0||Ee.dyn_ltree[20]!==0||Ee.dyn_ltree[26]!==0)return a;for(be=32;be<d;be++)if(Ee.dyn_ltree[2*be]!==0)return a;return s})(ie)),D(ie,ie.l_desc),D(ie,ie.d_desc),Se=(function(Ee){var be;for(N(Ee,Ee.dyn_ltree,Ee.l_desc.max_code),N(Ee,Ee.dyn_dtree,Ee.d_desc.max_code),D(Ee,Ee.bl_desc),be=p-1;3<=be&&Ee.bl_tree[2*_[be]+1]===0;be--);return Ee.opt_len+=3*(be+1)+5+5+4,be})(ie),se=ie.opt_len+3+7>>>3,(me=ie.static_len+3+7>>>3)<=se&&(se=me)):se=me=Q+5,Q+4<=se&&q!==-1?te(ie,q,Q,le):ie.strategy===4||me===se?(fe(ie,2+(le?1:0),3),G(ie,P,E)):(fe(ie,4+(le?1:0),3),(function(Ee,be,ue,Ie){var Le;for(fe(Ee,be-257,5),fe(Ee,ue-1,5),fe(Ee,Ie-4,4),Le=0;Le<Ie;Le++)fe(Ee,Ee.bl_tree[2*_[Le]+1],3);X(Ee,Ee.dyn_ltree,be-1),X(Ee,Ee.dyn_dtree,ue-1)})(ie,ie.l_desc.max_code+1,ie.d_desc.max_code+1,Se+1),G(ie,ie.dyn_ltree,ie.dyn_dtree)),ve(ie),le&&J(ie)},i._tr_tally=function(ie,q,Q){return ie.pending_buf[ie.d_buf+2*ie.last_lit]=q>>>8&255,ie.pending_buf[ie.d_buf+2*ie.last_lit+1]=255&q,ie.pending_buf[ie.l_buf+ie.last_lit]=255&Q,ie.last_lit++,q===0?ie.dyn_ltree[2*Q]++:(ie.matches++,q--,ie.dyn_ltree[2*(R[Q]+d+1)]++,ie.dyn_dtree[2*K(q)]++),ie.last_lit===ie.lit_bufsize-1},i._tr_align=function(ie){fe(ie,2,3),ee(ie,b,P),(function(q){q.bi_valid===16?(U(q,q.bi_buf),q.bi_buf=0,q.bi_valid=0):8<=q.bi_valid&&(q.pending_buf[q.pending++]=255&q.bi_buf,q.bi_buf>>=8,q.bi_valid-=8)})(ie)}},{"../utils/common":41}],53:[function(n,r,i){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(o){(function(s,a){"use strict";if(!s.setImmediate){var l,c,u,d,f=1,h={},p=!1,m=s.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(s);g=g&&g.setTimeout?g:s,l={}.toString.call(s.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:(function(){if(s.postMessage&&!s.importScripts){var w=!0,x=s.onmessage;return s.onmessage=function(){w=!1},s.postMessage("","*"),s.onmessage=x,w}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(w){s.postMessage(d+w,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){u.port2.postMessage(w)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(w){var x=m.createElement("script");x.onreadystatechange=function(){v(w),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(w){setTimeout(v,0,w)},g.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var x=new Array(arguments.length-1),S=0;S<x.length;S++)x[S]=arguments[S+1];return h[f]={callback:w,args:x},l(f),f++},g.clearImmediate=y}function y(w){delete h[w]}function v(w){if(p)setTimeout(v,0,w);else{var x=h[w];if(x){p=!0;try{(function(S){var T=S.callback,k=S.args;switch(k.length){case 0:T();break;case 1:T(k[0]);break;case 2:T(k[0],k[1]);break;case 3:T(k[0],k[1],k[2]);break;default:T.apply(a,k)}})(x)}finally{y(w),p=!1}}}}function b(w){w.source===s&&typeof w.data=="string"&&w.data.indexOf(d)===0&&v(+w.data.slice(d.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),BEe=md(FEe(),1);const HEe=e=>/\.xml$|\.rels$/i.test(e);function lYt(e){if(e.length>=2){const n=e[0],r=e[1];if(n===255&&r===254)return"utf-16le";if(n===254&&r===255)return"utf-16be"}let t=0;for(let n=0;n<Math.min(64,e.length);n++)e[n]===0&&t++;return t>16?"utf-16le":"utf-8"}function zEe(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function UEe(e){if(typeof e=="string")return zEe(e);let t=null;if(e&&typeof e=="object"&&(e instanceof Uint8Array?t=e:typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ArrayBuffer.isView&&ArrayBuffer.isView(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.constructor&&(e instanceof ArrayBuffer||e.constructor.name==="ArrayBuffer")&&(t=new Uint8Array(e))),!t)throw new Error("Unsupported content type for XML");const n=lYt(t);let r=new TextDecoder(n).decode(t);return r=zEe(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const uG=[{zipPath:"word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},{zipPath:"docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",relationshipType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},{zipPath:"docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},{zipPath:"docProps/custom.xml",contentType:"application/vnd.openxmlformats-officedocument.custom-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"}];var VEe=md(Pv(),1),cYt="http://schemas.openxmlformats.org/package/2006/relationships";function dG(e,t,n){if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];if(t)return Array.isArray(t)?t.find(r=>r.name===e)?.content:t[e]}function uYt(e,t,n){return dG(e,t,n)!=null}function WEe(e){try{return VEe.xml2js(e,{compact:!1})}catch{return null}}function GEe(e){return VEe.js2xml(e,{spaces:0})}function jEe(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function qEe(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:cYt},elements:[]}]}}function dYt(e){let t=0;for(const n of e.elements||[]){const r=n.attributes?.Id;if(!r)continue;const i=r.match(/^rId(\d+)$/);i&&(t=Math.max(t,parseInt(i[1],10)))}return t}function fYt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const o of uG)n.set(`/${o.zipPath}`,o);const r=new Map;for(let o=0;o<e.elements.length;o++){const s=e.elements[o];if(s.name!=="Override")continue;const a=s.attributes?.PartName;!a||!n.has(a)||(r.has(a)||r.set(a,[]),r.get(a).push(o))}const i=new Set;for(const[o,s]of n){const a=t.has(s.zipPath),l=r.get(o)||[];if(!a){for(const c of l)i.add(c);continue}if(l.length===0)e.elements.push({type:"element",name:"Override",attributes:{PartName:o,ContentType:s.contentType}});else{e.elements[l[0]].attributes.ContentType=s.contentType;for(let c=1;c<l.length;c++)i.add(l[c])}}if(i.size>0){const o=[...i].sort((s,a)=>a-s);for(const s of o)e.elements.splice(s,1)}}function hYt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of uG)n.set(s.relationshipType,s);const r=new Map;for(let s=0;s<e.elements.length;s++){const a=e.elements[s];if(a.name!=="Relationship")continue;const l=a.attributes?.Type;!l||!n.has(l)||(r.has(l)||r.set(l,[]),r.get(l).push({index:s,element:a}))}const i=new Set;let o=dYt(e);for(const[s,a]of n){const l=t.has(a.zipPath),c=r.get(s)||[];if(!l){for(const{index:u}of c)i.add(u);continue}if(c.length===0)o++,e.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s,Target:a.zipPath}});else{c[0].element.attributes.Target=a.zipPath;for(let u=1;u<c.length;u++)i.add(c[u].index)}}if(i.size>0){const s=[...i].sort((a,l)=>l-a);for(const a of s)e.elements.splice(a,1)}}function YEe({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of uG)uYt(c.zipPath,e,t)&&n.add(c.zipPath);const r=dG("[Content_Types].xml",e,t);if(r==null)throw new Error("syncPackageMetadata: [Content_Types].xml is missing from the package. Cannot safely reconcile package metadata without an existing content types file.");const i=WEe(r);if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml could not be parsed as valid XML. Cannot safely reconcile package metadata from a malformed content types file.");const o=jEe(i,"Types");if(!o)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");fYt(o,n);const s=dG("_rels/.rels",e,t);let a;if(s==null)a=qEe();else if(a=WEe(s),!a)throw new Error("syncPackageMetadata: _rels/.rels could not be parsed as valid XML. Cannot safely reconcile root relationships from a malformed rels file.");let l=jEe(a,"Relationships");return l||(a=qEe(),l=a.elements[0]),hYt(l,n),{contentTypesXml:GEe(i),relsXml:GEe(a)}}var KEe=md(Pv(),1);const XEe=[{zipPath:"word/numbering.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",relTarget:"numbering.xml"}];function pYt(e){let t=0;for(const n of e){const r=n.attributes?.Id?.match(/^rId(\d+)$/);r&&(t=Math.max(t,Number(r[1])))}return t}function mYt(e,t){if(!e)return e;let n;try{n=KEe.xml2js(e,{compact:!1})}catch{return e}const r=n?.elements?.find(s=>s.name==="Relationships");if(!r)return e;r.elements||(r.elements=[]);let i=!1,o=pYt(r.elements);for(const s of XEe)t(s.zipPath)&&(r.elements.some(a=>a.attributes?.Type===s.relationshipType)||(o++,r.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s.relationshipType,Target:s.relTarget}}),i=!0));return i?KEe.js2xml(n,{spaces:0}):e}var gYt=ls({detectContainerType:()=>fG},1);function JEe(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function fG(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return JEe(t,ZEe)?"zip":JEe(t,QEe)?"cfb":"unknown"}var ZEe,QEe,$Ee=Pe((()=>{ZEe=[80,75,3,4],QEe=[208,207,17,224,161,177,26,225]}));function eCe(e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function yYt(e,t){return(e+1)*t}function Jk(e,t){return e.getUint16(t,!0)}function wl(e,t){return e.getUint32(t,!0)}function bYt(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function vYt(e){return tCe.decode(e).replace(/\u0000+$/g,"")}var hG,wYt,AYt,SYt,xYt,TYt,IYt,pG,kYt,EYt,Zk,CYt,_Yt,RYt,tCe,PYt=Pe((()=>{hG=new Uint8Array([208,207,17,224,161,177,26,225]),wYt=512,AYt=128,SYt=109,xYt=512,TYt=4096,IYt=4294967295,pG=4294967294,kYt=4294967292,EYt=4294967295,Zk={STORAGE:1,STREAM:2,ROOT:5},CYt=65534,_Yt=3,RYt=4,tCe=new TextDecoder("utf-16le")}));function Qk(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function nCe(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function LYt(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<hG.length;c++)if(e[c]!==hG[c])throw new Error("Invalid CFB signature");const t=Qk(e),n=Jk(t,26),r=Jk(t,28),i=Jk(t,30),o=Jk(t,32),s=1<<i,a=1<<o;if(r!==65534)throw new Error(`Unsupported CFB byte order: 0x${r.toString(16)}`);if(!(n===3&&s===512||n===4&&s===4096))throw new Error(`Unsupported CFB major version ${n} with sector size ${s}`);const l=[];for(let c=0;c<109;c++){const u=wl(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:wl(t,44),firstDirectorySector:wl(t,48),miniStreamCutoffSize:wl(t,56),firstMiniFatSector:wl(t,60),numberOfMiniFatSectors:wl(t,64),firstDifatSector:wl(t,68),numberOfDifatSectors:wl(t,72),difatEntries:l}}function mG(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=yYt(n,t.sectorSize);return nCe(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function NYt(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let i=0;i<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);i++){const o=Qk(mG(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=wl(o,a*4);l!==4294967295&&n.push(l)}r=wl(o,t.sectorSize-4)}if(n.length<t.numberOfFatSectors)throw new Error(`CFB DIFAT only exposed ${n.length} FAT sectors, expected ${t.numberOfFatSectors}`);return n.slice(0,t.numberOfFatSectors)}function MYt(e,t){const n=NYt(e,t),r=[];for(const i of n){const o=Qk(mG(e,t,i)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(wl(o,a*4))}return r}function kM(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==pG;){if(o.has(s))throw new Error(`CFB sector chain loop detected at sector ${s}`);if(s>=n.length)throw new Error(`CFB sector ${s} is out of FAT bounds`);o.add(s),i.push(mG(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return eCe(i)}function DYt(e,t){const n=bYt(e,t);if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`CFB stream is too large to fit in a JavaScript number: ${n.toString()}`);return Number(n)}function OYt(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),i=Qk(r),o=Jk(i,64),s=r.subarray(0,Math.max(0,Math.min(o,64)-2));t.push({name:vYt(s),objectType:r[66],leftSiblingId:wl(i,68),rightSiblingId:wl(i,72),childId:wl(i,76),startSector:wl(i,116),streamSize:DYt(i,120)})}return t}function gG(e,t,n,r=new Set){if(t===4294967295)return!1;if(t>=e.length)throw new Error(`CFB directory entry id ${t} is out of bounds`);if(r.has(t))throw new Error(`CFB directory tree loop detected at entry id ${t}`);r.add(t);const i=e[t];return!!(gG(e,i.leftSiblingId,n,r)||n(i)===!0||gG(e,i.rightSiblingId,n,r))}function FYt(e,t){const n=t.split("/").map(i=>i.trim()).filter(Boolean);let r=e[0];for(const i of n){if(r.objectType!==Zk.ROOT&&r.objectType!==Zk.STORAGE)return null;let o=null;if(gG(e,r.childId,s=>s.name.toLowerCase()===i.toLowerCase()?(o=s,!0):!1),!o)return null;r=o}return r}function BYt(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):kM(t,n,r,e.startSector).subarray(0,e.streamSize)}function HYt(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=kM(e,t,n,t.firstMiniFatSector),i=Qk(r),o=Math.floor(r.length/4),s=[];for(let a=0;a<o;a++)s.push(wl(i,a*4));return s}function zYt(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==pG;){if(o.has(s))throw new Error(`CFB mini sector chain loop detected at mini sector ${s}`);if(s>=t.length)throw new Error(`CFB mini sector ${s} is out of MiniFAT bounds`);o.add(s);const a=s*n;nCe(e,a,n,`mini sector ${s}`),i.push(e.subarray(a,a+n));const l=t[s];if(l==null)throw new Error(`CFB MiniFAT missing next sector for mini sector ${s}`);s=l}return eCe(i)}function UYt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=LYt(t),r=MYt(t,n),i=OYt(kM(t,n,r,n.firstDirectorySector));if(i.length===0||i[0].objectType!==Zk.ROOT)throw new Error("CFB root directory entry is missing");const o=i[0],s=HYt(t,n,r),a=BYt(o,t,n,r);return{getStream(l){const c=FYt(i,l);return!c||c.objectType!==Zk.STREAM?null:c.streamSize<n.miniStreamCutoffSize?zYt(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):kM(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var VYt=Pe((()=>{PYt()}));function WYt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=UYt(t)}catch(o){throw new Go(ia.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",o instanceof Error?o:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new Go(ia.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const i=n.getStream("/EncryptedPackage");if(!i)throw new Go(ia.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:i}}var GYt=Pe((()=>{VYt(),Yk()}));function rCe(e,t){return e[t]|e[t+1]<<8}function yG(e,t){const n=new RegExp(`<(?:\\w+:)?${t}\\b([^>]*)/?>`),r=e.match(n);if(!r)return null;const i={},o=/(\w+)="([^"]*)"/g;let s;for(;(s=o.exec(r[1]))!==null;)i[s[1]]=s[2];return i}function jYt(e){if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}return new Uint8Array(Buffer.from(e,"base64"))}function AA(e,t,n){const r=e?.[t];if(r==null)throw new Go(ia.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function eb(e,t,n){return jYt(AA(e,t,n))}function SA(e,t,n){const r=parseInt(AA(e,t,n),10);if(Number.isNaN(r))throw new Go(ia.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function qYt(e){const t=new TextDecoder("utf-8").decode(e),n=yG(t,"keyData"),r=yG(t,"dataIntegrity"),i=yG(t,"encryptedKey");return{keySalt:eb(n,"saltValue","keyData"),keyBits:SA(n,"keyBits","keyData"),hashAlgorithm:AA(n,"hashAlgorithm","keyData"),hashSize:SA(n,"hashSize","keyData"),blockSize:SA(n,"blockSize","keyData"),cipherAlgorithm:AA(n,"cipherAlgorithm","keyData"),cipherChaining:AA(n,"cipherChaining","keyData"),spinCount:SA(i,"spinCount","encryptedKey"),passwordSalt:eb(i,"saltValue","encryptedKey"),passwordHashAlgorithm:AA(i,"hashAlgorithm","encryptedKey"),passwordKeyBits:SA(i,"keyBits","encryptedKey"),passwordBlockSize:SA(i,"blockSize","encryptedKey"),encryptedVerifierHashInput:eb(i,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:eb(i,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:eb(i,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:eb(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:eb(r,"encryptedHmacValue","dataIntegrity")}}function YYt(e){if(e.length<EM)throw new Go(ia.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${EM})`);const t=rCe(e,0),n=rCe(e,2);if(t===iCe&&n===oCe)return{type:"agile",params:qYt(e.subarray(EM))};throw(t===sCe||t===aCe)&&n===lCe?new Go(ia.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new Go(ia.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new Go(ia.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var iCe,oCe,sCe,aCe,lCe,EM,KYt=Pe((()=>{Yk(),iCe=4,oCe=4,sCe=3,aCe=4,lCe=3,EM=8}));function bG(){const e=globalThis.crypto?.subtle;if(!e)throw new Go(ia.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function $k(e){const t={SHA1:"SHA-1","SHA-1":"SHA-1",SHA256:"SHA-256","SHA-256":"SHA-256",SHA384:"SHA-384","SHA-384":"SHA-384",SHA512:"SHA-512","SHA-512":"SHA-512"}[e];if(!t)throw new Go(ia.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function XYt(e){const t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}function xA(...e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function cCe(e){const t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>>8&255,t[2]=e>>>16&255,t[3]=e>>>24&255,t}function TA(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function IA(e,t){const n=await bG().digest(e,TA(t));return new Uint8Array(n)}async function kA(e,t,n){const r=bG(),i=16,o=await r.importKey("raw",TA(e),{name:"AES-CBC"},!1,["encrypt","decrypt"]),s=n.subarray(n.length-i),a=new Uint8Array(i);a.fill(i);const l=new Uint8Array(await r.encrypt({name:"AES-CBC",iv:TA(s)},o,a)).subarray(0,i),c=new Uint8Array(n.length+i);c.set(n),c.set(l,n.length);const u=await r.decrypt({name:"AES-CBC",iv:TA(t)},o,c);return new Uint8Array(u).subarray(0,n.length)}async function vG(e,t,n,r,i,o){const s=$k(i);let a=await IA(s,xA(t,XYt(e)));for(let d=0;d<n;d++)a=await IA(s,xA(cCe(d),a));const l=await IA(s,xA(a,o)),c=r/8;if(l.length>=c)return l.subarray(0,c);const u=new Uint8Array(c);return u.set(l),u.fill(54,l.length),u}async function wG(e,t,n,r){let i;if(n?i=await IA($k(e),xA(t,n)):i=t,i.length>=r)return i.subarray(0,r);const o=new Uint8Array(r);return o.set(i),o.fill(54,i.length),o}async function JYt(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:i,passwordKeyBits:o,passwordBlockSize:s}=t,a=await vG(e,n,r,o,i,dCe),l=await vG(e,n,r,o,i,fCe),c=await vG(e,n,r,o,i,hCe),u=await wG(i,n,void 0,s),d=await kA(a,u,t.encryptedVerifierHashInput),f=await kA(l,u,t.encryptedVerifierHashValue),h=await IA($k(i),d);if(!uCe(h,f.subarray(0,h.length)))throw new Go(ia.PASSWORD_INVALID,"The password is incorrect");return kA(c,u,t.encryptedKeyValue)}function uCe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function ZYt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o}=t,s=$k(i);if(n.length<AG)throw new Go(ia.DECRYPTION_FAILED,"EncryptedPackage too short to contain size header");const a=n[0]|n[1]<<8|n[2]<<16|n[3]<<24>>>0,l=n.subarray(AG),c=Math.ceil(l.length/CM),u=[];for(let d=0;d<c;d++){const f=d*CM,h=Math.min(f+CM,l.length),p=l.subarray(f,h),m=await IA(s,xA(r,cCe(d))),g=await kA(e,m.length>=o?m.subarray(0,o):m,p);u.push(g)}return xA(...u).subarray(0,a)}async function QYt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o,hashSize:s}=t,a=$k(i),l=bG(),c=(await kA(e,await wG(i,r,pCe,o),t.encryptedHmacKey)).subarray(0,s),u=await kA(e,await wG(i,r,mCe,o),t.encryptedHmacValue),d=await l.importKey("raw",TA(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,TA(n)));if(!uCe(f,u.subarray(0,f.length)))throw new Go(ia.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function $Yt(e,t,n){try{const r=await JYt(e,t);return await QYt(r,t,n),await ZYt(r,t,n)}catch(r){throw r instanceof Go?r:new Go(ia.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var dCe,fCe,hCe,pCe,mCe,CM,AG,eKt=Pe((()=>{Yk(),dCe=new Uint8Array([254,167,210,118,59,75,158,121]),fCe=new Uint8Array([215,170,15,109,48,97,52,78]),hCe=new Uint8Array([20,110,11,231,171,172,208,214]),pCe=new Uint8Array([95,178,173,1,12,185,225,246]),mCe=new Uint8Array([160,103,127,2,178,44,132,51]),CM=4096,AG=8})),tKt=ls({decryptDocxIfNeeded:()=>rKt},1);function nKt(e){if(fG(e)!=="zip")throw new Go(ia.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function rKt(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=fG(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new Go(ia.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new Go(ia.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const i=WYt(n),{params:o}=YYt(i.encryptionInfo),s=await $Yt(t.password,o,i.encryptedPackage);return nKt(s),{data:s,wasEncrypted:!0}}var iKt=Pe((()=>{$Ee(),GYt(),KYt(),eKt(),Yk()})),gCe=md(Pv(),1),SG=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),xG={tif:"tiff",jpg:"jpeg"},oKt="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",yCe={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},sKt=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new BEe.default,this.files=[],this.media={},this.mediaFiles={},this.fonts={},this.decryptedFileData=null}async#e(e,t){if(e instanceof Uint8Array||typeof Buffer<"u"&&Buffer.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,Math.min(t,e.byteLength));if(e instanceof ArrayBuffer)return new Uint8Array(e,0,Math.min(t,e.byteLength));if(typeof Blob<"u"&&e instanceof Blob)try{if(typeof e.arrayBuffer=="function"){const n=await e.arrayBuffer();return new Uint8Array(n,0,Math.min(t,n.byteLength))}}catch{}return new Uint8Array(0)}async getDocxData(e,t=!1,n={}){const{detectContainerType:r}=await Promise.resolve().then(()=>($Ee(),gYt)),i=r(await this.#e(e,8));let o=e;if(i==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(iKt(),tKt)),c=await l(e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer()),{password:n.password});o=c.data,this.decryptedFileData=c.data}const s=await this.unzip(o),a=Object.entries(s.files);for(const[,l]of a){const c=l.name;if(HEe(c)){const u=UEe(await l.async("uint8array"));this.files.push({name:c,content:u})}else if(c.startsWith("word/media")&&c!=="word/media/"||l.name.startsWith("media")&&l.name!=="media/"||c.startsWith("media")&&c!=="media/"||c.startsWith("word/embeddings")&&c!=="word/embeddings/")if(t){const u=(await l.async("nodebuffer")).toString("base64");this.mediaFiles[c]=u}else{const u=await l.async("base64");let d=this.getFileExtension(c)?.toLowerCase(),f=null;if((!SG.has(d)||d==="tmp")&&(f=g1(u),f&&(d=f)),SG.has(d)){const h=xG[d]||d;this.mediaFiles[c]=`data:image/${h};base64,${u}`;const p=await l.async("blob"),m=new File([p],c,{type:p.type}),g=URL.createObjectURL(m);this.media[c]=g}else this.mediaFiles[c]=u}else if(c.startsWith("word/fonts")&&c!=="word/fonts/"){const u=await l.async("uint8array");this.fonts[c]=u}}return this.files}getFileExtension(e){const t=e.split(".");return t.length<2?null:t[t.length-1]}async updateContentTypes(e,t,n,r={},i={}){const o=Object.keys(r||{}),s=Object.keys(t).map(P=>this.getFileExtension(P)).filter(P=>P&&SG.has(P)),a=Object.entries(t).filter(([P])=>!this.getFileExtension(P)).map(([P,E])=>({name:P,contentType:this.#i(E)})).filter(P=>P.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(P=>P.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=oKe(c),f=new Set;for(let P of s){if(d.includes(P)||f.has(P))continue;const E=`<Default Extension="${P}" ContentType="image/${xG[P]||P}"/>`;u+=E,f.add(P)}if(i){const P=new Set(Object.keys(i).map(E=>this.getFileExtension(E)).filter(E=>E&&yCe[E]));for(const E of P)d.includes(E)||f.has(E)||(u+=`<Default Extension="${E}" ContentType="${yCe[E]}"/>`,f.add(E))}const h=JSON.parse(gCe.xml2json(c,null,2)).elements?.find(P=>P.name==="Types")||{},p=P=>h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName===P);for(const{name:P,contentType:E}of a){const L=`/${P}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${E}" />`)}const m=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsIds.xml"),v=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsExtensible.xml"),b=P=>r&&Object.prototype.hasOwnProperty.call(r,P)?r[P]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(E=>E.name===P):!!e.files[P]:!1;b("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),b("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),b("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),b("word/commentsExtensible.xml")&&(v||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const w=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/footnotes.xml"),x=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/endnotes.xml");b("word/footnotes.xml")&&(w||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),b("word/endnotes.xml")&&(x||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const P of XEe)b(P.zipPath)&&!p(`/${P.zipPath}`)&&(u+=`<Override PartName="/${P.zipPath}" ContentType="${P.contentType}" />`);const S=new Set(o);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(P=>S.add(P.name)):Object.keys(e.files).forEach(P=>S.add(P))),S.forEach(P=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(P)||!b(P))return;const E=`/${P}`;p(E)||(u+=`<Override PartName="${E}" ContentType="${oKt}" />`)}),S.forEach(P=>{if(P.includes(".rels")||!P.includes("header")&&!P.includes("footer"))return;const E=h.elements?.some(R=>R.name==="Override"&&R.attributes.PartName===`/${P}`),L=`<Override PartName="/${P}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${P.includes("header")?"header":"footer"}+xml"/>`;E||(u+=L)});const T=tU.map(P=>`/word/${P}`).filter(P=>!b(P.slice(1))),k='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let C=c.replace(k,`${k}${u}`);for(const P of T){const E=P.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`\\s*<Override[^>]*PartName="${E}"[^>]*/>`,"g");C=C.replace(L,"")}let _=r["word/_rels/document.xml.rels"];if(_||(n?Array.isArray(e.files)?_=e.files.find(P=>P.name==="word/_rels/document.xml.rels")?.content:_=e.files?.["word/_rels/document.xml.rels"]:_=await e.file("word/_rels/document.xml.rels")?.async("string")),_)try{gCe.xml2js(_,{compact:!1}).elements?.find(P=>P.name==="Relationships")?.elements?.forEach(P=>{const E=P.attributes?.Type,L=P.attributes?.Target;if(!E||!L)return;const R=E.includes("/header"),O=E.includes("/footer");if(!R&&!O)return;let F=L.replace(/^\.\//,"");F.startsWith("../")&&(F=F.slice(3)),F.startsWith("/")&&(F=F.slice(1));const B=F.startsWith("word/")?F:`word/${F}`;S.add(B)})}catch(P){console.warn("Failed to parse document relationships while updating content types",P)}if(S.forEach(P=>{if(P.includes(".rels")||!P.includes("header")&&!P.includes("footer")||C.includes(`PartName="/${P}"`))return;const E=`<Override PartName="/${P}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${P.includes("header")?"header":"footer"}+xml"/>`;C=C.replace("</Types>",`${E}</Types>`)}),_){const P=mYt(_,b);P!==_&&(n?r["word/_rels/document.xml.rels"]=P:e.file("word/_rels/document.xml.rels",P))}if(n)return C;e.file(l,C)}async#t(e){const t={};e.forEach(s=>{t[s]=""});const n=e.file("[Content_Types].xml");n&&(t["[Content_Types].xml"]=await n.async("string"));const r=e.file("_rels/.rels");r&&(t["_rels/.rels"]=await r.async("string"));const{contentTypesXml:i,relsXml:o}=YEe({baseFiles:t,updatedDocs:{}});e.file("[Content_Types].xml",i),e.file("_rels/.rels",o)}async unzip(e){return await this.zip.loadAsync(e)}async updateZip({docx:e,updatedDocs:t,originalDocxFile:n,media:r,fonts:i,isHeadless:o,compression:s="DEFLATE"}){let a;n?a=await this.exportFromOriginalFile(n,t,r,i):a=await this.exportFromCollaborativeDocx(e,t,r,i);const l=o?"nodebuffer":"blob";return await a.generateAsync({type:l,mimeType:pc,compression:s,compressionOptions:s==="DEFLATE"?{level:6}:void 0})}async exportFromCollaborativeDocx(e,t,n,r){if(!Array.isArray(e))throw new Error("Collaborative DOCX export requires base package entries");const i=new BEe.default;for(const o of e){const s=o.content;i.file(o.name,s)}Object.keys(t).forEach(o=>{t[o]===null?i.remove(o):i.file(o,t[o])}),Object.keys(n).forEach(o=>{const s=n[o],a=typeof s=="string"?kT(s):s;i.file(o,a)});for(const[o,s]of Object.entries(r))i.file(o,s);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}async exportFromOriginalFile(e,t,n,r){const i=await this.unzip(e),o=[];if(i.forEach((s,a)=>{const l=a.async("uint8array").then(c=>{i.file(a.name,HEe(a.name)?UEe(c):c)});o.push(l)}),await Promise.all(o),Object.keys(t).forEach(s=>{t[s]===null?i.remove(s):i.file(s,t[s])}),Object.keys(n).forEach(s=>{i.file(s,n[s])}),r)for(const[s,a]of Object.entries(r))i.file(s,a);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}#i(e){if(e==null)return null;if(typeof e=="string"&&e.startsWith("data:image/"))return e.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase()||null;let t=null;return e instanceof ArrayBuffer?t=g1(new Uint8Array(e)):ArrayBuffer.isView(e)?t=g1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=g1(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${xG[t]||t}`:null}},TG=sKt;const aKt=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const i=e.state.tr.setSelection(mn.create(n,t));return e.dispatch(i),!0}return!1};function lKt(e,t="sans-serif"){const n=(r,i)=>{const o=document.createElement("canvas").getContext("2d");o.textBaseline="top";const s="abcdefghijklmnopqrstuvwxyz0123456789";o.font=`72px ${i}`;const a=o.measureText(s),l=a.width,c=a.actualBoundingBoxDescent;o.font=`72px "${r}", ${i}`;const u=o.measureText(s),d=u.width,f=u.actualBoundingBoxDescent;return d!==l||f!==c};return n(e,t)?!0:n(e,t==="sans-serif"?"serif":"sans-serif")}var eE=(...e)=>{};const cKt=e=>{const t=[];if(eE("ATTEMPTING MIGRATIONS"),!e.converter.numbering)return t;const{state:n}=e,{doc:r}=n,i=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),o=["orderedList","bulletList"];let s=0;r.descendants((l,c)=>{if(!o.includes(l.type.name)||c<s)return;const u=_M(l,e,0);u.length>0&&t.push({from:c,to:c+l.nodeSize,listNode:l,replacement:u}),s=c+l.nodeSize});let a=n.tr;if(t.length>0)for(let l=t.length-1;l>=0;l--){const{from:c,to:u,replacement:d,listNode:f}=t[l],h=[];for(const p of d)if(p.node.type.name==="listItem"){const m=f.type.create(f.attrs,[p.node]);h.push(m)}else h.push(p.node);eE("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,i(a),t};function _M(e,t,n=0,r=null){const i=[],o=["orderedList","bulletList"],s=e.type.name,a=uKt(e),l=dKt(e,t);if(eE("Needs migration?",a),!a)return l?i:fKt(e,t);let c=parseInt(e.attrs?.listId);eE("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=ur.getNewListId(t)),(!ur.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=ur.getNewListId(t),eE("Genearted new list ID",c,"for list type",s),ur.generateNewListDefinition({numId:c,listType:s,editor:t})),r||(r=c);for(const u of e.content.content)if(!u.content.content?.length)i.push({node:u,baseLevel:n});else if(u.content.content.length===1){const d=u.content.content[0];if(o.includes(d.type.name)){const f=_M(d,t,n+1,r);i.push(...f)}else{const f=ur.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}}else{const d=u.content.content[0];if(o.includes(d.type.name)){const f=_M(d,t,n+1,r);i.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=ur.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}else i.push({node:d});for(let f of u.content.content.slice(1))if(o.includes(f.type.name)){const h=_M(f,t,n+1,r);i.push(...h)}else i.push({node:f})}return i}var uKt=e=>{const t=e.content;if(t?.content?.length>1)return!0;const n=t.firstChild;if(n&&n.type.name==="listItem"){const{attrs:r}=n,{level:i,listNumberingType:o}=r||{};return typeof i>"u"||!o?!0:(n?.content?.content).filter(s=>["bulletList","orderedList"].includes(s.type.name)).length>0}return!1},dKt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i,level:o}=r||{},{abstract:s}=ur.getListDefinitionDetails({numId:i,level:o,listType:n,editor:t})||{};return!!s},fKt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i}=r||{};return ur.generateNewListDefinition({numId:i,listType:n,editor:t})};const hKt=async(e=[],t)=>{const n=ru(t.state),r=[];if(!n.length)return e;for(const i of n){const o=i.node?.attrs?.type,s=e.find(l=>l.input_id===i.node.attrs.fieldId);if(s&&(!o||o!=="html")){r.push(s);continue}const a=s?.input_value;a&&await new Promise((l,c)=>{const u=document.createElement("div");t.createChildEditor({element:u,html:a,onCreate:({editor:d})=>{const{migrated:f}=d.options;f&&(s.input_value=d.getHTML(),r.push(s)),l()},onError:d=>{c(d)}})})}return r},pKt=(e,t={})=>e.options.isChildEditor?null:new Fp({...e.options,pagination:!1,suppressDefaultDocxStyles:!0,ydoc:null,collaborationProvider:null,fileSource:null,initialState:null,documentId:null,isCommentsEnabled:!1,isNewFile:!1,fragment:!1,onCreate:()=>null,onListDefinitionsChange:mKt,...t,isChildEditor:!0,parentEditor:e});var mKt=e=>{const{editor:t,numbering:n}=e,{parentEditor:r={}}=t.options,{converter:i}=r;if(!i)return;i.numbering=n;const{tr:o}=r.state;o.setMeta("updatedListItemNodeViews",!0),r.dispatch(o)};function bCe(e,t=[]){const n="[SuperValidator]",r="color: teal; font-weight: bold;",i=[n,...t.map(a=>`[${a}]`)],o=i.map(()=>"%c%s").join(" "),s=i.map(a=>[r,a]).flat();return{debug:(...a)=>{e&&console.debug(o,...s,...a)},withPrefix:a=>bCe(e,[...t,a])}}function gKt(e,t,n,r){let i=!1;const o=[];return e.forEach(({node:s,pos:a})=>{const{rId:l,src:c}=s.attrs;if(!l&&c){const u=ww(t,"image-rid:ensureValidImageRID",{target:c,type:"image"});u&&(r.debug("Assigned rId for image:",u,"at pos:",a),n.setNodeMarkup(a,void 0,{...s.attrs,rId:u}),o.push(`Added missing rId to image at pos ${a}`),i=!0)}}),{modified:i,results:o}}function yKt({editor:e,logger:t}){const n=(r,i)=>{const o=[gKt(i.image||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={nodes:["image"]},n}function bKt(e,t,n,r){let i=!1;const o=[];return e.forEach(({mark:s,from:a,to:l})=>{const{rId:c,href:u,anchor:d}=s.attrs;if(!c&&u&&!d){const f=ww(t,"link-rid:ensureValidLinkRID",{target:u,type:"hyperlink"});if(f){r.debug("Assigned rId for link:",f,"from pos:",a,"to pos:",l);const h=t.schema.marks.link,p=h.create({...s.attrs,rId:f});n.removeMark(a,l,h),n.addMark(a,l,p),o.push(`Added missing rId to link from pos ${a} to ${l}`),i=!0}}}),{modified:i,results:o}}function vKt({editor:e,logger:t}){const n=(r,i)=>{const o=[bKt(i.link||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={marks:["link"]},n}const wKt={imageNodeValidator:yKt,linkMarkValidator:vKt};function AKt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml,o="word/numbering.xml",s=i?.[o];if(!s||!s.elements?.length||!s.elements[0].elements?.length)return n.push(`${o} is not a valid xml`),{results:n,modified:r};const a=[];let l=s.elements[0];return vCe(l,a),a.length?(r=!0,n.push("Removed invalid <w:num> by numId:"+a.join(", ")),t?.debug?.(`Removed invalid <w:num> by numId: ${a.join(", ")}`)):n.push("No <w:num> entries with null/invalid numId found."),{results:n,modified:r}}}function vCe(e,t){if(!e||!Array.isArray(e.elements))return;const n=[];for(const r of e.elements){if(r?.type==="element"){if(r.name==="w:num"){const i=(r.attributes||{})["w:numId"],o=i==null?null:String(i).trim();if(o==null||o===""||/^null$/i.test(o)||!/^\d+$/.test(o)){t.push(o??"missing node");continue}}Array.isArray(r.elements)&&r.elements.length&&vCe(r,t)}n.push(r)}e.elements=n}function SKt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml;if(!i||typeof i!="object")return{results:n,modified:r};const{relsKey:o,wasNormalized:s}=xKt(i,n);if(!o)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=TKt(i[o],o,n);if(!a)return{results:n,modified:r};l&&(r=!0),IKt(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=kKt(a,i,n);d&&(r=!0),EKt(i,c,n,t)&&(r=!0);const f=i["[Content_Types].xml"];return u.size>0||f?CKt(i,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function xKt(e,t){const n=["word/_rels/document.xml.rels","word/document.xml.rels","_rels/document.xml.rels","document.xml.rels"].find(i=>e?.[i]?.elements);if(!n)return{relsKey:null,wasNormalized:!1};const r="word/_rels/document.xml.rels";return n!==r?(e[r]=e[n],delete e[n],t.push(`Normalized relationships location to ${r} (was ${n})`),{relsKey:r,wasNormalized:!0}):{relsKey:n,wasNormalized:!1}}function TKt(e,t,n){const r=e?.elements?.[0];if(!r||r.type!=="element")return n.push(`${t} is not a valid xml`),{root:null,wasFixed:!1};const i="http://schemas.openxmlformats.org/package/2006/relationships";let o=!1;return r.name!=="Relationships"&&(r.name="Relationships",n.push('Fixed relationships root element name to "Relationships"'),o=!0),r.attributes=r.attributes||{},r.attributes.xmlns!==i&&(r.attributes.xmlns=i,n.push(`Set relationships xmlns to ${i}`),o=!0),{root:r,wasFixed:o}}function IKt(e){const t=e.elements?.filter(n=>n?.type==="element"&&n.name==="Relationship")||[];return e.elements?.length!==t.length?(e.elements=t,!0):!1}function kKt(e,t,n){const r=new Set,i=new Set;let o=!1;const s=v=>{const b=/^rId(\d+)$/.exec(String(v||""));return b?parseInt(b[1],10):null},a=(v,b)=>typeof v=="string"&&new RegExp(`/relationships/${b}$`,"i").test(v),l=v=>a(v,"hyperlink"),c=v=>a(v,"image"),u=v=>/^https?:\/\//i.test(v||"")||/^mailto:/i.test(v||""),d=new Set;let f=0;for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes.Id,w=s(b);Number.isInteger(w)&&(f=Math.max(f,w)),typeof b=="string"&&b&&d.add(b)}let h=f;const p=v=>{if(v&&!d.has(v))return d.add(v),v;let b;do h+=1,b=`rId${h}`;while(d.has(b));return d.add(b),b},m=new Set,g=[];function y(v,b){return typeof v[b]=="string"?v[b].trim():""}for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes;let w=y(b,"Id");const x=y(b,"Type");let S=y(b,"Target"),T=y(b,"TargetMode");if(!S){n.push(`Removed relationship "${w}" without Target`),o=!0;continue}if(l(x)&&u(S)&&T.toLowerCase()!=="external"&&(b.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${w}`),o=!0),c(x)){const k=V0(S,"word");k&&/^media\/.+\.bin$/i.test(S)&&k in t&&r.add(`/${k}`)}if(T.toLowerCase()!=="external"&&!u(S)&&!(V0(S,"word")in t))if(c(x))n.push(`Warning: image relationship ${w} target not found: ${S}.`);else{n.push(`Removed relationship ${w} with missing target: ${S}`),o=!0;continue}if(!w){const k=p(null);b.Id=k,n.push(`Assigned missing Id "${k}"`),o=!0,w=k}if(m.has(w)){n.push(`Removed duplicate relationship with ID "${w}"`),o=!0;continue}m.add(w),g.push(v)}(e.elements.length!==g.length||e.elements.some((v,b)=>v!==g[b]))&&(e.elements=g,o=!0);for(const v of e.elements){const b=v.attributes?.Id;typeof b=="string"&&b&&i.add(b)}return{filteredIds:i,binMediaTargets:r,wasProcessed:o}}function EKt(e,t,n,r){const i=e["word/document.xml"];if(i?.elements?.length){const o=i.elements[0];if(o?.type==="element"){const s=[];if(wCe(o,t,s),s.length)return n.push(`Fixed ${s.length} missing relationship references`),r?.debug?.(`Fixed ${s.length} missing relationship references in document`),!0}}return!1}function CKt(e,t,n){const r="[Content_Types].xml",i=e[r];return typeof i=="string"?_Kt(i,t,n,e,r):i?.elements?.length?RKt(i,t,n):!1}function _Kt(e,t,n,r,i){const o='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">',s=(c,u,d)=>new RegExp(`<Default\\s+Extension="${u}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Default Extension="${u}" ContentType="${d}"/>`),a=(c,u,d)=>{const f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<Override\\s+PartName="${f}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Override PartName="${u}" ContentType="${d}" />`)};let l=e;l=s(l,"rels","application/vnd.openxmlformats-package.relationships+xml"),l=s(l,"xml","application/xml");for(const c of t)l=a(l,c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`);return l!==e?(r[i]=l,!0):!1}function RKt(e,t,n){const r=e.elements.find(c=>c.name==="Types")||e.elements[0];r.elements=r.elements||[];const i=c=>r.elements.some(u=>u.name==="Default"&&u.attributes?.Extension===c),o=(c,u)=>{r.elements.unshift({type:"element",name:"Default",attributes:{Extension:c,ContentType:u}})},s=c=>r.elements.some(u=>u.name==="Override"&&u.attributes?.PartName===c),a=(c,u)=>{r.elements.unshift({type:"element",name:"Override",attributes:{PartName:c,ContentType:u}})};let l=!1;i("rels")||(o("rels","application/vnd.openxmlformats-package.relationships+xml"),l=!0),i("xml")||(o("xml","application/xml"),l=!0);for(const c of t)s(c)||(a(c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`),l=!0);return l}function wCe(e,t,n){if(e?.elements?.length)for(const r of e.elements){if(r?.type!=="element")continue;const i=r.attributes?.["r:id"];typeof i=="string"&&!t.has(i)&&(delete r.attributes["r:id"],n.push(`Removed invalid r:id="${i}"`)),wCe(r,t,n)}}const PKt={numberingValidator:AKt,relationshipsValidator:SKt};var ACe=class{#e;#t;#i;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=bCe(this.debug);const{stateValidators:t,xmlValidators:n,nodeTypes:r,markTypes:i}=this.#o();this.#t=t,this.#i=n,this.#n=r,this.#r=i}#o(){const e=new Set,t=new Set,n=r=>Object.fromEntries(Object.entries(r).map(([i,o])=>{const s=this.logger.withPrefix(i),a=o({editor:this.#e,logger:s});return this.#a(a,e,t),[i,a]}));return{stateValidators:n(wKt),xmlValidators:n(PKt),nodeTypes:e,markTypes:t}}#a(e,t,n){e.requiredElements&&typeof e.requiredElements=="object"&&(e.requiredElements.nodes&&e.requiredElements.nodes.forEach(r=>{t.add(r)}),e.requiredElements.marks&&e.requiredElements.marks.forEach(r=>{n.add(r)}))}#c(){const{doc:e}=this.#e.state,t={};this.#n.forEach(r=>t[r]=[]),this.#r.forEach(r=>t[r]=[]);const n=(r,i)=>{this.#n.has(r.type.name)&&t[r.type.name].push({node:r,pos:i}),r.isText&&r.marks&&r.marks.forEach(o=>{this.#r.has(o.type.name)&&t[o.type.name].push({mark:o,node:r,pos:i,from:i,to:i+r.nodeSize})})};return e.descendants(n),t}validateActiveDocument(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e,n=this.#c();this.logger.debug("Document analysis:",n);let r=!1;const i=[];return Object.entries(this.#t).forEach(([o,s])=>{this.logger.debug(`🕵 Validating with ${o}...`);const{results:a,modified:l}=s(t,n);i.push({key:o,results:a}),r=r||l}),this.dryRun?this.logger.debug("DRY RUN: No changes applied to the document."):this.#u(t),this.logger.debug("Results:",i),{modified:r,results:i}}validateDocumentExport(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e;let n=!1;const r=[];return Object.entries(this.#i).forEach(([i,o])=>{this.logger.debug(`🕵 Validating export with ${i}...`);const{results:s,modified:a}=o();r.push({key:i,results:s}),n=n||a}),!this.dryRun&&n?this.#u(t):this.logger.debug("DRY RUN: No export changes applied to the document."),this.logger.debug("Export validation results:",r),{modified:n,results:r}}#u(e){if(typeof this.#e?.dispatch=="function"){this.#e.dispatch(e);return}this.#e?.view?.dispatch?.(e)}},RM=null;const EA=()=>{if(RM!==null)return RM;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return RM=e,e}catch{return RM=!1,!1}};var LKt="1.31.0",NKt=["group","content","marks","inline","atom","defining","code","tableRole","summary"],MKt=["group","inclusive","excludes","spanning","code"];function SCe(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n?.default;return[t,{default:r??null,required:r===void 0}]})):{}}function xCe(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function DKt(e,t){if(!e||typeof e!="object")throw new Error("Invalid schema: schema must be a valid ProseMirror Schema object.");const n=t||"current",r=[];e.spec.nodes.forEach((o,s)=>{r.push({name:o,attrs:SCe(s.attrs),...xCe(s,NKt)})});const i=[];return e.spec.marks.forEach((o,s)=>{i.push({name:o,attrs:SCe(s.attrs),...xCe(s,MKt)})}),{version:LKt,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:i}}const OKt=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],i=o=>{for(;r.length&&r[r.length-1].level>=o;){const s=r.pop();r.length?r[r.length-1].el.appendChild(s.el):n.push(s.el.outerHTML)}};return Array.from(t.childNodes).forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE){n.push(o.outerHTML||o.textContent);return}if(o.tagName.toLowerCase()==="ol"||o.tagName.toLowerCase()==="ul"){const s=BKt(o),a=HKt(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=o.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",FKt(l,c)),!r.length||r[r.length-1].level<a){const f=document.createElement(u);r.push({tag:u,level:a,el:f})}else if(r[r.length-1].level>a)i(a+1);else if(r[r.length-1].tag!==u){i(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else i(0),n.push(o.outerHTML)}),i(0),n.join("")},FKt=(e,t)=>{const n=new Map([["●","disc"],["◦","circle"],["▪","square"]]);if(e==="bullet")return n.get(t)||"disc";const r=new Map([["decimal","decimal"],["lowerLetter","lower-alpha"],["upperLetter","upper-alpha"],["lowerRoman","lower-roman"],["upperRoman","upper-roman"]]);return t.startsWith("0")?"decimal-leading-zero":r.get(e)};function BKt(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const HKt=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var zKt=1,UKt=10,VKt=150,WKt=1.2,GKt=1,jKt=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),qKt="span.sd-paragraph-content",TCe="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",YKt='<meta name="Generator" content="Microsoft Word">',KKt=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function ICe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(TCe))return r}n=n.parentNode}return null}function XKt(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(TCe)}function JKt(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),i=e.style.fontFamily||"",o=e.style.fontSize||(n?.fontSize&&n.fontSize!=="16px"?n.fontSize:""),s=e.style.textTransform||(n?.textTransform&&n.textTransform!=="none"?n.textTransform:""),a=e.style.fontWeight||(n?.fontWeight&&n.fontWeight!=="400"?n.fontWeight:"");return r&&t.push(`color: ${r}`),i&&t.push(`font-family: ${i}`),o&&t.push(`font-size: ${o}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function ZKt(e,t){const n=e.cloneContents();if(XKt(n))return n;const r=ICe(e.startContainer,t.dom),i=ICe(e.endContainer,t.dom);if(!r||r!==i)return n;const o=r.cloneNode(!1),s=JKt(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),o.appendChild(l)}else o.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(o),a}function QKt(e,t){let n;try{n=e.posAtDOM(t,0)}catch{return null}const{doc:r}=e.state;if(n<0||n>r.content.size)return null;const i=r.resolve(n);for(let o=i.depth;o>0;o-=1){const s=i.node(o);if(s.type.name==="paragraph")return s}return null}function $Kt(e){e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(t=>{const n=t.getAttribute("data-list-numbering-type"),r=t.getAttribute("data-marker-type");n&&!t.hasAttribute("data-num-fmt")&&t.setAttribute("data-num-fmt",n),r&&!t.hasAttribute("data-lvl-text")&&t.setAttribute("data-lvl-text",r)})}function eXt(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const i=r.getAttribute("data-sd-block-id");if(!i)return;const o=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(i)??i}"]`);if(!o)return;const s=QKt(t,o),a=s?.attrs?.paragraphProperties?.sectPr;if(!a||typeof a!="object")return;r.setAttribute("data-sd-sect-pr",JSON.stringify(a));const l=s?.attrs?.pageBreakSource;typeof l=="string"&&l.length>0&&r.setAttribute("data-sd-page-break-source",l)})}function tXt(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(n=>Number(n)).filter(n=>Number.isFinite(n)):[]}catch{return[]}}function nXt(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const i=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${i}`}function rXt(e){const t=document.createDocumentFragment();t.appendChild(document.createComment("[if !supportLists]"));const n=document.createElement("span");return n.textContent=e,t.appendChild(n),t.appendChild(document.createComment("[endif]")),t}function iXt(e){if(Array.from(e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]")).length===0)return null;const t=e.cloneNode(!0),n=[".MsoNormal {}",".MsoListParagraph {}"],r=new Set;return t.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(i=>{const o=Number.parseInt(i.getAttribute("data-level")||"0",10)||0,s=o+1,a=i.getAttribute("data-num-id")||"1",l=a,c=i.getAttribute("data-num-fmt")||i.getAttribute("data-list-numbering-type")||"decimal",u=KKt.get(c)||"decimal",d=i.getAttribute("data-marker-type")||i.getAttribute("data-lvl-text")||"1.",f=nXt(o,c,d,i.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=i.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;i.setAttribute("class","MsoListParagraph"),i.setAttribute("style",p?`${m};${p}`:m),r.has(h)||(n.push(`@list l${l}:level${s} lfo${a} { mso-level-number-format: ${u}; mso-level-text: "${f}"; }`),r.add(h));const g=tXt(i.getAttribute("data-list-level")),y=g[o]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;i.prepend(rXt(v))}),`${YKt}<style>${n.join(`
322
+ \0`,fe+=o($,2),fe+=S.magic,fe+=o(b,2),fe+=o(w,2),fe+=o(z.crc32,4),fe+=o(z.compressedSize,4),fe+=o(z.uncompressedSize,4),fe+=o(k.length,2),fe+=o(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+fe+k+O,dirRecord:d.CENTRAL_FILE_HEADER+o(U,2)+fe+o(P.length,2)+"\0\0\0\0"+o(K,4)+o(g,4)+k+O+P}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function f(h,p,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var m=s(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,m=s(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(g){return d.DATA_DESCRIPTOR+o(g.crc32,4)+o(g.compressedSize,4)+o(g.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var m=this.bytesWritten-h,g=(function(y,v,b,w,x){var S=a.transformTo("string",x(w));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(y,2)+o(y,2)+o(v,4)+o(b,4)+o(S.length,2)+S})(this.dirRecords.length,m,h,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(h){this._sources.push(h);var p=this;return h.on("data",function(m){p.processChunk(m)}),h.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),h.on("error",function(m){p.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(h){var p=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var m=0;m<p.length;m++)try{p[m].error(h)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,p=0;p<h.length;p++)h[p].lock()},r.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){"use strict";var o=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(a,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(f,h){d++;var p=(function(v,b){var w=v||b,x=o[w];if(!x)throw new Error(w+" is not a valid compression method !");return x})(h.options.compression,l.compression),m=h.options.compressionOptions||l.compressionOptions||{},g=h.dir,y=h.date;h._compressWorker(p,m).withStreamInfo("file",{name:f,dir:g,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){"use strict";function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new o;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(o.prototype=n("./object")).loadAsync=n("./load"),o.support=n("./support"),o.defaults=n("./defaults"),o.version="3.10.1",o.loadAsync=function(s,a){return new o().loadAsync(s,a)},o.external=n("./external"),r.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){"use strict";var o=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function d(f){return new s.Promise(function(h,p){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){p(g)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(f,h){var p=this;return h=o.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",f,!0,h.optimizedBinaryString,h.base64).then(function(m){var g=new l(h);return g.load(m),g}).then(function(m){var g=[s.Promise.resolve(m)],y=m.files;if(h.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,x=o.resolve(b.fileNameStr);p.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(x).unsafeOriginalName=w)}return g.zipComment.length&&(p.comment=g.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../stream/GenericWorker");function a(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}o.inherits(a,s),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){"use strict";var o=n("readable-stream").Readable;function s(a,l,c){o.call(this,l),this._helper=a;var u=this;a.on("data",function(d,f){u.push(d)||u._helper.pause(),c&&c(f)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,o),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,s);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,s)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var s=new Buffer(o);return s.fill(0),s},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(n,r,i){"use strict";function o(w,x,S){var T,k=a.getTypeOf(x),C=a.extend(S||{},u);C.date=C.date||new Date,C.compression!==null&&(C.compression=C.compression.toUpperCase()),typeof C.unixPermissions=="string"&&(C.unixPermissions=parseInt(C.unixPermissions,8)),C.unixPermissions&&16384&C.unixPermissions&&(C.dir=!0),C.dosPermissions&&16&C.dosPermissions&&(C.dir=!0),C.dir&&(w=y(w)),C.createFolders&&(T=g(w))&&v.call(this,T,!0);var _=k==="string"&&C.binary===!1&&C.base64===!1;S&&S.binary!==void 0||(C.binary=!_),(x instanceof d&&x.uncompressedSize===0||C.dir||!x||x.length===0)&&(C.base64=!1,C.binary=!0,x="",C.compression="STORE",k="string");var P=null;P=x instanceof d||x instanceof l?x:p.isNode&&p.isStream(x)?new m(w,x):a.prepareContent(w,x,C.binary,C.optimizedBinaryString,C.base64);var E=new f(w,P,C);this.files[w]=E}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),d=n("./compressedObject"),f=n("./zipObject"),h=n("./generate"),p=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),g=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var x=w.lastIndexOf("/");return 0<x?w.substring(0,x):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},v=function(w,x){return x=x!==void 0?x:u.createFolders,w=y(w),this.files[w]||o.call(this,w,null,{dir:!0,createFolders:x}),this.files[w]};function b(w){return Object.prototype.toString.call(w)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var x,S,T;for(x in this.files)T=this.files[x],(S=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&w(S,T)},filter:function(w){var x=[];return this.forEach(function(S,T){w(S,T)&&x.push(T)}),x},file:function(w,x,S){if(arguments.length!==1)return w=this.root+w,o.call(this,w,x,S),this;if(b(w)){var T=w;return this.filter(function(C,_){return!_.dir&&T.test(C)})}var k=this.files[this.root+w];return k&&!k.dir?k:null},folder:function(w){if(!w)return this;if(b(w))return this.filter(function(k,C){return C.dir&&w.test(k)});var x=this.root+w,S=v.call(this,x),T=this.clone();return T.root=S.name,T},remove:function(w){w=this.root+w;var x=this.files[w];if(x||(w.slice(-1)!=="/"&&(w+="/"),x=this.files[w]),x&&!x.dir)delete this.files[w];else for(var S=this.filter(function(k,C){return C.name.slice(0,w.length)===w}),T=0;T<S.length;T++)delete this.files[S[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var x,S={};try{if((S=a.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var T=S.comment||this.comment||"";x=h.generateWorker(this,S,T)}catch(k){(x=new l("error")).error(k)}return new c(x,S.type||"string",S.mimeType)},generateAsync:function(w,x){return this.generateInternalStream(w).accumulate(x)},generateNodeStream:function(w,x){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===d)return f-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),d=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&d===f[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){"use strict";var o=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return o.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){"use strict";var o=n("./Uint8ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){"use strict";var o=n("./DataReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){"use strict";var o=n("./ArrayReader");function s(a){o.call(this,a)}n("../utils").inherits(s,o),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){"use strict";var o=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var f=o.getTypeOf(d);return o.checkSupport(f),f!=="string"||s.uint8array?f==="nodebuffer"?new c(d):s.uint8array?new u(o.transformTo("uint8array",d)):new a(o.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){"use strict";i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../utils");function a(l){o.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,o),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){"use strict";var o=n("./GenericWorker"),s=n("../crc32");function a(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,o),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}o.inherits(a,s),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=o.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}o.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){"use strict";function o(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=o},{}],29:[function(n,r,i){"use strict";var o=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),d=null;if(c.nodestream)try{d=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,m){return new u.Promise(function(g,y){var v=[],b=p._internalType,w=p._outputType,x=p._mimeType;p.on("data",function(S,T){v.push(S),m&&m(T)}).on("error",function(S){v=[],y(S)}).on("end",function(){try{g((function(S,T,k){switch(S){case"blob":return o.newBlob(o.transformTo("arraybuffer",T),k);case"base64":return l.encode(T);default:return o.transformTo(S,T)}})(w,(function(S,T){var k,C=0,_=null,P=0;for(k=0;k<T.length;k++)P+=T[k].length;switch(S){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(_=new Uint8Array(P),k=0;k<T.length;k++)_.set(T[k],C),C+=T[k].length;return _;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+S+"'")}})(b,v),x))}catch(S){y(S)}v=[]}).resume()})}function h(p,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,o.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}h.prototype={accumulate:function(p){return f(this,p)},on:function(p,m){var g=this;return p==="data"?this._worker.on(p,function(y){m.call(g,y.data,y.meta)}):this._worker.on(p,function(){o.delay(m,arguments,g)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},p)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){"use strict";if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){"use strict";for(var o=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(p){var m,g,y,v,b,w=p.length,x=0;for(v=0;v<w;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),x+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(x):new Array(x),v=b=0;b<x;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(h)},i.utf8decode=function(h){return s.nodebuffer?o.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,v,b=p.length,w=new Array(2*b);for(m=g=0;m<b;)if((y=p[m++])<128)w[g++]=y;else if(4<(v=c[y]))w[g++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&p[m++],v--;1<v?w[g++]=65533:y<65536?w[g++]=y:(y-=65536,w[g++]=55296|y>>10&1023,w[g++]=56320|1023&y)}return w.length!==g&&(w.subarray?w=w.subarray(0,g):w.length=g),o.applyFromCharCode(w)})(h=o.transformTo(s.uint8array?"uint8array":"array",h))},o.inherits(d,l),d.prototype.processChunk=function(h){var p=o.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var m=p;(p=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),p.set(m,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=(function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+c[v[w]]>b?w:b})(p),y=p;g!==p.length&&(s.uint8array?(y=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(y=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,o.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){"use strict";var o=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function c(m){return m}function u(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}n("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,y){var v=[],b=0,w=m.length;if(w<=y)return String.fromCharCode.apply(null,m);for(;b<w;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=i.getTypeOf(m),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function h(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=f;var p={};p.string={string:c,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return p.string.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:function(m){return u(m,a.allocBuffer(m.length))}},p.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},p.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return h(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},p.uint8array={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},p.nodebuffer={string:f,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return p.nodebuffer.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:c},i.transformTo=function(m,g){return g=g||"",m?(i.checkSupport(m),p[i.getTypeOf(g)][m](g)):g},i.resolve=function(m){for(var g=m.split("/"),y=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":o.nodebuffer&&a.isBuffer(m)?"nodebuffer":o.uint8array&&m instanceof Uint8Array?"uint8array":o.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!o[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,v="";for(y=0;y<(m||"").length;y++)v+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,v,b){return l.Promise.resolve(g).then(function(w){return o.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,S){var T=new FileReader;T.onload=function(k){x(k.target.result)},T.onerror=function(k){S(k.target.error)},T.readAsArrayBuffer(w)}):w}).then(function(w){var x=i.getTypeOf(w);return x?(x==="arraybuffer"?w=i.transformTo("uint8array",w):x==="string"&&(b?w=s.decode(w):y&&v!==!0&&(w=(function(S){return u(S,o.uint8array?new Uint8Array(S.length):new Array(S.length))})(w))),w):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(f)+", expected "+s.pretty(d)+")")}},isSignature:function(d,f){var h=this.reader.index;this.reader.setIndex(d);var p=this.reader.readString(4)===f;return this.reader.setIndex(h),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),f=c.uint8array?"uint8array":"array",h=s.transformTo(f,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,f,h,p=this.zip64EndOfCentralSize-44;0<p;)d=this.reader.readInt(2),f=this.reader.readInt(4),h=this.reader.readData(f),this.zip64ExtensibleData[d]={id:d,length:f,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,f;for(d=0;d<this.files.length;d++)f=this.files[d],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var f=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var p=f-h;if(0<p)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(d){this.reader=o(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){"use strict";var o=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),d=n("./support");function f(h,p){this.options=h,this.loadOptions=p}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var p,m;if(h.skip(22),this.fileNameLength=h.readInt(2),m=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((p=(function(g){for(var y in u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===g)return u[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,p,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var p=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(p),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,m,g,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)p=h.readInt(2),m=h.readInt(2),g=h.readData(m),this.extraFields[p]={id:p,length:m,value:g};h.setIndex(y)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var m=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileName)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var p=o(h.value);return p.readInt(1)!==1||l(this.fileComment)!==p.readInt(4)?null:c.utf8decode(p.readData(h.length-5))}return null}},r.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){"use strict";function o(p,m,g){this.name=p,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");o.prototype={internalStream:function(p){var m=null,g="string";try{if(!p)throw new Error("No output type specified.");var y=(g=p.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new u("error")).error(b)}return new s(m,g,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof c&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,p,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)o.prototype[d[h]]=f;r.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(o){"use strict";var s,a,l=o.MutationObserver||o.WebKitMutationObserver;if(l){var c=0,u=new l(p),d=o.document.createTextNode("");u.observe(d,{characterData:!0}),s=function(){d.data=c=++c%2}}else if(o.setImmediate||o.MessageChannel===void 0)s="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var m=o.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},o.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var f=new o.MessageChannel;f.port1.onmessage=p,s=function(){f.port2.postMessage(0)}}var h=[];function p(){var m,g;a=!0;for(var y=h.length;y;){for(g=h,h=[],m=-1;++m<y;)g[m]();y=h.length}a=!1}r.exports=function(m){h.push(m)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){"use strict";var o=n("immediate");function s(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,y!==s&&m(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(y,v,b){o(function(){var w;try{w=v(b)}catch(x){return a.reject(y,x)}w===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,w)})}function p(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function m(y,v){var b=!1;function w(T){b||(b=!0,a.reject(y,T))}function x(T){b||(b=!0,a.resolve(y,T))}var S=g(function(){v(x,w)});S.status==="error"&&w(S.value)}function g(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==u?h(b,this.state===c?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},a.resolve=function(y,v){var b=g(p,v);if(b.status==="error")return a.reject(y,b.value);var w=b.value;if(w)m(y,w);else{y.state=c,y.outcome=v;for(var x=-1,S=y.queue.length;++x<S;)y.queue[x].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var v=new this(s);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=new Array(b),S=0,T=-1,k=new this(s);++T<b;)C(y[T],T);return k;function C(_,P){v.resolve(_).then(function(E){x[P]=E,++S!==b||w||(w=!0,a.resolve(k,x))},function(E){w||(w=!0,a.reject(k,E))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var x=-1,S=new this(s);++x<b;)T=y[x],v.resolve(T).then(function(k){w||(w=!0,a.resolve(S,k))},function(k){w||(w=!0,a.reject(S,k))});var T;return S}},{immediate:36}],38:[function(n,r,i){"use strict";var o={};(0,n("./lib/utils/common").assign)(o,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){"use strict";var o=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,d=0,f=-1,h=0,p=8;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({level:f,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=o.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&o.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?a.string2buf(v.dictionary):u.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=o.deflateSetDictionary(this.strm,w))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,v){var b,w,x=this.strm,S=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?x.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?x.input=new Uint8Array(y):x.input=y,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(S),x.next_out=0,x.avail_out=S),(b=o.deflate(x,w))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return w===4?(b=o.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):w!==2||(this.onEnd(d),!(x.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){"use strict";var o=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=n("./zlib/gzheader"),f=Object.prototype.toString;function h(m){if(!(this instanceof h))return new h(m);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var y=o.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,o.inflateGetHeader(this.strm,this.header)}function p(m,g){var y=new h(g);if(y.push(m,!0),y.err)throw y.msg||c[y.err];return y.result}h.prototype.push=function(m,g){var y,v,b,w,x,S,T=this.strm,k=this.options.chunkSize,C=this.options.dictionary,_=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?T.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?T.input=new Uint8Array(m):T.input=m,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(k),T.next_out=0,T.avail_out=k),(y=o.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(S=typeof C=="string"?a.string2buf(C):f.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=o.inflateSetDictionary(this.strm,S)),y===l.Z_BUF_ERROR&&_===!0&&(y=l.Z_OK,_=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==l.Z_STREAM_END&&(T.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(T.output,T.next_out),w=T.next_out-b,x=a.buf2string(T.output,b),T.next_out=w,T.avail_out=k-w,w&&s.arraySet(T.output,T.output,b,w,0),this.onData(x)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(_=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=o.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(m){this.chunks.push(m)},h.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=h,i.inflate=p,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,p(m,g)},i.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){"use strict";var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(l[d]=u[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,d,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+d),f);else for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){var c,u,d,f,h,p;for(c=d=0,u=l.length;c<u;c++)d+=l[c].length;for(p=new Uint8Array(d),c=f=0,u=l.length;c<u;c++)h=l[c],p.set(h,f),f+=h.length;return p}},a={arraySet:function(l,c,u,d,f){for(var h=0;h<d;h++)l[f+h]=c[u+h]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(o)},{}],42:[function(n,r,i){"use strict";var o=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new o.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(d,f){if(f<65537&&(d.subarray&&a||!d.subarray&&s))return String.fromCharCode.apply(null,o.shrinkBuf(d,f));for(var h="",p=0;p<f;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,i.string2buf=function(d){var f,h,p,m,g,y=d.length,v=0;for(m=0;m<y;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=new o.Buf8(v),m=g=0;g<v;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),h<128?f[g++]=h:(h<2048?f[g++]=192|h>>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(d){return u(d,d.length)},i.binstring2buf=function(d){for(var f=new o.Buf8(d.length),h=0,p=f.length;h<p;h++)f[h]=d.charCodeAt(h);return f},i.buf2string=function(d,f){var h,p,m,g,y=f||d.length,v=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)v[p++]=m;else if(4<(g=l[m]))v[p++]=65533,h+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&h<y;)m=m<<6|63&d[h++],g--;1<g?v[p++]=65533:m<65536?v[p++]=m:(m-=65536,v[p++]=55296|m>>10&1023,v[p++]=56320|1023&m)}return u(v,p)},i.utf8border=function(d,f){var h;for((f=f||d.length)>d.length&&(f=d.length),h=f-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?f:h+l[d[h]]>f?h:f}},{"./common":41}],43:[function(n,r,i){"use strict";r.exports=function(o,s,a,l){for(var c=65535&o|0,u=o>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;u=u+(c=c+s[l++]|0)|0,--d;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){"use strict";var o=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,c){var u=o,d=c+l;s^=-1;for(var f=c;f<d;f++)s=s>>>8^u[255&(s^a[f])];return-1^s}},{}],46:[function(n,r,i){"use strict";var o,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),d=0,f=4,h=0,p=-2,m=-1,g=4,y=2,v=8,b=9,w=286,x=30,S=19,T=2*w+1,k=15,C=3,_=258,P=_+C+1,E=42,L=113,R=1,O=2,F=3,B=4;function j(N,X){return N.msg=u[X],X}function M(N){return(N<<1)-(4<N?9:0)}function z(N){for(var X=N.length;0<=--X;)N[X]=0}function $(N){var X=N.state,ce=X.pending;ce>N.avail_out&&(ce=N.avail_out),ce!==0&&(s.arraySet(N.output,X.pending_buf,X.pending_out,ce,N.next_out),N.next_out+=ce,X.pending_out+=ce,N.total_out+=ce,N.avail_out-=ce,X.pending-=ce,X.pending===0&&(X.pending_out=0))}function K(N,X){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,X),N.block_start=N.strstart,$(N.strm)}function U(N,X){N.pending_buf[N.pending++]=X}function fe(N,X){N.pending_buf[N.pending++]=X>>>8&255,N.pending_buf[N.pending++]=255&X}function ee(N,X){var ce,te,ie=N.max_chain_length,q=N.strstart,Q=N.prev_length,le=N.nice_match,se=N.strstart>N.w_size-P?N.strstart-(N.w_size-P):0,me=N.window,Se=N.w_mask,Ee=N.prev,be=N.strstart+_,ue=me[q+Q-1],Ie=me[q+Q];N.prev_length>=N.good_match&&(ie>>=2),le>N.lookahead&&(le=N.lookahead);do if(me[(ce=X)+Q]===Ie&&me[ce+Q-1]===ue&&me[ce]===me[q]&&me[++ce]===me[q+1]){q+=2,ce++;do;while(me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&me[++q]===me[++ce]&&q<be);if(te=_-(be-q),q=be-_,Q<te){if(N.match_start=X,le<=(Q=te))break;ue=me[q+Q-1],Ie=me[q+Q]}}while((X=Ee[X&Se])>se&&--ie!=0);return Q<=N.lookahead?Q:N.lookahead}function Z(N){var X,ce,te,ie,q,Q,le,se,me,Se,Ee=N.w_size;do{if(ie=N.window_size-N.lookahead-N.strstart,N.strstart>=Ee+(Ee-P)){for(s.arraySet(N.window,N.window,Ee,Ee,0),N.match_start-=Ee,N.strstart-=Ee,N.block_start-=Ee,X=ce=N.hash_size;te=N.head[--X],N.head[X]=Ee<=te?te-Ee:0,--ce;);for(X=ce=Ee;te=N.prev[--X],N.prev[X]=Ee<=te?te-Ee:0,--ce;);ie+=Ee}if(N.strm.avail_in===0)break;if(Q=N.strm,le=N.window,se=N.strstart+N.lookahead,me=ie,Se=void 0,Se=Q.avail_in,me<Se&&(Se=me),ce=Se===0?0:(Q.avail_in-=Se,s.arraySet(le,Q.input,Q.next_in,Se,se),Q.state.wrap===1?Q.adler=l(Q.adler,le,Se,se):Q.state.wrap===2&&(Q.adler=c(Q.adler,le,Se,se)),Q.next_in+=Se,Q.total_in+=Se,Se),N.lookahead+=ce,N.lookahead+N.insert>=C)for(q=N.strstart-N.insert,N.ins_h=N.window[q],N.ins_h=(N.ins_h<<N.hash_shift^N.window[q+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[q+C-1])&N.hash_mask,N.prev[q&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=q,q++,N.insert--,!(N.lookahead+N.insert<C)););}while(N.lookahead<P&&N.strm.avail_in!==0)}function re(N,X){for(var ce,te;;){if(N.lookahead<P){if(Z(N),N.lookahead<P&&X===d)return R;if(N.lookahead===0)break}if(ce=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),ce!==0&&N.strstart-ce<=N.w_size-P&&(N.match_length=ee(N,ce)),N.match_length>=C)if(te=a._tr_tally(N,N.strstart-N.match_start,N.match_length-C),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=C){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart,--N.match_length!=0;);N.strstart++}else N.strstart+=N.match_length,N.match_length=0,N.ins_h=N.window[N.strstart],N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+1])&N.hash_mask;else te=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++;if(te&&(K(N,!1),N.strm.avail_out===0))return R}return N.insert=N.strstart<C-1?N.strstart:C-1,X===f?(K(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(K(N,!1),N.strm.avail_out===0)?R:O}function ve(N,X){for(var ce,te,ie;;){if(N.lookahead<P){if(Z(N),N.lookahead<P&&X===d)return R;if(N.lookahead===0)break}if(ce=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),N.prev_length=N.match_length,N.prev_match=N.match_start,N.match_length=C-1,ce!==0&&N.prev_length<N.max_lazy_match&&N.strstart-ce<=N.w_size-P&&(N.match_length=ee(N,ce),N.match_length<=5&&(N.strategy===1||N.match_length===C&&4096<N.strstart-N.match_start)&&(N.match_length=C-1)),N.prev_length>=C&&N.match_length<=N.prev_length){for(ie=N.strstart+N.lookahead-C,te=a._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-C),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=ie&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,ce=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),--N.prev_length!=0;);if(N.match_available=0,N.match_length=C-1,N.strstart++,te&&(K(N,!1),N.strm.avail_out===0))return R}else if(N.match_available){if((te=a._tr_tally(N,0,N.window[N.strstart-1]))&&K(N,!1),N.strstart++,N.lookahead--,N.strm.avail_out===0)return R}else N.match_available=1,N.strstart++,N.lookahead--}return N.match_available&&(te=a._tr_tally(N,0,N.window[N.strstart-1]),N.match_available=0),N.insert=N.strstart<C-1?N.strstart:C-1,X===f?(K(N,!0),N.strm.avail_out===0?F:B):N.last_lit&&(K(N,!1),N.strm.avail_out===0)?R:O}function J(N,X,ce,te,ie){this.good_length=N,this.max_lazy=X,this.nice_length=ce,this.max_chain=te,this.func=ie}function ke(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*T),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*S+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(k+1),this.heap=new s.Buf16(2*w+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*w+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ae(N){var X;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(X=N.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?E:L,N.adler=X.wrap===2?0:1,X.last_flush=d,a._tr_init(X),h):j(N,p)}function G(N){var X=Ae(N);return X===h&&(function(ce){ce.window_size=2*ce.w_size,z(ce.head),ce.max_lazy_match=o[ce.level].max_lazy,ce.good_match=o[ce.level].good_length,ce.nice_match=o[ce.level].nice_length,ce.max_chain_length=o[ce.level].max_chain,ce.strstart=0,ce.block_start=0,ce.lookahead=0,ce.insert=0,ce.match_length=ce.prev_length=C-1,ce.match_available=0,ce.ins_h=0})(N.state),X}function D(N,X,ce,te,ie,q){if(!N)return p;var Q=1;if(X===m&&(X=6),te<0?(Q=0,te=-te):15<te&&(Q=2,te-=16),ie<1||b<ie||ce!==v||te<8||15<te||X<0||9<X||q<0||g<q)return j(N,p);te===8&&(te=9);var le=new ke;return(N.state=le).strm=N,le.wrap=Q,le.gzhead=null,le.w_bits=te,le.w_size=1<<le.w_bits,le.w_mask=le.w_size-1,le.hash_bits=ie+7,le.hash_size=1<<le.hash_bits,le.hash_mask=le.hash_size-1,le.hash_shift=~~((le.hash_bits+C-1)/C),le.window=new s.Buf8(2*le.w_size),le.head=new s.Buf16(le.hash_size),le.prev=new s.Buf16(le.w_size),le.lit_bufsize=1<<ie+6,le.pending_buf_size=4*le.lit_bufsize,le.pending_buf=new s.Buf8(le.pending_buf_size),le.d_buf=1*le.lit_bufsize,le.l_buf=3*le.lit_bufsize,le.level=X,le.strategy=q,le.method=ce,G(N)}o=[new J(0,0,0,0,function(N,X){var ce=65535;for(ce>N.pending_buf_size-5&&(ce=N.pending_buf_size-5);;){if(N.lookahead<=1){if(Z(N),N.lookahead===0&&X===d)return R;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var te=N.block_start+ce;if((N.strstart===0||N.strstart>=te)&&(N.lookahead=N.strstart-te,N.strstart=te,K(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-P&&(K(N,!1),N.strm.avail_out===0))return R}return N.insert=0,X===f?(K(N,!0),N.strm.avail_out===0?F:B):(N.strstart>N.block_start&&(K(N,!1),N.strm.avail_out),R)}),new J(4,4,8,4,re),new J(4,5,16,8,re),new J(4,6,32,32,re),new J(4,4,16,16,ve),new J(8,16,32,32,ve),new J(8,16,128,128,ve),new J(8,32,128,256,ve),new J(32,128,258,1024,ve),new J(32,258,258,4096,ve)],i.deflateInit=function(N,X){return D(N,X,v,15,8,0)},i.deflateInit2=D,i.deflateReset=G,i.deflateResetKeep=Ae,i.deflateSetHeader=function(N,X){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=X,h):p},i.deflate=function(N,X){var ce,te,ie,q;if(!N||!N.state||5<X||X<0)return N?j(N,p):p;if(te=N.state,!N.output||!N.input&&N.avail_in!==0||te.status===666&&X!==f)return j(N,N.avail_out===0?-5:p);if(te.strm=N,ce=te.last_flush,te.last_flush=X,te.status===E)if(te.wrap===2)N.adler=0,U(te,31),U(te,139),U(te,8),te.gzhead?(U(te,(te.gzhead.text?1:0)+(te.gzhead.hcrc?2:0)+(te.gzhead.extra?4:0)+(te.gzhead.name?8:0)+(te.gzhead.comment?16:0)),U(te,255&te.gzhead.time),U(te,te.gzhead.time>>8&255),U(te,te.gzhead.time>>16&255),U(te,te.gzhead.time>>24&255),U(te,te.level===9?2:2<=te.strategy||te.level<2?4:0),U(te,255&te.gzhead.os),te.gzhead.extra&&te.gzhead.extra.length&&(U(te,255&te.gzhead.extra.length),U(te,te.gzhead.extra.length>>8&255)),te.gzhead.hcrc&&(N.adler=c(N.adler,te.pending_buf,te.pending,0)),te.gzindex=0,te.status=69):(U(te,0),U(te,0),U(te,0),U(te,0),U(te,0),U(te,te.level===9?2:2<=te.strategy||te.level<2?4:0),U(te,3),te.status=L);else{var Q=v+(te.w_bits-8<<4)<<8;Q|=(2<=te.strategy||te.level<2?0:te.level<6?1:te.level===6?2:3)<<6,te.strstart!==0&&(Q|=32),Q+=31-Q%31,te.status=L,fe(te,Q),te.strstart!==0&&(fe(te,N.adler>>>16),fe(te,65535&N.adler)),N.adler=1}if(te.status===69)if(te.gzhead.extra){for(ie=te.pending;te.gzindex<(65535&te.gzhead.extra.length)&&(te.pending!==te.pending_buf_size||(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending!==te.pending_buf_size));)U(te,255&te.gzhead.extra[te.gzindex]),te.gzindex++;te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),te.gzindex===te.gzhead.extra.length&&(te.gzindex=0,te.status=73)}else te.status=73;if(te.status===73)if(te.gzhead.name){ie=te.pending;do{if(te.pending===te.pending_buf_size&&(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending===te.pending_buf_size)){q=1;break}q=te.gzindex<te.gzhead.name.length?255&te.gzhead.name.charCodeAt(te.gzindex++):0,U(te,q)}while(q!==0);te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),q===0&&(te.gzindex=0,te.status=91)}else te.status=91;if(te.status===91)if(te.gzhead.comment){ie=te.pending;do{if(te.pending===te.pending_buf_size&&(te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),$(N),ie=te.pending,te.pending===te.pending_buf_size)){q=1;break}q=te.gzindex<te.gzhead.comment.length?255&te.gzhead.comment.charCodeAt(te.gzindex++):0,U(te,q)}while(q!==0);te.gzhead.hcrc&&te.pending>ie&&(N.adler=c(N.adler,te.pending_buf,te.pending-ie,ie)),q===0&&(te.status=103)}else te.status=103;if(te.status===103&&(te.gzhead.hcrc?(te.pending+2>te.pending_buf_size&&$(N),te.pending+2<=te.pending_buf_size&&(U(te,255&N.adler),U(te,N.adler>>8&255),N.adler=0,te.status=L)):te.status=L),te.pending!==0){if($(N),N.avail_out===0)return te.last_flush=-1,h}else if(N.avail_in===0&&M(X)<=M(ce)&&X!==f)return j(N,-5);if(te.status===666&&N.avail_in!==0)return j(N,-5);if(N.avail_in!==0||te.lookahead!==0||X!==d&&te.status!==666){var le=te.strategy===2?(function(se,me){for(var Se;;){if(se.lookahead===0&&(Z(se),se.lookahead===0)){if(me===d)return R;break}if(se.match_length=0,Se=a._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++,Se&&(K(se,!1),se.strm.avail_out===0))return R}return se.insert=0,me===f?(K(se,!0),se.strm.avail_out===0?F:B):se.last_lit&&(K(se,!1),se.strm.avail_out===0)?R:O})(te,X):te.strategy===3?(function(se,me){for(var Se,Ee,be,ue,Ie=se.window;;){if(se.lookahead<=_){if(Z(se),se.lookahead<=_&&me===d)return R;if(se.lookahead===0)break}if(se.match_length=0,se.lookahead>=C&&0<se.strstart&&(Ee=Ie[be=se.strstart-1])===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]){ue=se.strstart+_;do;while(Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&Ee===Ie[++be]&&be<ue);se.match_length=_-(ue-be),se.match_length>se.lookahead&&(se.match_length=se.lookahead)}if(se.match_length>=C?(Se=a._tr_tally(se,1,se.match_length-C),se.lookahead-=se.match_length,se.strstart+=se.match_length,se.match_length=0):(Se=a._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++),Se&&(K(se,!1),se.strm.avail_out===0))return R}return se.insert=0,me===f?(K(se,!0),se.strm.avail_out===0?F:B):se.last_lit&&(K(se,!1),se.strm.avail_out===0)?R:O})(te,X):o[te.level].func(te,X);if(le!==F&&le!==B||(te.status=666),le===R||le===F)return N.avail_out===0&&(te.last_flush=-1),h;if(le===O&&(X===1?a._tr_align(te):X!==5&&(a._tr_stored_block(te,0,0,!1),X===3&&(z(te.head),te.lookahead===0&&(te.strstart=0,te.block_start=0,te.insert=0))),$(N),N.avail_out===0))return te.last_flush=-1,h}return X!==f?h:te.wrap<=0?1:(te.wrap===2?(U(te,255&N.adler),U(te,N.adler>>8&255),U(te,N.adler>>16&255),U(te,N.adler>>24&255),U(te,255&N.total_in),U(te,N.total_in>>8&255),U(te,N.total_in>>16&255),U(te,N.total_in>>24&255)):(fe(te,N.adler>>>16),fe(te,65535&N.adler)),$(N),0<te.wrap&&(te.wrap=-te.wrap),te.pending!==0?h:1)},i.deflateEnd=function(N){var X;return N&&N.state?(X=N.state.status)!==E&&X!==69&&X!==73&&X!==91&&X!==103&&X!==L&&X!==666?j(N,p):(N.state=null,X===L?j(N,-3):h):p},i.deflateSetDictionary=function(N,X){var ce,te,ie,q,Q,le,se,me,Se=X.length;if(!N||!N.state||(q=(ce=N.state).wrap)===2||q===1&&ce.status!==E||ce.lookahead)return p;for(q===1&&(N.adler=l(N.adler,X,Se,0)),ce.wrap=0,Se>=ce.w_size&&(q===0&&(z(ce.head),ce.strstart=0,ce.block_start=0,ce.insert=0),me=new s.Buf8(ce.w_size),s.arraySet(me,X,Se-ce.w_size,ce.w_size,0),X=me,Se=ce.w_size),Q=N.avail_in,le=N.next_in,se=N.input,N.avail_in=Se,N.next_in=0,N.input=X,Z(ce);ce.lookahead>=C;){for(te=ce.strstart,ie=ce.lookahead-(C-1);ce.ins_h=(ce.ins_h<<ce.hash_shift^ce.window[te+C-1])&ce.hash_mask,ce.prev[te&ce.w_mask]=ce.head[ce.ins_h],ce.head[ce.ins_h]=te,te++,--ie;);ce.strstart=te,ce.lookahead=C-1,Z(ce)}return ce.strstart+=ce.lookahead,ce.block_start=ce.strstart,ce.insert=ce.lookahead,ce.lookahead=0,ce.match_length=ce.prev_length=C-1,ce.match_available=0,N.next_in=le,N.input=se,N.avail_in=Q,ce.wrap=q,h},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){"use strict";r.exports=function(o,s){var a=o.state,l=o.next_in,c,u,d,f,h,p,m,g,y,v,b,w,x,S,T,k,C,_,P,E,L,R=o.input,O;c=l+(o.avail_in-5),u=o.next_out,O=o.output,d=u-(s-o.avail_out),f=u+(o.avail_out-257),h=a.dmax,p=a.wsize,m=a.whave,g=a.wnext,y=a.window,v=a.hold,b=a.bits,w=a.lencode,x=a.distcode,S=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),k=w[v&S];t:for(;;){if(v>>>=C=k>>>24,b-=C,(C=k>>>16&255)===0)O[u++]=65535&k;else{if(!(16&C)){if((64&C)==0){k=w[(65535&k)+(v&(1<<C)-1)];continue t}if(32&C){a.mode=12;break e}o.msg="invalid literal/length code",a.mode=30;break e}_=65535&k,(C&=15)&&(b<C&&(v+=R[l++]<<b,b+=8),_+=v&(1<<C)-1,v>>>=C,b-=C),b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),k=x[v&T];n:for(;;){if(v>>>=C=k>>>24,b-=C,!(16&(C=k>>>16&255))){if((64&C)==0){k=x[(65535&k)+(v&(1<<C)-1)];continue n}o.msg="invalid distance code",a.mode=30;break e}if(P=65535&k,b<(C&=15)&&(v+=R[l++]<<b,(b+=8)<C&&(v+=R[l++]<<b,b+=8)),h<(P+=v&(1<<C)-1)){o.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=C,b-=C,(C=u-d)<P){if(m<(C=P-C)&&a.sane){o.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(E=0)===g){if(E+=p-C,C<_){for(_-=C;O[u++]=y[E++],--C;);E=u-P,L=O}}else if(g<C){if(E+=p+g-C,(C-=g)<_){for(_-=C;O[u++]=y[E++],--C;);if(E=0,g<_){for(_-=C=g;O[u++]=y[E++],--C;);E=u-P,L=O}}}else if(E+=g-C,C<_){for(_-=C;O[u++]=y[E++],--C;);E=u-P,L=O}for(;2<_;)O[u++]=L[E++],O[u++]=L[E++],O[u++]=L[E++],_-=3;_&&(O[u++]=L[E++],1<_&&(O[u++]=L[E++]))}else{for(E=u-P;O[u++]=O[E++],O[u++]=O[E++],O[u++]=O[E++],2<(_-=3););_&&(O[u++]=O[E++],1<_&&(O[u++]=O[E++]))}break}}break}}while(l<c&&u<f);l-=_=b>>3,v&=(1<<(b-=_<<3))-1,o.next_in=l,o.next_out=u,o.avail_in=l<c?c-l+5:5-(l-c),o.avail_out=u<f?f-u+257:257-(u-f),a.hold=v,a.bits=b}},{}],49:[function(n,r,i){"use strict";var o=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,d=2,f=0,h=-2,p=1,m=852,g=592;function y(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(E){var L;return E&&E.state?(L=E.state,E.total_in=E.total_out=L.total=0,E.msg="",L.wrap&&(E.adler=1&L.wrap),L.mode=p,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new o.Buf32(m),L.distcode=L.distdyn=new o.Buf32(g),L.sane=1,L.back=-1,f):h}function w(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,b(E)):h}function x(E,L){var R,O;return E&&E.state?(O=E.state,L<0?(R=0,L=-L):(R=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=R,O.wbits=L,w(E))):h}function S(E,L){var R,O;return E?(O=new v,(E.state=O).window=null,(R=x(E,L))!==f&&(E.state=null),R):h}var T,k,C=!0;function _(E){if(C){var L;for(T=new o.Buf32(512),k=new o.Buf32(32),L=0;L<144;)E.lens[L++]=8;for(;L<256;)E.lens[L++]=9;for(;L<280;)E.lens[L++]=7;for(;L<288;)E.lens[L++]=8;for(c(u,E.lens,0,288,T,0,E.work,{bits:9}),L=0;L<32;)E.lens[L++]=5;c(d,E.lens,0,32,k,0,E.work,{bits:5}),C=!1}E.lencode=T,E.lenbits=9,E.distcode=k,E.distbits=5}function P(E,L,R,O){var F,B=E.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new o.Buf8(B.wsize)),O>=B.wsize?(o.arraySet(B.window,L,R-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(O<(F=B.wsize-B.wnext)&&(F=O),o.arraySet(B.window,L,R-O,F,B.wnext),(O-=F)?(o.arraySet(B.window,L,R-O,O,0),B.wnext=O,B.whave=B.wsize):(B.wnext+=F,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=F))),0}i.inflateReset=w,i.inflateReset2=x,i.inflateResetKeep=b,i.inflateInit=function(E){return S(E,15)},i.inflateInit2=S,i.inflate=function(E,L){var R,O,F,B,j,M,z,$,K,U,fe,ee,Z,re,ve,J,ke,Ae,G,D,N,X,ce,te,ie=0,q=new o.Buf8(4),Q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return h;(R=E.state).mode===12&&(R.mode=13),j=E.next_out,F=E.output,z=E.avail_out,B=E.next_in,O=E.input,M=E.avail_in,$=R.hold,K=R.bits,U=M,fe=z,X=f;e:for(;;)switch(R.mode){case p:if(R.wrap===0){R.mode=13;break}for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(2&R.wrap&&$===35615){q[R.check=0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0),K=$=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&$)<<8)+($>>8))%31){E.msg="incorrect header check",R.mode=30;break}if((15&$)!=8){E.msg="unknown compression method",R.mode=30;break}if(K-=4,N=8+(15&($>>>=4)),R.wbits===0)R.wbits=N;else if(N>R.wbits){E.msg="invalid window size",R.mode=30;break}R.dmax=1<<N,E.adler=R.check=1,R.mode=512&$?10:12,K=$=0;break;case 2:for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(R.flags=$,(255&R.flags)!=8){E.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){E.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=$>>8&1),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0,R.mode=3;case 3:for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.head&&(R.head.time=$),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,q[2]=$>>>16&255,q[3]=$>>>24&255,R.check=a(R.check,q,4,0)),K=$=0,R.mode=4;case 4:for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.head&&(R.head.xflags=255&$,R.head.os=$>>8),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0,R.mode=5;case 5:if(1024&R.flags){for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.length=$,R.head&&(R.head.extra_len=$),512&R.flags&&(q[0]=255&$,q[1]=$>>>8&255,R.check=a(R.check,q,2,0)),K=$=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(M<(ee=R.length)&&(ee=M),ee&&(R.head&&(N=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),o.arraySet(R.head.extra,O,B,ee,N)),512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,R.length-=ee),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(M===0)break e;for(ee=0;N=O[B+ee++],R.head&&N&&R.length<65536&&(R.head.name+=String.fromCharCode(N)),N&&ee<M;);if(512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,N)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(M===0)break e;for(ee=0;N=O[B+ee++],R.head&&N&&R.length<65536&&(R.head.comment+=String.fromCharCode(N)),N&&ee<M;);if(512&R.flags&&(R.check=a(R.check,O,ee,B)),M-=ee,B+=ee,N)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;K<16;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($!==(65535&R.check)){E.msg="header crc mismatch",R.mode=30;break}K=$=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),E.adler=R.check=0,R.mode=12;break;case 10:for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}E.adler=R.check=y($),K=$=0,R.mode=11;case 11:if(R.havedict===0)return E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,2;E.adler=R.check=1,R.mode=12;case 12:if(L===5||L===6)break e;case 13:if(R.last){$>>>=7&K,K-=7&K,R.mode=27;break}for(;K<3;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}switch(R.last=1&$,K-=1,3&($>>>=1)){case 0:R.mode=14;break;case 1:if(_(R),R.mode=20,L!==6)break;$>>>=2,K-=2;break e;case 2:R.mode=17;break;case 3:E.msg="invalid block type",R.mode=30}$>>>=2,K-=2;break;case 14:for($>>>=7&K,K-=7&K;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if((65535&$)!=($>>>16^65535)){E.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&$,K=$=0,R.mode=15,L===6)break e;case 15:R.mode=16;case 16:if(ee=R.length){if(M<ee&&(ee=M),z<ee&&(ee=z),ee===0)break e;o.arraySet(F,O,B,ee,j),M-=ee,B+=ee,z-=ee,j+=ee,R.length-=ee;break}R.mode=12;break;case 17:for(;K<14;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(R.nlen=257+(31&$),$>>>=5,K-=5,R.ndist=1+(31&$),$>>>=5,K-=5,R.ncode=4+(15&$),$>>>=4,K-=4,286<R.nlen||30<R.ndist){E.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;K<3;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.lens[Q[R.have++]]=7&$,$>>>=3,K-=3}for(;R.have<19;)R.lens[Q[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ce={bits:R.lenbits},X=c(0,R.lens,0,19,R.lencode,0,R.work,ce),R.lenbits=ce.bits,X){E.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;J=(ie=R.lencode[$&(1<<R.lenbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(ke<16)$>>>=ve,K-=ve,R.lens[R.have++]=ke;else{if(ke===16){for(te=ve+2;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($>>>=ve,K-=ve,R.have===0){E.msg="invalid bit length repeat",R.mode=30;break}N=R.lens[R.have-1],ee=3+(3&$),$>>>=2,K-=2}else if(ke===17){for(te=ve+3;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}K-=ve,N=0,ee=3+(7&($>>>=ve)),$>>>=3,K-=3}else{for(te=ve+7;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}K-=ve,N=0,ee=11+(127&($>>>=ve)),$>>>=7,K-=7}if(R.have+ee>R.nlen+R.ndist){E.msg="invalid bit length repeat",R.mode=30;break}for(;ee--;)R.lens[R.have++]=N}}if(R.mode===30)break;if(R.lens[256]===0){E.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ce={bits:R.lenbits},X=c(u,R.lens,0,R.nlen,R.lencode,0,R.work,ce),R.lenbits=ce.bits,X){E.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ce={bits:R.distbits},X=c(d,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ce),R.distbits=ce.bits,X){E.msg="invalid distances set",R.mode=30;break}if(R.mode=20,L===6)break e;case 20:R.mode=21;case 21:if(6<=M&&258<=z){E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,l(E,fe),j=E.next_out,F=E.output,z=E.avail_out,B=E.next_in,O=E.input,M=E.avail_in,$=R.hold,K=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;J=(ie=R.lencode[$&(1<<R.lenbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if(J&&(240&J)==0){for(Ae=ve,G=J,D=ke;J=(ie=R.lencode[D+(($&(1<<Ae+G)-1)>>Ae)])>>>16&255,ke=65535&ie,!(Ae+(ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}$>>>=Ae,K-=Ae,R.back+=Ae}if($>>>=ve,K-=ve,R.back+=ve,R.length=ke,J===0){R.mode=26;break}if(32&J){R.back=-1,R.mode=12;break}if(64&J){E.msg="invalid literal/length code",R.mode=30;break}R.extra=15&J,R.mode=22;case 22:if(R.extra){for(te=R.extra;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.length+=$&(1<<R.extra)-1,$>>>=R.extra,K-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;J=(ie=R.distcode[$&(1<<R.distbits)-1])>>>16&255,ke=65535&ie,!((ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if((240&J)==0){for(Ae=ve,G=J,D=ke;J=(ie=R.distcode[D+(($&(1<<Ae+G)-1)>>Ae)])>>>16&255,ke=65535&ie,!(Ae+(ve=ie>>>24)<=K);){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}$>>>=Ae,K-=Ae,R.back+=Ae}if($>>>=ve,K-=ve,R.back+=ve,64&J){E.msg="invalid distance code",R.mode=30;break}R.offset=ke,R.extra=15&J,R.mode=24;case 24:if(R.extra){for(te=R.extra;K<te;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}R.offset+=$&(1<<R.extra)-1,$>>>=R.extra,K-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){E.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(z===0)break e;if(ee=fe-z,R.offset>ee){if((ee=R.offset-ee)>R.whave&&R.sane){E.msg="invalid distance too far back",R.mode=30;break}Z=ee>R.wnext?(ee-=R.wnext,R.wsize-ee):R.wnext-ee,ee>R.length&&(ee=R.length),re=R.window}else re=F,Z=j-R.offset,ee=R.length;for(z<ee&&(ee=z),z-=ee,R.length-=ee;F[j++]=re[Z++],--ee;);R.length===0&&(R.mode=21);break;case 26:if(z===0)break e;F[j++]=R.length,z--,R.mode=21;break;case 27:if(R.wrap){for(;K<32;){if(M===0)break e;M--,$|=O[B++]<<K,K+=8}if(fe-=z,E.total_out+=fe,R.total+=fe,fe&&(E.adler=R.check=R.flags?a(R.check,F,fe,j-fe):s(R.check,F,fe,j-fe)),fe=z,(R.flags?$:y($))!==R.check){E.msg="incorrect data check",R.mode=30;break}K=$=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;K<32;){if(M===0)break e;M--,$+=O[B++]<<K,K+=8}if($!==(4294967295&R.total)){E.msg="incorrect length check",R.mode=30;break}K=$=0}R.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;default:return h}return E.next_out=j,E.avail_out=z,E.next_in=B,E.avail_in=M,R.hold=$,R.bits=K,(R.wsize||fe!==E.avail_out&&R.mode<30&&(R.mode<27||L!==4))&&P(E,E.output,E.next_out,fe-E.avail_out)?(R.mode=31,-4):(U-=E.avail_in,fe-=E.avail_out,E.total_in+=U,E.total_out+=fe,R.total+=fe,R.wrap&&fe&&(E.adler=R.check=R.flags?a(R.check,F,fe,E.next_out-fe):s(R.check,F,fe,E.next_out-fe)),E.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(U==0&&fe===0||L===4)&&X===f&&(X=-5),X)},i.inflateEnd=function(E){if(!E||!E.state)return h;var L=E.state;return L.window&&(L.window=null),E.state=null,f},i.inflateGetHeader=function(E,L){var R;return E&&E.state?(2&(R=E.state).wrap)==0?h:((R.head=L).done=!1,f):h},i.inflateSetDictionary=function(E,L){var R,O=L.length;return E&&E.state?(R=E.state).wrap!==0&&R.mode!==11?h:R.mode===11&&s(1,L,O,0)!==R.check?-3:P(E,L,O,O)?(R.mode=31,-4):(R.havedict=1,f):h},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){"use strict";var o=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,d,f,h,p,m,g,y){var v,b,w,x,S,T,k,C,_,P=y.bits,E=0,L=0,R=0,O=0,F=0,B=0,j=0,M=0,z=0,$=0,K=null,U=0,fe=new o.Buf16(16),ee=new o.Buf16(16),Z=null,re=0;for(E=0;E<=15;E++)fe[E]=0;for(L=0;L<h;L++)fe[d[f+L]]++;for(F=P,O=15;1<=O&&fe[O]===0;O--);if(O<F&&(F=O),O===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(R=1;R<O&&fe[R]===0;R++);for(F<R&&(F=R),E=M=1;E<=15;E++)if(M<<=1,(M-=fe[E])<0)return-1;if(0<M&&(u===0||O!==1))return-1;for(ee[1]=0,E=1;E<15;E++)ee[E+1]=ee[E]+fe[E];for(L=0;L<h;L++)d[f+L]!==0&&(g[ee[d[f+L]]++]=L);if(T=u===0?(K=Z=g,19):u===1?(K=s,U-=257,Z=a,re-=257,256):(K=l,Z=c,-1),E=R,S=m,j=L=$=0,w=-1,x=(z=1<<(B=F))-1,u===1&&852<z||u===2&&592<z)return 1;for(;;){for(k=E-j,_=g[L]<T?(C=0,g[L]):g[L]>T?(C=Z[re+g[L]],K[U+g[L]]):(C=96,0),v=1<<E-j,R=b=1<<B;p[S+($>>j)+(b-=v)]=k<<24|C<<16|_|0,b!==0;);for(v=1<<E-1;$&v;)v>>=1;if(v!==0?($&=v-1,$+=v):$=0,L++,--fe[E]==0){if(E===O)break;E=d[f+g[L]]}if(F<E&&($&x)!==w){for(j===0&&(j=F),S+=R,M=1<<(B=E-j);B+j<O&&!((M-=fe[B+j])<=0);)B++,M<<=1;if(z+=1<<B,u===1&&852<z||u===2&&592<z)return 1;p[w=$&x]=F<<24|B<<16|S-m|0}}return $!==0&&(p[S+$]=E-j<<24|4194304),y.bits=F,0}},{"../utils/common":41}],51:[function(n,r,i){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){"use strict";var o=n("../utils/common"),s=0,a=1;function l(ie){for(var q=ie.length;0<=--q;)ie[q]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,v=7,b=256,w=16,x=17,S=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],P=new Array(2*(f+2));l(P);var E=new Array(2*h);l(E);var L=new Array(512);l(L);var R=new Array(256);l(R);var O=new Array(u);l(O);var F,B,j,M=new Array(h);function z(ie,q,Q,le,se){this.static_tree=ie,this.extra_bits=q,this.extra_base=Q,this.elems=le,this.max_length=se,this.has_stree=ie&&ie.length}function $(ie,q){this.dyn_tree=ie,this.max_code=0,this.stat_desc=q}function K(ie){return ie<256?L[ie]:L[256+(ie>>>7)]}function U(ie,q){ie.pending_buf[ie.pending++]=255&q,ie.pending_buf[ie.pending++]=q>>>8&255}function fe(ie,q,Q){ie.bi_valid>y-Q?(ie.bi_buf|=q<<ie.bi_valid&65535,U(ie,ie.bi_buf),ie.bi_buf=q>>y-ie.bi_valid,ie.bi_valid+=Q-y):(ie.bi_buf|=q<<ie.bi_valid&65535,ie.bi_valid+=Q)}function ee(ie,q,Q){fe(ie,Q[2*q],Q[2*q+1])}function Z(ie,q){for(var Q=0;Q|=1&ie,ie>>>=1,Q<<=1,0<--q;);return Q>>>1}function re(ie,q,Q){var le,se,me=new Array(g+1),Se=0;for(le=1;le<=g;le++)me[le]=Se=Se+Q[le-1]<<1;for(se=0;se<=q;se++){var Ee=ie[2*se+1];Ee!==0&&(ie[2*se]=Z(me[Ee]++,Ee))}}function ve(ie){var q;for(q=0;q<f;q++)ie.dyn_ltree[2*q]=0;for(q=0;q<h;q++)ie.dyn_dtree[2*q]=0;for(q=0;q<p;q++)ie.bl_tree[2*q]=0;ie.dyn_ltree[2*b]=1,ie.opt_len=ie.static_len=0,ie.last_lit=ie.matches=0}function J(ie){8<ie.bi_valid?U(ie,ie.bi_buf):0<ie.bi_valid&&(ie.pending_buf[ie.pending++]=ie.bi_buf),ie.bi_buf=0,ie.bi_valid=0}function ke(ie,q,Q,le){var se=2*q,me=2*Q;return ie[se]<ie[me]||ie[se]===ie[me]&&le[q]<=le[Q]}function Ae(ie,q,Q){for(var le=ie.heap[Q],se=Q<<1;se<=ie.heap_len&&(se<ie.heap_len&&ke(q,ie.heap[se+1],ie.heap[se],ie.depth)&&se++,!ke(q,le,ie.heap[se],ie.depth));)ie.heap[Q]=ie.heap[se],Q=se,se<<=1;ie.heap[Q]=le}function G(ie,q,Q){var le,se,me,Se,Ee=0;if(ie.last_lit!==0)for(;le=ie.pending_buf[ie.d_buf+2*Ee]<<8|ie.pending_buf[ie.d_buf+2*Ee+1],se=ie.pending_buf[ie.l_buf+Ee],Ee++,le===0?ee(ie,se,q):(ee(ie,(me=R[se])+d+1,q),(Se=T[me])!==0&&fe(ie,se-=O[me],Se),ee(ie,me=K(--le),Q),(Se=k[me])!==0&&fe(ie,le-=M[me],Se)),Ee<ie.last_lit;);ee(ie,b,q)}function D(ie,q){var Q,le,se,me=q.dyn_tree,Se=q.stat_desc.static_tree,Ee=q.stat_desc.has_stree,be=q.stat_desc.elems,ue=-1;for(ie.heap_len=0,ie.heap_max=m,Q=0;Q<be;Q++)me[2*Q]!==0?(ie.heap[++ie.heap_len]=ue=Q,ie.depth[Q]=0):me[2*Q+1]=0;for(;ie.heap_len<2;)me[2*(se=ie.heap[++ie.heap_len]=ue<2?++ue:0)]=1,ie.depth[se]=0,ie.opt_len--,Ee&&(ie.static_len-=Se[2*se+1]);for(q.max_code=ue,Q=ie.heap_len>>1;1<=Q;Q--)Ae(ie,me,Q);for(se=be;Q=ie.heap[1],ie.heap[1]=ie.heap[ie.heap_len--],Ae(ie,me,1),le=ie.heap[1],ie.heap[--ie.heap_max]=Q,ie.heap[--ie.heap_max]=le,me[2*se]=me[2*Q]+me[2*le],ie.depth[se]=(ie.depth[Q]>=ie.depth[le]?ie.depth[Q]:ie.depth[le])+1,me[2*Q+1]=me[2*le+1]=se,ie.heap[1]=se++,Ae(ie,me,1),2<=ie.heap_len;);ie.heap[--ie.heap_max]=ie.heap[1],(function(Ie,Le){var Xe,nt,he,xe,ge,pe,we=Le.dyn_tree,oe=Le.max_code,je=Le.stat_desc.static_tree,Y=Le.stat_desc.has_stree,Te=Le.stat_desc.extra_bits,Ke=Le.stat_desc.extra_base,de=Le.stat_desc.max_length,st=0;for(xe=0;xe<=g;xe++)Ie.bl_count[xe]=0;for(we[2*Ie.heap[Ie.heap_max]+1]=0,Xe=Ie.heap_max+1;Xe<m;Xe++)de<(xe=we[2*we[2*(nt=Ie.heap[Xe])+1]+1]+1)&&(xe=de,st++),we[2*nt+1]=xe,oe<nt||(Ie.bl_count[xe]++,ge=0,Ke<=nt&&(ge=Te[nt-Ke]),pe=we[2*nt],Ie.opt_len+=pe*(xe+ge),Y&&(Ie.static_len+=pe*(je[2*nt+1]+ge)));if(st!==0){do{for(xe=de-1;Ie.bl_count[xe]===0;)xe--;Ie.bl_count[xe]--,Ie.bl_count[xe+1]+=2,Ie.bl_count[de]--,st-=2}while(0<st);for(xe=de;xe!==0;xe--)for(nt=Ie.bl_count[xe];nt!==0;)oe<(he=Ie.heap[--Xe])||(we[2*he+1]!==xe&&(Ie.opt_len+=(xe-we[2*he+1])*we[2*he],we[2*he+1]=xe),nt--)}})(ie,q),re(me,ue,ie.bl_count)}function N(ie,q,Q){var le,se,me=-1,Se=q[1],Ee=0,be=7,ue=4;for(Se===0&&(be=138,ue=3),q[2*(Q+1)+1]=65535,le=0;le<=Q;le++)se=Se,Se=q[2*(le+1)+1],++Ee<be&&se===Se||(Ee<ue?ie.bl_tree[2*se]+=Ee:se!==0?(se!==me&&ie.bl_tree[2*se]++,ie.bl_tree[2*w]++):Ee<=10?ie.bl_tree[2*x]++:ie.bl_tree[2*S]++,me=se,ue=(Ee=0)===Se?(be=138,3):se===Se?(be=6,3):(be=7,4))}function X(ie,q,Q){var le,se,me=-1,Se=q[1],Ee=0,be=7,ue=4;for(Se===0&&(be=138,ue=3),le=0;le<=Q;le++)if(se=Se,Se=q[2*(le+1)+1],!(++Ee<be&&se===Se)){if(Ee<ue)for(;ee(ie,se,ie.bl_tree),--Ee!=0;);else se!==0?(se!==me&&(ee(ie,se,ie.bl_tree),Ee--),ee(ie,w,ie.bl_tree),fe(ie,Ee-3,2)):Ee<=10?(ee(ie,x,ie.bl_tree),fe(ie,Ee-3,3)):(ee(ie,S,ie.bl_tree),fe(ie,Ee-11,7));me=se,ue=(Ee=0)===Se?(be=138,3):se===Se?(be=6,3):(be=7,4)}}l(M);var ce=!1;function te(ie,q,Q,le){fe(ie,(c<<1)+(le?1:0),3),(function(se,me,Se,Ee){J(se),Ee&&(U(se,Se),U(se,~Se)),o.arraySet(se.pending_buf,se.window,me,Se,se.pending),se.pending+=Se})(ie,q,Q,!0)}i._tr_init=function(ie){ce||((function(){var q,Q,le,se,me,Se=new Array(g+1);for(se=le=0;se<u-1;se++)for(O[se]=le,q=0;q<1<<T[se];q++)R[le++]=se;for(R[le-1]=se,se=me=0;se<16;se++)for(M[se]=me,q=0;q<1<<k[se];q++)L[me++]=se;for(me>>=7;se<h;se++)for(M[se]=me<<7,q=0;q<1<<k[se]-7;q++)L[256+me++]=se;for(Q=0;Q<=g;Q++)Se[Q]=0;for(q=0;q<=143;)P[2*q+1]=8,q++,Se[8]++;for(;q<=255;)P[2*q+1]=9,q++,Se[9]++;for(;q<=279;)P[2*q+1]=7,q++,Se[7]++;for(;q<=287;)P[2*q+1]=8,q++,Se[8]++;for(re(P,f+1,Se),q=0;q<h;q++)E[2*q+1]=5,E[2*q]=Z(q,5);F=new z(P,T,d+1,f,g),B=new z(E,k,0,h,g),j=new z(new Array(0),C,0,p,v)})(),ce=!0),ie.l_desc=new $(ie.dyn_ltree,F),ie.d_desc=new $(ie.dyn_dtree,B),ie.bl_desc=new $(ie.bl_tree,j),ie.bi_buf=0,ie.bi_valid=0,ve(ie)},i._tr_stored_block=te,i._tr_flush_block=function(ie,q,Q,le){var se,me,Se=0;0<ie.level?(ie.strm.data_type===2&&(ie.strm.data_type=(function(Ee){var be,ue=4093624447;for(be=0;be<=31;be++,ue>>>=1)if(1&ue&&Ee.dyn_ltree[2*be]!==0)return s;if(Ee.dyn_ltree[18]!==0||Ee.dyn_ltree[20]!==0||Ee.dyn_ltree[26]!==0)return a;for(be=32;be<d;be++)if(Ee.dyn_ltree[2*be]!==0)return a;return s})(ie)),D(ie,ie.l_desc),D(ie,ie.d_desc),Se=(function(Ee){var be;for(N(Ee,Ee.dyn_ltree,Ee.l_desc.max_code),N(Ee,Ee.dyn_dtree,Ee.d_desc.max_code),D(Ee,Ee.bl_desc),be=p-1;3<=be&&Ee.bl_tree[2*_[be]+1]===0;be--);return Ee.opt_len+=3*(be+1)+5+5+4,be})(ie),se=ie.opt_len+3+7>>>3,(me=ie.static_len+3+7>>>3)<=se&&(se=me)):se=me=Q+5,Q+4<=se&&q!==-1?te(ie,q,Q,le):ie.strategy===4||me===se?(fe(ie,2+(le?1:0),3),G(ie,P,E)):(fe(ie,4+(le?1:0),3),(function(Ee,be,ue,Ie){var Le;for(fe(Ee,be-257,5),fe(Ee,ue-1,5),fe(Ee,Ie-4,4),Le=0;Le<Ie;Le++)fe(Ee,Ee.bl_tree[2*_[Le]+1],3);X(Ee,Ee.dyn_ltree,be-1),X(Ee,Ee.dyn_dtree,ue-1)})(ie,ie.l_desc.max_code+1,ie.d_desc.max_code+1,Se+1),G(ie,ie.dyn_ltree,ie.dyn_dtree)),ve(ie),le&&J(ie)},i._tr_tally=function(ie,q,Q){return ie.pending_buf[ie.d_buf+2*ie.last_lit]=q>>>8&255,ie.pending_buf[ie.d_buf+2*ie.last_lit+1]=255&q,ie.pending_buf[ie.l_buf+ie.last_lit]=255&Q,ie.last_lit++,q===0?ie.dyn_ltree[2*Q]++:(ie.matches++,q--,ie.dyn_ltree[2*(R[Q]+d+1)]++,ie.dyn_dtree[2*K(q)]++),ie.last_lit===ie.lit_bufsize-1},i._tr_align=function(ie){fe(ie,2,3),ee(ie,b,P),(function(q){q.bi_valid===16?(U(q,q.bi_buf),q.bi_buf=0,q.bi_valid=0):8<=q.bi_valid&&(q.pending_buf[q.pending++]=255&q.bi_buf,q.bi_buf>>=8,q.bi_valid-=8)})(ie)}},{"../utils/common":41}],53:[function(n,r,i){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(o){(function(s,a){"use strict";if(!s.setImmediate){var l,c,u,d,f=1,h={},p=!1,m=s.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(s);g=g&&g.setTimeout?g:s,l={}.toString.call(s.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:(function(){if(s.postMessage&&!s.importScripts){var w=!0,x=s.onmessage;return s.onmessage=function(){w=!1},s.postMessage("","*"),s.onmessage=x,w}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(w){s.postMessage(d+w,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){u.port2.postMessage(w)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(w){var x=m.createElement("script");x.onreadystatechange=function(){v(w),x.onreadystatechange=null,c.removeChild(x),x=null},c.appendChild(x)}):function(w){setTimeout(v,0,w)},g.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var x=new Array(arguments.length-1),S=0;S<x.length;S++)x[S]=arguments[S+1];return h[f]={callback:w,args:x},l(f),f++},g.clearImmediate=y}function y(w){delete h[w]}function v(w){if(p)setTimeout(v,0,w);else{var x=h[w];if(x){p=!0;try{(function(S){var T=S.callback,k=S.args;switch(k.length){case 0:T();break;case 1:T(k[0]);break;case 2:T(k[0],k[1]);break;case 3:T(k[0],k[1],k[2]);break;default:T.apply(a,k)}})(x)}finally{y(w),p=!1}}}}function b(w){w.source===s&&typeof w.data=="string"&&w.data.indexOf(d)===0&&v(+w.data.slice(d.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),BEe=md(FEe(),1);const HEe=e=>/\.xml$|\.rels$/i.test(e);function lYt(e){if(e.length>=2){const n=e[0],r=e[1];if(n===255&&r===254)return"utf-16le";if(n===254&&r===255)return"utf-16be"}let t=0;for(let n=0;n<Math.min(64,e.length);n++)e[n]===0&&t++;return t>16?"utf-16le":"utf-8"}function zEe(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function UEe(e){if(typeof e=="string")return zEe(e);let t=null;if(e&&typeof e=="object"&&(e instanceof Uint8Array?t=e:typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):ArrayBuffer.isView&&ArrayBuffer.isView(e)?t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.constructor&&(e instanceof ArrayBuffer||e.constructor.name==="ArrayBuffer")&&(t=new Uint8Array(e))),!t)throw new Error("Unsupported content type for XML");const n=lYt(t);let r=new TextDecoder(n).decode(t);return r=zEe(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const uG=[{zipPath:"word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},{zipPath:"docProps/core.xml",contentType:"application/vnd.openxmlformats-package.core-properties+xml",relationshipType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},{zipPath:"docProps/app.xml",contentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},{zipPath:"docProps/custom.xml",contentType:"application/vnd.openxmlformats-officedocument.custom-properties+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"}];var VEe=md(Pv(),1),cYt="http://schemas.openxmlformats.org/package/2006/relationships";function dG(e,t,n){if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];if(t)return Array.isArray(t)?t.find(r=>r.name===e)?.content:t[e]}function uYt(e,t,n){return dG(e,t,n)!=null}function WEe(e){try{return VEe.xml2js(e,{compact:!1})}catch{return null}}function GEe(e){return VEe.js2xml(e,{spaces:0})}function jEe(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function qEe(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:cYt},elements:[]}]}}function dYt(e){let t=0;for(const n of e.elements||[]){const r=n.attributes?.Id;if(!r)continue;const i=r.match(/^rId(\d+)$/);i&&(t=Math.max(t,parseInt(i[1],10)))}return t}function fYt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const o of uG)n.set(`/${o.zipPath}`,o);const r=new Map;for(let o=0;o<e.elements.length;o++){const s=e.elements[o];if(s.name!=="Override")continue;const a=s.attributes?.PartName;!a||!n.has(a)||(r.has(a)||r.set(a,[]),r.get(a).push(o))}const i=new Set;for(const[o,s]of n){const a=t.has(s.zipPath),l=r.get(o)||[];if(!a){for(const c of l)i.add(c);continue}if(l.length===0)e.elements.push({type:"element",name:"Override",attributes:{PartName:o,ContentType:s.contentType}});else{e.elements[l[0]].attributes.ContentType=s.contentType;for(let c=1;c<l.length;c++)i.add(l[c])}}if(i.size>0){const o=[...i].sort((s,a)=>a-s);for(const s of o)e.elements.splice(s,1)}}function hYt(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of uG)n.set(s.relationshipType,s);const r=new Map;for(let s=0;s<e.elements.length;s++){const a=e.elements[s];if(a.name!=="Relationship")continue;const l=a.attributes?.Type;!l||!n.has(l)||(r.has(l)||r.set(l,[]),r.get(l).push({index:s,element:a}))}const i=new Set;let o=dYt(e);for(const[s,a]of n){const l=t.has(a.zipPath),c=r.get(s)||[];if(!l){for(const{index:u}of c)i.add(u);continue}if(c.length===0)o++,e.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s,Target:a.zipPath}});else{c[0].element.attributes.Target=a.zipPath;for(let u=1;u<c.length;u++)i.add(c[u].index)}}if(i.size>0){const s=[...i].sort((a,l)=>l-a);for(const a of s)e.elements.splice(a,1)}}function YEe({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of uG)uYt(c.zipPath,e,t)&&n.add(c.zipPath);const r=dG("[Content_Types].xml",e,t);if(r==null)throw new Error("syncPackageMetadata: [Content_Types].xml is missing from the package. Cannot safely reconcile package metadata without an existing content types file.");const i=WEe(r);if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml could not be parsed as valid XML. Cannot safely reconcile package metadata from a malformed content types file.");const o=jEe(i,"Types");if(!o)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");fYt(o,n);const s=dG("_rels/.rels",e,t);let a;if(s==null)a=qEe();else if(a=WEe(s),!a)throw new Error("syncPackageMetadata: _rels/.rels could not be parsed as valid XML. Cannot safely reconcile root relationships from a malformed rels file.");let l=jEe(a,"Relationships");return l||(a=qEe(),l=a.elements[0]),hYt(l,n),{contentTypesXml:GEe(i),relsXml:GEe(a)}}var KEe=md(Pv(),1);const XEe=[{zipPath:"word/numbering.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",relationshipType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",relTarget:"numbering.xml"}];function pYt(e){let t=0;for(const n of e){const r=n.attributes?.Id?.match(/^rId(\d+)$/);r&&(t=Math.max(t,Number(r[1])))}return t}function mYt(e,t){if(!e)return e;let n;try{n=KEe.xml2js(e,{compact:!1})}catch{return e}const r=n?.elements?.find(s=>s.name==="Relationships");if(!r)return e;r.elements||(r.elements=[]);let i=!1,o=pYt(r.elements);for(const s of XEe)t(s.zipPath)&&(r.elements.some(a=>a.attributes?.Type===s.relationshipType)||(o++,r.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${o}`,Type:s.relationshipType,Target:s.relTarget}}),i=!0));return i?KEe.js2xml(n,{spaces:0}):e}var gYt=ls({detectContainerType:()=>fG},1);function JEe(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function fG(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return JEe(t,ZEe)?"zip":JEe(t,QEe)?"cfb":"unknown"}var ZEe,QEe,$Ee=Pe((()=>{ZEe=[80,75,3,4],QEe=[208,207,17,224,161,177,26,225]}));function eCe(e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function yYt(e,t){return(e+1)*t}function Jk(e,t){return e.getUint16(t,!0)}function wl(e,t){return e.getUint32(t,!0)}function bYt(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function vYt(e){return tCe.decode(e).replace(/\u0000+$/g,"")}var hG,wYt,AYt,SYt,xYt,TYt,IYt,pG,kYt,EYt,Zk,CYt,_Yt,RYt,tCe,PYt=Pe((()=>{hG=new Uint8Array([208,207,17,224,161,177,26,225]),wYt=512,AYt=128,SYt=109,xYt=512,TYt=4096,IYt=4294967295,pG=4294967294,kYt=4294967292,EYt=4294967295,Zk={STORAGE:1,STREAM:2,ROOT:5},CYt=65534,_Yt=3,RYt=4,tCe=new TextDecoder("utf-16le")}));function Qk(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function nCe(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function LYt(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<hG.length;c++)if(e[c]!==hG[c])throw new Error("Invalid CFB signature");const t=Qk(e),n=Jk(t,26),r=Jk(t,28),i=Jk(t,30),o=Jk(t,32),s=1<<i,a=1<<o;if(r!==65534)throw new Error(`Unsupported CFB byte order: 0x${r.toString(16)}`);if(!(n===3&&s===512||n===4&&s===4096))throw new Error(`Unsupported CFB major version ${n} with sector size ${s}`);const l=[];for(let c=0;c<109;c++){const u=wl(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:wl(t,44),firstDirectorySector:wl(t,48),miniStreamCutoffSize:wl(t,56),firstMiniFatSector:wl(t,60),numberOfMiniFatSectors:wl(t,64),firstDifatSector:wl(t,68),numberOfDifatSectors:wl(t,72),difatEntries:l}}function mG(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=yYt(n,t.sectorSize);return nCe(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function NYt(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let i=0;i<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);i++){const o=Qk(mG(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=wl(o,a*4);l!==4294967295&&n.push(l)}r=wl(o,t.sectorSize-4)}if(n.length<t.numberOfFatSectors)throw new Error(`CFB DIFAT only exposed ${n.length} FAT sectors, expected ${t.numberOfFatSectors}`);return n.slice(0,t.numberOfFatSectors)}function MYt(e,t){const n=NYt(e,t),r=[];for(const i of n){const o=Qk(mG(e,t,i)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(wl(o,a*4))}return r}function kM(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==pG;){if(o.has(s))throw new Error(`CFB sector chain loop detected at sector ${s}`);if(s>=n.length)throw new Error(`CFB sector ${s} is out of FAT bounds`);o.add(s),i.push(mG(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return eCe(i)}function DYt(e,t){const n=bYt(e,t);if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`CFB stream is too large to fit in a JavaScript number: ${n.toString()}`);return Number(n)}function OYt(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),i=Qk(r),o=Jk(i,64),s=r.subarray(0,Math.max(0,Math.min(o,64)-2));t.push({name:vYt(s),objectType:r[66],leftSiblingId:wl(i,68),rightSiblingId:wl(i,72),childId:wl(i,76),startSector:wl(i,116),streamSize:DYt(i,120)})}return t}function gG(e,t,n,r=new Set){if(t===4294967295)return!1;if(t>=e.length)throw new Error(`CFB directory entry id ${t} is out of bounds`);if(r.has(t))throw new Error(`CFB directory tree loop detected at entry id ${t}`);r.add(t);const i=e[t];return!!(gG(e,i.leftSiblingId,n,r)||n(i)===!0||gG(e,i.rightSiblingId,n,r))}function FYt(e,t){const n=t.split("/").map(i=>i.trim()).filter(Boolean);let r=e[0];for(const i of n){if(r.objectType!==Zk.ROOT&&r.objectType!==Zk.STORAGE)return null;let o=null;if(gG(e,r.childId,s=>s.name.toLowerCase()===i.toLowerCase()?(o=s,!0):!1),!o)return null;r=o}return r}function BYt(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):kM(t,n,r,e.startSector).subarray(0,e.streamSize)}function HYt(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=kM(e,t,n,t.firstMiniFatSector),i=Qk(r),o=Math.floor(r.length/4),s=[];for(let a=0;a<o;a++)s.push(wl(i,a*4));return s}function zYt(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const i=[],o=new Set;let s=r;for(;s!==pG;){if(o.has(s))throw new Error(`CFB mini sector chain loop detected at mini sector ${s}`);if(s>=t.length)throw new Error(`CFB mini sector ${s} is out of MiniFAT bounds`);o.add(s);const a=s*n;nCe(e,a,n,`mini sector ${s}`),i.push(e.subarray(a,a+n));const l=t[s];if(l==null)throw new Error(`CFB MiniFAT missing next sector for mini sector ${s}`);s=l}return eCe(i)}function UYt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=LYt(t),r=MYt(t,n),i=OYt(kM(t,n,r,n.firstDirectorySector));if(i.length===0||i[0].objectType!==Zk.ROOT)throw new Error("CFB root directory entry is missing");const o=i[0],s=HYt(t,n,r),a=BYt(o,t,n,r);return{getStream(l){const c=FYt(i,l);return!c||c.objectType!==Zk.STREAM?null:c.streamSize<n.miniStreamCutoffSize?zYt(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):kM(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var VYt=Pe((()=>{PYt()}));function WYt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=UYt(t)}catch(o){throw new Go(ia.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",o instanceof Error?o:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new Go(ia.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const i=n.getStream("/EncryptedPackage");if(!i)throw new Go(ia.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:i}}var GYt=Pe((()=>{VYt(),Yk()}));function rCe(e,t){return e[t]|e[t+1]<<8}function yG(e,t){const n=new RegExp(`<(?:\\w+:)?${t}\\b([^>]*)/?>`),r=e.match(n);if(!r)return null;const i={},o=/(\w+)="([^"]*)"/g;let s;for(;(s=o.exec(r[1]))!==null;)i[s[1]]=s[2];return i}function jYt(e){if(typeof atob=="function"){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}return new Uint8Array(Buffer.from(e,"base64"))}function AA(e,t,n){const r=e?.[t];if(r==null)throw new Go(ia.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function eb(e,t,n){return jYt(AA(e,t,n))}function SA(e,t,n){const r=parseInt(AA(e,t,n),10);if(Number.isNaN(r))throw new Go(ia.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function qYt(e){const t=new TextDecoder("utf-8").decode(e),n=yG(t,"keyData"),r=yG(t,"dataIntegrity"),i=yG(t,"encryptedKey");return{keySalt:eb(n,"saltValue","keyData"),keyBits:SA(n,"keyBits","keyData"),hashAlgorithm:AA(n,"hashAlgorithm","keyData"),hashSize:SA(n,"hashSize","keyData"),blockSize:SA(n,"blockSize","keyData"),cipherAlgorithm:AA(n,"cipherAlgorithm","keyData"),cipherChaining:AA(n,"cipherChaining","keyData"),spinCount:SA(i,"spinCount","encryptedKey"),passwordSalt:eb(i,"saltValue","encryptedKey"),passwordHashAlgorithm:AA(i,"hashAlgorithm","encryptedKey"),passwordKeyBits:SA(i,"keyBits","encryptedKey"),passwordBlockSize:SA(i,"blockSize","encryptedKey"),encryptedVerifierHashInput:eb(i,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:eb(i,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:eb(i,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:eb(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:eb(r,"encryptedHmacValue","dataIntegrity")}}function YYt(e){if(e.length<EM)throw new Go(ia.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${EM})`);const t=rCe(e,0),n=rCe(e,2);if(t===iCe&&n===oCe)return{type:"agile",params:qYt(e.subarray(EM))};throw(t===sCe||t===aCe)&&n===lCe?new Go(ia.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new Go(ia.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new Go(ia.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var iCe,oCe,sCe,aCe,lCe,EM,KYt=Pe((()=>{Yk(),iCe=4,oCe=4,sCe=3,aCe=4,lCe=3,EM=8}));function bG(){const e=globalThis.crypto?.subtle;if(!e)throw new Go(ia.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function $k(e){const t={SHA1:"SHA-1","SHA-1":"SHA-1",SHA256:"SHA-256","SHA-256":"SHA-256",SHA384:"SHA-384","SHA-384":"SHA-384",SHA512:"SHA-512","SHA-512":"SHA-512"}[e];if(!t)throw new Go(ia.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function XYt(e){const t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}function xA(...e){const t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n}function cCe(e){const t=new Uint8Array(4);return t[0]=e&255,t[1]=e>>>8&255,t[2]=e>>>16&255,t[3]=e>>>24&255,t}function TA(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function IA(e,t){const n=await bG().digest(e,TA(t));return new Uint8Array(n)}async function kA(e,t,n){const r=bG(),i=16,o=await r.importKey("raw",TA(e),{name:"AES-CBC"},!1,["encrypt","decrypt"]),s=n.subarray(n.length-i),a=new Uint8Array(i);a.fill(i);const l=new Uint8Array(await r.encrypt({name:"AES-CBC",iv:TA(s)},o,a)).subarray(0,i),c=new Uint8Array(n.length+i);c.set(n),c.set(l,n.length);const u=await r.decrypt({name:"AES-CBC",iv:TA(t)},o,c);return new Uint8Array(u).subarray(0,n.length)}async function vG(e,t,n,r,i,o){const s=$k(i);let a=await IA(s,xA(t,XYt(e)));for(let d=0;d<n;d++)a=await IA(s,xA(cCe(d),a));const l=await IA(s,xA(a,o)),c=r/8;if(l.length>=c)return l.subarray(0,c);const u=new Uint8Array(c);return u.set(l),u.fill(54,l.length),u}async function wG(e,t,n,r){let i;if(n?i=await IA($k(e),xA(t,n)):i=t,i.length>=r)return i.subarray(0,r);const o=new Uint8Array(r);return o.set(i),o.fill(54,i.length),o}async function JYt(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:i,passwordKeyBits:o,passwordBlockSize:s}=t,a=await vG(e,n,r,o,i,dCe),l=await vG(e,n,r,o,i,fCe),c=await vG(e,n,r,o,i,hCe),u=await wG(i,n,void 0,s),d=await kA(a,u,t.encryptedVerifierHashInput),f=await kA(l,u,t.encryptedVerifierHashValue),h=await IA($k(i),d);if(!uCe(h,f.subarray(0,h.length)))throw new Go(ia.PASSWORD_INVALID,"The password is incorrect");return kA(c,u,t.encryptedKeyValue)}function uCe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function ZYt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o}=t,s=$k(i);if(n.length<AG)throw new Go(ia.DECRYPTION_FAILED,"EncryptedPackage too short to contain size header");const a=n[0]|n[1]<<8|n[2]<<16|n[3]<<24>>>0,l=n.subarray(AG),c=Math.ceil(l.length/CM),u=[];for(let d=0;d<c;d++){const f=d*CM,h=Math.min(f+CM,l.length),p=l.subarray(f,h),m=await IA(s,xA(r,cCe(d))),g=await kA(e,m.length>=o?m.subarray(0,o):m,p);u.push(g)}return xA(...u).subarray(0,a)}async function QYt(e,t,n){const{keySalt:r,hashAlgorithm:i,blockSize:o,hashSize:s}=t,a=$k(i),l=bG(),c=(await kA(e,await wG(i,r,pCe,o),t.encryptedHmacKey)).subarray(0,s),u=await kA(e,await wG(i,r,mCe,o),t.encryptedHmacValue),d=await l.importKey("raw",TA(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,TA(n)));if(!uCe(f,u.subarray(0,f.length)))throw new Go(ia.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function $Yt(e,t,n){try{const r=await JYt(e,t);return await QYt(r,t,n),await ZYt(r,t,n)}catch(r){throw r instanceof Go?r:new Go(ia.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var dCe,fCe,hCe,pCe,mCe,CM,AG,eKt=Pe((()=>{Yk(),dCe=new Uint8Array([254,167,210,118,59,75,158,121]),fCe=new Uint8Array([215,170,15,109,48,97,52,78]),hCe=new Uint8Array([20,110,11,231,171,172,208,214]),pCe=new Uint8Array([95,178,173,1,12,185,225,246]),mCe=new Uint8Array([160,103,127,2,178,44,132,51]),CM=4096,AG=8})),tKt=ls({decryptDocxIfNeeded:()=>rKt},1);function nKt(e){if(fG(e)!=="zip")throw new Go(ia.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function rKt(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=fG(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new Go(ia.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new Go(ia.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const i=WYt(n),{params:o}=YYt(i.encryptionInfo),s=await $Yt(t.password,o,i.encryptedPackage);return nKt(s),{data:s,wasEncrypted:!0}}var iKt=Pe((()=>{$Ee(),GYt(),KYt(),eKt(),Yk()})),gCe=md(Pv(),1),SG=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),xG={tif:"tiff",jpg:"jpeg"},oKt="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",yCe={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},sKt=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new BEe.default,this.files=[],this.media={},this.mediaFiles={},this.fonts={},this.decryptedFileData=null}async#e(e,t){if(e instanceof Uint8Array||typeof Buffer<"u"&&Buffer.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,Math.min(t,e.byteLength));if(e instanceof ArrayBuffer)return new Uint8Array(e,0,Math.min(t,e.byteLength));if(typeof Blob<"u"&&e instanceof Blob)try{if(typeof e.arrayBuffer=="function"){const n=await e.arrayBuffer();return new Uint8Array(n,0,Math.min(t,n.byteLength))}}catch{}return new Uint8Array(0)}async getDocxData(e,t=!1,n={}){const{detectContainerType:r}=await Promise.resolve().then(()=>($Ee(),gYt)),i=r(await this.#e(e,8));let o=e;if(i==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(iKt(),tKt)),c=await l(e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer()),{password:n.password});o=c.data,this.decryptedFileData=c.data}const s=await this.unzip(o),a=Object.entries(s.files);for(const[,l]of a){const c=l.name;if(HEe(c)){const u=UEe(await l.async("uint8array"));this.files.push({name:c,content:u})}else if(c.startsWith("word/media")&&c!=="word/media/"||l.name.startsWith("media")&&l.name!=="media/"||c.startsWith("media")&&c!=="media/"||c.startsWith("word/embeddings")&&c!=="word/embeddings/")if(t){const u=(await l.async("nodebuffer")).toString("base64");this.mediaFiles[c]=u}else{const u=await l.async("base64");let d=this.getFileExtension(c)?.toLowerCase(),f=null;if((!SG.has(d)||d==="tmp")&&(f=g1(u),f&&(d=f)),SG.has(d)){const h=xG[d]||d;this.mediaFiles[c]=`data:image/${h};base64,${u}`;const p=await l.async("blob"),m=new File([p],c,{type:p.type}),g=URL.createObjectURL(m);this.media[c]=g}else this.mediaFiles[c]=u}else if(c.startsWith("word/fonts")&&c!=="word/fonts/"){const u=await l.async("uint8array");this.fonts[c]=u}}return this.files}getFileExtension(e){const t=e.split(".");return t.length<2?null:t[t.length-1]}async updateContentTypes(e,t,n,r={},i={}){const o=Object.keys(r||{}),s=Object.keys(t).map(P=>this.getFileExtension(P)).filter(P=>P&&SG.has(P)),a=Object.entries(t).filter(([P])=>!this.getFileExtension(P)).map(([P,E])=>({name:P,contentType:this.#i(E)})).filter(P=>P.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(P=>P.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=oKe(c),f=new Set;for(let P of s){if(d.includes(P)||f.has(P))continue;const E=`<Default Extension="${P}" ContentType="image/${xG[P]||P}"/>`;u+=E,f.add(P)}if(i){const P=new Set(Object.keys(i).map(E=>this.getFileExtension(E)).filter(E=>E&&yCe[E]));for(const E of P)d.includes(E)||f.has(E)||(u+=`<Default Extension="${E}" ContentType="${yCe[E]}"/>`,f.add(E))}const h=JSON.parse(gCe.xml2json(c,null,2)).elements?.find(P=>P.name==="Types")||{},p=P=>h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName===P);for(const{name:P,contentType:E}of a){const L=`/${P}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${E}" />`)}const m=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsIds.xml"),v=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/commentsExtensible.xml"),b=P=>r&&Object.prototype.hasOwnProperty.call(r,P)?r[P]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(E=>E.name===P):!!e.files[P]:!1;b("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),b("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),b("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),b("word/commentsExtensible.xml")&&(v||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const w=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/footnotes.xml"),x=h.elements?.some(P=>P.name==="Override"&&P.attributes.PartName==="/word/endnotes.xml");b("word/footnotes.xml")&&(w||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),b("word/endnotes.xml")&&(x||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const P of XEe)b(P.zipPath)&&!p(`/${P.zipPath}`)&&(u+=`<Override PartName="/${P.zipPath}" ContentType="${P.contentType}" />`);const S=new Set(o);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(P=>S.add(P.name)):Object.keys(e.files).forEach(P=>S.add(P))),S.forEach(P=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(P)||!b(P))return;const E=`/${P}`;p(E)||(u+=`<Override PartName="${E}" ContentType="${oKt}" />`)}),S.forEach(P=>{if(P.includes(".rels")||!P.includes("header")&&!P.includes("footer"))return;const E=h.elements?.some(R=>R.name==="Override"&&R.attributes.PartName===`/${P}`),L=`<Override PartName="/${P}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${P.includes("header")?"header":"footer"}+xml"/>`;E||(u+=L)});const T=tU.map(P=>`/word/${P}`).filter(P=>!b(P.slice(1))),k='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let C=c.replace(k,`${k}${u}`);for(const P of T){const E=P.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`\\s*<Override[^>]*PartName="${E}"[^>]*/>`,"g");C=C.replace(L,"")}let _=r["word/_rels/document.xml.rels"];if(_||(n?Array.isArray(e.files)?_=e.files.find(P=>P.name==="word/_rels/document.xml.rels")?.content:_=e.files?.["word/_rels/document.xml.rels"]:_=await e.file("word/_rels/document.xml.rels")?.async("string")),_)try{gCe.xml2js(_,{compact:!1}).elements?.find(P=>P.name==="Relationships")?.elements?.forEach(P=>{const E=P.attributes?.Type,L=P.attributes?.Target;if(!E||!L)return;const R=E.includes("/header"),O=E.includes("/footer");if(!R&&!O)return;let F=L.replace(/^\.\//,"");F.startsWith("../")&&(F=F.slice(3)),F.startsWith("/")&&(F=F.slice(1));const B=F.startsWith("word/")?F:`word/${F}`;S.add(B)})}catch(P){console.warn("Failed to parse document relationships while updating content types",P)}if(S.forEach(P=>{if(P.includes(".rels")||!P.includes("header")&&!P.includes("footer")||C.includes(`PartName="/${P}"`))return;const E=`<Override PartName="/${P}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${P.includes("header")?"header":"footer"}+xml"/>`;C=C.replace("</Types>",`${E}</Types>`)}),_){const P=mYt(_,b);P!==_&&(n?r["word/_rels/document.xml.rels"]=P:e.file("word/_rels/document.xml.rels",P))}if(n)return C;e.file(l,C)}async#t(e){const t={};e.forEach(s=>{t[s]=""});const n=e.file("[Content_Types].xml");n&&(t["[Content_Types].xml"]=await n.async("string"));const r=e.file("_rels/.rels");r&&(t["_rels/.rels"]=await r.async("string"));const{contentTypesXml:i,relsXml:o}=YEe({baseFiles:t,updatedDocs:{}});e.file("[Content_Types].xml",i),e.file("_rels/.rels",o)}async unzip(e){return await this.zip.loadAsync(e)}async updateZip({docx:e,updatedDocs:t,originalDocxFile:n,media:r,fonts:i,isHeadless:o,compression:s="DEFLATE"}){let a;n?a=await this.exportFromOriginalFile(n,t,r,i):a=await this.exportFromCollaborativeDocx(e,t,r,i);const l=o?"nodebuffer":"blob";return await a.generateAsync({type:l,mimeType:pc,compression:s,compressionOptions:s==="DEFLATE"?{level:6}:void 0})}async exportFromCollaborativeDocx(e,t,n,r){if(!Array.isArray(e))throw new Error("Collaborative DOCX export requires base package entries");const i=new BEe.default;for(const o of e){const s=o.content;i.file(o.name,s)}Object.keys(t).forEach(o=>{t[o]===null?i.remove(o):i.file(o,t[o])}),Object.keys(n).forEach(o=>{const s=n[o],a=typeof s=="string"?kT(s):s;i.file(o,a)});for(const[o,s]of Object.entries(r))i.file(o,s);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}async exportFromOriginalFile(e,t,n,r){const i=await this.unzip(e),o=[];if(i.forEach((s,a)=>{const l=a.async("uint8array").then(c=>{i.file(a.name,HEe(a.name)?UEe(c):c)});o.push(l)}),await Promise.all(o),Object.keys(t).forEach(s=>{t[s]===null?i.remove(s):i.file(s,t[s])}),Object.keys(n).forEach(s=>{i.file(s,n[s])}),r)for(const[s,a]of Object.entries(r))i.file(s,a);return await this.updateContentTypes(i,n,!1,t,r),await this.#t(i),i}#i(e){if(e==null)return null;if(typeof e=="string"&&e.startsWith("data:image/"))return e.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase()||null;let t=null;return e instanceof ArrayBuffer?t=g1(new Uint8Array(e)):ArrayBuffer.isView(e)?t=g1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=g1(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${xG[t]||t}`:null}},TG=sKt;const aKt=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const i=e.state.tr.setSelection(mn.create(n,t));return e.dispatch(i),!0}return!1};function lKt(e,t="sans-serif"){const n=(r,i)=>{const o=document.createElement("canvas").getContext("2d");o.textBaseline="top";const s="abcdefghijklmnopqrstuvwxyz0123456789";o.font=`72px ${i}`;const a=o.measureText(s),l=a.width,c=a.actualBoundingBoxDescent;o.font=`72px "${r}", ${i}`;const u=o.measureText(s),d=u.width,f=u.actualBoundingBoxDescent;return d!==l||f!==c};return n(e,t)?!0:n(e,t==="sans-serif"?"serif":"sans-serif")}var eE=(...e)=>{};const cKt=e=>{const t=[];if(eE("ATTEMPTING MIGRATIONS"),!e.converter.numbering)return t;const{state:n}=e,{doc:r}=n,i=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),o=["orderedList","bulletList"];let s=0;r.descendants((l,c)=>{if(!o.includes(l.type.name)||c<s)return;const u=_M(l,e,0);u.length>0&&t.push({from:c,to:c+l.nodeSize,listNode:l,replacement:u}),s=c+l.nodeSize});let a=n.tr;if(t.length>0)for(let l=t.length-1;l>=0;l--){const{from:c,to:u,replacement:d,listNode:f}=t[l],h=[];for(const p of d)if(p.node.type.name==="listItem"){const m=f.type.create(f.attrs,[p.node]);h.push(m)}else h.push(p.node);eE("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,i(a),t};function _M(e,t,n=0,r=null){const i=[],o=["orderedList","bulletList"],s=e.type.name,a=uKt(e),l=dKt(e,t);if(eE("Needs migration?",a),!a)return l?i:fKt(e,t);let c=parseInt(e.attrs?.listId);eE("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=ur.getNewListId(t)),(!ur.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=ur.getNewListId(t),eE("Genearted new list ID",c,"for list type",s),ur.generateNewListDefinition({numId:c,listType:s,editor:t})),r||(r=c);for(const u of e.content.content)if(!u.content.content?.length)i.push({node:u,baseLevel:n});else if(u.content.content.length===1){const d=u.content.content[0];if(o.includes(d.type.name)){const f=_M(d,t,n+1,r);i.push(...f)}else{const f=ur.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}}else{const d=u.content.content[0];if(o.includes(d.type.name)){const f=_M(d,t,n+1,r);i.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=ur.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});i.push({node:f,baseLevel:n})}else i.push({node:d});for(let f of u.content.content.slice(1))if(o.includes(f.type.name)){const h=_M(f,t,n+1,r);i.push(...h)}else i.push({node:f})}return i}var uKt=e=>{const t=e.content;if(t?.content?.length>1)return!0;const n=t.firstChild;if(n&&n.type.name==="listItem"){const{attrs:r}=n,{level:i,listNumberingType:o}=r||{};return typeof i>"u"||!o?!0:(n?.content?.content).filter(s=>["bulletList","orderedList"].includes(s.type.name)).length>0}return!1},dKt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i,level:o}=r||{},{abstract:s}=ur.getListDefinitionDetails({numId:i,level:o,listType:n,editor:t})||{};return!!s},fKt=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:i}=r||{};return ur.generateNewListDefinition({numId:i,listType:n,editor:t})};const hKt=async(e=[],t)=>{const n=ru(t.state),r=[];if(!n.length)return e;for(const i of n){const o=i.node?.attrs?.type,s=e.find(l=>l.input_id===i.node.attrs.fieldId);if(s&&(!o||o!=="html")){r.push(s);continue}const a=s?.input_value;a&&await new Promise((l,c)=>{const u=document.createElement("div");t.createChildEditor({element:u,html:a,onCreate:({editor:d})=>{const{migrated:f}=d.options;f&&(s.input_value=d.getHTML(),r.push(s)),l()},onError:d=>{c(d)}})})}return r},pKt=(e,t={})=>e.options.isChildEditor?null:new Fp({...e.options,pagination:!1,suppressDefaultDocxStyles:!0,ydoc:null,collaborationProvider:null,fileSource:null,initialState:null,documentId:null,isCommentsEnabled:!1,isNewFile:!1,fragment:!1,onCreate:()=>null,onListDefinitionsChange:mKt,...t,isChildEditor:!0,parentEditor:e});var mKt=e=>{const{editor:t,numbering:n}=e,{parentEditor:r={}}=t.options,{converter:i}=r;if(!i)return;i.numbering=n;const{tr:o}=r.state;o.setMeta("updatedListItemNodeViews",!0),r.dispatch(o)};function bCe(e,t=[]){const n="[SuperValidator]",r="color: teal; font-weight: bold;",i=[n,...t.map(a=>`[${a}]`)],o=i.map(()=>"%c%s").join(" "),s=i.map(a=>[r,a]).flat();return{debug:(...a)=>{e&&console.debug(o,...s,...a)},withPrefix:a=>bCe(e,[...t,a])}}function gKt(e,t,n,r){let i=!1;const o=[];return e.forEach(({node:s,pos:a})=>{const{rId:l,src:c}=s.attrs;if(!l&&c){const u=ww(t,"image-rid:ensureValidImageRID",{target:c,type:"image"});u&&(r.debug("Assigned rId for image:",u,"at pos:",a),n.setNodeMarkup(a,void 0,{...s.attrs,rId:u}),o.push(`Added missing rId to image at pos ${a}`),i=!0)}}),{modified:i,results:o}}function yKt({editor:e,logger:t}){const n=(r,i)=>{const o=[gKt(i.image||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={nodes:["image"]},n}function bKt(e,t,n,r){let i=!1;const o=[];return e.forEach(({mark:s,from:a,to:l})=>{const{rId:c,href:u,anchor:d}=s.attrs;if(!c&&u&&!d){const f=ww(t,"link-rid:ensureValidLinkRID",{target:u,type:"hyperlink"});if(f){r.debug("Assigned rId for link:",f,"from pos:",a,"to pos:",l);const h=t.schema.marks.link,p=h.create({...s.attrs,rId:f});n.removeMark(a,l,h),n.addMark(a,l,p),o.push(`Added missing rId to link from pos ${a} to ${l}`),i=!0}}}),{modified:i,results:o}}function vKt({editor:e,logger:t}){const n=(r,i)=>{const o=[bKt(i.link||[],e,r,t)];return{modified:o.some(s=>s.modified),results:o.flatMap(s=>s.results)}};return n.requiredElements={marks:["link"]},n}const wKt={imageNodeValidator:yKt,linkMarkValidator:vKt};function AKt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml,o="word/numbering.xml",s=i?.[o];if(!s||!s.elements?.length||!s.elements[0].elements?.length)return n.push(`${o} is not a valid xml`),{results:n,modified:r};const a=[];let l=s.elements[0];return vCe(l,a),a.length?(r=!0,n.push("Removed invalid <w:num> by numId:"+a.join(", ")),t?.debug?.(`Removed invalid <w:num> by numId: ${a.join(", ")}`)):n.push("No <w:num> entries with null/invalid numId found."),{results:n,modified:r}}}function vCe(e,t){if(!e||!Array.isArray(e.elements))return;const n=[];for(const r of e.elements){if(r?.type==="element"){if(r.name==="w:num"){const i=(r.attributes||{})["w:numId"],o=i==null?null:String(i).trim();if(o==null||o===""||/^null$/i.test(o)||!/^\d+$/.test(o)){t.push(o??"missing node");continue}}Array.isArray(r.elements)&&r.elements.length&&vCe(r,t)}n.push(r)}e.elements=n}function SKt({editor:e,logger:t}){return()=>{const n=[];let r=!1;const i=e?.converter?.convertedXml;if(!i||typeof i!="object")return{results:n,modified:r};const{relsKey:o,wasNormalized:s}=xKt(i,n);if(!o)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=TKt(i[o],o,n);if(!a)return{results:n,modified:r};l&&(r=!0),IKt(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=kKt(a,i,n);d&&(r=!0),EKt(i,c,n,t)&&(r=!0);const f=i["[Content_Types].xml"];return u.size>0||f?CKt(i,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function xKt(e,t){const n=["word/_rels/document.xml.rels","word/document.xml.rels","_rels/document.xml.rels","document.xml.rels"].find(i=>e?.[i]?.elements);if(!n)return{relsKey:null,wasNormalized:!1};const r="word/_rels/document.xml.rels";return n!==r?(e[r]=e[n],delete e[n],t.push(`Normalized relationships location to ${r} (was ${n})`),{relsKey:r,wasNormalized:!0}):{relsKey:n,wasNormalized:!1}}function TKt(e,t,n){const r=e?.elements?.[0];if(!r||r.type!=="element")return n.push(`${t} is not a valid xml`),{root:null,wasFixed:!1};const i="http://schemas.openxmlformats.org/package/2006/relationships";let o=!1;return r.name!=="Relationships"&&(r.name="Relationships",n.push('Fixed relationships root element name to "Relationships"'),o=!0),r.attributes=r.attributes||{},r.attributes.xmlns!==i&&(r.attributes.xmlns=i,n.push(`Set relationships xmlns to ${i}`),o=!0),{root:r,wasFixed:o}}function IKt(e){const t=e.elements?.filter(n=>n?.type==="element"&&n.name==="Relationship")||[];return e.elements?.length!==t.length?(e.elements=t,!0):!1}function kKt(e,t,n){const r=new Set,i=new Set;let o=!1;const s=v=>{const b=/^rId(\d+)$/.exec(String(v||""));return b?parseInt(b[1],10):null},a=(v,b)=>typeof v=="string"&&new RegExp(`/relationships/${b}$`,"i").test(v),l=v=>a(v,"hyperlink"),c=v=>a(v,"image"),u=v=>/^https?:\/\//i.test(v||"")||/^mailto:/i.test(v||""),d=new Set;let f=0;for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes.Id,w=s(b);Number.isInteger(w)&&(f=Math.max(f,w)),typeof b=="string"&&b&&d.add(b)}let h=f;const p=v=>{if(v&&!d.has(v))return d.add(v),v;let b;do h+=1,b=`rId${h}`;while(d.has(b));return d.add(b),b},m=new Set,g=[];function y(v,b){return typeof v[b]=="string"?v[b].trim():""}for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes;let w=y(b,"Id");const x=y(b,"Type");let S=y(b,"Target"),T=y(b,"TargetMode");if(!S){n.push(`Removed relationship "${w}" without Target`),o=!0;continue}if(l(x)&&u(S)&&T.toLowerCase()!=="external"&&(b.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${w}`),o=!0),c(x)){const k=V0(S,"word");k&&/^media\/.+\.bin$/i.test(S)&&k in t&&r.add(`/${k}`)}if(T.toLowerCase()!=="external"&&!u(S)&&!(V0(S,"word")in t))if(c(x))n.push(`Warning: image relationship ${w} target not found: ${S}.`);else{n.push(`Removed relationship ${w} with missing target: ${S}`),o=!0;continue}if(!w){const k=p(null);b.Id=k,n.push(`Assigned missing Id "${k}"`),o=!0,w=k}if(m.has(w)){n.push(`Removed duplicate relationship with ID "${w}"`),o=!0;continue}m.add(w),g.push(v)}(e.elements.length!==g.length||e.elements.some((v,b)=>v!==g[b]))&&(e.elements=g,o=!0);for(const v of e.elements){const b=v.attributes?.Id;typeof b=="string"&&b&&i.add(b)}return{filteredIds:i,binMediaTargets:r,wasProcessed:o}}function EKt(e,t,n,r){const i=e["word/document.xml"];if(i?.elements?.length){const o=i.elements[0];if(o?.type==="element"){const s=[];if(wCe(o,t,s),s.length)return n.push(`Fixed ${s.length} missing relationship references`),r?.debug?.(`Fixed ${s.length} missing relationship references in document`),!0}}return!1}function CKt(e,t,n){const r="[Content_Types].xml",i=e[r];return typeof i=="string"?_Kt(i,t,n,e,r):i?.elements?.length?RKt(i,t,n):!1}function _Kt(e,t,n,r,i){const o='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">',s=(c,u,d)=>new RegExp(`<Default\\s+Extension="${u}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Default Extension="${u}" ContentType="${d}"/>`),a=(c,u,d)=>{const f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<Override\\s+PartName="${f}"\\b`,"i").test(c)?c:c.replace(o,`${o}<Override PartName="${u}" ContentType="${d}" />`)};let l=e;l=s(l,"rels","application/vnd.openxmlformats-package.relationships+xml"),l=s(l,"xml","application/xml");for(const c of t)l=a(l,c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`);return l!==e?(r[i]=l,!0):!1}function RKt(e,t,n){const r=e.elements.find(c=>c.name==="Types")||e.elements[0];r.elements=r.elements||[];const i=c=>r.elements.some(u=>u.name==="Default"&&u.attributes?.Extension===c),o=(c,u)=>{r.elements.unshift({type:"element",name:"Default",attributes:{Extension:c,ContentType:u}})},s=c=>r.elements.some(u=>u.name==="Override"&&u.attributes?.PartName===c),a=(c,u)=>{r.elements.unshift({type:"element",name:"Override",attributes:{PartName:c,ContentType:u}})};let l=!1;i("rels")||(o("rels","application/vnd.openxmlformats-package.relationships+xml"),l=!0),i("xml")||(o("xml","application/xml"),l=!0);for(const c of t)s(c)||(a(c,"image/png"),n.push(`Added Content Types Override for "${c}" as image/png`),l=!0);return l}function wCe(e,t,n){if(e?.elements?.length)for(const r of e.elements){if(r?.type!=="element")continue;const i=r.attributes?.["r:id"];typeof i=="string"&&!t.has(i)&&(delete r.attributes["r:id"],n.push(`Removed invalid r:id="${i}"`)),wCe(r,t,n)}}const PKt={numberingValidator:AKt,relationshipsValidator:SKt};var ACe=class{#e;#t;#i;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=bCe(this.debug);const{stateValidators:t,xmlValidators:n,nodeTypes:r,markTypes:i}=this.#o();this.#t=t,this.#i=n,this.#n=r,this.#r=i}#o(){const e=new Set,t=new Set,n=r=>Object.fromEntries(Object.entries(r).map(([i,o])=>{const s=this.logger.withPrefix(i),a=o({editor:this.#e,logger:s});return this.#a(a,e,t),[i,a]}));return{stateValidators:n(wKt),xmlValidators:n(PKt),nodeTypes:e,markTypes:t}}#a(e,t,n){e.requiredElements&&typeof e.requiredElements=="object"&&(e.requiredElements.nodes&&e.requiredElements.nodes.forEach(r=>{t.add(r)}),e.requiredElements.marks&&e.requiredElements.marks.forEach(r=>{n.add(r)}))}#c(){const{doc:e}=this.#e.state,t={};this.#n.forEach(r=>t[r]=[]),this.#r.forEach(r=>t[r]=[]);const n=(r,i)=>{this.#n.has(r.type.name)&&t[r.type.name].push({node:r,pos:i}),r.isText&&r.marks&&r.marks.forEach(o=>{this.#r.has(o.type.name)&&t[o.type.name].push({mark:o,node:r,pos:i,from:i,to:i+r.nodeSize})})};return e.descendants(n),t}validateActiveDocument(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e,n=this.#c();this.logger.debug("Document analysis:",n);let r=!1;const i=[];return Object.entries(this.#t).forEach(([o,s])=>{this.logger.debug(`🕵 Validating with ${o}...`);const{results:a,modified:l}=s(t,n);i.push({key:o,results:a}),r=r||l}),this.dryRun?this.logger.debug("DRY RUN: No changes applied to the document."):this.#u(t),this.logger.debug("Results:",i),{modified:r,results:i}}validateDocumentExport(){const e=this.#e.state;if(!e)return{modified:!1,results:[]};const{tr:t}=e;let n=!1;const r=[];return Object.entries(this.#i).forEach(([i,o])=>{this.logger.debug(`🕵 Validating export with ${i}...`);const{results:s,modified:a}=o();r.push({key:i,results:s}),n=n||a}),!this.dryRun&&n?this.#u(t):this.logger.debug("DRY RUN: No export changes applied to the document."),this.logger.debug("Export validation results:",r),{modified:n,results:r}}#u(e){if(typeof this.#e?.dispatch=="function"){this.#e.dispatch(e);return}this.#e?.view?.dispatch?.(e)}},RM=null;const EA=()=>{if(RM!==null)return RM;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return RM=e,e}catch{return RM=!1,!1}};var LKt="1.31.1",NKt=["group","content","marks","inline","atom","defining","code","tableRole","summary"],MKt=["group","inclusive","excludes","spanning","code"];function SCe(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>{const r=n?.default;return[t,{default:r??null,required:r===void 0}]})):{}}function xCe(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function DKt(e,t){if(!e||typeof e!="object")throw new Error("Invalid schema: schema must be a valid ProseMirror Schema object.");const n=t||"current",r=[];e.spec.nodes.forEach((o,s)=>{r.push({name:o,attrs:SCe(s.attrs),...xCe(s,NKt)})});const i=[];return e.spec.marks.forEach((o,s)=>{i.push({name:o,attrs:SCe(s.attrs),...xCe(s,MKt)})}),{version:LKt,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:i}}const OKt=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],i=o=>{for(;r.length&&r[r.length-1].level>=o;){const s=r.pop();r.length?r[r.length-1].el.appendChild(s.el):n.push(s.el.outerHTML)}};return Array.from(t.childNodes).forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE){n.push(o.outerHTML||o.textContent);return}if(o.tagName.toLowerCase()==="ol"||o.tagName.toLowerCase()==="ul"){const s=BKt(o),a=HKt(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=o.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",FKt(l,c)),!r.length||r[r.length-1].level<a){const f=document.createElement(u);r.push({tag:u,level:a,el:f})}else if(r[r.length-1].level>a)i(a+1);else if(r[r.length-1].tag!==u){i(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else i(0),n.push(o.outerHTML)}),i(0),n.join("")},FKt=(e,t)=>{const n=new Map([["●","disc"],["◦","circle"],["▪","square"]]);if(e==="bullet")return n.get(t)||"disc";const r=new Map([["decimal","decimal"],["lowerLetter","lower-alpha"],["upperLetter","upper-alpha"],["lowerRoman","lower-roman"],["upperRoman","upper-roman"]]);return t.startsWith("0")?"decimal-leading-zero":r.get(e)};function BKt(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const HKt=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var zKt=1,UKt=10,VKt=150,WKt=1.2,GKt=1,jKt=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),qKt="span.sd-paragraph-content",TCe="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",YKt='<meta name="Generator" content="Microsoft Word">',KKt=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function ICe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(TCe))return r}n=n.parentNode}return null}function XKt(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(TCe)}function JKt(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),i=e.style.fontFamily||"",o=e.style.fontSize||(n?.fontSize&&n.fontSize!=="16px"?n.fontSize:""),s=e.style.textTransform||(n?.textTransform&&n.textTransform!=="none"?n.textTransform:""),a=e.style.fontWeight||(n?.fontWeight&&n.fontWeight!=="400"?n.fontWeight:"");return r&&t.push(`color: ${r}`),i&&t.push(`font-family: ${i}`),o&&t.push(`font-size: ${o}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function ZKt(e,t){const n=e.cloneContents();if(XKt(n))return n;const r=ICe(e.startContainer,t.dom),i=ICe(e.endContainer,t.dom);if(!r||r!==i)return n;const o=r.cloneNode(!1),s=JKt(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),o.appendChild(l)}else o.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(o),a}function QKt(e,t){let n;try{n=e.posAtDOM(t,0)}catch{return null}const{doc:r}=e.state;if(n<0||n>r.content.size)return null;const i=r.resolve(n);for(let o=i.depth;o>0;o-=1){const s=i.node(o);if(s.type.name==="paragraph")return s}return null}function $Kt(e){e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(t=>{const n=t.getAttribute("data-list-numbering-type"),r=t.getAttribute("data-marker-type");n&&!t.hasAttribute("data-num-fmt")&&t.setAttribute("data-num-fmt",n),r&&!t.hasAttribute("data-lvl-text")&&t.setAttribute("data-lvl-text",r)})}function eXt(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const i=r.getAttribute("data-sd-block-id");if(!i)return;const o=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(i)??i}"]`);if(!o)return;const s=QKt(t,o),a=s?.attrs?.paragraphProperties?.sectPr;if(!a||typeof a!="object")return;r.setAttribute("data-sd-sect-pr",JSON.stringify(a));const l=s?.attrs?.pageBreakSource;typeof l=="string"&&l.length>0&&r.setAttribute("data-sd-page-break-source",l)})}function tXt(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(n=>Number(n)).filter(n=>Number.isFinite(n)):[]}catch{return[]}}function nXt(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const i=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${i}`}function rXt(e){const t=document.createDocumentFragment();t.appendChild(document.createComment("[if !supportLists]"));const n=document.createElement("span");return n.textContent=e,t.appendChild(n),t.appendChild(document.createComment("[endif]")),t}function iXt(e){if(Array.from(e.querySelectorAll("p[data-num-id], p[data-list-numbering-type]")).length===0)return null;const t=e.cloneNode(!0),n=[".MsoNormal {}",".MsoListParagraph {}"],r=new Set;return t.querySelectorAll("p[data-num-id], p[data-list-numbering-type]").forEach(i=>{const o=Number.parseInt(i.getAttribute("data-level")||"0",10)||0,s=o+1,a=i.getAttribute("data-num-id")||"1",l=a,c=i.getAttribute("data-num-fmt")||i.getAttribute("data-list-numbering-type")||"decimal",u=KKt.get(c)||"decimal",d=i.getAttribute("data-marker-type")||i.getAttribute("data-lvl-text")||"1.",f=nXt(o,c,d,i.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=i.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;i.setAttribute("class","MsoListParagraph"),i.setAttribute("style",p?`${m};${p}`:m),r.has(h)||(n.push(`@list l${l}:level${s} lfo${a} { mso-level-number-format: ${u}; mso-level-text: "${f}"; }`),r.add(h));const g=tXt(i.getAttribute("data-list-level")),y=g[o]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;i.prepend(rXt(v))}),`${YKt}<style>${n.join(`
323
323
  `)}</style>${t.innerHTML}`}function kCe(e){if(e instanceof Document)return e.getSelection();if(typeof ShadowRoot<"u"&&e instanceof ShadowRoot){const t=e;return typeof t.getSelection=="function"?t.getSelection()??null:t.ownerDocument.getSelection()}return typeof document<"u"?document.getSelection():null}function oXt(e,t){const n=kCe(e.root);if(!n||n.isCollapsed||n.rangeCount===0)return null;const r=document.createElement("div");let i=!1;for(let o=0;o<n.rangeCount;o+=1){const s=n.getRangeAt(o),a=s.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;a&&!e.dom.contains(a)||(r.appendChild(ZKt(s,e)),i=!0)}return i?(r.querySelectorAll(jKt).forEach(o=>{o.parentNode?.removeChild(o)}),r.querySelectorAll(qKt).forEach(o=>{const s=o.parentNode;if(s){for(;o.firstChild;)s.insertBefore(o.firstChild,o);s.removeChild(o)}}),r.querySelectorAll("[contenteditable], [draggable], [spellcheck], [data-pm-slice]").forEach(o=>{o.removeAttribute("contenteditable"),o.removeAttribute("draggable"),o.removeAttribute("spellcheck"),o.removeAttribute("data-pm-slice")}),r.querySelectorAll("[class]").forEach(o=>{const s=(o.getAttribute("class")||"").split(/\s+/).filter(Boolean).filter(a=>!a.startsWith("ProseMirror"));s.length>0?o.setAttribute("class",s.join(" ")):o.removeAttribute("class")}),ebt(r,e,t),$Kt(r),eXt(r,e),iXt(r)||r.innerHTML||null):null}var ECe=class{constructor(){this.view=null,this.eventListenerCleanups=[],this.resizeTimeoutId=null}attach({element:e,state:t,editorProps:n={},dispatchTransaction:r,handleClick:i}){return this.view?.destroy(),this.view=new Dfe(e,{...n&&typeof n=="object"?n:{},dispatchTransaction:r,state:t,handleClick:i}),this.view}destroy(){this.resizeTimeoutId!==null&&(clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=null);for(const e of this.eventListenerCleanups)e();this.eventListenerCleanups=[],this.view?.destroy(),this.view=null}initContainerElement(e){if(!EA()){e.isHeadless=!0,e.element=null;return}if(!e.element&&e.selector){const{selector:t}=e;let n=null;if(t.startsWith("#")||t.startsWith(".")){const r=document.querySelector(t);n=r instanceof HTMLElement?r:null}else n=document.getElementById(t);e.element=n,["text","html"].includes(e.mode)&&e.element&&e.element.classList.add("sd-super-editor-html")}if(e.isHeadless){e.element=null;return}e.element=e.element||document.createElement("div"),oM(e.element)}initFonts(e){const t=e.converter.getFontFaceImportString();if(t?.styleString?.length)try{const n=document.createElement("style");n.textContent=t.styleString,document.head.appendChild(n),e.fontsImported=t.fontsImported}catch(n){console.warn("Failed to inject fonts into DOM:",n)}}updateEditorStyles(e,t,n){!n||!t||(this.#e(e,t,n),e.isWebLayout()?this.#t(t,n):this.#i(e,t,n))}#e(e,t,n){n.setAttribute("role","document"),n.setAttribute("aria-multiline","true"),n.setAttribute("aria-label","Main content area, start typing to enter text."),n.setAttribute("aria-description",""),n.classList.remove("view-mode"),t.style.boxSizing="border-box",t.style.isolation="isolate",n.style.outline="none",n.style.border="none",t.style.backgroundColor="#fff",n.style.backgroundColor="#fff";const{typeface:r,fontSizePt:i,fontFamilyCss:o}=e.converter.getDocumentDefaultStyles()??{},s=o||r;s&&(t.style.fontFamily=s),i&&(t.style.fontSize=`${i}pt`),n.style.lineHeight=e.options.isHeaderOrFooter?String(GKt):String(WKt),t.style.transformOrigin="top left",t.style.touchAction="auto";const a=t.style;("webkitOverflowScrolling"in t.style||typeof a=="object")&&(a.webkitOverflowScrolling="touch")}#t(e,t){e.style.width="",e.style.minWidth="",e.style.minHeight="",e.style.paddingLeft="",e.style.paddingRight="",t.style.paddingTop="0",t.style.paddingBottom="0"}#i(e,t,n){const{pageSize:r,pageMargins:i}=e.converter.pageStyles??{};r?.width!=null&&(t.style.width=`${r.width}in`,t.style.minWidth=`${r.width}in`,r?.height!=null&&(t.style.minHeight=`${r.height}in`)),i&&(t.style.paddingLeft=`${i.left}in`,t.style.paddingRight=`${i.right}in`),e.presentationEditor&&i?.top!=null?n.style.paddingTop=`${i.top}in`:e.presentationEditor?n.style.paddingTop=`${zKt}in`:n.style.paddingTop="0",n.style.paddingBottom="0"}initDefaultStyles(e,t=e.element){if(e.options.isHeadless||e.options.suppressDefaultDocxStyles||!t)return;const n=t.querySelector(".ProseMirror"),r=n instanceof HTMLElement?n:null;r&&(this.updateEditorStyles(e,t,r),this.initMobileStyles(e,t))}initMobileStyles(e,t){if(!t||e.isWebLayout())return;const n=t.offsetWidth,r=()=>{const o=n,s=document.documentElement.clientWidth-UKt;e.options.scale=Math.min(1,s/o);const a=t.closest(".super-editor"),l=t.closest(".super-editor-container");!(a instanceof HTMLElement)||!(l instanceof HTMLElement)||(e.options.scale<1?(a.style.maxWidth=`${o*e.options.scale}px`,l.style.minWidth="0px",t.style.transform=`scale(${e.options.scale})`):(a.style.maxWidth="",l.style.minWidth="",t.style.transform="none"))};r();const i=()=>{this.resizeTimeoutId!==null&&clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=setTimeout(()=>{r(),this.resizeTimeoutId=null},VKt)};if("orientation"in screen&&"addEventListener"in screen.orientation)screen.orientation.addEventListener("change",i),this.eventListenerCleanups.push(()=>{screen.orientation.removeEventListener("change",i)});else{const o=typeof window.matchMedia=="function"?window.matchMedia("(orientation: portrait)"):null;o?.addEventListener&&(o.addEventListener("change",i),this.eventListenerCleanups.push(()=>{o.removeEventListener("change",i)}))}window.addEventListener("resize",i),this.eventListenerCleanups.push(()=>{window.removeEventListener("resize",i)})}registerCopyHandler(e){const t=this.view?.dom;if(!t||!EA())return;const n=r=>{try{const i=r.clipboardData;if(!i||(r.preventDefault(),!this.view))return;const{from:o,to:s}=this.view.state.selection;let a="";if(o!==s){const m=this.view.state.doc.slice(o,s);a=JSON.stringify(m.toJSON()),i.setData("application/x-superdoc-slice",a);const g=Ope(a,e);g&&i.setData(pH,g)}const l=oXt(this.view,e),c=this.view.state.doc.attrs?.bodySectPr,u=c&&zpe(c)?JSON.stringify(c):"";if(l){i.setData("text/html",mH(l,a,u)),i.setData("text/plain",kCe(this.view.root)?.toString()??"");return}const d=this.view.state.doc.slice(o,s).content,f=document.createElement("div"),h=Cf.fromSchema(this.view.state.schema);f.appendChild(h.serializeFragment(d)),gH(f,d,e);const p=OKt(f.innerHTML);i.setData("text/html",mH(p,a,u)),i.setData("text/plain",this.view.state.doc.textBetween(o,s,`
324
324
  `))}catch(i){console.warn("Failed to transform copied content:",i)}};t.addEventListener("copy",n),this.eventListenerCleanups.push(()=>{t.removeEventListener("copy",n)})}initDevTools(e){if(!e.options.isHeaderOrFooter&&e.options.isDebug)try{window.superdocdev={converter:e.converter,editor:e}}catch(t){console.warn("Failed to initialize developer tools:",t)}}};const sXt="data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,UEsDBBQAAAAIAAAAIQAykW9XXgEAAKUFAAATABwAW0NvbnRlbnRfVHlwZXNdLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAAC1lMtqwzAQRfeF/oPRNthKuiilxMmij2UbaPoBijRORPVCmrz+vuM4NaWkMeSxMcgz994zQsxwvLEmW0FM2ruSDYo+y8BJr7Sbl+xz+po/sCyhcEoY76BkW0hsPLq9GU63AVJGapdKtkAMj5wnuQArUuEDOKpUPlqBdIxzHoT8EnPgd/3+PZfeITjMsfZgo+EzVGJpMHvZ0O+GJIJJLHtqGuuskokQjJYCqc5XTv1JyfcJBSl3PWmhQ+pRA+MHE+rK/wF73TtdTdQKsomI+CYsdfG1j4orL5eWlMVxmwOcvqq0hFZfu4XoJaREd25N0Vas0K7XxeGWdgaRlJcHaa07IRJuDaTLEzS+3fGASIJrAOydOxHWMPu4GsUv806QinKnYmbg8hitdScE0hqA5js4m2NncyySOifRh0RrJZ4w9s/eqNU5DRwgoj7+6tpEsj57PqhXkgJ1IJvvluzoG1BLAwQKAAAAAACTZE1bAAAAAAAAAAAAAAAACQAcAGRvY1Byb3BzL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhACEYr1llAQAAxQIAABAAHABkb2NQcm9wcy9hcHAueG1sVVQJAAMw0M4SMNDOEnV4CwABBPUBAAAEFAAAAJ1STU/DMAy9I/Efqt63dBwmNHlBaAhx4GPSCpyjxG0j0iRKson9e5wVSoEbOdnP9st7TuDqvTfFAUPUzq7LxbwqC7TSKW3bdflc384uyyImYZUwzuK6PGIsr/j5GWyD8xiSxlgQhY3rskvJrxiLssNexDmVLVUaF3qRKA0tc02jJd44ue/RJnZRVUuG7wmtQjXzI2E5MK4O6b+kysmsL77UR098HGrsvREJ+WOeNHPlUg9sRKF2SZha98grgscEtqLFyBfAhgBeXVAx9wwBbDoRhEy0vwxOMrj23mgpEu2VP2gZXHRNKp5OYos8DWzaAmRgh3IfdDpmqmkK99ri6YIhIFVBtEH47gROMthJYXBD1nkjTERg3wBsXO+FJTo2RsT3Fp997W7yFj5HfoITi686dTsvJP4yO8FhRygqUj8KGAG4o8cIJrPTrG1RffX8LeT1vQy/ki+W84rOaV9fGLkevwv/AFBLAwQUAAAACAAAACEACvOn+GYBAADtAgAAEQAcAGRvY1Byb3BzL2NvcmUueG1sVVQJAAMw0M4SMNDOEnV4CwABBPUBAAAEFAAAAJ2SXU+DMBSG7038D6T3UGBqDAGWTLMrZ0yc0XhX27Otjn6k7cb27y0wmMRdeXc+nvP29G3z6UFUwR6M5UoWKIliFICkinG5LtDbch7eo8A6IhmplIQCHcGiaXl9lVOdUWXgxSgNxnGwgVeSNqO6QBvndIaxpRsQxEaekL65UkYQ51OzxprQLVkDTuP4DgtwhBFHcCMY6kERnSQZHST1zlStAKMYKhAgncVJlOAz68AIe3Gg7fwiBXdHDRfRvjnQB8sHsK7rqJ60qN8/wR+Lp9f2qiGXjVcUUJkzmjnuKihzfA59ZHdf30BdVx4SH1MDxClTPnO6DWZgJKlapq83jm/hWCvDrJ8eZR5jYKnh2vl37LRHBU9XxLqFf9gVBzY7jo/5224mDOx58y/KtCWGND+Z3K0GLPDmZJ2Vfed98vC4nKMyjdObMEnD5G6Zpll8m8XxZ7PdaP4sKE4L/FuxF+gMGn/Q8gdQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAYAHABfcmVscy9VVAkAA4Yc7WiHHO1odXgLAAEE9QEAAAQUAAAAUEsDBBQAAAAIAAAAIQAekRq36QAAAE4CAAALABwAX3JlbHMvLnJlbHNVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAArZLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wFQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAUAHAB3b3JkL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAoWRNW+xw0GIQAgAAtAcAABIAHAB3b3JkL2ZvbnRUYWJsZS54bWxVVAkAA54c7WieHO1odXgLAAEE9QEAAAQUAAAAvZPBbqMwEIbvlfoOlu8NhpA0RSFV222kvexh1T6AY0ywFtvI44Tk7dcYiBSyuy3tqiCEGf75mPnHLO8PskR7bkBoleJwQjDiiulMqG2KX1/WNwuMwFKV0VIrnuIjB3y/ur5a1kmulQXk8hUkkqW4sLZKggBYwSWFia64ci9zbSS17tFsA0nNr111w7SsqBUbUQp7DCJC5vj6CrmjZZn3oHSeC8a/abaTXFkPCQwvHVYrKEQFZ8j6Pcham6wymnEA170sW6ikQp2zwviCJgUzGnRuJ663rjbPc4yQ+JUsB5TZOEr0Z8qc8cM40KIDBS7zAiaycbD5CSayIexjZQ0p2W4UJ5r2FTW3Jn0IhMxmxThmP8GgyaWWFhSKCywf1+/sxDxKNwgkWfJ9q7Shm9KR3CZDbosgD0btZJobaieO+j6Qdwiv2mK6nxLViaLSUV6E5IB+8Br91JKqXtZJK6o08NCp97RMMWkanZMpmZHYXZFbxTg4T2EFNcDtKYUMBTmVojz2743/6kBSCcuKXrGnRjQdD0Ugtk6ygw1J8TMhJHper3EbCVP85CK3i9ljF4maSvxx10WmpwhpIsxz/GPYcpjnnDT915dB6+Bf/HzSOyO4aRx908tb59+d97TxMv60l1Jn3PzbzFwcePYRJ+PpVzv54MZevunho9uPsfewPT/rIdQC4P/sx4evdrFfwuo3UEsDBBQAAAAIAAAAIQCWFrgr1QIAAIgLAAARABwAd29yZC9kb2N1bWVudC54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAApZZbb9sgFMffJ+07WH5v8S1OYjWttGab+jCpWrcPQIDEqAYsILd9+h3s+LJ5qxz3CXPg/PjDORxz93AShXdg2nAlV354G/gek0RRLncr/+ePLzcL3zMWS4oLJdnKPzPjP9x//HB3zKgie8Gk9QAhTXYsycrPrS0zhAzJmcDmVnCilVFbe0uUQGq75YSho9IURUEYVF+lVoQZA+s9YnnAxr/gyGkcjWp8BGcHTBDJsbbs1DHCqyEztESLISiaAIIdRuEQFV+NSpFTNQAlk0CgakCaTSP9Y3PpNFI0JM2nkeIhaTGNNEgnMUxwVTIJg1ulBbbQ1TsksH7dlzcALrHlG15wewZmkDYYzOXrBEXg1RJETK8mzJFQlBUxbShq5e+1zC7+N62/k57V/pem9WDFuGVhuSViJ1sY2/jqMWdXu68vhaU6NaRZAeeopMl52VYHMZUGg3kDObx1AAdR+G1lC0detf+VtnUdhg44Rv4ldqKolb9NDIMR0XSI1mOMhD/XbJQIyOBu4UlH0zvccGTxaQDRAJASNvJn0TAWFwYi3e12HD7yWjWctOVw2uNME9MD0P1ViChudLjGufdYhlqaX4drYoScL7Y4xybvE9l1G5y1uLPonXe5e9+l+qrVvuxo/H20p668HuV1GwzSvyNYmveJeclxCVVXkOxpJ5XGmwIUwVXz4LZ4VQS8Ol1d49U3wGti7VUJ5Lmq5d/DO22j6Nm1JQwkWYk1foI0T8JlmqTz0K+s8Jezzhoks+VivpyBNYM3If0OJkiveD3/1JqetTPGYZA8fm6Na7bF+8IOpz/3JiMnwzBin/VYfiV89/ILBqFihVGUBG4iJHQ4W8A3qid8w45oFRTWMKmnaL7LbdfdKGuV6PoF2/ZGc4Ypg3XnUdXdKmV73d3eVt3LckQVBqymxITVcyozvIe/aheSrOCSPXNLQGWcVqOo2Xf1WUcEdU/o+99QSwMEFAAAAAgAAAAhAMrnZYorBAAAvgwAABEAHAB3b3JkL3NldHRpbmdzLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAAC1V22PmzgQ/n7S/QfE58uG1ySLmq3yervV5lqVre6zAZNYa2Nkm03T0/33GwwO9BZVSav9hJln5pnxeGYM795/ZdR6wUISXsxt98axLVykPCPFfm5/edqOZrYlFSoyRHmB5/YJS/v93e+/vTtGEisFatICikJGLJ3bB6XKaDyW6QEzJG94iQsAcy4YUvAq9mOGxHNVjlLOSqRIQihRp7HnOBO7peFzuxJF1FKMGEkFlzxXtUnE85ykuH0YC3GJ38ZkzdOK4UJpj2OBKcTAC3kgpTRs7GfZADwYkpcfbeKFUaN3dJ0LtnvkIjtbXBJebVAKnmIp4YAYNQGSonMcvCI6+74B3+0WNRWYu45e9SMPryPwXhFMUvz1Oo5ZyzEGyz4Pya7jmZx5SNbj+blgegRZdRWF55s46kdt3uOSmcoO19GZMxrXtkihA5KHPiO+boPhme7EunxLekkFNtAjSQQSp375sTR62BdcoIRCOFCGFlSSpaOzmqOsH1ZTHZbJg6WTa9/B1PnGObOOUYlFCq0HI8tz7HENQMHzPFZIAVEkS0ypnmEpxQj8HqO9QAymj5FomwznqKLqCSWx4iUovSDY3tRQpgckUKqwiEuUAtuKF0pwavQy/hdXK5hkAhqttdBzrVvFzYwEiwIx2PB3c2/HM1xHVgly+cnYxrsb9l3+3xGHmS5Ihp/qRMfqRPEWgo/JN7wosg+VVAQY9fT7hQh+FAAuas8foTSeTiXeYqQqSNMbOdMnsaWk3BEhuHgoMqiNN3NG8hwLcECg1nZQPkTwo87zPUYZXKVv5LeS+G9Qhs70n6Asn5dcKc7uT+UBcv1rJ6nrfdwvX/ggyKRZfOZcnVVhbPnr6bKJtEYvQXzXCVabQWTibN1hm0XgO/4gsnLXbjCMhLPlaggJboOJuxhCJqG3CcIhZLH0Zv5sCFku3Wk4iKxW/srfDiIbZz28n83Km04HY9vees7tpj2d9kxYVH9qfBJmVTe2xRqLFWKJIMja1R8j41ojEc9LUhg8wTClcR+Jq8SAo1EDSIYo3UKJGcBp5BmR5Rrnek13SOw73lZDDEphyn44c9VTG4s/Ba/KBj0KVDYNa1TcIGgtSaEeCTNyWSWxsSrgXulBVZF9fBE6T116jpGCBtCD7xHpRtK6uBh9idtGoyKumwTvUFk2vZbs3blNyf6g3Lo9FLxl8M2qX5K912KexrwG0y8orXcG2u2ik3lG1tPzjczvZIGRBZ0sNLKwk02MbFLLDjBdBVx1z9D2ZlnLc04pP+LsvsNficwlmBI48fjEku5uu2kwSiTMoRKuQcWFwf7QmBtEGU8f6vs6aOT+YhGuF860gUN9fSo9qiC1n3G+RBJnLWZMw8b0n8nEmbjuajYKZpvb0WYaBKOZu7wdTafO1PW3rufPnH/bPjA/Hnf/AVBLAwQUAAAACAAAACEA24Vsw30EAACXHQAAEgAcAHdvcmQvbnVtYmVyaW5nLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAADNmc1u4zYQx+8F+g6CgB4Tifq2sM4iySZFFttF0U3RMy3RlhB+CBRlx9d9mT5CH2tfoaRkyXLkxJIctz4pJjk/zQxnyL+dDx+fCdaWiOcpo1MdXJq6hmjE4pQupvqfj/cXga7lAtIYYkbRVF+jXP949fNPH1YhLcgMcblQkwyah6ssmuqJEFloGHmUIALzS5JGnOVsLi4jRgw2n6cRMlaMx4ZlArP8K+MsQnkuObeQLmGub3DRcz9azOFKGiugY0QJ5AI9bxlgMMQ1JkbQBVkjQDJCC3RR9mCUZyivOiBnFEh61SG540h7gvPGkawuyR9HsrukYBypU06kW+AsQ1ROzhknUMiPfGEQyJ+K7EKCMyjSWYpTsZZM06sxMKVPIzySVg2B2PFggm8QFiNsxzWFTfWC03Bjf9HYK9fDyn7zaCwQ7vda+bqJgZ4FzkVty/vkrjL/xKKCICrKrBkcYZlHRvMkzZrTgYylycmkhizfSsCSYL052UDPVnvtaPtUbcMW2Mf9zd4RXHn+NhGYPXZTIRqLPi7svrP2hMgK3r54VGpayQU9D58aYHUAXoR6XhY1I9gwjGjb3YqT9myrmuM1nDRuccY50wLExSCEZdd+qIcyb7HyWMTJMFy9R4ayhQImME/aRDQsQLfBrUkr39niuKb6lbMi29LS42gP2+N1RYcFaHovdzDLj3PmWwIzeeqSKHxYUMbhDEuPZKtpslu0cge0qlzVQ6s6QKv3WisLSFOnln4lhRqc5YLDSHwtiLbz6UFWuxR8khlyJFUeV4OVprueC8RvOIJPaomi0Fy9LVxCeQUAD1jejenrhpohBRbpF7RE+HGdoXpNsp7xNP5NzWE1V60VJMP1Chfc3Tp3ZlDN4KWaSOWjcioUGZb3remYE9M0QelD6WPjRGUnZeg9aQZnBcZINMRHeQfVUz++/9OMf47qUYzmm+XZ71w9UqrCVMNT3bdKTxJIF6Ugtj1TrTWaxXzzuGdU5Cq5eZTKOvy2JjOGS9NrmbedgZRKcIzmUGZmAyspRunYy0yATibsckTeZ/JSXCK14ujMsKF5AY4zLjG3rOAp4tpXtGpl58VolHcXDsua1cma+/5Z+/H976F5s4A3Lm9/ydXqO1neytru2LAE2Xsa7AQJGtxwVhD83x3nnGXHyTycdce5Z9pxjj3yCH/vjvPOtONcc+RR/n4d559lx7n+yLP6P+q44Ew7znNGHuHHd5yxo24PSl8wRvq6gW8C++b6OOl7d+c5wL91+kjf+57bGKMoJRDv3cdfwOU7a9+echVMRhYlZivEvyAh92J/RNbgiA6p1p5aEtwcE9IfjEC6PyJ7X0Q8XSQDBCUIeoTUVX/3I0N6s+acwTt0SP71VGynKzp3cEiHhFtPOXWyovOGF11HU/Uquq4AOknR+YN36JAC6ilaTld0wfCQDmiXnoriZEU3GV50HVnxStF1NQAt737auvPVD2dhXJQ/q5WDMlTHn3jWy5/LHpprv34X3cO09jGdwHWB7wDwOhO0mUbrH6pX/wJQSwMEFAAAAAgAAAAhAL5+dmJWAQAA0AMAABQAHAB3b3JkL3dlYlNldHRpbmdzLnhtbFVUCQADMNDOEjDQzhJ1eAsAAQT1AQAABBQAAACd01FvwiAQAOD3JfsPhHelumlMYzVZFpe9LEu2/QAKV0sGXAO46n79aLWuiy92T0DLfbnjYLneG02+wHmFNqOTcUIJWIFS2W1GP943owUlPnAruUYLGT2Ap+vV7c2yTmvI3yCEuNOTqFifGpHRMoQqZcyLEgz3Y6zAxp8FOsNDXLotM9x97qqRQFPxoHKlVTiwaZLM6Ylx1yhYFErAI4qdARvaeOZARxGtL1XlO62+RqvRycqhAO9jPUYfPcOVPTOT+wvIKOHQYxHGsZhTRi0VwydJOzP6F5gNA6YXwFzAfpixOBksRvYdJYc587OjZM/5XzI9QO4GEdO7Lo9maMJ7lpdBlsO4rkesieWBl9yXfRGGFTg7cwfTnLcR6fPWouO5jlK8QSReAtLC5NiFZiDHxpKuBNKeC13FJ4ZVUEZ9wwbdg8Pag2PNZ6411q8vT3HB/rzD1Q9QSwMEFAAAAAgAAAAhAD+v4WZfDwAADaYAAA8AHAB3b3JkL3N0eWxlcy54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAA3Z1tc9s2Esff38x9B45e9V6ksp5lT92O7STnzCWpWzvX1xAJWaj5oCOpOO6nPwB8EKUlKC64UdRMZlqL4v4I4L+7xIIU+dMvXwLf+czjREThZW/w41nP4aEbeSJ8vOx9enj7at5zkpSFHvOjkF/2XnjS++Xnf/7jp+eLJH3xeeJIQJhcBO5lb5Wm64t+P3FXPGDJj9Gah/LLZRQHLJUf48d+wOKnzfqVGwVrloqF8EX60h+enU17OSZuQ4mWS+Hy15G7CXiYavt+zH1JjMJkJdZJQXtuQ3uOYm8dRy5PEtnpwM94ARNhiRmMASgQbhwl0TL9UXYmb5FGSfPBmf4r8LeACQ4wBICpy7/gGPOc0ZeWVY7wcJxpyRFehWPXmArA26AQw1HRDvU/ZV5hJV7qrXC4QqO+smUpW7FkVSVyXAcnJe4lUOMduBfvHsMoZgtfkqQHOdIJHA12MhXU/5xMWKfogqPHpfezjC4vcl/zJdv4aaI+xndx/jH/pP/3NgrTxHm+YIkrxGXvKhZMDvHzBWdJepUI9iBbLg8fCNmS26swEerLlfqjsrObXPYeRCBD+SN/dn6PAhY6P1xH3otzc/+vXl8d6InHodzzM/Mve8NsU/JXuWFcbLlJ9rf5LHwstvHw1af7ausqmxbCk01i8av7K204GF/44pGlm1g2S33ShCwRxd6N7Db/km5k++XO/Xw8+vujtC4/ZXvtDalMGDJ93GdZTH7Ll+8j94l796n84rJ31ss2fnp3F4solpnqsnd+nm+854G4FZ7Hw8qO4Up4/I8VDz8l3Ntu/+2tzjb5BjfahPLv0WyqZfYT780Xl69V7pLfhkzp9VEZaG02Yntwbf6/AjbIB7jOfsWZSuDOYB9xjkYMlUVS6W09c7PX9wH6QKNjHWh8rANNjnWg6bEONDvWgebHOtD51z6QCD2Z3wf1hwHUQxxDNKI5hmBDcwyxhOYYQgXNMUQCmmNwdDTH4MdojsFNEZw0ck1eWHH2kcHbm7mHzxF23MOnBDvu4TOAHfdwwrfjHs7vdtzD6dyOezh723EPJ2s8N5tqOe9kmIVp5yhbRlEaRil31PS0M42FkqWrWhqeOunxmKSTBJgss+Un4s40l+nPhz1k0u18nqqCzomWzlI8quKkc8N5+Jn70Zo7zPMkjxAYc1k+GUbExqdjvuQxD11O6dh0UF+E3Ak3wYLAN9fskYzFQ494+AoiSVIoHZpt0pUKEkHg1AFz44hgzsLI8sN7kXQfKwVxrje+z4lYH2lcTLO61wYa07000JjulYHGdC8MKppRDVFOIxqpnEY0YDmNaNwy/6Qat5xGNG45jWjcclr3cXsQqc/3Zx2D9mt3N36UUCS8e/EY6vXTzqR8zdS5YzF7jNl65ahl54MzLfRx9JLzA8U5rSRRzeu1i6hVZxFuug/oDo0quEoeUXiVPKIAK3ndQ+yDnCarCdotTT1zv1mktUHbviq4Z/4mm9B2jzaWdvewbQC8FXFCFgb1WAIP/qims7dEU71tK7s3bMvqHlb7WYm0eTmSoJV+5D7RpOHblzWPZVn21Jn0NvL96Jl7dMT7NI4yX6uG/HDYOuTfBOsVS0QCEO1P9cUdDM4Htu7coTufiZBGtzevAiZ8h24Gcfvw4b3zEK1VmakGhgZ4HaVpFJAx85XAH/7gi3/RNPBKFsHhC1Fvr4iWhzTsRhCcZDJS5BGR5DRThILkHKp5/+Evi4jFHg3tLubZTUMpJyLes2DtU8WWzIvPMv8QzIY0778sFmpdiCqoHkhglWXDZLP4k7vdU93HyCFZGfp1k+r1Rz3V7X61dwfXfZqwg+s+RdBqytOD8l+Czu7gund2B0fV2RufJYkwXkK15lF1t+BR97d78ZfzIj+KlxufbgALINkIFkCyIYz8TRAmlD3WPMIOax51fwldRvMIluQ079+x8MjE0DAqJTSMSgYNo9JAw0gF6H6HTgXW/TadCqz7vToZjGgKUIFR+Rnp6Z/oKk8FRuVnGkblZxpG5WcaRuVno9cOXy7lJJjuFFNBUvlcBUl3oglTHqyjmMUvRMg3Pn9kBAukGe0ujpbq1yRRmN3ETTGd3SxSysl2hqMS+Q++IGuaYlG2i2BFlPl+FBGtrW1PONpy9961Q2b65xydm3DnM5evIt/jsaFPjfXy/Zq5Ai6dtr9Y8l48rlLnflWu9lcx07ODlkXBvmN2+IB1Yz4dNl5m8sQmKBoKf0wxHbU3HgLj8WHj7Uxix3LS0hIec3rYcjtL3rGctbSEx5y3tBwBy6Z4eM3ip1pHmDX5T1njGZxv1nhhvjCuPWyTI5WWdS44a/KinVBxrlxXXS2A6rSLGbN9u+Ax22OiyEzBhJOZ0jquzIimAPudfxZJ7Rr1gevf5d0TIO+PW2fO3zZRCi5TD9v/qOudnDiFCXdqOaP2F652sox5HFunGzOidd4xI1onIDOiVSYymqNSkpnSOjeZEa2TlBmBzlbwjIDLVtAel62gvU22ghSbbNVhFmBGtJ4OmBHoQIUIdKB2mCmYEahABeZWgQop6ECFCHSgQgQ6UOEEDBeo0B4XqNDeJlAhxSZQIQUdqBCBDlSIQAcqRKADFSLQgWo5tzeaWwUqpKADFSLQgQoR6EAddwxUaI8LVGhvE6iQYhOokIIOVIhABypEoAMVItCBChHoQIUIVKACc6tAhRR0oEIEOlAhAh2ok46BCu1xgQrtbQIVUmwCFVLQgQoR6ECFCHSgQgQ6UCECHagQgQpUYG4VqJCCDlSIQAcqRKADddoxUKE9LlChvU2gQopNoEIKOlAhAh2oEIEOVIhABypEoAMVIlCBCsytAhVS0IEKEehAhYgm/8wvUZpusx/gVz2Nd+wjfueTNer36k+5d9ZQ26OKVplZ7X+LcB1FT07tDw9Ho/YQsfBFpJeoDZfVq9wZ+sLnrzfNv/Bp8RiPtl3Jfwuhr5kC+LitJVhTGTe5fNUSFHnjJk+vWoJZ57gp+1YtwWlw3JR0dVwWN6XI0xEwbkozFeOBwbwpW1fM4RA35eiKIRzhpsxcMYQD3JSPK4YTRyXnfetJy3GalveXAkKTO1YIMzOhyS2hVsa1/daimQlt1TMT2spoJqD0NGLwwppRaIXNKDupYZhhpbYPVDMBKzUkWEkNMPZSQ5S11BBlJzVMjFipIQErtX1yNhOspAYYe6khylpqiLKTGp7KsFJDAlZqSMBK3fGEbMTYSw1R1lJDlJ3UcHKHlRoSsFJDAlZqSLCSGmDspYYoa6khyk5qUCWjpYYErNSQgJUaEqykBhh7qSHKWmqIapJar6LYV0sVc9wkrGKIOyFXDHHJuWJoUS1VrC2rpQrBslqCWtlVS1XR7Kqlqnp21VJVRrtqCehpVy3VCmtXLdUqbFctmaXGVUt1UtsHql21VCc1rloySo2rlhqlxlVLjVLjqiWz1LhqqU5qXLVUJ7V9crarloxS46qlRqlx1VKj1LhqySw1rlqqkxpXLdVJjauW6qTueEK2q5YapcZVS41S46ols9S4aqlOaly1VCc1rlqqkxpXLRmlxlVLjVLjqqVGqXHVkllqXLVUJzWuWqqTGlct1UmNq5aMUuOqpUapcdVSo9S4aumDNBEEj4C6D1icOnTPi7tlySpl3R9O+CmMeRL5n7nn0Hb1PaqX/eed118ptn6dn9w/lWOmnoBe+bmSlz0BNgfqHd955WuqlLFqiZO/5yvfrBucX67NjqgNDxyqhOfXigcAv325lT7Cgsle/RrWHTxUD0as2a4cotheHOZmxeLs262rFvuc7/fl+SJO1Avcsq/Pzoaj0evZdbbXOns12xPn64/y+P3ig9SHJ/pTkv2AVpov1DPF5AiMpvq3V2yZ8viyN8+jNsqe2vT+s18eKZcuP0btW+CKV76xPyuvfNt/H5z68k2+TX2vXwlXa+kmaWXztfBE1jhXRXnZrrfj2VT7ht5ZZ4DLHtPxv92sbkpR9xm8zQjbF8gVF5urL5AbF30tXu1m4zxDo/MMKZ1n2MJ5tmGZ7bcTlF/ZvQYt3WvwfbrXaAjdK9vW0b1GRvcaUbrX6Dtxr2Gzex1yomO4ynAOXSXb1tFVxkZXGVO6yvjEXWVe9ZSx0VNGX8dTRPbfm4TEbzp6xMToERNKj5h8Hx4xPs3c0dEHpkYfmFL6wPTEfcAs++ToiWByrv7tO4F609LWBR6EeoPv1ZTAA2ZGD5hResDsb+sB0yME/pE1nxs1n1NqPj8pzaGys6PH9nCm/rXR+TXFnO/cqPM5pc7nJ67z/AgRTK+sKweVufkD1Q3rX/mLkcon++jXIu1rbnh7kkGvQTu9zO1O1SpsQ5v1Km3jwl3+sHaTQ7X2qHThZ1LLP96FyqGe83fYZy31vrBeseMN9/0PLNs7Wpt39fkyzb4dnM1rvl9kr4Qw2sf62oER0N9tTL/shHm8s5dE5j9qMa6T6keGweHOHiXWcaRb+rC7SeTQ6OXe/fbtrIHut/K2WG51tnlmL3HVxoEpXQ0OpCpz8vle1qO6LHciJR02SjokknSIO/t8/wp3WXFEKjxqVHhEpPDoayn8d1/0Q6o1blRrTKTW+NTUOvbCG1KVSaMqEyJVJqemysnpMG3UYUqkw/TUdDjqahRSklmjJDMiSWanJslpiTBvFGFOJML81EQ46koOUpLzRknOiSQ5PzVJvslyWvZgi/2xzrZSrKNpUtMi2iAv2FBrZNtF7r0L4656fcWXdMP8/En6jctjxyyBtk3W3XpV9PuJx+XgbifLZXqcwunzhDgRbiWqdYOu4VbxJbP6p1m2Hl+z+iAtX6K9L1D5BUWoFrDGaB1YRGu4CbI/hA/vhyq/BDE9mB64Je+bTECAVwwm36Lm3RHL5BZdQ3fXvczecOJzxq8sWX3MZq8B2Fcm20oRrZrUFKpDmztrD92ANige3venW3BUEcvj2khtmGSOz9S/NhpS18PbgasVp2vMVBQ2a3IwYI46cvUOrC6fbN+rsT9We6/dOOTRcChGYwv3FPpSl7pQpZ6R12LO19Jdyk7nD44rn2a3323wuDuco9R4BOqEetg7jnifVT4W9Ylu920oFAmverimvDeyKSjW117lAqneL5GelL9X+y91j5yTZUeuJ61OPuyW6+PlpdSvfKT+tmeHfhgxKjJ7NcbmU90afWU3+0SS/L/peijwo0bX7Xo62AmSAx57cnHfmCO3z9Y0DeB2j65Zsrjmh8qSi+yo+WglMqn4N2xNM3ZgSjmpH9Hir+Tn/wNQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAHAB3b3JkL3RoZW1lL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhAGeA/LSbBgAAzSAAABUAHAB3b3JkL3RoZW1lL3RoZW1lMS54bWxVVAkAAzDQzhIw0M4SdXgLAAEE9QEAAAQUAAAA7VlPb9s2FL8P2HcgdHf1x5IsBXUL/23XJm3RpB16ZGRaYkyJAkknMYoCQ3vaZcCAbthlwG47DMMKrMCKXfZhCrTYug8xSnZs0abatE23AksMxCL5e48/vvf4+ExdvHycEnCIGMc0axv2BcsAKIvoCGdx27izN2wEBuACZiNIaIbaxgxx4/KlTz+5CLdEglIEpHzGt2DbSITIt0yTR7Ib8gs0R5kcG1OWQiGbLDZHDB5JvSkxHcvyzRTizAAZTKXam+MxjhDYK1Qal06UD4j8lwledESE7UbljFWJEjua2MUXn/EeYeAQkrYh5xnRoz10LAxAIBdyoG1Y5Z9hXrpoLoWIqJGtyA3Lv4XcQmA0cUo5Fu8vBa2BE7j2Ur8z17+JGwTFZ6mvBMAokiu1N7C251uBs8BWQPNHje6wZTdVfEV/c1N/6HcdV8E3V3h3c43DcND3FLy7wnsb+I7ldMOmgvdWeH8D7w46LWeg4EtQQnA22UT7rSDwF+glZEzJVS089H2r1V/AVyizEl1z+UzUxVoKDygbSkDpXChwBsQsR2MYSVwnF5SDPuY5gTMD5DCjXHZbjm3LwHMtZ/kpLQ63EKxIz7sivtFV8AE8YjgXbeOa1GpUIC+ePXv+8Onzh789f/To+cNfwDaOE6GRuwqzuCr36sev//7+C/DXrz+8evyNHs+r+Jc/f/ny9z9ep14otL598vLpkxffffXnT4818A6D+1X4Hk4RBzfQEbhNU7lAzQRon72dxF4CcVWik8UcZrCQ0aAHIlHQN2aQQA2ui1Q73mUyXeiAV6YHCuHdhE0F1gCvJ6kC3KGUdCnTrul6MVfVCtMs1k/OplXcbQgPdXP31rw8mOYy7rFOZS9BCs1bRLocxihDAhRjdIKQRuwexopdd3DEKKdjAe5h0IVYa5I9vC/0QldxKv0y0xGU/lZss3MXdCnRqe+jQxUp9wYkOpWIKGa8AqcCplrGMCVV5DYUiY7k7oxFisG5kJ6OEaFgMEKc62RusplC9zqUeUvr9h0yS1UkE3iiQ25DSqvIPp30EpjmWs44S6rYz/hEhigEt6jQkqDqDina0g8wq3X3XYzE2+3tOzIN6QOkGJky3ZZAVN2PMzKGSKe8w1IlxXYY1kZHdxorob2NEIFHcIQQuPOZDk9zqid9LZFZ5SrS2eYaVGO1aGeIy1qpKG40jsVcCdldFNMaPjuztcQzg1kKWZ3mGxM1ZAb7TG5GXbySaKKkUsyKTasncZOn8FRabyVQCauizfXxOmPZ2+4xKXPwDjLorWVkYj+1bfYgQfqA2YMYbOvSrRSZ6kWK7VSKTbVyY3XTrtxgrhU9Kc7eUAH9N5XPB6t5zr7aqUso6zVOHW69sulRNsIff2HTh9PsFpJnyXldc17X/B/rmrr9fF7NnFcz59XMv1bNrAoYs3rZU2pJa29+xpiQXTEjaJuXpQ+Xe380lJ1loxRaXjTliXxcTKfgYgbLZ8Co+ByLZDeBuZzGLmeI+UJ1zEFOuSyfjFrdZfE1TXfoaHGPZ5/cbUoBKFb9lrfsl6WamPf6rdVF6FJ92Yp5lYBXKj09icpkKommhkSreToStnVWLEINi8B+HQuz4hV5OAFYXIt77pyRDDcZ0qPCT3P5E++euafrjKku29EsL3TPzNMKiUq4qSQqYZjIw2O9+4x9HYZ6VztaGq3gQ/ja3MwNJFNb4EjuuaYn1UQwbxtj+bNJPqa51MeLTAVJnLWNSCwM/S6ZJWdc9CFP5rByaL7+FAvEAMGpjPWqG0i24mY7LevjJRdaH5/lzHUno/EYRaKmZ9WUY3Ml2tH3BBcNOpWkd5PREdgnU3YbSkN5Lbsw4AhzsbTmCLNKcK+suJauFltReQO02qKQ5AlcnCjVZD6Hl89LOpV1lEzXV2XqTLgfD8/i1H2z0FrSrDlAWrVZ7MMd8hVWTT0rT5vrwsB6/Snx/gdChVqgp9bUU6s7O86wIKhM59fYzan15nueButRa1bqyrK18XKb7h/IyO/LanVKBJ9fkB3L8rt38lpyngnK3pPscizAlOG2cd/yOm7P8XoNK/AGDbfpWo3A6zQbHc9r2gPPtvpd54E0ikhS25vPPZQ/9sls8e6+7N94f5+elNoXIpqatKyDzVK4fH9vO/Xv7wGWlrnvO8OwGXb9RtjsDBtuvxs0wp7fbfT9Xqs/7Pe8IBw+MMBhCXY7zZ7rD4KGb/d6Dde3CvpB2Gi5jtNxW51g4HYeLGwtV37yfWLektelfwBQSwMECgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAHAB3b3JkL19yZWxzL1VUCQADhhztaIcc7Wh1eAsAAQT1AQAABBQAAABQSwMEFAAAAAgAAAAhALO+ix3+AAAAtgMAABwAHAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzVVQJAAMw0M4SiBztaHV4CwABBPUBAAAEFAAAAK2TzWrDMBCE74W+g9h7LTttQwmRcymBXFv3AWR7/UP1Y6RNWr99RUoShwbTg44zYme+hdV6860VO6DzvTUCsiQFhqaydW9aAR/F9uEFmCdpaqmsQQEjetjk93frN1SSwpDv+sGzkGK8gI5oWHHuqw619Ikd0ISXxjotKUjX8kFWn7JFvkjTJXfTDMivMtmuFuB29SOwYhzwP9m2afoKX22112joRgX3SBQ28yFTuhZJwMlJQhbw2wiLqAg0KpwCHPVcfRaz3ux1iS5sfCE4W3MQy5gQFGbxAnCUv2Y2x/Ack6GxhgpZqgnH2ZqDeIoJ8YXl+5+TnJgnEH712/IfUEsBAh4DFAAAAAgAAAAhADKRb1deAQAApQUAABMAGAAAAAAAAQAAAKSBAAAAAFtDb250ZW50X1R5cGVzXS54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMKAAAAAACTZE1bAAAAAAAAAAAAAAAACQAYAAAAAAAAABAA7UGrAQAAZG9jUHJvcHMvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhACEYr1llAQAAxQIAABAAGAAAAAAAAQAAAKSB7gEAAGRvY1Byb3BzL2FwcC54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEACvOn+GYBAADtAgAAEQAYAAAAAAABAAAApIGdAwAAZG9jUHJvcHMvY29yZS54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMKAAAAAACTZE1bAAAAAAAAAAAAAAAABgAYAAAAAAAAABAA7UFOBQAAX3JlbHMvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhAB6RGrfpAAAATgIAAAsAGAAAAAAAAQAAAKSBjgUAAF9yZWxzLy5yZWxzVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsBAh4DCgAAAAAAk2RNWwAAAAAAAAAAAAAAAAUAGAAAAAAAAAAQAO1BvAYAAHdvcmQvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAoWRNW+xw0GIQAgAAtAcAABIAGAAAAAAAAQAAAKSB+wYAAHdvcmQvZm9udFRhYmxlLnhtbFVUBQADnhztaHV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQCWFrgr1QIAAIgLAAARABgAAAAAAAEAAACkgVcJAAB3b3JkL2RvY3VtZW50LnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQDK52WKKwQAAL4MAAARABgAAAAAAAEAAACkgXcMAAB3b3JkL3NldHRpbmdzLnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQDbhWzDfQQAAJcdAAASABgAAAAAAAEAAACkge0QAAB3b3JkL251bWJlcmluZy54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEAvn52YlYBAADQAwAAFAAYAAAAAAABAAAApIG2FQAAd29yZC93ZWJTZXR0aW5ncy54bWxVVAUAAzDQzhJ1eAsAAQT1AQAABBQAAABQSwECHgMUAAAACAAAACEAP6/hZl8PAAANpgAADwAYAAAAAAABAAAApIFaFwAAd29yZC9zdHlsZXMueG1sVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsBAh4DCgAAAAAAk2RNWwAAAAAAAAAAAAAAAAsAGAAAAAAAAAAQAO1BAicAAHdvcmQvdGhlbWUvVVQFAAOGHO1odXgLAAEE9QEAAAQUAAAAUEsBAh4DFAAAAAgAAAAhAGeA/LSbBgAAzSAAABUAGAAAAAAAAQAAAKSBRycAAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFVUBQADMNDOEnV4CwABBPUBAAAEFAAAAFBLAQIeAwoAAAAAAJNkTVsAAAAAAAAAAAAAAAALABgAAAAAAAAAEADtQTEuAAB3b3JkL19yZWxzL1VUBQADhhztaHV4CwABBPUBAAAEFAAAAFBLAQIeAxQAAAAIAAAAIQCzvosd/gAAALYDAAAcABgAAAAAAAEAAACkgXYuAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzVVQFAAMw0M4SdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAARABEAqQUAAMovAAAAAA==";var aXt={dot:".",hyphen:"-",underscore:"_",middleDot:"·"},lXt={".":"dot","-":"hyphen",_:"underscore","·":"middleDot"},cXt={outlineLevels:{from:1,to:3},useAppliedOutlineLevel:!0},uXt={hyperlinks:!0,hideInWebView:!0};const CCe={source:cXt,display:uXt,preserved:{}};var _Ce=/\\([a-z])\s*(?:"([^"]*)")?/gi;function IG(e){const t=e.match(/^(\d+)-(\d+)$/);if(t)return{from:parseInt(t[1],10),to:parseInt(t[2],10)}}function dXt(e){const t=[],n=e.split(",");for(let r=0;r<n.length-1;r+=2){const i=n[r].trim(),o=parseInt(n[r+1].trim(),10);i&&!isNaN(o)&&t.push({styleName:i,level:o})}return t}function kG(e,t){if(!e)return!0;const n=t??{from:1,to:9};return!(e.from<=n.from&&e.to>=n.to)}function RCe(e){return e?lXt[e]:"none"}function tb(e){const t={},n={},r={},i=[];let o;for(_Ce.lastIndex=0;(o=_Ce.exec(e))!==null;){const a=o[1].toLowerCase(),l=o[2]??"";switch(a){case"o":{const c=IG(l);c&&(t.outlineLevels=c);break}case"u":t.useAppliedOutlineLevel=!0;break;case"f":l&&(t.tcFieldIdentifier=l);break;case"l":{const c=IG(l);c&&(t.tcFieldLevels=c);break}case"h":n.hyperlinks=!0;break;case"z":n.hideInWebView=!0;break;case"n":{const c=IG(l);c&&(n.omitPageNumberLevels=c);break}case"p":l&&(n.separator=l);break;case"t":l&&(r.customStyles=dXt(l));break;case"b":l&&(r.bookmarkName=l);break;case"a":l&&(r.captionType=l);break;case"c":l&&(r.seqFieldIdentifier=l);break;case"d":l&&(r.chapterSeparator=l);break;case"s":l&&(r.chapterNumberSource=l);break;case"w":r.preserveTabEntries=!0;break;default:i.push(l?`\\${a} "${l}"`:`\\${a}`);break}}i.length>0&&(r.rawExtensions=i),n.includePageNumbers=kG(n.omitPageNumberLevels,t.outlineLevels);const s=RCe(n.separator);return s!==void 0&&(n.tabLeader=s),{source:t,display:n,preserved:r}}function PM(e){const t=["TOC"],{source:n,display:r,preserved:i}=e;if(n.outlineLevels&&t.push(`\\o "${n.outlineLevels.from}-${n.outlineLevels.to}"`),n.useAppliedOutlineLevel&&t.push("\\u"),n.tcFieldIdentifier&&t.push(`\\f "${n.tcFieldIdentifier}"`),n.tcFieldLevels&&t.push(`\\l "${n.tcFieldLevels.from}-${n.tcFieldLevels.to}"`),i.customStyles?.length){const o=i.customStyles.map(s=>`${s.styleName},${s.level}`).join(",");t.push(`\\t "${o}"`)}return r.hyperlinks&&t.push("\\h"),r.hideInWebView&&t.push("\\z"),r.omitPageNumberLevels&&t.push(`\\n "${r.omitPageNumberLevels.from}-${r.omitPageNumberLevels.to}"`),r.separator&&t.push(`\\p "${r.separator}"`),i.captionType&&t.push(`\\a "${i.captionType}"`),i.bookmarkName&&t.push(`\\b "${i.bookmarkName}"`),i.seqFieldIdentifier&&t.push(`\\c "${i.seqFieldIdentifier}"`),i.chapterSeparator&&t.push(`\\d "${i.chapterSeparator}"`),i.chapterNumberSource&&t.push(`\\s "${i.chapterNumberSource}"`),i.preserveTabEntries&&t.push("\\w"),i.rawExtensions?.length&&t.push(...i.rawExtensions),t.join(" ")}function fXt(e){return e.outlineLevels??{from:1,to:9}}function hXt(e,t){if(t.tabLeader!==void 0&&t.separator!==void 0)throw new Error("INVALID_INPUT: cannot set both tabLeader and separator in the same patch");if(t.includePageNumbers!==void 0&&t.omitPageNumberLevels!==void 0)throw new Error("INVALID_INPUT: cannot set both includePageNumbers and omitPageNumberLevels in the same patch");const n={...e.source,...t.outlineLevels!==void 0&&{outlineLevels:t.outlineLevels},...t.useAppliedOutlineLevel!==void 0&&{useAppliedOutlineLevel:t.useAppliedOutlineLevel},...t.tcFieldIdentifier!==void 0&&{tcFieldIdentifier:t.tcFieldIdentifier},...t.tcFieldLevels!==void 0&&{tcFieldLevels:t.tcFieldLevels}},r={...e.display,...t.hyperlinks!==void 0&&{hyperlinks:t.hyperlinks},...t.hideInWebView!==void 0&&{hideInWebView:t.hideInWebView}};if(t.includePageNumbers!==void 0?(t.includePageNumbers?delete r.omitPageNumberLevels:r.omitPageNumberLevels=fXt(n),r.includePageNumbers=t.includePageNumbers):t.omitPageNumberLevels!==void 0&&(r.omitPageNumberLevels=t.omitPageNumberLevels,r.includePageNumbers=kG(t.omitPageNumberLevels,n.outlineLevels)),t.tabLeader!==void 0)t.tabLeader==="none"?delete r.separator:r.separator=aXt[t.tabLeader],r.tabLeader=t.tabLeader;else if(t.separator!==void 0){r.separator=t.separator;const i=RCe(t.separator);i!==void 0?r.tabLeader=i:delete r.tabLeader}return{source:n,display:r,preserved:{...e.preserved}}}function pXt(e,t){return PM(e)===PM(t)}function tE(e){return nE(e)}function PCe(e){return OCe(e)}function LCe(e,t){const{nodeType:n,anchor:r,attrs:i}=t,o=NCe(e,r);return n==="hyperlink"?{kind:"hyperlink",hyperlink:{...typeof i?.href=="string"?{href:i.href}:{},...typeof i?.anchor=="string"?{anchor:i.anchor}:{},...typeof i?.tooltip=="string"?{tooltip:i.tooltip}:{},inlines:[{kind:"run",run:{text:o}}]}}:{kind:"run",run:{text:o}}}function mXt(e,t){const n=e.attrs;return n?n.sdBlockId===t||n.paraId===t||n.blockId===t||n.id===t||n.uuid===t:!1}function NCe(e,t){try{const n=e.state.doc;let r="";return n.descendants((i,o)=>{if(mXt(i,t.start.blockId)&&i.isBlock){const s=o+1+t.start.offset,a=o+1+t.end.offset;return r=n.textBetween(s,Math.min(a,o+i.nodeSize-1),""),!1}return!0}),r}catch{return""}}function gXt(e,t){const n=e.state.doc,r=[];n.forEach(s=>{r.push(nE(s))});const i=yXt(e),o=wXt(e);return{modelVersion:"sdm/1",body:r,...i.length>0&&{sections:i},...o&&{numbering:o}}}function yXt(e){let t;try{t=zs(e)}catch{return[]}return t.map(n=>bXt(n.domain))}function bXt(e){const t={id:e.address.sectionId};return e.breakType&&(t.breakType=e.breakType),e.pageSetup&&(t.pageSetup=e.pageSetup),e.margins&&(t.margins={top:e.margins.top,right:e.margins.right,bottom:e.margins.bottom,left:e.margins.left,gutter:e.margins.gutter}),e.headerFooterMargins&&(t.headerFooterMargins=e.headerFooterMargins),e.columns&&(t.columns=e.columns),e.lineNumbering&&(t.lineNumbering=e.lineNumbering),e.pageNumbering&&(t.pageNumbering=e.pageNumbering),e.titlePage!=null&&(t.titlePage=e.titlePage),e.oddEvenHeadersFooters!=null&&(t.oddEvenHeadersFooters=e.oddEvenHeadersFooters),e.verticalAlign&&(t.verticalAlign=e.verticalAlign),e.sectionDirection&&(t.sectionDirection=e.sectionDirection),t}var vXt=new Set(["bullet"]);function wXt(e){const t=e.converter?.translatedNumbering;if(!t)return;const{definitions:n={},abstracts:r={}}=t,i=Object.entries(n);if(i.length===0)return;const o={definitions:{}};for(const[s,a]of i){if(!a)continue;const l=a.abstractNumId,c=(l!=null?r[l]:void 0)?.levels;if(!c)continue;const u=[];for(const d of Object.values(c)){const f=d.numFmt?.val,h=a.lvlOverrides?.[d.ilvl]?.startOverride??d.start;u.push({level:d.ilvl,kind:f&&vXt.has(f)?"bullet":"ordered",...f!=null&&{format:f},...d.lvlText!=null&&{text:d.lvlText},...h!=null&&{start:h},...d.lvlRestart!=null&&{restartAfterLevel:d.lvlRestart}})}u.length>0&&(o.definitions[s]={levels:u})}return Object.keys(o.definitions).length>0?o:void 0}function nE(e){const t=e.type.name;switch(t){case"paragraph":return AXt(e);case"heading":return SXt(e);case"table":return TXt(e);case"bulletList":case"orderedList":return EXt(e,t==="orderedList");case"listItem":return _Xt(e);case"image":return RXt(e);case"tableOfContents":return PXt(e);case"sdt":case"structuredContentBlock":return NXt(e);case"sectionBreak":return DXt(e);case"pageBreak":case"horizontalRule":return OXt(e);case"drawing":return FXt(e);default:return BXt(e)}}function AXt(e){const t=e.attrs,n=Rw(t?.paragraphProperties?.styleId);return n&&n>=1&&n<=6?MCe(e,t,n):xXt(e,t)}function SXt(e){const t=e.attrs;return MCe(e,t,e.attrs?.level??Rw(t?.paragraphProperties?.styleId)??1)}function xXt(e,t){const n=rE(e),r={kind:"paragraph",id:Zd(e),paragraph:{inlines:n}},i=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;i&&(r.paragraph.styleRef=i);const o=HCe(t);return o&&(r.paragraph.props=o),r}function MCe(e,t,n){const r=rE(e),i={kind:"heading",id:Zd(e),heading:{level:n,inlines:r}},o=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;o&&(i.heading.styleRef=o);const s=HCe(t);return s&&(i.heading.props=s),i}function TXt(e){const t=e.attrs,n=e.attrs,r=[];e.forEach(l=>{l.type.name==="tableRow"&&r.push(IXt(l))});const i={kind:"table",id:Zd(e),table:{rows:r}},o=t?.tableProperties?.tableStyleId??n?.tableStyleId;o&&(i.table.styleRef=o);const s=JXt(t,n);s&&(i.table.props=s);const a=n?.grid??n?.tableGridModel??t?.tableGrid?.colWidths;if(a&&Array.isArray(a)){const l=a.map(c=>typeof c=="number"?c:c?.col??c?.width).filter(c=>typeof c=="number"&&Number.isFinite(c)).map(c=>({width:c}));l.length>0&&(i.table.columns=l)}if(n?.needsTableStyleNormalization===!0){const l=EG(i.ext)?{...i.ext}:{},c=EG(l.superdoc)?{...l.superdoc}:{};c.needsTableStyleNormalization=!0,i.ext={...l,superdoc:c}}return i}function IXt(e){const t=[];e.forEach(i=>{(i.type.name==="tableCell"||i.type.name==="tableHeader")&&t.push(kXt(i))});const n={cells:t},r=e.attrs;return(r?.minHeight!==void 0||r?.cantSplit!==void 0)&&(n.props={},r.minHeight!==void 0&&(n.props.minHeight=r.minHeight),r.cantSplit!==void 0&&(n.props.cantSplit=r.cantSplit)),n}function kXt(e){const t=e.attrs,n=[];e.forEach(o=>{n.push(nE(o))});const r={content:n};t?.colspan&&t.colspan>1&&(r.colSpan=t.colspan),t?.rowspan&&t.rowspan>1&&(r.rowSpan=t.rowspan);const i=t?.tableCellProperties?.vAlign??t?.verticalAlign;return i&&(r.props={verticalAlign:i}),r}function EXt(e,t){const n=[];e.forEach(o=>{o.type.name==="listItem"&&n.push(CXt(o))});const r={kind:"list",id:Zd(e),list:{items:n,levels:[{level:0,kind:t?"ordered":"bullet"}]}},i=e.attrs;return i?.listStyleId&&(r.list.styleRef=i.listStyleId),r}function CXt(e){const t=[];return e.forEach(n=>{t.push(nE(n))}),{level:e.attrs?.level??0,content:t}}function _Xt(e){const t=rE(e);return{kind:"paragraph",id:Zd(e),paragraph:{inlines:t}}}function RXt(e){const t=e.attrs;return{kind:"image",id:Zd(e),image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function PXt(e){const t=e.attrs?.instruction??"",n=tb(t);return{kind:"toc",id:Zd(e),toc:{...t?{instruction:t}:{},...n.source?{sourceConfig:n.source}:{},...n.display?{displayConfig:n.display}:{},...n.preserved?{preservedSwitches:n.preserved}:{},entryCount:e.childCount}}}var LXt={unlocked:"none",sdtLocked:"sdt",contentLocked:"content",sdtContentLocked:"both"};function DCe(e){const t=LXt[e.lockMode],n=e.controlType??e.type;return{...e.tag?{tag:e.tag}:{},...e.alias?{alias:e.alias}:{},...typeof n=="string"?{type:n}:{},...e.appearance?{appearance:e.appearance}:{},...e.placeholder?{placeholder:e.placeholder}:{},...t&&t!=="none"?{lock:t}:{}}}function NXt(e){const t=[];return e.forEach(n=>{t.push(nE(n))}),{kind:"sdt",id:BCe(e),sdt:{...DCe(e.attrs??{}),scope:"block",...t.length>0?{content:t}:{}}}}function MXt(e){const t=rE(e);return{kind:"sdt",id:BCe(e),sdt:{...DCe(e.attrs??{}),scope:"inline",...t.length>0?{inlines:t}:{}}}}function DXt(e){return{kind:"sectionBreak",id:Zd(e),sectionBreak:{targetSectionId:e.attrs?.targetSectionId??""}}}function OXt(e){const t=e.attrs?.breakType??"page";return{kind:"break",id:Zd(e),break:{type:t==="column"?"column":"page"}}}function FXt(e){return{kind:"drawing",id:Zd(e),drawing:{source:e.attrs?.source??{type:"unknown"},...e.attrs?.geometry?{geometry:e.attrs.geometry}:{},...e.attrs?.layout?{layout:e.attrs.layout}:{}}}}function BXt(e){const t=rE(e);return{kind:"paragraph",id:Zd(e),paragraph:{inlines:t}}}function rE(e){const t=[];return e.forEach(n=>{const r=OCe(n);t.push(r)}),t}function OCe(e){if(e.isText)return UXt(e);switch(e.type.name){case"run":return HXt(e);case"image":return WXt(e);case"tab":return GXt();case"hardBreak":case"lineBreak":return jXt();case"footnoteRef":case"footnoteReference":return qXt(e);case"endnoteRef":case"endnoteReference":return YXt(e);case"field":return KXt(e);case"structuredContent":return MXt(e);default:return XXt(e)}}function HXt(e){const t=(e.attrs??{}).runProperties,n=e.textContent;let r;if(e.forEach(a=>{r||(r=a.marks?.find(l=>l.type.name==="link"))}),r)return zXt(e,r);const i={kind:"run",run:{text:n}},o=typeof t?.rStyle=="string"?t.rStyle:typeof t?.styleId=="string"?t.styleId:void 0;o&&(i.run.styleRef=o);const s=FCe(t);return s&&(i.run.props=s),i}function zXt(e,t){const n=t.attrs,r={kind:"run",run:{text:e.textContent}},i=e.attrs?.runProperties,o=FCe(i);return o&&(r.run.props=o),{kind:"hyperlink",hyperlink:{...typeof n.href=="string"?{href:n.href}:{},...typeof n.anchor=="string"?{anchor:n.anchor}:{},...typeof n.tooltip=="string"?{tooltip:n.tooltip}:{},inlines:[r]}}}function FCe(e){if(!e)return;const t={};let n=!1;const r=l=>{if(typeof l=="boolean")return l;if(l&&typeof l=="object"){const c=l,u=c.val??c.value;return typeof u=="boolean"?u:typeof u=="string"?u!=="0"&&u!=="false"&&u!=="none":!0}if(typeof l=="string")return l!=="0"&&l!=="false"};r(e.bold??e.b)&&(t.bold=!0,n=!0),r(e.italic??e.i)&&(t.italic=!0,n=!0);const i=e.underline??e.u;if(i!==void 0&&i!=="none"&&i!==!1&&(t.underline=typeof i=="object"?i:{style:"single"},n=!0),r(e.strike??e.dstrike)&&(t.strikethrough=!0,n=!0),e.highlight){const l=e.highlight,c=typeof l=="string"?l:l?.val??l?.color;typeof c=="string"&&(t.highlight=c,n=!0)}if(e.color){const l=e.color;t.color=typeof l=="string"?{model:"rgb",value:l}:l,n=!0}const o=e.sz??e.size??e.fontSize;if(typeof o=="number")t.fontSize=o,n=!0;else if(typeof o=="string"){const l=Number.parseFloat(o);Number.isFinite(l)&&(t.fontSize=l,n=!0)}const s=e.rFonts??e.fontFamily;if(s){if(typeof s=="string")t.fontFamily=s,n=!0;else if(typeof s=="object"){const l=s.ascii??s.hAnsi??s.eastAsia??s.cs;typeof l=="string"&&(t.fontFamily=l,n=!0),t.fonts=s,n=!0}}const a=e.lang;return a&&(t.lang=typeof a=="string"?{val:a}:a,n=!0),r(e.caps)&&(t.caps=!0,n=!0),r(e.smallCaps)&&(t.smallCaps=!0,n=!0),r(e.vanish)&&(t.vanish=!0,n=!0),n?t:void 0}function UXt(e){const t=e.marks,n=t.find(s=>s.type.name==="link");if(n)return VXt(e,n);const r={kind:"run",run:{text:e.text??""}},i=$Xt(t);i&&(r.run.styleRef=i);const o=eJt(t);return o&&(r.run.props=o),r}function VXt(e,t){const n=t.attrs,r={kind:"run",run:{text:e.text??""}},i=e.marks.filter(a=>a!==t),o=UCe(i);o&&(r.run.props=o);const s=zCe(i);return s&&(r.run.styleRef=s),{kind:"hyperlink",hyperlink:{...typeof n.href=="string"?{href:n.href}:{},...typeof n.anchor=="string"?{anchor:n.anchor}:{},...typeof n.tooltip=="string"?{tooltip:n.tooltip}:{},inlines:[r]}}}function WXt(e){const t=e.attrs;return{kind:"image",image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function GXt(){return{kind:"tab",tab:{}}}function jXt(){return{kind:"lineBreak",lineBreak:{}}}function qXt(e){return{kind:"footnoteRef",footnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function YXt(e){return{kind:"endnoteRef",endnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function KXt(e){return{kind:"field",field:{...e.attrs?.fieldType?{fieldType:e.attrs.fieldType}:{},...e.attrs?.instruction?{instruction:e.attrs.instruction}:{},...e.attrs?.resultText?{resultText:e.attrs.resultText}:{},placement:"inline"}}}function XXt(e){return{kind:"run",run:{text:e.textContent??""}}}function Zd(e){const t=e.attrs?.sdBlockId;return typeof t=="string"&&t.length>0?t:void 0}function BCe(e){const t=e.attrs??{},n=t.id??t.sdBlockId;return typeof n=="number"?String(n):typeof n=="string"&&n.length>0?n:void 0}function EG(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function JXt(e,t){const n=e?.tableProperties,r={};let i=!1;const o=QXt(n?.tableWidth??t?.tableWidth);o&&(r.width=o,i=!0);const s=n?.tableLayout??t?.tableLayout;(s==="fixed"||s==="autofit")&&(r.layout=s,i=!0);const a=ZXt(n?.justification??t?.justification);return a&&(r.alignment=a,i=!0),i?r:void 0}function ZXt(e){if(typeof e=="string")switch(e){case"start":case"left":return"left";case"end":case"right":return"right";case"center":case"inside":case"outside":return e;default:return}}function QXt(e){if(!EG(e))return;const t=typeof e.type=="string"?e.type.toLowerCase():void 0,n=typeof e.value=="number"?e.value:typeof e.width=="number"?e.width:void 0;if(t==="auto")return{kind:"auto"};if(t==="nil"||t==="none")return{kind:"none"};if(t==="pct"&&typeof n=="number"&&Number.isFinite(n))return{kind:"percent",value:n};if(t==="dxa"&&typeof n=="number"&&Number.isFinite(n))return{kind:"points",value:n/20};if(typeof n=="number"&&Number.isFinite(n))return{kind:"points",value:n}}function HCe(e){const t=e?.paragraphProperties;if(!t)return;const n=t,r={};let i=!1;return t.justification&&(r.alignment=t.justification==="both"?"justify":t.justification,i=!0),t.indent&&(r.indent=t.indent,i=!0),t.spacing&&(r.spacing=t.spacing,i=!0),t.keepNext!==void 0&&(r.keepWithNext=t.keepNext,i=!0),t.keepLines!==void 0&&(r.keepLines=t.keepLines,i=!0),t.pageBreakBefore!==void 0&&(r.pageBreakBefore=t.pageBreakBefore,i=!0),t.widowControl!==void 0&&(r.widowControl=t.widowControl,i=!0),t.outlineLvl!==void 0&&(r.outlineLevel=t.outlineLvl,i=!0),t.numberingProperties&&(r.numbering={numId:String(t.numberingProperties.numId??""),level:t.numberingProperties.ilvl},i=!0),n.tabs&&(r.tabs=n.tabs,i=!0),n.borders&&(r.borders=n.borders,i=!0),n.shading&&(r.shading=n.shading,i=!0),n.rightToLeft!==void 0&&(r.bidi=n.rightToLeft,i=!0),n.markRunProps&&(r.markRunProps=n.markRunProps,i=!0),i?r:void 0}function $Xt(e){return zCe(e)}function zCe(e){const t=e.find(n=>n.type.name==="textStyle");if(t)return typeof t.attrs?.rStyle=="string"?t.attrs.rStyle:void 0}function eJt(e){return UCe(e)}function UCe(e){const t={};let n=!1;for(const r of e)switch(r.type.name){case"bold":t.bold=!0,n=!0;break;case"italic":t.italic=!0,n=!0;break;case"underline":t.underline=r.attrs&&typeof r.attrs=="object"&&Object.keys(r.attrs).length>0?r.attrs:{style:"single"},n=!0;break;case"strikethrough":t.strikethrough=!0,n=!0;break;case"highlight":{const i=r.attrs?.color;typeof i=="string"&&(t.highlight=i,n=!0);break}case"textStyle":{const i=r.attrs;if(!i)break;i.color&&(t.color=i.color,n=!0),i.fontSize!==void 0&&(t.fontSize=i.fontSize,n=!0),i.fontSizeCs!==void 0&&(t.fontSizeCs=i.fontSizeCs,n=!0),i.fontFamily&&(t.fontFamily=i.fontFamily,n=!0),i.fonts&&(t.fonts=i.fonts,n=!0),i.caps&&(t.caps=!0,n=!0),i.smallCaps&&(t.smallCaps=!0,n=!0),i.vanish&&(t.vanish=!0,n=!0),i.characterSpacing!==void 0&&(t.characterSpacing=i.characterSpacing,n=!0);break}}return n?t:void 0}function tJt(e,t){return gXt(e,t.options)}function LM(e){if(typeof e=="number")return e;if(e&&typeof e=="object"&&typeof e.value=="number")return e.value}function nJt(e){switch(e){case"start":return"left";case"end":return"right";case"left":case"center":case"right":return e;default:return}}function CG(e){const t=e?.paragraphProperties??void 0,n=t?.indent?{left:t.indent.left,right:t.indent.right,firstLine:t.indent.firstLine,hanging:t.indent.hanging}:void 0,r=t?.spacing?{before:t.spacing.before,after:t.spacing.after,line:t.spacing.line}:void 0,i=t?.justification,o=i==="both"?"justify":i,s=t?.numberingProperties?{numId:NL(t.numberingProperties.numId),level:NL(t.numberingProperties.ilvl)}:void 0;return{styleId:t?.styleId??void 0,alignment:o??void 0,indentation:n,spacing:r,keepWithNext:t?.keepNext??void 0,outlineLevel:t?.outlineLvl??void 0,paragraphNumbering:s}}function rJt(e){const t=r1(e?.listRendering);if(!t)return;const n={};return t.markerText&&(n.marker=t.markerText),Array.isArray(t.path)&&(n.path=t.path),n.ordinal=o8(t.path),Object.keys(n).length?n:void 0}function iJt(e){const t=e.node.attrs;return{nodeType:"paragraph",kind:"block",properties:CG(t)}}function oJt(e){const t=e.node.attrs,n=CG(t),r=Rw(t?.paragraphProperties?.styleId)??(n.outlineLevel!=null?n.outlineLevel+1:void 0);if(!r||r<1||r>6)throw new Oe("INVALID_TARGET",`Node "${e.nodeId}" does not have a valid heading level.`);return{nodeType:"heading",kind:"block",properties:{...n,headingLevel:r}}}function sJt(e){const t=e.node.attrs;return{nodeType:"listItem",kind:"block",properties:{...CG(t),numbering:rJt(t)}}}function aJt(e){const t=e.node.attrs?.tableProperties??void 0;return{nodeType:"table",kind:"block",properties:{layout:t?.tableLayout??void 0,width:LM(t?.tableWidth??null)??void 0,alignment:nJt(t?.justification)}}}function lJt(){return{nodeType:"tableRow",kind:"block",properties:{}}}function cJt(e){const t=e.node.attrs,n=t?.tableCellProperties??void 0;return{nodeType:"tableCell",kind:"block",properties:{width:LM(n?.cellWidth??null)??(Array.isArray(t?.colwidth)&&t.colwidth.length>0?t.colwidth[0]:void 0),shading:n?.shading?.fill??t?.background?.color??void 0,vMerge:n?.vMerge==="continue"||n?.vMerge==="restart"||t?.rowspan&&t.rowspan>1?!0:void 0,gridSpan:n?.gridSpan??t?.colspan??void 0,padding:LM(n?.cellMargins?.top??null)??LM(t?.cellMargins?.top??null)}}}function uJt(e){const t=e.node,n=t.attrs?.instruction??"",r=tb(n),i=t.childCount;return{nodeType:"tableOfContents",kind:"block",properties:{instruction:n,sourceConfig:r.source,displayConfig:r.display,preservedSwitches:r.preserved,entryCount:i}}}function dJt(e){if(!e)return null;const t=e.match(/^inset\(\s*([\d.]+)%\s+([\d.]+)%\s+([\d.]+)%\s+([\d.]+)%\s*\)$/);return t?{top:parseFloat(t[1]),right:parseFloat(t[2]),bottom:parseFloat(t[3]),left:parseFloat(t[4])}:null}function fJt(e,t){if(!e)return!1;try{const n=e.resolve(t),r=n.depth-1;if(r<0)return!1;const i=n.before(r+1)+n.node(r+1).nodeSize;if(i>=e.content.size)return!1;const o=e.nodeAt(i);return!o||o.type.name!=="paragraph"?!1:o.attrs?.paragraphProperties?.styleId==="Caption"}catch{return!1}}function hJt(e,t,n,r){const i=!!e?.isAnchor,o=e?.wrap,s=e?.transformData,a=s&&(s.rotation||s.verticalFlip||s.horizontalFlip)?{rotation:s.rotation??void 0,verticalFlip:s.verticalFlip??void 0,horizontalFlip:s.horizontalFlip??void 0}:null;return{nodeType:"image",kind:t,properties:{src:e?.src??void 0,alt:e?.alt??void 0,size:e?.size?{width:e.size.width,height:e.size.height,unit:void 0}:void 0,placement:i?"floating":"inline",wrap:{type:o?.type??"Inline",attrs:o?.attrs??void 0},anchorData:e?.anchorData??null,marginOffset:e?.marginOffset??null,relativeHeight:e?.relativeHeight??null,name:e?.alt??void 0,description:e?.title??void 0,transform:a,crop:dJt(e?.clipPath),lockAspectRatio:e?.lockAspectRatio??!0,decorative:e?.decorative??!1,hyperlink:e?.hyperlink??null,hasCaption:r!=null?fJt(n,r):!1}}}function pJt(e){const t=e.mark?.attrs??e.attrs??{};return{nodeType:"hyperlink",kind:"inline",properties:{href:typeof t.href=="string"?t.href:void 0,anchor:typeof t.anchor=="string"?t.anchor:typeof t.docLocation=="string"?t.docLocation:void 0,tooltip:typeof t.tooltip=="string"?t.tooltip:void 0}}}function mJt(e){const t=ML(e.mark?.attrs??e.attrs??{});if(!t)throw new Oe("INVALID_TARGET","Comment node is missing a commentId attribute.");return{nodeType:"comment",kind:"inline",properties:{commentId:t}}}function gJt(e){const t=e.attrs??e.node?.attrs??{};return{nodeType:"bookmark",kind:"inline",properties:{name:typeof t.name=="string"?t.name:void 0,bookmarkId:typeof t.id=="string"?t.id:void 0}}}function yJt(e){const t=e.node?.attrs??e.attrs??{};return{nodeType:"footnoteRef",kind:"inline",properties:{noteId:typeof t.id=="string"?t.id:void 0}}}function bJt(e){const t=e.trim().toLowerCase();if(t){if(t==="0"||t==="false"||t==="off"||t==="none")return!1;if(t==="1"||t==="true"||t==="on"||t==="single")return!0}}function CA(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="string")return bJt(e);if(e&&typeof e=="object"){const t=e,n=CA(t.val??t.value??t.type??t["w:val"]??t["w:value"]);return n??!0}}function vJt(e){for(const t of e){if(t==null)continue;if(typeof t=="string"){const r=t.trim().toLowerCase();if(!r)continue;return r!=="none"&&r!=="false"&&r!=="0"}const n=CA(t);if(n!=null)return n}}function wJt(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(typeof t.val=="string")return t.val;if(typeof t.value=="string")return t.value;if(typeof t["w:val"]=="string")return t["w:val"]}}function AJt(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e,n=t.val??t.value??t["w:val"];if(typeof n=="string"){const i=n.trim();return i?i.toLowerCase()==="none"?"transparent":i:void 0}const r=t.fill??t["w:fill"];if(typeof r=="string"){const i=r.trim();return!i||i.toLowerCase()==="auto"?void 0:i.startsWith("#")?i:`#${i}`}}}function SJt(e){const t=e.rFonts;if(t&&typeof t=="object"){const r=t,i=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof i=="string")return i}const n=e.fontFamily;if(typeof n=="string")return n;if(n&&typeof n=="object"){const r=n,i=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof i=="string")return i}}function xJt(e){const t=e.sz??e.size??e.fontSize;if(typeof t=="number")return t;if(typeof t=="string"){const n=Number.parseFloat(t);return Number.isFinite(n)?n:void 0}}function TJt(e){const t=e.node?.attrs??e.attrs??{},n=t.runProperties&&typeof t.runProperties=="object"?t.runProperties:void 0,r=vJt([n?.underline,n?.u]),i=CA(n?.strike)??CA(n?.dstrike)??void 0,o=n?.lang,s=typeof o=="string"?o:o&&typeof o=="object"&&typeof o.val=="string"?o.val:void 0;return{nodeType:"run",kind:"inline",properties:{bold:CA(n?.bold)??void 0,italic:CA(n?.italic)??void 0,underline:r??void 0,strike:i,font:n?SJt(n):void 0,size:n?xJt(n):void 0,color:wJt(n?.color),highlight:AJt(n?.highlight),styleId:typeof n?.rStyle=="string"?n.rStyle:typeof n?.styleId=="string"?n.styleId:void 0,language:s}}}function IJt(){return{nodeType:"tab",kind:"inline",properties:{}}}function kJt(){return{nodeType:"lineBreak",kind:"inline",properties:{}}}function _A(e){return"anchor"in e}function VCe(e,t,n){const r=t??e.nodeType,i=_A(e)?"inline":"block";switch(r){case"paragraph":if(i!=="block")throw new Oe("INVALID_TARGET","Paragraph nodes can only be resolved as blocks.");return iJt(e);case"heading":if(i!=="block")throw new Oe("INVALID_TARGET","Heading nodes can only be resolved as blocks.");return oJt(e);case"listItem":if(i!=="block")throw new Oe("INVALID_TARGET","ListItem nodes can only be resolved as blocks.");return sJt(e);case"table":if(i!=="block")throw new Oe("INVALID_TARGET","Table nodes can only be resolved as blocks.");return aJt(e);case"tableRow":if(i!=="block")throw new Oe("INVALID_TARGET","TableRow nodes can only be resolved as blocks.");return lJt();case"tableCell":if(i!=="block")throw new Oe("INVALID_TARGET","TableCell nodes can only be resolved as blocks.");return cJt(e);case"image":{const o=e.node?.attrs;return hJt(o,i,n,e.pos)}case"sdt":{const o=e.node?.attrs;return qMt(o,i)}case"tableOfContents":if(i!=="block")throw new Oe("INVALID_TARGET","TableOfContents nodes can only be resolved as blocks.");return uJt(e);case"hyperlink":if(!_A(e))throw new Oe("INVALID_TARGET","Hyperlink nodes can only be resolved inline.");return pJt(e);case"comment":if(!_A(e))throw new Oe("INVALID_TARGET","Comment nodes can only be resolved inline.");return mJt(e);case"run":if(!_A(e))throw new Oe("INVALID_TARGET","Run nodes can only be resolved inline.");return TJt(e);case"bookmark":if(!_A(e))throw new Oe("INVALID_TARGET","Bookmark nodes can only be resolved inline.");return gJt(e);case"footnoteRef":if(!_A(e))throw new Oe("INVALID_TARGET","Footnote references can only be resolved inline.");return yJt(e);case"tab":return IJt();case"lineBreak":return kJt();default:throw new Oe("INVALID_TARGET",`Node type "${r}" is not implemented yet.`)}}function WCe(e,t,n,r){if(n.kind==="block"){const o=Yf(t,n);return o?VCe(o,n.nodeType,e.state.doc):void 0}const i=ak(r??rg(e),n);if(i)return VCe(i,n.nodeType)}function EJt(e,t,n){const r=[];let i;for(const o of n){if(o.kind==="inline"){i??=rg(e);const a=WCe(e,t,o,i);a&&r.push(a);continue}const s=WCe(e,t,o);s&&r.push(s)}return r}var GCe=30,CJt=new Set(["sdt","image"]),_Jt=new Set(["paragraph","table","tableRow","tableCell","tableHeader","structuredContentBlock","sdt","image"]),RJt=new Set(["text","run","structuredContent","image","tab","lineBreak","hardBreak","hard_break","footnoteReference","bookmarkStart","bookmarkEnd","commentRangeStart","commentRangeEnd"]);function PJt(e){if(e)return ho(e.paraId)??ho(e.sdBlockId)??ho(e.blockId)??ho(e.id)??ho(e.uuid)}function LJt(e){return!!(e&&CJt.has(e))}function jCe(e,t,n){return n.kind==="block"?Yf(t,n)?.pos??Number.MAX_SAFE_INTEGER:ak(rg(e),n)?.pos??Number.MAX_SAFE_INTEGER}function NJt(e,t,n,r,i){const o=e.state.doc.content.size,s=Math.max(0,n-GCe),a=Math.min(o,r+GCe),l=e.state.doc.textBetween(s,a," ").replace(/ {2,}/g," "),c=e.state.doc.textBetween(s,n," "),u=e.state.doc.textBetween(n,r," "),d=c.replace(/ {2,}/g," "),f=u.replace(/ {2,}/g," ");return{address:t,snippet:l,highlightRange:{start:d.length,end:d.length+f.length},textRanges:i?.length?i:void 0}}function MJt(e,t,n){const r=t.pos+1,i=t.end-1;if(n.from<r||n.to>i)return;const o=e.state.doc.textBetween(r,n.from,`
325
325
  `,"").length,s=e.state.doc.textBetween(r,n.to,`
@@ -352,7 +352,7 @@ function print() { __p += __j.call(arguments, '') }
352
352
  `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}var Qmn=Pe((()=>{})),$mn=Pe((()=>{Qmn()})),OLe,egn=Pe((()=>{OLe={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"}}));function tgn(e,t){const n=t||{};return sY({file:n.file||void 0,location:!1,schema:n.space==="svg"?d3:u3,verbose:n.verbose||!1},e)}function sY(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},f3(e,r,n),n}case"#document":case"#document-fragment":{const r=t,i="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:FLe(e,t.childNodes),data:{quirksMode:i}},e.file&&e.location){const o=String(e.file),s=Zmn(o),a=s.toPoint(0),l=s.toPoint(o.length);n.position={start:a,end:l}}return n}case"#documentType":{const r=t;return n={type:"doctype"},f3(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},f3(e,r,n),n}default:return n=ngn(e,t),n}}function FLe(e,t){let n=-1;const r=[];for(;++n<t.length;){const i=sY(e,t[n]);r.push(i)}return r}function ngn(e,t){const n=e.schema;e.schema=t.namespaceURI===OLe.svg?d3:u3;let r=-1;const i={};for(;++r<t.attrs.length;){const s=t.attrs[r],a=(s.prefix?s.prefix+":":"")+s.name;aY.call(HLe,a)||(i[a]=s.value)}const o=(e.schema.space==="svg"?MLe:NLe)(t.tagName,i,FLe(e,t.childNodes));if(f3(e,t,o),o.tagName==="template"){const s=t,a=s.sourceCodeLocation,l=a&&a.startTag&&aS(a.startTag),c=a&&a.endTag&&aS(a.endTag),u=sY(e,s.content);l&&c&&e.file&&(u.position={start:l.end,end:c.start}),o.content=u}return e.schema=n,o}function f3(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=rgn(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function rgn(e,t,n){const r=aS(n);if(t.type==="element"){const i=t.children[t.children.length-1];if(r&&!n.endTag&&i&&i.position&&i.position.end&&(r.end=Object.assign({},i.position.end)),e.verbose){const o={};let s;if(n.attrs)for(s in n.attrs)aY.call(n.attrs,s)&&(o[ILe(e.schema,s).property]=aS(n.attrs[s]));n.startTag;const a=aS(n.startTag),l=n.endTag?aS(n.endTag):void 0,c={opening:a};l&&(c.closing=l),c.properties=o,t.data={position:c}}}return r}function aS(e){const t=BLe({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=BLe({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function BLe(e){return e.line&&e.column?e:void 0}var aY,HLe,ign=Pe((()=>{Iy(),Jmn(),rY(),$mn(),egn(),aY={}.hasOwnProperty,HLe=Object.prototype})),ogn=Pe((()=>{ign()}));function zLe(e){return e>=55296&&e<=57343}function sgn(e){return e>=56320&&e<=57343}function agn(e,t){return(e-55296)*1024+9216+t}function ULe(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function VLe(e){return e>=64976&&e<=65007||WLe.has(e)}var WLe,lgn,Ne,tc,lY=Pe((()=>{WLe=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),lgn="�",(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(Ne||(Ne={})),tc={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"}})),At,h3=Pe((()=>{(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(At||(At={}))})),GLe,jLe,cgn=Pe((()=>{lY(),h3(),GLe=65536,jLe=class{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=GLe,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){const{line:n,col:r,offset:i}=this,o=r+t,s=i+t;return{code:e,startLine:n,endLine:n,startCol:o,endCol:o,startOffset:s,endOffset:s}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){const t=this.html.charCodeAt(this.pos+1);if(sgn(t))return this.pos++,this._addGap(),agn(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Ne.EOF;return this._err(At.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let n=0;n<e.length;n++)if((this.html.charCodeAt(this.pos+n)|32)!==e.charCodeAt(n))return!1;return!0}peek(e){const t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ne.EOF;const n=this.html.charCodeAt(t);return n===Ne.CARRIAGE_RETURN?Ne.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ne.EOF;let e=this.html.charCodeAt(this.pos);return e===Ne.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Ne.LINE_FEED):e===Ne.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,zLe(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===Ne.LINE_FEED||e===Ne.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){ULe(e)?this._err(At.controlCharacterInInputStream):VLe(e)&&this._err(At.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}}));function qLe(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}var _i,cY=Pe((()=>{(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(_i||(_i={}))})),YLe,ugn=Pe((()=>{YLe=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0)))}));function dgn(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=KLe.get(e))!==null&&t!==void 0?t:e}var uY,KLe,fgn,hgn=Pe((()=>{KLe=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),fgn=(uY=String.fromCodePoint)!==null&&uY!==void 0?uY:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t}}));function dY(e){return e>=Ea.ZERO&&e<=Ea.NINE}function pgn(e){return e>=Ea.UPPER_A&&e<=Ea.UPPER_F||e>=Ea.LOWER_A&&e<=Ea.LOWER_F}function mgn(e){return e>=Ea.UPPER_A&&e<=Ea.UPPER_Z||e>=Ea.LOWER_A&&e<=Ea.LOWER_Z||dY(e)}function ggn(e){return e===Ea.EQUALS||mgn(e)}function ygn(e,t,n,r){const i=(t&Ng.BRANCH_LENGTH)>>7,o=t&Ng.JUMP_TABLE;if(i===0)return o!==0&&r===o?n:-1;if(o){const l=r-o;return l<0||l>=i?-1:e[n+l]-1}let s=n,a=s+i-1;for(;s<=a;){const l=s+a>>>1,c=e[l];if(c<r)s=l+1;else if(c>r)a=l-1;else return e[l+i]}return-1}var Ea,XLe,Ng,Ca,Dp,JLe,bgn=Pe((()=>{hgn(),ugn(),(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(Ea||(Ea={})),XLe=32,(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Ng||(Ng={})),(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(Ca||(Ca={})),(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Dp||(Dp={})),JLe=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=Ca.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Dp.Strict}startEntity(e){this.decodeMode=e,this.state=Ca.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case Ca.EntityStart:return e.charCodeAt(t)===Ea.NUM?(this.state=Ca.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=Ca.NamedEntity,this.stateNamedEntity(e,t));case Ca.NumericStart:return this.stateNumericStart(e,t);case Ca.NumericDecimal:return this.stateNumericDecimal(e,t);case Ca.NumericHex:return this.stateNumericHex(e,t);case Ca.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|XLe)===Ea.LOWER_X?(this.state=Ca.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=Ca.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){const i=n-t;this.result=this.result*Math.pow(r,i)+Number.parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){const n=t;for(;t<e.length;){const r=e.charCodeAt(t);if(dY(r)||pgn(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){const n=t;for(;t<e.length;){const r=e.charCodeAt(t);if(dY(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)===null||n===void 0||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===Ea.SEMI)this.consumed+=1;else if(this.decodeMode===Dp.Strict)return 0;return this.emitCodePoint(dgn(this.result),this.consumed),this.errors&&(e!==Ea.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){const{decodeTree:n}=this;let r=n[this.treeIndex],i=(r&Ng.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const o=e.charCodeAt(t);if(this.treeIndex=ygn(n,r,this.treeIndex+Math.max(1,i),o),this.treeIndex<0)return this.result===0||this.decodeMode===Dp.Attribute&&(i===0||ggn(o))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&Ng.VALUE_LENGTH)>>14,i!==0){if(o===Ea.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==Dp.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:t,decodeTree:n}=this,r=(n[t]&Ng.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)===null||e===void 0||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){const{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~Ng.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case Ca.NamedEntity:return this.result!==0&&(this.decodeMode!==Dp.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Ca.NumericDecimal:return this.emitNumericEntity(0,2);case Ca.NumericHex:return this.emitNumericEntity(0,3);case Ca.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Ca.EntityStart:return 0}}}}));function p3(e){var t;return(t=ZLe.get(e))!==null&&t!==void 0?t:W.UNKNOWN}var Ht,fb,Zu,dt,W,ZLe,Wt,QLe,m3,vgn,Mg=Pe((()=>{(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Ht||(Ht={})),(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(fb||(fb={})),(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Zu||(Zu={})),(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(dt||(dt={})),(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(W||(W={})),ZLe=new Map([[dt.A,W.A],[dt.ADDRESS,W.ADDRESS],[dt.ANNOTATION_XML,W.ANNOTATION_XML],[dt.APPLET,W.APPLET],[dt.AREA,W.AREA],[dt.ARTICLE,W.ARTICLE],[dt.ASIDE,W.ASIDE],[dt.B,W.B],[dt.BASE,W.BASE],[dt.BASEFONT,W.BASEFONT],[dt.BGSOUND,W.BGSOUND],[dt.BIG,W.BIG],[dt.BLOCKQUOTE,W.BLOCKQUOTE],[dt.BODY,W.BODY],[dt.BR,W.BR],[dt.BUTTON,W.BUTTON],[dt.CAPTION,W.CAPTION],[dt.CENTER,W.CENTER],[dt.CODE,W.CODE],[dt.COL,W.COL],[dt.COLGROUP,W.COLGROUP],[dt.DD,W.DD],[dt.DESC,W.DESC],[dt.DETAILS,W.DETAILS],[dt.DIALOG,W.DIALOG],[dt.DIR,W.DIR],[dt.DIV,W.DIV],[dt.DL,W.DL],[dt.DT,W.DT],[dt.EM,W.EM],[dt.EMBED,W.EMBED],[dt.FIELDSET,W.FIELDSET],[dt.FIGCAPTION,W.FIGCAPTION],[dt.FIGURE,W.FIGURE],[dt.FONT,W.FONT],[dt.FOOTER,W.FOOTER],[dt.FOREIGN_OBJECT,W.FOREIGN_OBJECT],[dt.FORM,W.FORM],[dt.FRAME,W.FRAME],[dt.FRAMESET,W.FRAMESET],[dt.H1,W.H1],[dt.H2,W.H2],[dt.H3,W.H3],[dt.H4,W.H4],[dt.H5,W.H5],[dt.H6,W.H6],[dt.HEAD,W.HEAD],[dt.HEADER,W.HEADER],[dt.HGROUP,W.HGROUP],[dt.HR,W.HR],[dt.HTML,W.HTML],[dt.I,W.I],[dt.IMG,W.IMG],[dt.IMAGE,W.IMAGE],[dt.INPUT,W.INPUT],[dt.IFRAME,W.IFRAME],[dt.KEYGEN,W.KEYGEN],[dt.LABEL,W.LABEL],[dt.LI,W.LI],[dt.LINK,W.LINK],[dt.LISTING,W.LISTING],[dt.MAIN,W.MAIN],[dt.MALIGNMARK,W.MALIGNMARK],[dt.MARQUEE,W.MARQUEE],[dt.MATH,W.MATH],[dt.MENU,W.MENU],[dt.META,W.META],[dt.MGLYPH,W.MGLYPH],[dt.MI,W.MI],[dt.MO,W.MO],[dt.MN,W.MN],[dt.MS,W.MS],[dt.MTEXT,W.MTEXT],[dt.NAV,W.NAV],[dt.NOBR,W.NOBR],[dt.NOFRAMES,W.NOFRAMES],[dt.NOEMBED,W.NOEMBED],[dt.NOSCRIPT,W.NOSCRIPT],[dt.OBJECT,W.OBJECT],[dt.OL,W.OL],[dt.OPTGROUP,W.OPTGROUP],[dt.OPTION,W.OPTION],[dt.P,W.P],[dt.PARAM,W.PARAM],[dt.PLAINTEXT,W.PLAINTEXT],[dt.PRE,W.PRE],[dt.RB,W.RB],[dt.RP,W.RP],[dt.RT,W.RT],[dt.RTC,W.RTC],[dt.RUBY,W.RUBY],[dt.S,W.S],[dt.SCRIPT,W.SCRIPT],[dt.SEARCH,W.SEARCH],[dt.SECTION,W.SECTION],[dt.SELECT,W.SELECT],[dt.SOURCE,W.SOURCE],[dt.SMALL,W.SMALL],[dt.SPAN,W.SPAN],[dt.STRIKE,W.STRIKE],[dt.STRONG,W.STRONG],[dt.STYLE,W.STYLE],[dt.SUB,W.SUB],[dt.SUMMARY,W.SUMMARY],[dt.SUP,W.SUP],[dt.TABLE,W.TABLE],[dt.TBODY,W.TBODY],[dt.TEMPLATE,W.TEMPLATE],[dt.TEXTAREA,W.TEXTAREA],[dt.TFOOT,W.TFOOT],[dt.TD,W.TD],[dt.TH,W.TH],[dt.THEAD,W.THEAD],[dt.TITLE,W.TITLE],[dt.TR,W.TR],[dt.TRACK,W.TRACK],[dt.TT,W.TT],[dt.U,W.U],[dt.UL,W.UL],[dt.SVG,W.SVG],[dt.VAR,W.VAR],[dt.WBR,W.WBR],[dt.XMP,W.XMP]]),Wt=W,QLe={[Ht.HTML]:new Set([Wt.ADDRESS,Wt.APPLET,Wt.AREA,Wt.ARTICLE,Wt.ASIDE,Wt.BASE,Wt.BASEFONT,Wt.BGSOUND,Wt.BLOCKQUOTE,Wt.BODY,Wt.BR,Wt.BUTTON,Wt.CAPTION,Wt.CENTER,Wt.COL,Wt.COLGROUP,Wt.DD,Wt.DETAILS,Wt.DIR,Wt.DIV,Wt.DL,Wt.DT,Wt.EMBED,Wt.FIELDSET,Wt.FIGCAPTION,Wt.FIGURE,Wt.FOOTER,Wt.FORM,Wt.FRAME,Wt.FRAMESET,Wt.H1,Wt.H2,Wt.H3,Wt.H4,Wt.H5,Wt.H6,Wt.HEAD,Wt.HEADER,Wt.HGROUP,Wt.HR,Wt.HTML,Wt.IFRAME,Wt.IMG,Wt.INPUT,Wt.LI,Wt.LINK,Wt.LISTING,Wt.MAIN,Wt.MARQUEE,Wt.MENU,Wt.META,Wt.NAV,Wt.NOEMBED,Wt.NOFRAMES,Wt.NOSCRIPT,Wt.OBJECT,Wt.OL,Wt.P,Wt.PARAM,Wt.PLAINTEXT,Wt.PRE,Wt.SCRIPT,Wt.SECTION,Wt.SELECT,Wt.SOURCE,Wt.STYLE,Wt.SUMMARY,Wt.TABLE,Wt.TBODY,Wt.TD,Wt.TEMPLATE,Wt.TEXTAREA,Wt.TFOOT,Wt.TH,Wt.THEAD,Wt.TITLE,Wt.TR,Wt.TRACK,Wt.UL,Wt.WBR,Wt.XMP]),[Ht.MATHML]:new Set([Wt.MI,Wt.MO,Wt.MN,Wt.MS,Wt.MTEXT,Wt.ANNOTATION_XML]),[Ht.SVG]:new Set([Wt.TITLE,Wt.FOREIGN_OBJECT,Wt.DESC]),[Ht.XLINK]:new Set,[Ht.XML]:new Set,[Ht.XMLNS]:new Set},m3=new Set([Wt.H1,Wt.H2,Wt.H3,Wt.H4,Wt.H5,Wt.H6]),vgn=new Set([dt.STYLE,dt.SCRIPT,dt.XMP,dt.IFRAME,dt.NOEMBED,dt.NOFRAMES,dt.PLAINTEXT])}));function wgn(e){return e>=Ne.DIGIT_0&&e<=Ne.DIGIT_9}function NE(e){return e>=Ne.LATIN_CAPITAL_A&&e<=Ne.LATIN_CAPITAL_Z}function Agn(e){return e>=Ne.LATIN_SMALL_A&&e<=Ne.LATIN_SMALL_Z}function Dg(e){return Agn(e)||NE(e)}function $Le(e){return Dg(e)||wgn(e)}function g3(e){return e+32}function eNe(e){return e===Ne.SPACE||e===Ne.LINE_FEED||e===Ne.TABULATION||e===Ne.FORM_FEED}function tNe(e){return eNe(e)||e===Ne.SOLIDUS||e===Ne.GREATER_THAN_SIGN}function Sgn(e){return e===Ne.NULL?At.nullCharacterReference:e>1114111?At.characterReferenceOutsideUnicodeRange:zLe(e)?At.surrogateCharacterReference:VLe(e)?At.noncharacterCharacterReference:ULe(e)||e===Ne.CARRIAGE_RETURN?At.controlCharacterReference:null}var Be,nc,nNe,rNe=Pe((()=>{cgn(),lY(),cY(),bgn(),h3(),Mg(),(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(Be||(Be={})),nc={DATA:Be.DATA,RCDATA:Be.RCDATA,RAWTEXT:Be.RAWTEXT,SCRIPT_DATA:Be.SCRIPT_DATA,PLAINTEXT:Be.PLAINTEXT,CDATA_SECTION:Be.CDATA_SECTION},nNe=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=Be.DATA,this.returnState=Be.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new jLe(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new JLe(YLe,(n,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(n)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(At.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(At.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const r=Sgn(n);r&&this._err(r,1)}}:void 0)}_err(e,t=0){var n,r;(r=(n=this.handler).onParseError)===null||r===void 0||r.call(n,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e?.())}write(e,t,n){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||n?.()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:_i.START_TAG,tagName:"",tagID:W.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:_i.END_TAG,tagName:"",tagID:W.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:_i.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:_i.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e,t;const n=this.currentToken;if(qLe(n,this.currentAttr.name)===null){if(n.attrs.push(this.currentAttr),n.location&&this.currentLocation){const r=(e=(t=n.location).attrs)!==null&&e!==void 0?e:t.attrs=Object.create(null);r[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(At.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const e=this.currentToken;this.prepareToken(e),e.tagID=p3(e.tagName),e.type===_i.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(At.endTagWithAttributes),e.selfClosing&&this._err(At.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case _i.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case _i.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case _i.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}this.currentCharacterToken=null}}_emitEOFToken(){const e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:_i.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken)if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(e,t)}_emitCodePoint(e){const t=eNe(e)?_i.WHITESPACE_CHARACTER:e===Ne.NULL?_i.NULL_CHARACTER:_i.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(_i.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=Be.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Dp.Attribute:Dp.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===Be.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===Be.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===Be.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case Be.DATA:this._stateData(e);break;case Be.RCDATA:this._stateRcdata(e);break;case Be.RAWTEXT:this._stateRawtext(e);break;case Be.SCRIPT_DATA:this._stateScriptData(e);break;case Be.PLAINTEXT:this._statePlaintext(e);break;case Be.TAG_OPEN:this._stateTagOpen(e);break;case Be.END_TAG_OPEN:this._stateEndTagOpen(e);break;case Be.TAG_NAME:this._stateTagName(e);break;case Be.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case Be.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case Be.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case Be.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case Be.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case Be.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case Be.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case Be.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case Be.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case Be.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case Be.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case Be.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case Be.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case Be.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case Be.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case Be.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case Be.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case Be.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case Be.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case Be.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case Be.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case Be.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case Be.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case Be.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case Be.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case Be.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case Be.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case Be.BOGUS_COMMENT:this._stateBogusComment(e);break;case Be.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case Be.COMMENT_START:this._stateCommentStart(e);break;case Be.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case Be.COMMENT:this._stateComment(e);break;case Be.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case Be.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case Be.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case Be.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case Be.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case Be.COMMENT_END:this._stateCommentEnd(e);break;case Be.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case Be.DOCTYPE:this._stateDoctype(e);break;case Be.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case Be.DOCTYPE_NAME:this._stateDoctypeName(e);break;case Be.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case Be.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case Be.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case Be.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case Be.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case Be.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case Be.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case Be.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case Be.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case Be.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case Be.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case Be.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case Be.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case Be.CDATA_SECTION:this._stateCdataSection(e);break;case Be.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case Be.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case Be.CHARACTER_REFERENCE:this._stateCharacterReference();break;case Be.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw new Error("Unknown state")}}_stateData(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=Be.TAG_OPEN;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitCodePoint(e);break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.LESS_THAN_SIGN:this.state=Be.RCDATA_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=Be.RAWTEXT_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(Dg(e))this._createStartTagToken(),this.state=Be.TAG_NAME,this._stateTagName(e);else switch(e){case Ne.EXCLAMATION_MARK:this.state=Be.MARKUP_DECLARATION_OPEN;break;case Ne.SOLIDUS:this.state=Be.END_TAG_OPEN;break;case Ne.QUESTION_MARK:this._err(At.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=Be.BOGUS_COMMENT,this._stateBogusComment(e);break;case Ne.EOF:this._err(At.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(At.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=Be.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(Dg(e))this._createEndTagToken(),this.state=Be.TAG_NAME,this._stateTagName(e);else switch(e){case Ne.GREATER_THAN_SIGN:this._err(At.missingEndTagName),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break;default:this._err(At.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=Be.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.BEFORE_ATTRIBUTE_NAME;break;case Ne.SOLIDUS:this.state=Be.SELF_CLOSING_START_TAG;break;case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentTagToken();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.tagName+="�";break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(NE(e)?g3(e):e)}}_stateRcdataLessThanSign(e){e===Ne.SOLIDUS?this.state=Be.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=Be.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){Dg(e)?(this.state=Be.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=Be.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=Be.BEFORE_ATTRIBUTE_NAME,!1;case Ne.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=Be.SELF_CLOSING_START_TAG,!1;case Ne.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=Be.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Be.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===Ne.SOLIDUS?this.state=Be.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=Be.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){Dg(e)?(this.state=Be.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=Be.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Be.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case Ne.SOLIDUS:this.state=Be.SCRIPT_DATA_END_TAG_OPEN;break;case Ne.EXCLAMATION_MARK:this.state=Be.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break;default:this._emitChars("<"),this.state=Be.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){Dg(e)?(this.state=Be.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=Be.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Be.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===Ne.HYPHEN_MINUS?(this.state=Be.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=Be.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===Ne.HYPHEN_MINUS?(this.state=Be.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=Be.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case Ne.HYPHEN_MINUS:this.state=Be.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case Ne.HYPHEN_MINUS:this.state=Be.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.state=Be.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Be.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case Ne.HYPHEN_MINUS:this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Ne.GREATER_THAN_SIGN:this.state=Be.SCRIPT_DATA,this._emitChars(">");break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.state=Be.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Be.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===Ne.SOLIDUS?this.state=Be.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Dg(e)?(this._emitChars("<"),this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=Be.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){Dg(e)?(this.state=Be.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=Be.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Be.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(tc.SCRIPT,!1)&&tNe(this.preprocessor.peek(tc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<tc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=Be.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case Ne.HYPHEN_MINUS:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case Ne.HYPHEN_MINUS:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case Ne.HYPHEN_MINUS:this._emitChars("-");break;case Ne.LESS_THAN_SIGN:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Ne.GREATER_THAN_SIGN:this.state=Be.SCRIPT_DATA,this._emitChars(">");break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Ne.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===Ne.SOLIDUS?(this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(tc.SCRIPT,!1)&&tNe(this.preprocessor.peek(tc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<tc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=Be.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=Be.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.SOLIDUS:case Ne.GREATER_THAN_SIGN:case Ne.EOF:this.state=Be.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Ne.EQUALS_SIGN:this._err(At.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=Be.ATTRIBUTE_NAME;break;default:this._createAttr(""),this.state=Be.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:case Ne.SOLIDUS:case Ne.GREATER_THAN_SIGN:case Ne.EOF:this._leaveAttrName(),this.state=Be.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Ne.EQUALS_SIGN:this._leaveAttrName(),this.state=Be.BEFORE_ATTRIBUTE_VALUE;break;case Ne.QUOTATION_MARK:case Ne.APOSTROPHE:case Ne.LESS_THAN_SIGN:this._err(At.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.name+="�";break;default:this.currentAttr.name+=String.fromCodePoint(NE(e)?g3(e):e)}}_stateAfterAttributeName(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.SOLIDUS:this.state=Be.SELF_CLOSING_START_TAG;break;case Ne.EQUALS_SIGN:this.state=Be.BEFORE_ATTRIBUTE_VALUE;break;case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentTagToken();break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._createAttr(""),this.state=Be.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:this.state=Be.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this.state=Be.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(At.missingAttributeValue),this.state=Be.DATA,this.emitCurrentTagToken();break;default:this.state=Be.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case Ne.QUOTATION_MARK:this.state=Be.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case Ne.APOSTROPHE:this.state=Be.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this._leaveAttrValue(),this.state=Be.BEFORE_ATTRIBUTE_NAME;break;case Ne.AMPERSAND:this._startCharacterReference();break;case Ne.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Be.DATA,this.emitCurrentTagToken();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Ne.QUOTATION_MARK:case Ne.APOSTROPHE:case Ne.LESS_THAN_SIGN:case Ne.EQUALS_SIGN:case Ne.GRAVE_ACCENT:this._err(At.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this._leaveAttrValue(),this.state=Be.BEFORE_ATTRIBUTE_NAME;break;case Ne.SOLIDUS:this._leaveAttrValue(),this.state=Be.SELF_CLOSING_START_TAG;break;case Ne.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Be.DATA,this.emitCurrentTagToken();break;case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._err(At.missingWhitespaceBetweenAttributes),this.state=Be.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case Ne.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=Be.DATA,this.emitCurrentTagToken();break}case Ne.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._err(At.unexpectedSolidusInTag),this.state=Be.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.data+="�";break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(tc.DASH_DASH,!0)?(this._createCommentToken(tc.DASH_DASH.length+1),this.state=Be.COMMENT_START):this._consumeSequenceIfMatch(tc.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(tc.DOCTYPE.length+1),this.state=Be.DOCTYPE):this._consumeSequenceIfMatch(tc.CDATA_START,!0)?this.inForeignNode?this.state=Be.CDATA_SECTION:(this._err(At.cdataInHtmlContent),this._createCommentToken(tc.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=Be.BOGUS_COMMENT):this._ensureHibernation()||(this._err(At.incorrectlyOpenedComment),this._createCommentToken(2),this.state=Be.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case Ne.HYPHEN_MINUS:this.state=Be.COMMENT_START_DASH;break;case Ne.GREATER_THAN_SIGN:{this._err(At.abruptClosingOfEmptyComment),this.state=Be.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=Be.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=Be.COMMENT_END;break;case Ne.GREATER_THAN_SIGN:this._err(At.abruptClosingOfEmptyComment),this.state=Be.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=Be.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=Be.COMMENT_END_DASH;break;case Ne.LESS_THAN_SIGN:t.data+="<",this.state=Be.COMMENT_LESS_THAN_SIGN;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.data+="�";break;case Ne.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case Ne.EXCLAMATION_MARK:t.data+="!",this.state=Be.COMMENT_LESS_THAN_SIGN_BANG;break;case Ne.LESS_THAN_SIGN:t.data+="<";break;default:this.state=Be.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===Ne.HYPHEN_MINUS?this.state=Be.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=Be.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===Ne.HYPHEN_MINUS?this.state=Be.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=Be.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==Ne.GREATER_THAN_SIGN&&e!==Ne.EOF&&this._err(At.nestedComment),this.state=Be.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:this.state=Be.COMMENT_END;break;case Ne.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=Be.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentComment(t);break;case Ne.EXCLAMATION_MARK:this.state=Be.COMMENT_END_BANG;break;case Ne.HYPHEN_MINUS:t.data+="-";break;case Ne.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--",this.state=Be.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case Ne.HYPHEN_MINUS:t.data+="--!",this.state=Be.COMMENT_END_DASH;break;case Ne.GREATER_THAN_SIGN:this._err(At.incorrectlyClosedComment),this.state=Be.DATA,this.emitCurrentComment(t);break;case Ne.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--!",this.state=Be.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.BEFORE_DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:this.state=Be.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case Ne.EOF:{this._err(At.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(At.missingWhitespaceBeforeDoctypeName),this.state=Be.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(NE(e))this._createDoctypeToken(String.fromCharCode(g3(e))),this.state=Be.DOCTYPE_NAME;else switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.NULL:this._err(At.unexpectedNullCharacter),this._createDoctypeToken("�"),this.state=Be.DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:{this._err(At.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Be.DATA;break}case Ne.EOF:{this._err(At.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=Be.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.AFTER_DOCTYPE_NAME;break;case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.name+="�";break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(NE(e)?g3(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(tc.PUBLIC,!1)?this.state=Be.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(tc.SYSTEM,!1)?this.state=Be.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(At.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.QUOTATION_MARK:this._err(At.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=Be.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(At.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=Be.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(At.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:t.publicId="",this.state=Be.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.publicId="",this.state=Be.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(At.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Ne.QUOTATION_MARK:this.state=Be.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.publicId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(At.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Ne.APOSTROPHE:this.state=Be.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.publicId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(At.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case Ne.GREATER_THAN_SIGN:this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.QUOTATION_MARK:this._err(At.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(At.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.QUOTATION_MARK:t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:this.state=Be.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.QUOTATION_MARK:this._err(At.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:this._err(At.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(At.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.QUOTATION_MARK:t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Ne.APOSTROPHE:t.systemId="",this.state=Be.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Ne.GREATER_THAN_SIGN:this._err(At.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.DATA,this.emitCurrentDoctype(t);break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Ne.QUOTATION_MARK:this.state=Be.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.systemId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(At.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Ne.APOSTROPHE:this.state=Be.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Ne.NULL:this._err(At.unexpectedNullCharacter),t.systemId+="�";break;case Ne.GREATER_THAN_SIGN:this._err(At.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Ne.SPACE:case Ne.LINE_FEED:case Ne.TABULATION:case Ne.FORM_FEED:break;case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=Be.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case Ne.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Be.DATA;break;case Ne.NULL:this._err(At.unexpectedNullCharacter);break;case Ne.EOF:this.emitCurrentDoctype(t),this._emitEOFToken();break;default:}}_stateCdataSection(e){switch(e){case Ne.RIGHT_SQUARE_BRACKET:this.state=Be.CDATA_SECTION_BRACKET;break;case Ne.EOF:this._err(At.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===Ne.RIGHT_SQUARE_BRACKET?this.state=Be.CDATA_SECTION_END:(this._emitChars("]"),this.state=Be.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case Ne.GREATER_THAN_SIGN:this.state=Be.DATA;break;case Ne.RIGHT_SQUARE_BRACKET:this._emitChars("]");break;default:this._emitChars("]]"),this.state=Be.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0)if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(Ne.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&$Le(this.preprocessor.peek(1))?Be.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){$Le(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===Ne.SEMICOLON&&this._err(At.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}}})),fY,hY,ME,iNe,oNe,pY,mY,sNe,aNe,lNe,cNe,uNe,xgn=Pe((()=>{Mg(),fY=new Set([W.DD,W.DT,W.LI,W.OPTGROUP,W.OPTION,W.P,W.RB,W.RP,W.RT,W.RTC]),hY=new Set([...fY,W.CAPTION,W.COLGROUP,W.TBODY,W.TD,W.TFOOT,W.TH,W.THEAD,W.TR]),ME=new Set([W.APPLET,W.CAPTION,W.HTML,W.MARQUEE,W.OBJECT,W.TABLE,W.TD,W.TEMPLATE,W.TH]),iNe=new Set([...ME,W.OL,W.UL]),oNe=new Set([...ME,W.BUTTON]),pY=new Set([W.ANNOTATION_XML,W.MI,W.MN,W.MO,W.MS,W.MTEXT]),mY=new Set([W.DESC,W.FOREIGN_OBJECT,W.TITLE]),sNe=new Set([W.TR,W.TEMPLATE,W.HTML]),aNe=new Set([W.TBODY,W.TFOOT,W.THEAD,W.TEMPLATE,W.HTML]),lNe=new Set([W.TABLE,W.TEMPLATE,W.HTML]),cNe=new Set([W.TD,W.TH]),uNe=class{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=W.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===W.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Ht.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){const r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==Ht.HTML);this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){const t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(n,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(m3,Ht.HTML)}popUntilTableCellPopped(){this.popUntilPopped(cNe,Ht.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let n=this.stackTop;n>=0;n--)if(e.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(lNe,Ht.HTML)}clearBackToTableBodyContext(){this.clearBackTo(aNe,Ht.HTML)}clearBackToTableRowContext(){this.clearBackTo(sNe,Ht.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===W.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===W.HTML}hasInDynamicScope(e,t){for(let n=this.stackTop;n>=0;n--){const r=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case Ht.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case Ht.SVG:if(mY.has(r))return!1;break;case Ht.MATHML:if(pY.has(r))return!1;break}}return!0}hasInScope(e){return this.hasInDynamicScope(e,ME)}hasInListItemScope(e){return this.hasInDynamicScope(e,iNe)}hasInButtonScope(e){return this.hasInDynamicScope(e,oNe)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case Ht.HTML:if(m3.has(t))return!0;if(ME.has(t))return!1;break;case Ht.SVG:if(mY.has(t))return!1;break;case Ht.MATHML:if(pY.has(t))return!1;break}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ht.HTML)switch(this.tagIDs[t]){case e:return!0;case W.TABLE:case W.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===Ht.HTML)switch(this.tagIDs[e]){case W.TBODY:case W.THEAD:case W.TFOOT:return!0;case W.TABLE:case W.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ht.HTML)switch(this.tagIDs[t]){case e:return!0;case W.OPTION:case W.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&fY.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&hY.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&hY.has(this.currentTagId);)this.pop()}}})),y3,hh,gY,dNe,Tgn=Pe((()=>{y3=3,(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(hh||(hh={})),gY={type:hh.Marker},dNe=class{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const n=[],r=t.length,i=this.treeAdapter.getTagName(e),o=this.treeAdapter.getNamespaceURI(e);for(let s=0;s<this.entries.length;s++){const a=this.entries[s];if(a.type===hh.Marker)break;const{element:l}=a;if(this.treeAdapter.getTagName(l)===i&&this.treeAdapter.getNamespaceURI(l)===o){const c=this.treeAdapter.getAttrList(l);c.length===r&&n.push({idx:s,attrs:c})}}return n}_ensureNoahArkCondition(e){if(this.entries.length<y3)return;const t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<y3)return;const r=new Map(t.map(o=>[o.name,o.value]));let i=0;for(let o=0;o<n.length;o++){const s=n[o];s.attrs.every(a=>r.get(a.name)===a.value)&&(i+=1,i>=y3&&this.entries.splice(s.idx,1))}}insertMarker(){this.entries.unshift(gY)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:hh.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:hh.Element,element:e,token:t})}removeEntry(e){const t=this.entries.indexOf(e);t!==-1&&this.entries.splice(t,1)}clearToLastMarker(){const e=this.entries.indexOf(gY);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){const t=this.entries.find(n=>n.type===hh.Marker||this.treeAdapter.getTagName(n.element)===e);return t&&t.type===hh.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===hh.Element&&t.element===e)}}})),Op,yY=Pe((()=>{Mg(),Op={createDocument(){return{nodeName:"#document",mode:Zu.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,r){const i=e.childNodes.find(o=>o.nodeName==="#documentType");if(i)i.name=t,i.publicId=n,i.systemId=r;else{const o={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};Op.appendChild(e,o)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(Op.isTextNode(n)){n.value+=t;return}}Op.appendChild(e,Op.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&Op.isTextNode(r)?r.value+=t:Op.insertBefore(e,Op.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(r=>r.name));for(let r=0;r<t.length;r++)n.has(t[r].name)||e.attrs.push(t[r])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}}}));function fNe(e,t){return t.some(n=>e.startsWith(n))}function Ign(e){return e.name===bY&&e.publicId===null&&(e.systemId===null||e.systemId===hNe)}function kgn(e){if(e.name!==bY)return Zu.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===pNe)return Zu.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),gNe.has(n))return Zu.QUIRKS;let r=t===null?mNe:vY;if(fNe(n,r))return Zu.QUIRKS;if(r=t===null?wY:yNe,fNe(n,r))return Zu.LIMITED_QUIRKS}return Zu.NO_QUIRKS}var bY,hNe,pNe,vY,mNe,gNe,wY,yNe,Egn=Pe((()=>{Mg(),bY="html",hNe="about:legacy-compat",pNe="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",vY=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],mNe=[...vY,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],gNe=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),wY=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],yNe=[...wY,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"]}));function Cgn(e){const t=e.tagID;return t===W.FONT&&e.attrs.some(({name:n})=>n===fb.COLOR||n===fb.SIZE||n===fb.FACE)||INe.has(t)}function bNe(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===wNe){e.attrs[t].name=ANe;break}}function vNe(e){for(let t=0;t<e.attrs.length;t++){const n=SNe.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function AY(e){for(let t=0;t<e.attrs.length;t++){const n=xNe.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function _gn(e){const t=TNe.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=p3(e.tagName))}function Rgn(e,t){return t===Ht.MATHML&&(e===W.MI||e===W.MO||e===W.MN||e===W.MS||e===W.MTEXT)}function Pgn(e,t,n){if(t===Ht.MATHML&&e===W.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===fb.ENCODING){const i=n[r].value.toLowerCase();return i===SY.TEXT_HTML||i===SY.APPLICATION_XML}}return t===Ht.SVG&&(e===W.FOREIGN_OBJECT||e===W.DESC||e===W.TITLE)}function Lgn(e,t,n,r){return(!r||r===Ht.HTML)&&Pgn(e,t,n)||(!r||r===Ht.MATHML)&&Rgn(e,t)}var SY,wNe,ANe,SNe,xNe,TNe,INe,kNe=Pe((()=>{Mg(),SY={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},wNe="definitionurl",ANe="definitionURL",SNe=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),xNe=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Ht.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Ht.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Ht.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Ht.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Ht.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Ht.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Ht.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Ht.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Ht.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Ht.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Ht.XMLNS}]]),TNe=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),INe=new Set([W.B,W.BIG,W.BLOCKQUOTE,W.BODY,W.BR,W.CENTER,W.CODE,W.DD,W.DIV,W.DL,W.DT,W.EM,W.EMBED,W.H1,W.H2,W.H3,W.H4,W.H5,W.H6,W.HEAD,W.HR,W.I,W.IMG,W.LI,W.LISTING,W.MENU,W.META,W.NOBR,W.OL,W.P,W.PRE,W.RUBY,W.S,W.SMALL,W.SPAN,W.STRONG,W.STRIKE,W.SUB,W.SUP,W.TABLE,W.TT,W.U,W.UL,W.VAR])}));function Ngn(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):NNe(e,t),n}function Mgn(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const i=e.openElements.items[r];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[r])&&(n=i)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function Dgn(e,t,n){let r=t,i=e.openElements.getCommonAncestor(t);for(let o=0,s=i;s!==n;o++,s=i){i=e.openElements.getCommonAncestor(s);const a=e.activeFormattingElements.getElementEntry(s),l=a&&o>=jNe;!a||l?(l&&e.activeFormattingElements.removeEntry(a),e.openElements.remove(s)):(s=Ogn(e,a),r===t&&(e.activeFormattingElements.bookmark=a),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(s,r),r=s)}return r}function Ogn(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function Fgn(e,t,n){const r=p3(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);r===W.TEMPLATE&&i===Ht.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function Bgn(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:i}=n,o=e.treeAdapter.createElement(i.tagName,r,i.attrs);e._adoptNodes(t,o),e.treeAdapter.appendChild(t,o),e.activeFormattingElements.insertElementAfterBookmark(o,i),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,o,i.tagID)}function xY(e,t){for(let n=0;n<GNe;n++){const r=Ngn(e,t);if(!r)break;const i=Mgn(e,r);if(!i)break;e.activeFormattingElements.bookmark=r;const o=Dgn(e,i,r.element),s=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(o),s&&Fgn(e,s,o),Bgn(e,i,r)}}function TY(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function Hgn(e,t){e._appendCommentNode(t,e.openElements.items[0])}function zgn(e,t){e._appendCommentNode(t,e.document)}function IY(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const r=e.openElements.items[0],i=e.treeAdapter.getNodeSourceCodeLocation(r);if(i&&!i.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const o=e.openElements.items[1],s=e.treeAdapter.getNodeSourceCodeLocation(o);s&&!s.endTag&&e._setEndLocation(o,t)}}}}function Ugn(e,t){e._setDocumentType(t);const n=t.forceQuirks?Zu.QUIRKS:kgn(t);Ign(t)||e._err(t,At.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=Ye.BEFORE_HTML}function DE(e,t){e._err(t,At.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Zu.QUIRKS),e.insertionMode=Ye.BEFORE_HTML,e._processToken(t)}function Vgn(e,t){t.tagID===W.HTML?(e._insertElement(t,Ht.HTML),e.insertionMode=Ye.BEFORE_HEAD):OE(e,t)}function Wgn(e,t){const n=t.tagID;(n===W.HTML||n===W.HEAD||n===W.BODY||n===W.BR)&&OE(e,t)}function OE(e,t){e._insertFakeRootElement(),e.insertionMode=Ye.BEFORE_HEAD,e._processToken(t)}function Ggn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.HEAD:e._insertElement(t,Ht.HTML),e.headElement=e.openElements.current,e.insertionMode=Ye.IN_HEAD;break;default:FE(e,t)}}function jgn(e,t){const n=t.tagID;n===W.HEAD||n===W.BODY||n===W.HTML||n===W.BR?FE(e,t):e._err(t,At.endTagWithoutMatchingOpenElement)}function FE(e,t){e._insertFakeElement(dt.HEAD,W.HEAD),e.headElement=e.openElements.current,e.insertionMode=Ye.IN_HEAD,e._processToken(t)}function ef(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.TITLE:e._switchToTextParsing(t,nc.RCDATA);break;case W.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,nc.RAWTEXT):(e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_HEAD_NO_SCRIPT);break;case W.NOFRAMES:case W.STYLE:e._switchToTextParsing(t,nc.RAWTEXT);break;case W.SCRIPT:e._switchToTextParsing(t,nc.SCRIPT_DATA);break;case W.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Ye.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Ye.IN_TEMPLATE);break;case W.HEAD:e._err(t,At.misplacedStartTagForHeadElement);break;default:BE(e,t)}}function qgn(e,t){switch(t.tagID){case W.HEAD:e.openElements.pop(),e.insertionMode=Ye.AFTER_HEAD;break;case W.BODY:case W.BR:case W.HTML:BE(e,t);break;case W.TEMPLATE:hb(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function hb(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==W.TEMPLATE&&e._err(t,At.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(W.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,At.endTagWithoutMatchingOpenElement)}function BE(e,t){e.openElements.pop(),e.insertionMode=Ye.AFTER_HEAD,e._processToken(t)}function Ygn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.BASEFONT:case W.BGSOUND:case W.HEAD:case W.LINK:case W.META:case W.NOFRAMES:case W.STYLE:ef(e,t);break;case W.NOSCRIPT:e._err(t,At.nestedNoscriptInHead);break;default:HE(e,t)}}function Kgn(e,t){switch(t.tagID){case W.NOSCRIPT:e.openElements.pop(),e.insertionMode=Ye.IN_HEAD;break;case W.BR:HE(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function HE(e,t){const n=t.type===_i.EOF?At.openElementsLeftAfterEof:At.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=Ye.IN_HEAD,e._processToken(t)}function Xgn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.BODY:e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=Ye.IN_BODY;break;case W.FRAMESET:e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_FRAMESET;break;case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:case W.NOFRAMES:case W.SCRIPT:case W.STYLE:case W.TEMPLATE:case W.TITLE:e._err(t,At.abandonedHeadElementChild),e.openElements.push(e.headElement,W.HEAD),ef(e,t),e.openElements.remove(e.headElement);break;case W.HEAD:e._err(t,At.misplacedStartTagForHeadElement);break;default:zE(e,t)}}function Jgn(e,t){switch(t.tagID){case W.BODY:case W.HTML:case W.BR:zE(e,t);break;case W.TEMPLATE:hb(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function zE(e,t){e._insertFakeElement(dt.BODY,W.BODY),e.insertionMode=Ye.IN_BODY,b3(e,t)}function b3(e,t){switch(t.type){case _i.CHARACTER:CNe(e,t);break;case _i.WHITESPACE_CHARACTER:ENe(e,t);break;case _i.COMMENT:TY(e,t);break;case _i.START_TAG:Al(e,t);break;case _i.END_TAG:v3(e,t);break;case _i.EOF:MNe(e,t);break;default:}}function ENe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function CNe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Zgn(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Qgn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function $gn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_FRAMESET)}function e0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML)}function t0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&m3.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Ht.HTML)}function n0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function r0n(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),n||(e.formElement=e.openElements.current))}function i0n(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const i=e.openElements.tagIDs[r];if(n===W.LI&&i===W.LI||(n===W.DD||n===W.DT)&&(i===W.DD||i===W.DT)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i);break}if(i!==W.ADDRESS&&i!==W.DIV&&i!==W.P&&e._isSpecialElement(e.openElements.items[r],i))break}e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML)}function o0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.tokenizer.state=nc.PLAINTEXT}function s0n(e,t){e.openElements.hasInScope(W.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.framesetOk=!1}function a0n(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(dt.A);n&&(xY(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function l0n(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function c0n(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(W.NOBR)&&(xY(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function u0n(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function d0n(e,t){e.treeAdapter.getDocumentMode(e.document)!==Zu.QUIRKS&&e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=Ye.IN_TABLE}function _Ne(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ht.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function RNe(e){const t=qLe(e,fb.TYPE);return t!=null&&t.toLowerCase()===WNe}function f0n(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ht.HTML),RNe(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function h0n(e,t){e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0}function p0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._appendElement(t,Ht.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function m0n(e,t){t.tagName=dt.IMG,t.tagID=W.IMG,_Ne(e,t)}function g0n(e,t){e._insertElement(t,Ht.HTML),e.skipNextNewLine=!0,e.tokenizer.state=nc.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Ye.TEXT}function y0n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,nc.RAWTEXT)}function b0n(e,t){e.framesetOk=!1,e._switchToTextParsing(t,nc.RAWTEXT)}function PNe(e,t){e._switchToTextParsing(t,nc.RAWTEXT)}function v0n(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Ye.IN_TABLE||e.insertionMode===Ye.IN_CAPTION||e.insertionMode===Ye.IN_TABLE_BODY||e.insertionMode===Ye.IN_ROW||e.insertionMode===Ye.IN_CELL?Ye.IN_SELECT_IN_TABLE:Ye.IN_SELECT}function w0n(e,t){e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML)}function A0n(e,t){e.openElements.hasInScope(W.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Ht.HTML)}function S0n(e,t){e.openElements.hasInScope(W.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(W.RTC),e._insertElement(t,Ht.HTML)}function x0n(e,t){e._reconstructActiveFormattingElements(),bNe(t),AY(t),t.selfClosing?e._appendElement(t,Ht.MATHML):e._insertElement(t,Ht.MATHML),t.ackSelfClosing=!0}function T0n(e,t){e._reconstructActiveFormattingElements(),vNe(t),AY(t),t.selfClosing?e._appendElement(t,Ht.SVG):e._insertElement(t,Ht.SVG),t.ackSelfClosing=!0}function LNe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML)}function Al(e,t){switch(t.tagID){case W.I:case W.S:case W.B:case W.U:case W.EM:case W.TT:case W.BIG:case W.CODE:case W.FONT:case W.SMALL:case W.STRIKE:case W.STRONG:l0n(e,t);break;case W.A:a0n(e,t);break;case W.H1:case W.H2:case W.H3:case W.H4:case W.H5:case W.H6:t0n(e,t);break;case W.P:case W.DL:case W.OL:case W.UL:case W.DIV:case W.DIR:case W.NAV:case W.MAIN:case W.MENU:case W.ASIDE:case W.CENTER:case W.FIGURE:case W.FOOTER:case W.HEADER:case W.HGROUP:case W.DIALOG:case W.DETAILS:case W.ADDRESS:case W.ARTICLE:case W.SEARCH:case W.SECTION:case W.SUMMARY:case W.FIELDSET:case W.BLOCKQUOTE:case W.FIGCAPTION:e0n(e,t);break;case W.LI:case W.DD:case W.DT:i0n(e,t);break;case W.BR:case W.IMG:case W.WBR:case W.AREA:case W.EMBED:case W.KEYGEN:_Ne(e,t);break;case W.HR:p0n(e,t);break;case W.RB:case W.RTC:A0n(e,t);break;case W.RT:case W.RP:S0n(e,t);break;case W.PRE:case W.LISTING:n0n(e,t);break;case W.XMP:y0n(e,t);break;case W.SVG:T0n(e,t);break;case W.HTML:Zgn(e,t);break;case W.BASE:case W.LINK:case W.META:case W.STYLE:case W.TITLE:case W.SCRIPT:case W.BGSOUND:case W.BASEFONT:case W.TEMPLATE:ef(e,t);break;case W.BODY:Qgn(e,t);break;case W.FORM:r0n(e,t);break;case W.NOBR:c0n(e,t);break;case W.MATH:x0n(e,t);break;case W.TABLE:d0n(e,t);break;case W.INPUT:f0n(e,t);break;case W.PARAM:case W.TRACK:case W.SOURCE:h0n(e,t);break;case W.IMAGE:m0n(e,t);break;case W.BUTTON:s0n(e,t);break;case W.APPLET:case W.OBJECT:case W.MARQUEE:u0n(e,t);break;case W.IFRAME:b0n(e,t);break;case W.SELECT:v0n(e,t);break;case W.OPTION:case W.OPTGROUP:w0n(e,t);break;case W.NOEMBED:case W.NOFRAMES:PNe(e,t);break;case W.FRAMESET:$gn(e,t);break;case W.TEXTAREA:g0n(e,t);break;case W.NOSCRIPT:e.options.scriptingEnabled?PNe(e,t):LNe(e,t);break;case W.PLAINTEXT:o0n(e,t);break;case W.COL:case W.TH:case W.TD:case W.TR:case W.HEAD:case W.FRAME:case W.TBODY:case W.TFOOT:case W.THEAD:case W.CAPTION:case W.COLGROUP:break;default:LNe(e,t)}}function I0n(e,t){if(e.openElements.hasInScope(W.BODY)&&(e.insertionMode=Ye.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function k0n(e,t){e.openElements.hasInScope(W.BODY)&&(e.insertionMode=Ye.AFTER_BODY,UNe(e,t))}function E0n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function C0n(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(W.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(W.FORM):n&&e.openElements.remove(n))}function _0n(e){e.openElements.hasInButtonScope(W.P)||e._insertFakeElement(dt.P,W.P),e._closePElement()}function R0n(e){e.openElements.hasInListItemScope(W.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(W.LI),e.openElements.popUntilTagNamePopped(W.LI))}function P0n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function L0n(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function N0n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function M0n(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(dt.BR,W.BR),e.openElements.pop(),e.framesetOk=!1}function NNe(e,t){const n=t.tagName,r=t.tagID;for(let i=e.openElements.stackTop;i>0;i--){const o=e.openElements.items[i],s=e.openElements.tagIDs[i];if(r===s&&(r!==W.UNKNOWN||e.treeAdapter.getTagName(o)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=i&&e.openElements.shortenToLength(i);break}if(e._isSpecialElement(o,s))break}}function v3(e,t){switch(t.tagID){case W.A:case W.B:case W.I:case W.S:case W.U:case W.EM:case W.TT:case W.BIG:case W.CODE:case W.FONT:case W.NOBR:case W.SMALL:case W.STRIKE:case W.STRONG:xY(e,t);break;case W.P:_0n(e);break;case W.DL:case W.UL:case W.OL:case W.DIR:case W.DIV:case W.NAV:case W.PRE:case W.MAIN:case W.MENU:case W.ASIDE:case W.BUTTON:case W.CENTER:case W.FIGURE:case W.FOOTER:case W.HEADER:case W.HGROUP:case W.DIALOG:case W.ADDRESS:case W.ARTICLE:case W.DETAILS:case W.SEARCH:case W.SECTION:case W.SUMMARY:case W.LISTING:case W.FIELDSET:case W.BLOCKQUOTE:case W.FIGCAPTION:E0n(e,t);break;case W.LI:R0n(e);break;case W.DD:case W.DT:P0n(e,t);break;case W.H1:case W.H2:case W.H3:case W.H4:case W.H5:case W.H6:L0n(e);break;case W.BR:M0n(e);break;case W.BODY:I0n(e,t);break;case W.HTML:k0n(e,t);break;case W.FORM:C0n(e);break;case W.APPLET:case W.OBJECT:case W.MARQUEE:N0n(e,t);break;case W.TEMPLATE:hb(e,t);break;default:NNe(e,t)}}function MNe(e,t){e.tmplInsertionModeStack.length>0?zNe(e,t):IY(e,t)}function D0n(e,t){var n;t.tagID===W.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function O0n(e,t){e._err(t,At.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function kY(e,t){if(e.openElements.currentTagId!==void 0&&_Y.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Ye.IN_TABLE_TEXT,t.type){case _i.CHARACTER:ONe(e,t);break;case _i.WHITESPACE_CHARACTER:DNe(e,t);break}else VE(e,t)}function F0n(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_CAPTION}function B0n(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_COLUMN_GROUP}function H0n(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(dt.COLGROUP,W.COLGROUP),e.insertionMode=Ye.IN_COLUMN_GROUP,EY(e,t)}function z0n(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_TABLE_BODY}function U0n(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(dt.TBODY,W.TBODY),e.insertionMode=Ye.IN_TABLE_BODY,A3(e,t)}function V0n(e,t){e.openElements.hasInTableScope(W.TABLE)&&(e.openElements.popUntilTagNamePopped(W.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function W0n(e,t){RNe(t)?e._appendElement(t,Ht.HTML):VE(e,t),t.ackSelfClosing=!0}function G0n(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Ht.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function lS(e,t){switch(t.tagID){case W.TD:case W.TH:case W.TR:U0n(e,t);break;case W.STYLE:case W.SCRIPT:case W.TEMPLATE:ef(e,t);break;case W.COL:H0n(e,t);break;case W.FORM:G0n(e,t);break;case W.TABLE:V0n(e,t);break;case W.TBODY:case W.TFOOT:case W.THEAD:z0n(e,t);break;case W.INPUT:W0n(e,t);break;case W.CAPTION:F0n(e,t);break;case W.COLGROUP:B0n(e,t);break;default:VE(e,t)}}function UE(e,t){switch(t.tagID){case W.TABLE:e.openElements.hasInTableScope(W.TABLE)&&(e.openElements.popUntilTagNamePopped(W.TABLE),e._resetInsertionMode());break;case W.TEMPLATE:hb(e,t);break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TBODY:case W.TD:case W.TFOOT:case W.TH:case W.THEAD:case W.TR:break;default:VE(e,t)}}function VE(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,b3(e,t),e.fosterParentingEnabled=n}function DNe(e,t){e.pendingCharacterTokens.push(t)}function ONe(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function WE(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)VE(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}function j0n(e,t){const n=t.tagID;LY.has(n)?e.openElements.hasInTableScope(W.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ye.IN_TABLE,lS(e,t)):Al(e,t)}function q0n(e,t){const n=t.tagID;switch(n){case W.CAPTION:case W.TABLE:e.openElements.hasInTableScope(W.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ye.IN_TABLE,n===W.TABLE&&UE(e,t));break;case W.BODY:case W.COL:case W.COLGROUP:case W.HTML:case W.TBODY:case W.TD:case W.TFOOT:case W.TH:case W.THEAD:case W.TR:break;default:v3(e,t)}}function EY(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.COL:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.TEMPLATE:ef(e,t);break;default:w3(e,t)}}function Y0n(e,t){switch(t.tagID){case W.COLGROUP:e.openElements.currentTagId===W.COLGROUP&&(e.openElements.pop(),e.insertionMode=Ye.IN_TABLE);break;case W.TEMPLATE:hb(e,t);break;case W.COL:break;default:w3(e,t)}}function w3(e,t){e.openElements.currentTagId===W.COLGROUP&&(e.openElements.pop(),e.insertionMode=Ye.IN_TABLE,e._processToken(t))}function A3(e,t){switch(t.tagID){case W.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_ROW;break;case W.TH:case W.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(dt.TR,W.TR),e.insertionMode=Ye.IN_ROW,S3(e,t);break;case W.CAPTION:case W.COL:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE,lS(e,t));break;default:lS(e,t)}}function CY(e,t){const n=t.tagID;switch(t.tagID){case W.TBODY:case W.TFOOT:case W.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE);break;case W.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE,UE(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TD:case W.TH:case W.TR:break;default:UE(e,t)}}function S3(e,t){switch(t.tagID){case W.TH:case W.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Ye.IN_CELL,e.activeFormattingElements.insertMarker();break;case W.CAPTION:case W.COL:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:case W.TR:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE_BODY,A3(e,t));break;default:lS(e,t)}}function FNe(e,t){switch(t.tagID){case W.TR:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE_BODY);break;case W.TABLE:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE_BODY,CY(e,t));break;case W.TBODY:case W.TFOOT:case W.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(W.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Ye.IN_TABLE_BODY,CY(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TD:case W.TH:break;default:UE(e,t)}}function K0n(e,t){const n=t.tagID;LY.has(n)?(e.openElements.hasInTableScope(W.TD)||e.openElements.hasInTableScope(W.TH))&&(e._closeTableCell(),S3(e,t)):Al(e,t)}function X0n(e,t){const n=t.tagID;switch(n){case W.TD:case W.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Ye.IN_ROW);break;case W.TABLE:case W.TBODY:case W.TFOOT:case W.THEAD:case W.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),FNe(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:break;default:v3(e,t)}}function BNe(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.OPTION:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e._insertElement(t,Ht.HTML);break;case W.OPTGROUP:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Ht.HTML);break;case W.HR:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.INPUT:case W.KEYGEN:case W.TEXTAREA:case W.SELECT:e.openElements.hasInSelectScope(W.SELECT)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),t.tagID!==W.SELECT&&e._processStartTag(t));break;case W.SCRIPT:case W.TEMPLATE:ef(e,t);break;default:}}function HNe(e,t){switch(t.tagID){case W.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===W.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===W.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop();break;case W.OPTION:e.openElements.currentTagId===W.OPTION&&e.openElements.pop();break;case W.SELECT:e.openElements.hasInSelectScope(W.SELECT)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode());break;case W.TEMPLATE:hb(e,t);break;default:}}function J0n(e,t){const n=t.tagID;n===W.CAPTION||n===W.TABLE||n===W.TBODY||n===W.TFOOT||n===W.THEAD||n===W.TR||n===W.TD||n===W.TH?(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),e._processStartTag(t)):BNe(e,t)}function Z0n(e,t){const n=t.tagID;n===W.CAPTION||n===W.TABLE||n===W.TBODY||n===W.TFOOT||n===W.THEAD||n===W.TR||n===W.TD||n===W.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),e.onEndTag(t)):HNe(e,t)}function Q0n(e,t){switch(t.tagID){case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:case W.NOFRAMES:case W.SCRIPT:case W.STYLE:case W.TEMPLATE:case W.TITLE:ef(e,t);break;case W.CAPTION:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:e.tmplInsertionModeStack[0]=Ye.IN_TABLE,e.insertionMode=Ye.IN_TABLE,lS(e,t);break;case W.COL:e.tmplInsertionModeStack[0]=Ye.IN_COLUMN_GROUP,e.insertionMode=Ye.IN_COLUMN_GROUP,EY(e,t);break;case W.TR:e.tmplInsertionModeStack[0]=Ye.IN_TABLE_BODY,e.insertionMode=Ye.IN_TABLE_BODY,A3(e,t);break;case W.TD:case W.TH:e.tmplInsertionModeStack[0]=Ye.IN_ROW,e.insertionMode=Ye.IN_ROW,S3(e,t);break;default:e.tmplInsertionModeStack[0]=Ye.IN_BODY,e.insertionMode=Ye.IN_BODY,Al(e,t)}}function $0n(e,t){t.tagID===W.TEMPLATE&&hb(e,t)}function zNe(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(W.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):IY(e,t)}function eyn(e,t){t.tagID===W.HTML?Al(e,t):x3(e,t)}function UNe(e,t){var n;if(t.tagID===W.HTML){if(e.fragmentContext||(e.insertionMode=Ye.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===W.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else x3(e,t)}function x3(e,t){e.insertionMode=Ye.IN_BODY,b3(e,t)}function tyn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.FRAMESET:e._insertElement(t,Ht.HTML);break;case W.FRAME:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.NOFRAMES:ef(e,t);break;default:}}function nyn(e,t){t.tagID===W.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==W.FRAMESET&&(e.insertionMode=Ye.AFTER_FRAMESET))}function ryn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.NOFRAMES:ef(e,t);break;default:}}function iyn(e,t){t.tagID===W.HTML&&(e.insertionMode=Ye.AFTER_AFTER_FRAMESET)}function oyn(e,t){t.tagID===W.HTML?Al(e,t):T3(e,t)}function T3(e,t){e.insertionMode=Ye.IN_BODY,b3(e,t)}function syn(e,t){switch(t.tagID){case W.HTML:Al(e,t);break;case W.NOFRAMES:ef(e,t);break;default:}}function ayn(e,t){t.chars="�",e._insertCharacters(t)}function lyn(e,t){e._insertCharacters(t),e.framesetOk=!1}function VNe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Ht.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function cyn(e,t){if(Cgn(t))VNe(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===Ht.MATHML?bNe(t):r===Ht.SVG&&(_gn(t),vNe(t)),AY(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function uyn(e,t){if(t.tagID===W.P||t.tagID===W.BR){VNe(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===Ht.HTML){e._endTagOutsideForeignContent(t);break}const i=e.treeAdapter.getTagName(r);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(n);break}}}var WNe,GNe,jNe,Ye,qNe,_Y,RY,PY,LY,dyn=Pe((()=>{rNe(),xgn(),Tgn(),yY(),Egn(),kNe(),h3(),lY(),Mg(),cY(),WNe="hidden",GNe=8,jNe=3,(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(Ye||(Ye={})),qNe={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},_Y=new Set([W.TABLE,W.TBODY,W.TFOOT,W.THEAD,W.TR]),RY={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Op,onParseError:null},PY=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=Ye.INITIAL,this.originalInsertionMode=Ye.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...RY,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new nNe(this.options,this),this.activeFormattingElements=new dNe(this.treeAdapter),this.fragmentContextID=n?p3(this.treeAdapter.getTagName(n)):W.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new uNe(this.document,this.treeAdapter,this)}static parse(e,t){const n=new this(t);return n.tokenizer.write(e,!0),n.document}static getFragmentParser(e,t){const n={...RY,...t};e!=null||(e=n.treeAdapter.createElement(dt.TEMPLATE,Ht.HTML,[]));const r=n.treeAdapter.createElement("documentmock",Ht.HTML,[]),i=new this(n,r,e);return i.fragmentContextID===W.TEMPLATE&&i.tmplInsertionModeStack.unshift(Ye.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,n){var r;if(!this.onParseError)return;const i=(r=e.location)!==null&&r!==void 0?r:qNe,o={code:t,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:n?i.startLine:i.endLine,endCol:n?i.startCol:i.endCol,endOffset:n?i.startOffset:i.endOffset};this.onParseError(o)}onItemPush(e,t,n){var r,i;(i=(r=this.treeAdapter).onItemPush)===null||i===void 0||i.call(r,e),n&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var n,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(r=(n=this.treeAdapter).onItemPop)===null||r===void 0||r.call(n,e,this.openElements.current),t){let i,o;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,o=this.fragmentContextID):{current:i,currentTagId:o}=this.openElements,this._setContextModes(i,o)}}_setContextModes(e,t){const n=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===Ht.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,Ht.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=Ye.TEXT}switchToPlaintextParsing(){this.insertionMode=Ye.TEXT,this.originalInsertionMode=Ye.IN_BODY,this.tokenizer.state=nc.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===dt.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Ht.HTML))switch(this.fragmentContextID){case W.TITLE:case W.TEXTAREA:this.tokenizer.state=nc.RCDATA;break;case W.STYLE:case W.XMP:case W.IFRAME:case W.NOEMBED:case W.NOFRAMES:case W.NOSCRIPT:this.tokenizer.state=nc.RAWTEXT;break;case W.SCRIPT:this.tokenizer.state=nc.SCRIPT_DATA;break;case W.PLAINTEXT:this.tokenizer.state=nc.PLAINTEXT;break;default:}}_setDocumentType(e){const t=e.name||"",n=e.publicId||"",r=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,n,r),e.location){const i=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));i&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){const n=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{const n=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(n??this.document,e)}}_appendElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location)}_insertElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location),this.openElements.push(n,e.tagID)}_insertFakeElement(e,t){const n=this.treeAdapter.createElement(e,Ht.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,Ht.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(dt.HTML,Ht.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,W.HTML)}_appendCommentNode(e,t){const n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const r=this.treeAdapter.getChildNodes(t),i=r[(n?r.lastIndexOf(n):r.length)-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){const{endLine:o,endCol:s,endOffset:a}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:o,endCol:s,endOffset:a})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let n=this.treeAdapter.getFirstChild(e);n;n=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(t,n)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){const n=t.location,r=this.treeAdapter.getTagName(e),i=t.type===_i.END_TAG&&r===t.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,i)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,n;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,n=this.fragmentContextID):{current:t,currentTagId:n}=this.openElements,e.tagID===W.SVG&&this.treeAdapter.getTagName(t)===dt.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===Ht.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===W.MGLYPH||e.tagID===W.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,Ht.HTML)}_processToken(e){switch(e.type){case _i.CHARACTER:this.onCharacter(e);break;case _i.NULL_CHARACTER:this.onNullCharacter(e);break;case _i.COMMENT:this.onComment(e);break;case _i.DOCTYPE:this.onDoctype(e);break;case _i.START_TAG:this._processStartTag(e);break;case _i.END_TAG:this.onEndTag(e);break;case _i.EOF:this.onEof(e);break;case _i.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e);break}}_isIntegrationPoint(e,t,n){const r=this.treeAdapter.getNamespaceURI(t),i=this.treeAdapter.getAttrList(t);return Lgn(e,r,i,n)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(r=>r.type===hh.Marker||this.openElements.contains(r.element)),n=t===-1?e-1:t-1;for(let r=n;r>=0;r--){const i=this.activeFormattingElements.entries[r];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=Ye.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(W.P),this.openElements.popUntilTagNamePopped(W.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case W.TR:this.insertionMode=Ye.IN_ROW;return;case W.TBODY:case W.THEAD:case W.TFOOT:this.insertionMode=Ye.IN_TABLE_BODY;return;case W.CAPTION:this.insertionMode=Ye.IN_CAPTION;return;case W.COLGROUP:this.insertionMode=Ye.IN_COLUMN_GROUP;return;case W.TABLE:this.insertionMode=Ye.IN_TABLE;return;case W.BODY:this.insertionMode=Ye.IN_BODY;return;case W.FRAMESET:this.insertionMode=Ye.IN_FRAMESET;return;case W.SELECT:this._resetInsertionModeForSelect(e);return;case W.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case W.HTML:this.insertionMode=this.headElement?Ye.AFTER_HEAD:Ye.BEFORE_HEAD;return;case W.TD:case W.TH:if(e>0){this.insertionMode=Ye.IN_CELL;return}break;case W.HEAD:if(e>0){this.insertionMode=Ye.IN_HEAD;return}break}this.insertionMode=Ye.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const n=this.openElements.tagIDs[t];if(n===W.TEMPLATE)break;if(n===W.TABLE){this.insertionMode=Ye.IN_SELECT_IN_TABLE;return}}this.insertionMode=Ye.IN_SELECT}_isElementCausesFosterParenting(e){return _Y.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case W.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===Ht.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case W.TABLE:{const n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}default:}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return QLe[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){lyn(this,e);return}switch(this.insertionMode){case Ye.INITIAL:DE(this,e);break;case Ye.BEFORE_HTML:OE(this,e);break;case Ye.BEFORE_HEAD:FE(this,e);break;case Ye.IN_HEAD:BE(this,e);break;case Ye.IN_HEAD_NO_SCRIPT:HE(this,e);break;case Ye.AFTER_HEAD:zE(this,e);break;case Ye.IN_BODY:case Ye.IN_CAPTION:case Ye.IN_CELL:case Ye.IN_TEMPLATE:CNe(this,e);break;case Ye.TEXT:case Ye.IN_SELECT:case Ye.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case Ye.IN_TABLE:case Ye.IN_TABLE_BODY:case Ye.IN_ROW:kY(this,e);break;case Ye.IN_TABLE_TEXT:ONe(this,e);break;case Ye.IN_COLUMN_GROUP:w3(this,e);break;case Ye.AFTER_BODY:x3(this,e);break;case Ye.AFTER_AFTER_BODY:T3(this,e);break;default:}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){ayn(this,e);return}switch(this.insertionMode){case Ye.INITIAL:DE(this,e);break;case Ye.BEFORE_HTML:OE(this,e);break;case Ye.BEFORE_HEAD:FE(this,e);break;case Ye.IN_HEAD:BE(this,e);break;case Ye.IN_HEAD_NO_SCRIPT:HE(this,e);break;case Ye.AFTER_HEAD:zE(this,e);break;case Ye.TEXT:this._insertCharacters(e);break;case Ye.IN_TABLE:case Ye.IN_TABLE_BODY:case Ye.IN_ROW:kY(this,e);break;case Ye.IN_COLUMN_GROUP:w3(this,e);break;case Ye.AFTER_BODY:x3(this,e);break;case Ye.AFTER_AFTER_BODY:T3(this,e);break;default:}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){TY(this,e);return}switch(this.insertionMode){case Ye.INITIAL:case Ye.BEFORE_HTML:case Ye.BEFORE_HEAD:case Ye.IN_HEAD:case Ye.IN_HEAD_NO_SCRIPT:case Ye.AFTER_HEAD:case Ye.IN_BODY:case Ye.IN_TABLE:case Ye.IN_CAPTION:case Ye.IN_COLUMN_GROUP:case Ye.IN_TABLE_BODY:case Ye.IN_ROW:case Ye.IN_CELL:case Ye.IN_SELECT:case Ye.IN_SELECT_IN_TABLE:case Ye.IN_TEMPLATE:case Ye.IN_FRAMESET:case Ye.AFTER_FRAMESET:TY(this,e);break;case Ye.IN_TABLE_TEXT:WE(this,e);break;case Ye.AFTER_BODY:Hgn(this,e);break;case Ye.AFTER_AFTER_BODY:case Ye.AFTER_AFTER_FRAMESET:zgn(this,e);break;default:}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case Ye.INITIAL:Ugn(this,e);break;case Ye.BEFORE_HEAD:case Ye.IN_HEAD:case Ye.IN_HEAD_NO_SCRIPT:case Ye.AFTER_HEAD:this._err(e,At.misplacedDoctype);break;case Ye.IN_TABLE_TEXT:WE(this,e);break;default:}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,At.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?cyn(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case Ye.INITIAL:DE(this,e);break;case Ye.BEFORE_HTML:Vgn(this,e);break;case Ye.BEFORE_HEAD:Ggn(this,e);break;case Ye.IN_HEAD:ef(this,e);break;case Ye.IN_HEAD_NO_SCRIPT:Ygn(this,e);break;case Ye.AFTER_HEAD:Xgn(this,e);break;case Ye.IN_BODY:Al(this,e);break;case Ye.IN_TABLE:lS(this,e);break;case Ye.IN_TABLE_TEXT:WE(this,e);break;case Ye.IN_CAPTION:j0n(this,e);break;case Ye.IN_COLUMN_GROUP:EY(this,e);break;case Ye.IN_TABLE_BODY:A3(this,e);break;case Ye.IN_ROW:S3(this,e);break;case Ye.IN_CELL:K0n(this,e);break;case Ye.IN_SELECT:BNe(this,e);break;case Ye.IN_SELECT_IN_TABLE:J0n(this,e);break;case Ye.IN_TEMPLATE:Q0n(this,e);break;case Ye.AFTER_BODY:eyn(this,e);break;case Ye.IN_FRAMESET:tyn(this,e);break;case Ye.AFTER_FRAMESET:ryn(this,e);break;case Ye.AFTER_AFTER_BODY:oyn(this,e);break;case Ye.AFTER_AFTER_FRAMESET:syn(this,e);break;default:}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?uyn(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case Ye.INITIAL:DE(this,e);break;case Ye.BEFORE_HTML:Wgn(this,e);break;case Ye.BEFORE_HEAD:jgn(this,e);break;case Ye.IN_HEAD:qgn(this,e);break;case Ye.IN_HEAD_NO_SCRIPT:Kgn(this,e);break;case Ye.AFTER_HEAD:Jgn(this,e);break;case Ye.IN_BODY:v3(this,e);break;case Ye.TEXT:D0n(this,e);break;case Ye.IN_TABLE:UE(this,e);break;case Ye.IN_TABLE_TEXT:WE(this,e);break;case Ye.IN_CAPTION:q0n(this,e);break;case Ye.IN_COLUMN_GROUP:Y0n(this,e);break;case Ye.IN_TABLE_BODY:CY(this,e);break;case Ye.IN_ROW:FNe(this,e);break;case Ye.IN_CELL:X0n(this,e);break;case Ye.IN_SELECT:HNe(this,e);break;case Ye.IN_SELECT_IN_TABLE:Z0n(this,e);break;case Ye.IN_TEMPLATE:$0n(this,e);break;case Ye.AFTER_BODY:UNe(this,e);break;case Ye.IN_FRAMESET:nyn(this,e);break;case Ye.AFTER_FRAMESET:iyn(this,e);break;case Ye.AFTER_AFTER_BODY:T3(this,e);break;default:}}onEof(e){switch(this.insertionMode){case Ye.INITIAL:DE(this,e);break;case Ye.BEFORE_HTML:OE(this,e);break;case Ye.BEFORE_HEAD:FE(this,e);break;case Ye.IN_HEAD:BE(this,e);break;case Ye.IN_HEAD_NO_SCRIPT:HE(this,e);break;case Ye.AFTER_HEAD:zE(this,e);break;case Ye.IN_BODY:case Ye.IN_TABLE:case Ye.IN_CAPTION:case Ye.IN_COLUMN_GROUP:case Ye.IN_TABLE_BODY:case Ye.IN_ROW:case Ye.IN_CELL:case Ye.IN_SELECT:case Ye.IN_SELECT_IN_TABLE:MNe(this,e);break;case Ye.TEXT:O0n(this,e);break;case Ye.IN_TABLE_TEXT:WE(this,e);break;case Ye.IN_TEMPLATE:zNe(this,e);break;case Ye.AFTER_BODY:case Ye.IN_FRAMESET:case Ye.AFTER_FRAMESET:case Ye.AFTER_AFTER_BODY:case Ye.AFTER_AFTER_FRAMESET:IY(this,e);break;default:}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===Ne.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case Ye.IN_HEAD:case Ye.IN_HEAD_NO_SCRIPT:case Ye.AFTER_HEAD:case Ye.TEXT:case Ye.IN_COLUMN_GROUP:case Ye.IN_SELECT:case Ye.IN_SELECT_IN_TABLE:case Ye.IN_FRAMESET:case Ye.AFTER_FRAMESET:this._insertCharacters(e);break;case Ye.IN_BODY:case Ye.IN_CAPTION:case Ye.IN_CELL:case Ye.IN_TEMPLATE:case Ye.AFTER_BODY:case Ye.AFTER_AFTER_BODY:case Ye.AFTER_AFTER_FRAMESET:ENe(this,e);break;case Ye.IN_TABLE:case Ye.IN_TABLE_BODY:case Ye.IN_ROW:kY(this,e);break;case Ye.IN_TABLE_TEXT:DNe(this,e);break;default:}}},LY=new Set([W.CAPTION,W.COL,W.COLGROUP,W.TBODY,W.TD,W.TFOOT,W.TH,W.THEAD,W.TR])})),fyn,hyn=Pe((()=>{Mg(),yY(),fyn=new Set([dt.AREA,dt.BASE,dt.BASEFONT,dt.BGSOUND,dt.BR,dt.COL,dt.EMBED,dt.FRAME,dt.HR,dt.IMG,dt.INPUT,dt.KEYGEN,dt.LINK,dt.META,dt.PARAM,dt.SOURCE,dt.TRACK,dt.WBR])}));function pyn(e,t){return PY.parse(e,t)}function myn(e,t,n){typeof e=="string"&&(n=t,t=e,e=null);const r=PY.getFragmentParser(e,n);return r.tokenizer.write(t,!0),r.getFragment()}var gyn=Pe((()=>{dyn(),yY(),hyn(),h3(),kNe(),Mg(),cY(),rNe()})),YNe,yyn=Pe((()=>{YNe={abandonedHeadElementChild:{reason:"Unexpected metadata element after head",description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:"Unexpected abruptly closed empty comment",description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:"Unexpected abruptly closed public identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:"Unexpected abruptly closed system identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:"Unexpected non-digit at start of numeric character reference",description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:"Unexpected CDATA section in HTML",description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:"Unexpected too big numeric character reference",description:"Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)"},closingOfElementWithOpenChildElements:{reason:"Unexpected closing tag with open child elements",description:"Unexpectedly closing tag. Expected other tags to be closed first",url:!1},controlCharacterInInputStream:{reason:"Unexpected control character",description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:"Unexpected control character reference",description:"Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace"},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:"Unexpected duplicate attribute",description:"Unexpectedly double attribute. Expected attributes to occur only once"},endTagWithAttributes:{reason:"Unexpected attribute on closing tag",description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:"Unexpected slash at end of closing tag",description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:"Unexpected unopened end tag",description:"Unexpected end tag. Expected no end tag or another end tag",url:!1},eofBeforeTagName:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected tag name instead"},eofInCdata:{reason:"Unexpected end of file in CDATA",description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:"Unexpected end of file in comment",description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:"Unexpected end of file in doctype",description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:"Unexpected end of file in element that can only contain text",description:"Unexpected end of file. Expected text or a closing tag",url:!1},eofInScriptHtmlCommentLikeText:{reason:"Unexpected end of file in comment inside script",description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:"Unexpected end of file in tag",description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:"Incorrectly closed comment",description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:"Incorrectly opened comment",description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:"Invalid sequence after doctype name",description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:"Invalid first character in tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:"Misplaced doctype",description:"Unexpected doctype. Expected doctype before head",url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:"Missing attribute value",description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:"Missing doctype before other content",description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:"Missing doctype name",description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:"Missing public identifier in doctype",description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:"Missing system identifier in doctype",description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:"Missing name in end tag",description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:"Missing quote before public identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:"Missing quote before system identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:"Missing semicolon after character reference",description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:"Missing whitespace after public identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:"Missing whitespace after system identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:"Missing whitespace before doctype name",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:"Missing whitespace between attributes",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:"Missing whitespace between public and system identifiers in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:"Unexpected nested comment",description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:"Unexpected non-conforming doctype declaration",description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:"Unexpected trailing slash on start tag of non-void element",description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:"Unexpected noncharacter code point referenced by character reference",description:"Unexpected code point. Do not use noncharacters in HTML"},noncharacterInInputStream:{reason:"Unexpected noncharacter character",description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:"Unexpected NULL character referenced by character reference",description:"Unexpected code point. Do not use NULL characters in HTML"},openElementsLeftAfterEof:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected closing tag instead",url:!1},surrogateCharacterReference:{reason:"Unexpected surrogate character referenced by character reference",description:"Unexpected code point. Do not use lone surrogate characters in HTML"},surrogateInInputStream:{reason:"Unexpected surrogate character",description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:"Invalid character after system identifier in doctype",description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:"Unexpected character in attribute name",description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:"Unexpected character in unquoted attribute value",description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:"Unexpected equals sign before attribute name",description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:"Unexpected NULL character",description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:"Unexpected question mark instead of tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:"Unexpected slash in tag",description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:"Unexpected unknown named character reference",description:"Unexpected character reference. Expected known named character references"}}}));function byn(e,t){const n=t||$Ne,r=n.onerror,i=e instanceof zP?e:new zP(e),o=n.fragment?myn:pyn,s=String(i);return tgn(o(s,{sourceCodeLocationInfo:!0,onParseError:n.onerror?a:null,scriptingEnabled:!1}),{file:i,space:n.space,verbose:n.verbose});function a(l){const c=l.code,u=vyn(c),d=n[u],f=d??!0,h=typeof f=="number"?f:f?1:0;if(h){const m=YNe[u],g=new ml(p(m.reason),{place:{start:{line:l.startLine,column:l.startCol,offset:l.startOffset},end:{line:l.endLine,column:l.endCol,offset:l.endOffset}},ruleId:c,source:"hast-util-from-html"});i.path&&(g.file=i.path,g.name=i.path+":"+g.name),g.fatal=QNe[h],g.note=p(m.description),g.url=m.url===!1?void 0:KNe+c,r(g)}function p(m){return m.replace(JNe,g).replace(ZNe,y);function g(v,b,w){const x=(w?Number.parseInt(w,10):0)*(b==="-"?-1:1);return Ayn(s.charAt(l.startOffset+x))}function y(){return Syn(s.charCodeAt(l.startOffset))}}}}function vyn(e){return e.replace(XNe,wyn)}function wyn(e){return e.charAt(1).toUpperCase()}function Ayn(e){return e==="`"?"` ` `":e}function Syn(e){return"0x"+e.toString(16).toUpperCase()}var KNe,XNe,JNe,ZNe,QNe,$Ne,xyn=Pe((()=>{Iy(),ogn(),gyn(),nme(),$pe(),yyn(),KNe="https://html.spec.whatwg.org/multipage/parsing.html#parse-error-",XNe=/-[a-z]/g,JNe=/%c(?:([-+])(\d+))?/g,ZNe=/%x/g,QNe={2:!0,1:!1,0:null},$Ne={}})),Tyn=Pe((()=>{xyn()}));function Iyn(e){const t=this,{emitParseErrors:n,...r}={...t.data("settings"),...e};t.parser=i;function i(o,s){return byn(o,{...r,onerror:n?function(a){s.path&&(a.name=s.path+":"+a.name,a.file=s.path),s.messages.push(a)}:void 0})}}var kyn=Pe((()=>{Tyn()})),Eyn=ls({default:()=>Iyn},1),Cyn=Pe((()=>{kyn()})),_yn,Ryn,Pyn,Lyn,Nyn,Myn,Dyn,Oyn,Fyn,Byn,eMe=Pe((()=>{_yn=-1,Ryn=0,Pyn=1,Lyn=2,Nyn=3,Myn=4,Dyn=5,Oyn=6,Fyn=7,Byn=8})),NY,tMe,MY,Hyn=Pe((()=>{eMe(),NY=typeof self=="object"?self:globalThis,tMe=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,s]=t[i];switch(o){case 0:case-1:return n(s,i);case 1:{const a=n([],i);for(const l of s)a.push(r(l));return a}case 2:{const a=n({},i);for(const[l,c]of s)a[r(l)]=r(c);return a}case 3:return n(new Date(s),i);case 4:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case 5:{const a=n(new Map,i);for(const[l,c]of s)a.set(r(l),r(c));return a}case 6:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case 7:{const{name:a,message:l}=s;return n(new NY[a](l),i)}case 8:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i);case"ArrayBuffer":return n(new Uint8Array(s).buffer,s);case"DataView":{const{buffer:a}=new Uint8Array(s);return n(new DataView(a),s)}}return n(new NY[o](s),i)};return r},MY=e=>tMe(new Map,e)(0)})),pb,nMe,rMe,cS,GE,iMe,DY,zyn=Pe((()=>{eMe(),pb="",{toString:nMe}={},{keys:rMe}=Object,cS=e=>{const t=typeof e;if(t!=="object"||!e)return[0,t];const n=nMe.call(e).slice(8,-1);switch(n){case"Array":return[1,pb];case"Object":return[2,pb];case"Date":return[3,pb];case"RegExp":return[4,pb];case"Map":return[5,pb];case"Set":return[6,pb];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},GE=([e,t])=>e===0&&(t==="function"||t==="symbol"),iMe=(e,t,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=cS(s);switch(a){case 0:{let u=s;switch(l){case"bigint":a=8,u=s.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);u=null;break;case"undefined":return i([-1],s)}return i([a,u],s)}case 1:{if(l){let f=s;return l==="DataView"?f=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(s)),i([l,[...f]],s)}const u=[],d=i([a,u],s);for(const f of s)u.push(o(f));return d}case 2:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(t&&"toJSON"in s)return o(s.toJSON());const u=[],d=i([a,u],s);for(const f of rMe(s))(e||!GE(cS(s[f])))&&u.push([o(f),o(s[f])]);return d}case 3:return i([a,s.toISOString()],s);case 4:{const{source:u,flags:d}=s;return i([a,{source:u,flags:d}],s)}case 5:{const u=[],d=i([a,u],s);for(const[f,h]of s)(e||!(GE(cS(f))||GE(cS(h))))&&u.push([o(f),o(h)]);return d}case 6:{const u=[],d=i([a,u],s);for(const f of s)(e||!GE(cS(f)))&&u.push(o(f));return d}}const{message:c}=s;return i([a,{name:l,message:c}],s)};return o},DY=(e,{json:t,lossy:n}={})=>{const r=[];return iMe(!(t||n),!!t,new Map,r)(e),r}})),OY,oMe=Pe((()=>{Hyn(),zyn(),OY=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?MY(DY(e,t)):structuredClone(e):(e,t)=>MY(DY(e,t))}));function Uyn(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Qu(e[n]);return FY(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function Vyn(e){return FY(t);function t(n){return n.tagName===e}}function FY(e){return t;function t(n,r,i){return!!(sMe(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Wyn(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function sMe(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var I3,Qu,Gyn=Pe((()=>{I3=(function(e,t,n,r,i){const o=Qu(t);if(n!=null&&(typeof n!="number"||n<0||n===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(r!=null&&(!r.type||!r.children))throw new Error("Expected valid `parent`");if(n==null!=(r==null))throw new Error("Expected both `index` and `parent`");return sMe(e)?o.call(i,e,n,r):!1}),Qu=(function(e){if(e==null)return Wyn;if(typeof e=="string")return Vyn(e);if(typeof e=="object")return Uyn(e);if(typeof e=="function")return FY(e);throw new Error("Expected function, string, or array as `test`")})})),k3=Pe((()=>{Gyn()})),BY,jyn=Pe((()=>{k3(),BY=Qu(function(e){return e.tagName==="audio"||e.tagName==="canvas"||e.tagName==="embed"||e.tagName==="iframe"||e.tagName==="img"||e.tagName==="math"||e.tagName==="object"||e.tagName==="picture"||e.tagName==="svg"||e.tagName==="video"})})),aMe=Pe((()=>{jyn()}));function lMe(e){return typeof e=="object"?e.type==="text"?cMe(e.value):!1:cMe(e)}function cMe(e){return e.replace(uMe,"")===""}var uMe,qyn=Pe((()=>{uMe=/[ \t\n\f\r]/g})),dMe=Pe((()=>{qyn()})),fMe,Yyn=Pe((()=>{fMe=["address","article","aside","blockquote","body","br","caption","center","col","colgroup","dd","dialog","dir","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","legend","li","li","listing","main","menu","nav","ol","optgroup","option","p","plaintext","pre","section","summary","table","tbody","td","td","tfoot","th","th","thead","tr","ul","wbr","xmp"]})),hMe,Kyn=Pe((()=>{hMe=["button","input","select","textarea"]})),pMe,Xyn=Pe((()=>{pMe=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"]}));function Jyn(e,t){mMe(e,{collapse:rbn((t||wMe).newlines?tbn:nbn),whitespace:"normal"})}function mMe(e,t){if("children"in e){const n={...t};return(e.type==="root"||bMe(e))&&(n.before=!0,n.after=!0),n.whitespace=ibn(e,t),Qyn(e,n)}if(e.type==="text"){if(t.whitespace==="normal")return Zyn(e,t);t.whitespace==="nowrap"&&(e.value=t.collapse(e.value))}return{ignore:E3(e),stripAtStart:!1,remove:!1}}function Zyn(e,t){const n=t.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1};let i=0,o=n.length;return t.before&&vMe(n.charAt(0))&&i++,i!==o&&vMe(n.charAt(o-1))&&(t.after?o--:r.stripAtStart=!0),i===o?r.remove=!0:e.value=n.slice(i,o),r}function Qyn(e,t){let n=t.before;const r=t.after,i=e.children;let o=i.length,s=-1;for(;++s<o;){const a=mMe(i[s],{...t,after:gMe(i,s,r),before:n});a.remove?(i.splice(s,1),s--,o--):a.ignore||(n=a.stripAtStart),yMe(i[s])&&(n=!1)}return{ignore:!1,stripAtStart:!!(n||r),remove:!1}}function gMe(e,t,n){for(;++t<e.length;){const r=e[t];let i=$yn(r);if(i===void 0&&"children"in r&&!ebn(r)&&(i=gMe(r.children,-1)),typeof i=="boolean")return i}return n}function $yn(e){if(e.type==="element"){if(yMe(e))return!1;if(bMe(e))return!0}else if(e.type==="text"){if(!lMe(e))return!1}else if(!E3(e))return!1}function yMe(e){return BY(e)||I3(e,hMe)}function bMe(e){return I3(e,fMe)}function ebn(e){return!!(e.type==="element"&&e.properties.hidden)||E3(e)||I3(e,pMe)}function vMe(e){return e===" "||e===`
353
353
  `}function tbn(e){const t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function nbn(){return" "}function rbn(e){return t;function t(n){return String(n).replace(/[\t\n\v\f\r ]+/g,e)}}function ibn(e,t){if("tagName"in e&&e.properties)switch(e.tagName){case"listing":case"plaintext":case"script":case"style":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return e.properties.wrap?"pre-wrap":"pre";case"td":case"th":return e.properties.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}return t.whitespace}var wMe,E3,obn=Pe((()=>{aMe(),k3(),dMe(),qI(),Yyn(),Kyn(),Xyn(),wMe={},E3=ky(["comment","doctype"])})),sbn=Pe((()=>{obn()}));function abn(e){return function(t){Jyn(t,e)}}var lbn=Pe((()=>{sbn()})),cbn=Pe((()=>{lbn()}));function AMe(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function ubn(e){const t=xMe(e),n=SMe(e);if(t&&n)return{start:t,end:n}}var SMe,xMe,dbn=Pe((()=>{SMe=AMe("end"),xMe=AMe("start")})),fbn=Pe((()=>{dbn()}));function hbn(e,t){const n=t.properties||{},r=e.all(t),i={type:"link",url:e.resolve(String(n.href||"")||null),title:n.title?String(n.title):null,children:r};return e.patch(t,i),i}var pbn=Pe((()=>{}));function mbn(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)}var gbn=Pe((()=>{}));function ybn(e,t){const n={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,n),n}var bbn=Pe((()=>{}));function vbn(e,t){const n={type:"break"};return e.patch(t,n),n}var wbn=Pe((()=>{})),HY,Abn=Pe((()=>{qI(),HY=(function(e,t,n){const r=ky(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]})})),Sbn=Pe((()=>{Abn()}));function jE(e,t){const n=t||{},r="children"in e?e.children:[],i=GY(e),o=kMe(e,{whitespace:n.whitespace||"normal",breakBefore:!1,breakAfter:!1}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...IMe(e,{whitespace:o,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)s.push(...TMe(r[a],e,{whitespace:o,breakBefore:a?void 0:i,breakAfter:a<r.length-1?C3(r[a+1]):i}));const l=[];let c;for(a=-1;++a<s.length;){const u=s[a];typeof u=="number"?c!==void 0&&u>c&&(c=u):u&&(c!==void 0&&c>-1&&l.push(`
354
354
  `.repeat(c)||" "),c=-1,l.push(u))}return l.join("")}function TMe(e,t,n){return e.type==="element"?xbn(e,t,n):e.type==="text"?n.whitespace==="normal"?IMe(e,n):Tbn(e):[]}function xbn(e,t,n){const r=kMe(e,n),i=e.children||[];let o=-1,s=[];if(CMe(e))return s;let a,l;for(C3(e)||WY(e)&&HY(t,e,WY)?l=`
355
- `:EMe(e)?(a=2,l=2):GY(e)&&(a=1,l=1);++o<i.length;)s=s.concat(TMe(i[o],e,{whitespace:r,breakBefore:o?void 0:a,breakAfter:o<i.length-1?C3(i[o+1]):l}));return VY(e)&&HY(t,e,VY)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function IMe(e,t){const n=String(e.value),r=[],i=[];let o=0;for(;o<=n.length;){zY.lastIndex=o;const l=zY.exec(n),c=l&&"index"in l?l.index:n.length;r.push(Ibn(n.slice(o,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),o=c+1}let s=-1,a;for(;++s<r.length;)r[s].charCodeAt(r[s].length-1)===8203||s<r.length-1&&r[s+1].charCodeAt(0)===8203?(i.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&i.push(a),i.push(r[s]),a=0):(s===0||s===r.length-1)&&i.push(0);return i}function Tbn(e){return[String(e.value)]}function Ibn(e,t,n){const r=[];let i=0,o;for(;i<e.length;){UY.lastIndex=i;const s=UY.exec(e);o=s?s.index:e.length,!i&&!o&&s&&!t&&r.push(""),i!==o&&r.push(e.slice(i,o)),i=s?o+s[0].length:o}return i!==o&&!n&&r.push(""),r.join(" ")}function kMe(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function kbn(e){return!!(e.properties||{}).hidden}function Ebn(e){return e.tagName==="td"||e.tagName==="th"}function Cbn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var zY,UY,C3,VY,EMe,WY,CMe,GY,_bn=Pe((()=>{Sbn(),k3(),zY=/\n/g,UY=/[\t ]+/g,C3=Qu("br"),VY=Qu(Ebn),EMe=Qu("p"),WY=Qu("tr"),CMe=Qu(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",kbn,Cbn]),GY=Qu(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"])})),qE=Pe((()=>{_bn()}));function Rbn(e){const t=String(e);let n=t.length;for(;n>0;){const r=t.codePointAt(n-1);if(r!==void 0&&(r===10||r===13))n--;else break}return t.slice(0,n)}var Pbn=Pe((()=>{}));function _3(e,t){const n=t.children;let r=-1,i,o;if(t.tagName==="pre")for(;++r<n.length;){const a=n[r];if(a.type==="element"&&a.tagName==="code"&&a.properties&&a.properties.className&&Array.isArray(a.properties.className)){i=a.properties.className;break}}if(i){for(r=-1;++r<i.length;)if(String(i[r]).slice(0,9)===_Me){o=String(i[r]).slice(9);break}}const s={type:"code",lang:o||null,meta:null,value:Rbn(jE(t))};return e.patch(t,s),s}var _Me,Lbn=Pe((()=>{qE(),Pbn(),_Me="language-"}));function Nbn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var Mbn=Pe((()=>{}));function jY(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var Dbn=Pe((()=>{}));function qY(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var RMe=Pe((()=>{}));function Obn(e,t){const n=[],r=[];let i=-1;for(;++i<t.children.length;){const a=t.children[i];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let o={definitions:[],titles:[]};for(i=-1;++i<n.length;){const a=n[i];if(a.type==="element"&&a.tagName==="dt"){const l=n[i-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(o),o={definitions:[],titles:[]}),o.titles.push(a)}else o.definitions.push(a)}r.push(o),i=-1;const s=[];for(;++i<r.length;){const a=[...PMe(e,r[i].titles),...PMe(e,r[i].definitions)];a.length>0&&s.push({type:"listItem",spread:a.length>1,checked:null,children:a})}if(s.length>0){const a={type:"list",ordered:!1,start:null,spread:qY(s),children:s};return e.patch(t,a),a}}function PMe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,Fbn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:qY(r),children:r}]}function Fbn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var Bbn=Pe((()=>{RMe()}));function R3(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var Hbn=Pe((()=>{}));function YY(e){let t=0,n=e.length;for(;t<n&&e[t].type==="break";)t++;for(;n>t&&e[n-1].type==="break";)n--;return t===0&&n===e.length?e:e.slice(t,n)}var KY=Pe((()=>{}));function uS(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:YY(e.all(t))};return e.patch(t,n),n}var zbn=Pe((()=>{KY()}));function Ubn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var Vbn=Pe((()=>{}));function Wbn(e,t){const n=t.properties||{},r=String(n.src||""),i=String(n.title||"");if(r&&i){const o={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:i}]};return e.patch(t,o),o}}var Gbn=Pe((()=>{}));function LMe(e,t){const n=t.properties||{},r={type:"image",url:e.resolve(String(n.src||"")||null),title:n.title?String(n.title):null,alt:n.alt?String(n.alt):""};return e.patch(t,r),r}var jbn=Pe((()=>{}));function YE(e,t){const n={type:"inlineCode",value:jE(t)};return e.patch(t,n),n}var qbn=Pe((()=>{qE()}));function NMe(e,t){const n=[],r=[],i=t||e.properties||{},o=MMe(e),s=Math.min(Number.parseInt(String(i.size),10),0)||(i.multiple?4:1);let a=-1;for(;++a<o.length;){const u=o[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:o,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=jE(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function MMe(e){const t=[];let n=-1;for(;++n<e.children.length;){const r=e.children[n];"children"in r&&Array.isArray(r.children)&&t.push(...MMe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var DMe=Pe((()=>{qE()}));function Ybn(e,t){const n=t.properties||{},r=String(n.value||n.placeholder||"");if(n.disabled||n.type==="hidden"||n.type==="file")return;if(n.type==="checkbox"||n.type==="radio"){const l={type:"text",value:n.checked?e.options.checked||OMe:e.options.unchecked||FMe};return e.patch(t,l),l}if(n.type==="image"){const l=n.alt||r;if(l){const c={type:"image",url:e.resolve(String(n.src||"")||null),title:String(n.title||"")||null,alt:String(l)};return e.patch(t,c),c}return}let i=[];if(r)i=[[r,void 0]];else if(n.type!=="button"&&n.type!=="file"&&n.type!=="password"&&n.type!=="reset"&&n.type!=="submit"&&n.list){const l=String(n.list),c=e.elementById.get(l);c&&c.tagName==="datalist"&&(i=NMe(c,n))}if(i.length===0)return;if(n.type==="password"&&(i[0]=["•".repeat(i[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<i.length;){const u=e.resolve(i[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:i[c][1]||u}]};l.push(d),c!==i.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let s=-1;for(;++s<i.length;)o.push(i[s][1]?i[s][1]+" ("+i[s][0]+")":i[s][0]);const a={type:"text",value:o.join(", ")};return e.patch(t,a),a}var OMe,FMe,Kbn=Pe((()=>{DMe(),OMe="[x]",FMe="[ ]"}));function Xbn(e,t){const n=e.type==="element"&&BMe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var BMe,Jbn=Pe((()=>{BMe={}.hasOwnProperty})),Zbn=Pe((()=>{Jbn()}));function Qbn(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;const t=e.properties.rel;let n=-1;if(!Array.isArray(t)||t.length===0)return!1;for(;++n<t.length;)if(!HMe.has(String(t[n])))return!1;return!0}var HMe,$bn=Pe((()=>{HMe=new Set(["pingback","prefetch","stylesheet"])})),evn=Pe((()=>{$bn()}));function zMe(e){return!!(e.type==="text"||UMe(e)||BY(e)||Qbn(e)||VMe(e)&&Xbn(e,"itemProp"))}var UMe,VMe,tvn=Pe((()=>{aMe(),Zbn(),evn(),k3(),UMe=Qu(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),VMe=Qu("meta")})),WMe=Pe((()=>{tvn()}));function XY(e,t){const{rest:n,checkbox:r}=jMe(t),i=r?!!r.properties.checked:null,o={type:"listItem",spread:GMe(n),checked:i,children:e.toFlow(e.all(n))};return e.patch(t,o),o}function GMe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(zMe(r))continue;if(r.tagName==="p"||n||GMe(r))return!0;n=!0}}return!1}function jMe(e){const t=e.children[0];if(t&&t.type==="element"&&t.tagName==="input"&&t.properties&&(t.properties.type==="checkbox"||t.properties.type==="radio"))return{checkbox:t,rest:{...e,children:e.children.slice(1)}};if(t&&t.type==="element"&&t.tagName==="p"){const{checkbox:n,rest:r}=jMe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var nvn=Pe((()=>{WMe()}));function JY(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),rvn);let i=null;n&&(i=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const o={type:"list",ordered:n,start:i,spread:qY(r),children:r};return e.patch(t,o),o}function rvn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var ivn=Pe((()=>{RMe()}));function P3(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!KMe(n)||"children"in n&&P3(n.children))return!0}return!1}function qMe(e){return YMe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?lMe(r.value):!1})?[]:[{type:"paragraph",children:YY(n)}]}}function ovn(e){return YMe(e.children,t,n);function t(r){const i=ZY(e);return i.children=r,[i]}function n(r){if("children"in r&&"children"in e){const i=ZY(e),o=ZY(r);return i.children=r.children,o.children.push(i),o}return{...r}}}function YMe(e,t,n){const r=svn(e),i=[];let o=[],s=-1;for(;++s<r.length;){const a=r[s];KMe(a)?o.push(a):(o.length>0&&(i.push(...t(o)),o=[]),i.push(n(a)))}return o.length>0&&(i.push(...t(o)),o=[]),i}function svn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&P3(r.children)?t.push(...ovn(r)):t.push(r)}return t}function KMe(e){const t=e.data&&e.data.hName;return t?zMe({type:"element",tagName:t,properties:{},children:[]}):ez(e)}function ZY(e){return OY({...e,children:[]})}var QY=Pe((()=>{oMe(),WMe(),dMe(),Hge(),KY()}));function XMe(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let i=String(n.src||""),o=-1,s=!1,a=e.all(t);if(KI({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||P3(a))return a;for(;!i&&++o<t.children.length;){const u=t.children[o];u.type==="element"&&u.tagName==="source"&&u.properties&&(i=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:GP(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(i),children:l};return e.patch(t,c),c}var avn=Pe((()=>{jP(),iL(),QY()}));function JMe(e,t){const n=YY(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var lvn=Pe((()=>{KY()}));function cvn(e,t){const n=e.options.quotes||ZMe;e.qNesting++;const r=e.all(t);e.qNesting--;const i=n[e.qNesting%n.length],o=r[0],s=r[r.length-1],a=i.charAt(0),l=i.length>1?i.charAt(1):i;return o&&o.type==="text"?o.value=a+o.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var ZMe,uvn=Pe((()=>{ZMe=['"']}));function dvn(e,t){let n=e.all(t);(e.options.document||P3(n))&&(n=qMe(n));const r={type:"root",children:n};return e.patch(t,r),r}var fvn=Pe((()=>{QY()}));function hvn(e,t){const n=NMe(t);let r=-1;const i=[];for(;++r<n.length;){const o=n[r];i.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(i.length>0){const o={type:"text",value:i.join(", ")};return e.patch(t,o),o}}var pvn=Pe((()=>{DMe()}));function QMe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var mvn=Pe((()=>{}));function $Me(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,i=t.properties.colSpan;if(r||i){const o=n.data||(n.data={});r&&(o.hastUtilToMdastTemporaryRowSpan=r),i&&(o.hastUtilToMdastTemporaryColSpan=i)}}return n}var gvn=Pe((()=>{}));function yvn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),bvn)};return e.patch(t,n),n}function bvn(){return{type:"tableCell",children:[]}}var vvn=Pe((()=>{}));function wvn(e,t){if(e.inTable){const c={type:"text",value:jE(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=Avn(t),i=e.toSpecificContent(e.all(t),eDe);r&&i.unshift(eDe());let o=-1;for(;++o<i.length;){const c=i[o];c.children=e.toSpecificContent(c.children,Svn)}let s=1;for(o=-1;++o<i.length;){const c=i[o].children;let u=-1;for(;++u<c.length;){const d=c[u];if(d.data){const f=d.data,h=Number.parseInt(String(f.hastUtilToMdastTemporaryColSpan),10)||1,p=Number.parseInt(String(f.hastUtilToMdastTemporaryRowSpan),10)||1;if(h>1||p>1){let m=o-1;for(;++m<o+p;){let g=u-1;for(;++g<u+h&&i[m];){const y=[];(m!==o||g!==u)&&y.push({type:"tableCell",children:[]}),i[m].children.splice(g,0,...y)}}}"hastUtilToMdastTemporaryColSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryRowSpan,Object.keys(d.data).length===0&&delete d.data}}c.length>s&&(s=c.length)}for(o=-1;++o<i.length;){const c=i[o].children;let u=c.length-1;for(;++u<s;)c.push({type:"tableCell",children:[]})}let a=n.length-1;for(;++a<s;)n.push(null);e.inTable=!1;const l={type:"table",align:n,children:i};return e.patch(t,l),l}function Avn(e){const t={align:[null],headless:!0};let n=0,r=0;return KI(e,function(i){if(i.type==="element"){if(i.tagName==="table"&&e!==i)return uge;if((i.tagName==="th"||i.tagName==="td")&&i.properties){if(!t.align[r]){const o=String(i.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(t.align[r]=o)}t.headless&&n<2&&i.tagName==="th"&&(t.headless=!1),r++}else i.tagName==="thead"?t.headless=!1:i.tagName==="tr"&&(n++,r=0)}}),t}function Svn(){return{type:"tableCell",children:[]}}function eDe(){return{type:"tableRow",children:[]}}var xvn=Pe((()=>{qE(),iL()}));function Tvn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var Ivn=Pe((()=>{}));function kvn(e,t){const n={type:"text",value:jE(t)};return e.patch(t,n),n}var Evn=Pe((()=>{qE()}));function Cvn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var _vn=Pe((()=>{}));function ri(e,t){return e.all(t)}function Vs(e,t){return e.toFlow(e.all(t))}function ii(){}var tDe,nDe,Rvn=Pe((()=>{pbn(),gbn(),bbn(),wbn(),Lbn(),Mbn(),Dbn(),Bbn(),Hbn(),zbn(),Vbn(),Gbn(),jbn(),qbn(),Kbn(),nvn(),ivn(),avn(),lvn(),uvn(),fvn(),pvn(),mvn(),gvn(),vvn(),xvn(),Ivn(),Evn(),_vn(),tDe={comment:Nbn,doctype:ii,root:dvn,text:Tvn},nDe={applet:ii,area:ii,basefont:ii,bgsound:ii,caption:ii,col:ii,colgroup:ii,command:ii,content:ii,datalist:ii,dialog:ii,element:ii,embed:ii,frame:ii,frameset:ii,isindex:ii,keygen:ii,link:ii,math:ii,menu:ii,menuitem:ii,meta:ii,nextid:ii,noembed:ii,noframes:ii,optgroup:ii,option:ii,param:ii,script:ii,shadow:ii,source:ii,spacer:ii,style:ii,svg:ii,template:ii,title:ii,track:ii,abbr:ri,acronym:ri,bdi:ri,bdo:ri,big:ri,blink:ri,button:ri,canvas:ri,cite:ri,data:ri,details:ri,dfn:ri,font:ri,ins:ri,label:ri,map:ri,marquee:ri,meter:ri,nobr:ri,noscript:ri,object:ri,output:ri,progress:ri,rb:ri,rbc:ri,rp:ri,rt:ri,rtc:ri,ruby:ri,slot:ri,small:ri,span:ri,sup:ri,sub:ri,tbody:ri,tfoot:ri,thead:ri,time:ri,address:Vs,article:Vs,aside:Vs,body:Vs,center:Vs,div:Vs,fieldset:Vs,figcaption:Vs,figure:Vs,form:Vs,footer:Vs,header:Vs,hgroup:Vs,html:Vs,legend:Vs,main:Vs,multicol:Vs,nav:Vs,picture:Vs,section:Vs,a:hbn,audio:XMe,b:QMe,base:mbn,blockquote:ybn,br:vbn,code:YE,dir:JY,dl:Obn,dt:XY,dd:XY,del:jY,em:R3,h1:uS,h2:uS,h3:uS,h4:uS,h5:uS,h6:uS,hr:Ubn,i:R3,iframe:Wbn,img:LMe,image:LMe,input:Ybn,kbd:YE,li:XY,listing:_3,mark:R3,ol:JY,p:JMe,plaintext:_3,pre:_3,q:cvn,s:jY,samp:YE,select:hvn,strike:jY,strong:QMe,summary:JMe,table:wvn,td:$Me,textarea:kvn,th:$Me,tr:yvn,tt:YE,u:R3,ul:JY,var:YE,video:XMe,wbr:Cvn,xmp:_3}}));function Pvn(e){return{all:Lvn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...nDe,...e.handlers},inTable:!1,nodeHandlers:{...tDe,...e.nodeHandlers},one:Nvn,options:e,patch:Mvn,qNesting:0,resolve:Dvn,toFlow:Ovn,toSpecificContent:Fvn}}function Lvn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const i=t[r],o=this.one(i,e);Array.isArray(o)?n.push(...o):o&&n.push(o)}return n}function Nvn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if($Y.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if($Y.call(this.nodeHandlers,e.type))return this.nodeHandlers[e.type](this,e,t)||void 0;if("value"in e&&typeof e.value=="string"){const n={type:"text",value:e.value};return this.patch(e,n),n}if("children"in e)return this.all(e)}function Mvn(e,t){e.position&&(t.position=ubn(e))}function Dvn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function Ovn(e){return qMe(e)}function Fvn(e,t){const n=t(),r=[];let i=[],o=-1;for(;++o<e.length;){const a=e[o];if(s(a))i.length>0&&(a.children.unshift(...i),i=[]),r.push(a);else{const l=a;i.push(l)}}if(i.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...i),i=[]}return r;function s(a){return a.type===n.type}}var $Y,Bvn=Pe((()=>{fbn(),Rvn(),QY(),$Y={}.hasOwnProperty}));function rDe(e,t){const n=OY(e),r=t||iDe,i=abn({newlines:r.newlines===!0}),o=Pvn(r);let s;i(n),KI(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!o.elementById.has(c)&&o.elementById.set(c,l)}});const a=o.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},KI(s,function(l,c,u){if(l.type==="text"&&c!==void 0&&u){const d=u.children[c-1];if(d&&d.type===l.type)return d.value+=l.value,u.children.splice(c,1),d.position&&l.position&&(d.position.end=l.position.end),c-1;if(l.value=l.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),u&&(u.type==="heading"||u.type==="paragraph"||u.type==="root")&&(c||(l.value=l.value.replace(/^[\t ]+/,"")),c===u.children.length-1&&(l.value=l.value.replace(/[\t ]+$/,""))),!l.value)return u.children.splice(c,1),c}}),s}var iDe,Hvn=Pe((()=>{oMe(),cbn(),iL(),Bvn(),iDe={}})),zvn=Pe((()=>{Hvn()}));function Uvn(e,t){return e&&"run"in e?async function(n,r){const i=rDe(n,{...eK,...t});await e.run(i,r)}:function(n){return rDe(n,{...eK,...e})}}var eK,Vvn=Pe((()=>{zvn(),eK={document:!0}})),Wvn=ls({default:()=>Uvn},1),Gvn=Pe((()=>{Vvn()})),jvn="1.31.0",tK=96,qvn=50,Yvn=20,oDe=e=>{const t=e,n=t?.config,r=t?.constructor;if(!n||typeof n!="object"||typeof r!="function")return e;try{return new r(n)}catch{return e}};function Kvn(e){const t=(e.attrs?.colwidth??[]).reduce((o,s)=>o+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,i=n?.right??0;return Math.max(t-r-i,0)}var Fp=class am extends Xk{#e;#t=null;#i=!1;#n="initialized";#r=null;#o=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#a=null;#c=!1;constructor(t){super(),this.extensionStorage={},this.presentationEditor=null,this.isFocused=!1,this.fontsImported=[],this.options={element:null,selector:null,isHeadless:!1,document:null,mockDocument:null,mockWindow:null,content:"",user:null,users:[],media:{},mediaFiles:{},fonts:{},documentMode:"editing",mode:"docx",role:"editor",colors:[],converter:null,fileSource:null,initialState:null,documentId:null,extensions:[],editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,isCommentsEnabled:!1,isNewFile:!1,scale:1,viewOptions:{layout:"print"},annotations:!1,isInternal:!1,externalExtensions:[],isChildEditor:!1,numbering:{},isHeaderOrFooter:!1,lastSelection:null,suppressDefaultDocxStyles:!1,jsonOverride:null,loadFromSchema:!1,fragment:null,skipViewCreation:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:c})=>{throw c},onTrackedChangesUpdate:()=>null,onCommentsUpdate:()=>null,onCommentsLoaded:()=>null,onCommentClicked:()=>null,onCommentLocationsUpdate:()=>null,onPointerDown:()=>null,onPointerUp:()=>null,onRightClick:()=>null,onDocumentLocked:()=>null,onFirstRender:()=>null,onCollaborationReady:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onFontsResolved:null,handleImageUpload:null,customUpdatedFiles:{},isHeaderFooterChanged:!1,isCustomXmlChanged:!1,ydoc:null,collaborationProvider:null,collaborationIsReady:!1,shouldLoadComments:!1,replacedFile:!1,focusTarget:null,permissionResolver:null,parentEditor:null,licenseKey:void 0,telemetry:{enabled:!0}};const n={...t},r=EA(),i=!!n.isHeadless,o=!!(n.element||n.selector),s=n.document??n.mockDocument??(r?document:null),a=!!(n.html||n.markdown)||(n.mode==="text"||n.mode==="html")&&typeof n.content=="string";if(!s&&a)throw new Error("[super-editor] HTML/Markdown import requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");if(!r&&o&&!i)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!i&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#_(n),this.setOptions(n),this.#t=n.renderer??(r?new ECe:null),this.#s();const{setHighContrastMode:l}=kp();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#k(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#I(),html:()=>this.#I(),default:()=>{console.log("Not implemented.")}};(c[this.options.mode]??c.default)(),this.#n="ready"}}get docChanged(){return this.options.isHeaderFooterChanged||this.options.isCustomXmlChanged||!this.options.initialState.doc.eq(this.state.doc)}#u(t){this.#t?.initContainerElement?.(t)}#d(){return EA()&&!this.options.isHeadless}#f(){return this.options.document??this.options.mockDocument??(EA()?document:null)}#l(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}#s(){const{telemetry:t,licenseKey:n}=this.options;if(typeof process<"u"&&process.env?.VITEST||this.options.mode==="text"||this.options.isHeaderOrFooter||this.options.isChildEditor||!t?.enabled)return;const r=n!==void 0?n:t.licenseKey??"community-and-eval-agplv3";try{this.#a=new cYe({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#w(){this.getDocumentIdentifier().then(t=>{if(!(!this.#a||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()||null;this.#a.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#b(...t){if(!t.includes(this.#n))throw new PEe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#x(t,n,r,i){this.#n=t;try{const o=await i();return this.#n=n,o}catch(o){throw this.#n=r,o}}#k(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?bM():Zy()),this.#L(),this.#v(),this.#H(),this.#T()}#T(){this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#ee.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#m(t,n){try{const r=n?.mode??this.options.mode??"docx",i=n?.isNewFile,o={...this.options,mode:r,isCommentsEnabled:n?.isCommentsEnabled??this.options.isCommentsEnabled,suppressDefaultDocxStyles:n?.suppressDefaultDocxStyles??this.options.suppressDefaultDocxStyles,documentMode:n?.documentMode??this.options.documentMode??"editing",html:n?.html,markdown:n?.markdown,jsonOverride:n?.json??null},s=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const l=a8().readFileSync(t),[c,u,d,f,h]=await am.loadXmlData(l,!0,s);o.content=c,o.mediaFiles=d,o.fonts=f,o.fileSource=h??l,o.isNewFile=i??!1,this.#o=h?null:t}else{const l=await fetch(t);if(!l.ok)throw console.debug("[SuperDoc] Fetch failed:",l.status,l.statusText),new Error(`Fetch failed: ${l.status} ${l.statusText}`);const c=await l.blob(),[u,d,f,h,p]=await am.loadXmlData(c,!1,s);o.content=u,o.mediaFiles=f,o.fonts=h,o.fileSource=p??c,o.isNewFile=i??!1,this.#o=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const l=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),c=typeof Blob<"u"&&t instanceof Blob,u=t instanceof ArrayBuffer,d=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(l||c||u||d){const[f,h,p,m,g]=await am.loadXmlData(t,l,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}else{const[f,h,p,m,g]=await am.loadXmlData(t,!1,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:l,mediaFiles:c,fonts:u,fileSource:d}=await this.#q();o.content=l,o.mediaFiles={...c,...n?.mediaFiles??{}},o.fonts={...u,...n?.fonts??{}},o.fileSource=d,o.isNewFile=i??!0,this.#o=null}else o.content=n?.content??[],o.mediaFiles=n?.mediaFiles??{},o.fonts=n?.fonts??{},o.fileSource=null,o.isNewFile=i??!n?.content,this.#o=null;this.setOptions(o),this.#G(),o3(this),this.#h(),this.#X();const a=this.#d();if(a&&(this.#u(this.options),this.#j()),this.#$({includePlugins:!a}),!a){const l=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(l)}a&&(this.mount(this.options.element),this.#oe()),a||this.#l(),a&&(this.initDefaultStyles(),this.#ie()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#S(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#se(),a&&(this.#fe(),this.#R())}catch(r){if(r instanceof Go)throw console.debug("[SuperDoc] Document load error:",r.message),r;const i=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",i.message),new MEe(`Failed to load document: ${i.message}`,i)}}#y(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=pp(this);t&&(t.state={...cae},t.initialized=!1,t.editableBaseline=null),this.#o=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this._state=void 0}#h(){const t=pp(this);t&&(t.state=My(this.converter?Gd(this.converter):null),t.initialized=!0)}#S(){const t=pp(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#L(),this.#v(),this.#H(),this.#G(),o3(this),this.#h(),this.#X(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();if(this.#$({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(n)}t&&(this.#u(this.options),this.#j(),this.mount(this.options.element),this.#oe()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#ee.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#ie()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#S(),!this.options.ydoc&&!this.options.isChildEditor&&this.#se(),t&&(this.#fe(),this.#R())}#I(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Zy()),this.#L(),this.#v(),this.#H(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();this.#$({includePlugins:!t}),t&&(this.#u(this.options),this.mount(this.options.element),this.#oe()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l()}mount(t){this.#K(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#A({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#_(t){t.isHeadless&&(typeof navigator>"u"&&(global.navigator={platform:"node",userAgent:"Node.js"}),t.mockDocument&&(console.warn("[super-editor] `mockDocument` is deprecated and will be removed in a future version. Use `document` instead (e.g., `new Editor({ document: jsdomDocument })`). See https://docs.superdoc.dev/guide/headless for migration guidance."),global.document=t.mockDocument),t.mockWindow&&(console.warn("[super-editor] `mockWindow` is deprecated and will be removed in a future version. Prefer passing `document` only. Global window assignment is no longer required for headless mode."),global.window=t.mockWindow))}isWebLayout(){return this.options.viewOptions?.layout==="web"}focus(){this.view?.focus()}get state(){return this._state}get lifecycleState(){return this.#n}get sourcePath(){return this.#o}setState(t){this._state=t,this.view&&!this.view.isDestroyed&&this.view.updateState(t)}get storage(){return this.extensionStorage}get commands(){return this.#e?.commands}get doc(){return this.#b("ready","saving"),this.#r||(this.#r=fst(vmn(this))),this.#r}#g(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#b("ready","saving");const n=dLe(this);return Kwe(this,n,t??this.#g())}captureEffectiveSelectionHandle(t){this.#b("ready","saving");const n=fLe(this);return Kwe(this,n,t??this.#g())}resolveSelectionHandle(t){this.#b("ready","saving");const n=$Dt(t);return n?Xq(t._owner,n):null}releaseSelectionHandle(t){this.#b("ready","saving"),e3t(t)}getCurrentSelectionRange(){return this.#b("ready","saving"),xmn(this)}getEffectiveSelectionRange(){return this.#b("ready","saving"),Tmn(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#i||this.view?.isDestroyed)}get element(){return this.options.element}get users(){return this.options.users}chain(){return this.#e.chain()}can(){return this.#e.can()}setDocumentMode(t,n){if(this.options.isHeaderOrFooter||this.options.isChildEditor)return;let r=t?.toLowerCase()||"editing";if(!this.extensionService||!this.state)return;const i=this.view?.dom||this.options.element?.querySelector?.(".ProseMirror");if(this.options.role==="viewer"&&(r="viewing"),this.options.role==="suggester"&&r==="editing"&&(r="suggesting"),r==="viewing"){this.commands.toggleTrackChangesShowOriginal?.();const o=x0e(this.state);o&&this.view?.dispatch(this.state.tr.setSelection(o)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),i&&i.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),i&&i.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),i&&i.classList.remove("view-mode"));Ow(this),this.emit("documentModeChange",{editor:this,documentMode:r})}blur(){this.view?.dom?.blur()}hasFocus(){return this.view?this.view.hasFocus():!1}coordsAtPos(t){return this.presentationEditor?this.presentationEditor.coordsAtPos(t):this.view?this.view.coordsAtPos(t):null}getElementAtPos(t,n={}){if(this.presentationEditor)return this.presentationEditor.getElementAtPos(t,n);if(!this.view||!Number.isFinite(t))return null;const r=this.view.state.doc.content.size,i=Math.max(0,Math.min(t,r));try{const{node:o}=this.view.domAtPos(i);return o&&o.nodeType===1?o:o&&o.nodeType===3?o.parentElement:o?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,i=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(i)){const o=this.presentationEditor.hitTest(r,i);if(o)return{pos:o.pos,inside:o.pos}}}return this.view?this.view.posAtCoords(t):null}#R(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await K3t(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||jw(this.options.collaborationProvider,()=>{this.#P()})}replaceContent(t){this.setOptions({content:t}),this.#G(),this.initDefaultStyles(),this.#G(),o3(this),this.#X();const n=this.#Z(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#B(r)}#D(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},i=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(i.size===0)return;const o=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of i){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;o(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#B(s)}#P(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#Z(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#B(r);const i=this.options.ydoc;i&&i.getMap("meta").set("bodySectPr",n),this.#D(t.attrs??{}),setTimeout(()=>{this.#se()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},i=Object.getOwnPropertyDescriptors(n);for(const[o,s]of Object.entries(i))s.enumerable||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(r,o,s);this.options=r,(this.options.isNewFile||!this.options.ydoc)&&this.options.isCommentsEnabled&&(this.options.shouldLoadComments=!0),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t=!0,n=!0){this.setOptions({editable:t}),this.view&&(this.view.setProps({}),!t&&this.view.dom&&this.view.dom.blur()),n&&this.state&&this.emit("update",{editor:this,transaction:this.state.tr})}registerPlugin(t,n){if(this.isDestroyed||!this.state?.plugins)return;const r=typeof n=="function"?n(t,[...this.state.plugins]):[...this.state.plugins,t];this._state=this.state.reconfigure({plugins:r}),this.view?.updateState(this._state)}#E(t){const n=t.key;return typeof n?.key=="string"?n.key:""}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t?.key??"";this._state=this.state.reconfigure({plugins:this.state.plugins.filter(r=>!this.#E(r).startsWith(n))}),this.view?.updateState(this._state)}attachCollaboration({ydoc:t,collaborationProvider:n}){if(this.isDestroyed)throw new Error("[super-editor] Cannot attach collaboration to a destroyed editor");if(this.options.ydoc)throw new Error("[super-editor] Editor already has collaboration attached");if(this.options.isHeadless)throw new Error("[super-editor] attachCollaboration is not supported in headless mode");const r=this.options.collaborationProvider,i=this.options.shouldLoadComments,o=this.options.collaborationIsReady,s=this._state,a=()=>{SAe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=i,this.options.collaborationIsReady=o,this._state=s,this.view?.updateState(s)};this.options.ydoc=t,this.options.collaborationProvider=n,this.options.shouldLoadComments=!1;let l;try{l=[...this.extensionService.plugins]}catch(c){throw a(),c}try{this._state=this.state.reconfigure({plugins:l}),this.view?.updateState(this._state)}catch(c){throw a(),c}}#L(){const t=["extension","node","mark"],n=[tYt,Kqt,nYt,Jqt,rYt,iYt],r=this.options.externalExtensions||[],i=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>oDe(s)),o=r.map(s=>oDe(s));this.extensionService=sYt.create(i,o,this)}#v(){this.#e=ghe.create({editor:this})}#G(){this.options.converter?this.converter=this.options.converter:this.converter=new ju({docx:this.options.content,media:this.options.mediaFiles,fonts:this.options.fonts,debug:!0,fileSource:this.options.fileSource,documentId:this.options.documentId,mockWindow:this.options.mockWindow??null,mockDocument:this.options.mockDocument??null,isNewFile:this.options.isNewFile??!1,trackedChangesOptions:this.options.trackedChanges??null})}async#q(){const t=await jie(sXt),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let i;if(n)i=Buffer.from(r);else if(typeof Blob<"u")i=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[o,s,a,l]=await am.loadXmlData(i,n);return{content:o,mediaFiles:a,fonts:l,fileSource:i}}async#Y(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#q();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#X(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#j(){this.#t?.initFonts?.(this)}async#ie(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#V(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#V(t){return t.filter(n=>{const r=lKt(n),i=this.fontsImported.includes(n);return!r&&!i})}static async loadXmlData(t,n=!1,r){if(!t)return;const i=new TG;return[await i.getDocxData(t,n,{password:r?.password}),i.media,i.mediaFiles,i.fonts,i.decryptedFileData]}static getDocumentVersion(t){return ju.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=ju.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return ju.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),am.setDocumentVersion(t,n)}async getSchemaSummaryJSON(){if(!this.schema)throw new Error("Schema is not initialized.");const t=this.converter?.getSuperdocVersion?.()||"current",n=new Set((this.extensionService?.extensions||[]).filter(i=>!!i?.config?.excludeFromSummaryJSON).map(i=>i.name)),r=DKt(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(i=>!n.has(i.name)),marks:r.marks.filter(i=>!n.has(i.name))}:r}validateJSON(t){if(!this.schema)throw new Error("Schema is not initialized.");try{return Array.isArray(t)?t.map(n=>this.schema.nodeFromJSON(n)):this.schema.nodeFromJSON(t)}catch(n){const r=n instanceof Error?n.message:String(n),i=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(i.cause=n),i}}#H(){this.schema=this.extensionService.schema}#Z(){let t;try{const{mode:n,content:r,fragment:i,loadFromSchema:o}=this.options,s=this.#f(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?o&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#N(t)):(t=Ade(this.converter,this.schema,this),t=this.#N(t),this.options.markdown?t=gz(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=BI(this.options.html,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.jsonOverride&&(t=this.schema.nodeFromJSON(this.options.jsonOverride)),i&&(t=Ygt(i,this.schema))):(n==="text"||n==="html")&&(o&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=BI(r,this,{document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):t=this.schema.topNodeType.createAndFill())}catch(n){console.error(n);const r=n instanceof Error?n:new Error(String(n));this.emit("contentError",{editor:this,error:r})}return t}#$({includePlugins:t=!1}={}){if(this._state)return;const n=this.#Z(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let i=KR.create(r);t&&(i=i.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=i,this._state=i}#oe(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#K(t){if(this._state||this.#$(),!this.#t){if(!EA())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new ECe}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#B.bind(this),state:this.state,handleClick:this.#Q.bind(this)}),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){if(!this.converter)return{};let t=0;const{$head:n}=this.state.selection;for(let p=n.depth;p>0;p--){const m=n.node(p);if(m.type.name==="tableCell"||m.type.name==="tableHeader"){t=Kvn(m);break}}if(this.isWebLayout())return t>0?{width:t,height:1/0}:{};const{pageSize:r={},pageMargins:i={}}=this.converter.pageStyles??{},{width:o,height:s}=r;if(!o||!s)return{};const a=p=>(i?.[p]??0)*tK,l=a("top"),c=a("bottom"),u=a("left"),d=a("right"),f=s*tK-l-c-qvn,h=o*tK-u-d-Yvn;return t>0?{width:t,height:f}:{width:h,height:f}}updateEditorStyles(t,n){this.#t?.updateEditorStyles?.(this,t,n)}initDefaultStyles(t=this.element){this.options.isHeadless||this.options.suppressDefaultDocxStyles||this.#t?.initDefaultStyles?.(this,t)}initMobileStyles(t){this.#t?.initMobileStyles?.(this,t)}#ee({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#te(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#B(r),this.options.isNewFile||this.#se()}#se(){if(!this.options.isCommentsEnabled||!this.options.shouldLoadComments||!this.converter)return;const t=this.options.replacedFile;this.emit("commentsLoaded",{editor:this,replacedFile:t,comments:this.converter.comments||[]}),this.options.replacedFile=!1,!this.options.isHeadless&&setTimeout(()=>{const n=this.state;if(!n)return;const r=n.tr.setMeta(Yi,{type:"force"});this.#B(r)},50)}#B(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),i=r(),o=this.state;let s,a=t;const l=a.getMeta("forceTrackChanges")===!0;try{const h=Qi.getState(o)?.isTrackChangesActive??!1,p=a.getMeta("skipTrackChanges")===!0,m=(h||l)&&!p;if(m&&l&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");a=m?qTe({tr:a,state:o,user:this.options.user,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:g}=o.applyTransaction(a);s=g}catch(h){if(l)throw h;s=o.apply(a),console.log(h)}const c=!o.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const u=r();this.emit("transaction",{editor:this,transaction:a,duration:u-i}),c&&this.emit("selectionUpdate",{editor:this,transaction:a});const d=a.getMeta("focus");d&&this.emit("focus",{editor:this,event:d.event,transaction:a});const f=a.getMeta("blur");f&&this.emit("blur",{editor:this,event:f.event,transaction:a}),a.docChanged&&(t.docChanged&&this.converter&&(this.converter.documentGuid||(this.converter.promoteToGuid(),console.debug("Document modified - assigned GUID:",this.converter.documentGuid)),this.converter.documentModified=!0),this.emit("update",{editor:this,transaction:a}))}dispatch(t){this.#B(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return cn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,i=typeof t=="string"?n:t;return xde(this.state,r,i)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,i=this.converter;i&&i.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=i.bodySectPr)}catch{}return t}getMetadata(){return{documentGuid:this.converter?.documentGuid||null,isModified:this.isDocumentModified(),version:this.converter?.getSuperdocVersion()||null}}getHTML({unflattenLists:t=!1}={}){const n=this.#f();if(!n)throw new Error("[super-editor] getHTML() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const r=n.createElement("div"),i=Cf.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(i);let o=r.innerHTML;return t&&(o=Cpe(o,n)),o}async getMarkdown(){const t=this.#f();if(!t)throw new Error("[super-editor] getMarkdown() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const n=globalThis,r=n.document===void 0,i=r?{document:n.document,window:n.window,navigatorDescriptor:Object.getOwnPropertyDescriptor(globalThis,"navigator")}:null;r&&(n.document=t,!n.window&&t.defaultView&&(n.window=t.defaultView),!n.navigator&&t.defaultView?.navigator&&(n.navigator=t.defaultView.navigator));try{const[{unified:o},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(RH(),Zbt)),Promise.resolve().then(()=>(Cyn(),Eyn)),Promise.resolve().then(()=>(Gvn(),Wvn)),Promise.resolve().then(()=>(l_e(),EZt)),Promise.resolve().then(()=>(dz(),UTt))]),u=this.getHTML(),d=o().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{i&&(i.document===void 0?delete n.document:n.document=i.document,i.window===void 0?delete n.window:n.window=i.window,i.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",i.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return pKt(this,t)}getPageStyles(){return this.converter?.pageStyles||{}}updatePageStyle({pageMargins:t}){if(!this.converter)return;let n=!1;if(t&&(this.converter.pageStyles.pageMargins=t,this.initDefaultStyles(),n=!0),n&&this.view&&!Wy()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#B(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#Q(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return aKt(t,n)}#N(t){const n=KR.create({schema:this.schema,doc:t}),{tr:r,doc:i}=n;return hFt(i,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:cKt(this)}#he(t=[]){const n=this.state.doc,r=new R7(n);return fFt(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#he()}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:i=!1,comments:o,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{TMt(By(this));const c=(o??this.converter.comments??[]).map(fe=>{const ee=Array.isArray(fe.elements)&&fe.elements.length?fe.elements:void 0;return{...fe,commentJSON:fe.commentJSON??ee}}),u=this.#he(c),d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#ue(),i||r)return d;const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],w=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,x=this.converter.convertedXml["word/endnotes.xml"],S=x?.elements?.[0]?this.converter.schemaToXml(x.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],k=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,C=this.converter.convertedXml["word/_rels/settings.xml.rels"],_=C?.elements?.[0]?this.converter.schemaToXml(C.elements[0]):null,P=this.converter.addedMedia,E={};Object.entries(this.converter.convertedXml).forEach(([fe,ee])=>{if(fe.includes("header")||fe.includes("footer")){const Z=ee,re=this.converter.schemaToXml(Z.elements?.[0]);E[fe]=String(re.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=this.converter.schemaToXml(L.elements[0]),O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,B=this.converter.convertedXml["docProps/core.xml"],j=B?.elements?.[0]?this.converter.schemaToXml(B.elements[0]):null,M={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),"word/numbering.xml":String(R),"word/styles.xml":String(h),...E,...F?{"docProps/app.xml":String(F)}:{},...j?{"docProps/core.xml":String(j)}:{}};if(p){let fe=String(m);_?M["word/_rels/settings.xml.rels"]=String(_):/<\w+:attachedTemplate\b/i.test(fe)&&(fe=fe.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=fe}v&&(M["word/footnotes.xml"]=String(v)),w&&(M["word/_rels/footnotes.xml.rels"]=String(w)),S&&(M["word/endnotes.xml"]=String(S)),k&&(M["word/_rels/endnotes.xml.rels"]=String(k));const z=tU.map(fe=>`word/${fe}`);for(const fe of z){const ee=this.converter.convertedXml[fe];ee?.elements?.[0]?M[fe]=String(this.converter.schemaToXml(ee.elements[0])):M[fe]=null}const $=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const fe of $){const ee=this.converter.convertedXml[fe];ee?.elements?.[0]&&(M[fe]=String(this.converter.schemaToXml(ee.elements[0])))}for(const fe of Object.keys(this.converter.convertedXml)){if(!fe.startsWith("customXml/")||!fe.endsWith(".xml")&&!fe.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,fe))continue;const ee=this.converter.convertedXml[fe];ee?.elements?.[0]&&(M[fe]=String(this.converter.schemaToXml(ee.elements[0])))}const K=new TG;if(s){M["[Content_Types].xml"]=await K.updateContentTypes({files:this.options.content},P,!0,M,this.options.fonts);const fe=this.options.content,{contentTypesXml:ee,relsXml:Z}=YEe({baseFiles:Array.isArray(fe)||fe&&typeof fe=="object"?fe:null,updatedDocs:M});return M["[Content_Types].xml"]=ee,M["_rels/.rels"]=Z,M}const U=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#Y():this.options.content;return await K.updateZip({docx:U,updatedDocs:M,originalDocxFile:this.options.fileSource,media:P,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#pe(){if(this.options.ydoc)try{console.debug("🔗 [super-editor] Ending collaboration"),this.options.collaborationProvider?.disconnect?.(),this.options.ydoc.destroy()}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}async open(t,n){this.#b("initialized","closed"),await this.#x("documentLoading","ready","closed",async()=>{await this.#m(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#o})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p,...m}=r,g={mode:r.mode,html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p},y=new am({...m,deferDocumentLoad:!0});return await y.open(t,g),y}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#b("ready"),this.emit("documentClose",{editor:this}),this.#y(),this.#r=null,this.#n="closed")}async save(t){if(this.#b("ready"),!this.#o)throw new LEe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#x("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#M(this.#o,n)})}async saveTo(t,n){this.#b("ready"),await this.#x("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#M(t,r),this.#o=t})}async exportDocument(t){return this.#b("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#M(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,i=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||i)try{const o=a8(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());o.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const o=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await o.write(n),await o.close();return}throw new NEe("File System Access API not available. Use exportDocument() to get the document data and handle the download manually.")}destroy(){this.#n==="ready"&&this.close(),this.#n!=="destroyed"&&(this.#i=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#pe(),this.removeAllListeners(),this.extensionService=void 0,this.schema=void 0,this.#e=void 0,this.#r=null,this.#n="destroyed")}destroyHeaderFooterEditors(){try{const t=this.converter?.headerEditors??[],n=this.converter?.footerEditors??[];if(!t.length&&!n.length)return;const r=[...t,...n].filter(Boolean);for(const i of r)i?.editor?.destroy?.();t.length&&(t.length=0),n.length&&(n.length=0)}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}static checkIfMigrationsNeeded(){const t=version??"initial",n=OEe(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",jvn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=OEe(t)||[],r=this.state.plugins.find(o=>this.#E(o).startsWith("y-sync"));if(!r)return this.options.ydoc;let i=!1;for(const o of n)if(console.debug("🏃‍♂️ Running migration",o.name),o(this))i=!0;else throw new Error("Migration failed at "+o.name);if(i)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,i,o,s,a]=await am.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:i,mediaFiles:o,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#G(),o3(this),this.#X(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#P(),bN(this,l,{replaceExisting:!0});const f=this.options.mediaFiles??{},h=l.getMap("media");for(const p of h.keys())p in f||h.delete(p);Object.entries(f).forEach(([p,m])=>{h.set(p,m)})},d=1e4;await new Promise((f,h)=>{let p,m=!1;const g=jw(c,()=>{if(!m){m=!0,clearTimeout(p);try{u(),f()}catch(y){h(y)}}});m||(p=setTimeout(()=>{m=!0,g(),h(new Error(`replaceFile(): collaboration provider did not sync within ${d}ms. The provider exposes on/off but never emitted sync(true) or synced.`))},d))})}else this.#P();this.options.ydoc||this.#se()}getInternalXmlFile(t,n="json"){return this.converter.convertedXml[t]?n==="json"?this.converter.convertedXml[t].elements[0]||null:this.converter.schemaToXml(this.converter.convertedXml[t].elements[0]):(console.warn("Cannot find file in docx"),null)}updateInternalXmlFile(t,n){if(typeof n=="string")this.options.customUpdatedFiles[t]=String(n);else{const r=this.converter.schemaToXml(n);this.options.customUpdatedFiles[t]=String(r)}this.options.isCustomXmlChanged=!0}getNodesOfType(t){const{findChildren:n}=wz;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const i=t.pos,o=i+t.node.nodeSize,s=BI(n,this);r.replaceWith(i,o,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=WN.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await hKt(t,this)}annotate(t=[],n=[],r=!1){const{state:i,schema:o}=this;let s=i.tr;if(s=WN.processTables({state:this.state,tr:s,annotationValues:t}),s=WN.annotateDocument({tr:s,schema:o,annotationValues:t,hiddenFieldIds:n,removeEmptyFields:r,editor:this}),s.docChanged){const a=s.scrollIntoView();this.dispatch(a)}}previewAnnotations(t=[],n=[]){this.originalState=this.state,this.annotate(t,n)}closePreview(){this.originalState&&(this.view?this.view.updateState(this.originalState):this._state=this.originalState)}#te(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ACe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#ue(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ACe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#fe(){this.#t?.initDevTools?.(this)}},Og=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),Fg={EXT:Og("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:Og("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:Og("--sd-comments-highlight-external-faded","#B1124B20"),INT:Og("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:Og("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:Og("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:Og("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:Og("--sd-comments-highlight-internal-nested-border","#07838399")},L3="track-change-focused",sDe=".superdoc-comment-highlight",Xvn="[data-track-change-id]";function aDe(e){return e?e.split(",").filter(Boolean):[]}function Jvn(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const r=n.indexOf("=");r>0&&t.set(n.slice(0,r),n.slice(r+1))}return t}function lDe(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function nK(e,t){lDe(e,"backgroundColor",t.css,t.fallback)}function Zvn(e,t){lDe(e,"boxShadow",`inset 1px 0 0 ${t.css}, inset -1px 0 0 ${t.css}`,`inset 1px 0 0 ${t.fallback}, inset -1px 0 0 ${t.fallback}`)}var Qvn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#i(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(sDe);for(let r=0;r<t.length;r++){const i=t[r];i.style.backgroundColor="",i.style.boxShadow=""}const n=e.querySelectorAll(`.${L3}`);for(let r=0;r<n.length;r++)n[r].classList.remove(L3)}#i(e){const t=this.#e,n=e.querySelectorAll(sDe);for(let r=0;r<n.length;r++){const i=n[r],o=aDe(i.dataset.commentIds);if(o.length===0)continue;const s=new Set(aDe(i.dataset.commentInternalIds)),a=s.has(o[0]);if(t==null){nK(i,a?Fg.INT:Fg.EXT),i.style.boxShadow="";continue}const l=this.#n(t,o,i.dataset.commentImportedIds);if(l!=null){const c=s.has(l);nK(i,c?Fg.INT_ACTIVE:Fg.EXT_ACTIVE),o.length>1?Zvn(i,c?Fg.INT_NESTED_BDR:Fg.EXT_NESTED_BDR):i.style.boxShadow=""}else nK(i,a?Fg.INT_FADED:Fg.EXT_FADED),i.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=Jvn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(Xvn);for(let r=0;r<n.length;r++){const i=n[r];t&&i.dataset.trackChangeId===t?i.classList.add(L3):i.classList.remove(L3)}}},$vn=[Qi,Yi,Tk,dg,oA,lM],ewn=new Set([...$vn]),twn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],rK=`
355
+ `:EMe(e)?(a=2,l=2):GY(e)&&(a=1,l=1);++o<i.length;)s=s.concat(TMe(i[o],e,{whitespace:r,breakBefore:o?void 0:a,breakAfter:o<i.length-1?C3(i[o+1]):l}));return VY(e)&&HY(t,e,VY)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function IMe(e,t){const n=String(e.value),r=[],i=[];let o=0;for(;o<=n.length;){zY.lastIndex=o;const l=zY.exec(n),c=l&&"index"in l?l.index:n.length;r.push(Ibn(n.slice(o,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),o===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),o=c+1}let s=-1,a;for(;++s<r.length;)r[s].charCodeAt(r[s].length-1)===8203||s<r.length-1&&r[s+1].charCodeAt(0)===8203?(i.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&i.push(a),i.push(r[s]),a=0):(s===0||s===r.length-1)&&i.push(0);return i}function Tbn(e){return[String(e.value)]}function Ibn(e,t,n){const r=[];let i=0,o;for(;i<e.length;){UY.lastIndex=i;const s=UY.exec(e);o=s?s.index:e.length,!i&&!o&&s&&!t&&r.push(""),i!==o&&r.push(e.slice(i,o)),i=s?o+s[0].length:o}return i!==o&&!n&&r.push(""),r.join(" ")}function kMe(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap";default:}}return t.whitespace}function kbn(e){return!!(e.properties||{}).hidden}function Ebn(e){return e.tagName==="td"||e.tagName==="th"}function Cbn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var zY,UY,C3,VY,EMe,WY,CMe,GY,_bn=Pe((()=>{Sbn(),k3(),zY=/\n/g,UY=/[\t ]+/g,C3=Qu("br"),VY=Qu(Ebn),EMe=Qu("p"),WY=Qu("tr"),CMe=Qu(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",kbn,Cbn]),GY=Qu(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"])})),qE=Pe((()=>{_bn()}));function Rbn(e){const t=String(e);let n=t.length;for(;n>0;){const r=t.codePointAt(n-1);if(r!==void 0&&(r===10||r===13))n--;else break}return t.slice(0,n)}var Pbn=Pe((()=>{}));function _3(e,t){const n=t.children;let r=-1,i,o;if(t.tagName==="pre")for(;++r<n.length;){const a=n[r];if(a.type==="element"&&a.tagName==="code"&&a.properties&&a.properties.className&&Array.isArray(a.properties.className)){i=a.properties.className;break}}if(i){for(r=-1;++r<i.length;)if(String(i[r]).slice(0,9)===_Me){o=String(i[r]).slice(9);break}}const s={type:"code",lang:o||null,meta:null,value:Rbn(jE(t))};return e.patch(t,s),s}var _Me,Lbn=Pe((()=>{qE(),Pbn(),_Me="language-"}));function Nbn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var Mbn=Pe((()=>{}));function jY(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var Dbn=Pe((()=>{}));function qY(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var RMe=Pe((()=>{}));function Obn(e,t){const n=[],r=[];let i=-1;for(;++i<t.children.length;){const a=t.children[i];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let o={definitions:[],titles:[]};for(i=-1;++i<n.length;){const a=n[i];if(a.type==="element"&&a.tagName==="dt"){const l=n[i-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(o),o={definitions:[],titles:[]}),o.titles.push(a)}else o.definitions.push(a)}r.push(o),i=-1;const s=[];for(;++i<r.length;){const a=[...PMe(e,r[i].titles),...PMe(e,r[i].definitions)];a.length>0&&s.push({type:"listItem",spread:a.length>1,checked:null,children:a})}if(s.length>0){const a={type:"list",ordered:!1,start:null,spread:qY(s),children:s};return e.patch(t,a),a}}function PMe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,Fbn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:qY(r),children:r}]}function Fbn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var Bbn=Pe((()=>{RMe()}));function R3(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var Hbn=Pe((()=>{}));function YY(e){let t=0,n=e.length;for(;t<n&&e[t].type==="break";)t++;for(;n>t&&e[n-1].type==="break";)n--;return t===0&&n===e.length?e:e.slice(t,n)}var KY=Pe((()=>{}));function uS(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:YY(e.all(t))};return e.patch(t,n),n}var zbn=Pe((()=>{KY()}));function Ubn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var Vbn=Pe((()=>{}));function Wbn(e,t){const n=t.properties||{},r=String(n.src||""),i=String(n.title||"");if(r&&i){const o={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:i}]};return e.patch(t,o),o}}var Gbn=Pe((()=>{}));function LMe(e,t){const n=t.properties||{},r={type:"image",url:e.resolve(String(n.src||"")||null),title:n.title?String(n.title):null,alt:n.alt?String(n.alt):""};return e.patch(t,r),r}var jbn=Pe((()=>{}));function YE(e,t){const n={type:"inlineCode",value:jE(t)};return e.patch(t,n),n}var qbn=Pe((()=>{qE()}));function NMe(e,t){const n=[],r=[],i=t||e.properties||{},o=MMe(e),s=Math.min(Number.parseInt(String(i.size),10),0)||(i.multiple?4:1);let a=-1;for(;++a<o.length;){const u=o[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:o,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=jE(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function MMe(e){const t=[];let n=-1;for(;++n<e.children.length;){const r=e.children[n];"children"in r&&Array.isArray(r.children)&&t.push(...MMe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var DMe=Pe((()=>{qE()}));function Ybn(e,t){const n=t.properties||{},r=String(n.value||n.placeholder||"");if(n.disabled||n.type==="hidden"||n.type==="file")return;if(n.type==="checkbox"||n.type==="radio"){const l={type:"text",value:n.checked?e.options.checked||OMe:e.options.unchecked||FMe};return e.patch(t,l),l}if(n.type==="image"){const l=n.alt||r;if(l){const c={type:"image",url:e.resolve(String(n.src||"")||null),title:String(n.title||"")||null,alt:String(l)};return e.patch(t,c),c}return}let i=[];if(r)i=[[r,void 0]];else if(n.type!=="button"&&n.type!=="file"&&n.type!=="password"&&n.type!=="reset"&&n.type!=="submit"&&n.list){const l=String(n.list),c=e.elementById.get(l);c&&c.tagName==="datalist"&&(i=NMe(c,n))}if(i.length===0)return;if(n.type==="password"&&(i[0]=["•".repeat(i[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<i.length;){const u=e.resolve(i[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:i[c][1]||u}]};l.push(d),c!==i.length-1&&l.push({type:"text",value:", "})}return l}const o=[];let s=-1;for(;++s<i.length;)o.push(i[s][1]?i[s][1]+" ("+i[s][0]+")":i[s][0]);const a={type:"text",value:o.join(", ")};return e.patch(t,a),a}var OMe,FMe,Kbn=Pe((()=>{DMe(),OMe="[x]",FMe="[ ]"}));function Xbn(e,t){const n=e.type==="element"&&BMe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var BMe,Jbn=Pe((()=>{BMe={}.hasOwnProperty})),Zbn=Pe((()=>{Jbn()}));function Qbn(e){if(e.type!=="element"||e.tagName!=="link")return!1;if(e.properties.itemProp)return!0;const t=e.properties.rel;let n=-1;if(!Array.isArray(t)||t.length===0)return!1;for(;++n<t.length;)if(!HMe.has(String(t[n])))return!1;return!0}var HMe,$bn=Pe((()=>{HMe=new Set(["pingback","prefetch","stylesheet"])})),evn=Pe((()=>{$bn()}));function zMe(e){return!!(e.type==="text"||UMe(e)||BY(e)||Qbn(e)||VMe(e)&&Xbn(e,"itemProp"))}var UMe,VMe,tvn=Pe((()=>{aMe(),Zbn(),evn(),k3(),UMe=Qu(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),VMe=Qu("meta")})),WMe=Pe((()=>{tvn()}));function XY(e,t){const{rest:n,checkbox:r}=jMe(t),i=r?!!r.properties.checked:null,o={type:"listItem",spread:GMe(n),checked:i,children:e.toFlow(e.all(n))};return e.patch(t,o),o}function GMe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(zMe(r))continue;if(r.tagName==="p"||n||GMe(r))return!0;n=!0}}return!1}function jMe(e){const t=e.children[0];if(t&&t.type==="element"&&t.tagName==="input"&&t.properties&&(t.properties.type==="checkbox"||t.properties.type==="radio"))return{checkbox:t,rest:{...e,children:e.children.slice(1)}};if(t&&t.type==="element"&&t.tagName==="p"){const{checkbox:n,rest:r}=jMe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var nvn=Pe((()=>{WMe()}));function JY(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),rvn);let i=null;n&&(i=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const o={type:"list",ordered:n,start:i,spread:qY(r),children:r};return e.patch(t,o),o}function rvn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var ivn=Pe((()=>{RMe()}));function P3(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!KMe(n)||"children"in n&&P3(n.children))return!0}return!1}function qMe(e){return YMe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?lMe(r.value):!1})?[]:[{type:"paragraph",children:YY(n)}]}}function ovn(e){return YMe(e.children,t,n);function t(r){const i=ZY(e);return i.children=r,[i]}function n(r){if("children"in r&&"children"in e){const i=ZY(e),o=ZY(r);return i.children=r.children,o.children.push(i),o}return{...r}}}function YMe(e,t,n){const r=svn(e),i=[];let o=[],s=-1;for(;++s<r.length;){const a=r[s];KMe(a)?o.push(a):(o.length>0&&(i.push(...t(o)),o=[]),i.push(n(a)))}return o.length>0&&(i.push(...t(o)),o=[]),i}function svn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&P3(r.children)?t.push(...ovn(r)):t.push(r)}return t}function KMe(e){const t=e.data&&e.data.hName;return t?zMe({type:"element",tagName:t,properties:{},children:[]}):ez(e)}function ZY(e){return OY({...e,children:[]})}var QY=Pe((()=>{oMe(),WMe(),dMe(),Hge(),KY()}));function XMe(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let i=String(n.src||""),o=-1,s=!1,a=e.all(t);if(KI({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||P3(a))return a;for(;!i&&++o<t.children.length;){const u=t.children[o];u.type==="element"&&u.tagName==="source"&&u.properties&&(i=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:GP(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(i),children:l};return e.patch(t,c),c}var avn=Pe((()=>{jP(),iL(),QY()}));function JMe(e,t){const n=YY(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var lvn=Pe((()=>{KY()}));function cvn(e,t){const n=e.options.quotes||ZMe;e.qNesting++;const r=e.all(t);e.qNesting--;const i=n[e.qNesting%n.length],o=r[0],s=r[r.length-1],a=i.charAt(0),l=i.length>1?i.charAt(1):i;return o&&o.type==="text"?o.value=a+o.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var ZMe,uvn=Pe((()=>{ZMe=['"']}));function dvn(e,t){let n=e.all(t);(e.options.document||P3(n))&&(n=qMe(n));const r={type:"root",children:n};return e.patch(t,r),r}var fvn=Pe((()=>{QY()}));function hvn(e,t){const n=NMe(t);let r=-1;const i=[];for(;++r<n.length;){const o=n[r];i.push(o[1]?o[1]+" ("+o[0]+")":o[0])}if(i.length>0){const o={type:"text",value:i.join(", ")};return e.patch(t,o),o}}var pvn=Pe((()=>{DMe()}));function QMe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var mvn=Pe((()=>{}));function $Me(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,i=t.properties.colSpan;if(r||i){const o=n.data||(n.data={});r&&(o.hastUtilToMdastTemporaryRowSpan=r),i&&(o.hastUtilToMdastTemporaryColSpan=i)}}return n}var gvn=Pe((()=>{}));function yvn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),bvn)};return e.patch(t,n),n}function bvn(){return{type:"tableCell",children:[]}}var vvn=Pe((()=>{}));function wvn(e,t){if(e.inTable){const c={type:"text",value:jE(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=Avn(t),i=e.toSpecificContent(e.all(t),eDe);r&&i.unshift(eDe());let o=-1;for(;++o<i.length;){const c=i[o];c.children=e.toSpecificContent(c.children,Svn)}let s=1;for(o=-1;++o<i.length;){const c=i[o].children;let u=-1;for(;++u<c.length;){const d=c[u];if(d.data){const f=d.data,h=Number.parseInt(String(f.hastUtilToMdastTemporaryColSpan),10)||1,p=Number.parseInt(String(f.hastUtilToMdastTemporaryRowSpan),10)||1;if(h>1||p>1){let m=o-1;for(;++m<o+p;){let g=u-1;for(;++g<u+h&&i[m];){const y=[];(m!==o||g!==u)&&y.push({type:"tableCell",children:[]}),i[m].children.splice(g,0,...y)}}}"hastUtilToMdastTemporaryColSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in d.data&&delete d.data.hastUtilToMdastTemporaryRowSpan,Object.keys(d.data).length===0&&delete d.data}}c.length>s&&(s=c.length)}for(o=-1;++o<i.length;){const c=i[o].children;let u=c.length-1;for(;++u<s;)c.push({type:"tableCell",children:[]})}let a=n.length-1;for(;++a<s;)n.push(null);e.inTable=!1;const l={type:"table",align:n,children:i};return e.patch(t,l),l}function Avn(e){const t={align:[null],headless:!0};let n=0,r=0;return KI(e,function(i){if(i.type==="element"){if(i.tagName==="table"&&e!==i)return uge;if((i.tagName==="th"||i.tagName==="td")&&i.properties){if(!t.align[r]){const o=String(i.properties.align||"")||null;(o==="center"||o==="left"||o==="right"||o===null)&&(t.align[r]=o)}t.headless&&n<2&&i.tagName==="th"&&(t.headless=!1),r++}else i.tagName==="thead"?t.headless=!1:i.tagName==="tr"&&(n++,r=0)}}),t}function Svn(){return{type:"tableCell",children:[]}}function eDe(){return{type:"tableRow",children:[]}}var xvn=Pe((()=>{qE(),iL()}));function Tvn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var Ivn=Pe((()=>{}));function kvn(e,t){const n={type:"text",value:jE(t)};return e.patch(t,n),n}var Evn=Pe((()=>{qE()}));function Cvn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var _vn=Pe((()=>{}));function ri(e,t){return e.all(t)}function Vs(e,t){return e.toFlow(e.all(t))}function ii(){}var tDe,nDe,Rvn=Pe((()=>{pbn(),gbn(),bbn(),wbn(),Lbn(),Mbn(),Dbn(),Bbn(),Hbn(),zbn(),Vbn(),Gbn(),jbn(),qbn(),Kbn(),nvn(),ivn(),avn(),lvn(),uvn(),fvn(),pvn(),mvn(),gvn(),vvn(),xvn(),Ivn(),Evn(),_vn(),tDe={comment:Nbn,doctype:ii,root:dvn,text:Tvn},nDe={applet:ii,area:ii,basefont:ii,bgsound:ii,caption:ii,col:ii,colgroup:ii,command:ii,content:ii,datalist:ii,dialog:ii,element:ii,embed:ii,frame:ii,frameset:ii,isindex:ii,keygen:ii,link:ii,math:ii,menu:ii,menuitem:ii,meta:ii,nextid:ii,noembed:ii,noframes:ii,optgroup:ii,option:ii,param:ii,script:ii,shadow:ii,source:ii,spacer:ii,style:ii,svg:ii,template:ii,title:ii,track:ii,abbr:ri,acronym:ri,bdi:ri,bdo:ri,big:ri,blink:ri,button:ri,canvas:ri,cite:ri,data:ri,details:ri,dfn:ri,font:ri,ins:ri,label:ri,map:ri,marquee:ri,meter:ri,nobr:ri,noscript:ri,object:ri,output:ri,progress:ri,rb:ri,rbc:ri,rp:ri,rt:ri,rtc:ri,ruby:ri,slot:ri,small:ri,span:ri,sup:ri,sub:ri,tbody:ri,tfoot:ri,thead:ri,time:ri,address:Vs,article:Vs,aside:Vs,body:Vs,center:Vs,div:Vs,fieldset:Vs,figcaption:Vs,figure:Vs,form:Vs,footer:Vs,header:Vs,hgroup:Vs,html:Vs,legend:Vs,main:Vs,multicol:Vs,nav:Vs,picture:Vs,section:Vs,a:hbn,audio:XMe,b:QMe,base:mbn,blockquote:ybn,br:vbn,code:YE,dir:JY,dl:Obn,dt:XY,dd:XY,del:jY,em:R3,h1:uS,h2:uS,h3:uS,h4:uS,h5:uS,h6:uS,hr:Ubn,i:R3,iframe:Wbn,img:LMe,image:LMe,input:Ybn,kbd:YE,li:XY,listing:_3,mark:R3,ol:JY,p:JMe,plaintext:_3,pre:_3,q:cvn,s:jY,samp:YE,select:hvn,strike:jY,strong:QMe,summary:JMe,table:wvn,td:$Me,textarea:kvn,th:$Me,tr:yvn,tt:YE,u:R3,ul:JY,var:YE,video:XMe,wbr:Cvn,xmp:_3}}));function Pvn(e){return{all:Lvn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...nDe,...e.handlers},inTable:!1,nodeHandlers:{...tDe,...e.nodeHandlers},one:Nvn,options:e,patch:Mvn,qNesting:0,resolve:Dvn,toFlow:Ovn,toSpecificContent:Fvn}}function Lvn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const i=t[r],o=this.one(i,e);Array.isArray(o)?n.push(...o):o&&n.push(o)}return n}function Nvn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if($Y.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if($Y.call(this.nodeHandlers,e.type))return this.nodeHandlers[e.type](this,e,t)||void 0;if("value"in e&&typeof e.value=="string"){const n={type:"text",value:e.value};return this.patch(e,n),n}if("children"in e)return this.all(e)}function Mvn(e,t){e.position&&(t.position=ubn(e))}function Dvn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function Ovn(e){return qMe(e)}function Fvn(e,t){const n=t(),r=[];let i=[],o=-1;for(;++o<e.length;){const a=e[o];if(s(a))i.length>0&&(a.children.unshift(...i),i=[]),r.push(a);else{const l=a;i.push(l)}}if(i.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...i),i=[]}return r;function s(a){return a.type===n.type}}var $Y,Bvn=Pe((()=>{fbn(),Rvn(),QY(),$Y={}.hasOwnProperty}));function rDe(e,t){const n=OY(e),r=t||iDe,i=abn({newlines:r.newlines===!0}),o=Pvn(r);let s;i(n),KI(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!o.elementById.has(c)&&o.elementById.set(c,l)}});const a=o.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},KI(s,function(l,c,u){if(l.type==="text"&&c!==void 0&&u){const d=u.children[c-1];if(d&&d.type===l.type)return d.value+=l.value,u.children.splice(c,1),d.position&&l.position&&(d.position.end=l.position.end),c-1;if(l.value=l.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),u&&(u.type==="heading"||u.type==="paragraph"||u.type==="root")&&(c||(l.value=l.value.replace(/^[\t ]+/,"")),c===u.children.length-1&&(l.value=l.value.replace(/[\t ]+$/,""))),!l.value)return u.children.splice(c,1),c}}),s}var iDe,Hvn=Pe((()=>{oMe(),cbn(),iL(),Bvn(),iDe={}})),zvn=Pe((()=>{Hvn()}));function Uvn(e,t){return e&&"run"in e?async function(n,r){const i=rDe(n,{...eK,...t});await e.run(i,r)}:function(n){return rDe(n,{...eK,...e})}}var eK,Vvn=Pe((()=>{zvn(),eK={document:!0}})),Wvn=ls({default:()=>Uvn},1),Gvn=Pe((()=>{Vvn()})),jvn="1.31.1",tK=96,qvn=50,Yvn=20,oDe=e=>{const t=e,n=t?.config,r=t?.constructor;if(!n||typeof n!="object"||typeof r!="function")return e;try{return new r(n)}catch{return e}};function Kvn(e){const t=(e.attrs?.colwidth??[]).reduce((o,s)=>o+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,i=n?.right??0;return Math.max(t-r-i,0)}var Fp=class am extends Xk{#e;#t=null;#i=!1;#n="initialized";#r=null;#o=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#a=null;#c=!1;constructor(t){super(),this.extensionStorage={},this.presentationEditor=null,this.isFocused=!1,this.fontsImported=[],this.options={element:null,selector:null,isHeadless:!1,document:null,mockDocument:null,mockWindow:null,content:"",user:null,users:[],media:{},mediaFiles:{},fonts:{},documentMode:"editing",mode:"docx",role:"editor",colors:[],converter:null,fileSource:null,initialState:null,documentId:null,extensions:[],editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,isCommentsEnabled:!1,isNewFile:!1,scale:1,viewOptions:{layout:"print"},annotations:!1,isInternal:!1,externalExtensions:[],isChildEditor:!1,numbering:{},isHeaderOrFooter:!1,lastSelection:null,suppressDefaultDocxStyles:!1,jsonOverride:null,loadFromSchema:!1,fragment:null,skipViewCreation:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:c})=>{throw c},onTrackedChangesUpdate:()=>null,onCommentsUpdate:()=>null,onCommentsLoaded:()=>null,onCommentClicked:()=>null,onCommentLocationsUpdate:()=>null,onPointerDown:()=>null,onPointerUp:()=>null,onRightClick:()=>null,onDocumentLocked:()=>null,onFirstRender:()=>null,onCollaborationReady:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onFontsResolved:null,handleImageUpload:null,customUpdatedFiles:{},isHeaderFooterChanged:!1,isCustomXmlChanged:!1,ydoc:null,collaborationProvider:null,collaborationIsReady:!1,shouldLoadComments:!1,replacedFile:!1,focusTarget:null,permissionResolver:null,parentEditor:null,licenseKey:void 0,telemetry:{enabled:!0}};const n={...t},r=EA(),i=!!n.isHeadless,o=!!(n.element||n.selector),s=n.document??n.mockDocument??(r?document:null),a=!!(n.html||n.markdown)||(n.mode==="text"||n.mode==="html")&&typeof n.content=="string";if(!s&&a)throw new Error("[super-editor] HTML/Markdown import requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");if(!r&&o&&!i)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!i&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#_(n),this.setOptions(n),this.#t=n.renderer??(r?new ECe:null),this.#s();const{setHighContrastMode:l}=kp();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#k(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#I(),html:()=>this.#I(),default:()=>{console.log("Not implemented.")}};(c[this.options.mode]??c.default)(),this.#n="ready"}}get docChanged(){return this.options.isHeaderFooterChanged||this.options.isCustomXmlChanged||!this.options.initialState.doc.eq(this.state.doc)}#u(t){this.#t?.initContainerElement?.(t)}#d(){return EA()&&!this.options.isHeadless}#f(){return this.options.document??this.options.mockDocument??(EA()?document:null)}#l(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}#s(){const{telemetry:t,licenseKey:n}=this.options;if(typeof process<"u"&&process.env?.VITEST||this.options.mode==="text"||this.options.isHeaderOrFooter||this.options.isChildEditor||!t?.enabled)return;const r=n!==void 0?n:t.licenseKey??"community-and-eval-agplv3";try{this.#a=new cYe({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#w(){this.getDocumentIdentifier().then(t=>{if(!(!this.#a||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()||null;this.#a.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#b(...t){if(!t.includes(this.#n))throw new PEe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#x(t,n,r,i){this.#n=t;try{const o=await i();return this.#n=n,o}catch(o){throw this.#n=r,o}}#k(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?bM():Zy()),this.#L(),this.#v(),this.#H(),this.#T()}#T(){this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#ee.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#m(t,n){try{const r=n?.mode??this.options.mode??"docx",i=n?.isNewFile,o={...this.options,mode:r,isCommentsEnabled:n?.isCommentsEnabled??this.options.isCommentsEnabled,suppressDefaultDocxStyles:n?.suppressDefaultDocxStyles??this.options.suppressDefaultDocxStyles,documentMode:n?.documentMode??this.options.documentMode??"editing",html:n?.html,markdown:n?.markdown,jsonOverride:n?.json??null},s=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const l=a8().readFileSync(t),[c,u,d,f,h]=await am.loadXmlData(l,!0,s);o.content=c,o.mediaFiles=d,o.fonts=f,o.fileSource=h??l,o.isNewFile=i??!1,this.#o=h?null:t}else{const l=await fetch(t);if(!l.ok)throw console.debug("[SuperDoc] Fetch failed:",l.status,l.statusText),new Error(`Fetch failed: ${l.status} ${l.statusText}`);const c=await l.blob(),[u,d,f,h,p]=await am.loadXmlData(c,!1,s);o.content=u,o.mediaFiles=f,o.fonts=h,o.fileSource=p??c,o.isNewFile=i??!1,this.#o=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const l=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),c=typeof Blob<"u"&&t instanceof Blob,u=t instanceof ArrayBuffer,d=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(l||c||u||d){const[f,h,p,m,g]=await am.loadXmlData(t,l,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}else{const[f,h,p,m,g]=await am.loadXmlData(t,!1,s);o.content=f,o.mediaFiles=p,o.fonts=m,o.fileSource=g??t,o.isNewFile=i??!1,this.#o=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:l,mediaFiles:c,fonts:u,fileSource:d}=await this.#q();o.content=l,o.mediaFiles={...c,...n?.mediaFiles??{}},o.fonts={...u,...n?.fonts??{}},o.fileSource=d,o.isNewFile=i??!0,this.#o=null}else o.content=n?.content??[],o.mediaFiles=n?.mediaFiles??{},o.fonts=n?.fonts??{},o.fileSource=null,o.isNewFile=i??!n?.content,this.#o=null;this.setOptions(o),this.#G(),o3(this),this.#h(),this.#X();const a=this.#d();if(a&&(this.#u(this.options),this.#j()),this.#$({includePlugins:!a}),!a){const l=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(l)}a&&(this.mount(this.options.element),this.#oe()),a||this.#l(),a&&(this.initDefaultStyles(),this.#ie()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#S(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#se(),a&&(this.#fe(),this.#R())}catch(r){if(r instanceof Go)throw console.debug("[SuperDoc] Document load error:",r.message),r;const i=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",i.message),new MEe(`Failed to load document: ${i.message}`,i)}}#y(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=pp(this);t&&(t.state={...cae},t.initialized=!1,t.editableBaseline=null),this.#o=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this._state=void 0}#h(){const t=pp(this);t&&(t.state=My(this.converter?Gd(this.converter):null),t.initialized=!0)}#S(){const t=pp(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#L(),this.#v(),this.#H(),this.#G(),o3(this),this.#h(),this.#X(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();if(this.#$({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(n)}t&&(this.#u(this.options),this.#j(),this.mount(this.options.element),this.#oe()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("trackedChangesUpdate",this.options.onTrackedChangesUpdate),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("commentsUpdate",this.options.onCommentsUpdate),this.on("locked",this.options.onDocumentLocked),this.on("collaborationReady",this.#ee.bind(this)),this.on("comment-positions",this.options.onCommentLocationsUpdate),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("fonts-resolved",this.options.onFontsResolved),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#ie()),(this.options.markdown||this.options.html||this.options.loadFromSchema||this.options.jsonOverride||this.options.mode==="html"||this.options.mode==="text")&&this.migrateListsToV2(),this.setDocumentMode(this.options.documentMode,"init"),this.#S(),!this.options.ydoc&&!this.options.isChildEditor&&this.#se(),t&&(this.#fe(),this.#R())}#I(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Zy()),this.#L(),this.#v(),this.#H(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#d();this.#$({includePlugins:!t}),t&&(this.#u(this.options),this.mount(this.options.element),this.#oe()),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.#A.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l()}mount(t){this.#K(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#w()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#A({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#_(t){t.isHeadless&&(typeof navigator>"u"&&(global.navigator={platform:"node",userAgent:"Node.js"}),t.mockDocument&&(console.warn("[super-editor] `mockDocument` is deprecated and will be removed in a future version. Use `document` instead (e.g., `new Editor({ document: jsdomDocument })`). See https://docs.superdoc.dev/guide/headless for migration guidance."),global.document=t.mockDocument),t.mockWindow&&(console.warn("[super-editor] `mockWindow` is deprecated and will be removed in a future version. Prefer passing `document` only. Global window assignment is no longer required for headless mode."),global.window=t.mockWindow))}isWebLayout(){return this.options.viewOptions?.layout==="web"}focus(){this.view?.focus()}get state(){return this._state}get lifecycleState(){return this.#n}get sourcePath(){return this.#o}setState(t){this._state=t,this.view&&!this.view.isDestroyed&&this.view.updateState(t)}get storage(){return this.extensionStorage}get commands(){return this.#e?.commands}get doc(){return this.#b("ready","saving"),this.#r||(this.#r=fst(vmn(this))),this.#r}#g(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#b("ready","saving");const n=dLe(this);return Kwe(this,n,t??this.#g())}captureEffectiveSelectionHandle(t){this.#b("ready","saving");const n=fLe(this);return Kwe(this,n,t??this.#g())}resolveSelectionHandle(t){this.#b("ready","saving");const n=$Dt(t);return n?Xq(t._owner,n):null}releaseSelectionHandle(t){this.#b("ready","saving"),e3t(t)}getCurrentSelectionRange(){return this.#b("ready","saving"),xmn(this)}getEffectiveSelectionRange(){return this.#b("ready","saving"),Tmn(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#i||this.view?.isDestroyed)}get element(){return this.options.element}get users(){return this.options.users}chain(){return this.#e.chain()}can(){return this.#e.can()}setDocumentMode(t,n){if(this.options.isHeaderOrFooter||this.options.isChildEditor)return;let r=t?.toLowerCase()||"editing";if(!this.extensionService||!this.state)return;const i=this.view?.dom||this.options.element?.querySelector?.(".ProseMirror");if(this.options.role==="viewer"&&(r="viewing"),this.options.role==="suggester"&&r==="editing"&&(r="suggesting"),r==="viewing"){this.commands.toggleTrackChangesShowOriginal?.();const o=x0e(this.state);o&&this.view?.dispatch(this.state.tr.setSelection(o)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),i&&i.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),i&&i.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),i&&i.classList.remove("view-mode"));Ow(this),this.emit("documentModeChange",{editor:this,documentMode:r})}blur(){this.view?.dom?.blur()}hasFocus(){return this.view?this.view.hasFocus():!1}coordsAtPos(t){return this.presentationEditor?this.presentationEditor.coordsAtPos(t):this.view?this.view.coordsAtPos(t):null}getElementAtPos(t,n={}){if(this.presentationEditor)return this.presentationEditor.getElementAtPos(t,n);if(!this.view||!Number.isFinite(t))return null;const r=this.view.state.doc.content.size,i=Math.max(0,Math.min(t,r));try{const{node:o}=this.view.domAtPos(i);return o&&o.nodeType===1?o:o&&o.nodeType===3?o.parentElement:o?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,i=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(i)){const o=this.presentationEditor.hitTest(r,i);if(o)return{pos:o.pos,inside:o.pos}}}return this.view?this.view.posAtCoords(t):null}#R(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await K3t(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||jw(this.options.collaborationProvider,()=>{this.#P()})}replaceContent(t){this.setOptions({content:t}),this.#G(),this.initDefaultStyles(),this.#G(),o3(this),this.#X();const n=this.#Z(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#B(r)}#D(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},i=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(i.size===0)return;const o=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of i){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;o(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#B(s)}#P(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#Z(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#B(r);const i=this.options.ydoc;i&&i.getMap("meta").set("bodySectPr",n),this.#D(t.attrs??{}),setTimeout(()=>{this.#se()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},i=Object.getOwnPropertyDescriptors(n);for(const[o,s]of Object.entries(i))s.enumerable||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(r,o,s);this.options=r,(this.options.isNewFile||!this.options.ydoc)&&this.options.isCommentsEnabled&&(this.options.shouldLoadComments=!0),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t=!0,n=!0){this.setOptions({editable:t}),this.view&&(this.view.setProps({}),!t&&this.view.dom&&this.view.dom.blur()),n&&this.state&&this.emit("update",{editor:this,transaction:this.state.tr})}registerPlugin(t,n){if(this.isDestroyed||!this.state?.plugins)return;const r=typeof n=="function"?n(t,[...this.state.plugins]):[...this.state.plugins,t];this._state=this.state.reconfigure({plugins:r}),this.view?.updateState(this._state)}#E(t){const n=t.key;return typeof n?.key=="string"?n.key:""}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t?.key??"";this._state=this.state.reconfigure({plugins:this.state.plugins.filter(r=>!this.#E(r).startsWith(n))}),this.view?.updateState(this._state)}attachCollaboration({ydoc:t,collaborationProvider:n}){if(this.isDestroyed)throw new Error("[super-editor] Cannot attach collaboration to a destroyed editor");if(this.options.ydoc)throw new Error("[super-editor] Editor already has collaboration attached");if(this.options.isHeadless)throw new Error("[super-editor] attachCollaboration is not supported in headless mode");const r=this.options.collaborationProvider,i=this.options.shouldLoadComments,o=this.options.collaborationIsReady,s=this._state,a=()=>{SAe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=i,this.options.collaborationIsReady=o,this._state=s,this.view?.updateState(s)};this.options.ydoc=t,this.options.collaborationProvider=n,this.options.shouldLoadComments=!1;let l;try{l=[...this.extensionService.plugins]}catch(c){throw a(),c}try{this._state=this.state.reconfigure({plugins:l}),this.view?.updateState(this._state)}catch(c){throw a(),c}}#L(){const t=["extension","node","mark"],n=[tYt,Kqt,nYt,Jqt,rYt,iYt],r=this.options.externalExtensions||[],i=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>oDe(s)),o=r.map(s=>oDe(s));this.extensionService=sYt.create(i,o,this)}#v(){this.#e=ghe.create({editor:this})}#G(){this.options.converter?this.converter=this.options.converter:this.converter=new ju({docx:this.options.content,media:this.options.mediaFiles,fonts:this.options.fonts,debug:!0,fileSource:this.options.fileSource,documentId:this.options.documentId,mockWindow:this.options.mockWindow??null,mockDocument:this.options.mockDocument??null,isNewFile:this.options.isNewFile??!1,trackedChangesOptions:this.options.trackedChanges??null})}async#q(){const t=await jie(sXt),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let i;if(n)i=Buffer.from(r);else if(typeof Blob<"u")i=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[o,s,a,l]=await am.loadXmlData(i,n);return{content:o,mediaFiles:a,fonts:l,fileSource:i}}async#Y(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#q();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#X(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#j(){this.#t?.initFonts?.(this)}async#ie(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#V(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#V(t){return t.filter(n=>{const r=lKt(n),i=this.fontsImported.includes(n);return!r&&!i})}static async loadXmlData(t,n=!1,r){if(!t)return;const i=new TG;return[await i.getDocxData(t,n,{password:r?.password}),i.media,i.mediaFiles,i.fonts,i.decryptedFileData]}static getDocumentVersion(t){return ju.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=ju.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return ju.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),am.setDocumentVersion(t,n)}async getSchemaSummaryJSON(){if(!this.schema)throw new Error("Schema is not initialized.");const t=this.converter?.getSuperdocVersion?.()||"current",n=new Set((this.extensionService?.extensions||[]).filter(i=>!!i?.config?.excludeFromSummaryJSON).map(i=>i.name)),r=DKt(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(i=>!n.has(i.name)),marks:r.marks.filter(i=>!n.has(i.name))}:r}validateJSON(t){if(!this.schema)throw new Error("Schema is not initialized.");try{return Array.isArray(t)?t.map(n=>this.schema.nodeFromJSON(n)):this.schema.nodeFromJSON(t)}catch(n){const r=n instanceof Error?n.message:String(n),i=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(i.cause=n),i}}#H(){this.schema=this.extensionService.schema}#Z(){let t;try{const{mode:n,content:r,fragment:i,loadFromSchema:o}=this.options,s=this.#f(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?o&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#N(t)):(t=Ade(this.converter,this.schema,this),t=this.#N(t),this.options.markdown?t=gz(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=BI(this.options.html,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.jsonOverride&&(t=this.schema.nodeFromJSON(this.options.jsonOverride)),i&&(t=Ygt(i,this.schema))):(n==="text"||n==="html")&&(o&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=BI(r,this,{document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):t=this.schema.topNodeType.createAndFill())}catch(n){console.error(n);const r=n instanceof Error?n:new Error(String(n));this.emit("contentError",{editor:this,error:r})}return t}#$({includePlugins:t=!1}={}){if(this._state)return;const n=this.#Z(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let i=KR.create(r);t&&(i=i.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=i,this._state=i}#oe(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#K(t){if(this._state||this.#$(),!this.#t){if(!EA())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new ECe}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#B.bind(this),state:this.state,handleClick:this.#Q.bind(this)}),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){if(!this.converter)return{};let t=0;const{$head:n}=this.state.selection;for(let p=n.depth;p>0;p--){const m=n.node(p);if(m.type.name==="tableCell"||m.type.name==="tableHeader"){t=Kvn(m);break}}if(this.isWebLayout())return t>0?{width:t,height:1/0}:{};const{pageSize:r={},pageMargins:i={}}=this.converter.pageStyles??{},{width:o,height:s}=r;if(!o||!s)return{};const a=p=>(i?.[p]??0)*tK,l=a("top"),c=a("bottom"),u=a("left"),d=a("right"),f=s*tK-l-c-qvn,h=o*tK-u-d-Yvn;return t>0?{width:t,height:f}:{width:h,height:f}}updateEditorStyles(t,n){this.#t?.updateEditorStyles?.(this,t,n)}initDefaultStyles(t=this.element){this.options.isHeadless||this.options.suppressDefaultDocxStyles||this.#t?.initDefaultStyles?.(this,t)}initMobileStyles(t){this.#t?.initMobileStyles?.(this,t)}#ee({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#te(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#B(r),this.options.isNewFile||this.#se()}#se(){if(!this.options.isCommentsEnabled||!this.options.shouldLoadComments||!this.converter)return;const t=this.options.replacedFile;this.emit("commentsLoaded",{editor:this,replacedFile:t,comments:this.converter.comments||[]}),this.options.replacedFile=!1,!this.options.isHeadless&&setTimeout(()=>{const n=this.state;if(!n)return;const r=n.tr.setMeta(Yi,{type:"force"});this.#B(r)},50)}#B(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),i=r(),o=this.state;let s,a=t;const l=a.getMeta("forceTrackChanges")===!0;try{const h=Qi.getState(o)?.isTrackChangesActive??!1,p=a.getMeta("skipTrackChanges")===!0,m=(h||l)&&!p;if(m&&l&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");a=m?qTe({tr:a,state:o,user:this.options.user,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:g}=o.applyTransaction(a);s=g}catch(h){if(l)throw h;s=o.apply(a),console.log(h)}const c=!o.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const u=r();this.emit("transaction",{editor:this,transaction:a,duration:u-i}),c&&this.emit("selectionUpdate",{editor:this,transaction:a});const d=a.getMeta("focus");d&&this.emit("focus",{editor:this,event:d.event,transaction:a});const f=a.getMeta("blur");f&&this.emit("blur",{editor:this,event:f.event,transaction:a}),a.docChanged&&(t.docChanged&&this.converter&&(this.converter.documentGuid||(this.converter.promoteToGuid(),console.debug("Document modified - assigned GUID:",this.converter.documentGuid)),this.converter.documentModified=!0),this.emit("update",{editor:this,transaction:a}))}dispatch(t){this.#B(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return cn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,i=typeof t=="string"?n:t;return xde(this.state,r,i)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,i=this.converter;i&&i.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=i.bodySectPr)}catch{}return t}getMetadata(){return{documentGuid:this.converter?.documentGuid||null,isModified:this.isDocumentModified(),version:this.converter?.getSuperdocVersion()||null}}getHTML({unflattenLists:t=!1}={}){const n=this.#f();if(!n)throw new Error("[super-editor] getHTML() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const r=n.createElement("div"),i=Cf.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(i);let o=r.innerHTML;return t&&(o=Cpe(o,n)),o}async getMarkdown(){const t=this.#f();if(!t)throw new Error("[super-editor] getMarkdown() requires a DOM. Provide { document } (e.g. from JSDOM), set DOM globals, or run in a browser environment.");const n=globalThis,r=n.document===void 0,i=r?{document:n.document,window:n.window,navigatorDescriptor:Object.getOwnPropertyDescriptor(globalThis,"navigator")}:null;r&&(n.document=t,!n.window&&t.defaultView&&(n.window=t.defaultView),!n.navigator&&t.defaultView?.navigator&&(n.navigator=t.defaultView.navigator));try{const[{unified:o},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(RH(),Zbt)),Promise.resolve().then(()=>(Cyn(),Eyn)),Promise.resolve().then(()=>(Gvn(),Wvn)),Promise.resolve().then(()=>(l_e(),EZt)),Promise.resolve().then(()=>(dz(),UTt))]),u=this.getHTML(),d=o().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{i&&(i.document===void 0?delete n.document:n.document=i.document,i.window===void 0?delete n.window:n.window=i.window,i.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",i.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return pKt(this,t)}getPageStyles(){return this.converter?.pageStyles||{}}updatePageStyle({pageMargins:t}){if(!this.converter)return;let n=!1;if(t&&(this.converter.pageStyles.pageMargins=t,this.initDefaultStyles(),n=!0),n&&this.view&&!Wy()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#B(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#Q(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return aKt(t,n)}#N(t){const n=KR.create({schema:this.schema,doc:t}),{tr:r,doc:i}=n;return hFt(i,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:cKt(this)}#he(t=[]){const n=this.state.doc,r=new R7(n);return fFt(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#he()}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:i=!1,comments:o,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{TMt(By(this));const c=(o??this.converter.comments??[]).map(fe=>{const ee=Array.isArray(fe.elements)&&fe.elements.length?fe.elements:void 0;return{...fe,commentJSON:fe.commentJSON??ee}}),u=this.#he(c),d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#ue(),i||r)return d;const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],w=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,x=this.converter.convertedXml["word/endnotes.xml"],S=x?.elements?.[0]?this.converter.schemaToXml(x.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],k=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,C=this.converter.convertedXml["word/_rels/settings.xml.rels"],_=C?.elements?.[0]?this.converter.schemaToXml(C.elements[0]):null,P=this.converter.addedMedia,E={};Object.entries(this.converter.convertedXml).forEach(([fe,ee])=>{if(fe.includes("header")||fe.includes("footer")){const Z=ee,re=this.converter.schemaToXml(Z.elements?.[0]);E[fe]=String(re.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=this.converter.schemaToXml(L.elements[0]),O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,B=this.converter.convertedXml["docProps/core.xml"],j=B?.elements?.[0]?this.converter.schemaToXml(B.elements[0]):null,M={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),"word/numbering.xml":String(R),"word/styles.xml":String(h),...E,...F?{"docProps/app.xml":String(F)}:{},...j?{"docProps/core.xml":String(j)}:{}};if(p){let fe=String(m);_?M["word/_rels/settings.xml.rels"]=String(_):/<\w+:attachedTemplate\b/i.test(fe)&&(fe=fe.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=fe}v&&(M["word/footnotes.xml"]=String(v)),w&&(M["word/_rels/footnotes.xml.rels"]=String(w)),S&&(M["word/endnotes.xml"]=String(S)),k&&(M["word/_rels/endnotes.xml.rels"]=String(k));const z=tU.map(fe=>`word/${fe}`);for(const fe of z){const ee=this.converter.convertedXml[fe];ee?.elements?.[0]?M[fe]=String(this.converter.schemaToXml(ee.elements[0])):M[fe]=null}const $=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const fe of $){const ee=this.converter.convertedXml[fe];ee?.elements?.[0]&&(M[fe]=String(this.converter.schemaToXml(ee.elements[0])))}for(const fe of Object.keys(this.converter.convertedXml)){if(!fe.startsWith("customXml/")||!fe.endsWith(".xml")&&!fe.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,fe))continue;const ee=this.converter.convertedXml[fe];ee?.elements?.[0]&&(M[fe]=String(this.converter.schemaToXml(ee.elements[0])))}const K=new TG;if(s){M["[Content_Types].xml"]=await K.updateContentTypes({files:this.options.content},P,!0,M,this.options.fonts);const fe=this.options.content,{contentTypesXml:ee,relsXml:Z}=YEe({baseFiles:Array.isArray(fe)||fe&&typeof fe=="object"?fe:null,updatedDocs:M});return M["[Content_Types].xml"]=ee,M["_rels/.rels"]=Z,M}const U=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#Y():this.options.content;return await K.updateZip({docx:U,updatedDocs:M,originalDocxFile:this.options.fileSource,media:P,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#pe(){if(this.options.ydoc)try{console.debug("🔗 [super-editor] Ending collaboration"),this.options.collaborationProvider?.disconnect?.(),this.options.ydoc.destroy()}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}async open(t,n){this.#b("initialized","closed"),await this.#x("documentLoading","ready","closed",async()=>{await this.#m(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#o})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p,...m}=r,g={mode:r.mode,html:i,markdown:o,json:s,isCommentsEnabled:a,suppressDefaultDocxStyles:l,documentMode:c,content:u,mediaFiles:d,fonts:f,isNewFile:h,password:p},y=new am({...m,deferDocumentLoad:!0});return await y.open(t,g),y}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#b("ready"),this.emit("documentClose",{editor:this}),this.#y(),this.#r=null,this.#n="closed")}async save(t){if(this.#b("ready"),!this.#o)throw new LEe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#x("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#M(this.#o,n)})}async saveTo(t,n){this.#b("ready"),await this.#x("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#M(t,r),this.#o=t})}async exportDocument(t){return this.#b("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#M(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,i=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||i)try{const o=a8(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());o.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const o=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await o.write(n),await o.close();return}throw new NEe("File System Access API not available. Use exportDocument() to get the document data and handle the download manually.")}destroy(){this.#n==="ready"&&this.close(),this.#n!=="destroyed"&&(this.#i=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#pe(),this.removeAllListeners(),this.extensionService=void 0,this.schema=void 0,this.#e=void 0,this.#r=null,this.#n="destroyed")}destroyHeaderFooterEditors(){try{const t=this.converter?.headerEditors??[],n=this.converter?.footerEditors??[];if(!t.length&&!n.length)return;const r=[...t,...n].filter(Boolean);for(const i of r)i?.editor?.destroy?.();t.length&&(t.length=0),n.length&&(n.length=0)}catch(t){const n=t instanceof Error?t:new Error(String(t));this.emit("exception",{error:n,editor:this}),console.error(n)}}static checkIfMigrationsNeeded(){const t=version??"initial",n=OEe(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",jvn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=OEe(t)||[],r=this.state.plugins.find(o=>this.#E(o).startsWith("y-sync"));if(!r)return this.options.ydoc;let i=!1;for(const o of n)if(console.debug("🏃‍♂️ Running migration",o.name),o(this))i=!0;else throw new Error("Migration failed at "+o.name);if(i)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,i,o,s,a]=await am.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:i,mediaFiles:o,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#G(),o3(this),this.#X(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#P(),bN(this,l,{replaceExisting:!0});const f=this.options.mediaFiles??{},h=l.getMap("media");for(const p of h.keys())p in f||h.delete(p);Object.entries(f).forEach(([p,m])=>{h.set(p,m)})},d=1e4;await new Promise((f,h)=>{let p,m=!1;const g=jw(c,()=>{if(!m){m=!0,clearTimeout(p);try{u(),f()}catch(y){h(y)}}});m||(p=setTimeout(()=>{m=!0,g(),h(new Error(`replaceFile(): collaboration provider did not sync within ${d}ms. The provider exposes on/off but never emitted sync(true) or synced.`))},d))})}else this.#P();this.options.ydoc||this.#se()}getInternalXmlFile(t,n="json"){return this.converter.convertedXml[t]?n==="json"?this.converter.convertedXml[t].elements[0]||null:this.converter.schemaToXml(this.converter.convertedXml[t].elements[0]):(console.warn("Cannot find file in docx"),null)}updateInternalXmlFile(t,n){if(typeof n=="string")this.options.customUpdatedFiles[t]=String(n);else{const r=this.converter.schemaToXml(n);this.options.customUpdatedFiles[t]=String(r)}this.options.isCustomXmlChanged=!0}getNodesOfType(t){const{findChildren:n}=wz;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const i=t.pos,o=i+t.node.nodeSize,s=BI(n,this);r.replaceWith(i,o,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=WN.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await hKt(t,this)}annotate(t=[],n=[],r=!1){const{state:i,schema:o}=this;let s=i.tr;if(s=WN.processTables({state:this.state,tr:s,annotationValues:t}),s=WN.annotateDocument({tr:s,schema:o,annotationValues:t,hiddenFieldIds:n,removeEmptyFields:r,editor:this}),s.docChanged){const a=s.scrollIntoView();this.dispatch(a)}}previewAnnotations(t=[],n=[]){this.originalState=this.state,this.annotate(t,n)}closePreview(){this.originalState&&(this.view?this.view.updateState(this.originalState):this._state=this.originalState)}#te(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ACe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#ue(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ACe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#fe(){this.#t?.initDevTools?.(this)}},Og=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),Fg={EXT:Og("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:Og("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:Og("--sd-comments-highlight-external-faded","#B1124B20"),INT:Og("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:Og("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:Og("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:Og("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:Og("--sd-comments-highlight-internal-nested-border","#07838399")},L3="track-change-focused",sDe=".superdoc-comment-highlight",Xvn="[data-track-change-id]";function aDe(e){return e?e.split(",").filter(Boolean):[]}function Jvn(e){const t=new Map;if(!e)return t;for(const n of e.split(",")){const r=n.indexOf("=");r>0&&t.set(n.slice(0,r),n.slice(r+1))}return t}function lDe(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function nK(e,t){lDe(e,"backgroundColor",t.css,t.fallback)}function Zvn(e,t){lDe(e,"boxShadow",`inset 1px 0 0 ${t.css}, inset -1px 0 0 ${t.css}`,`inset 1px 0 0 ${t.fallback}, inset -1px 0 0 ${t.fallback}`)}var Qvn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#i(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(sDe);for(let r=0;r<t.length;r++){const i=t[r];i.style.backgroundColor="",i.style.boxShadow=""}const n=e.querySelectorAll(`.${L3}`);for(let r=0;r<n.length;r++)n[r].classList.remove(L3)}#i(e){const t=this.#e,n=e.querySelectorAll(sDe);for(let r=0;r<n.length;r++){const i=n[r],o=aDe(i.dataset.commentIds);if(o.length===0)continue;const s=new Set(aDe(i.dataset.commentInternalIds)),a=s.has(o[0]);if(t==null){nK(i,a?Fg.INT:Fg.EXT),i.style.boxShadow="";continue}const l=this.#n(t,o,i.dataset.commentImportedIds);if(l!=null){const c=s.has(l);nK(i,c?Fg.INT_ACTIVE:Fg.EXT_ACTIVE),o.length>1?Zvn(i,c?Fg.INT_NESTED_BDR:Fg.EXT_NESTED_BDR):i.style.boxShadow=""}else nK(i,a?Fg.INT_FADED:Fg.EXT_FADED),i.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=Jvn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(Xvn);for(let r=0;r<n.length;r++){const i=n[r];t&&i.dataset.trackChangeId===t?i.classList.add(L3):i.classList.remove(L3)}}},$vn=[Qi,Yi,Tk,dg,oA,lM],ewn=new Set([...$vn]),twn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],rK=`
356
356
  `,iK=`
357
357
  `;function nwn(e,t,n,r){const i=e.content.size;if(t<=0)return 0;if(t>=e.textBetween(0,i,n,r).length)return i;let o=0,s=i;for(;o<s;){const a=Math.floor((o+s)/2);e.textBetween(0,a,n,r).length<t?o=a+1:s=a}return o}function cDe(e,t,n){if(!t)return null;const r=e.content.size,i=e.textBetween(0,r,rK,iK),o=[];let s=0;for(;;){const f=i.indexOf(t,s);if(f===-1)break;o.push(f),s=f+1}if(o.length===0)return null;const a=f=>nwn(e,f,rK,iK),l=o[0];let c;n==null?c=l:c=o.reduce((f,h)=>{const p=a(h);return Math.abs(p-n)<Math.abs(f.bestPos-n)?{best:h,bestPos:p}:f},{best:l,bestPos:a(l)}).best;const u=a(c),d=a(c+t.length);return u<d?{from:u,to:d}:null}function rwn(e,t,n){if(!n.text)return null;const r=cDe(e,n.text,n.from);return!r||r.from<0||r.to<=r.from||r.to>t?null:r}function uDe(e,t,n){const r=[];for(const i of n){const o=rwn(e,t,i);o&&r.push({...i,from:o.from,to:o.to})}return r}function dDe(e){if(e.length===0)return null;let t=e[0].from,n=e[0].to;for(let r=1;r<e.length;r++)e[r].from<t&&(t=e[r].from),e[r].to>n&&(n=e[r].to);return{from:t,to:n}}function iwn(e,t,n,r){if(e.length===0||!t?.length)return e;const i=uDe(n,r,t);if(i.length===0)return e;const o=dDe(e),s=dDe(i);return!o||!s?e:o.from>=s.from&&o.to<=s.to&&s.to-s.from>o.to-o.from?i:e}var own=class g${#e=new WeakMap;#t=[];#i=[];#n=new Map;#r=!1;#o=new Map;#a=!1;#c=!1;#u=0;#d=new Map;#f=new Map;sync(t,n,r){this.#s(t);const i=t.doc.content.size,o=r?.restoreEmptyDecorations!==!1;o||(this.#a=!0);const s=this.#t.length>0?this.#x(t,n,i,o):new Map;return this.#r=this.#t.length>0,this.#P(s,n,i)}recordTransaction(t){this.#c=!!t?.docChanged,t?.docChanged&&(this.#u+=1,this.#d.set(this.#u,t.mapping))}hasChanges(t){if(this.#s(t),this.#t.length===0)return this.#r;for(const n of this.#t)if(this.#A(n,t)!==this.#n.get(n))return!0;return!1}hasCurrentRanges(t){if(this.#s(t),this.#t.length===0)return!1;const n=t.doc.content.size;for(const r of this.#t){const i=this.#A(r,t);if(i!==Rn.empty)for(const o of i.find(0,n)){if(!this.#_(o))continue;const s=this.#g(o);if((s.classes.length>0||s.dataEntries.length>0||s.styleEntries.length>0)&&!(o.from>=o.to))return!0}}return!1}collectDecorationRanges(t){this.#s(t);const n=[],r=t.doc.content.size;for(const i of this.#t){const{ranges:o,decorationSet:s}=this.#T(i,t,r),a=this.#o.get(i),l=!this.#a&&a&&a.length>0,{effectiveRanges:c,rangesToStore:u}=this.#m(o,a,t.doc,r,l,this.#c);this.#y(i,u.length>0?[...u]:[]),this.#n.set(i,s),n.push(...c)}return this.#l(),n}#l(){this.#a&&(this.#a=!1)}destroy(){this.#t=[],this.#i=[],this.#n.clear(),this.#o.clear(),this.#f.clear(),this.#r=!1,this.#a=!1,this.#c=!1,this.#u=0,this.#d.clear()}#s(t){if(t.plugins===this.#i)return;this.#i=t.plugins,this.#t=t.plugins.filter(r=>!(!r.props.decorations||this.#w(r)||this.#b(r)));const n=new Set(this.#t);for(const r of this.#n.keys())n.has(r)||this.#n.delete(r);for(const r of this.#o.keys())n.has(r)||this.#o.delete(r);for(const r of this.#f.keys())n.has(r)||this.#f.delete(r);this.#C()}#w(t){const n=t.spec?.key;return n!=null&&ewn.has(n)}#b(t){const n=t.key??"";return twn.some(r=>n===r||n.startsWith(`${r}$`))}#x(t,n,r,i){const o=new Map;for(const s of this.#t){const{ranges:a,decorationSet:l}=this.#T(s,t,r),c=this.#o.get(s),{effectiveRanges:u,rangesToStore:d}=this.#m(a,c,t.doc,r,i,this.#c);if(a.length>0||u.length>0){this.#k(o,n,u),this.#y(s,d.length>0?[...d]:[]),this.#n.set(s,l);continue}if(!i){this.#y(s,[]),this.#n.set(s,l);continue}this.#y(s,[]),this.#n.set(s,l)}return o}#k(t,n,r){for(const i of r){const o=n.findEntriesInRange(i.from,i.to);for(const s of o){const a=this.#D(t,s.el);for(const l of i.classes)a.classes.add(l);for(const[l,c]of Object.entries(i.dataAttrs))a.dataAttrs.set(l,c);if(i.style)for(const[l,c]of g$.#R(i.style))a.styleProps.set(l,c)}}}#T(t,n,r){const i=this.#A(t,n),o=this.#n.get(t),s=this.#I(t,i,o,n.doc,r);if(s)return{ranges:s,decorationSet:i};const a=[];if(i!==Rn.empty){const l=i.find(0,r);for(const c of l){if(!this.#_(c))continue;const u=this.#g(c);if(u.classes.length===0&&u.dataEntries.length===0&&u.styleEntries.length===0||c.from>=c.to)continue;const d={};for(const[p,m]of u.dataEntries)d[p]=m;const f=u.styleEntries.length>0?u.styleEntries.map(([p,m])=>`${p}: ${m}`).join("; "):null,h=typeof n.doc.textBetween=="function"?n.doc.textBetween(c.from,c.to,rK,iK):void 0;a.push({from:c.from,to:c.to,classes:u.classes,style:f,dataAttrs:d,...h?{text:h}:{}})}}return{ranges:a,decorationSet:i}}#m(t,n,r,i,o,s){let a=t;a.length===0&&o&&n?.length&&(a=uDe(r,i,n));const l=s&&o&&n?.length?iwn(a,n,r,i):a,c=s&&l!==a;return{effectiveRanges:l,rangesToStore:t.length>0?c?l:t:l}}#y(t,n){this.#o.set(t,n),this.#f.set(t,this.#u),this.#C()}#h(t){if(t>=this.#u)return[];const n=[];for(let r=t+1;r<=this.#u;r+=1){const i=this.#d.get(r);if(!i)return[];n.push(i)}return n}#S(t,n,r){let i=t;for(const o of r)i=o.map(i,n);return i}#C(){if(this.#d.size===0)return;let t=this.#u;for(const n of this.#f.values())n<t&&(t=n);for(const n of this.#d.keys())n<=t&&this.#d.delete(n)}#I(t,n,r,i,o){if(!r||r!==n)return null;const s=this.#o.get(t);if(!s?.length)return null;const a=this.#f.get(t)??-1;if(a===this.#u)return s;const l=this.#h(a);if(l.length===0)return null;const c=[];for(const u of s){if(u.text){const h=cDe(i,u.text,u.from);if(h&&h.from>=0&&h.to>h.from&&h.to<=o){c.push({from:h.from,to:h.to,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text});continue}}const d=this.#S(u.from,-1,l),f=this.#S(u.to,1,l);d<0||f<=d||f>o||c.push({from:d,to:f,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text})}return c.length===0?null:c}#A(t,n){try{const r=t.props.decorations?.call(t,n);return r instanceof Rn?r:Rn.empty}catch{return Rn.empty}}#_(t){return t.inline===!0}#g(t){const n=t.type?.attrs??{},r=typeof n.class=="string"?n.class.split(/\s+/).filter(o=>o.length>0):[],i=[];for(const[o,s]of Object.entries(n))o==="class"||o==="style"||o.startsWith("data-")&&typeof s=="string"&&i.push([o,s]);return{classes:r,dataEntries:i,styleEntries:typeof n.style=="string"?g$.#R(n.style):[]}}static#R(t){if(!t.trim())return[];const n=document.createElement("span");n.style.cssText=t;const r=[];for(let i=0;i<n.style.length;i++){const o=n.style.item(i),s=n.style.getPropertyValue(o);o&&s&&r.push([o,s])}return r}#D(t,n){let r=t.get(n);return r||(r={classes:new Set,dataAttrs:new Map,styleProps:new Map},t.set(n,r)),r}#P(t,n,r){let i=!1;for(const[s,a]of t){const l=this.#e.get(s);l?this.#q(s,l,a)&&(i=!0):(this.#E(s,a),i=!0)}const o=r>0?n.findEntriesInRange(0,r):[];for(const s of o){if(t.has(s.el))continue;const a=this.#e.get(s.el);a&&(this.#Y(s.el,a),i=!0)}return i}#E(t,n){const r={classes:new Set,dataAttrs:new Map,styleProps:new Map,priorClasses:new Set,priorDataAttrs:new Map,priorStyleProps:new Map};for(const i of n.classes)t.classList.contains(i)&&r.priorClasses.add(i),t.classList.add(i),r.classes.add(i);for(const[i,o]of n.dataAttrs){const s=t.getAttribute(i);s!==null&&r.priorDataAttrs.set(i,s),t.setAttribute(i,o),r.dataAttrs.set(i,o)}for(const[i,o]of n.styleProps){const s=t.style.getPropertyValue(i);s&&r.priorStyleProps.set(i,s),t.style.setProperty(i,o),r.styleProps.set(i,o)}this.#e.set(t,r)}#L(t,n,r){const i=n.classes.has(r),o=t.classList.contains(r);return i&&o?!1:(!i&&o&&n.priorClasses.add(r),t.classList.add(r),n.classes.add(r),!0)}#v(t,n,r,i){const o=n.dataAttrs.get(r),s=t.getAttribute(r);return o===i&&s===i?!1:(!n.dataAttrs.has(r)&&s!==null&&n.priorDataAttrs.set(r,s),t.setAttribute(r,i),n.dataAttrs.set(r,i),!0)}#G(t,n,r,i){const o=n.styleProps.get(r),s=t.style.getPropertyValue(r);return o===i&&s===i?!1:(!n.styleProps.has(r)&&s&&n.priorStyleProps.set(r,s),t.style.setProperty(r,i),n.styleProps.set(r,i),!0)}#q(t,n,r){let i=!1;for(const o of r.classes)this.#L(t,n,o)&&(i=!0);for(const o of n.classes)r.classes.has(o)||(n.priorClasses.has(o)||t.classList.remove(o),n.priorClasses.delete(o),n.classes.delete(o),i=!0);for(const[o,s]of r.dataAttrs)this.#v(t,n,o,s)&&(i=!0);for(const o of n.dataAttrs.keys())if(!r.dataAttrs.has(o)){const s=n.priorDataAttrs.get(o);s!=null?t.setAttribute(o,s):t.removeAttribute(o),n.priorDataAttrs.delete(o),n.dataAttrs.delete(o),i=!0}for(const[o,s]of r.styleProps)this.#G(t,n,o,s)&&(i=!0);for(const o of n.styleProps.keys())if(!r.styleProps.has(o)){const s=n.priorStyleProps.get(o);s?t.style.setProperty(o,s):t.style.removeProperty(o),n.priorStyleProps.delete(o),n.styleProps.delete(o),i=!0}return n.classes.size===0&&n.dataAttrs.size===0&&n.styleProps.size===0&&this.#e.delete(t),i}#Y(t,n){for(const r of n.classes)n.priorClasses.has(r)||t.classList.remove(r);for(const r of n.dataAttrs.keys()){const i=n.priorDataAttrs.get(r);i!=null?t.setAttribute(r,i):t.removeAttribute(r)}for(const r of n.styleProps.keys()){const i=n.priorStyleProps.get(r);i?t.style.setProperty(r,i):t.style.removeProperty(r)}this.#e.delete(t)}},oK="interactionEpoch",sK="displayLabelSource",aK={CANONICAL:"canonical",DERIVED:"derived"};function swn(e,t){const n=e.dataset[Xl.DISPLAY_LABEL],r=e.dataset[sK];if(n!==void 0&&r!==aK.DERIVED)return{source:aK.CANONICAL,value:n};const i=t?.textContent?.trim()??"";return i.length===0?null:{source:aK.DERIVED,value:i}}var awn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e),n=this.#e.querySelectorAll(uM());for(let r=0;r<n.length;r+=1){const i=n[r];if(i.dataset[oK]===t)continue;i.dataset[oK]=t,i.draggable=!0,i.dataset[Xl.DRAGGABLE]="true";const o=swn(i,i.querySelector(`.${yn.ANNOTATION_CONTENT}`));o!==null&&(i.dataset[Xl.DISPLAY_LABEL]=o.value,i.dataset[sK]=o.source);const s=i.dataset[Xl.TYPE];s&&(i.dataset[Xl.VARIANT]=s),this.#t(i)}}clear(){if(!this.#e)return;const e=this.#e.querySelectorAll(uM());for(let t=0;t<e.length;t+=1){const n=e[t];n.removeAttribute("draggable"),delete n.dataset[Xl.DRAGGABLE],delete n.dataset[Xl.DISPLAY_LABEL],delete n.dataset[Xl.VARIANT],delete n.dataset[oK],delete n.dataset[sK],n.querySelector(`.${yn.ANNOTATION_CARET_ANCHOR}`)?.remove()}}#t(e){if(e.querySelector(`.${yn.ANNOTATION_CARET_ANCHOR}`))return;const t=e.dataset[Xl.PM_END],n=e.dataset[Xl.LAYOUT_EPOCH];if(t==null)return;const r=this.#e?.ownerDocument;if(!r)return;const i=r.createElement("span");i.dataset[Xl.PM_START]=t,i.dataset[Xl.PM_END]=t,i.dataset[Xl.LAYOUT_EPOCH]=n??"",i.classList.add(yn.ANNOTATION_CARET_ANCHOR),i.style.position="absolute",i.style.left="100%",i.style.top="0",i.style.width="0",i.style.height="1em",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.userSelect="none",i.style.opacity="0",i.textContent="​",e.style.position||(e.style.position="relative"),e.appendChild(i)}};const Ka={SPELLING:"sd-proofing-spelling",GRAMMAR:"sd-proofing-grammar",STYLE:"sd-proofing-style",DATA_ATTR:"data-sd-proofing",SPLIT_ATTR:"data-sd-proofing-split"};function fDe(e){switch(e){case"spelling":return Ka.SPELLING;case"grammar":return Ka.GRAMMAR;case"style":return Ka.STYLE}}var hDe=new WeakMap;function lwn(e,t,n,r){const i=new Set;i.add(e),i.add(t);for(const a of r){const l=Math.max(a.pmFrom,e),c=Math.min(a.pmTo,t);l>e&&i.add(l),c<t&&i.add(c)}const o=Array.from(i).sort((a,l)=>a-l),s=[];for(let a=0;a<o.length-1;a+=1){const l=o[a],c=o[a+1],u=l-e,d=c-e;if(d<=u||u>=n.length)continue;const f=Math.min(d,n.length);let h=null;for(const p of r)if(p.pmFrom<=l&&p.pmTo>=c){h=fDe(p.kind);break}s.push({textStart:u,textEnd:f,pmStart:l,pmEnd:c,proofingClass:h})}return s}function cwn(e,t,n){const r=e.parentNode;if(!r)return[];const i=e.ownerDocument,o=[];for(const l of t){const c=n.slice(l.textStart,l.textEnd);if(c.length===0)continue;const u=i.createElement("span");for(let d=0;d<e.attributes.length;d+=1){const f=e.attributes[d];u.setAttribute(f.name,f.value)}u.setAttribute("data-pm-start",String(l.pmStart)),u.setAttribute("data-pm-end",String(l.pmEnd)),l.proofingClass&&(u.classList.add(l.proofingClass),u.setAttribute("aria-invalid","spelling")),u.setAttribute(Ka.SPLIT_ATTR,""),u.setAttribute(Ka.DATA_ATTR,""),u.textContent="",u.appendChild(i.createTextNode(c)),hDe.set(u,e),o.push(u)}e.style.display="none",e.setAttribute(Ka.DATA_ATTR,"original");const s=e.getAttribute("data-pm-start"),a=e.getAttribute("data-pm-end");s&&e.setAttribute("data-sd-orig-pm-start",s),a&&e.setAttribute("data-sd-orig-pm-end",a),e.removeAttribute("data-pm-start"),e.removeAttribute("data-pm-end");for(const l of o)r.insertBefore(l,e);return o}function uwn(e){const t=Array.from(e.querySelectorAll(`[${Ka.SPLIT_ATTR}]`));if(t.length===0)return!1;const n=new Map;for(const o of t){const s=hDe.get(o);if(!s)continue;const a=n.get(s);a?a.push(o):n.set(s,[o])}for(const[o,s]of n){const a=o.parentNode;if(a){pDe(o);for(const l of s)a.removeChild(l)}}const r=Array.from(e.querySelectorAll(`[${Ka.SPLIT_ATTR}]`));for(const o of r)o.parentNode?.removeChild(o);const i=Array.from(e.querySelectorAll(`[${Ka.DATA_ATTR}="original"]`));for(const o of i)pDe(o);return!0}function pDe(e){e.style.display="",e.style.cssText||e.removeAttribute("style"),e.removeAttribute(Ka.DATA_ATTR);const t=e.getAttribute("data-sd-orig-pm-start"),n=e.getAttribute("data-sd-orig-pm-end");t&&(e.setAttribute("data-pm-start",t),e.removeAttribute("data-sd-orig-pm-start")),n&&(e.setAttribute("data-pm-end",n),e.removeAttribute("data-sd-orig-pm-end"))}function dwn(e,t){const n=lK(e);if(t.length===0)return n;const r=[...t].sort((s,a)=>s.pmFrom-a.pmFrom),i=Array.from(e.querySelectorAll("[data-pm-start][data-pm-end]"));let o=!1;for(const s of i){const a=Number.parseInt(s.getAttribute("data-pm-start")??"",10),l=Number.parseInt(s.getAttribute("data-pm-end")??"",10);if(Number.isNaN(a)||Number.isNaN(l)||l<=a||!fwn(s))continue;const c=hwn(r,a,l);if(c.length===0)continue;const u=s.textContent??"";if(u.length===0)continue;if(pwn(a,l,c)){s.classList.add(fDe(c[0].kind)),s.setAttribute(Ka.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),o=!0;continue}const d=lwn(a,l,u,c);if(d.length>1){cwn(s,d,u),o=!0;continue}d.length===1&&d[0].proofingClass&&(s.classList.add(d[0].proofingClass),s.setAttribute(Ka.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),o=!0)}return o||n}function lK(e){let t=!1;const n=uwn(e),r=Array.from(e.querySelectorAll(`[${Ka.DATA_ATTR}]`));for(const i of r)i.classList.remove(Ka.SPELLING,Ka.GRAMMAR,Ka.STYLE),i.removeAttribute(Ka.DATA_ATTR),i.removeAttribute("aria-invalid"),t=!0;return t||n}function fwn(e){const t=e.childNodes;if(t.length===0)return!1;for(let n=0;n<t.length;n+=1)if(t[n].nodeType===Node.ELEMENT_NODE)return!1;return!0}function hwn(e,t,n){const r=[];for(const i of e){if(i.pmFrom>=n)break;i.pmTo>t&&r.push(i)}return r}function pwn(e,t,n){return n.some(r=>r.pmFrom<=e&&r.pmTo>=t)}var mwn=class{#e=null;setContainer(e){this.#e=e}applyAnnotations(e){const t=this.#e;return t?!e||e.length===0?lK(t):dwn(t,e):!1}clear(){const e=this.#e;return e?lK(e):!1}},gwn=class{#e;#t;#i;#n;constructor(e={}){this.#e=e.fieldAnnotationLayer??new awn,this.#t=e.commentHighlightDecorator??new Qvn,this.#i=e.decorationBridge??new own,this.#n=e.proofingDecorator??new mwn}setContainer(e){this.#e.setContainer(e),this.#t.setContainer(e),this.#n.setContainer(e)}setActiveComment(e){return this.#t.setActiveComment(e)}recordDecorationTransaction(e){this.#i.recordTransaction(e)}hasDecorationChanges(e){return this.#i.hasChanges(e)}hasCurrentDecorationRanges(e){return this.#i.hasCurrentRanges(e)}collectDecorationRanges(e){return this.#i.collectDecorationRanges(e)}syncDecorations(e,t,n){return e?this.#i.sync(e,t,n):!1}applyCommentHighlights(){this.#t.apply()}syncInlineStyleLayers(e,t){return this.applyCommentHighlights(),this.syncDecorations(e,t)}applyProofingAnnotations(e,t){const n=this.#n.applyAnnotations(e);return n&&t(),n}refreshAfterPaint(e){this.#e.apply(e.layoutEpoch),e.rebuildDomPositionIndex(),this.syncInlineStyleLayers(e.editorState,e.domPositionIndex),this.applyProofingAnnotations(e.proofingAnnotations,e.rebuildDomPositionIndex),e.reapplyStructuredContentHover?.()}destroy(){this.#n.clear(),this.#e.clear(),this.#t.destroy(),this.#i.destroy()}},ywn=class{#e=new Map;addIssue(e){const t=this.#e.get(e.segmentId);t?t.push(e):this.#e.set(e.segmentId,[e])}remapIssues(e,t,n){for(const r of e){const i=this.#e.get(r);if(!i)continue;const o=[];for(const s of i){const a=t.mapResult(s.pmFrom,-1),l=t.mapResult(s.pmTo,1);a.deleted||l.deleted||a.pos>=l.pos||(s.pmFrom=a.pos,s.pmTo=l.pos,s.state="mapped",s.recheckId=n,o.push(s))}o.length>0?this.#e.set(r,o):this.#e.delete(r)}}replaceBatchResults(e,t,n){for(const r of t){const i=this.#e.get(r);if(!i)continue;const o=i.filter(s=>s.recheckId===null||!e.has(s.recheckId));o.length>0?this.#e.set(r,o):this.#e.delete(r)}for(const r of n)this.addIssue(r)}removeBySegmentIds(e){for(const t of e)this.#e.delete(t)}removeOrphanedSegments(e){for(const t of this.#e.keys())e.has(t)||this.#e.delete(t)}clear(){this.#e.clear()}getAllIssues(){const e=[];for(const t of this.#e.values())e.push(...t);return e}getDisplayIssues(e){const t=new Set(e.map(r=>r.normalize("NFC").toLowerCase())),n=[];for(const r of this.#e.values())for(const i of r)i.kind==="spelling"&&(bwn(i,t)||n.push(i));return n}getActiveRecheckIds(){const e=new Set;for(const t of this.#e.values())for(const n of t)n.state==="mapped"&&n.recheckId!==null&&e.add(n.recheckId);return e}get isEmpty(){return this.#e.size===0}get size(){let e=0;for(const t of this.#e.values())e+=t.length;return e}};function bwn(e,t){if(t.size===0)return!1;const n=e.word??e.message;if(!n)return!1;const r=n.normalize("NFC").toLowerCase();return t.has(r)}function vwn(e,t){const n=wwn(e);if(n)return n;const r=Awn(e);return r||t}function wwn(e){let t=null;return e.descendants(n=>{if(t)return!1;if(n.type.name==="run"){const r=n.attrs.runProperties;if(r?.lang?.val)return t=r.lang.val,!1}return!0}),t}function Awn(e){return e.attrs.paragraphProperties?.lang?.val??null}function mDe(e,t,n){const r=[],i=new Map,o=new Map;return Swn(e,(s,a,l)=>{const{text:c,slices:u}=Twn(s,a);if(c.length===0)return;const d=Cwn(s,a),f=vwn(s,t??null),h=n?.(a);r.push({id:d,text:c,language:f,metadata:{blockId:s.attrs.sdBlockId,pageIndex:h,surface:l}}),i.set(d,{segmentId:d,slices:u}),o.set(d,a)}),{segments:r,offsetMaps:i,segmentPositions:o}}function Swn(e,t){e.descendants((n,r)=>{const i=n.type.name;return i==="header"||i==="footer"?!1:i==="paragraph"?(t(n,r,xwn(e,r)?"table-cell":"body"),!1):!0})}function xwn(e,t){const n=e.resolve(t);for(let r=n.depth;r>0;r--){const i=n.node(r);if(i.type.name==="tableCell"||i.type.name==="tableHeader")return!0}return!1}function Twn(e,t){const n=[],r=[];let i=0;const o=t+1;return e.forEach((l,c)=>{s(l,o+c)}),{text:n.join(""),slices:r};function s(l,c){const u=l.type.name;if(u==="run"){const d=l.attrs.runProperties;if(d?.vanish===!0){a();return}if(d?.noProof===!0){a();return}const f=c+1;l.forEach((h,p)=>{s(h,f+p)});return}if(l.isText&&l.text){if(Iwn(l))return;const d=l.text,f=c,h=c+d.length;r.push({textStart:i,textEnd:i+d.length,pmFrom:f,pmTo:h}),n.push(d),i+=d.length;return}if(Ewn(u)){a();return}if(l.childCount>0){const d=c+1;l.forEach((f,h)=>{s(f,d+h)})}}function a(){n.length>0&&!n[n.length-1].endsWith(" ")&&(n.push(" "),i+=1)}}function Iwn(e){return e.marks?.some(t=>t.type.name==="trackDelete")??!1}var kwn=new Set(["fieldAnnotation","image","equation","hardBreak","lineBreak","tab","footnoteReference","symbol"]);function Ewn(e){return kwn.has(e)}function Cwn(e,t){const n=e.attrs.sdBlockId;return n?`blk-${n}`:`pos-${t}`}function _wn(e,t){const n=gDe(e.start,t),r=gDe(e.end,t);return n===null||r===null||n>=r?null:{...e,pmFrom:n,pmTo:r}}function gDe(e,t){for(const n of t)if(e>=n.textStart&&e<=n.textEnd){const r=e-n.textStart;return n.pmFrom+r}for(const n of t)if(n.textStart>=e)return n.pmFrom;if(t.length>0){const n=t[t.length-1];if(e>=n.textEnd)return n.pmTo}return null}function Rwn(e,t,n){if(n.length===0)return new Set;const r=new Set,i=e.map(o=>({id:o.id,pos:t.get(o.id)??-1})).filter(o=>o.pos>=0).sort((o,s)=>o.pos-s.pos);for(const o of n)for(let s=0;s<i.length;s++){const a=i[s],l=i[s+1]?.pos??1/0;a.pos<o.to&&l>o.from&&r.add(a.id),a.pos<=o.from&&l>=o.from&&s>0&&r.add(i[s-1].id)}return r}function yDe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function Pwn(e,t){const n=t.getVisiblePageIndices();if(!n||n.length===0)return e;const r=new Set(n),i=[],o=[];for(const s of e){const a=s.metadata.pageIndex;a!==void 0&&r.has(a)?i.push(s):o.push(s)}return[...i,...o]}function Lwn(e){const t=e.filter(o=>o.kind==="spelling");if(t.length===0)return[];const n=[...t].sort((o,s)=>o.pmFrom-s.pmFrom||o.pmTo-s.pmTo),r=[];let i=null;for(const o of n){if(!i){i={pmFrom:o.pmFrom,pmTo:o.pmTo,kind:"spelling",issue:o};continue}o.pmFrom<=i.pmTo?i.pmTo=Math.max(i.pmTo,o.pmTo):(r.push(i),i={pmFrom:o.pmFrom,pmTo:o.pmTo,kind:"spelling",issue:o})}return i&&r.push(i),r}function Nwn(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=n+r>>>1,o=e[i];if(t<o.pmFrom)r=i-1;else if(t>=o.pmTo)n=i+1;else return o}return null}var Mwn=500,Dwn=2e3,Own=1e4,Fwn=2,Bwn=20,Hwn=5,bDe=class{#e;#t=null;#i=null;#n="disabled";#r=new ywn;#o=new Map;#a=new Map;#c=null;#u=new Set;#d=0;#f=0;#l=!1;#s=[];#w=0;#b=!1;#x=0;#k=null;#T=null;#m=null;#y=null;#h=[];constructor(e={}){this.onResultsChanged=null,this.#e={enabled:e.enabled??!1,debounceMs:e.debounceMs??Mwn,maxSuggestions:e.maxSuggestions??Hwn,visibleFirst:e.visibleFirst??!0,allowIgnoreWord:e.allowIgnoreWord??!0,defaultLanguage:e.defaultLanguage??null,ignoredWords:e.ignoredWords??[],timeoutMs:e.timeoutMs??Own,maxConcurrentRequests:e.maxConcurrentRequests??Fwn,maxSegmentsPerBatch:e.maxSegmentsPerBatch??Bwn,onProofingError:e.onProofingError??null,onStatusChange:e.onStatusChange??null},e.provider&&(this.#t=e.provider),this.#e.enabled&&this.#t&&this.#v("idle")}get status(){return this.#n}get isEnabled(){return this.#e.enabled&&this.#t!==null}get config(){return this.#e}setVisibilitySource(e){this.#k=e}setDocumentId(e){this.#T=e}setPageResolver(e){this.#m=e}setComposing(e){this.#b=e,!e&&this.#h.length>0&&this.isEnabled&&this.#C(this.#h)}getPaintSlices(e){if(!this.isEnabled)return[];const t=Lwn(this.#r.getDisplayIssues(this.#e.ignoredWords));return e?t.filter(n=>n.pmTo<=e.from||n.pmFrom>=e.to):t}getIssueAtPosition(e,t){return Nwn(this.getPaintSlices(t),e)?.issue??null}updateConfig(e,t){const n=this.#e.enabled,r=this.#t,i=e.provider!==void 0||e.defaultLanguage!==void 0;if(e.debounceMs!==void 0&&(this.#e.debounceMs=e.debounceMs),e.maxSuggestions!==void 0&&(this.#e.maxSuggestions=e.maxSuggestions),e.visibleFirst!==void 0&&(this.#e.visibleFirst=e.visibleFirst),e.allowIgnoreWord!==void 0&&(this.#e.allowIgnoreWord=e.allowIgnoreWord),e.timeoutMs!==void 0&&(this.#e.timeoutMs=e.timeoutMs),e.maxConcurrentRequests!==void 0&&(this.#e.maxConcurrentRequests=e.maxConcurrentRequests),e.maxSegmentsPerBatch!==void 0&&(this.#e.maxSegmentsPerBatch=e.maxSegmentsPerBatch),e.onProofingError!==void 0&&(this.#e.onProofingError=e.onProofingError??null),e.onStatusChange!==void 0&&(this.#e.onStatusChange=e.onStatusChange??null),e.defaultLanguage!==void 0&&(this.#e.defaultLanguage=e.defaultLanguage??null),e.ignoredWords!==void 0&&(this.#e.ignoredWords=e.ignoredWords??[],this.onResultsChanged?.()),e.provider!==void 0&&(r&&r!==e.provider&&r.dispose?.(),this.#t=e.provider??null,this.#i=null),e.enabled!==void 0){if(this.#e.enabled=e.enabled,!e.enabled){this.#L(),this.#r.clear(),this.#a.clear(),this.#o.clear(),this.#v("disabled"),this.onResultsChanged?.();return}if(e.enabled&&!n&&t){this.#v("idle"),this.#S(t);return}}i&&this.isEnabled&&t&&(this.#L(),this.#f++,this.#r.clear(),this.#a.clear(),this.onResultsChanged?.(),this.#S(t))}onDocumentChanged(e,t,n){if(!this.isEnabled)return;this.#f++,this.#y=e;const{segments:r,offsetMaps:i,segmentPositions:o}=mDe(e,this.#e.defaultLanguage,this.#m??void 0);this.#h=r,this.#o=i;const s=Rwn(r,o,t);for(const a of s)this.#a.delete(a);if(s.size>0){const a=this.#w++;this.#r.remapIssues(s,n,a),this.#r.removeOrphanedSegments(new Set(r.map(l=>l.id)))}this.#C(r)}runInitialCheck(e){this.isEnabled&&this.#S(e)}ignoreWord(e){const t=e.normalize("NFC").toLowerCase();this.#e.ignoredWords.includes(t)||(this.#e.ignoredWords=[...this.#e.ignoredWords,t],this.onResultsChanged?.())}removeIgnoredWord(e){const t=e.normalize("NFC").toLowerCase();this.#e.ignoredWords=this.#e.ignoredWords.filter(n=>n!==t),this.onResultsChanged?.()}dispose(){this.#l=!0,this.#L(),this.#r.clear(),this.#o.clear(),this.#a.clear(),this.#y=null,this.#h=[],this.#s=[],this.#t?.dispose?.(),this.#t=null,this.#v("disabled")}#S(e){this.#y=e;const{segments:t,offsetMaps:n}=mDe(e,this.#e.defaultLanguage,this.#m??void 0);this.#h=t,this.#o=n,this.#a.clear(),this.#r.clear(),this.#C(t)}#C(e){if(this.#b)return;this.#c!==null&&clearTimeout(this.#c);const t=Date.now()-this.#x;this.#x>0&&t>=Dwn?this.#I(e):this.#c=setTimeout(()=>{this.#c=null,this.#I(e)},this.#e.debounceMs)}#I(e){this.#x=Date.now(),this.#A(e)}async#A(e){if(this.#l||!this.#t)return;if(!this.#i&&this.#t.getCapabilities)try{this.#i=await this.#t.getCapabilities()}catch{}const t=e.filter(s=>{const a=yDe(s.text);return this.#a.get(s.id)!==a});if(t.length===0){this.#v("idle");return}const n=this.#r.getActiveRecheckIds(),r=this.#e.visibleFirst&&this.#k?Pwn(t,this.#k):t,i=this.#E(r),o=this.#f;this.#s=[];for(let s=0;s<i.length;s++){if(this.#l||o!==this.#f)return;if(this.#d>=this.#e.maxConcurrentRequests){for(let a=s;a<i.length;a++)this.#s.push(...i[a]);break}this.#_(i[s],o,n)}}async#_(e,t,n){if(!this.#t||this.#l)return;const r=new AbortController;this.#u.add(r),this.#d++,this.#v("checking");const i=setTimeout(()=>r.abort(),this.#e.timeoutMs),o={documentId:this.#T,defaultLanguage:this.#e.defaultLanguage,maxSuggestions:this.#e.maxSuggestions,segments:e,signal:r.signal};try{const s=await this.#t.check(o);if(clearTimeout(i),!this.#u.delete(r))return;if(this.#d--,t!==this.#f||this.#l){this.#R();return}const a=new Set(e.map(u=>u.id)),l=new Map(e.map(u=>[u.id,u])),c=[];for(const u of s.issues){if(!this.#D(u,a,l))continue;const d=this.#o.get(u.segmentId);if(!d)continue;const f=_wn(u,d.slices);if(!f)continue;const h=l.get(u.segmentId),p={...f,state:"confirmed",recheckId:null};h&&(p.word=h.text.slice(u.start,u.end)),c.push(p)}this.#r.replaceBatchResults(n,a,c);for(const u of e)this.#a.set(u.id,yDe(u.text));this.#v(this.#d>0?"checking":"idle"),this.onResultsChanged?.(),this.#g(t,n)}catch(s){if(clearTimeout(i),!this.#u.delete(r)||(this.#d--,this.#l))return;if(t!==this.#f){this.#R();return}const a=r.signal.aborted,l={kind:a?"timeout":"provider-error",message:a?"Provider request timed out":String(s),segmentIds:e.map(c=>c.id),cause:s};this.#e.onProofingError?.(l),this.#v(this.#d>0?"checking":"degraded"),this.#g(t,n)}}#g(e,t){if(this.#l||e!==this.#f||this.#s.length===0||this.#d>=this.#e.maxConcurrentRequests)return;const n=this.#s.splice(0,this.#e.maxSegmentsPerBatch);n.length>0&&this.#_(n,e,t)}#R(){this.#l||this.#s.length===0||this.#g(this.#f,this.#r.getActiveRecheckIds())}#D(e,t,n){if(!t.has(e.segmentId))return this.#P(`Unknown segmentId: ${e.segmentId}`,[e.segmentId]),!1;const r=n.get(e.segmentId);return r?e.start<0||e.end<=e.start||e.end>r.text.length?(this.#P(`Invalid offsets [${e.start}, ${e.end}) for segment "${e.segmentId}" (length ${r.text.length})`,[e.segmentId]),!1):!0:!1}#P(e,t){this.#e.onProofingError?.({kind:"validation-error",message:e,segmentIds:t})}#E(e){const t=[];for(let n=0;n<e.length;n+=this.#e.maxSegmentsPerBatch)t.push(e.slice(n,n+this.#e.maxSegmentsPerBatch));return t}#L(){this.#c!==null&&(clearTimeout(this.#c),this.#c=null);for(const e of this.#u)e.abort();this.#u.clear(),this.#d=0,this.#s=[]}#v(e){this.#n!==e&&(this.#n=e,this.#e.onStatusChange?.(e))}};const zwn=Object.freeze({swiss:"Arial, sans-serif",roman:"Times New Roman, serif",modern:"Courier New, monospace",script:"cursive",decorative:"fantasy",system:"system-ui",auto:"sans-serif"}),vDe="sans-serif";var Uwn=new Set(["cambria","cambria math","times","times new roman","georgia","garamond","palatino","palatino linotype","book antiqua","baskerville","cochin","hoefler text","minion pro","didot","bodoni mt","constantia"]),Vwn=e=>!e||typeof e!="string"?"":e.trim().replace(/^["']|["']$/g,"").toLowerCase(),Wwn=e=>Uwn.has(Vwn(e))?"serif":vDe,Gwn=e=>(e||"").split(",").map(t=>t.trim()).filter(Boolean),jwn=(e,t)=>{if(!e.includes('"')&&!e.includes("'"))return e.split(t).map(s=>s.trim()).filter(Boolean);const n=[];let r="",i=!1,o=null;for(const s of e)!i&&(s==='"'||s==="'")?(i=!0,o=s,r+=s):i&&s===o?(i=!1,o=null,r+=s):!i&&s===t?(r.trim()&&n.push(r.trim()),r=""):r+=s;return r.trim()&&n.push(r.trim()),n};function qwn(e){return e?zwn[e.toLowerCase()]||"sans-serif":vDe}function Bp(e,t={}){if(!e||typeof e!="string")return e;let n=e.trim();if(!n||n.includes(","))return n;n.includes(";")&&(n=jwn(n,";").join(", "));const{fallback:r,wordFamily:i}=t,o=Gwn(r??(i?qwn(i):void 0)??Wwn(n));if(o.length===0)return n;const s=n.toLowerCase();return o.some(a=>a.toLowerCase()===s)?o.join(", "):[n,...o].join(", ")}var wDe=20,mb=500,Bg=5e3,Sl=["#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#70AD47"],Hg="#595959",KE="#E0E0E0",XE="#333",N3="#666",su="Calibri, Arial, sans-serif",Ywn="#f8f9fa",Kwn="#dee2e6",ADe="#6c757d",Er="http://www.w3.org/2000/svg",Fn={top:30,right:20,bottom:50,left:60},au=5;function Xwn(e,t,n){const r=e.createElement("div");return r.classList.add("superdoc-chart"),r.style.width="100%",r.style.height="100%",r.style.position="relative",!t||!t.series?.length?xl(e,r,"No chart data"):t.chartType==="barChart"?uAn(e,r,t,n):t.chartType==="lineChart"||t.chartType==="stockChart"?FDe(e,r,t,n):t.chartType==="areaChart"?sAn(e,r,t,n):t.chartType==="scatterChart"?tAn(e,r,t,n):t.chartType==="bubbleChart"?nAn(e,r,t,n):t.chartType==="radarChart"?iAn(e,r,t,n):t.chartType==="pieChart"?ODe(e,r,t,n):t.chartType==="doughnutChart"?lAn(e,r,t,n):t.chartType==="ofPieChart"?ODe(e,r,t,n):xl(e,r,`Chart: ${t.chartType}`)}function xl(e,t,n){t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.background=Ywn,t.style.border=`1px solid ${Kwn}`,t.style.borderRadius="4px",t.style.color=ADe,t.style.fontSize="13px",t.style.fontFamily=su;const r=e.createElement("span");r.textContent="📊 ",t.appendChild(r);const i=e.createElement("span");return i.textContent=n,t.appendChild(i),t}function M3(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(1)}function dS(e){let t=!1,n=e.series;return n.length>wDe&&(n=n.slice(0,wDe),t=!0),n=n.map(r=>r.values.length<=mb&&r.categories.length<=mb?r:(t=!0,{name:r.name,categories:r.categories.slice(0,mb),values:r.values.slice(0,mb),...r.xValues&&{xValues:r.xValues.slice(0,mb)},...r.bubbleSizes&&{bubbleSizes:r.bubbleSizes.slice(0,mb)}})),{series:n,truncated:t}}function Jwn(e,t,n){const r=Math.max(1,e-Fn.left-Fn.right),i=Math.max(1,t-Fn.top-Fn.bottom),o=n.flatMap(m=>m.values),s=Math.max(0,...o),a=Math.min(0,...o),l=Math.max(1,s-a),c=n[0]?.categories??[],u=Math.max(1,c.length),d=n.length,f=r/u,h=Math.max(1,f*.1),p=f-h*2;return{plotWidth:r,plotHeight:i,groupWidth:f,barWidth:Math.max(1,p/d),barGap:h,baselineY:Fn.top+i*(s/l),valueRange:l,minValue:a,maxValue:s}}function Zwn(e,t,n,r){const{groupWidth:i,barGap:o,barWidth:s,baselineY:a,valueRange:l,plotHeight:c}=r;for(let u=0;u<n.length;u++){const d=n[u],f=Sl[u%Sl.length];for(let h=0;h<d.values.length;h++){const p=d.values[h],m=Math.abs(p/l)*c,g=Fn.left+h*i+o+u*s,y=p>=0?a-m:a,v=e.createElementNS(Er,"rect");v.setAttribute("x",String(g)),v.setAttribute("y",String(y)),v.setAttribute("width",String(s)),v.setAttribute("height",String(Math.max(.5,m))),v.setAttribute("fill",f),t.appendChild(v)}}}function Qwn(e,t,n){const{plotWidth:r,plotHeight:i,baselineY:o}=n,s=e.createElementNS(Er,"line");s.setAttribute("x1",String(Fn.left)),s.setAttribute("y1",String(Fn.top)),s.setAttribute("x2",String(Fn.left)),s.setAttribute("y2",String(Fn.top+i)),s.setAttribute("stroke",Hg),s.setAttribute("stroke-width","1"),t.appendChild(s);const a=e.createElementNS(Er,"line");a.setAttribute("x1",String(Fn.left)),a.setAttribute("y1",String(o)),a.setAttribute("x2",String(Fn.left+r)),a.setAttribute("y2",String(o)),a.setAttribute("stroke",Hg),a.setAttribute("stroke-width","1"),t.appendChild(a)}function $wn(e,t,n,r,i){const{groupWidth:o,plotHeight:s}=r,a=Math.max(1,n.length),l=Math.max(8,Math.min(12,i/a/5));for(let c=0;c<n.length;c++){const u=Fn.left+c*o+o/2,d=e.createElementNS(Er,"text");d.setAttribute("x",String(u)),d.setAttribute("y",String(Fn.top+s+16)),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size",String(l)),d.setAttribute("fill",XE),d.setAttribute("font-family",su),d.textContent=n[c]??"",t.appendChild(d)}}function eAn(e,t,n,r){const{plotWidth:i,plotHeight:o,valueRange:s,minValue:a}=n,l=s/au,c=Math.max(8,Math.min(11,r/30));for(let u=0;u<=au;u++){const d=a+l*u,f=Fn.top+o-o*(d-a)/s,h=e.createElementNS(Er,"text");if(h.setAttribute("x",String(Fn.left-6)),h.setAttribute("y",String(f+3)),h.setAttribute("text-anchor","end"),h.setAttribute("font-size",String(c)),h.setAttribute("fill",N3),h.setAttribute("font-family",su),h.textContent=M3(d),t.appendChild(h),u>0&&u<au){const p=e.createElementNS(Er,"line");p.setAttribute("x1",String(Fn.left)),p.setAttribute("y1",String(f)),p.setAttribute("x2",String(Fn.left+i)),p.setAttribute("y2",String(f)),p.setAttribute("stroke",KE),p.setAttribute("stroke-width","0.5"),t.appendChild(p)}}}function fS(e,t,n,r){const i=r-12;let o=Fn.left;for(let s=0;s<n.length;s++){const a=n[s],l=Sl[s%Sl.length],c=e.createElementNS(Er,"rect");c.setAttribute("x",String(o)),c.setAttribute("y",String(i-8)),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("fill",l),t.appendChild(c);const u=e.createElementNS(Er,"text");u.setAttribute("x",String(o+14)),u.setAttribute("y",String(i)),u.setAttribute("font-size","10"),u.setAttribute("fill",XE),u.setAttribute("font-family",su),u.textContent=a.name,t.appendChild(u),o+=14+a.name.length*6+16}}function zg(e,t,n){const r=e.createElementNS(Er,"text");r.setAttribute("x",String(n-8)),r.setAttribute("y","14"),r.setAttribute("text-anchor","end"),r.setAttribute("font-size","10"),r.setAttribute("fill",ADe),r.setAttribute("font-family",su),r.textContent="Data truncated for display",t.appendChild(r)}function SDe(e,t,n,r=!1){const i=Math.max(1,e-Fn.left-Fn.right),o=Math.max(1,t-Fn.top-Fn.bottom),s=n.flatMap(p=>p.values).filter(p=>Number.isFinite(p));let a=s.length?Math.min(...s):0,l=s.length?Math.max(...s):1;r&&(a=Math.min(0,a),l=Math.max(0,l)),l===a&&(a-=1,l+=1);const c=Math.max(1,l-a),u=(0-a)/c,d=Math.max(0,Math.min(1,u)),f=Fn.top+o-o*d,h=Math.max(1,n[0]?.categories?.length??n[0]?.values?.length??1);return{plotWidth:i,plotHeight:o,minValue:a,maxValue:l,valueRange:c,baselineY:f,categoryCount:h}}function hS(e,t){return e.categoryCount<=1?Fn.left+e.plotWidth/2:Fn.left+e.plotWidth*t/(e.categoryCount-1)}function cK(e,t){return Fn.top+e.plotHeight-(t-e.minValue)/e.valueRange*e.plotHeight}function xDe(e,t,n){const r=e.createElementNS(Er,"line");r.setAttribute("x1",String(Fn.left)),r.setAttribute("y1",String(Fn.top)),r.setAttribute("x2",String(Fn.left)),r.setAttribute("y2",String(Fn.top+n.plotHeight)),r.setAttribute("stroke",Hg),r.setAttribute("stroke-width","1"),t.appendChild(r);const i=e.createElementNS(Er,"line");i.setAttribute("x1",String(Fn.left)),i.setAttribute("y1",String(n.baselineY)),i.setAttribute("x2",String(Fn.left+n.plotWidth)),i.setAttribute("y2",String(n.baselineY)),i.setAttribute("stroke",Hg),i.setAttribute("stroke-width","1"),t.appendChild(i)}function TDe(e,t,n,r,i){const o=n.length?n:Array.from({length:r.categoryCount},(l,c)=>String(c+1)),s=Math.max(1,o.length),a=Math.max(8,Math.min(12,i/s/4));for(let l=0;l<o.length;l++){const c=e.createElementNS(Er,"text");c.setAttribute("x",String(hS(r,l))),c.setAttribute("y",String(Fn.top+r.plotHeight+16)),c.setAttribute("text-anchor","middle"),c.setAttribute("font-size",String(a)),c.setAttribute("fill",XE),c.setAttribute("font-family",su),c.textContent=o[l]??"",t.appendChild(c)}}function IDe(e,t,n,r){const i=n.valueRange/au,o=Math.max(8,Math.min(11,r/30));for(let s=0;s<=au;s++){const a=n.minValue+i*s,l=Fn.top+n.plotHeight-n.plotHeight*(a-n.minValue)/n.valueRange,c=e.createElementNS(Er,"text");if(c.setAttribute("x",String(Fn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(o)),c.setAttribute("fill",N3),c.setAttribute("font-family",su),c.textContent=M3(a),t.appendChild(c),s>0&&s<au){const u=e.createElementNS(Er,"line");u.setAttribute("x1",String(Fn.left)),u.setAttribute("y1",String(l)),u.setAttribute("x2",String(Fn.left+n.plotWidth)),u.setAttribute("y2",String(l)),u.setAttribute("stroke",KE),u.setAttribute("stroke-width","0.5"),t.appendChild(u)}}}function kDe(e){const t=e.values,n=e.xValues?.length?e.xValues:t.map((s,a)=>a+1),r=e.bubbleSizes??[],i=Math.min(n.length,t.length),o=[];for(let s=0;s<i;s++){const a=n[s],l=t[s];if(!Number.isFinite(a)||!Number.isFinite(l))continue;const c=r[s];o.push({x:a,y:l,...Number.isFinite(c)?{size:c}:{}})}return o}function EDe(e,t,n,r=!1){const i=Math.max(1,e-Fn.left-Fn.right),o=Math.max(1,t-Fn.top-Fn.bottom);let s=n.length?Math.min(...n.map(g=>g.x)):0,a=n.length?Math.max(...n.map(g=>g.x)):1,l=n.length?Math.min(...n.map(g=>g.y)):0,c=n.length?Math.max(...n.map(g=>g.y)):1;r&&(s=Math.min(0,s),a=Math.max(0,a),l=Math.min(0,l),c=Math.max(0,c)),a===s&&(s-=1,a+=1),c===l&&(l-=1,c+=1);const u=Math.max(1,a-s),d=Math.max(1,c-l),f=Math.max(0,Math.min(1,(0-s)/u)),h=Math.max(0,Math.min(1,(0-l)/d)),p=Fn.left+i*f,m=Fn.top+o-o*h;return{plotWidth:i,plotHeight:o,minX:s,maxX:a,xRange:u,minY:l,maxY:c,yRange:d,axisX:p,axisY:m}}function CDe(e,t){return Fn.left+(t-e.minX)/e.xRange*e.plotWidth}function _De(e,t){return Fn.top+e.plotHeight-(t-e.minY)/e.yRange*e.plotHeight}function RDe(e,t,n){const r=e.createElementNS(Er,"line");r.setAttribute("x1",String(n.axisX)),r.setAttribute("y1",String(Fn.top)),r.setAttribute("x2",String(n.axisX)),r.setAttribute("y2",String(Fn.top+n.plotHeight)),r.setAttribute("stroke",Hg),r.setAttribute("stroke-width","1"),t.appendChild(r);const i=e.createElementNS(Er,"line");i.setAttribute("x1",String(Fn.left)),i.setAttribute("y1",String(n.axisY)),i.setAttribute("x2",String(Fn.left+n.plotWidth)),i.setAttribute("y2",String(n.axisY)),i.setAttribute("stroke",Hg),i.setAttribute("stroke-width","1"),t.appendChild(i)}function PDe(e,t,n,r){const i=Math.max(8,Math.min(11,r/30));for(let o=0;o<=au;o++){const s=o/au,a=n.minY+n.yRange*s,l=Fn.top+n.plotHeight-n.plotHeight*s,c=e.createElementNS(Er,"text");if(c.setAttribute("x",String(Fn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(i)),c.setAttribute("fill",N3),c.setAttribute("font-family",su),c.textContent=M3(a),t.appendChild(c),o>0&&o<au){const h=e.createElementNS(Er,"line");h.setAttribute("x1",String(Fn.left)),h.setAttribute("y1",String(l)),h.setAttribute("x2",String(Fn.left+n.plotWidth)),h.setAttribute("y2",String(l)),h.setAttribute("stroke",KE),h.setAttribute("stroke-width","0.5"),t.appendChild(h)}const u=n.minX+n.xRange*s,d=Fn.left+n.plotWidth*s,f=e.createElementNS(Er,"text");f.setAttribute("x",String(d)),f.setAttribute("y",String(Fn.top+n.plotHeight+16)),f.setAttribute("text-anchor","middle"),f.setAttribute("font-size",String(i)),f.setAttribute("fill",N3),f.setAttribute("font-family",su),f.textContent=M3(u),t.appendChild(f)}}function LDe(e,t){const n=e.reduce((a,l)=>a+l.length,0),r=2,i=(au+1)*2,o=Math.max(0,au-1),s=t?e.length*2:0;return n+r+i+o+s}function tAn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s.map(kDe),c=l.flat();if(c.length===0)return xl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=LDe(l,u);if(d>Bg)return xl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=EDe(i,o,c,!1),h=e.createElementNS(Er,"svg");h.setAttribute("viewBox",`0 0 ${i} ${o}`),h.setAttribute("width","100%"),h.setAttribute("height","100%"),h.style.display="block",RDe(e,h,f),PDe(e,h,f,o);for(let p=0;p<l.length;p++){const m=l[p],g=Sl[p%Sl.length];for(const y of m){const v=e.createElementNS(Er,"circle");v.setAttribute("cx",String(CDe(f,y.x))),v.setAttribute("cy",String(_De(f,y.y))),v.setAttribute("r","3"),v.setAttribute("fill",g),v.setAttribute("fill-opacity","0.85"),h.appendChild(v)}}return u&&fS(e,h,s,o),a&&zg(e,h,i),t.appendChild(h),t}function nAn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s.map(kDe),c=l.flat();if(c.length===0)return xl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=LDe(l,u);if(d>Bg)return xl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=EDe(i,o,c,!1),h=c.map(g=>g.size).filter(g=>g!=null&&g>0),p=h.length?Math.max(...h):1,m=e.createElementNS(Er,"svg");m.setAttribute("viewBox",`0 0 ${i} ${o}`),m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.style.display="block",RDe(e,m,f),PDe(e,m,f,o);for(let g=0;g<l.length;g++){const y=l[g],v=Sl[g%Sl.length];for(const b of y){const w=b.size&&b.size>0?b.size:p*.5,x=p>0?4+w/p*10:6,S=e.createElementNS(Er,"circle");S.setAttribute("cx",String(CDe(f,b.x))),S.setAttribute("cy",String(_De(f,b.y))),S.setAttribute("r",String(Math.max(2,x))),S.setAttribute("fill",v),S.setAttribute("fill-opacity","0.45"),S.setAttribute("stroke",v),S.setAttribute("stroke-width","1"),m.appendChild(S)}}return u&&fS(e,m,s,o),a&&zg(e,m,i),t.appendChild(m),t}function rAn(e,t,n){const r=4+t,i=t,o=e.reduce((a,l)=>a+1+Math.min(t,l.values.length),0),s=n?e.length*2:0;return r+i+o+s}function iAn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s[0]?.categories??[],c=Math.max(3,l.length,...s.map(S=>S.values.length)),u=n.legendPosition!==void 0,d=rAn(s,c,u);if(d>Bg)return xl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=s.flatMap(S=>S.values).filter(S=>Number.isFinite(S)),h=f.length?Math.max(...f):1,p=f.length?Math.min(...f):0,m=Math.max(1,h-Math.min(0,p)),g=e.createElementNS(Er,"svg");g.setAttribute("viewBox",`0 0 ${i} ${o}`),g.setAttribute("width","100%"),g.setAttribute("height","100%"),g.style.display="block";const y=u?34:10,v=Math.max(10,Math.min(i-60,o-y-60)/2),b=i/2,w=Fn.top+(o-Fn.top-y)/2,x=4;for(let S=1;S<=x;S++){const T=v*S/x,k=[];for(let _=0;_<c;_++){const P=-Math.PI/2+_*Math.PI*2/c;k.push(`${b+T*Math.cos(P)},${w+T*Math.sin(P)}`)}const C=e.createElementNS(Er,"polygon");C.setAttribute("points",k.join(" ")),C.setAttribute("fill","none"),C.setAttribute("stroke",KE),C.setAttribute("stroke-width","0.8"),g.appendChild(C)}for(let S=0;S<c;S++){const T=-Math.PI/2+S*Math.PI*2/c,k=b+v*Math.cos(T),C=w+v*Math.sin(T),_=e.createElementNS(Er,"line");_.setAttribute("x1",String(b)),_.setAttribute("y1",String(w)),_.setAttribute("x2",String(k)),_.setAttribute("y2",String(C)),_.setAttribute("stroke",KE),_.setAttribute("stroke-width","0.8"),g.appendChild(_);const P=v+14,E=b+P*Math.cos(T),L=w+P*Math.sin(T),R=e.createElementNS(Er,"text");R.setAttribute("x",String(E)),R.setAttribute("y",String(L)),R.setAttribute("font-size","10"),R.setAttribute("fill",XE),R.setAttribute("font-family",su),R.setAttribute("text-anchor",Math.abs(Math.cos(T))<.2?"middle":Math.cos(T)>0?"start":"end"),R.textContent=l[S]??`Category ${S+1}`,g.appendChild(R)}for(let S=0;S<s.length;S++){const T=s[S],k=Sl[S%Sl.length],C=[],_=[],P=Math.min(c,T.values.length);for(let E=0;E<P;E++){const L=T.values[E]??0,R=Math.max(0,(L-Math.min(0,p))/m)*v,O=-Math.PI/2+E*Math.PI*2/c,F=b+R*Math.cos(O),B=w+R*Math.sin(O);C.push(`${F},${B}`),_.push({x:F,y:B})}if(C.length>0){const E=e.createElementNS(Er,"polygon");E.setAttribute("points",C.join(" ")),E.setAttribute("fill",k),E.setAttribute("fill-opacity","0.18"),E.setAttribute("stroke",k),E.setAttribute("stroke-width","1.8"),g.appendChild(E)}for(const E of _){const L=e.createElementNS(Er,"circle");L.setAttribute("cx",String(E.x)),L.setAttribute("cy",String(E.y)),L.setAttribute("r","2.5"),L.setAttribute("fill",k),g.appendChild(L)}}return u&&fS(e,g,s,o),a&&zg(e,g,i),t.appendChild(g),t}function NDe(e,t,n,r){const i=e.reduce((d,f)=>d+f.values.length,0),o=e.length,s=r?i:0,a=2,l=(au+1)*2,c=t.length,u=n?e.length*2:0;return o+s+a+l+c+u}function MDe(e){let t=!1;const n=Math.min(e.values.length,mb);e.values.length>n&&(t=!0);const r=[];for(let i=0;i<n;i++){const o=Number(e.values[i]),s=Number.isFinite(o)&&o>0?o:0;r.push({label:e.categories[i]??`Category ${i+1}`,value:s,color:Sl[i%Sl.length]})}return{slices:r,truncated:t}}function oAn(e,t,n,r,i,o){const s=n.reduce((l,c)=>l+c.value,0);if(s<=0)return;let a=-Math.PI/2;for(const l of n){if(l.value<=0)continue;const c=l.value/s*Math.PI*2;if(c>=Math.PI*2-1e-4){const y=e.createElementNS(Er,"circle");y.setAttribute("cx",String(r)),y.setAttribute("cy",String(i)),y.setAttribute("r",String(o)),y.setAttribute("fill",l.color),y.setAttribute("stroke","#fff"),y.setAttribute("stroke-width",String(Math.max(1,o*.01))),t.appendChild(y);break}const u=a+c,d=r+o*Math.cos(a),f=i+o*Math.sin(a),h=r+o*Math.cos(u),p=i+o*Math.sin(u),m=c>Math.PI?1:0,g=e.createElementNS(Er,"path");g.setAttribute("d",`M ${r} ${i} L ${d} ${f} A ${o} ${o} 0 ${m} 1 ${h} ${p} Z`),g.setAttribute("fill",l.color),g.setAttribute("stroke","#fff"),g.setAttribute("stroke-width",String(Math.max(1,o*.01))),t.appendChild(g),a=u}}function DDe(e,t,n,r,i){const o=n.reduce((l,c)=>l+14+c.label.length*6+16,0);let s=Math.max(10,(r-o)/2);const a=i-14;for(const l of n){const c=e.createElementNS(Er,"rect");c.setAttribute("x",String(s)),c.setAttribute("y",String(a-8)),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("fill",l.color),t.appendChild(c);const u=e.createElementNS(Er,"text");u.setAttribute("x",String(s+14)),u.setAttribute("y",String(a)),u.setAttribute("font-size","10"),u.setAttribute("fill",XE),u.setAttribute("font-family",su),u.textContent=l.label,t.appendChild(u),s+=14+l.label.length*6+16}}function ODe(e,t,n,r){const i=n.series[0];if(!i)return xl(e,t,"No chart data");const{slices:o,truncated:s}=MDe(i);if(o.reduce((w,x)=>w+x.value,0)<=0)return xl(e,t,"No chart data");if(o.length*3>Bg)return xl(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=i.name?.trim()||"",d=u.length>0,f=d?34:10,h=c?40:10,p=Math.max(1,a-20),m=Math.max(1,l-f-h),g=a/2,y=f+m/2,v=Math.max(8,Math.min(p,m)*.45),b=e.createElementNS(Er,"svg");if(b.setAttribute("viewBox",`0 0 ${a} ${l}`),b.setAttribute("width","100%"),b.setAttribute("height","100%"),b.style.display="block",d){const w=e.createElementNS(Er,"text");w.setAttribute("x",String(g)),w.setAttribute("y","24"),w.setAttribute("text-anchor","middle"),w.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),w.setAttribute("fill",Hg),w.setAttribute("font-family",su),w.textContent=u,b.appendChild(w)}return oAn(e,b,o,g,y,v),c&&DDe(e,b,o,a,l),s&&zg(e,b,a),t.appendChild(b),t}function FDe(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=NDe(s,l,c,!0);if(u>Bg)return xl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=SDe(i,o,s,!1),f=e.createElementNS(Er,"svg");f.setAttribute("viewBox",`0 0 ${i} ${o}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",xDe(e,f,d),IDe(e,f,d,o),TDe(e,f,l,d,i);for(let h=0;h<s.length;h++){const p=s[h],m=Sl[h%Sl.length],g=[];for(let v=0;v<p.values.length;v++){const b=hS(d,v),w=cK(d,p.values[v]??0);g.push(`${b},${w}`)}if(g.length===0)continue;const y=e.createElementNS(Er,"polyline");y.setAttribute("points",g.join(" ")),y.setAttribute("fill","none"),y.setAttribute("stroke",m),y.setAttribute("stroke-width","2"),f.appendChild(y);for(let v=0;v<p.values.length;v++){const b=e.createElementNS(Er,"circle");b.setAttribute("cx",String(hS(d,v))),b.setAttribute("cy",String(cK(d,p.values[v]??0))),b.setAttribute("r","2.5"),b.setAttribute("fill",m),f.appendChild(b)}}return c&&fS(e,f,s,o),a&&zg(e,f,i),t.appendChild(f),t}function sAn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=NDe(s,l,c,!1)+s.length;if(u>Bg)return xl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=SDe(i,o,s,!0),f=e.createElementNS(Er,"svg");f.setAttribute("viewBox",`0 0 ${i} ${o}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",xDe(e,f,d),IDe(e,f,d,o),TDe(e,f,l,d,i);for(let h=0;h<s.length;h++){const p=s[h];if(p.values.length===0)continue;const m=Sl[h%Sl.length],g=[`M ${hS(d,0)} ${d.baselineY}`];for(let b=0;b<p.values.length;b++)g.push(`L ${hS(d,b)} ${cK(d,p.values[b]??0)}`);const y=hS(d,Math.max(0,p.values.length-1));g.push(`L ${y} ${d.baselineY} Z`);const v=e.createElementNS(Er,"path");v.setAttribute("d",g.join(" ")),v.setAttribute("fill",m),v.setAttribute("fill-opacity","0.35"),v.setAttribute("stroke",m),v.setAttribute("stroke-width","1.5"),f.appendChild(v)}return c&&fS(e,f,s,o),a&&zg(e,f,i),t.appendChild(f),t}function aAn(e,t,n,r,i,o,s){const a=n.reduce((c,u)=>c+u.value,0);if(a<=0)return;let l=-Math.PI/2;for(const c of n){if(c.value<=0)continue;const u=c.value/a*Math.PI*2;if(u>=Math.PI*2-1e-4){const S=e.createElementNS(Er,"circle");S.setAttribute("cx",String(r)),S.setAttribute("cy",String(i)),S.setAttribute("r",String((o+s)/2)),S.setAttribute("fill","none"),S.setAttribute("stroke",c.color),S.setAttribute("stroke-width",String(Math.max(1,o-s))),t.appendChild(S);break}const d=l+u,f=r+o*Math.cos(l),h=i+o*Math.sin(l),p=r+o*Math.cos(d),m=i+o*Math.sin(d),g=r+s*Math.cos(l),y=i+s*Math.sin(l),v=r+s*Math.cos(d),b=i+s*Math.sin(d),w=u>Math.PI?1:0,x=e.createElementNS(Er,"path");x.setAttribute("d",`M ${f} ${h} A ${o} ${o} 0 ${w} 1 ${p} ${m} L ${v} ${b} A ${s} ${s} 0 ${w} 0 ${g} ${y} Z`),x.setAttribute("fill",c.color),x.setAttribute("stroke","#fff"),x.setAttribute("stroke-width","1"),t.appendChild(x),l=d}}function lAn(e,t,n,r){const i=n.series[0];if(!i)return xl(e,t,"No chart data");const{slices:o,truncated:s}=MDe(i);if(o.reduce((x,S)=>x+S.value,0)<=0)return xl(e,t,"No chart data");if(o.length*3>Bg)return xl(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=i.name?.trim()||"",d=u.length>0,f=d?34:10,h=c?40:10,p=Math.max(1,a-20),m=Math.max(1,l-f-h),g=a/2,y=f+m/2,v=Math.max(8,Math.min(p,m)*.45),b=Math.max(2,v*.58),w=e.createElementNS(Er,"svg");if(w.setAttribute("viewBox",`0 0 ${a} ${l}`),w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.style.display="block",d){const x=e.createElementNS(Er,"text");x.setAttribute("x",String(g)),x.setAttribute("y","24"),x.setAttribute("text-anchor","middle"),x.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),x.setAttribute("fill",Hg),x.setAttribute("font-family",su),x.textContent=u,w.appendChild(x)}return aAn(e,w,o,g,y,v,b),c&&DDe(e,w,o,a,l),s&&zg(e,w,a),t.appendChild(w),t}function cAn(e,t,n){const r=e.reduce((l,c)=>l+c.values.length,0),i=2,o=t.length,s=(au+1)*2,a=n?e.length*2:0;return r+i+o+s+a}function uAn(e,t,n,r){const{width:i,height:o}=r,{series:s,truncated:a}=dS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=cAn(s,l,c);if(u>Bg)return xl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=e.createElementNS(Er,"svg");d.setAttribute("viewBox",`0 0 ${i} ${o}`),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.style.display="block";const f=Jwn(i,o,s);return Zwn(e,d,s,f),Qwn(e,d,f),$wn(e,d,l,f,i),eAn(e,d,f,o),c&&fS(e,d,s,o),a&&zg(e,d,i),t.appendChild(d),t}const JE=e=>{const t=[];return e.style!==void 0&&t.push(`s:${e.style}`),e.width!==void 0&&t.push(`w:${e.width}`),e.color!==void 0&&t.push(`c:${e.color}`),e.space!==void 0&&t.push(`sp:${e.space}`),t.join(",")},BDe=e=>{const t=[];return e.top&&t.push(`t:[${JE(e.top)}]`),e.right&&t.push(`r:[${JE(e.right)}]`),e.bottom&&t.push(`b:[${JE(e.bottom)}]`),e.left&&t.push(`l:[${JE(e.left)}]`),e.between&&t.push(`bw:[${JE(e.between)}]`),t.join(";")};var HDe=()=>(typeof process<"u"&&typeof process.env<"u",!1),dAn=class{constructor(){this.stats={totalSpans:0,validSpans:0,missingPmStart:0,missingPmEnd:0,missingBoth:0}}record(e,t){this.stats.totalSpans++,e&&t?this.stats.validSpans++:!e&&!t?this.stats.missingBoth++:e?this.stats.missingPmEnd++:this.stats.missingPmStart++}getStats(){return{...this.stats}}reset(){this.stats={totalSpans:0,validSpans:0,missingPmStart:0,missingPmEnd:0,missingBoth:0}}getCoveragePercent(){return this.stats.totalSpans===0?100:this.stats.validSpans/this.stats.totalSpans*100}logSummary(){if(!HDe())return;const e=this.getCoveragePercent(),t=this.stats;e<100&&console.warn("[PmPositionValidation] PM position coverage:",{coverage:`${e.toFixed(1)}%`,totalSpans:t.totalSpans,validSpans:t.validSpans,missingPmStart:t.missingPmStart,missingPmEnd:t.missingPmEnd,missingBoth:t.missingBoth})}};const zDe=new dAn;function uK(e,t){const n=e.pmStart!=null,r=e.pmEnd!=null;if(zDe.record(n,r),!!HDe()&&(!n||!r)){const i=e.text?e.text.substring(0,20)+(e.text.length>20?"...":""):"(no text)";console.warn(`[PmPositionValidation] Missing PM positions in ${t}:`,{hasPmStart:n,hasPmEnd:r,textPreview:i,fallback:"Will use PM DOM coordinates for cursor positioning"})}}function UDe(e,t){const n=e.pmStart!=null,r=e.pmEnd!=null;zDe.record(n,r)}var D3=96,VDe=25,Ug=D3/8;function fAn(e){const t=e.ppi??D3,n=e.heightPx??VDe,{pageSize:r,pageMargins:i}=e;if(!Number.isFinite(t)||t<=0)throw new Error(`Invalid PPI: ${t}. Must be a positive finite number.`);if(!Number.isFinite(r.width)||r.width<=0)throw new Error(`Invalid page width: ${r.width}. Must be a positive finite number.`);if(!Number.isFinite(r.height)||r.height<=0)throw new Error(`Invalid page height: ${r.height}. Must be a positive finite number.`);if(!Number.isFinite(i.left)||i.left<0)throw new Error(`Invalid left margin: ${i.left}. Must be a non-negative finite number.`);if(!Number.isFinite(i.right)||i.right<0)throw new Error(`Invalid right margin: ${i.right}. Must be a non-negative finite number.`);if(i.left+i.right>=r.width)throw new Error(`Invalid margins: left (${i.left}) + right (${i.right}) must be less than page width (${r.width}).`);const o=r.width*t,s=[];let a=0;for(let l=0;l<r.width;l++){const c=r.width-l;s.push({size:"main",height:"20%",label:l,x:a}),a+=Ug;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=Ug;if(s.push({size:"half",height:"40%",x:a}),a+=Ug,c<=.5)break;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=Ug}return{widthPx:o,heightPx:n,ticks:s,leftMarginPx:i.left*t,rightMarginPx:o-i.right*t,pageWidthInches:r.width}}function hAn(e,t,n,r=D3){return t==="left"?e/r:(n-e)/r}function pAn(e,t,n,r,i=200){if(!Number.isFinite(e))throw new Error(`Invalid handleX: ${e}. Must be a finite number.`);if(!Number.isFinite(n))throw new Error(`Invalid otherHandleX: ${n}. Must be a finite number.`);if(!Number.isFinite(r))throw new Error(`Invalid pageWidthPx: ${r}. Must be a finite number.`);if(!Number.isFinite(i))throw new Error(`Invalid minContentWidthPx: ${i}. Must be a finite number.`);if(t==="left"){const s=n-i;return Math.max(0,Math.min(s,e))}else{const o=n+i;return Math.max(o,Math.min(r,e))}}function mAn(e){const t=e.ppi??D3,n=e.heightPx??VDe,{pageWidthPx:r,leftMarginPx:i,rightMarginPx:o}=e;if(!Number.isFinite(t)||t<=0)throw new Error(`Invalid PPI: ${t}. Must be a positive finite number.`);if(!Number.isFinite(r)||r<=0)throw new Error(`Invalid page width: ${r}px. Must be a positive finite number.`);if(!Number.isFinite(e.pageHeightPx)||e.pageHeightPx<=0)throw new Error(`Invalid page height: ${e.pageHeightPx}px. Must be a positive finite number.`);if(!Number.isFinite(i)||i<0)throw new Error(`Invalid left margin: ${i}px. Must be a non-negative finite number.`);if(!Number.isFinite(o)||o<0)throw new Error(`Invalid right margin: ${o}px. Must be a non-negative finite number.`);if(i+o>=r)throw new Error(`Invalid margins: left (${i}px) + right (${o}px) must be less than page width (${r}px).`);const s=r/t,a=[];let l=0;for(let c=0;c<s;c++){const u=s-c;a.push({size:"main",height:"20%",label:c,x:l}),l+=Ug;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=Ug;if(a.push({size:"half",height:"40%",x:l}),l+=Ug,u<=.5)break;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=Ug}return{widthPx:r,heightPx:n,ticks:a,leftMarginPx:i,rightMarginPx:r-o,pageWidthInches:s}}const es={ruler:"superdoc-ruler",tick:"superdoc-ruler-tick",tickMain:"superdoc-ruler-tick--main",tickHalf:"superdoc-ruler-tick--half",tickEighth:"superdoc-ruler-tick--eighth",label:"superdoc-ruler-label",handle:"superdoc-ruler-handle",handleLeft:"superdoc-ruler-handle--left",handleRight:"superdoc-ruler-handle--right",indicator:"superdoc-ruler-indicator"};function gAn(e){const{definition:t,doc:n,interactive:r=!1}=e;(!Number.isFinite(t.widthPx)||t.widthPx<=0)&&(console.warn(`[createRulerElement] Invalid ruler width: ${t.widthPx}px. Using minimum width of 1px.`),t.widthPx=Math.max(1,t.widthPx||1)),(!t.ticks||t.ticks.length===0)&&console.warn("[createRulerElement] Ruler definition has no ticks. Ruler will be empty.");const i=n.createElement("div");i.className=es.ruler,i.style.cssText=`
358
358
  position: relative;
@@ -1107,7 +1107,7 @@ or
1107
1107
  bash: npm install skia-canvas
1108
1108
  js: import "konva/skia-backend";
1109
1109
  `,C9e=()=>{if(typeof document>"u")throw new Error(QFn)},lf=class Gze{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Gze(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),i=this.m[0]*n+this.m[2]*r,o=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=i,this.m[1]=o,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,i=this.m[1]+this.m[3]*n,o=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=o,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],i=this.m[0]*t.m[2]+this.m[2]*t.m[3],o=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,i=-this.m[2]*t,o=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],i=this.m[3],o=this.m[4],s=this.m[5],a=t*i-n*r,l={x:o,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const c=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/c):-Math.acos(t/c),l.scaleX=c,l.scaleY=a/c,l.skewX=(t*r+n*i)/a,l.skewY=0}else if(r!=0||i!=0){const c=Math.sqrt(r*r+i*i);l.rotation=Math.PI/2-(i>0?Math.acos(-r/c):-Math.acos(r/c)),l.scaleX=a/c,l.scaleY=c,l.skewX=0,l.skewY=(t*r+n*i)/a}return l.rotation=ot._getRotation(l.rotation),l}},$Fn="[object Array]",eBn="[object Number]",tBn="[object String]",nBn="[object Boolean]",rBn=Math.PI/180,iBn=180/Math.PI,YC="#",oBn="",sBn="0",aBn="Konva warning: ",_9e="Konva error: ",lBn="rgb(",uZ={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},cBn=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,u5=[],KC=null,uBn=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const ot={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===$Fn},_isNumber(e){return Object.prototype.toString.call(e)===eBn&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===tBn},_isBoolean(e){return Object.prototype.toString.call(e)===nBn},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){u5.push(e),u5.length===1&&uBn(function(){const t=u5;u5=[],t.forEach(function(n){n()})})},createCanvasElement(){C9e();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return C9e(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=ot.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(YC,oBn);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=sBn+e;return YC+e},isCanvasFarblingActive(){if(KC!==null)return KC;if(typeof document>"u")return KC=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let i=0;i<100;i++)if(n[i*4]!==40||n[i*4+1]!==40||n[i*4+2]!==40||n[i*4+3]!==255){r=!0;break}return KC=r,this.releaseCanvas(e),KC},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),YC+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return YC+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in uZ?(t=uZ[e],{r:t[0],g:t[1],b:t[2]}):e[0]===YC?this._hexToRgb(e.substring(1)):e.substr(0,4)===lBn?(t=cBn.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",ot._namedColorToRBA(e)||ot._hex3ColorToRGBA(e)||ot._hex4ColorToRGBA(e)||ot._hex6ColorToRGBA(e)||ot._hex8ColorToRGBA(e)||ot._rgbColorToRGBA(e)||ot._rgbaColorToRGBA(e)||ot._hslColorToRGBA(e)},_namedColorToRBA(e){const t=uZ[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,i=Number(n[1])/100,o=Number(n[2])/100;let s,a,l;if(i===0)return l=o*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};o<.5?s=o*(1+i):s=o+i-o*i;const c=2*o-s,u=[0,0,0];for(let d=0;d<3;d++)a=r+1/3*-(d-1),a<0&&a++,a>1&&a--,6*a<1?l=c+(s-c)*6*a:2*a<1?l=s:3*a<2?l=c+(s-c)*(2/3-a)*6:l=c,u[d]=l*255;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*rBn},radToDeg(e){return e*iBn},_degToRad(e){return ot.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),ot.degToRad(e)},_radToDeg(e){return ot.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),ot.radToDeg(e)},_getRotation(e){return on.angleDeg?ot.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(_9e+e)},error(e){console.error(_9e+e)},warn(e){on.showWarnings&&console.warn(aBn+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,i,o){let s,a,l;const c=(e-n)*(e-n)+(t-r)*(t-r);if(c==0)s=e,a=t,l=(i-n)*(i-n)+(o-r)*(o-r);else{const u=((i-e)*(n-e)+(o-t)*(r-t))/c;u<0?(s=e,a=t,l=(e-i)*(e-i)+(t-o)*(t-o)):u>1?(s=n,a=r,l=(n-i)*(n-i)+(r-o)*(r-o)):(s=e+u*(n-e),a=t+u*(r-t),l=(s-i)*(s-i)+(a-o)*(a-o))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=ot.cloneObject(e);let i=Number.MAX_VALUE;return t.forEach(function(o,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=ot._getProjectionToSegment(o.x,o.y,a.x,a.y,e.x,e.y),c=l[0],u=l[1],d=l[2];d<i&&(r.x=c,r.y=u,i=d)}),r},_prepareArrayForTween(e,t,n){const r=[],i=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)i.push({x:t[s],y:t[s+1]});const o=[];return i.forEach(function(s){const a=ot._getProjectionToLine(s,r,n);o.push(a.x),o.push(a.y)}),o},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||ot._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(ot._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){on.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,o=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,c=0;typeof r=="number"?s=a=l=c=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),c=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(i+s,o),e.lineTo(i+t-a,o),e.arc(i+t-a,o+a,a,Math.PI*3/2,0,!1),e.lineTo(i+t,o+n-c),e.arc(i+t-c,o+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,o+n),e.arc(i+l,o+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,o+s),e.arc(i+s,o+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let o=0;o<n;o++){const s=t[(o-1+n)%n],a=t[o],l=t[(o+1)%n],c={x:a.x-s.x,y:a.y-s.y},u={x:l.x-a.x,y:l.y-a.y},d=Math.hypot(c.x,c.y),f=Math.hypot(u.x,u.y);let h;typeof i=="number"?h=i:h=o<i.length?i[o]:0,h=r*Math.cos(Math.PI/n)*Math.min(1,h/r*2);const p={x:c.x/d,y:c.y/d},m={x:u.x/f,y:u.y/f},g={x:a.x-p.x*h,y:a.y-p.y*h},y={x:a.x+m.x*h,y:a.y+m.y*h};o===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y),e.arcTo(a.x,a.y,y.x,y.y,h)}}};function dBn(e){const t=[],n=e.length,r=ot;for(let i=0;i<n;i++){let o=e[i];r._isNumber(o)?o=Math.round(o*1e3)/1e3:r._isString(o)||(o=o+""),t.push(o)}return t}var R9e=",",fBn="(",hBn=")",pBn="([",mBn="])",gBn=";",yBn="()",bBn="=",P9e=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],vBn=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],wBn=100,d5=null;function L9e(){if(d5!==null)return d5;try{const e=ot.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(d5=!1,!1)}catch{return d5=!1,!1}}var f5=class{constructor(e){this.canvas=e,on.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,i="",o,s,a,l;for(o=0;o<r;o++)s=n[o],a=s.method,a?(l=s.args,i+=a,e?i+=yBn:ot._isArray(l[0])?i+=pBn+l.join(R9e)+mBn:(t&&(l=l.map(c=>typeof c=="number"?Math.floor(c):c)),i+=fBn+l.join(R9e)+hBn)):(i+=s.property,e||(i+=bBn+s.val)),i+=gBn;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=wBn&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,o){this._context.arc(e,t,n,r,i,o)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,o){this._context.bezierCurveTo(e,t,n,r,i,o)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,o){return this._context.createRadialGradient(e,t,n,r,i,o)}drawImage(e,t,n,r,i,o,s,a,l){const c=arguments,u=this._context;c.length===3?u.drawImage(e,t,n):c.length===5?u.drawImage(e,t,n,r,i):c.length===9&&u.drawImage(e,t,n,r,i,o,s,a,l)}ellipse(e,t,n,r,i,o,s,a){this._context.ellipse(e,t,n,r,i,o,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,o){this._context.setTransform(e,t,n,r,i,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,o){this._context.transform(e,t,n,r,i,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=P9e.length,n=this.setAttr,r,i;const o=function(s){let a=e[s],l;e[s]=function(){return i=dBn(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:i}),l}};for(r=0;r<t;r++)o(P9e[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};vBn.forEach(function(e){Object.defineProperty(f5.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var ABn=class extends f5{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const i=e.getFillLinearGradientColorStops();if(i&&n==="linear-gradient"){this._fillLinearGradient(e);return}const o=e.getFillRadialGradientColorStops();if(o&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):i?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let o=0;o<r.length;o+=2)i.addColorStop(r[o],r[o+1]);this.setAttr("strokeStyle",i)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const i=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",o=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=a.x*l,u=a.y*l;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",o*Math.min(Math.abs(c),Math.abs(u))),this.setAttr("shadowOffsetX",s.x*c),this.setAttr("shadowOffsetY",s.y*u)}},SBn=class extends f5{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},h5;function xBn(){if(h5)return h5;const e=ot.createCanvasElement(),t=e.getContext("2d");return h5=(function(){return(on._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),ot.releaseCanvas(e),h5}var dZ=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||on.pixelRatio||xBn(),this._canvas=ot.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return ot.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},t0=class extends dZ{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new ABn(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},fZ=class extends dZ{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new SBn(this),this.setSize(e.width,e.height)}};const Ri={get isDragging(){let e=!1;return Ri._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Ri._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Ri._dragElements.forEach((n,r)=>{const{node:i}=n,o=i.getStage();o.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=ot._getFirstPointerId(e));const s=o._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=i.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(i.startDrag({evt:e}),!i.isDragging()))return}i._setDragPosition(e,n),t.push(i)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Ri._dragElements.forEach(n=>{const{node:r}=n,i=r.getStage();if(e&&i.setPointersPositions(e),!i._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Ri.justDragged=!0,on._mouseListenClick=!1,on._touchListenClick=!1,on._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof on.Stage&&n.node;o&&t.indexOf(o)===-1&&t.push(o)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Ri._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Ri._dragElements.delete(n)})}};on.isBrowser&&(window.addEventListener("mouseup",Ri._endDragBefore,!0),window.addEventListener("touchend",Ri._endDragBefore,!0),window.addEventListener("touchcancel",Ri._endDragBefore,!0),window.addEventListener("mousemove",Ri._drag),window.addEventListener("touchmove",Ri._drag),window.addEventListener("mouseup",Ri._endDragAfter,!1),window.addEventListener("touchend",Ri._endDragAfter,!1),window.addEventListener("touchcancel",Ri._endDragAfter,!1));function n0(e){return ot._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||ot._isBoolean(e)?e:Object.prototype.toString.call(e)}function N9e(e){return e>255?255:e<0?0:Math.round(e)}function Jt(){if(on.isUnminified)return function(e,t){return ot._isNumber(e)||ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function p5(e){if(on.isUnminified)return function(t,n){let r=ot._isNumber(t),i=ot._isArray(t)&&t.length==e;return!r&&!i&&ot.warn(n0(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function hZ(){if(on.isUnminified)return function(e,t){return ot._isNumber(e)||e==="auto"||ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Rb(){if(on.isUnminified)return function(e,t){return ot._isString(e)||ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function M9e(){if(on.isUnminified)return function(e,t){const n=ot._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function TBn(){if(on.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(ot._isArray(e)?e.forEach(function(r){ot._isNumber(r)||ot.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function cf(){if(on.isUnminified)return function(e,t){return e===!0||e===!1||ot.warn(n0(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function IBn(e){if(on.isUnminified)return function(t,n){return t==null||ot.isObject(t)||ot.warn(n0(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var XC="get",JC="set";const We={addGetterSetter(e,t,n,r,i){We.addGetter(e,t,n),We.addSetter(e,t,r,i),We.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=XC+ot._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const i=this.attrs[t];return i===void 0?n:i}},addSetter(e,t,n,r){const i=JC+ot._capitalize(t);e.prototype[i]||We.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const i=JC+ot._capitalize(t);e.prototype[i]=function(o){return n&&o!==void 0&&o!==null&&(o=n.call(this,o,t)),this._setAttr(t,o),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){const o=n.length,s=ot._capitalize,a=XC+s(t),l=JC+s(t);e.prototype[a]=function(){const u={};for(let d=0;d<o;d++){const f=n[d];u[f]=this.getAttr(t+s(f))}return u};const c=IBn(n);e.prototype[l]=function(u){const d=this.attrs[t];r&&(u=r.call(this,u,t)),c&&c.call(this,u,t);for(const f in u)u.hasOwnProperty(f)&&this._setAttr(t+s(f),u[f]);return u||n.forEach(f=>{this._setAttr(t+s(f),void 0)}),this._fireChangeEvent(t,d,u),i&&i.call(this),this},We.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=ot._capitalize(t),r=JC+n,i=XC+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(e,t,n,r){ot.error("Adding deprecated "+t);const i=XC+ot._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[i]=function(){ot.error(o);const s=this.attrs[t];return s===void 0?n:s},We.addSetter(e,t,r,function(){ot.error(o)}),We.addOverloadedGetterSetter(e,t)},backCompat(e,t){ot.each(t,function(n,r){const i=e.prototype[r],o=XC+ot._capitalize(n),s=JC+ot._capitalize(n);function a(){i.apply(this,arguments),ot.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[o]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function kBn(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,i]=n;switch(r){case"blur":{const o=parseFloat(i.replace("px",""));return function(s){this.blurRadius(o*.5);const a=on.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const o=i.includes("%")?parseFloat(i)/100:parseFloat(i);return function(s){this.brightness(o);const a=on.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const o=parseFloat(i);return function(s){const a=100*(Math.sqrt(o)-1);this.contrast(a);const l=on.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(o){const s=on.Filters;s&&s.Grayscale&&s.Grayscale.call(this,o)};case"sepia":return function(o){const s=on.Filters;s&&s.Sepia&&s.Sepia.call(this,o)};case"invert":return function(o){const s=on.Filters;s&&s.Invert&&s.Invert.call(this,o)};default:ot.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var m5="absoluteOpacity",D9e="allEventListeners",qp="absoluteTransform",O9e="absoluteScale",Pb="canvas",EBn="Change",CBn="children",_Bn="konva",pZ="listening",RBn="mouseenter",PBn="mouseleave",LBn="pointerenter",NBn="pointerleave",MBn="touchenter",DBn="touchleave",F9e="set",B9e="Shape",g5=" ",H9e="stage",r0="transform",OBn="Stage",mZ="visible",FBn=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(g5),BBn=1,an=class F_{constructor(t){this._id=BBn++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===r0||t===qp)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===r0||t===qp)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const i=n.map(o=>o+"Change.konva").join(g5);this.on(i,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(Pb)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===qp&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Pb)){const{scene:t,filter:n,hit:r}=this._cache.get(Pb);ot.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(Pb)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let i=Math.ceil(n.width||r.width),o=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,c=n.offset||0,u=n.drawBorder||!1,d=n.hitCanvasPixelRatio||1;if(!i||!o){ot.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const f=Math.abs(Math.round(r.x)-a)>.5?1:0,h=Math.abs(Math.round(r.y)-l)>.5?1:0;i+=c*2+f,o+=c*2+h,a-=c,l-=c;const p=new t0({pixelRatio:s,width:i,height:o}),m=new t0({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),g=new fZ({pixelRatio:d,width:i,height:o}),y=p.getContext(),v=g.getContext(),b=new t0({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),w=b.getContext();return g.isCache=!0,p.isCache=!0,this._cache.delete(Pb),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),y.save(),v.save(),w.save(),y.translate(-a,-l),v.translate(-a,-l),w.translate(-a,-l),b.x=a,b.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(m5),this._clearSelfAndDescendantCache(O9e),this.drawScene(p,this,b),this.drawHit(g,this),this._isUnderCache=!1,y.restore(),v.restore(),u&&(y.save(),y.beginPath(),y.rect(0,0,i,o),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),ot.releaseCanvas(b._canvas),this._cache.set(Pb,{scene:p,filter:m,hit:g,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Pb)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let i=1/0,o=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(c){const u=l.point(c);i===void 0&&(i=s=u.x,o=a=u.y),i=Math.min(i,u.x),o=Math.min(o,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}),{x:i,y:o,width:s-i,height:a-o}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),i=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/i,r.height/i),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,i=n.filter,o=i.getContext(),s,a,l,c;if(!t||t.length===0)return r;if(this._filterUpToDate)return i;let u=!0;for(let f=0;f<t.length;f++)if(typeof t[f]=="string"&&L9e(),typeof t[f]!="string"||!L9e()){u=!1;break}const d=r.pixelRatio;if(i.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),u){const f=t.join(" ");return o.save(),o.setAttr("filter",f),o.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),o.restore(),this._filterUpToDate=!0,i}try{for(s=t.length,o.clear(),o.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=o.getImageData(0,0,i.getWidth(),i.getHeight()),l=0;l<s;l++)c=t[l],typeof c=="string"&&(c=kBn(c)),c.call(this,a),o.putImageData(a,0,0)}catch(f){ot.error("Unable to apply filter. "+f.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,i}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(D9e),t.length===3)return this._delegate.apply(this,t);const i=n.split(g5);for(let o=0;o<i.length;o++){const s=i[o].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(g5),i=r.length,o,s,a,l,c,u;if(this._cache&&this._cache.delete(D9e),!t)for(s in this.eventListeners)this._off(s);for(o=0;o<i;o++)if(a=r[o],l=a.split("."),c=l[0],u=l[1],c)this.eventListeners[c]&&this._off(c,u,n);else for(s in this.eventListeners)this._off(s,u,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const i=this;return this.on(t,function(o){const s=o.target.findAncestors(n,!0,i);for(let a=0;a<s.length;a++)o=ot.cloneObject(o),o.currentTarget=s[a],r.call(s[a],o)}),this}remove(){return this.isDragging()&&this.stopDrag(),Ri._dragElements.delete(this._id),Ri._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Ri._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(qp),this._clearSelfAndDescendantCache(m5),this._clearSelfAndDescendantCache(O9e),this._clearSelfAndDescendantCache(H9e),this._clearSelfAndDescendantCache(mZ),this._clearSelfAndDescendantCache(pZ)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+ot._capitalize(t);return ot._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==CBn&&(r=F9e+ot._capitalize(n),ot._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(pZ,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(mZ,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let i=!1;Ri._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(i=!0)});const o=!n&&!on.hitOnDragEnabled&&(i||on.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,i,o,s,a;function l(u){for(i=[],o=u.length,s=0;s<o;s++)a=u[s],r++,a.nodeType!==B9e&&(i=i.concat(a.getChildren().slice())),a._id===n._id&&(s=o);i.length>0&&i[0].getDepth()<=t&&l(i)}const c=this.getStage();return n.nodeType!==OBn&&c&&l(c.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(r0),this._clearSelfAndDescendantCache(qp)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const i=this.getAbsoluteTransform(t).getMatrix(),o=new lf,s=this.offset();return o.m=i.slice(),o.translate(s.x,s.y),o.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...i}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(r0);const o=this._getAbsoluteTransform().copy();return o.invert(),o.translate(t.x,t.y),t={x:this.attrs.x+o.getTranslation().x,y:this.attrs.y+o.getTranslation().y},this._setTransform(i),this.setPosition({x:t.x,y:t.y}),this._clearCache(r0),this._clearSelfAndDescendantCache(qp),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,i=this.x(),o=this.y();return n!==void 0&&(i+=n),r!==void 0&&(o+=r),this.setPosition({x:i,y:o}),this}_eachAncestorReverse(t,n){let r=[],i=this.getParent(),o,s;if(!(n&&n._id===this._id)){for(r.unshift(this);i&&(!n||i._id!==n._id);)r.unshift(i),i=i.parent;for(o=r.length,s=0;s<o;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return ot.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return ot.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return ot.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return ot.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return ot.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&ot.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(m5,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,i,o,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=ot.isObject(r)&&!ot._isPlainObject(r)&&!ot._isArray(r),!s&&(i=typeof this[n]=="function"&&this[n],delete t[n],o=i?i.call(this):null,t[n]=r,o!==r&&(a.attrs[n]=r));return ot._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const i=[];n&&this._isMatch(t)&&i.push(this);let o=this.parent;for(;o;){if(o===r)return i;o._isMatch(t)&&i.push(o),o=o.parent}return i}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,i,o;for(i=0;i<r;i++)if(o=n[i],ot.isValidSelector(o)||(ot.warn('Selector "'+o+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),ot.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),ot.warn("Konva is awesome, right?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(H9e,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(qp,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new lf,this._eachAncestorReverse(function(r){const i=r.transformsEnabled();i==="all"?n.multiply(r.getTransform()):i==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(qp)||new lf,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const i=this.attrs.x||0,o=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(i-s,o-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(r0,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(r0)||new lf;r.reset();const i=this.x(),o=this.y(),s=on.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,c=this.attrs.skewX||0,u=this.attrs.skewY||0,d=this.attrs.offsetX||0,f=this.attrs.offsetY||0;return(i!==0||o!==0)&&r.translate(i,o),s!==0&&r.rotate(s),(c!==0||u!==0)&&r.skew(c,u),(a!==1||l!==1)&&r.scale(a,l),(d!==0||f!==0)&&r.translate(-1*d,-1*f),r.dirty=!1,r}clone(t){let n=ot.cloneObject(this.attrs),r,i,o,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(i=this.eventListeners[r],o=i.length,s=0;s<o;s++)a=i[s],a.name.indexOf(_Bn)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),i=t.x!==void 0?t.x:Math.floor(n.x),o=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new t0({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),c=new t0({width:a.width/a.pixelRatio+Math.abs(i),height:a.height/a.pixelRatio+Math.abs(o),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(i||o)&&l.translate(-1*i,-1*o),this.drawScene(a,void 0,c),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,i=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(i),i}toImage(t){return new Promise((n,r)=>{try{const i=t?.callback;i&&delete t.callback,ot._urlToImage(this.toDataURL(t),function(o){n(o),i?.(o)})}catch(i){r(i)}})}toBlob(t){return new Promise((n,r)=>{try{const i=t?.callback;i&&delete t.callback,this.toCanvas(t).toBlob(o=>{n(o),i?.(o)},t?.mimeType,t?.quality)}catch(i){r(i)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():on.dragDistance}_off(t,n,r){let i=this.eventListeners[t],o,s,a;for(o=0;o<i.length;o++)if(s=i[o].name,a=i[o].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(i.splice(o,1),i.length===0){delete this.eventListeners[t];break}o--}}_fireChangeEvent(t,n,r){this._fire(t+EBn,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[F9e+ot._capitalize(t)];return ot._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(on.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!ot.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let i;r!==void 0&&(i=this.attrs[t],i||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,i,r))}_fireAndBubble(t,n,r){n&&this.nodeType===B9e&&(n.target=this);const i=[RBn,PBn,LBn,NBn,MBn,DBn];if(!(i.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const o=i.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:i}=this,o=F_.protoListenerMap.get(i)||{};let s=o?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}o[t]=s,F_.protoListenerMap.set(i,o)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const o=r.slice();for(let s=0;s<o.length;s++)o[s].handler.call(this,n)}const i=this.eventListeners[t];if(i){const o=i.slice(),s=o.length;for(let l=0;l<o.length;l++)o[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),i=this.getAbsolutePosition();if(!r)return;const o=r._getPointerById(n)||r._changedPointerPositions[0]||i;Ri._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-i.x,y:o.y-i.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Ri._dragElements.has(this._id)||this._createDragElement(t);const r=Ri._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let i={x:r.x-n.offset.x,y:r.y-n.offset.y};const o=this.dragBoundFunc();if(o!==void 0){const s=o.call(this,i,t);s?i=s:ot.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==i.x||this._lastPos.y!==i.y)&&(this.setAbsolutePosition(i),this._requestDraw()),this._lastPos=i}stopDrag(t){const n=Ri._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Ri._endDragBefore(t),Ri._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Ri._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||on.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Ri._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Ri._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Ri._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return ot.haveIntersection(r,this.getClientRect())}static create(t,n){return ot._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=F_.prototype.getClassName.call(t),i=t.children,o,s,a;n&&(t.attrs.container=n),on[r]||(ot.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=on[r];if(o=new l(t.attrs),i)for(s=i.length,a=0;a<s;a++)o.add(F_._createNode(i[a]));return o}};an.protoListenerMap=new Map,an.prototype.nodeType="Node",an.prototype._attrsAffectingSize=[],an.prototype.eventListeners={},an.prototype.on(FBn,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(r0),this._clearSelfAndDescendantCache(qp)}),an.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(mZ)}),an.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(pZ)}),an.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(m5)});var mo=We.addGetterSetter;mo(an,"zIndex"),mo(an,"absolutePosition"),mo(an,"position"),mo(an,"x",0,Jt()),mo(an,"y",0,Jt()),mo(an,"globalCompositeOperation","source-over",Rb()),mo(an,"opacity",1,Jt()),mo(an,"name","",Rb()),mo(an,"id","",Rb()),mo(an,"rotation",0,Jt()),We.addComponentsGetterSetter(an,"scale",["x","y"]),mo(an,"scaleX",1,Jt()),mo(an,"scaleY",1,Jt()),We.addComponentsGetterSetter(an,"skew",["x","y"]),mo(an,"skewX",0,Jt()),mo(an,"skewY",0,Jt()),We.addComponentsGetterSetter(an,"offset",["x","y"]),mo(an,"offsetX",0,Jt()),mo(an,"offsetY",0,Jt()),mo(an,"dragDistance",void 0,Jt()),mo(an,"width",0,Jt()),mo(an,"height",0,Jt()),mo(an,"listening",!0,cf()),mo(an,"preventDefault",!0,cf()),mo(an,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),mo(an,"visible",!0,cf()),mo(an,"transformsEnabled","all",Rb()),mo(an,"size"),mo(an,"dragBoundFunc"),mo(an,"draggable",!1,cf()),We.backCompat(an,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var fu=class extends an{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=an.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=an.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),i=e||r&&r.getCanvas(),o=i&&i.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=i&&i.isCache;if(!this.isVisible()&&!l)return this;if(a){o.save();const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",i,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){i.save();const s=this.getAbsoluteTransform(t).getMatrix();i.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var i;const o=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),c=typeof s=="number"&&typeof a=="number"||l,u=n===this;if(c){o.save();const f=this.getAbsoluteTransform(n);let h=f.getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),o.beginPath();let p;if(l)p=l.call(this,o,this);else{const m=this.clipX(),g=this.clipY();o.rect(m||0,g||0,s,a)}o.clip.apply(o,p),h=f.copy().invert().getMatrix(),o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}const d=!u&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(o.save(),o._applyGlobalCompositeOperation(this)),(i=this.children)===null||i===void 0||i.forEach(function(f){f[e](t,n,r)}),d&&o.restore(),c&&o.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let i,o,s,a,l={x:1/0,y:1/0,width:0,height:0};const c=this;(t=this.children)===null||t===void 0||t.forEach(function(f){if(!f.visible())return;const h=f.getClientRect({relativeTo:c,skipShadow:e.skipShadow,skipStroke:e.skipStroke});h.width===0&&h.height===0||(i===void 0?(i=h.x,o=h.y,s=h.x+h.width,a=h.y+h.height):(i=Math.min(i,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x+h.width),a=Math.max(a,h.y+h.height)))});const u=this.find("Shape");let d=!1;for(let f=0;f<u.length;f++)if(u[f]._isVisible(this)){d=!0;break}return d&&i!==void 0?l={x:i,y:o,width:s-i,height:a-o}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};We.addComponentsGetterSetter(fu,"clip",["x","y","width","height"]),We.addGetterSetter(fu,"clipX",void 0,Jt()),We.addGetterSetter(fu,"clipY",void 0,Jt()),We.addGetterSetter(fu,"clipWidth",void 0,Jt()),We.addGetterSetter(fu,"clipHeight",void 0,Jt()),We.addGetterSetter(fu,"clipFunc");var ZC=new Map,z9e=on._global.PointerEvent!==void 0;function gZ(e){return ZC.get(e)}function yZ(e){return{evt:e,pointerId:e.pointerId}}function U9e(e,t){return ZC.get(e)===t}function V9e(e,t){QC(e),t.getStage()&&(ZC.set(e,t),z9e&&t._fire("gotpointercapture",yZ(new PointerEvent("gotpointercapture"))))}function QC(e,t){const n=ZC.get(e);if(!n)return;const r=n.getStage();r&&r.content,ZC.delete(e),z9e&&n._fire("lostpointercapture",yZ(new PointerEvent("lostpointercapture")))}var HBn="Stage",zBn="string",W9e="px",UBn="mouseout",G9e="mouseleave",j9e="mouseover",q9e="mouseenter",Y9e="mousemove",K9e="mousedown",X9e="mouseup",$C="pointermove",e_="pointerdown",$S="pointerup",t_="pointercancel",VBn="lostpointercapture",y5="pointerout",n_="pointerleave",b5="pointerover",v5="pointerenter",bZ="contextmenu",J9e="touchstart",Z9e="touchend",Q9e="touchmove",$9e="touchcancel",vZ="wheel",WBn=5,GBn=[[q9e,"_pointerenter"],[K9e,"_pointerdown"],[Y9e,"_pointermove"],[X9e,"_pointerup"],[G9e,"_pointerleave"],[J9e,"_pointerdown"],[Q9e,"_pointermove"],[Z9e,"_pointerup"],[$9e,"_pointercancel"],[j9e,"_pointerover"],[vZ,"_wheel"],[bZ,"_contextmenu"],[e_,"_pointerdown"],[$C,"_pointermove"],[$S,"_pointerup"],[t_,"_pointercancel"],[n_,"_pointerleave"],[VBn,"_lostpointercapture"]],wZ={mouse:{[y5]:UBn,[n_]:G9e,[b5]:j9e,[v5]:q9e,[$C]:Y9e,[e_]:K9e,[$S]:X9e,[t_]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[y5]:"touchout",[n_]:"touchleave",[b5]:"touchover",[v5]:"touchenter",[$C]:Q9e,[e_]:J9e,[$S]:Z9e,[t_]:$9e,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[y5]:y5,[n_]:n_,[b5]:b5,[v5]:v5,[$C]:$C,[e_]:e_,[$S]:$S,[t_]:t_,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},r_=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",ex=e=>{const t=r_(e);if(t==="pointer")return on.pointerEventsEnabled&&wZ.pointer;if(t==="touch")return wZ.touch;if(t==="mouse")return wZ.mouse};function e7e(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&ot.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var jBn="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";const i_=[];var w5=class extends fu{constructor(e){super(e7e(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),i_.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{e7e(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||ot.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===zBn){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),fu.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&ot._isInDocument(e)&&this.container().removeChild(e);const t=i_.indexOf(this);return t>-1&&i_.splice(t,1),ot.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(ot.warn(jBn),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new t0({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(i){if(!i.isVisible())return;const o=i._toKonvaCanvas(e);n.drawImage(o._canvas,e.x,e.y,o.getWidth()/o.getPixelRatio(),o.getHeight()/o.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const i=t[r].getIntersection(e);if(i)return i}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+W9e,this.content.style.height=t+W9e),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>WBn&&ot.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),on.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return U9e(e,this)}setPointerCapture(e){V9e(e,this)}releaseCapture(e){QC(e,this)}getLayers(){return this.children}_bindContentEvents(){on.isBrowser&&GBn.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=ex(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=ex(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=ex(e.type),n=r_(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),i=!(on.isDragging()||on.isTransforming())||on.hitOnDragEnabled;r&&i?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):i&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=ex(e.type),n=r_(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{const o=this.getIntersection(i);if(Ri.justDragged=!1,on["_"+n+"ListenClick"]=!0,!o||!o.isListening()){this[n+"ClickStartShape"]=void 0;return}on.capturePointerEventsEnabled&&o.setPointerCapture(i.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;const s=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=ex(e.type),n=r_(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(on.isDragging()&&Ri.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(on.isDragging()||on.isTransforming())||on.hitOnDragEnabled))return;const i={};let o=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=gZ(a.id)||this.getIntersection(a),c=a.id,u={evt:e,pointerId:c},d=s!==l;if(d&&s&&(s._fireAndBubble(t.pointerout,{...u},l),s._fireAndBubble(t.pointerleave,{...u},l)),l){if(i[l._id])return;i[l._id]=!0}l&&l.isListening()?(o=!0,d&&(l._fireAndBubble(t.pointerover,{...u},s),l._fireAndBubble(t.pointerenter,{...u},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...u})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+"targetShape"]=null)}),o||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=ex(e.type),n=r_(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],i=this[n+"ClickEndShape"],o={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=gZ(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),o[l._id])return;o[l._id]=!0}const c=a.id,u={evt:e,pointerId:c};let d=!1;on["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Ri.justDragged||(on["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){on["_"+n+"InDblClickWindow"]=!1},on.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...u}),on["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...u}),d&&i&&i===l&&l._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),on["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:c}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:c}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),on["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(bZ,{evt:e}):this._fire(bZ,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(vZ,{evt:e}):this._fire(vZ,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=gZ(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble($S,yZ(e)),QC(e.pointerId)}_lostpointercapture(e){QC(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,i=>{this._pointerPositions.push({id:i.identifier,x:(i.clientX-t.left)/t.scaleX,y:(i.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,i=>{this._changedPointerPositions.push({id:i.identifier,x:(i.clientX-t.left)/t.scaleX,y:(i.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:ot._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:ot._getFirstPointerId(e)}])}_setPointerPosition(e){ot.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new t0({width:this.width(),height:this.height()}),this.bufferHitCanvas=new fZ({pixelRatio:1,width:this.width(),height:this.height()}),!on.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return ot.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};w5.prototype.nodeType=HBn,ss(w5),We.addGetterSetter(w5,"container"),on.isBrowser&&document.addEventListener("visibilitychange",()=>{i_.forEach(e=>{e.batchDraw()})});var t7e="hasShadow",n7e="shadowRGBA",r7e="patternImage",i7e="linearGradient",o7e="radialGradient",A5;function AZ(){return A5||(A5=ot.createCanvasElement().getContext("2d"),A5)}const o_={};function qBn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function YBn(e){e.stroke()}function KBn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function XBn(e){e.stroke()}function JBn(){this._clearCache(t7e)}function ZBn(){this._clearCache(n7e)}function QBn(){this._clearCache(r7e)}function $Bn(){this._clearCache(i7e)}function e8n(){this._clearCache(o7e)}var Yt=class extends an{constructor(e){super(e);let t,n=0;for(;t=ot.getHitColor(),!(t&&!(t in o_));)if(n++,n>=1e4){ot.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=ot.getRandomColor();break}this.colorKey=t,o_[t]=this}getContext(){return ot.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return ot.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(t7e,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(r7e,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=AZ().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new lf;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(on.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(i7e,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=AZ(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let o=0;o<e.length;o+=2)i.addColorStop(e[o],e[o+1]);return i}}_getRadialGradient(){return this._getCache(o7e,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=AZ(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let o=0;o<e.length;o+=2)i.addColorStop(e[o],e[o+1]);return i}}getShadowRGBA(){return this._getCache(n7e,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=ot.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return an.prototype.destroy.call(this),delete o_[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),i=this.getAbsoluteOpacity()!==1;if(n&&r&&i)return!0;const o=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&o&&s)}setStrokeHitEnabled(e){ot.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,i=e.relativeTo||t&&this.getStage()||void 0,o=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=o.width+s,l=o.height+s,c=!e.skipShadow&&this.hasShadow(),u=c?this.shadowOffsetX():0,d=c?this.shadowOffsetY():0,f=a+Math.abs(u),h=l+Math.abs(d),p=c&&this.shadowBlur()||0,m={width:f+p*2,height:h+p*2,x:-(s/2+p)+Math.min(u,0)+o.x,y:-(s/2+p)+Math.min(d,0)+o.y};return r?m:this._transformedRect(m,i)}drawScene(e,t,n){const r=this.getLayer(),i=(e||r.getCanvas()).getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const c=t===this;if(!this.isVisible()&&!c)return this;if(o){i.save();const u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),this._useBufferCanvas()){l=this.getStage();const u=n||l.bufferCanvas,d=u.getContext();n?(d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),d.restore()):d.clear(),d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);const f=this.getAbsoluteTransform(t).getMatrix();d.transform(f[0],f[1],f[2],f[3],f[4],f[5]),s.call(this,d,this),d.restore();const h=u.pixelRatio;a&&i._applyShadow(this),c||(i._applyOpacity(this),i._applyGlobalCompositeOperation(this)),i.drawImage(u._canvas,u.x||0,u.y||0,u.width/h,u.height/h)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!c){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}a&&i._applyShadow(this),s.call(this,i,this)}return i.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),i=e||r.hitCanvas,o=i&&i.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||ot.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();const c=this.getAbsoluteTransform(t).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),o._applyLineJoin(this),o._applyMiterLimit(this),this!==t){const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return s.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,i=r.getContext(),o=r.getWidth(),s=r.getHeight();i.clear(),i.drawImage(n._canvas,0,0,o,s);try{const a=i.getImageData(0,0,o,s),l=a.data,c=l.length,u=ot._hexToRgb(this.colorKey);for(let d=0;d<c;d+=4)l[d+3]>e?(l[d]=u.r,l[d+1]=u.g,l[d+2]=u.b,l[d+3]=255):l[d+3]=0;i.putImageData(a,0,0)}catch(a){ot.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return U9e(e,this)}setPointerCapture(e){V9e(e,this)}releaseCapture(e){QC(e,this)}};Yt.prototype._fillFunc=qBn,Yt.prototype._strokeFunc=YBn,Yt.prototype._fillFuncHit=KBn,Yt.prototype._strokeFuncHit=XBn,Yt.prototype._centroid=!1,Yt.prototype.nodeType="Shape",ss(Yt),Yt.prototype.eventListeners={},Yt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",JBn),Yt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",ZBn),Yt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",QBn),Yt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",$Bn),Yt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",e8n),We.addGetterSetter(Yt,"stroke",void 0,M9e()),We.addGetterSetter(Yt,"strokeWidth",2,Jt()),We.addGetterSetter(Yt,"fillAfterStrokeEnabled",!1),We.addGetterSetter(Yt,"hitStrokeWidth","auto",hZ()),We.addGetterSetter(Yt,"strokeHitEnabled",!0,cf()),We.addGetterSetter(Yt,"perfectDrawEnabled",!0,cf()),We.addGetterSetter(Yt,"shadowForStrokeEnabled",!0,cf()),We.addGetterSetter(Yt,"lineJoin"),We.addGetterSetter(Yt,"lineCap"),We.addGetterSetter(Yt,"miterLimit"),We.addGetterSetter(Yt,"sceneFunc"),We.addGetterSetter(Yt,"hitFunc"),We.addGetterSetter(Yt,"dash"),We.addGetterSetter(Yt,"dashOffset",0,Jt()),We.addGetterSetter(Yt,"shadowColor",void 0,Rb()),We.addGetterSetter(Yt,"shadowBlur",0,Jt()),We.addGetterSetter(Yt,"shadowOpacity",1,Jt()),We.addComponentsGetterSetter(Yt,"shadowOffset",["x","y"]),We.addGetterSetter(Yt,"shadowOffsetX",0,Jt()),We.addGetterSetter(Yt,"shadowOffsetY",0,Jt()),We.addGetterSetter(Yt,"fillPatternImage"),We.addGetterSetter(Yt,"fill",void 0,M9e()),We.addGetterSetter(Yt,"fillPatternX",0,Jt()),We.addGetterSetter(Yt,"fillPatternY",0,Jt()),We.addGetterSetter(Yt,"fillLinearGradientColorStops"),We.addGetterSetter(Yt,"strokeLinearGradientColorStops"),We.addGetterSetter(Yt,"fillRadialGradientStartRadius",0),We.addGetterSetter(Yt,"fillRadialGradientEndRadius",0),We.addGetterSetter(Yt,"fillRadialGradientColorStops"),We.addGetterSetter(Yt,"fillPatternRepeat","repeat"),We.addGetterSetter(Yt,"fillEnabled",!0),We.addGetterSetter(Yt,"strokeEnabled",!0),We.addGetterSetter(Yt,"shadowEnabled",!0),We.addGetterSetter(Yt,"dashEnabled",!0),We.addGetterSetter(Yt,"strokeScaleEnabled",!0),We.addGetterSetter(Yt,"fillPriority","color"),We.addComponentsGetterSetter(Yt,"fillPatternOffset",["x","y"]),We.addGetterSetter(Yt,"fillPatternOffsetX",0,Jt()),We.addGetterSetter(Yt,"fillPatternOffsetY",0,Jt()),We.addComponentsGetterSetter(Yt,"fillPatternScale",["x","y"]),We.addGetterSetter(Yt,"fillPatternScaleX",1,Jt()),We.addGetterSetter(Yt,"fillPatternScaleY",1,Jt()),We.addComponentsGetterSetter(Yt,"fillLinearGradientStartPoint",["x","y"]),We.addComponentsGetterSetter(Yt,"strokeLinearGradientStartPoint",["x","y"]),We.addGetterSetter(Yt,"fillLinearGradientStartPointX",0),We.addGetterSetter(Yt,"strokeLinearGradientStartPointX",0),We.addGetterSetter(Yt,"fillLinearGradientStartPointY",0),We.addGetterSetter(Yt,"strokeLinearGradientStartPointY",0),We.addComponentsGetterSetter(Yt,"fillLinearGradientEndPoint",["x","y"]),We.addComponentsGetterSetter(Yt,"strokeLinearGradientEndPoint",["x","y"]),We.addGetterSetter(Yt,"fillLinearGradientEndPointX",0),We.addGetterSetter(Yt,"strokeLinearGradientEndPointX",0),We.addGetterSetter(Yt,"fillLinearGradientEndPointY",0),We.addGetterSetter(Yt,"strokeLinearGradientEndPointY",0),We.addComponentsGetterSetter(Yt,"fillRadialGradientStartPoint",["x","y"]),We.addGetterSetter(Yt,"fillRadialGradientStartPointX",0),We.addGetterSetter(Yt,"fillRadialGradientStartPointY",0),We.addComponentsGetterSetter(Yt,"fillRadialGradientEndPoint",["x","y"]),We.addGetterSetter(Yt,"fillRadialGradientEndPointX",0),We.addGetterSetter(Yt,"fillRadialGradientEndPointY",0),We.addGetterSetter(Yt,"fillPatternRotation",0),We.addGetterSetter(Yt,"fillRule",void 0,Rb()),We.backCompat(Yt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var t8n="beforeDraw",n8n="draw",s7e=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],r8n=s7e.length,Lb=class extends fu{constructor(e){super(e),this.canvas=new t0,this.hitCanvas=new fZ({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){an.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!an.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(an.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(an.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return an.prototype.remove.call(this),e&&e.parentNode&&ot._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&ot.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),an.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){ot.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){ot.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,ot.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<r8n;r++){const i=s7e[r],o=this._getIntersection({x:e.x+i.x*t,y:e.y+i.y*t}),s=o.shape;if(s)return s;if(n=!!o.antialiased,!o.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const i=o_[ot.getHitColorKey(n[0],n[1],n[2])];return i?{shape:i}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(t8n,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),fu.prototype.drawScene.call(this,i,t,n),this._fire(n8n,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),fu.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){ot.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return ot.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return ot.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Lb.prototype.nodeType="Layer",ss(Lb),We.addGetterSetter(Lb,"imageSmoothingEnabled",!0),We.addGetterSetter(Lb,"clearBeforeDraw",!0),We.addGetterSetter(Lb,"hitGraphEnabled",!0,cf());var SZ=class extends Lb{constructor(e){super(e),this.listening(!1),ot.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};SZ.prototype.nodeType="FastLayer",ss(SZ);var tx=class extends fu{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&ot.throw("You may only add groups and shapes to groups.")}};tx.prototype.nodeType="Group",ss(tx);var xZ=(function(){return _b.performance&&_b.performance.now?function(){return _b.performance.now()}:function(){return new Date().getTime()}})(),nx=class Ex{constructor(t,n){this.id=Ex.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:xZ(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let i=0;i<r;i++)if(n[i]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Ex.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=xZ(),Ex._addAnimation(this),this}stop(){return Ex._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,i=r.length;for(let o=0;o<i;o++)if(r[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const i=n[r],o=i.layers,s=i.func;i._updateFrameObject(xZ());const a=o.length;let l;if(s?l=s.call(i,i.frame)!==!1:l=!0,!!l)for(let c=0;c<a;c++){const u=o[c];u._id!==void 0&&(t[u._id]=u)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Ex;t.animations.length?(t._runFrames(),ot.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,ot.requestAnimFrame(this._animationLoop))}};nx.animations=[],nx.animIdCounter=0,nx.animRunning=!1;var i8n={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o8n=1,a7e=2,l7e=3,c7e=["fill","stroke","shadowColor"],s8n=0,a8n=class{constructor(e,t,n,r,i,o,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=a7e,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=l7e,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===a7e?this.setTime(e):this.state===l7e&&this.setTime(this.duration-e)}pause(){this.state=o8n,this.fire("onPause")}getTimer(){return new Date().getTime()}},S5=class ys{constructor(t){const n=this,r=t.node,i=r._id,o=t.easing||s_.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=s8n++;const c=r.getLayer()||(r instanceof on.Stage?r.getLayers():null);c||ot.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new nx(function(){n.tween.onEnterFrame()},c),this.tween=new a8n(l,function(u){n._tweenFunc(u)},o,0,1,a*1e3,s),this._addListeners(),ys.attrs[i]||(ys.attrs[i]={}),ys.attrs[i][this._id]||(ys.attrs[i][this._id]={}),ys.tweens[i]||(ys.tweens[i]={});for(l in t)i8n[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,i=r._id;let o,s,a,l,c;const u=ys.tweens[i][t];u&&delete ys.attrs[i][u][t];let d=r.getAttr(t);if(ot._isArray(n))if(o=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=ot._prepareArrayForTween(d,n,r.closed())):(a=n,n=ot._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let f=0;f<s;f++)if(f%2===0)o.push(n[f]-d[f]);else{const h=ot.colorToRGBA(d[f]);c=ot.colorToRGBA(n[f]),d[f]=h,o.push({r:c.r-h.r,g:c.g-h.g,b:c.b-h.b,a:c.a-h.a})}else for(let f=0;f<s;f++)o.push(n[f]-d[f]);else c7e.indexOf(t)!==-1?(d=ot.colorToRGBA(d),c=ot.colorToRGBA(n),o={r:c.r-d.r,g:c.g-d.g,b:c.b-d.b,a:c.a-d.a}):o=n-d;ys.attrs[i][this._id][t]={start:d,diff:o,end:n,trueEnd:a,trueStart:l},ys.tweens[i][t]=this._id}_tweenFunc(t){const n=this.node,r=ys.attrs[n._id][this._id];let i,o,s,a,l,c,u,d;for(i in r){if(o=r[i],s=o.start,a=o.diff,d=o.end,ot._isArray(s))if(l=[],u=Math.max(s.length,d.length),i.indexOf("fill")===0)for(c=0;c<u;c++)c%2===0?l.push((s[c]||0)+a[c]*t):l.push("rgba("+Math.round(s[c].r+a[c].r*t)+","+Math.round(s[c].g+a[c].g*t)+","+Math.round(s[c].b+a[c].b*t)+","+(s[c].a+a[c].a*t)+")");else for(c=0;c<u;c++)l.push((s[c]||0)+a[c]*t);else c7e.indexOf(i)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(i,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=ys.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=ys.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=ys.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const i in r)delete ys.tweens[t][i];delete ys.attrs[t][n],ys.tweens[t]&&(Object.keys(ys.tweens[t]).length===0&&delete ys.tweens[t],Object.keys(ys.attrs[t]).length===0&&delete ys.attrs[t])}};S5.attrs={},S5.tweens={},an.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new S5(e).play()};const s_={BackEaseIn(e,t,n,r){return n*(e/=r)*e*((1.70158+1)*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*((1.70158+1)*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r)===1?t+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),-(i*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o))+t)},ElasticEaseOut(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r)===1?t+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),i*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,r,i,o){let s=0;return e===0?t:(e/=r/2)===2?t+n:(o||(o=r*(.3*1.5)),!i||i<Math.abs(n)?(i=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/i),e<1?-.5*(i*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o))+t:i*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-s_.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?s_.BounceEaseIn(e*2,0,n,r)*.5+t:s_.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},u7e=ot._assign(on,{Util:ot,Transform:lf,Node:an,Container:fu,Stage:w5,stages:i_,Layer:Lb,FastLayer:SZ,Group:tx,DD:Ri,Shape:Yt,shapes:o_,Animation:nx,Tween:S5,Easings:s_,Context:f5,Canvas:dZ});var Yp=class extends Yt{_sceneFunc(e){const t=on.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=on.getAngle(n?360-this.angle():this.angle()),i=Math.cos(Math.min(r,Math.PI)),o=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=i*(i>0?e:t),c=o*(o>0?t:e),u=s*(s>0?e:t),d=a*(a>0?t:e);return{x:l,y:n?-1*d:u,width:c-l,height:d-u}}};Yp.prototype._centroid=!0,Yp.prototype.className="Arc",Yp.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],ss(Yp),We.addGetterSetter(Yp,"innerRadius",0,Jt()),We.addGetterSetter(Yp,"outerRadius",0,Jt()),We.addGetterSetter(Yp,"angle",0,Jt()),We.addGetterSetter(Yp,"clockwise",!1,cf());function TZ(e,t,n,r,i,o,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2)),c=s*a/(a+l),u=s*l/(a+l);return[n-c*(i-e),r-c*(o-t),n+u*(i-e),r+u*(o-t)]}function d7e(e,t){const n=e.length,r=[];for(let i=2;i<n-2;i+=2){const o=TZ(e[i-2],e[i-1],e[i],e[i+1],e[i+2],e[i+3],t);isNaN(o[0])||(r.push(o[0]),r.push(o[1]),r.push(e[i]),r.push(e[i+1]),r.push(o[2]),r.push(o[3]))}return r}function l8n(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const i=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(i!==0){const o=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=o*o-4*i*s;if(a>=0){const l=Math.sqrt(a);n.push((-o+l)/(2*i)),n.push((-o-l)/(2*i))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(i=>{const o=1-r;return o*o*o*i[0]+3*o*o*r*i[1]+3*o*r*r*i[2]+r*r*r*i[3]}))}var Kp=class extends Yt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),i=this.closed(),o=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=i?0:4,i||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);i||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(o)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);i?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():d7e(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=TZ(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=TZ(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=d7e(e,n);return[r[2],r[3]].concat(o).concat([i[0],i[1],e[t-2],e[t-1],i[2],i[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...l8n(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],i=e[1],o,s;for(let a=0;a<e.length/2;a++)o=e[a*2],s=e[a*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);return{x:t,y:r,width:n-t,height:i-r}}};Kp.prototype.className="Line",Kp.prototype._attrsAffectingSize=["points","bezier","tension"],ss(Kp),We.addGetterSetter(Kp,"closed",!1),We.addGetterSetter(Kp,"bezier",!1),We.addGetterSetter(Kp,"tension",0,Jt()),We.addGetterSetter(Kp,"points",[],TBn());const c8n=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],u8n=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],d8n=[[1],[1,1],[1,2,1],[1,3,3,1]],f7e=(e,t,n)=>{let r,i;const s=n/2;r=0;for(let a=0;a<20;a++)i=s*c8n[20][a]+s,r+=u8n[20][a]*f8n(e,t,i);return s*r},h7e=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],i=t[0]-2*t[1]+t[2],o=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+i*i),l=4*(r*o+i*s),c=o*o+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const u=l/(2*a),d=c/a,f=n+u,h=d-u*u,p=f*f+h>0?Math.sqrt(f*f+h):0,m=u*u+h>0?Math.sqrt(u*u+h):0,g=u+Math.sqrt(u*u+h)!==0?h*Math.log(Math.abs((f+p)/(u+m))):0;return Math.sqrt(a)/2*(f*p-u*m+g)};function f8n(e,t,n){const r=IZ(1,n,e),i=IZ(1,n,t),o=r*r+i*i;return Math.sqrt(o)}var IZ=(e,t,n)=>{const r=n.length-1;let i,o;if(r===0)return 0;if(e===0){o=0;for(let s=0;s<=r;s++)o+=d8n[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return o}else{i=new Array(r);for(let s=0;s<r;s++)i[s]=r*(n[s+1]-n[s]);return IZ(e-1,t,i)}};const p7e=(e,t,n)=>{let r=1,i=e/t,o=(e-n(i))/t,s=0;for(;r>.001;){const a=n(i+o),l=Math.abs(e-a)/t;if(l<r)r=l,i+=o;else{const c=n(i-o),u=Math.abs(e-c)/t;u<r?(r=u,i-=o):o/=2}if(s++,s>500)break}return i};var od=class zc extends Yt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=zc.parsePathData(this.data()),this.pathLength=zc.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let i=0;i<n.length;i++){const o=n[i].command,s=n[i].points;switch(o){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],c=s[2],u=s[3],d=s[4],f=s[5],h=s[6],p=s[7],m=c>u?c:u,g=c>u?1:c/u,y=c>u?u/c:1;t.translate(a,l),t.rotate(h),t.scale(g,y),t.arc(0,0,m,d,d+f,1-p),t.scale(1/g,1/y),t.rotate(-h),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const c=l.points[4],u=l.points[5],d=l.points[4]+u;let f=Math.PI/180;if(Math.abs(c-d)<f&&(f=Math.abs(c-d)),u<0)for(let h=c-f;h>d;h-=f){const p=zc.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],h,0);t.push(p.x,p.y)}else for(let h=c+f;h<d;h+=f){const p=zc.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],h,0);t.push(p.x,p.y)}}else if(l.command==="C")for(let c=0;c<=1;c+=.01){const u=zc.getPointOnCubicBezier(c,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(u.x,u.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],i=t[1],o=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(i=Math.min(i,a),o=Math.max(o,a));return{x:n,y:i,width:r-n,height:o-i}}getLength(){return this.pathLength}getPointAtLength(t){return zc.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,i){return Math.sqrt((r-t)*(r-t)+(i-n)*(i-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,i=0,o=n.length;if(!o)return null;for(;i<o&&t>n[i].pathLength;)t-=n[i].pathLength,++i;if(i===o)return r=n[i-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[i].command==="M"?(r=n[i].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[i].start.x,y:n[i].start.y};const s=n[i],a=s.points;switch(s.command){case"L":return zc.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return zc.getPointOnCubicBezier(p7e(t,zc.getPathLength(n),m=>f7e([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],m)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return zc.getPointOnQuadraticBezier(p7e(t,zc.getPathLength(n),m=>h7e([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],m)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],c=a[1],u=a[2],d=a[3],f=a[5],h=a[6];let p=a[4];return p+=f*t/s.pathLength,zc.getPointOnEllipticalArc(l,c,u,d,p,h)}return null}static getPointOnLine(t,n,r,i,o,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,i,o);if(l<1e-10)return{x:n,y:r};if(i===n)return{x:s,y:a+(o>r?t:-t)};const c=(o-r)/(i-n),u=Math.sqrt(t*t/(1+c*c))*(i<n?-1:1),d=c*u;if(Math.abs(a-r-c*(s-n))<1e-10)return{x:s+u,y:a+d};const f=((s-n)*(i-n)+(a-r)*(o-r))/(l*l),h=n+f*(i-n),p=r+f*(o-r),m=this.getLineLength(s,a,h,p),g=Math.sqrt(t*t-m*m),y=Math.sqrt(g*g/(1+c*c))*(i<n?-1:1),v=c*y;return{x:h+y,y:p+v}}static getPointOnCubicBezier(t,n,r,i,o,s,a,l,c){function u(p){return p*p*p}function d(p){return 3*p*p*(1-p)}function f(p){return 3*p*(1-p)*(1-p)}function h(p){return(1-p)*(1-p)*(1-p)}return{x:l*u(t)+s*d(t)+i*f(t)+n*h(t),y:c*u(t)+a*d(t)+o*f(t)+r*h(t)}}static getPointOnQuadraticBezier(t,n,r,i,o,s,a){function l(d){return d*d}function c(d){return 2*d*(1-d)}function u(d){return(1-d)*(1-d)}return{x:s*l(t)+i*c(t)+n*u(t),y:a*l(t)+o*c(t)+r*u(t)}}static getPointOnEllipticalArc(t,n,r,i,o,s){const a=Math.cos(s),l=Math.sin(s),c={x:r*Math.cos(o),y:i*Math.sin(o)};return{x:t+(c.x*a-c.y*l),y:n+(c.x*l+c.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let d=0;d<r.length;d++)n=n.replace(new RegExp(r[d],"g"),"|"+r[d]);const i=n.split("|"),o=[],s=[];let a=0,l=0;const c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let u;for(let d=1;d<i.length;d++){let f=i[d],h=f.charAt(0);for(f=f.slice(1),s.length=0;u=c.exec(f);)s.push(u[0]);let p=[],m=h==="A"||h==="a"?0:-1;for(let g=0,y=s.length;g<y;g++){const v=s[g];if(v==="00"){p.push(0,0),m>=0&&(m+=2,m>=7&&(m-=7));continue}if(m>=0){if(m===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),p.push(parseFloat(v.slice(2))),m+=3,m>=7&&(m-=7);continue}if(v==="11"||v==="10"||v==="01"){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}else if(m===4){if(/^[01]\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseFloat(v.slice(1))),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b),m+=1,m>=7&&(m-=7)}else{const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b)}}for(;p.length>0&&!isNaN(p[0]);){let g="",y=[];const v=a,b=l;let w,x,S,T,k,C,_,P,E,L;switch(h){case"l":a+=p.shift(),l+=p.shift(),g="L",y.push(a,l);break;case"L":a=p.shift(),l=p.shift(),y.push(a,l);break;case"m":const R=p.shift(),O=p.shift();if(a+=R,l+=O,g="M",o.length>2&&o[o.length-1].command==="z"){for(let F=o.length-2;F>=0;F--)if(o[F].command==="M"){a=o[F].points[0]+R,l=o[F].points[1]+O;break}}y.push(a,l),h="l";break;case"M":a=p.shift(),l=p.shift(),g="M",y.push(a,l),h="L";break;case"h":a+=p.shift(),g="L",y.push(a,l);break;case"H":a=p.shift(),g="L",y.push(a,l);break;case"v":l+=p.shift(),g="L",y.push(a,l);break;case"V":l=p.shift(),g="L",y.push(a,l);break;case"C":y.push(p.shift(),p.shift(),p.shift(),p.shift()),a=p.shift(),l=p.shift(),y.push(a,l);break;case"c":y.push(a+p.shift(),l+p.shift(),a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="C",y.push(a,l);break;case"S":x=a,S=l,w=o[o.length-1],w.command==="C"&&(x=a+(a-w.points[2]),S=l+(l-w.points[3])),y.push(x,S,p.shift(),p.shift()),a=p.shift(),l=p.shift(),g="C",y.push(a,l);break;case"s":x=a,S=l,w=o[o.length-1],w.command==="C"&&(x=a+(a-w.points[2]),S=l+(l-w.points[3])),y.push(x,S,a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="C",y.push(a,l);break;case"Q":y.push(p.shift(),p.shift()),a=p.shift(),l=p.shift(),y.push(a,l);break;case"q":y.push(a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="Q",y.push(a,l);break;case"T":x=a,S=l,w=o[o.length-1],w.command==="Q"&&(x=a+(a-w.points[0]),S=l+(l-w.points[1])),a=p.shift(),l=p.shift(),g="Q",y.push(x,S,a,l);break;case"t":x=a,S=l,w=o[o.length-1],w.command==="Q"&&(x=a+(a-w.points[0]),S=l+(l-w.points[1])),a+=p.shift(),l+=p.shift(),g="Q",y.push(x,S,a,l);break;case"A":T=p.shift(),k=p.shift(),C=p.shift(),_=p.shift(),P=p.shift(),E=a,L=l,a=p.shift(),l=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(E,L,a,l,_,P,T,k,C);break;case"a":T=p.shift(),k=p.shift(),C=p.shift(),_=p.shift(),P=p.shift(),E=a,L=l,a+=p.shift(),l+=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(E,L,a,l,_,P,T,k,C);break}o.push({command:g||h,points:y,start:{x:v,y:b},pathLength:this.calcLength(v,b,g||h,y)})}(h==="z"||h==="Z")&&o.push({command:"z",points:[],start:void 0,pathLength:0})}return o}static calcLength(t,n,r,i){let o,s,a,l;const c=zc;switch(r){case"L":return c.getLineLength(t,n,i[0],i[1]);case"C":return f7e([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case"Q":return h7e([t,i[0],i[2]],[n,i[1],i[3]],1);case"A":o=0;const u=i[4],d=i[5],f=i[4]+d;let h=Math.PI/180;if(Math.abs(u-f)<h&&(h=Math.abs(u-f)),s=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],u,0),d<0)for(l=u-h;l>f;l-=h)a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],l,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=u+h;l<f;l+=h)a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],l,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=c.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],f,0),o+=c.getLineLength(s.x,s.y,a.x,a.y),o}return 0}static convertEndpointToCenterParameterization(t,n,r,i,o,s,a,l,c){const u=c*(Math.PI/180),d=Math.cos(u)*(t-r)/2+Math.sin(u)*(n-i)/2,f=-1*Math.sin(u)*(t-r)/2+Math.cos(u)*(n-i)/2,h=d*d/(a*a)+f*f/(l*l);h>1&&(a*=Math.sqrt(h),l*=Math.sqrt(h));let p=Math.sqrt((a*a*(l*l)-a*a*(f*f)-l*l*(d*d))/(a*a*(f*f)+l*l*(d*d)));o===s&&(p*=-1),isNaN(p)&&(p=0);const m=p*a*f/l,g=p*-l*d/a,y=(t+r)/2+Math.cos(u)*m-Math.sin(u)*g,v=(n+i)/2+Math.sin(u)*m+Math.cos(u)*g,b=function(_){return Math.sqrt(_[0]*_[0]+_[1]*_[1])},w=function(_,P){return(_[0]*P[0]+_[1]*P[1])/(b(_)*b(P))},x=function(_,P){return(_[0]*P[1]<_[1]*P[0]?-1:1)*Math.acos(w(_,P))},S=x([1,0],[(d-m)/a,(f-g)/l]),T=[(d-m)/a,(f-g)/l],k=[(-1*d-m)/a,(-1*f-g)/l];let C=x(T,k);return w(T,k)<=-1&&(C=Math.PI),w(T,k)>=1&&(C=0),s===0&&C>0&&(C=C-2*Math.PI),s===1&&C<0&&(C=C+2*Math.PI),[y,v,a,l,S,C,u,s]}};od.prototype.className="Path",od.prototype._attrsAffectingSize=["data"],ss(od),We.addGetterSetter(od,"data");var Nb=class extends Kp{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const i=this.tension()!==0&&n.length>4;i&&(r=this.getTensionPoints());const o=this.pointerLength(),s=n.length;let a,l;if(i){const d=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],f=od.calcLength(r[r.length-4],r[r.length-3],"C",d),h=od.getPointOnQuadraticBezier(Math.min(1,1-o/f),d[0],d[1],d[2],d[3],d[4],d[5]);a=n[s-2]-h.x,l=n[s-1]-h.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const c=(Math.atan2(l,a)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(c),e.moveTo(0,0),e.lineTo(-o,u/2),e.lineTo(-o,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),i?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-o,u/2),e.lineTo(-o,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};Nb.prototype.className="Arrow",ss(Nb),We.addGetterSetter(Nb,"pointerLength",10,Jt()),We.addGetterSetter(Nb,"pointerWidth",10,Jt()),We.addGetterSetter(Nb,"pointerAtBeginning",!1),We.addGetterSetter(Nb,"pointerAtEnding",!0);var rx=class extends Yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};rx.prototype._centroid=!0,rx.prototype.className="Circle",rx.prototype._attrsAffectingSize=["radius"],ss(rx),We.addGetterSetter(rx,"radius",0,Jt());var i0=class extends Yt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};i0.prototype.className="Ellipse",i0.prototype._centroid=!0,i0.prototype._attrsAffectingSize=["radiusX","radiusY"],ss(i0),We.addComponentsGetterSetter(i0,"radius",["x","y"]),We.addGetterSetter(i0,"radiusX",0,Jt()),We.addGetterSetter(i0,"radiusY",0,Jt());var uf=class jze extends Yt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),i=this.cornerRadius(),o=this.attrs.image;let s;if(o){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[o,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[o,0,0,n,r]}(this.hasFill()||this.hasStroke()||i)&&(t.beginPath(),i?ot.drawRoundedRectPath(t,n,r,i):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),o&&(i&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),i=this.cornerRadius();t.beginPath(),i?ot.drawRoundedRectPath(t,n,r,i):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const i=ot.createImageElement();i.onload=function(){n(new jze({image:i}))},i.onerror=r,i.crossOrigin="Anonymous",i.src=t}};uf.prototype.className="Image",uf.prototype._attrsAffectingSize=["image"],ss(uf),We.addGetterSetter(uf,"cornerRadius",0,p5(4)),We.addGetterSetter(uf,"image"),We.addComponentsGetterSetter(uf,"crop",["x","y","width","height"]),We.addGetterSetter(uf,"cropX",0,Jt()),We.addGetterSetter(uf,"cropY",0,Jt()),We.addGetterSetter(uf,"cropWidth",0,Jt()),We.addGetterSetter(uf,"cropHeight",0,Jt());var m7e=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],h8n="Change.konva",p8n="none",kZ="up",EZ="right",CZ="down",_Z="left",m8n=m7e.length,RZ=class extends tx{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<m8n;n++)e.on(m7e[n]+h8n,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,o,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),o=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,i){case kZ:s=n/2,a=-1*l;break;case EZ:s=n+o,a=r/2;break;case CZ:s=n/2,a=r+l;break;case _Z:s=-1*o,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};RZ.prototype.className="Label",ss(RZ);var Mb=class extends Yt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),o=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,c=0,u=0;typeof s=="number"?a=l=c=u=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),u=Math.min(s[2]||0,t/2,n/2),c=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===kZ&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+i)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===EZ&&(e.lineTo(t,(n-o)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===CZ&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-i)/2,n)),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),r===_Z&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),o=this.width(),s=this.height();return i===kZ?(t-=r,s+=r):i===CZ?s+=r:i===_Z?(e-=n*1.5,o+=n):i===EZ&&(o+=n*1.5),{x:e,y:t,width:o,height:s}}};Mb.prototype.className="Tag",ss(Mb),We.addGetterSetter(Mb,"pointerDirection",p8n),We.addGetterSetter(Mb,"pointerWidth",0,Jt()),We.addGetterSetter(Mb,"pointerHeight",0,Jt()),We.addGetterSetter(Mb,"cornerRadius",0,p5(4));var a_=class extends Yt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?ot.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};a_.prototype.className="Rect",ss(a_),We.addGetterSetter(a_,"cornerRadius",0,p5(4));var o0=class extends Yt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(e.beginPath(),i)ot.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let o=1;o<t.length;o++)e.lineTo(t[o].x,t[o].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(o=>{t=Math.min(t,o.x),n=Math.max(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};o0.prototype.className="RegularPolygon",o0.prototype._centroid=!0,o0.prototype._attrsAffectingSize=["radius"],ss(o0),We.addGetterSetter(o0,"radius",0,Jt()),We.addGetterSetter(o0,"sides",0,Jt()),We.addGetterSetter(o0,"cornerRadius",0,p5(4));var g7e=Math.PI*2,Db=class extends Yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,g7e,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),g7e,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Db.prototype.className="Ring",Db.prototype._centroid=!0,Db.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ss(Db),We.addGetterSetter(Db,"innerRadius",0,Jt()),We.addGetterSetter(Db,"outerRadius",0,Jt());var vh=class extends Yt{constructor(e){super(e),this._updated=!0,this.anim=new nx(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],o=this.frameOffsets(),s=i[r+0],a=i[r+1],l=i[r+2],c=i[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,c),e.closePath(),e.fillStrokeShape(this)),u)if(o){const d=o[t],f=n*2;e.drawImage(u,s,a,l,c,d[f+0],d[f+1],l,c)}else e.drawImage(u,s,a,l,c,0,0,l,c)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],o=this.frameOffsets(),s=i[r+2],a=i[r+3];if(e.beginPath(),o){const l=o[t],c=n*2;e.rect(l[c+0],l[c+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};vh.prototype.className="Sprite",ss(vh),We.addGetterSetter(vh,"animation"),We.addGetterSetter(vh,"animations"),We.addGetterSetter(vh,"frameOffsets"),We.addGetterSetter(vh,"image"),We.addGetterSetter(vh,"frameIndex",0,Jt()),We.addGetterSetter(vh,"frameRate",17,Jt()),We.backCompat(vh,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var s0=class extends Yt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){const o=i%2===0?n:t,s=o*Math.sin(i*Math.PI/r),a=-1*o*Math.cos(i*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};s0.prototype.className="Star",s0.prototype._centroid=!0,s0.prototype._attrsAffectingSize=["innerRadius","outerRadius"],ss(s0),We.addGetterSetter(s0,"numPoints",5,Jt()),We.addGetterSetter(s0,"innerRadius",0,Jt()),We.addGetterSetter(s0,"outerRadius",0,Jt());function a0(e){return[...e].reduce((t,n,r,i)=>{if(/\p{Emoji}/u.test(n)){const o=i[r+1];o&&/\p{Emoji_Modifier}|\u200D/u.test(o)?(t.push(n+o),i[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(i[r+1]||""))?t.push(n+i[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var ix="auto",g8n="center",y7e="inherit",l_="justify",y8n="Change.konva",b7e="2d",v7e="-",w7e="left",b8n="text",v8n="Text",w8n="top",A8n="bottom",A7e="middle",S7e="normal",S8n="px ",x5=" ",x8n="right",x7e="rtl",T8n="word",I8n="char",T7e="none",PZ="…",I7e=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],k8n=I7e.length,c_=null;function E8n(){if(c_!==null)return c_;c_=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(b7e);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){c_=!0;break}}}catch{}return c_}function C8n(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var T5;function LZ(){return T5||(T5=ot.createCanvasElement().getContext(b7e),T5)}function _8n(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function R8n(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function P8n(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Ro=class extends Yt{constructor(e){super(P8n(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<k8n;t++)this.on(I7e[t]+y8n,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,i=r.length;if(!this.text())return;let o=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),c=this.direction(),u=0,d=this.align(),f=this.getWidth(),h=this.letterSpacing(),p=this.charRenderFunc(),m=this.fill(),g=this.textDecoration(),y=this.underlineOffset(),v=g.indexOf("underline")!==-1,b=g.indexOf("line-through")!==-1,w;c=c===y7e?e.direction:c;let x=a/2,S=A7e;if(!on.legacyTextRendering){const T=this.measureSize("M");S="alphabetic",x=(((t=T.fontBoundingBoxAscent)!==null&&t!==void 0?t:T.actualBoundingBoxAscent)-((n=T.fontBoundingBoxDescent)!==null&&n!==void 0?n:T.actualBoundingBoxDescent))/2+a/2}for(c===x7e&&e.setAttr("direction",c),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",S),e.setAttr("textAlign",w7e),l===A7e?u=(this.getHeight()-i*a-o*2)/2:l===A8n&&(u=this.getHeight()-i*a-o*2),e.translate(o,u+o),w=0;w<i;w++){let T=0,k=0;const C=r[w],_=C.text,P=C.width,E=C.lastInParagraph;if(e.save(),d===x8n?T+=f-P-o*2:d===g8n&&(T+=(f-P-o*2)/2),v){e.save(),e.beginPath();const R=y??(on.legacyTextRendering?Math.round(s/2):Math.round(s/4)),O=T,F=x+k+R;e.moveTo(O,F);const B=d===l_&&!E?f-o*2:P;e.lineTo(O+Math.round(B),F),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}const L=T;if(c!==x7e&&(h!==0||d===l_||p)){const R=_.split(" ").length-1,O=a0(_);for(let F=0;F<O.length;F++){const B=O[F];if(B===" "&&!E&&d===l_&&(T+=(f-o*2-P)/R),this._partialTextX=T,this._partialTextY=x+k,this._partialText=B,p){e.save();const j=r.slice(0,w).reduce((M,z)=>M+a0(z.text).length,0);p({char:B,index:F+j,x:T,y:x+k,lineIndex:w,column:F,isLastInLine:E,width:this.measureSize(B).width,context:e})}e.fillStrokeShape(this),p&&e.restore(),T+=this.measureSize(B).width+h}}else h!==0&&e.setAttr("letterSpacing",`${h}px`),this._partialTextX=T,this._partialTextY=x+k,this._partialText=_,e.fillStrokeShape(this);if(b){e.save(),e.beginPath();const R=on.legacyTextRendering?0:-Math.round(s/4),O=L;e.moveTo(O,x+k+R);const F=d===l_&&!E?f-o*2:P;e.lineTo(O+Math.round(F),x+k+R),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}e.restore(),i>1&&(x+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=ot._isString(e)?e:e==null?"":e+"";return this._setAttr(b8n,t),this}getWidth(){return this.attrs.width===ix||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===ix||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return ot.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,i,o,s,a,l,c,u,d;let f=LZ(),h=this.fontSize(),p;f.save(),f.font=this._getContextFont(),p=f.measureText(e),f.restore();const m=h/100;return{actualBoundingBoxAscent:(t=p.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*m,actualBoundingBoxDescent:(n=p.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=p.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*m,actualBoundingBoxRight:(i=p.actualBoundingBoxRight)!==null&&i!==void 0?i:75.732421875*m,alphabeticBaseline:(o=p.alphabeticBaseline)!==null&&o!==void 0?o:0,emHeightAscent:(s=p.emHeightAscent)!==null&&s!==void 0?s:100*m,emHeightDescent:(a=p.emHeightDescent)!==null&&a!==void 0?a:-20*m,fontBoundingBoxAscent:(l=p.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*m,fontBoundingBoxDescent:(c=p.fontBoundingBoxDescent)!==null&&c!==void 0?c:21*m,hangingBaseline:(u=p.hangingBaseline)!==null&&u!==void 0?u:72.80000305175781*m,ideographicBaseline:(d=p.ideographicBaseline)!==null&&d!==void 0?d:-21*m,width:p.width,height:h}}_getContextFont(){return this.fontStyle()+x5+this.fontVariant()+x5+(this.fontSize()+S8n)+C8n(this.fontFamily())}_addTextLine(e){this.align()===l_&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return LZ().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
1110
- `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,o=this.attrs.height,s=i!==ix&&i!==void 0,a=o!==ix&&o!==void 0,l=this.padding(),c=i-l*2,u=o-l*2,d=0,f=this.wrap(),h=f!==I8n&&f!==T7e,p=this.ellipsis();this.textArr=[],LZ().font=this._getContextFont();const m=p?this._getTextWidth(PZ):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let w=0,x=a0(v).length,S="",T=0;for(;w<x;){const k=w+x>>>1,C=a0(v).slice(0,k+1).join(""),_=this._getTextWidth(C);(p&&a&&d+r>u?_+m:_)<=c?(w=k+1,S=C,T=_):x=k}if(S){if(h){const k=a0(v),C=a0(S),_=k[C.length],P=_===x5||_===v7e;let E;if(P&&T<=c)E=C.length;else{const L=C.lastIndexOf(x5),R=C.lastIndexOf(v7e);E=Math.max(L,R)+1}E>0&&(w=E,S=k.slice(0,w).join(""),T=this._getTextWidth(S))}if(S=S.trimRight(),this._addTextLine(S),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=a0(v).slice(w).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==ix&&r!==void 0,o=r-this.padding()*2;return this.wrap()===T7e||i&&e+n>o}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==ix&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+PZ)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+PZ))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&E8n()?!0:super._useBufferCanvas()}};Ro.prototype._fillFunc=_8n,Ro.prototype._strokeFunc=R8n,Ro.prototype.className=v8n,Ro.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],ss(Ro),We.overWriteSetter(Ro,"width",hZ()),We.overWriteSetter(Ro,"height",hZ()),We.addGetterSetter(Ro,"direction",y7e),We.addGetterSetter(Ro,"fontFamily","Arial"),We.addGetterSetter(Ro,"fontSize",12,Jt()),We.addGetterSetter(Ro,"fontStyle",S7e),We.addGetterSetter(Ro,"fontVariant",S7e),We.addGetterSetter(Ro,"padding",0,Jt()),We.addGetterSetter(Ro,"align",w7e),We.addGetterSetter(Ro,"verticalAlign",w8n),We.addGetterSetter(Ro,"lineHeight",1,Jt()),We.addGetterSetter(Ro,"wrap",T8n),We.addGetterSetter(Ro,"ellipsis",!1,cf()),We.addGetterSetter(Ro,"letterSpacing",0,Jt()),We.addGetterSetter(Ro,"text","",Rb()),We.addGetterSetter(Ro,"textDecoration",""),We.addGetterSetter(Ro,"underlineOffset",void 0,Jt()),We.addGetterSetter(Ro,"charRenderFunc",void 0);var L8n="",k7e="normal";function E7e(e){e.fillText(this.partialText,0,0)}function C7e(e){e.strokeText(this.partialText,0,0)}var oa=class extends Yt{constructor(e){super(e),this.dummyCanvas=ot.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return od.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:od.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=od.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,o=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;o&&e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),this.partialText=i[a].text,e.fillStrokeShape(this),o&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(i[a].width,r/2+1)),e.restore()}if(o&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(i[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return ot.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Ro.prototype.setText.call(this,e)}_getContextFont(){return Ro.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=a0(this.text()),t=[];let n=0;for(let f=0;f<e.length;f++)t.push({char:e[f],width:this._getTextSize(e[f]).width}),n+=t[f].width;const{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;const o=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*o,0);let u=0;s==="center"&&(u=Math.max(0,this.pathLength/2-c/2)),s==="right"&&(u=Math.max(0,this.pathLength-c));let d=u;for(let f=0;f<t.length;f++){const h=this._getPointAtLength(d);if(!h)return;const p=t[f].char;let m=t[f].width+o;if(p===" "&&s==="justify"){const S=this.text().split(" ").length-1;m+=(this.pathLength-c)/S}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=od.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const w=od.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),x=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:w.x,transposeY:w.y,text:e[f],rotation:x,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,o,s;for(let l=0;l<e.length/2;l++)o=e[l*2],s=e[l*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:i-r+a}}destroy(){return ot.releaseCanvas(this.dummyCanvas),super.destroy()}};oa.prototype._fillFunc=E7e,oa.prototype._strokeFunc=C7e,oa.prototype._fillFuncHit=E7e,oa.prototype._strokeFuncHit=C7e,oa.prototype.className="TextPath",oa.prototype._attrsAffectingSize=["text","fontSize","data"],ss(oa),We.addGetterSetter(oa,"data"),We.addGetterSetter(oa,"fontFamily","Arial"),We.addGetterSetter(oa,"fontSize",12,Jt()),We.addGetterSetter(oa,"fontStyle",k7e),We.addGetterSetter(oa,"align","left"),We.addGetterSetter(oa,"letterSpacing",0,Jt()),We.addGetterSetter(oa,"textBaseline","middle"),We.addGetterSetter(oa,"fontVariant",k7e),We.addGetterSetter(oa,"text",L8n),We.addGetterSetter(oa,"textDecoration",""),We.addGetterSetter(oa,"kerningFunc",void 0);var _7e="tr-konva",N8n=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${_7e}`).join(" "),R7e="nodesRect",M8n=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],D8n={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},O8n="ontouchstart"in on._global;function F8n(e,t,n){if(e==="rotater")return n;t+=ot.degToRad(D8n[e]||0);const r=(ot.radToDeg(t)%360+360)%360;return ot._inRange(r,337.5,360)||ot._inRange(r,0,22.5)?"ns-resize":ot._inRange(r,22.5,67.5)?"nesw-resize":ot._inRange(r,67.5,112.5)?"ew-resize":ot._inRange(r,112.5,157.5)?"nwse-resize":ot._inRange(r,157.5,202.5)?"ns-resize":ot._inRange(r,202.5,247.5)?"nesw-resize":ot._inRange(r,247.5,292.5)?"ew-resize":ot._inRange(r,292.5,337.5)?"nwse-resize":(ot.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var I5=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],P7e=1e8;function B8n(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function L7e(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function H8n(e,t){return L7e(e,t,B8n(e))}function z8n(e,t,n){let r=t;for(let i=0;i<e.length;i++){const o=on.getAngle(e[i]),s=Math.abs(o-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=o)}return r}var NZ=0,hi=class extends tx{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(N8n,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return ot.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return _7e+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(ot.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(M8n.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),i=r.x-t.x,o=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+i,y:a.y+o}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(R7e),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(R7e,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),s=r.x*i.x-e.offsetX()*i.x,a=r.y*i.y-e.offsetY()*i.y,l=(on.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return L7e({x:o.x+s*Math.cos(l)+a*Math.sin(-l),y:o.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-on.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-P7e,y:-P7e,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),c=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],u=a.getAbsoluteTransform();c.forEach(function(d){const f=u.point(d);e.push(f)})});const t=new lf;t.rotate(-on.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,o=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=i=l.x,r=o=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.x),o=Math.max(o,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:i-n,height:o-r,rotation:on.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),I5.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new a_({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:O8n?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=F8n(e,on.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new Yt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),i=r.padding(),o=n.width(),s=n.height();if(t.beginPath(),t.rect(-i,-i,o+i*2,s+i*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=ot.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=o/2,h=s/2;let p=1/0;d<0?p=Math.min(p,-h/d):d>0&&(p=Math.min(p,(s-h)/d)),u<0?p=Math.min(p,-f/u):u>0&&(p=Math.min(p,(o-f)/u));const m=f+u*p,g=h+d*p,y=ot._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},NZ++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(e);const s=o.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),i.setAbsolutePosition(a);const c=i.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=i.x()-y.width/2,n=-i.y()+y.height/2;const v=on.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const w=on.getAngle(this.rotation())+b,x=on.getAngle(this.rotationSnapTolerance()),S=H8n(y,z8n(this.rotationSnaps(),w,x)-y.rotation);this._fitNodesInto(S,e);return}const u=this.shiftBehavior();let d;u==="inverted"?d=this.keepRatio()&&!e.shiftKey:u==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(i.y());else if(this._movingAnchorName==="top-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=i.position();this.findOne(".top-left").y(h.y),this.findOne(".bottom-right").x(h.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(i.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(i.x());else if(this._movingAnchorName==="bottom-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(i.y()-y.y,2));const v=y.x<i.x()?-1:1,b=i.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,i.x(y.x-t),i.y(y.y+n)}h=i.position(),this.findOne(".top-left").x(h.x),this.findOne(".bottom-right").y(h.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(i.y());else if(this._movingAnchorName==="bottom-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(i.y()-y.y,2));const v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),w=y.y(),x=this.getWidth()-v.x(),S=this.getHeight()-v.y();v.move({x:-b,y:-w}),y.move({x,y:S})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:m,height:g,rotation:on.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();NZ--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var i;r._fire("transformend",{evt:e,target:r}),(i=r.getLayer())===null||i===void 0||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(ot._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(ot._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const i=new lf;if(i.rotate(on.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=i.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=i.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=i.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=i.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:ot.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,s=new lf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/o,n.height/o);const a=new lf,l=e.width/o,c=e.height/o;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(c))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,c));const u=a.multiply(s.invert());this._nodes.forEach(d=>{var f;if(!d.getStage())return;const h=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const m=new lf;m.multiply(h.copy().invert()).multiply(u).multiply(h).multiply(p);const g=m.decompose();d.setAttrs(g),(f=d.getLayer())===null||f===void 0||f.batchDraw()}),this.rotation(ot._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(ot._getRotation(t.rotation));const n=t.width,r=t.height,i=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:o&&i.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:o&&i.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:o&&i.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:o&&i.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:o&&i.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:o&&i.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=ot.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=ot._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const w=this.anchorStyleFunc();w&&l.forEach(x=>{w(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),tx.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(ot.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return an.prototype.toObject.call(this)}clone(e){return an.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};hi.isTransforming=()=>NZ>0;function U8n(e){return e instanceof Array||ot.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){I5.indexOf(t)===-1&&ot.warn("Unknown anchor name: "+t+". Available names are: "+I5.join(", "))}),e||[]}hi.prototype.className="Transformer",ss(hi),We.addGetterSetter(hi,"enabledAnchors",I5,U8n),We.addGetterSetter(hi,"flipEnabled",!0,cf()),We.addGetterSetter(hi,"resizeEnabled",!0),We.addGetterSetter(hi,"anchorSize",10,Jt()),We.addGetterSetter(hi,"rotateEnabled",!0),We.addGetterSetter(hi,"rotateLineVisible",!0),We.addGetterSetter(hi,"rotationSnaps",[]),We.addGetterSetter(hi,"rotateAnchorOffset",50,Jt()),We.addGetterSetter(hi,"rotateAnchorAngle",0,Jt()),We.addGetterSetter(hi,"rotateAnchorCursor","crosshair"),We.addGetterSetter(hi,"rotationSnapTolerance",5,Jt()),We.addGetterSetter(hi,"borderEnabled",!0),We.addGetterSetter(hi,"anchorStroke","rgb(0, 161, 255)"),We.addGetterSetter(hi,"anchorStrokeWidth",1,Jt()),We.addGetterSetter(hi,"anchorFill","white"),We.addGetterSetter(hi,"anchorCornerRadius",0,Jt()),We.addGetterSetter(hi,"borderStroke","rgb(0, 161, 255)"),We.addGetterSetter(hi,"borderStrokeWidth",1,Jt()),We.addGetterSetter(hi,"borderDash"),We.addGetterSetter(hi,"keepRatio",!0),We.addGetterSetter(hi,"shiftBehavior","default"),We.addGetterSetter(hi,"centeredScaling",!1),We.addGetterSetter(hi,"ignoreStroke",!1),We.addGetterSetter(hi,"padding",0,Jt()),We.addGetterSetter(hi,"nodes"),We.addGetterSetter(hi,"node"),We.addGetterSetter(hi,"boundBoxFunc"),We.addGetterSetter(hi,"anchorDragBoundFunc"),We.addGetterSetter(hi,"anchorStyleFunc"),We.addGetterSetter(hi,"shouldOverdrawWholeArea",!1),We.addGetterSetter(hi,"useSingleNodeRotation",!0),We.backCompat(hi,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Xp=class extends Yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,on.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Xp.prototype.className="Wedge",Xp.prototype._centroid=!0,Xp.prototype._attrsAffectingSize=["radius"],ss(Xp),We.addGetterSetter(Xp,"radius",0,Jt()),We.addGetterSetter(Xp,"angle",0,Jt()),We.addGetterSetter(Xp,"clockwise",!1),We.backCompat(Xp,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function N7e(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var V8n=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],W8n=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function G8n(e,t){const n=e.data,r=e.width,i=e.height;let o,s,a,l,c,u,d,f,h,p,m,g,y,v,b,w,x,S,T,k;const C=t+t+1,_=r-1,P=i-1,E=t+1,L=E*(E+1)/2,R=new N7e,O=V8n[t],F=W8n[t];let B=null,j=R,M=null,z=null;for(let $=1;$<C;$++)j=j.next=new N7e,$===E&&(B=j);j.next=R,a=s=0;for(let $=0;$<i;$++){g=y=v=b=l=c=u=d=0,f=E*(w=n[s]),h=E*(x=n[s+1]),p=E*(S=n[s+2]),m=E*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*S,d+=L*T,j=R;for(let K=0;K<E;K++)j.r=w,j.g=x,j.b=S,j.a=T,j=j.next;for(let K=1;K<E;K++)o=s+((_<K?_:K)<<2),l+=(j.r=w=n[o])*(k=E-K),c+=(j.g=x=n[o+1])*k,u+=(j.b=S=n[o+2])*k,d+=(j.a=T=n[o+3])*k,g+=w,y+=x,v+=S,b+=T,j=j.next;M=R,z=B;for(let K=0;K<r;K++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=a+((o=K+t+1)<_?o:_)<<2,g+=M.r=n[o],y+=M.g=n[o+1],v+=M.b=n[o+2],b+=M.a=n[o+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=w=z.r,h+=x=z.g,p+=S=z.b,m+=T=z.a,g-=w,y-=x,v-=S,b-=T,z=z.next,s+=4;a+=r}for(let $=0;$<r;$++){y=v=b=g=c=u=d=l=0,s=$<<2,f=E*(w=n[s]),h=E*(x=n[s+1]),p=E*(S=n[s+2]),m=E*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*S,d+=L*T,j=R;for(let U=0;U<E;U++)j.r=w,j.g=x,j.b=S,j.a=T,j=j.next;let K=r;for(let U=1;U<=t;U++)s=K+$<<2,l+=(j.r=w=n[s])*(k=E-U),c+=(j.g=x=n[s+1])*k,u+=(j.b=S=n[s+2])*k,d+=(j.a=T=n[s+3])*k,g+=w,y+=x,v+=S,b+=T,j=j.next,U<P&&(K+=r);s=$,M=R,z=B;for(let U=0;U<i;U++)o=s<<2,n[o+3]=T=d*O>>F,T>0?(T=255/T,n[o]=(l*O>>F)*T,n[o+1]=(c*O>>F)*T,n[o+2]=(u*O>>F)*T):n[o]=n[o+1]=n[o+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=$+((o=U+E)<P?o:P)*r<<2,l+=g+=M.r=n[o],c+=y+=M.g=n[o+1],u+=v+=M.b=n[o+2],d+=b+=M.a=n[o+3],M=M.next,f+=w=z.r,h+=x=z.g,p+=S=z.b,m+=T=z.a,g-=w,y-=x,v-=S,b-=T,z=z.next,s+=r}}const j8n=function(t){const n=Math.round(this.blurRadius());n>0&&G8n(t,n)};We.addGetterSetter(an,"blurRadius",0,Jt(),We.afterSetFilter);const q8n=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]+=t,n[i+1]+=t,n[i+2]+=t};We.addGetterSetter(an,"brightness",0,Jt(),We.afterSetFilter);const Y8n=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]=Math.min(255,n[i]*t),n[i+1]=Math.min(255,n[i+1]*t),n[i+2]=Math.min(255,n[i+2]*t)},K8n=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let i=150,o=150,s=150;for(let a=0;a<r;a+=4)i=n[a],o=n[a+1],s=n[a+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,s=s<0?0:s>255?255:s,n[a]=i,n[a+1]=o,n[a+2]=s};We.addGetterSetter(an,"contrast",0,Jt(),We.afterSetFilter);const X8n=function(e){var t,n,r,i,o,s,a,l,c;const u=e.data,d=e.width,f=e.height,h=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(i=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&i!==void 0?i:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(o=this.embossDirection)===null||o===void 0?void 0:o.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,g=!!((c=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&c!==void 0&&c),y=h*10,v=p*255,b=m*Math.PI/180,w=Math.cos(b),x=Math.sin(b),S=128/1020*y,T=new Uint8ClampedArray(u),k=new Float32Array(d*f);for(let L=0,R=0;R<u.length;R+=4,L++)k[L]=.2126*T[R]+.7152*T[R+1]+.0722*T[R+2];const C=[-1,0,1,-2,0,2,-1,0,1],_=[-1,-2,-1,0,0,0,1,2,1],P=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],E=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let R=1;R<d-1;R++){const O=L*d+R;let F=0,B=0;F+=k[O+P[0]]*C[0],B+=k[O+P[0]]*_[0],F+=k[O+P[1]]*C[1],B+=k[O+P[1]]*_[1],F+=k[O+P[2]]*C[2],B+=k[O+P[2]]*_[2],F+=k[O+P[3]]*C[3],B+=k[O+P[3]]*_[3],F+=k[O+P[5]]*C[5],B+=k[O+P[5]]*_[5],F+=k[O+P[6]]*C[6],B+=k[O+P[6]]*_[6],F+=k[O+P[7]]*C[7],B+=k[O+P[7]]*_[7],F+=k[O+P[8]]*C[8],B+=k[O+P[8]]*_[8];const j=E(v+(w*F+x*B)*S),M=O*4;if(g){const z=j-v;u[M]=E(T[M]+z),u[M+1]=E(T[M+1]+z),u[M+2]=E(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=j,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let R=L*4,O=((f-1)*d+L)*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let R=L*d*4,O=(L*d+(d-1))*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};We.addGetterSetter(an,"embossStrength",.5,Jt(),We.afterSetFilter),We.addGetterSetter(an,"embossWhiteLevel",.5,Jt(),We.afterSetFilter),We.addGetterSetter(an,"embossDirection","top-left",void 0,We.afterSetFilter),We.addGetterSetter(an,"embossBlend",!1,void 0,We.afterSetFilter);function MZ(e,t,n,r,i){const o=n-t,s=i-r;if(o===0)return r+s/2;if(s===0)return r;let a=(e-t)/o;return a=s*a+r,a}const J8n=function(e){const t=e.data,n=t.length;let r=t[0],i=r,o,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let b=0;b<n;b+=4)o=t[b+0],o<r?r=o:o>i&&(i=o),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+2],d<c?c=d:d>u&&(u=d);i===r&&(i=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,v;if(f>0)h=i+f*(255-i),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),v=c-f*(c-0);else{const b=(i+r)*.5;h=i+f*(i-b),p=r+f*(r-b);const w=(a+s)*.5;m=a+f*(a-w),g=s+f*(s-w);const x=(u+c)*.5;y=u+f*(u-x),v=c+f*(c-x)}for(let b=0;b<n;b+=4)t[b+0]=MZ(t[b+0],r,i,p,h),t[b+1]=MZ(t[b+1],s,a,g,m),t[b+2]=MZ(t[b+2],c,u,v,y)};We.addGetterSetter(an,"enhance",0,Jt(),We.afterSetFilter);const Z8n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=i,t[r+1]=i,t[r+2]=i}};We.addGetterSetter(an,"hue",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"saturation",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"luminance",0,Jt(),We.afterSetFilter);const Q8n=function(e){const t=e.data,n=t.length,r=1,i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*i*Math.cos(o*Math.PI/180),l=r*i*Math.sin(o*Math.PI/180),c=.299*r+.701*a+.167*l,u=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,f=.299*r-.299*a-.328*l,h=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,m=.299*r-.3*a+1.25*l,g=.587*r-.586*a-1.05*l,y=.114*r+.886*a-.2*l;let v,b,w,x;for(let S=0;S<n;S+=4)v=t[S+0],b=t[S+1],w=t[S+2],x=t[S+3],t[S+0]=c*v+u*b+d*w+s,t[S+1]=f*v+h*b+p*w+s,t[S+2]=m*v+g*b+y*w+s,t[S+3]=x},$8n=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=r*i*Math.cos(o*Math.PI/180),a=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*s+.167*a,c=.587*r-.587*s+.33*a,u=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,f=.587*r+.413*s+.035*a,h=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,m=.587*r-.586*s-1.05*a,g=.114*r+.886*s-.2*a;for(let y=0;y<n;y+=4){const v=t[y+0],b=t[y+1],w=t[y+2],x=t[y+3];t[y+0]=l*v+c*b+u*w,t[y+1]=d*v+f*b+h*w,t[y+2]=p*v+m*b+g*w,t[y+3]=x}};We.addGetterSetter(an,"hue",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"saturation",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"value",0,Jt(),We.afterSetFilter);const e9n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var t9n=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let w=(d*o+u)*4;const x=r[w+0],S=r[w+1],T=r[w+2],k=r[w+3];w=(g+b*o)*4,i[w+0]=x,i[w+1]=S,i[w+2]=T,i[w+3]=k}}},n9n=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=n.polarRotation||0;let g,y;for(u=0;u<o;u+=1)for(d=0;d<s;d+=1){const v=u-a,b=d-l,w=Math.sqrt(v*v+b*b)*h/c;let x=(Math.atan2(b,v)*180/Math.PI+360+m)%360;x=x*p/360,g=Math.floor(x),y=Math.floor(w);let S=(y*o+g)*4;const T=r[S+0],k=r[S+1],C=r[S+2],_=r[S+3];S=(d*o+u)*4,i[S+0]=T,i[S+1]=k,i[S+2]=C,i[S+3]=_}};const r9n=function(e){const t=e.width,n=e.height;let r,i,o,s,a,l,c,u,d,f,h=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(t*(p%360)/360);if(h<1)return;const g=ot.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);ot.releaseCanvas(g),t9n(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,w=0,x=b,S=1;for(m+v>t&&(w=b,x=0,S=-1),i=0;i<n;i+=1)for(r=w;r!==x;r+=S)o=Math.round(r+m)%t,d=(t*i+o)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(i=0;i<n;i+=1)for(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+1;r+=1)d=(t*i+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}n9n(y,e,{polarRotation:0})};We.addGetterSetter(an,"kaleidoscopePower",2,Jt(),We.afterSetFilter),We.addGetterSetter(an,"kaleidoscopeAngle",0,Jt(),We.afterSetFilter);function k5(e,t,n){let r=(n*e.width+t)*4;const i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function u_(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function i9n(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function o9n(e,t){const n=k5(e,0,0),r=k5(e,e.width-1,0),i=k5(e,0,e.height-1),o=k5(e,e.width-1,e.height-1),s=t||10;if(u_(n,r)<s&&u_(r,o)<s&&u_(o,i)<s&&u_(i,n)<s){const a=i9n([r,n,o,i]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=u_(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function s9n(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function a9n(e,t,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function l9n(e,t,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function c9n(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u}return s}const u9n=function(e){let t=o9n(e,this.threshold());return t&&(t=a9n(t,e.width,e.height),t=l9n(t,e.width,e.height),t=c9n(t,e.width,e.height),s9n(e,t)),e};We.addGetterSetter(an,"threshold",0,Jt(),We.afterSetFilter);const d9n=function(e){const t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let o=0;o<r;o+=4)n[o+0]+=i-2*i*Math.random(),n[o+1]+=i-2*i*Math.random(),n[o+2]+=i-2*i*Math.random()};We.addGetterSetter(an,"noise",.2,Jt(),We.afterSetFilter);const f9n=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),o=Math.ceil(r/t),s=e.data;if(t<=0){ot.error("pixelSize value can not be <= 0");return}for(let a=0;a<i;a+=1)for(let l=0;l<o;l+=1){let c=0,u=0,d=0,f=0;const h=a*t,p=h+t,m=l*t,g=m+t;let y=0;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;c+=s[w+0],u+=s[w+1],d+=s[w+2],f+=s[w+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;s[w+0]=c,s[w+1]=u,s[w+2]=d,s[w+3]=f}}};We.addGetterSetter(an,"pixelSize",8,Jt(),We.afterSetFilter);const h9n=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let o=0;o<r;o+=1)n[o]=Math.floor(n[o]/i)*i};We.addGetterSetter(an,"levels",.5,Jt(),We.afterSetFilter);const p9n=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*i,t[s+2]=a*o,t[s+3]=t[s+3]}};We.addGetterSetter(an,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"blue",0,N9e,We.afterSetFilter);const m9n=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=i*s+t[a+1]*l,t[a+2]=o*s+t[a+2]*l}};We.addGetterSetter(an,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"blue",0,N9e,We.afterSetFilter),We.addGetterSetter(an,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const g9n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=t[r+0],o=t[r+1],s=t[r+2];t[r+0]=Math.min(255,i*.393+o*.769+s*.189),t[r+1]=Math.min(255,i*.349+o*.686+s*.168),t[r+2]=Math.min(255,i*.272+o*.534+s*.131)}},y9n=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const i=n[r],o=n[r+1],s=n[r+2];.2126*i+.7152*o+.0722*s>=128&&(n[r]=255-i,n[r+1]=255-o,n[r+2]=255-s)}return e},b9n=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=1)n[i]=n[i]<t?0:255};We.addGetterSetter(an,"threshold",.5,Jt(),We.afterSetFilter);var v9n=u7e.Util._assign(u7e,{Arc:Yp,Arrow:Nb,Circle:rx,Ellipse:i0,Image:uf,Label:RZ,Tag:Mb,Line:Kp,Path:od,Rect:a_,RegularPolygon:o0,Ring:Db,Sprite:vh,Star:s0,Text:Ro,TextPath:oa,Transformer:hi,Wedge:Xp,Filters:{Blur:j8n,Brightness:Y8n,Brighten:q8n,Contrast:K8n,Emboss:X8n,Enhance:J8n,Grayscale:Z8n,HSL:Q8n,HSV:$8n,Invert:e9n,Kaleidoscope:r9n,Mask:u9n,Noise:d9n,Pixelate:f9n,Posterize:h9n,RGB:p9n,RGBA:m9n,Sepia:g9n,Solarize:y9n,Threshold:b9n}});en();var w9n=["dialog","floating"],M7e=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function A9n(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!w9n.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!M7e.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${M7e.join(", ")}, got "${e.floating.placement}".`)}var S9n=class{activeDialog=bu(null);activeFloating=bu(null);#e=!1;#t=1;#i;constructor({getModuleConfig:e}){this.#i=e}open(e){if(this.#e)return this.#u(e);A9n(e);const t=this.#a(e),{component:n,props:r,render:i}=this.#c(t);let o,s=!1;const a=new Promise(h=>{o=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{o({status:"submitted",data:h})&&this.#r(l)},u=h=>{o({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:i,resolve:c,close:u,settle:h=>o(h),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",f=this[d].value;return f&&!f.settled&&f.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:h=>this.#n(l,h),result:a}}close(e,t){if(e!=null){const i=this.#o(e);i&&this.#n(i,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#n(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#n(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#n(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#r(e))}#r(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#o(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#a(e){const t=e.id??`surface-${this.#t++}`,n=this.#i()??{},r=e.mode==="dialog"?n.dialog:n.floating,i=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,o=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:i,floating:o}}#c(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#i()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via modules.surfaces.resolver, or use a direct-render request.`)}#u(e){return{id:e?.id??`surface-${this.#t++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},x9n="https://docs.superdoc.dev/guides/migration/document-api",D7e=new Set;function T9n(e,t){D7e.has(e)||(D7e.add(e),console.warn(t))}var I9n={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},O7e=Symbol.for("superdoc:rawEditor"),F7e=new WeakMap;function B7e(e){return!e||e[O7e]?e:new Proxy(e,{get(t,n){if(n===O7e)return t;const r=I9n[n];r&&T9n(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${x9n}`);const i=Reflect.get(t,n,t);if(typeof i=="function"){let o=F7e.get(t);return o||(o=new Map,F7e.set(t,o)),o.has(n)||o.set(n,i.bind(t)),o.get(n)}return i}})}var H7e=["review","original","final","off"],k9n=["paired","independent"],z7e=Symbol.for("@superdoc/trackChanges:normalized"),U7e=new Set;function V7e(e,t){U7e.has(e)||(U7e.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function W7e(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function E9n(e,t,n){return typeof e=="string"&&H7e.includes(e)?e:typeof t=="string"&&H7e.includes(t)?t:n}function C9n(e){return typeof e=="string"&&k9n.includes(e)?e:null}function d_(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function _9n(e){const t=e[z7e]===!0;d_(e.modules)||(e.modules={});const n=d_(e.modules.trackChanges),r=d_(e.trackChanges),i=d_(e.layoutEngineOptions?.trackedChanges);t||(r&&V7e("config.trackChanges","config.modules.trackChanges"),i&&V7e("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const o=W7e(n?.visible,r?.visible,!1),s=W7e(n?.enabled,i?.enabled,!0),a=C9n(n?.replacements)??"paired",l=e.documentMode==="viewing"?o?"review":"original":"review",c=E9n(n?.mode,i?.mode,l),u={visible:o,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:o},d_(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,z7e,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}en();var DZ=Object.freeze({name:"Default SuperDoc user",email:null}),R9n=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]),E5=class extends v6.default{static allowedTypes=[pc,wT,n1];#e=!1;#t=!1;#i=null;#n=null;#r;version;users;ydoc;provider;whiteboard;colors=[];config={superdocId:null,selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],format:null,editorExtensions:[],colors:[],user:{name:null,email:null},users:[],modules:{},permissionResolver:null,licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbar:null,toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,onFontsResolved:null,onTrackedChangeBubbleAccept:null,onTrackedChangeBubbleReject:null,handleImageUpload:null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0};constructor(e){if(super(),!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o(e,t)}async#o(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),_9n(this.config);const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated");const i=this.config.user;if(!i||typeof i!="object"?this.config.user={...DZ}:(this.config.user={...DZ,...i},this.config.user.name||(this.config.user.name=DZ.name)),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.colors=sYe(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.31.0",this.#A("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||wn(),this.colors=this.config.colors??[],this.#d(),this.#r=new S9n({getModuleConfig:()=>this.config.modules?.surfaces}),await this.#s(this.config.modules),this.#e){this.#v();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null,this.#n=document.createElement("div"),this.#n.style.display="contents",t.appendChild(this.#n),this.#l(),this.#c(),this.#_(),this.#a()}#a(){this.#f(),this.readyEditors=0,this.app.mount(this.#n)}#c(){const e=(this.config.modules?.whiteboard??{}).enabled??!1;this.whiteboard=new XFn({Renderer:v9n,superdoc:this,enabled:e}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(e=>e.type===pc).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(this.config.document)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,i=!!e&&e instanceof Blob&&!(e instanceof File),o=this.config.documents&&this.config.documents?.length;if(t&&o&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}else if(n)this.config.documents=[{id:wn(),type:pc,url:this.config.document,name:"document.docx"}];else if(r){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}else if(i){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=GC(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||wn()}}))}#f(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:i}=zFn({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#r),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=i,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const o=this.config.modules.comments;this.commentsStore.init(o||{}),this.isCollaborative&&s5(this),this.#E()}#l(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf:document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException),this.on("list-definitions-change",this.config.onListDefinitionsChange),this.on("pagination-update",this.config.onPaginationUpdate),this.config.onFontsResolved&&this.on("fonts-resolved",this.config.onFontsResolved)}async#s({collaboration:e,comments:t={}}={}){if(!e)return this.config.documents;const{ydoc:n,provider:r}=e;if(n&&r)return(!this.config.documents||this.config.documents.length===0)&&(this.config.documents=[{id:wn(),type:pc,name:"document.docx"}]),this.#w(n,r),s5(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Jre({url:e.url}));const i=lOn(this);if(t.useInternalExternalComments&&!t.suppressInternalExternalComments){const{ydoc:o,provider:s}=aOn(this);this.ydoc=Zi(o),this.provider=Zi(s)}else this.ydoc=Zi(i[0].ydoc),this.provider=Zi(i[0].provider);return s5(this),i}#w(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Zi(e),this.provider=Zi(t),this.#x(),this._cleanupAwareness=iOn(t,this,this.config.user),this.config.documents.forEach(n=>{n.ydoc=e,n.provider=t,n.role=this.config.role})}#b(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0,delete this.config.modules.collaboration,this.config.documents.forEach(e=>{delete e.ydoc,delete e.provider})}#x(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:R9n,n=e.email||e.name||"";let r=5381;for(let i=0;i<n.length;i++)r=(r<<5)+r^n.charCodeAt(i);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#C({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#I();await this.#S(t),this.#k(),X3t(n,e),GFn(e,this.commentsStore.commentsList),jFn(e,{isLocked:this.isLocked,lockedBy:this.lockedBy}),this.config.modules.collaboration={ydoc:e,provider:t},this.#w(e,t),this.#T(e,t);const r=this.#m();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(i){throw this.#y(),i}if(await this.#h(r),this.#e)return;s5(this)}finally{this.#i=null,this.#t=!1}}#k(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#T(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const i=di(r);i.ydoc&&typeof i.ydoc=="object"&&"value"in i.ydoc&&(i.ydoc.value=e),i.provider&&typeof i.provider=="object"&&"value"in i.provider&&(i.provider.value=t)}}#m(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getPresentationEditor?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#y(){this.#b(),this.#T(null,null)}#h(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let i=!1;const o=()=>{i||(i=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{o(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{o(),r(void 0)};this.#i=()=>{o(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(o(),r(void 0))})}#S(e){return new Promise((n,r)=>{let i,o=!1,s=()=>{};const a=()=>{o=!0,clearTimeout(i),s()};s=jw(e,()=>{o||(a(),n())}),o||(i=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#i=()=>{o||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#C({ydoc:e,provider:t}){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#t)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");if(!e||!t)throw new Error("SuperDoc: upgradeToCollaboration() requires both ydoc and provider");const n=this.config.documents.filter(r=>r.type===pc);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(this.config.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#I(){const e=this.config.documents.find(n=>n.type===pc),t=this.superdocStore.documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.users.some(t=>t.email===e.email)||this.users.push(e)}removeSharedUser(e){this.users=this.users.filter(t=>t.email!==e)}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.superdocStore.documents.find(i=>i.id===n);this.config.onContentError?.({error:e,editor:t,documentId:r.id,file:r.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:B7e(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:B7e(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#A(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(e=>{e.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:i=null}={}){if(!e)return!1;let o=r??i?.comment??null;const s=i?.commentId||i?.id;if(!o&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s);o=a?.getValues?a.getValues():a}return kb(e,t,n,{superdoc:this,currentUser:this.config.user,comment:o??null,trackedChange:i??null})}#_(){const e=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const t=[...e.excludeItems||[]];(!this.config.rulers||this.config.viewOptions?.layout==="web")&&t.push("ruler"),this.toolbar=new REe({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,icons:this.config.modules?.toolbar?.icons||this.config.toolbarIcons,texts:this.config.modules?.toolbar?.texts||this.config.toolbarTexts,fonts:this.config.modules?.toolbar?.fonts||null,hideButtons:this.config.modules?.toolbar?.hideButtons??!0,responsiveToContainer:this.config.modules?.toolbar?.responsiveToContainer??!1,documentMode:this.config.documentMode,superdoc:this,aiApiKey:this.config.modules?.ai?.apiKey,aiEndpoint:this.config.modules?.ai?.endpoint,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont,...e,excludeItems:t}),this.toolbar.on("exception",this.config.onException),this.once("editorCreate",()=>this.toolbar?.updateToolbarState())}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new Z5n(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),i=n.querySelector(`[data-comment-ids*="${r}"]`);if(!i)return!1;const{behavior:o="smooth",block:s="start"}=t??{};return i.scrollIntoView({behavior:o,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getPresentationEditor?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const i=n.getEditor?.();i?.setOptions&&i.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowBookmarks?.(t)}))}setDocumentMode(e){if(!e)return;e=e.toLowerCase(),this.config.documentMode=e,this.#E();const t={viewing:()=>this.#P(),editing:()=>this.#R(),suggesting:()=>this.#D()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#g(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#R(){if(this.config.role!=="editor")return this.#D();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#g(e,"editing")})}#D(){if(!["editor","suggester"].includes(this.config.role))return this.#P();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#g(e,"suggesting")})}#P(){this.toolbar&&(this.toolbar.activeEditor=null);const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(t?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!e&&!t&&this.commentsStore?.clearEditorCommentPositions?.(),this.superdocStore.documents.forEach(n=>{e||t?n.restoreComments():n.removeComments(),this.#g(n,"viewing")})}#E(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const i=this.superdocStore?.documents;Array.isArray(i)&&i.length>0&&i.forEach(o=>{const s=typeof o.getPresentationEditor=="function"?o.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t){this.isLocked=e,this.lockedBy=t,this.#A("🦋 [superdoc] Locking superdoc:",e,t,`
1110
+ `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,o=this.attrs.height,s=i!==ix&&i!==void 0,a=o!==ix&&o!==void 0,l=this.padding(),c=i-l*2,u=o-l*2,d=0,f=this.wrap(),h=f!==I8n&&f!==T7e,p=this.ellipsis();this.textArr=[],LZ().font=this._getContextFont();const m=p?this._getTextWidth(PZ):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let w=0,x=a0(v).length,S="",T=0;for(;w<x;){const k=w+x>>>1,C=a0(v).slice(0,k+1).join(""),_=this._getTextWidth(C);(p&&a&&d+r>u?_+m:_)<=c?(w=k+1,S=C,T=_):x=k}if(S){if(h){const k=a0(v),C=a0(S),_=k[C.length],P=_===x5||_===v7e;let E;if(P&&T<=c)E=C.length;else{const L=C.lastIndexOf(x5),R=C.lastIndexOf(v7e);E=Math.max(L,R)+1}E>0&&(w=E,S=k.slice(0,w).join(""),T=this._getTextWidth(S))}if(S=S.trimRight(),this._addTextLine(S),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=a0(v).slice(w).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==ix&&r!==void 0,o=r-this.padding()*2;return this.wrap()===T7e||i&&e+n>o}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==ix&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+PZ)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+PZ))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&E8n()?!0:super._useBufferCanvas()}};Ro.prototype._fillFunc=_8n,Ro.prototype._strokeFunc=R8n,Ro.prototype.className=v8n,Ro.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],ss(Ro),We.overWriteSetter(Ro,"width",hZ()),We.overWriteSetter(Ro,"height",hZ()),We.addGetterSetter(Ro,"direction",y7e),We.addGetterSetter(Ro,"fontFamily","Arial"),We.addGetterSetter(Ro,"fontSize",12,Jt()),We.addGetterSetter(Ro,"fontStyle",S7e),We.addGetterSetter(Ro,"fontVariant",S7e),We.addGetterSetter(Ro,"padding",0,Jt()),We.addGetterSetter(Ro,"align",w7e),We.addGetterSetter(Ro,"verticalAlign",w8n),We.addGetterSetter(Ro,"lineHeight",1,Jt()),We.addGetterSetter(Ro,"wrap",T8n),We.addGetterSetter(Ro,"ellipsis",!1,cf()),We.addGetterSetter(Ro,"letterSpacing",0,Jt()),We.addGetterSetter(Ro,"text","",Rb()),We.addGetterSetter(Ro,"textDecoration",""),We.addGetterSetter(Ro,"underlineOffset",void 0,Jt()),We.addGetterSetter(Ro,"charRenderFunc",void 0);var L8n="",k7e="normal";function E7e(e){e.fillText(this.partialText,0,0)}function C7e(e){e.strokeText(this.partialText,0,0)}var oa=class extends Yt{constructor(e){super(e),this.dummyCanvas=ot.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return od.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:od.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=od.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,o=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;o&&e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),this.partialText=i[a].text,e.fillStrokeShape(this),o&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(i[a].width,r/2+1)),e.restore()}if(o&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<i.length;a++){e.save();const l=i[a].p0;e.translate(l.x,l.y),e.rotate(i[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(i[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return ot.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Ro.prototype.setText.call(this,e)}_getContextFont(){return Ro.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=a0(this.text()),t=[];let n=0;for(let f=0;f<e.length;f++)t.push({char:e[f],width:this._getTextSize(e[f]).width}),n+=t[f].width;const{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;const o=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*o,0);let u=0;s==="center"&&(u=Math.max(0,this.pathLength/2-c/2)),s==="right"&&(u=Math.max(0,this.pathLength-c));let d=u;for(let f=0;f<t.length;f++){const h=this._getPointAtLength(d);if(!h)return;const p=t[f].char;let m=t[f].width+o;if(p===" "&&s==="justify"){const S=this.text().split(" ").length-1;m+=(this.pathLength-c)/S}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=od.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const w=od.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),x=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:w.x,transposeY:w.y,text:e[f],rotation:x,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,o,s;for(let l=0;l<e.length/2;l++)o=e[l*2],s=e[l*2+1],t=Math.min(t,o),n=Math.max(n,o),r=Math.min(r,s),i=Math.max(i,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:i-r+a}}destroy(){return ot.releaseCanvas(this.dummyCanvas),super.destroy()}};oa.prototype._fillFunc=E7e,oa.prototype._strokeFunc=C7e,oa.prototype._fillFuncHit=E7e,oa.prototype._strokeFuncHit=C7e,oa.prototype.className="TextPath",oa.prototype._attrsAffectingSize=["text","fontSize","data"],ss(oa),We.addGetterSetter(oa,"data"),We.addGetterSetter(oa,"fontFamily","Arial"),We.addGetterSetter(oa,"fontSize",12,Jt()),We.addGetterSetter(oa,"fontStyle",k7e),We.addGetterSetter(oa,"align","left"),We.addGetterSetter(oa,"letterSpacing",0,Jt()),We.addGetterSetter(oa,"textBaseline","middle"),We.addGetterSetter(oa,"fontVariant",k7e),We.addGetterSetter(oa,"text",L8n),We.addGetterSetter(oa,"textDecoration",""),We.addGetterSetter(oa,"kerningFunc",void 0);var _7e="tr-konva",N8n=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${_7e}`).join(" "),R7e="nodesRect",M8n=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],D8n={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},O8n="ontouchstart"in on._global;function F8n(e,t,n){if(e==="rotater")return n;t+=ot.degToRad(D8n[e]||0);const r=(ot.radToDeg(t)%360+360)%360;return ot._inRange(r,337.5,360)||ot._inRange(r,0,22.5)?"ns-resize":ot._inRange(r,22.5,67.5)?"nesw-resize":ot._inRange(r,67.5,112.5)?"ew-resize":ot._inRange(r,112.5,157.5)?"nwse-resize":ot._inRange(r,157.5,202.5)?"ns-resize":ot._inRange(r,202.5,247.5)?"nesw-resize":ot._inRange(r,247.5,292.5)?"ew-resize":ot._inRange(r,292.5,337.5)?"nwse-resize":(ot.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var I5=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],P7e=1e8;function B8n(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function L7e(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function H8n(e,t){return L7e(e,t,B8n(e))}function z8n(e,t,n){let r=t;for(let i=0;i<e.length;i++){const o=on.getAngle(e[i]),s=Math.abs(o-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=o)}return r}var NZ=0,hi=class extends tx{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(N8n,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return ot.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return _7e+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(ot.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(M8n.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),i=r.x-t.x,o=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+i,y:a.y+o}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(R7e),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(R7e,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),s=r.x*i.x-e.offsetX()*i.x,a=r.y*i.y-e.offsetY()*i.y,l=(on.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return L7e({x:o.x+s*Math.cos(l)+a*Math.sin(-l),y:o.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-on.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-P7e,y:-P7e,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),c=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],u=a.getAbsoluteTransform();c.forEach(function(d){const f=u.point(d);e.push(f)})});const t=new lf;t.rotate(-on.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,o=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=i=l.x,r=o=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),i=Math.max(i,l.x),o=Math.max(o,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:i-n,height:o-r,rotation:on.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),I5.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new a_({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:O8n?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=F8n(e,on.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new Yt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),i=r.padding(),o=n.width(),s=n.height();if(t.beginPath(),t.rect(-i,-i,o+i*2,s+i*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=ot.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=o/2,h=s/2;let p=1/0;d<0?p=Math.min(p,-h/d):d>0&&(p=Math.min(p,(s-h)/d)),u<0?p=Math.min(p,-f/u):u>0&&(p=Math.min(p,(o-f)/u));const m=f+u*p,g=h+d*p,y=ot._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},NZ++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(e);const s=o.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),i.setAbsolutePosition(a);const c=i.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=i.x()-y.width/2,n=-i.y()+y.height/2;const v=on.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const w=on.getAngle(this.rotation())+b,x=on.getAngle(this.rotationSnapTolerance()),S=H8n(y,z8n(this.rotationSnaps(),w,x)-y.rotation);this._fitNodesInto(S,e);return}const u=this.shiftBehavior();let d;u==="inverted"?d=this.keepRatio()&&!e.shiftKey:u==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(i.y());else if(this._movingAnchorName==="top-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(y.y-i.y(),2));const v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=i.position();this.findOne(".top-left").y(h.y),this.findOne(".bottom-right").x(h.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(i.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(i.x());else if(this._movingAnchorName==="bottom-left"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(y.x-i.x(),2)+Math.pow(i.y()-y.y,2));const v=y.x<i.x()?-1:1,b=i.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,i.x(y.x-t),i.y(y.y+n)}h=i.position(),this.findOne(".top-left").x(h.x),this.findOne(".bottom-right").y(h.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(i.y());else if(this._movingAnchorName==="bottom-right"){if(d){const y=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-y.x,2)+Math.pow(i.y()-y.y,2));const v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),w=y.y(),x=this.getWidth()-v.x(),S=this.getHeight()-v.y();v.move({x:-b,y:-w}),y.move({x,y:S})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),g=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:m,height:g,rotation:on.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();NZ--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var i;r._fire("transformend",{evt:e,target:r}),(i=r.getLayer())===null||i===void 0||i.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(ot._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(ot._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const i=new lf;if(i.rotate(on.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=i.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=i.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=i.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=i.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:ot.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,s=new lf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/o,n.height/o);const a=new lf,l=e.width/o,c=e.height/o;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(c))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,c));const u=a.multiply(s.invert());this._nodes.forEach(d=>{var f;if(!d.getStage())return;const h=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const m=new lf;m.multiply(h.copy().invert()).multiply(u).multiply(h).multiply(p);const g=m.decompose();d.setAttrs(g),(f=d.getLayer())===null||f===void 0||f.batchDraw()}),this.rotation(ot._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(ot._getRotation(t.rotation));const n=t.width,r=t.height,i=this.enabledAnchors(),o=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:o&&i.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:o&&i.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:o&&i.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:o&&i.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:o&&i.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:o&&i.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:o&&i.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=ot.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=ot._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const w=this.anchorStyleFunc();w&&l.forEach(x=>{w(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),tx.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(ot.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return an.prototype.toObject.call(this)}clone(e){return an.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};hi.isTransforming=()=>NZ>0;function U8n(e){return e instanceof Array||ot.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){I5.indexOf(t)===-1&&ot.warn("Unknown anchor name: "+t+". Available names are: "+I5.join(", "))}),e||[]}hi.prototype.className="Transformer",ss(hi),We.addGetterSetter(hi,"enabledAnchors",I5,U8n),We.addGetterSetter(hi,"flipEnabled",!0,cf()),We.addGetterSetter(hi,"resizeEnabled",!0),We.addGetterSetter(hi,"anchorSize",10,Jt()),We.addGetterSetter(hi,"rotateEnabled",!0),We.addGetterSetter(hi,"rotateLineVisible",!0),We.addGetterSetter(hi,"rotationSnaps",[]),We.addGetterSetter(hi,"rotateAnchorOffset",50,Jt()),We.addGetterSetter(hi,"rotateAnchorAngle",0,Jt()),We.addGetterSetter(hi,"rotateAnchorCursor","crosshair"),We.addGetterSetter(hi,"rotationSnapTolerance",5,Jt()),We.addGetterSetter(hi,"borderEnabled",!0),We.addGetterSetter(hi,"anchorStroke","rgb(0, 161, 255)"),We.addGetterSetter(hi,"anchorStrokeWidth",1,Jt()),We.addGetterSetter(hi,"anchorFill","white"),We.addGetterSetter(hi,"anchorCornerRadius",0,Jt()),We.addGetterSetter(hi,"borderStroke","rgb(0, 161, 255)"),We.addGetterSetter(hi,"borderStrokeWidth",1,Jt()),We.addGetterSetter(hi,"borderDash"),We.addGetterSetter(hi,"keepRatio",!0),We.addGetterSetter(hi,"shiftBehavior","default"),We.addGetterSetter(hi,"centeredScaling",!1),We.addGetterSetter(hi,"ignoreStroke",!1),We.addGetterSetter(hi,"padding",0,Jt()),We.addGetterSetter(hi,"nodes"),We.addGetterSetter(hi,"node"),We.addGetterSetter(hi,"boundBoxFunc"),We.addGetterSetter(hi,"anchorDragBoundFunc"),We.addGetterSetter(hi,"anchorStyleFunc"),We.addGetterSetter(hi,"shouldOverdrawWholeArea",!1),We.addGetterSetter(hi,"useSingleNodeRotation",!0),We.backCompat(hi,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Xp=class extends Yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,on.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Xp.prototype.className="Wedge",Xp.prototype._centroid=!0,Xp.prototype._attrsAffectingSize=["radius"],ss(Xp),We.addGetterSetter(Xp,"radius",0,Jt()),We.addGetterSetter(Xp,"angle",0,Jt()),We.addGetterSetter(Xp,"clockwise",!1),We.backCompat(Xp,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function N7e(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var V8n=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],W8n=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function G8n(e,t){const n=e.data,r=e.width,i=e.height;let o,s,a,l,c,u,d,f,h,p,m,g,y,v,b,w,x,S,T,k;const C=t+t+1,_=r-1,P=i-1,E=t+1,L=E*(E+1)/2,R=new N7e,O=V8n[t],F=W8n[t];let B=null,j=R,M=null,z=null;for(let $=1;$<C;$++)j=j.next=new N7e,$===E&&(B=j);j.next=R,a=s=0;for(let $=0;$<i;$++){g=y=v=b=l=c=u=d=0,f=E*(w=n[s]),h=E*(x=n[s+1]),p=E*(S=n[s+2]),m=E*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*S,d+=L*T,j=R;for(let K=0;K<E;K++)j.r=w,j.g=x,j.b=S,j.a=T,j=j.next;for(let K=1;K<E;K++)o=s+((_<K?_:K)<<2),l+=(j.r=w=n[o])*(k=E-K),c+=(j.g=x=n[o+1])*k,u+=(j.b=S=n[o+2])*k,d+=(j.a=T=n[o+3])*k,g+=w,y+=x,v+=S,b+=T,j=j.next;M=R,z=B;for(let K=0;K<r;K++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=a+((o=K+t+1)<_?o:_)<<2,g+=M.r=n[o],y+=M.g=n[o+1],v+=M.b=n[o+2],b+=M.a=n[o+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=w=z.r,h+=x=z.g,p+=S=z.b,m+=T=z.a,g-=w,y-=x,v-=S,b-=T,z=z.next,s+=4;a+=r}for(let $=0;$<r;$++){y=v=b=g=c=u=d=l=0,s=$<<2,f=E*(w=n[s]),h=E*(x=n[s+1]),p=E*(S=n[s+2]),m=E*(T=n[s+3]),l+=L*w,c+=L*x,u+=L*S,d+=L*T,j=R;for(let U=0;U<E;U++)j.r=w,j.g=x,j.b=S,j.a=T,j=j.next;let K=r;for(let U=1;U<=t;U++)s=K+$<<2,l+=(j.r=w=n[s])*(k=E-U),c+=(j.g=x=n[s+1])*k,u+=(j.b=S=n[s+2])*k,d+=(j.a=T=n[s+3])*k,g+=w,y+=x,v+=S,b+=T,j=j.next,U<P&&(K+=r);s=$,M=R,z=B;for(let U=0;U<i;U++)o=s<<2,n[o+3]=T=d*O>>F,T>0?(T=255/T,n[o]=(l*O>>F)*T,n[o+1]=(c*O>>F)*T,n[o+2]=(u*O>>F)*T):n[o]=n[o+1]=n[o+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,o=$+((o=U+E)<P?o:P)*r<<2,l+=g+=M.r=n[o],c+=y+=M.g=n[o+1],u+=v+=M.b=n[o+2],d+=b+=M.a=n[o+3],M=M.next,f+=w=z.r,h+=x=z.g,p+=S=z.b,m+=T=z.a,g-=w,y-=x,v-=S,b-=T,z=z.next,s+=r}}const j8n=function(t){const n=Math.round(this.blurRadius());n>0&&G8n(t,n)};We.addGetterSetter(an,"blurRadius",0,Jt(),We.afterSetFilter);const q8n=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]+=t,n[i+1]+=t,n[i+2]+=t};We.addGetterSetter(an,"brightness",0,Jt(),We.afterSetFilter);const Y8n=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let i=0;i<r;i+=4)n[i]=Math.min(255,n[i]*t),n[i+1]=Math.min(255,n[i+1]*t),n[i+2]=Math.min(255,n[i+2]*t)},K8n=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let i=150,o=150,s=150;for(let a=0;a<r;a+=4)i=n[a],o=n[a+1],s=n[a+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,s=s<0?0:s>255?255:s,n[a]=i,n[a+1]=o,n[a+2]=s};We.addGetterSetter(an,"contrast",0,Jt(),We.afterSetFilter);const X8n=function(e){var t,n,r,i,o,s,a,l,c;const u=e.data,d=e.width,f=e.height,h=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(i=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&i!==void 0?i:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(o=this.embossDirection)===null||o===void 0?void 0:o.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,g=!!((c=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&c!==void 0&&c),y=h*10,v=p*255,b=m*Math.PI/180,w=Math.cos(b),x=Math.sin(b),S=128/1020*y,T=new Uint8ClampedArray(u),k=new Float32Array(d*f);for(let L=0,R=0;R<u.length;R+=4,L++)k[L]=.2126*T[R]+.7152*T[R+1]+.0722*T[R+2];const C=[-1,0,1,-2,0,2,-1,0,1],_=[-1,-2,-1,0,0,0,1,2,1],P=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],E=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let R=1;R<d-1;R++){const O=L*d+R;let F=0,B=0;F+=k[O+P[0]]*C[0],B+=k[O+P[0]]*_[0],F+=k[O+P[1]]*C[1],B+=k[O+P[1]]*_[1],F+=k[O+P[2]]*C[2],B+=k[O+P[2]]*_[2],F+=k[O+P[3]]*C[3],B+=k[O+P[3]]*_[3],F+=k[O+P[5]]*C[5],B+=k[O+P[5]]*_[5],F+=k[O+P[6]]*C[6],B+=k[O+P[6]]*_[6],F+=k[O+P[7]]*C[7],B+=k[O+P[7]]*_[7],F+=k[O+P[8]]*C[8],B+=k[O+P[8]]*_[8];const j=E(v+(w*F+x*B)*S),M=O*4;if(g){const z=j-v;u[M]=E(T[M]+z),u[M+1]=E(T[M+1]+z),u[M+2]=E(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=j,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let R=L*4,O=((f-1)*d+L)*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let R=L*d*4,O=(L*d+(d-1))*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};We.addGetterSetter(an,"embossStrength",.5,Jt(),We.afterSetFilter),We.addGetterSetter(an,"embossWhiteLevel",.5,Jt(),We.afterSetFilter),We.addGetterSetter(an,"embossDirection","top-left",void 0,We.afterSetFilter),We.addGetterSetter(an,"embossBlend",!1,void 0,We.afterSetFilter);function MZ(e,t,n,r,i){const o=n-t,s=i-r;if(o===0)return r+s/2;if(s===0)return r;let a=(e-t)/o;return a=s*a+r,a}const J8n=function(e){const t=e.data,n=t.length;let r=t[0],i=r,o,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let b=0;b<n;b+=4)o=t[b+0],o<r?r=o:o>i&&(i=o),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+2],d<c?c=d:d>u&&(u=d);i===r&&(i=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,v;if(f>0)h=i+f*(255-i),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),v=c-f*(c-0);else{const b=(i+r)*.5;h=i+f*(i-b),p=r+f*(r-b);const w=(a+s)*.5;m=a+f*(a-w),g=s+f*(s-w);const x=(u+c)*.5;y=u+f*(u-x),v=c+f*(c-x)}for(let b=0;b<n;b+=4)t[b+0]=MZ(t[b+0],r,i,p,h),t[b+1]=MZ(t[b+1],s,a,g,m),t[b+2]=MZ(t[b+2],c,u,v,y)};We.addGetterSetter(an,"enhance",0,Jt(),We.afterSetFilter);const Z8n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=i,t[r+1]=i,t[r+2]=i}};We.addGetterSetter(an,"hue",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"saturation",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"luminance",0,Jt(),We.afterSetFilter);const Q8n=function(e){const t=e.data,n=t.length,r=1,i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*i*Math.cos(o*Math.PI/180),l=r*i*Math.sin(o*Math.PI/180),c=.299*r+.701*a+.167*l,u=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,f=.299*r-.299*a-.328*l,h=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,m=.299*r-.3*a+1.25*l,g=.587*r-.586*a-1.05*l,y=.114*r+.886*a-.2*l;let v,b,w,x;for(let S=0;S<n;S+=4)v=t[S+0],b=t[S+1],w=t[S+2],x=t[S+3],t[S+0]=c*v+u*b+d*w+s,t[S+1]=f*v+h*b+p*w+s,t[S+2]=m*v+g*b+y*w+s,t[S+3]=x},$8n=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=r*i*Math.cos(o*Math.PI/180),a=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*s+.167*a,c=.587*r-.587*s+.33*a,u=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,f=.587*r+.413*s+.035*a,h=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,m=.587*r-.586*s-1.05*a,g=.114*r+.886*s-.2*a;for(let y=0;y<n;y+=4){const v=t[y+0],b=t[y+1],w=t[y+2],x=t[y+3];t[y+0]=l*v+c*b+u*w,t[y+1]=d*v+f*b+h*w,t[y+2]=p*v+m*b+g*w,t[y+3]=x}};We.addGetterSetter(an,"hue",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"saturation",0,Jt(),We.afterSetFilter),We.addGetterSetter(an,"value",0,Jt(),We.afterSetFilter);const e9n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var t9n=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let w=(d*o+u)*4;const x=r[w+0],S=r[w+1],T=r[w+2],k=r[w+3];w=(g+b*o)*4,i[w+0]=x,i[w+1]=S,i[w+2]=T,i[w+3]=k}}},n9n=function(e,t,n){const r=e.data,i=t.data,o=e.width,s=e.height,a=n.polarCenterX||o/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=o-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=o,m=n.polarRotation||0;let g,y;for(u=0;u<o;u+=1)for(d=0;d<s;d+=1){const v=u-a,b=d-l,w=Math.sqrt(v*v+b*b)*h/c;let x=(Math.atan2(b,v)*180/Math.PI+360+m)%360;x=x*p/360,g=Math.floor(x),y=Math.floor(w);let S=(y*o+g)*4;const T=r[S+0],k=r[S+1],C=r[S+2],_=r[S+3];S=(d*o+u)*4,i[S+0]=T,i[S+1]=k,i[S+2]=C,i[S+3]=_}};const r9n=function(e){const t=e.width,n=e.height;let r,i,o,s,a,l,c,u,d,f,h=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(t*(p%360)/360);if(h<1)return;const g=ot.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);ot.releaseCanvas(g),t9n(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,w=0,x=b,S=1;for(m+v>t&&(w=b,x=0,S=-1),i=0;i<n;i+=1)for(r=w;r!==x;r+=S)o=Math.round(r+m)%t,d=(t*i+o)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(i=0;i<n;i+=1)for(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+1;r+=1)d=(t*i+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*i+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}n9n(y,e,{polarRotation:0})};We.addGetterSetter(an,"kaleidoscopePower",2,Jt(),We.afterSetFilter),We.addGetterSetter(an,"kaleidoscopeAngle",0,Jt(),We.afterSetFilter);function k5(e,t,n){let r=(n*e.width+t)*4;const i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function u_(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function i9n(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function o9n(e,t){const n=k5(e,0,0),r=k5(e,e.width-1,0),i=k5(e,0,e.height-1),o=k5(e,e.width-1,e.height-1),s=t||10;if(u_(n,r)<s&&u_(r,o)<s&&u_(o,i)<s&&u_(i,n)<s){const a=i9n([r,n,o,i]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=u_(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function s9n(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function a9n(e,t,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function l9n(e,t,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function c9n(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const c=a*t+l;let u=0;for(let d=0;d<i;d++)for(let f=0;f<i;f++){const h=a+d-o,p=l+f-o;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*i+f];u+=e[m]*g}}s[c]=u}return s}const u9n=function(e){let t=o9n(e,this.threshold());return t&&(t=a9n(t,e.width,e.height),t=l9n(t,e.width,e.height),t=c9n(t,e.width,e.height),s9n(e,t)),e};We.addGetterSetter(an,"threshold",0,Jt(),We.afterSetFilter);const d9n=function(e){const t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let o=0;o<r;o+=4)n[o+0]+=i-2*i*Math.random(),n[o+1]+=i-2*i*Math.random(),n[o+2]+=i-2*i*Math.random()};We.addGetterSetter(an,"noise",.2,Jt(),We.afterSetFilter);const f9n=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),o=Math.ceil(r/t),s=e.data;if(t<=0){ot.error("pixelSize value can not be <= 0");return}for(let a=0;a<i;a+=1)for(let l=0;l<o;l+=1){let c=0,u=0,d=0,f=0;const h=a*t,p=h+t,m=l*t,g=m+t;let y=0;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;c+=s[w+0],u+=s[w+1],d+=s[w+2],f+=s[w+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const w=(n*b+v)*4;s[w+0]=c,s[w+1]=u,s[w+2]=d,s[w+3]=f}}};We.addGetterSetter(an,"pixelSize",8,Jt(),We.afterSetFilter);const h9n=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let o=0;o<r;o+=1)n[o]=Math.floor(n[o]/i)*i};We.addGetterSetter(an,"levels",.5,Jt(),We.afterSetFilter);const p9n=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*i,t[s+2]=a*o,t[s+3]=t[s+3]}};We.addGetterSetter(an,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"blue",0,N9e,We.afterSetFilter);const m9n=function(e){const t=e.data,n=t.length,r=this.red(),i=this.green(),o=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=i*s+t[a+1]*l,t[a+2]=o*s+t[a+2]*l}};We.addGetterSetter(an,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),We.addGetterSetter(an,"blue",0,N9e,We.afterSetFilter),We.addGetterSetter(an,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const g9n=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const i=t[r+0],o=t[r+1],s=t[r+2];t[r+0]=Math.min(255,i*.393+o*.769+s*.189),t[r+1]=Math.min(255,i*.349+o*.686+s*.168),t[r+2]=Math.min(255,i*.272+o*.534+s*.131)}},y9n=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const i=n[r],o=n[r+1],s=n[r+2];.2126*i+.7152*o+.0722*s>=128&&(n[r]=255-i,n[r+1]=255-o,n[r+2]=255-s)}return e},b9n=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let i=0;i<r;i+=1)n[i]=n[i]<t?0:255};We.addGetterSetter(an,"threshold",.5,Jt(),We.afterSetFilter);var v9n=u7e.Util._assign(u7e,{Arc:Yp,Arrow:Nb,Circle:rx,Ellipse:i0,Image:uf,Label:RZ,Tag:Mb,Line:Kp,Path:od,Rect:a_,RegularPolygon:o0,Ring:Db,Sprite:vh,Star:s0,Text:Ro,TextPath:oa,Transformer:hi,Wedge:Xp,Filters:{Blur:j8n,Brightness:Y8n,Brighten:q8n,Contrast:K8n,Emboss:X8n,Enhance:J8n,Grayscale:Z8n,HSL:Q8n,HSV:$8n,Invert:e9n,Kaleidoscope:r9n,Mask:u9n,Noise:d9n,Pixelate:f9n,Posterize:h9n,RGB:p9n,RGBA:m9n,Sepia:g9n,Solarize:y9n,Threshold:b9n}});en();var w9n=["dialog","floating"],M7e=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function A9n(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!w9n.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!M7e.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${M7e.join(", ")}, got "${e.floating.placement}".`)}var S9n=class{activeDialog=bu(null);activeFloating=bu(null);#e=!1;#t=1;#i;constructor({getModuleConfig:e}){this.#i=e}open(e){if(this.#e)return this.#u(e);A9n(e);const t=this.#a(e),{component:n,props:r,render:i}=this.#c(t);let o,s=!1;const a=new Promise(h=>{o=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{o({status:"submitted",data:h})&&this.#r(l)},u=h=>{o({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:i,resolve:c,close:u,settle:h=>o(h),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",f=this[d].value;return f&&!f.settled&&f.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:h=>this.#n(l,h),result:a}}close(e,t){if(e!=null){const i=this.#o(e);i&&this.#n(i,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#n(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#n(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#n(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#r(e))}#r(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#o(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#a(e){const t=e.id??`surface-${this.#t++}`,n=this.#i()??{},r=e.mode==="dialog"?n.dialog:n.floating,i=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,o=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:i,floating:o}}#c(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#i()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via modules.surfaces.resolver, or use a direct-render request.`)}#u(e){return{id:e?.id??`surface-${this.#t++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},x9n="https://docs.superdoc.dev/guides/migration/document-api",D7e=new Set;function T9n(e,t){D7e.has(e)||(D7e.add(e),console.warn(t))}var I9n={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},O7e=Symbol.for("superdoc:rawEditor"),F7e=new WeakMap;function B7e(e){return!e||e[O7e]?e:new Proxy(e,{get(t,n){if(n===O7e)return t;const r=I9n[n];r&&T9n(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${x9n}`);const i=Reflect.get(t,n,t);if(typeof i=="function"){let o=F7e.get(t);return o||(o=new Map,F7e.set(t,o)),o.has(n)||o.set(n,i.bind(t)),o.get(n)}return i}})}var H7e=["review","original","final","off"],k9n=["paired","independent"],z7e=Symbol.for("@superdoc/trackChanges:normalized"),U7e=new Set;function V7e(e,t){U7e.has(e)||(U7e.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function W7e(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function E9n(e,t,n){return typeof e=="string"&&H7e.includes(e)?e:typeof t=="string"&&H7e.includes(t)?t:n}function C9n(e){return typeof e=="string"&&k9n.includes(e)?e:null}function d_(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function _9n(e){const t=e[z7e]===!0;d_(e.modules)||(e.modules={});const n=d_(e.modules.trackChanges),r=d_(e.trackChanges),i=d_(e.layoutEngineOptions?.trackedChanges);t||(r&&V7e("config.trackChanges","config.modules.trackChanges"),i&&V7e("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const o=W7e(n?.visible,r?.visible,!1),s=W7e(n?.enabled,i?.enabled,!0),a=C9n(n?.replacements)??"paired",l=e.documentMode==="viewing"?o?"review":"original":"review",c=E9n(n?.mode,i?.mode,l),u={visible:o,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:o},d_(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,z7e,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}en();var DZ=Object.freeze({name:"Default SuperDoc user",email:null}),R9n=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]),E5=class extends v6.default{static allowedTypes=[pc,wT,n1];#e=!1;#t=!1;#i=null;#n=null;#r;version;users;ydoc;provider;whiteboard;colors=[];config={superdocId:null,selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],format:null,editorExtensions:[],colors:[],user:{name:null,email:null},users:[],modules:{},permissionResolver:null,licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbar:null,toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,onFontsResolved:null,onTrackedChangeBubbleAccept:null,onTrackedChangeBubbleReject:null,handleImageUpload:null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0};constructor(e){if(super(),!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o(e,t)}async#o(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),_9n(this.config);const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated");const i=this.config.user;if(!i||typeof i!="object"?this.config.user={...DZ}:(this.config.user={...DZ,...i},this.config.user.name||(this.config.user.name=DZ.name)),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.colors=sYe(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.31.1",this.#A("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||wn(),this.colors=this.config.colors??[],this.#d(),this.#r=new S9n({getModuleConfig:()=>this.config.modules?.surfaces}),await this.#s(this.config.modules),this.#e){this.#v();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null,this.#n=document.createElement("div"),this.#n.style.display="contents",t.appendChild(this.#n),this.#l(),this.#c(),this.#_(),this.#a()}#a(){this.#f(),this.readyEditors=0,this.app.mount(this.#n)}#c(){const e=(this.config.modules?.whiteboard??{}).enabled??!1;this.whiteboard=new XFn({Renderer:v9n,superdoc:this,enabled:e}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(e=>e.type===pc).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(this.config.document)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,i=!!e&&e instanceof Blob&&!(e instanceof File),o=this.config.documents&&this.config.documents?.length;if(t&&o&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}else if(n)this.config.documents=[{id:wn(),type:pc,url:this.config.document,name:"document.docx"}];else if(r){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}else if(i){const s=GC(this.config.document);this.config.documents=[{id:wn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=GC(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||wn()}}))}#f(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:i}=zFn({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#r),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=i,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const o=this.config.modules.comments;this.commentsStore.init(o||{}),this.isCollaborative&&s5(this),this.#E()}#l(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf:document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException),this.on("list-definitions-change",this.config.onListDefinitionsChange),this.on("pagination-update",this.config.onPaginationUpdate),this.config.onFontsResolved&&this.on("fonts-resolved",this.config.onFontsResolved)}async#s({collaboration:e,comments:t={}}={}){if(!e)return this.config.documents;const{ydoc:n,provider:r}=e;if(n&&r)return(!this.config.documents||this.config.documents.length===0)&&(this.config.documents=[{id:wn(),type:pc,name:"document.docx"}]),this.#w(n,r),s5(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Jre({url:e.url}));const i=lOn(this);if(t.useInternalExternalComments&&!t.suppressInternalExternalComments){const{ydoc:o,provider:s}=aOn(this);this.ydoc=Zi(o),this.provider=Zi(s)}else this.ydoc=Zi(i[0].ydoc),this.provider=Zi(i[0].provider);return s5(this),i}#w(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Zi(e),this.provider=Zi(t),this.#x(),this._cleanupAwareness=iOn(t,this,this.config.user),this.config.documents.forEach(n=>{n.ydoc=e,n.provider=t,n.role=this.config.role})}#b(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0,delete this.config.modules.collaboration,this.config.documents.forEach(e=>{delete e.ydoc,delete e.provider})}#x(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:R9n,n=e.email||e.name||"";let r=5381;for(let i=0;i<n.length;i++)r=(r<<5)+r^n.charCodeAt(i);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#C({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#I();await this.#S(t),this.#k(),X3t(n,e),GFn(e,this.commentsStore.commentsList),jFn(e,{isLocked:this.isLocked,lockedBy:this.lockedBy}),this.config.modules.collaboration={ydoc:e,provider:t},this.#w(e,t),this.#T(e,t);const r=this.#m();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(i){throw this.#y(),i}if(await this.#h(r),this.#e)return;s5(this)}finally{this.#i=null,this.#t=!1}}#k(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#T(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const i=di(r);i.ydoc&&typeof i.ydoc=="object"&&"value"in i.ydoc&&(i.ydoc.value=e),i.provider&&typeof i.provider=="object"&&"value"in i.provider&&(i.provider.value=t)}}#m(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getPresentationEditor?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#y(){this.#b(),this.#T(null,null)}#h(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let i=!1;const o=()=>{i||(i=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{o(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{o(),r(void 0)};this.#i=()=>{o(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(o(),r(void 0))})}#S(e){return new Promise((n,r)=>{let i,o=!1,s=()=>{};const a=()=>{o=!0,clearTimeout(i),s()};s=jw(e,()=>{o||(a(),n())}),o||(i=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#i=()=>{o||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#C({ydoc:e,provider:t}){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#t)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");if(!e||!t)throw new Error("SuperDoc: upgradeToCollaboration() requires both ydoc and provider");const n=this.config.documents.filter(r=>r.type===pc);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(this.config.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#I(){const e=this.config.documents.find(n=>n.type===pc),t=this.superdocStore.documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.users.some(t=>t.email===e.email)||this.users.push(e)}removeSharedUser(e){this.users=this.users.filter(t=>t.email!==e)}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.superdocStore.documents.find(i=>i.id===n);this.config.onContentError?.({error:e,editor:t,documentId:r.id,file:r.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:B7e(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:B7e(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#A(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(e=>{e.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:i=null}={}){if(!e)return!1;let o=r??i?.comment??null;const s=i?.commentId||i?.id;if(!o&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s);o=a?.getValues?a.getValues():a}return kb(e,t,n,{superdoc:this,currentUser:this.config.user,comment:o??null,trackedChange:i??null})}#_(){const e=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const t=[...e.excludeItems||[]];(!this.config.rulers||this.config.viewOptions?.layout==="web")&&t.push("ruler"),this.toolbar=new REe({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,icons:this.config.modules?.toolbar?.icons||this.config.toolbarIcons,texts:this.config.modules?.toolbar?.texts||this.config.toolbarTexts,fonts:this.config.modules?.toolbar?.fonts||null,hideButtons:this.config.modules?.toolbar?.hideButtons??!0,responsiveToContainer:this.config.modules?.toolbar?.responsiveToContainer??!1,documentMode:this.config.documentMode,superdoc:this,aiApiKey:this.config.modules?.ai?.apiKey,aiEndpoint:this.config.modules?.ai?.endpoint,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont,...e,excludeItems:t}),this.toolbar.on("exception",this.config.onException),this.once("editorCreate",()=>this.toolbar?.updateToolbarState())}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new Z5n(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),i=n.querySelector(`[data-comment-ids*="${r}"]`);if(!i)return!1;const{behavior:o="smooth",block:s="start"}=t??{};return i.scrollIntoView({behavior:o,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getPresentationEditor?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getPresentationEditor?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const i=n.getEditor?.();i?.setOptions&&i.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowBookmarks?.(t)}))}setDocumentMode(e){if(!e)return;e=e.toLowerCase(),this.config.documentMode=e,this.#E();const t={viewing:()=>this.#P(),editing:()=>this.#R(),suggesting:()=>this.#D()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#g(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#R(){if(this.config.role!=="editor")return this.#D();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#g(e,"editing")})}#D(){if(!["editor","suggester"].includes(this.config.role))return this.#P();if(this.superdocStore.documents.length>0){const e=this.superdocStore.documents[0]?.getEditor();e&&this.setActiveEditor(e)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),this.superdocStore.documents.forEach(e=>{e.restoreComments(),this.#g(e,"suggesting")})}#P(){this.toolbar&&(this.toolbar.activeEditor=null);const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(t?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!e&&!t&&this.commentsStore?.clearEditorCommentPositions?.(),this.superdocStore.documents.forEach(n=>{e||t?n.restoreComments():n.removeComments(),this.#g(n,"viewing")})}#E(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const i=this.superdocStore?.documents;Array.isArray(i)&&i.length>0&&i.forEach(o=>{const s=typeof o.getPresentationEditor=="function"?o.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t){this.isLocked=e,this.lockedBy=t,this.#A("🦋 [superdoc] Locking superdoc:",e,t,`
1111
1111
 
1112
1112
 
1113
1113
  `),this.emit("locked",{isLocked:e,lockedBy:t})}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:i=[],isFinalDoc:o=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=I9e(n||this.config.title),c=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:o,fieldsHighlightColor:a}),u=[...r],d=[...i];if(e.includes("docx")&&c.forEach(h=>{u.push(h),d.push(`${l}.docx`)}),u.length===1)return s?T9e(u[0],l,e[0]):u[0];const f=await BBe(u,d);return s?T9e(f,l,"zip"):f}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){let r;const i=this.config?.modules?.comments!==!1;e==="clean"?r=[]:i&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(r=this.commentsStore.translateCommentsForExport(),Array.isArray(r)||(r=[]));const o=this.superdocStore.documents.map(async s=>{if(!s||s.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const a=typeof s.getEditor=="function"?s.getEditor():null,l=()=>!s.data||s.data.type&&s.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:s.data;if(!a)return l();try{const c=await a.exportDocx({isFinalDoc:t,comments:r,commentsType:e,fieldsHighlightColor:n});if(c)return c}catch(c){this.emit("exception",{error:c,document:s})}return l()});return(await Promise.all(o)).filter(Boolean)}async#L(){return this.#A("🦋 [superdoc] Triggering collaboration saves"),new Promise(e=>{this.superdocStore.documents.forEach((t,n)=>{if(this.#A(`Before reset - Doc ${n}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,t.ydoc){this.pendingCollaborationSaves++,this.#A(`After increment - Doc ${n}: pending = ${this.pendingCollaborationSaves}`);const r=t.ydoc.getMap("meta");r.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&e())}),r.set("immediate-save",!0)}}),this.#A(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${this.superdocStore.documents.filter(t=>t.ydoc).length} docs!`)})}async save(){const e=[this.#L()];this.#A("🦋 [superdoc] Saving superdoc");const t=await Promise.all(e);return this.#A("🦋 [superdoc] Save complete:",t),t}#v(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.config.socket?.cancelWebsocketRetry(),this.config.socket?.disconnect(),this.config.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect(),this.provider?.destroy(),this.config.documents.forEach(e=>{e.provider?.disconnect(),e.provider?.destroy(),e.ydoc?.destroy()})}openSurface(e){return this.#r.open(e)}closeSurface(e){this.#r.close(e)}destroy(){this.#e=!0,this.#i&&(this.#i(),this.#i=null),this.#r&&this.#r.destroy(),this.toolbar?.destroy(),this.app&&(this.#A("[superdoc] Unmounting app"),this.superdocStore.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#v(),this.#n&&(this.#n.remove(),this.#n=null)}focus(){this.activeEditor?this.activeEditor.focus():this.superdocStore.documents.find(e=>{const t=e.getEditor();t&&t.focus()})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore.setHighContrastMode(e))}};const P9n=async(e={})=>{const{editor:t,extensions:n,mode:r="docx"}=e;if(t)return t.getSchemaSummaryJSON();const i=new Fp({extensions:Array.isArray(n)&&n.length?n:r==="docx"?bM():Zy(),mode:r,isHeadless:!0,deferDocumentLoad:!0,telemetry:{enabled:!1}});try{return await i.getSchemaSummaryJSON()}finally{typeof i.destroy=="function"&&i.destroy()}};var L9n={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},N9n=0;function G7e(e){const{name:t,font:n,radius:r,shadow:i,colors:o,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++N9n}`}`,l=[];if(o)for(const[c,u]of Object.entries(o)){if(u==null)continue;const d=L9n[c];d&&l.push(` ${d}: ${u};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),i!=null&&l.push(` --sd-ui-shadow: ${i};`),s)for(const[c,u]of Object.entries(s))u!=null&&l.push(` ${c}: ${u};`);return{className:a,css:l.length>0?`.${a} {