superdoc 1.44.2 → 1.45.0

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.
Files changed (48) hide show
  1. package/dist/chunks/{SuperConverter-CbmLWM1W.cjs → SuperConverter-CMnYbU3R.cjs} +1 -1
  2. package/dist/chunks/{SuperConverter-Dtd-RlxM.es.js → SuperConverter-C_k6Kyxn.es.js} +1 -1
  3. package/dist/chunks/{create-headless-toolbar-CqOmU57t.cjs → create-headless-toolbar-9hSPhUq1.cjs} +1 -1
  4. package/dist/chunks/{create-headless-toolbar-ClF2K2m2.es.js → create-headless-toolbar-Bk1DvH4C.es.js} +1 -1
  5. package/dist/chunks/{create-super-doc-ui-Cs2VRTCD.cjs → create-super-doc-ui-BpcKG5fa.cjs} +2 -2
  6. package/dist/chunks/{create-super-doc-ui-2aN02gOP.es.js → create-super-doc-ui-BsfD9cQX.es.js} +2 -2
  7. package/dist/chunks/{create-theme-BYvD0SO7.es.js → create-theme-C1xpGtGM.es.js} +5 -5
  8. package/dist/chunks/{create-theme-BmDqGmMB.cjs → create-theme-Mny0hKZH.cjs} +5 -5
  9. package/dist/chunks/{react-CEF5oqTF.es.js → react-B-qxNz_q.es.js} +1 -1
  10. package/dist/chunks/{react-CtcF-yLX.cjs → react-BjSvAKbO.cjs} +1 -1
  11. package/dist/chunks/{react-BJpSebYd.cjs → react-CXe4GokS.cjs} +1 -1
  12. package/dist/chunks/{react-Bmh3etk4.es.js → react-Ca51qgvY.es.js} +1 -1
  13. package/dist/chunks/{src-0Osur9Ig.es.js → src-D766riLN.es.js} +5 -5
  14. package/dist/chunks/{src-CjeePlND.cjs → src-DOBbTamm.cjs} +5 -5
  15. package/dist/chunks/{vue-DuPSCC-4.es.js → vue-BUceAXPK.es.js} +1 -1
  16. package/dist/chunks/{vue-D_hZVIYJ.cjs → vue-DzMQmmgo.cjs} +1 -1
  17. package/dist/headless-toolbar-react.cjs +3 -3
  18. package/dist/headless-toolbar-react.es.js +3 -3
  19. package/dist/headless-toolbar-vue.cjs +3 -3
  20. package/dist/headless-toolbar-vue.es.js +3 -3
  21. package/dist/headless-toolbar.cjs +4 -4
  22. package/dist/headless-toolbar.es.js +4 -4
  23. package/dist/public/legacy/converter.cjs +1 -1
  24. package/dist/public/legacy/converter.es.js +1 -1
  25. package/dist/public/legacy/headless-toolbar-react.cjs +3 -3
  26. package/dist/public/legacy/headless-toolbar-react.es.js +3 -3
  27. package/dist/public/legacy/headless-toolbar-vue.cjs +3 -3
  28. package/dist/public/legacy/headless-toolbar-vue.es.js +3 -3
  29. package/dist/public/legacy/headless-toolbar.cjs +4 -4
  30. package/dist/public/legacy/headless-toolbar.es.js +4 -4
  31. package/dist/public/ui-react.cjs +4 -4
  32. package/dist/public/ui-react.es.js +4 -4
  33. package/dist/public/ui.cjs +3 -3
  34. package/dist/public/ui.es.js +3 -3
  35. package/dist/public.cjs +5 -5
  36. package/dist/public.es.js +5 -5
  37. package/dist/super-editor/converter.cjs +1 -1
  38. package/dist/super-editor/converter.es.js +1 -1
  39. package/dist/super-editor.cjs +4 -4
  40. package/dist/super-editor.es.js +4 -4
  41. package/dist/superdoc.cjs +5 -5
  42. package/dist/superdoc.es.js +5 -5
  43. package/dist/superdoc.min.js +5 -5
  44. package/dist/ui-react.cjs +4 -4
  45. package/dist/ui-react.es.js +4 -4
  46. package/dist/ui.cjs +3 -3
  47. package/dist/ui.es.js +3 -3
  48. package/package.json +4 -4
@@ -2,7 +2,7 @@ var SuperDoc=(function(){var unt=Object.create,FP=Object.defineProperty,dnt=Obje
2
2
  `)}},lH=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[yk]?Xce(e,t):eb(e)?U7(e,n=>V7(t,r=>lH(n,r))):Jot(e)?nA(e,(n,r)=>lH(n,t[r])):!1,uc=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),lH(t,n)}equals(e){return this.constructor===e.constructor&&rA(this.shape,e.shape)}[Rit](){return!0}[yk](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ld()}get nullable(){return oA(this,MN)}get optional(){return new due(this)}cast(e){return xue(e,this),e}expect(e){return xue(e,this),e}},cH=class extends uc{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 aa=(e,t=null)=>new cH(e,t),GTr=aa(cH);var uH=class extends uc{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 Va=e=>new uH(e),WTr=aa(uH);var _N=class extends uc{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 RN=(...e)=>new _N(e),cue=aa(_N);var Nit=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),uue=e=>{if(sA.check(e))return[Nit(e)];if(cue.check(e))return e.shape.map(t=>t+"");if(Sue.check(e))return["[+-]?\\d+.?\\d*"];if(Tue.check(e))return[".*"];if(PN.check(e))return e.shape.map(uue).flat(1);lc()},Lit=class extends uc{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(uue).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 jTr=aa(Lit);var Mit=Symbol("optional"),due=class extends uc{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[Mit](){return!0}};const Dit=aa(due);var fue=class extends uc{check(e,t){return t?.extend(null,"never",typeof e),!1}};const qTr=new fue,KTr=aa(fue);var hue=class ltt extends uc{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new ltt(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):nA(this.shape,(r,o)=>{const i=this._isPartial&&!$7(t,o)||r.check(t[o],n);return!i&&n?.extend(o.toString(),r.toString(),typeof t[o],"Object property does not match"),i})}};const Oit=e=>new hue(e),Fit=aa(hue),Bit=Va(e=>e!=null&&(e.constructor===Object||e.constructor==null));var pue=class extends uc{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&nA(e,(n,r)=>{const o=this.shape.keys.check(r,t);return!o&&t?.extend(r+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(n,t)})}};const mue=(e,t)=>new pue(e,t),Hit=aa(pue);var gue=class extends uc{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&nA(this.shape,(n,r)=>{const o=n.check(e[r],t);return!o&&t?.extend(r.toString(),"Tuple",typeof n),o})}};const zit=(...e)=>new gue(e),YTr=aa(gue);var yue=class extends uc{constructor(e){super(),this.shape=e.length===1?e[0]:new dH(e)}check(e,t){const n=eb(e)&&U7(e,r=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}};const bue=(...e)=>new yue(e),Uit=aa(yue),Vit=Va(e=>eb(e));var vue=class extends uc{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 Git=(e,t=null)=>new vue(e,t),XTr=aa(vue),Wit=Git(uc);var jit=class extends uc{constructor(e){super(),this.len=e.length-1,this.args=zit(...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 qit=aa(jit),Kit=Va(e=>typeof e=="function");var Yit=class extends uc{constructor(e){super(),this.shape=e}check(e,t){const n=U7(this.shape,r=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}};const JTr=aa(Yit,e=>e.shape.length>0);var dH=class extends uc{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=V7(this.shape,r=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}};const oA=(...e)=>e.findIndex(t=>PN.check(t))>=0?oA(...e.map(t=>bk(t)).map(t=>PN.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new dH(e),PN=aa(dH);var wue=()=>!0;const NN=Va(wue),Xit=aa(uH,e=>e.shape===wue),fH=Va(e=>typeof e=="bigint"),Jit=Va(e=>e===fH),Aue=Va(e=>typeof e=="symbol"),ZTr=Va(e=>e===Aue),iA=Va(e=>typeof e=="number"),Sue=Va(e=>e===iA),sA=Va(e=>typeof e=="string"),Tue=Va(e=>e===sA),LN=Va(e=>typeof e=="boolean"),Zit=Va(e=>e===LN),Iue=RN(void 0),QTr=aa(_N,e=>e.shape.length===1&&e.shape[0]===void 0),$Tr=RN(void 0),MN=RN(null),Qit=aa(_N,e=>e.shape.length===1&&e.shape[0]===null),eIr=aa(Uint8Array),tIr=aa(cH,e=>e.shape===Uint8Array),$it=oA(iA,sA,MN,Iue,fH,LN,Aue),nIr=(()=>{const e=bue(NN),t=mue(sA,NN),n=oA(iA,sA,MN,LN,e,t);return e.shape=n,t.shape.values=n,n})(),bk=e=>{if(Wit.check(e))return e;if(Bit.check(e)){const t={};for(const n in e)t[n]=bk(e[n]);return Oit(t)}else{if(Vit.check(e))return oA(...e.map(bk));if($it.check(e))return RN(e);if(Kit.check(e))return aa(e)}lc()},xue=ait?()=>{}:(e,t)=>{const n=new Pit;if(!t.check(e,n))throw ah(`Expected value to be of type ${t.constructor.name}.
3
3
  ${n.toString()}`)};var est=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:bk(e),h:t}),this}else(e){return this.if(NN,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 ah("Unhandled pattern")}}},kue=(e=>new est(e))(NN).if(Sue,(e,t)=>iH(t,Dce,vN)).if(Tue,(e,t)=>_it(t)).if(Zit,(e,t)=>aue(t)).if(Jit,(e,t)=>BigInt(iH(t,Dce,vN))).if(PN,(e,t)=>aA(t,aH(t,e.shape))).if(Fit,(e,t)=>{const n={};for(const r in e.shape){let o=e.shape[r];if(Dit.check(o)){if(aue(t))continue;o=o.shape}n[r]=kue(o,t)}return n}).if(Uit,(e,t)=>{const n=[],r=lue(t,0,42);for(let o=0;o<r;o++)n.push(aA(t,e.shape));return n}).if(cue,(e,t)=>aH(t,e.shape)).if(Qit,(e,t)=>null).if(qit,(e,t)=>{const n=aA(t,e.res);return()=>n}).if(Xit,(e,t)=>aA(t,aH(t,[iA,sA,MN,Iue,fH,LN,bue(iA),mue(oA("a","b","c"),iA)]))).if(Hit,(e,t)=>{const n={},r=iH(t,0,3);for(let o=0;o<r;o++){const i=aA(t,e.shape.keys);n[i]=aA(t,e.shape.values)}return n}).done();const aA=(e,t)=>kue(bk(t),e),vg=typeof document<"u"?document:{},oIr=Va(e=>e.nodeType===ist),iIr=typeof DOMParser<"u"?new DOMParser:null,sIr=Va(e=>e.nodeType===nst),aIr=Va(e=>e.nodeType===rst),tst=e=>jot(e,(t,n)=>`${n}:${t};`).join(""),nst=vg.ELEMENT_NODE,rst=vg.TEXT_NODE,lIr=vg.CDATA_SECTION_NODE,cIr=vg.COMMENT_NODE,ost=vg.DOCUMENT_NODE,uIr=vg.DOCUMENT_TYPE_NODE,ist=vg.DOCUMENT_FRAGMENT_NODE,dIr=Va(e=>e.nodeType===ost);var DN=e=>class{constructor(n){this._=n}destroy(){e(this._)}},sst=DN(clearTimeout);const hH=(e,t)=>new sst(setTimeout(t,e));var fIr=DN(clearInterval);const hIr=DN(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var pIr=DN(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));const Vp=Symbol,Cue=Vp(),Eue=Vp(),ast=Vp(),lst=Vp(),cst=Vp(),_ue=Vp(),ust=Vp(),pH=Vp(),dst=Vp(),fst=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let r=0;for(;r<e.length;r++){const o=e[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){const o=e[r];o instanceof Symbol||n.push(o)}return n};var mIr=uf(),hst={[Cue]:Up("font-weight","bold"),[Eue]:Up("font-weight","normal"),[ast]:Up("color","blue"),[cst]:Up("color","green"),[lst]:Up("color","grey"),[_ue]:Up("color","red"),[ust]:Up("color","purple"),[pH]:Up("color","orange"),[dst]:Up("color","black")},pst=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=cc();let o=[],i=0;for(;i<e.length;i++){const s=e[i],a=hst[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=tst(r);i>0||l.length>0?(t.push("%c"+s),n.push(l)):t.push(s)}else break}}for(i>0&&(o=n,o.unshift(t.join("")));i<e.length;i++){const s=e[i];s instanceof Symbol||o.push(s)}return o},Rue=cit?pst:fst;const mst=(...e)=>{console.log(...Rue(e)),Nue.forEach(t=>t.print(e))},Pue=(...e)=>{console.warn(...Rue(e)),e.unshift(pH),Nue.forEach(t=>t.print(e))},Nue=Bp(),Lue=e=>({[Symbol.iterator](){return this},next:e}),gst=(e,t)=>Lue(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),mH=(e,t)=>Lue(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var ON=class{constructor(e,t){this.clock=e,this.len=t}},lA=class{constructor(){this.clients=new Map}},wg=(e,t,n)=>t.clients.forEach((r,o)=>{const i=e.doc.store.clients.get(o);if(i!=null){const s=i[i.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])Que(e,i,c.clock,c.len,n)}}),yst=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const o=ad((n+r)/2),i=e[o],s=i.clock;if(s<=t){if(t<s+i.len)return o;n=o+1}else r=o-1}return null},cA=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&yst(n,t.clock)!==null},gH=e=>{e.clients.forEach(t=>{t.sort((o,i)=>o.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){const o=t[r-1],i=t[n];o.clock+o.len>=i.clock?t[r-1]=new ON(o.clock,cf(o.len,i.clock+i.len-o.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},yH=e=>{const t=new lA;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,o)=>{if(!t.clients.has(o)){const i=r.slice();for(let s=n+1;s<e.length;s++)got(i,e[s].clients.get(o)||[]);t.clients.set(o,i)}});return gH(t),t},vk=(e,t,n,r)=>{cd(e.clients,t,()=>[]).push(new ON(n,r))},bH=()=>new lA,Mue=e=>{const t=bH();return e.clients.forEach((n,r)=>{const o=[];for(let i=0;i<n.length;i++){const s=n[i];if(s.deleted){const a=s.id.clock;let l=s.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])l+=c.length;o.push(new ON(a,l))}}o.length>0&&t.clients.set(r,o)}),t},uA=(e,t)=>{Fn(e.restEncoder,t.clients.size),Hp(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),Fn(e.restEncoder,n);const o=r.length;Fn(e.restEncoder,o);for(let i=0;i<o;i++){const s=r[i];e.writeDsClock(s.clock),e.writeDsLen(s.len)}})},vH=e=>{const t=new lA,n=Fr(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const o=Fr(e.restDecoder),i=Fr(e.restDecoder);if(i>0){const s=cd(t.clients,o,()=>[]);for(let a=0;a<i;a++)s.push(new ON(e.readDsClock(),e.readDsLen()))}}return t},Due=(e,t,n)=>{const r=new lA,o=Fr(e.restDecoder);for(let i=0;i<o;i++){e.resetDsCurVal();const s=Fr(e.restDecoder),a=Fr(e.restDecoder),l=n.clients.get(s)||[],c=Js(n,s);for(let u=0;u<a;u++){const d=e.readDsClock(),f=d+e.readDsLen();if(d<c){c<f&&vk(r,s,c,f-c);let h=df(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,XN(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,XN(t,p,f-p.id.clock)),p.delete(t))}else vk(r,s,d,f-d)}}if(r.clients.size>0){const i=new nb;return Fn(i.restEncoder,0),uA(i,r),i.toUint8Array()}return null},Oue=iue,Gp=class ctt extends oH{constructor({guid:t=kit(),collectionid:n=null,gc:r=!0,gcFilter:o=()=>!0,meta:i=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=o,this.clientID=Oue(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Xue,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=sue(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>sue(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&&Ri(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Hp(this.subdocs).map(t=>t.guid))}transact(t,n=null){return Ri(this,t,n)}get(t,n=Ga){const r=cd(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),o=r.constructor;if(n!==Ga&&o!==n)if(o===Ga){const i=new n;i._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=i}),i._start=r._start;for(let s=i._start;s!==null;s=s.right)s.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}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,MH)}getText(t=""){return this.get(t,Ck)}getMap(t=""){return this.get(t,Sg)}getXmlElement(t=""){return this.get(t,Dl)}getXmlFragment(t=""){return this.get(t,gA)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,Hp(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new ctt({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Ri(t.parent.doc,r=>{const o=n.doc;t.deleted||r.subdocsAdded.add(o),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Fue=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Fr(this.restDecoder)}readDsLen(){return Fr(this.restDecoder)}},Bue=class extends Fue{readLeftID(){return Qr(Fr(this.restDecoder),Fr(this.restDecoder))}readRightID(){return Qr(Fr(this.restDecoder),Fr(this.restDecoder))}readClient(){return Fr(this.restDecoder)}readInfo(){return tA(this.restDecoder)}readString(){return ku(this.restDecoder)}readParentInfo(){return Fr(this.restDecoder)===1}readTypeRef(){return Fr(this.restDecoder)}readLen(){return Fr(this.restDecoder)}readAny(){return gk(this.restDecoder)}readBuf(){return yit(ul(this.restDecoder))}readJSON(){return JSON.parse(ku(this.restDecoder))}readKey(){return ku(this.restDecoder)}},bst=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Fr(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Fr(this.restDecoder)+1;return this.dsCurrVal+=e,e}},dA=class extends bst{constructor(e){super(e),this.keys=[],Fr(e),this.keyClockDecoder=new J7(ul(e)),this.clientDecoder=new xN(ul(e)),this.leftClockDecoder=new J7(ul(e)),this.rightClockDecoder=new J7(ul(e)),this.infoDecoder=new Gce(ul(e),tA),this.stringDecoder=new Hot(ul(e)),this.parentInfoDecoder=new Gce(ul(e),tA),this.typeRefDecoder=new xN(ul(e)),this.lenDecoder=new xN(ul(e))}readLeftID(){return new fA(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new fA(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 gk(this.restDecoder)}readBuf(){return ul(this.restDecoder)}readJSON(){return gk(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}}},Hue=class{constructor(){this.restEncoder=ya()}toUint8Array(){return Gi(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Fn(this.restEncoder,e)}writeDsLen(e){Fn(this.restEncoder,e)}},wk=class extends Hue{writeLeftID(e){Fn(this.restEncoder,e.client),Fn(this.restEncoder,e.clock)}writeRightID(e){Fn(this.restEncoder,e.client),Fn(this.restEncoder,e.clock)}writeClient(e){Fn(this.restEncoder,e)}writeInfo(e){W7(this.restEncoder,e)}writeString(e){Ua(this.restEncoder,e)}writeParentInfo(e){Fn(this.restEncoder,e?1:0)}writeTypeRef(e){Fn(this.restEncoder,e)}writeLen(e){Fn(this.restEncoder,e)}writeAny(e){eA(this.restEncoder,e)}writeBuf(e){ys(this.restEncoder,e)}writeJSON(e){Ua(this.restEncoder,JSON.stringify(e))}writeKey(e){Ua(this.restEncoder,e)}},zue=class{constructor(){this.restEncoder=ya(),this.dsCurrVal=0}toUint8Array(){return Gi(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,Fn(this.restEncoder,t)}writeDsLen(e){e===0&&lc(),Fn(this.restEncoder,e-1),this.dsCurrVal+=e}},nb=class extends zue{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Y7,this.clientEncoder=new SN,this.leftClockEncoder=new Y7,this.rightClockEncoder=new Y7,this.infoEncoder=new Bce(W7),this.stringEncoder=new Mot,this.parentInfoEncoder=new Bce(W7),this.typeRefEncoder=new SN,this.lenEncoder=new SN}toUint8Array(){const e=ya();return Fn(e,0),ys(e,this.keyClockEncoder.toUint8Array()),ys(e,this.clientEncoder.toUint8Array()),ys(e,this.leftClockEncoder.toUint8Array()),ys(e,this.rightClockEncoder.toUint8Array()),ys(e,Gi(this.infoEncoder)),ys(e,this.stringEncoder.toUint8Array()),ys(e,Gi(this.parentInfoEncoder)),ys(e,this.typeRefEncoder.toUint8Array()),ys(e,this.lenEncoder.toUint8Array()),AN(e,Gi(this.restEncoder)),Gi(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){eA(this.restEncoder,e)}writeBuf(e){ys(this.restEncoder,e)}writeJSON(e){eA(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)}},vst=(e,t,n,r)=>{r=cf(r,t[0].id.clock);const o=df(t,r);Fn(e.restEncoder,t.length-o),e.writeClient(n),Fn(e.restEncoder,r);const i=t[o];i.write(e,r-i.id.clock);for(let s=o+1;s<t.length;s++)t[s].write(e,0)},wH=(e,t,n)=>{const r=new Map;n.forEach((o,i)=>{Js(t,i)>o&&r.set(i,o)}),Ik(t).forEach((o,i)=>{n.has(i)||r.set(i,0)}),Fn(e.restEncoder,r.size),Hp(r.entries()).sort((o,i)=>i[0]-o[0]).forEach(([o,i])=>{vst(e,t.clients.get(o),o,i)})},wst=(e,t)=>{const n=cc(),r=Fr(e.restDecoder);for(let o=0;o<r;o++){const i=Fr(e.restDecoder),s=new Array(i),a=e.readClient();let l=Fr(e.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<i;c++){const u=e.readInfo();switch(31&u){case 0:{const d=e.readLen();s[c]=new ud(Qr(a,l),d),l+=d;break}case 10:{const d=Fr(e.restDecoder);s[c]=new dd(Qr(a,l),d),l+=d;break}default:{const d=(u&192)===0,f=new Wi(Qr(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,Rde(e,u));s[c]=f,l+=f.length}}}}return n},Ast=(e,t,n)=>{const r=[];let o=Hp(n.keys()).sort((h,p)=>h-p);if(o.length===0)return null;const i=()=>{if(o.length===0)return null;let h=n.get(o[o.length-1]);for(;h.refs.length===h.i;)if(o.pop(),o.length>0)h=n.get(o[o.length-1]);else return null;return h};let s=i();if(s===null)return null;const a=new Xue,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]),o=o.filter(g=>g!==p)}r.length=0};for(;;){if(u.constructor!==dd){const h=cd(d,u.id.client,()=>Js(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,Js(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=i(),s===null)break;u=s.refs[s.i++]}}if(a.clients.size>0){const h=new nb;return wH(h,a,new Map),Fn(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},Sst=(e,t)=>wH(e,t.doc.store,t.beforeState),Tst=(e,t,n,r=new dA(e))=>Ri(t,o=>{o.local=!1;let i=!1;const s=o.doc,a=s.store,l=Ast(o,a,wst(r,s)),c=a.pendingStructs;if(c){for(const[d,f]of c.missing)if(f<Js(a,d)){i=!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=zN([c.update,l.update])}}else a.pendingStructs=l;const u=Due(r,o,a);if(a.pendingDs){const d=new dA(zp(a.pendingDs));Fr(d.restDecoder);const f=Due(d,o,a);u&&f?a.pendingDs=zN([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,FN(o.doc,d)}},n,!1),FN=(e,t,n,r=dA)=>{const o=zp(t);Tst(o,e,n,new r(o))},Uue=(e,t,n)=>FN(e,t,n,Bue),Ist=(e,t,n=new Map)=>{wH(e,t.store,n),uA(e,Mue(t.store))},xst=(e,t=new Uint8Array([0]),n=new nb)=>{Ist(n,e,Vue(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Wst(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===wk)return Vst(r.map((o,i)=>i===0?o:qst(o)));if(n.constructor===nb)return zN(r)}return r[0]},AH=(e,t)=>xst(e,t,new wk),kst=e=>{const t=new Map,n=Fr(e.restDecoder);for(let r=0;r<n;r++){const o=Fr(e.restDecoder),i=Fr(e.restDecoder);t.set(o,i)}return t},Vue=e=>kst(new Fue(zp(e))),Gue=(e,t)=>(Fn(e.restEncoder,t.size),Hp(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Fn(e.restEncoder,n),Fn(e.restEncoder,r)}),e),Cst=(e,t)=>Gue(e,Ik(t.store)),Est=(e,t=new zue)=>(e instanceof Map?Gue(t,e):Cst(t,e),t.toUint8Array()),_st=e=>Est(e,new Hue),Rst=class{constructor(){this.l=[]}},Wue=()=>new Rst,jue=(e,t)=>e.l.push(t),que=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter(o=>t!==o),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Kue=(e,t,n)=>eH(e.l,[t,n]),fA=class{constructor(e,t){this.client=e,this.clock=t}},hA=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Qr=(e,t)=>new fA(e,t),Ak=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw lc()},Sk=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Tk=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},rb=e=>new Tk(e.type==null?null:Qr(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Qr(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Pst=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Nst=(e,t,n=0)=>new Pst(e,t,n),BN=(e,t,n)=>{let r=null,o=null;return e._item===null?o=Ak(e):r=Qr(e._item.id.client,e._item.id.clock),new Tk(r,o,t,n)},SH=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return BN(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return BN(e,Qr(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return BN(e,r.lastId,n);r=r.right}return BN(e,null,n)},Lst=(e,t)=>{const n=pA(e,t);return{item:n,diff:t.clock-n.id.clock}},Mst=(e,t,n=!0)=>{const r=t.store,o=e.item,i=e.type,s=e.tname,a=e.assoc;let l=null,c=0;if(o!==null){if(Js(r,o.client)<=o.clock)return null;const u=n?UH(r,o):Lst(r,o),d=u.item;if(!(d instanceof Wi))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(i!==null){if(Js(r,i.client)<=i.clock)return null;const{item:u}=n?UH(r,i):{item:pA(r,i)};if(u instanceof Wi&&u.content instanceof Wp)l=u.content.type;else return null}else throw lc();a>=0?c=l._length:c=0}return Nst(l,c,e.assoc)},Yue=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&hA(e.item,t.item)&&hA(e.type,t.type)&&e.assoc===t.assoc,TH=class{constructor(e,t){this.ds=e,this.sv=t}},IH=(e,t)=>new TH(e,t),gIr=IH(bH(),new Map),xH=e=>IH(Mue(e.store),Ik(e.store)),ob=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!cA(t.ds,e.id),kH=(e,t)=>{const n=cd(e.meta,kH,Bp),r=e.doc.store;n.has(t)||(t.sv.forEach((o,i)=>{o<Js(r,i)&&qc(e,Qr(i,o))}),wg(e,t.ds,o=>{}),n.add(t))},Xue=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ik=e=>{const t=new Map;return e.clients.forEach((n,r)=>{const o=n[n.length-1];t.set(r,o.id.clock+o.length)}),t},Js=(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},Jue=(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 lc()}n.push(t)},df=(e,t)=>{let n=0,r=e.length-1,o=e[r],i=o.id.clock;if(i===t)return r;let s=ad(t/(i+o.length-1)*r);for(;n<=r;){if(o=e[s],i=o.id.clock,i<=t){if(t<i+o.length)return s;n=s+1}else r=s-1;s=ad((n+r)/2)}throw lc()},Dst=(e,t)=>{const n=e.clients.get(t.client);return n[df(n,t.clock)]},pA=Dst,CH=(e,t,n)=>{const r=df(t,n),o=t[r];return o.id.clock<n&&o instanceof Wi?(t.splice(r+1,0,XN(e,o,n-o.id.clock)),r+1):r},qc=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[CH(e,n,t.clock)]},Zue=(e,t,n)=>{const r=t.clients.get(n.client),o=df(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==ud&&r.splice(o+1,0,XN(e,i,n.clock-i.id.clock+1)),i},Ost=(e,t,n)=>{const r=e.clients.get(t.id.client);r[df(r,t.id.clock)]=n},Que=(e,t,n,r,o)=>{if(r===0)return;const i=n+r;let s=CH(e,t,n),a;do a=t[s++],i<a.id.clock+a.length&&CH(e,t,i),o(a);while(s<t.length&&t[s].id.clock<i)},Fst=class{constructor(e,t,n){this.doc=e,this.deleteSet=new lA,this.beforeState=Ik(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}},$ue=(e,t)=>t.deleteSet.clients.size===0&&!qot(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(gH(t.deleteSet),Sst(e,t),uA(e,t.deleteSet),!0),ede=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&cd(e.changed,t,Bp).add(n)},HN=(e,t)=>{let n=e[t],r=e[t-1],o=t;for(;o>0;n=r,r=e[--o-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Wi&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=t-o;return i&&e.splice(t+1-i,i),i},Bst=(e,t,n)=>{for(const[r,o]of e.clients.entries()){const i=t.clients.get(r);for(let s=o.length-1;s>=0;s--){const a=o[s],l=a.clock+a.len;for(let c=df(i,a.clock),u=i[c];c<i.length&&u.id.clock<l;u=i[++c]){const d=i[c];if(a.clock+a.len<=d.id.clock)break;d instanceof Wi&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},Hst=(e,t)=>{e.clients.forEach((n,r)=>{const o=t.clients.get(r);for(let i=n.length-1;i>=0;i--){const s=n[i],a=sh(o.length-1,1+df(o,s.clock+s.len-1));for(let l=a,c=o[l];l>0&&c.id.clock>=s.clock;c=o[l])l-=1+HN(o,l)}})},tde=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{gH(i),n.afterState=Ik(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(()=>{Kue(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&sat(n)})}),eH(a,[])}finally{r.gc&&Bst(i,o,r.gcFilter),Hst(i,o),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=o.clients.get(d),p=cf(df(h,f),1);for(let m=h.length-1;m>=p;)m-=1+HN(h,m)}});for(let u=s.length-1;u>=0;u--){const{client:d,clock:f}=s[u].id,h=o.clients.get(d),p=df(h,f);p+1<h.length&&HN(h,p+1)>1||p>0&&HN(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(mst(pH,Cue,"[yjs] ",Eue,_ue,"Changed the client-id because another client seems to be using it."),r.clientID=Oue()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new wk;$ue(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new nb;$ue(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])):tde(e,t+1)}}},Ri=(e,t,n=null,r=!0)=>{const o=e._transactionCleanups;let i=!1,s=null;e._transaction===null&&(i=!0,e._transaction=new Fst(e,n,r),o.push(e._transaction),o.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(i){const a=e._transaction===o[0];e._transaction=null,a&&tde(o,0)}}return s},zst=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},nde=(e,t,n)=>{wg(e,n.deletions,r=>{r instanceof Wi&&t.scope.some(o=>o===e.doc||Sk(o,r))&&VH(r,!1)})},rde=(e,t,n)=>{let r=null;const o=e.doc,i=e.scope;Ri(o,a=>{for(;t.length>0&&e.currStackItem===null;){const l=o.store,c=t.pop(),u=new Set,d=[];let f=!1;wg(a,c.insertions,h=>{if(h instanceof Wi){if(h.redone!==null){let{item:p,diff:m}=UH(l,h.id);m>0&&(p=qc(a,Qr(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>p===a.doc||Sk(p,h))&&d.push(h)}}),wg(a,c.deletions,h=>{h instanceof Wi&&i.some(p=>p===a.doc||Sk(p,h))&&!cA(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=_de(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},ode=class extends oH{constructor(e,{captureTimeout:t=500,captureTransaction:n=a=>!0,deleteFilter:r=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:s=eb(e)?e[0].doc:e instanceof Gp?e:e.doc}={}){super(),this.scope=[],this.doc=s,this.addToScope(e),this.deleteFilter=r,o.add(this),this.trackedOrigins=o,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,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 lA;a.afterState.forEach((m,g)=>{const y=a.beforeState.get(g)||0,b=m-y;b>0&&vk(d,g,y,b)});const f=uf();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=yH([m.deletions,a.deleteSet]),m.insertions=yH([m.insertions,d])}else u.push(new zst(a.deleteSet,d)),h=!0;!l&&!c&&(this.lastChange=f),wg(a,a.deleteSet,m=>{m instanceof Wi&&this.scope.some(g=>g===a.doc||Sk(g,m))&&VH(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=eb(e)?e:[e],e.forEach(n=>{t.has(n)||(t.add(n),(n instanceof Ga?n.doc!==this.doc:n!==this.doc)&&Pue("[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=>nde(n,this,r)),this.undoStack=[]),t&&(this.redoStack.forEach(r=>nde(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=rde(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=rde(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*Ust(e){const t=Fr(e.restDecoder);for(let n=0;n<t;n++){const r=Fr(e.restDecoder),o=e.readClient();let i=Fr(e.restDecoder);for(let s=0;s<r;s++){const a=e.readInfo();if(a===10){const l=Fr(e.restDecoder);yield new dd(Qr(o,i),l),i+=l}else if((31&a)!==0){const l=(a&192)===0,c=new Wi(Qr(o,i),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,Rde(e,a));yield c,i+=c.length}else{const l=e.readLen();yield new ud(Qr(o,i),l),i+=l}}}}var EH=class{constructor(e,t){this.gen=Ust(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===dd);return this.curr}},_H=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Vst=e=>zN(e,Bue,wk),Gst=(e,t)=>{if(e.constructor===ud){const{client:n,clock:r}=e.id;return new ud(Qr(n,r+t),e.length-t)}else if(e.constructor===dd){const{client:n,clock:r}=e.id;return new dd(Qr(n,r+t),e.length-t)}else{const n=e,{client:r,clock:o}=n.id;return new Wi(Qr(r,o+t),null,Qr(r,o+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},zN=(e,t=dA,n=nb)=>{if(e.length===1)return e[0];const r=e.map(l=>new t(zp(l)));let o=r.map(l=>new EH(l,!0)),i=null;const s=new n,a=new _H(s);for(;o=o.filter(u=>u.curr!==null),o.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===dd?1:-1:f}else return d.curr.id.client-u.curr.id.client}),o.length!==0;){const l=o[0],c=l.curr.id.client;if(i!==null){let u=l.curr,d=!1;for(;u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client;)u=l.next(),d=!0;if(u===null||u.id.client!==c||d&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(c!==i.struct.id.client)Ag(a,i.struct,i.offset),i={struct:u,offset:0},l.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===dd)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{Ag(a,i.struct,i.offset);const f=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new dd(Qr(c,i.struct.id.clock+i.struct.length),f),offset:0}}else{const f=i.struct.id.clock+i.struct.length-u.id.clock;f>0&&(i.struct.constructor===dd?i.struct.length-=f:u=Gst(u,f)),i.struct.mergeWith(u)||(Ag(a,i.struct,i.offset),i={struct:u,offset:0},l.next())}}else i={struct:l.curr,offset:0},l.next();for(let u=l.curr;u!==null&&u.id.client===c&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==dd;u=l.next())Ag(a,i.struct,i.offset),i={struct:u,offset:0}}return i!==null&&(Ag(a,i.struct,i.offset),i=null),RH(a),uA(s,yH(r.map(l=>vH(l)))),s.toUint8Array()},Wst=(e,t,n=dA,r=nb)=>{const o=Vue(t),i=new r,s=new _H(i),a=new n(zp(e)),l=new EH(a,!1);for(;l.curr;){const c=l.curr,u=c.id.client,d=o.get(u)||0;if(l.curr.constructor===dd){l.next();continue}if(c.id.clock+c.length>d)for(Ag(s,c,cf(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)Ag(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 RH(s),uA(i,vH(a)),i.toUint8Array()},ide=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Gi(e.encoder.restEncoder)}),e.encoder.restEncoder=ya(),e.written=0)},Ag=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&ide(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Fn(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},RH=e=>{ide(e);const t=e.encoder.restEncoder;Fn(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];Fn(t,r.written),AN(t,r.restEncoder)}},jst=(e,t,n,r)=>{const o=new n(zp(e)),i=new EH(o,!1),s=new r,a=new _H(s);for(let l=i.curr;l!==null;l=i.next())Ag(a,t(l),0);return RH(a),uA(s,vH(o)),s.toUint8Array()},qst=e=>jst(e,rit,dA,wk),sde="You must not compute changes after the event-handler fired.",UN=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=Kst(this.currentTarget,this.target))}deletes(e){return cA(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ah(sde);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const r=t._map.get(n);let o,i;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))o="delete",i=z7(s.content.getContent());else return;else s!==null&&this.deletes(s)?(o="update",i=z7(s.content.getContent())):(o="add",i=void 0)}else if(this.deletes(r))o="delete",i=z7(r.content.getContent());else return;e.set(n,{action:o,oldValue:i})}}),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 ah(sde);const t=this.target,n=Bp(),r=Bp(),o=[];if(e={added:n,deleted:r,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null;const s=()=>{i&&o.push(i)};for(let a=t._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((i===null||i.delete===void 0)&&(s(),i={delete:0}),i.delete+=a.length,r.add(a)):this.adds(a)?((i===null||i.insert===void 0)&&(s(),i={insert:[]}),i.insert=i.insert.concat(a.content.getContent()),n.add(a)):((i===null||i.retain===void 0)&&(s(),i={retain:0}),i.retain+=a.length);i!==null&&i.retain===void 0&&s()}this._changes=e}return e}},Kst=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,o=t._item.parent._start;for(;o!==t._item&&o!==null;)!o.deleted&&o.countable&&(r+=o.length),o=o.right;n.unshift(r)}t=t._item.parent}return n},Ml=()=>{Pue("Invalid access: Add Yjs type to a document before reading data.")},ade=80,PH=0,Yst=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=PH++}},Xst=e=>{e.timestamp=PH++},lde=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=PH++},Jst=(e,t,n)=>{if(e.length>=ade){const r=e.reduce((o,i)=>o.timestamp<i.timestamp?o:i);return lde(r,t,n),r}else{const r=new Yst(t,n);return e.push(r),r}},VN=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,s)=>bN(t-i.index)<bN(t-s.index)?i:s);let r=e._start,o=0;for(n!==null&&(r=n.p,o=n.index,Xst(n));r.right!==null&&o<t;){if(!r.deleted&&r.countable){if(t<o+r.length)break;o+=r.length}r=r.right}for(;r.left!==null&&o>t;)r=r.left,!r.deleted&&r.countable&&(o-=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&&(o-=r.length);return n!==null&&bN(n.index-o)<r.parent.length/ade?(lde(n,r,o),n):Jst(e._searchMarker,r,o)},xk=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(n>0){let i=o.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(o.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}o.p=i,i.marker=!0}(t<o.index||n>0&&t===o.index)&&(o.index=cf(t,o.index+n))}},GN=(e,t,n)=>{const r=e,o=t.changedParentTypes;for(;cd(o,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Kue(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=Wue(),this._dEH=Wue(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw ld()}clone(){throw ld()}_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){jue(this._eH,e)}observeDeep(e){jue(this._dEH,e)}unobserve(e){que(this._eH,e)}unobserveDeep(e){que(this._dEH,e)}toJSON(){}},cde=(e,t,n)=>{e.doc??Ml(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const o=[];let i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const s=i.content.getContent();if(s.length<=t)t-=s.length;else{for(let a=t;a<s.length&&r>0;a++)o.push(s[a]),r--;t=0}}i=i.right}return o},ude=e=>{e.doc??Ml();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let o=0;o<r.length;o++)t.push(r[o])}n=n.right}return t},dde=(e,t)=>{const n=[];let r=e._start;for(;r!==null;){if(r.countable&&ob(r,t)){const o=r.content.getContent();for(let i=0;i<o.length;i++)n.push(o[i])}r=r.right}return n},kk=(e,t)=>{let n=0,r=e._start;for(e.doc??Ml();r!==null;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let i=0;i<o.length;i++)t(o[i],n++,e)}r=r.right}},fde=(e,t)=>{const n=[];return kk(e,(r,o)=>{n.push(t(r,o,e))}),n},Zst=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 o=n[r++];return n.length<=r&&(n=null),{done:!1,value:o}}}},hde=(e,t)=>{e.doc??Ml();const n=VN(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}},WN=(e,t,n,r)=>{let o=n;const i=e.doc,s=i.clientID,a=i.store,l=n===null?t._start:n.right;let c=[];const u=()=>{c.length>0&&(o=new Wi(Qr(s,Js(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new YN(c)),o.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:o=new Wi(Qr(s,Js(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new HH(new Uint8Array(d))),o.integrate(e,0);break;case Gp:o=new Wi(Qr(s,Js(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new zH(d)),o.integrate(e,0);break;default:if(d instanceof Ga)o=new Wi(Qr(s,Js(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new Wp(d)),o.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},pde=()=>ah("Length exceeded!"),mde=(e,t,n,r)=>{if(n>t._length)throw pde();if(n===0)return t._searchMarker&&xk(t._searchMarker,n,r.length),WN(e,t,null,r);const o=n,i=VN(t,n);let s=t._start;for(i!==null&&(s=i.p,n-=i.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&&qc(e,Qr(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&xk(t._searchMarker,o,r.length),WN(e,t,s,r)},Qst=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return WN(e,t,r,n)},gde=(e,t,n,r)=>{if(r===0)return;const o=n,i=r,s=VN(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&&qc(e,Qr(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&qc(e,Qr(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw pde();t._searchMarker&&xk(t._searchMarker,o,-i+r)},jN=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},NH=(e,t,n,r)=>{const o=t._map.get(n)||null,i=e.doc,s=i.clientID;let a;if(r==null)a=new YN([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new YN([r]);break;case Uint8Array:a=new HH(r);break;case Gp:a=new zH(r);break;default:if(r instanceof Ga)a=new Wp(r);else throw new Error("Unexpected content type")}new Wi(Qr(s,Js(i.store,s)),o,o&&o.lastId,null,null,t,n,a).integrate(e,0)},LH=(e,t)=>{e.doc??Ml();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},yde=e=>{const t={};return e.doc??Ml(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},bde=(e,t)=>{e.doc??Ml();const n=e._map.get(t);return n!==void 0&&!n.deleted},$st=(e,t)=>{const n={};return e._map.forEach((r,o)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ob(i,t)&&(n[o]=i.content.getContent()[i.length-1])}),n},qN=e=>(e.doc??Ml(),gst(e._map.entries(),t=>!t[1].deleted)),eat=class extends UN{},MH=class t4 extends Ga{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new t4;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t4}clone(){const t=new t4;return t.insert(0,this.toArray().map(n=>n instanceof Ga?n.clone():n)),t}get length(){return this.doc??Ml(),this._length}_callObserver(t,n){super._callObserver(t,n),GN(this,t,new eat(this,t))}insert(t,n){this.doc!==null?Ri(this.doc,r=>{mde(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?Ri(this.doc,n=>{Qst(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{gde(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return hde(this,t)}toArray(){return ude(this)}slice(t=0,n=this.length){return cde(this,t,n)}toJSON(){return this.map(t=>t instanceof Ga?t.toJSON():t)}map(t){return fde(this,t)}forEach(t){kk(this,t)}[Symbol.iterator](){return Zst(this)}_write(t){t.writeTypeRef(Cat)}},tat=e=>new MH,nat=class extends UN{constructor(e,t,n){super(e,t),this.keysChanged=n}},Sg=class Rse 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,o)=>{this.set(o,r)}),this._prelimContent=null}_copy(){return new Rse}clone(){const t=new Rse;return this.forEach((n,r)=>{t.set(r,n instanceof Ga?n.clone():n)}),t}_callObserver(t,n){GN(this,t,new nat(this,t,n))}toJSON(){this.doc??Ml();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];t[r]=o instanceof Ga?o.toJSON():o}}),t}get size(){return[...qN(this)].length}keys(){return mH(qN(this),t=>t[0])}values(){return mH(qN(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return mH(qN(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??Ml(),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?Ri(this.doc,n=>{jN(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?Ri(this.doc,r=>{NH(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return LH(this,t)}has(t){return bde(this,t)}clear(){this.doc!==null?Ri(this.doc,t=>{this.forEach(function(n,r,o){jN(t,o,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Eat)}},rat=e=>new Sg,Tg=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&tit(e,t),DH=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){this.right===null&&lc(),this.right.content.constructor===Wa?this.right.deleted||mA(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},vde=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===Wa?t.right.deleted||mA(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&qc(e,Qr(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},KN=(e,t,n,r)=>{const o=new Map,i=r?VN(t,n):null;return i?vde(e,new DH(i.p.left,i.p,i.index,o),n-i.index):vde(e,new DH(null,t._start,0,o),n)},wde=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Wa&&Tg(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=e.doc,i=o.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,u=new Wi(Qr(i,Js(o.store,i)),l,l&&l.lastId,c,c&&c.id,t,null,new Wa(a,s));u.integrate(e,0),n.right=u,n.forward()})},mA=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ade=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===Wa&&Tg(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Sde=(e,t,n,r)=>{const o=e.doc,i=o.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!Tg(c,l)){s.set(a,c);const{left:u,right:d}=n;n.right=new Wi(Qr(i,Js(o.store,i)),u,u&&u.lastId,d,d&&d.id,t,null,new Wa(a,l)),n.right.integrate(e,0),n.forward()}}return s},OH=(e,t,n,r,o)=>{n.currentAttributes.forEach((f,h)=>{o[h]===void 0&&(o[h]=null)});const i=e.doc,s=i.clientID;Ade(n,o);const a=Sde(e,t,n,o),l=r.constructor===String?new Ig(r):r instanceof Ga?new Wp(r):new Ek(r);let{left:c,right:u,index:d}=n;t._searchMarker&&xk(t._searchMarker,n.index,l.getLength()),u=new Wi(Qr(s,Js(i.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(),wde(e,t,n,a)},Tde=(e,t,n,r,o)=>{const i=e.doc,s=i.clientID;Ade(n,o);const a=Sde(e,t,n,o);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Wa));){if(!n.right.deleted)switch(n.right.content.constructor){case Wa:{const{key:l,value:c}=n.right.content,u=o[l];if(u!==void 0){if(Tg(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&&qc(e,Qr(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 Wi(Qr(s,Js(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Ig(l)),n.right.integrate(e,0),n.forward()}wde(e,t,n,a)},Ide=(e,t,n,r,o)=>{let i=t;const s=cc();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Wa){const c=i.content;s.set(c.key,c)}i=i.right}let a=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){const c=t.content;if(c.constructor===Wa){const{key:u,value:d}=c,f=r.get(u)??null;(s.get(u)!==c||f===d)&&(t.delete(e),a++,!l&&(o.get(u)??null)===d&&f!==d&&(f===null?o.delete(u):o.set(u,f))),!l&&!t.deleted&&mA(o,c)}}t=t.right}return a},oat=(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===Wa){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},iat=e=>{let t=0;return Ri(e.doc,n=>{let r=e._start,o=e._start,i=cc();const s=Z7(i);for(;o;)o.deleted===!1&&(o.content.constructor===Wa?mA(s,o.content):(t+=Ide(n,r,o,i,s),i=Z7(s),r=o)),o=o.right}),t},sat=e=>{const t=new Set,n=e.doc;for(const[r,o]of e.afterState.entries()){const i=e.beforeState.get(r)||0;o!==i&&Que(e,n.store.clients.get(r),i,o,s=>{!s.deleted&&s.content.constructor===Wa&&s.constructor!==ud&&t.add(s.parent)})}Ri(n,r=>{wg(e,e.deleteSet,o=>{if(o instanceof ud||!o.parent._hasFormatting||t.has(o.parent))return;const i=o.parent;o.content.constructor===Wa?t.add(i):oat(r,o)});for(const o of t)iat(o)})},xde=(e,t,n)=>{const r=n,o=Z7(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Wp:case Ek:case Ig:n<t.right.length&&qc(e,Qr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Ide(e,i,t.right,o,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&xk(s._searchMarker,t.index,-r+n),t},aat=class extends UN{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=[];Ri(e,n=>{const r=new Map,o=new Map;let i=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},eit(a)||(f.attributes=Zot({},a))),c=0;break}f&&t.push(f),s=null}};for(;i!==null;){switch(i.content.constructor){case Wp:case Ek:this.adds(i)?this.deletes(i)||(d(),s="insert",l=i.content.getContent()[0],d()):this.deletes(i)?(s!=="delete"&&(d(),s="delete"),u+=1):i.deleted||(s!=="retain"&&(d(),s="retain"),c+=1);break;case Ig:this.adds(i)?this.deletes(i)||(s!=="insert"&&(d(),s="insert"),l+=i.content.str):this.deletes(i)?(s!=="delete"&&(d(),s="delete"),u+=i.length):i.deleted||(s!=="retain"&&(d(),s="retain"),c+=i.length);break;case Wa:{const{key:f,value:h}=i.content;if(this.adds(i))this.deletes(i)||(Tg(r.get(f)??null,h)?h!==null&&i.delete(n):(s==="retain"&&d(),Tg(h,o.get(f)??null)?delete a[f]:a[f]=h));else if(this.deletes(i)){o.set(f,h);const p=r.get(f)??null;Tg(p,h)||(s==="retain"&&d(),a[f]=p)}else if(!i.deleted){o.set(f,h);const p=a[f];p!==void 0&&(Tg(p,h)?p!==null&&i.delete(n):(s==="retain"&&d(),h===null?delete a[f]:a[f]=h))}i.deleted||(s==="insert"&&d(),mA(r,i.content));break}}i=i.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}},Ck=class Pse extends Ga{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ml(),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 Pse}clone(){const t=new Pse;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new aat(this,t,n);GN(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??Ml();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ig&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?Ri(this.doc,r=>{const o=new DH(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const s=t[i];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&i===t.length-1&&o.right===null&&s.insert.slice(-1)===`
5
- `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&OH(r,this,o,a,s.attributes||{})}else s.retain!==void 0?Tde(r,this,o,s.retain,s.attributes||{}):s.delete!==void 0&&xde(r,o,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??Ml();const o=[],i=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;i.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),o.push(h),a=""}}const u=()=>{for(;l!==null;){if(ob(l,t)||n!==void 0&&ob(l,n))switch(l.content.constructor){case Ig:{const d=i.get("ychange");t!==void 0&&!ob(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ob(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),a+=l.content.str;break}case Wp:case Ek:{c();const d={insert:l.content.getContent()[0]};if(i.size>0){const f={};d.attributes=f,i.forEach((h,p)=>{f[p]=h})}o.push(d);break}case Wa:ob(l,t)&&(c(),mA(i,l.content));break}l=l.right}c()};return t||n?Ri(s,d=>{t&&kH(d,t),n&&kH(d,n),u()},"cleanup"):u(),o}insert(t,n,r){if(n.length<=0)return;const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),OH(i,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!r);OH(i,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?Ri(r,o=>{xde(o,KN(o,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!1);s.right!==null&&Tde(i,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{jN(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{NH(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return LH(this,t)}getAttributes(){return yde(this)}_write(t){t.writeTypeRef(_at)}},lat=e=>new Ck,FH=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ml()}[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===Dl||t.constructor===gA)&&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})}},gA=class Nse 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 Nse}clone(){const t=new Nse;return t.insert(0,this.toArray().map(n=>n instanceof Ga?n.clone():n)),t}get length(){return this.doc??Ml(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new FH(this,t)}querySelector(t){t=t.toUpperCase();const n=new FH(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),Hp(new FH(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){GN(this,t,new dat(this,n,t))}toString(){return fde(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const o=t.createDocumentFragment();return r!==void 0&&r._createAssociation(o,this),kk(this,i=>{o.insertBefore(i.toDOM(t,n,r),null)}),o}insert(t,n){this.doc!==null?Ri(this.doc,r=>{mde(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)Ri(this.doc,r=>{const o=t&&t instanceof Ga?t._item:t;WN(r,this,o,n)});else{const r=this._prelimContent,o=t===null?0:r.findIndex(i=>i===t)+1;if(o===0&&t!==null)throw ah("Reference item not found");r.splice(o,0,...n)}}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{gde(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return ude(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return hde(this,t)}slice(t=0,n=this.length){return cde(this,t,n)}forEach(t){kk(this,t)}_write(t){t.writeTypeRef(Pat)}},cat=e=>new gA,Dl=class Lse extends gA{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,o)=>{this.setAttribute(o,r)}),this._prelimAttrs=null}_copy(){return new Lse(this.nodeName)}clone(){const t=new Lse(this.nodeName),n=this.getAttributes();return Qot(n,(r,o)=>{t.setAttribute(o,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 o=r.length;for(let s=0;s<o;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const i=this.nodeName.toLocaleLowerCase();return`<${i}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{jN(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{NH(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return LH(this,t)}hasAttribute(t){return bde(this,t)}getAttributes(t){return t?$st(this,t):yde(this)}toDOM(t=document,n={},r){const o=t.createElement(this.nodeName),i=this.getAttributes();for(const s in i){const a=i[s];typeof a=="string"&&o.setAttribute(s,a)}return kk(this,s=>{o.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(Rat),t.writeKey(this.nodeName)}},uat=e=>new Dl(e.readKey()),dat=class extends UN{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)})}},fat=class Mse extends Sg{constructor(t){super(),this.hookName=t}_copy(){return new Mse(this.hookName)}clone(){const t=new Mse(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const o=n[this.hookName];let i;return o!==void 0?i=o.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(Nat),t.writeKey(this.hookName)}},hat=e=>new fat(e.readKey()),ff=class Dse extends Ck{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 Dse}clone(){const t=new Dse;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const o=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(o,this),o}toString(){return this.toDelta().map(t=>{const n=[];for(const o in t.attributes){const i=[];for(const s in t.attributes[o])i.push({key:s,value:t.attributes[o][s]});i.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:o,attrs:i})}n.sort((o,i)=>o.nodeName<i.nodeName?-1:1);let r="";for(let o=0;o<n.length;o++){const i=n[o];r+=`<${i.nodeName}`;for(let s=0;s<i.attrs.length;s++){const a=i.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let o=n.length-1;o>=0;o--)r+=`</${n[o].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Lat)}},pat=e=>new ff,BH=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ld()}mergeWith(e){return!1}write(e,t,n){throw ld()}integrate(e,t){throw ld()}},mat=0,ud=class extends BH{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),Jue(e.doc.store,this)}write(e,t){e.writeInfo(mat),e.writeLen(this.length-t)}getMissing(e,t){return null}},HH=class utt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new utt(this.content)}splice(t){throw ld()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},gat=e=>new HH(e.readBuf()),kde=class Ose{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ose(this.len)}splice(t){const n=new Ose(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){vk(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}},yat=e=>new kde(e.readLen()),Cde=(e,t)=>new Gp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),zH=class dtt{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 dtt(Cde(this.doc.guid,this.opts))}splice(t){throw ld()}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}},bat=e=>new zH(Cde(e.readString(),e.readAny())),Ek=class ftt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ftt(this.embed)}splice(t){throw ld()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},vat=e=>new Ek(e.readJSON()),Wa=class htt{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new htt(this.key,this.value)}splice(t){throw ld()}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}},wat=e=>new Wa(e.readKey(),e.readJSON()),Aat=class Fse{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Fse(this.arr)}splice(t){const n=new Fse(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 o=n;o<r;o++){const i=this.arr[o];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},Sat=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const o=e.readString();o==="undefined"?n.push(void 0):n.push(JSON.parse(o))}return new Aat(n)},Tat=EN("node_env")==="development",YN=class Bse{constructor(t){this.arr=t,Tat&&Zce(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Bse(this.arr)}splice(t){const n=new Bse(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 o=n;o<r;o++){const i=this.arr[o];t.writeAny(i)}}getRef(){return 8}},Iat=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new YN(n)},Ig=class Hse{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Hse(this.str)}splice(t){const n=new Hse(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}},xat=e=>new Ig(e.readString()),kat=[tat,rat,lat,uat,cat,hat,pat],Cat=0,Eat=1,_at=2,Rat=3,Pat=4,Nat=5,Lat=6,Wp=class ptt{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ptt(this.type._copy())}splice(t){throw ld()}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}},Mat=e=>new Wp(kat[e.readTypeRef()](e)),UH=(e,t)=>{let n=t,r=0,o;do r>0&&(n=Qr(n.client,n.clock+r)),o=pA(e,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof Wi);return{item:o,diff:r}},VH=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},XN=(e,t,n)=>{const{client:r,clock:o}=t.id,i=new Wi(Qr(r,o+n),t,Qr(r,o+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=Qr(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},Ede=(e,t)=>V7(e,n=>cA(n.deletions,t)),_de=(e,t,n,r,o,i)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return qc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||_de(e,u,n,r,o,i)===null))return null;for(;u.redone!==null;)u=qc(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:qc(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:qc(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!o){for(d=t;d!==null&&d.right!==null&&(d.right.redone||cA(r,d.right.id)||Ede(i.undoStack,d.right.id)||Ede(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=qc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Qr(l,Js(a,l)),m=new Wi(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,VH(m,!0),m.integrate(e,0),m},Wi=class zse extends BH{constructor(t,n,r,o,i,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=o,this.rightOrigin=i,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>=Js(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Js(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===fA&&this.id.client!==this.parent.client&&this.parent.clock>=Js(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Zue(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=qc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ud||this.right&&this.right.constructor===ud)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===zse?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===zse&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===fA){const r=pA(n,this.parent);r.constructor===ud?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Zue(t,t.doc.store,Qr(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,o;if(r!==null)o=r.right;else if(this.parentSub!==null)for(o=this.parent._map.get(this.parentSub)||null;o!==null&&o.left!==null;)o=o.left;else o=this.parent._start;const i=new Set,s=new Set;for(;o!==null&&o!==this.right;){if(s.add(o),i.add(o),hA(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,i.clear();else if(hA(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&s.has(pA(t.doc.store,o.origin)))i.has(pA(t.doc.store,o.origin))||(r=o,i.clear());else break;o=o.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),Jue(t.doc.store,this),this.content.integrate(t,this),ede(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new ud(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:Qr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&hA(t.origin,this.lastId)&&this.right===t&&hA(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(),vk(t.deleteSet,this.id.client,this.id.clock,this.length),ede(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw lc();this.content.gc(t),n?Ost(t,this,new ud(this.id,this.length)):this.content=new kde(this.length)}write(t,n){const r=n>0?Qr(this.id.client,this.id.clock+n-1):this.origin,o=this.rightOrigin,i=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(o===null?0:64)|(i===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),o!==null&&t.writeRightID(o),r===null&&o===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=Ak(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===fA?(t.writeParentInfo(!1),t.writeLeftID(a)):lc();i!==null&&t.writeString(i)}this.content.write(t,n)}},Rde=(e,t)=>Dat[t&31](e),Dat=[()=>{lc()},yat,Sat,gat,xat,vat,wat,Mat,Iat,bat,()=>{lc()}],Oat=10,dd=class extends BH{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){lc()}write(e,t){e.writeInfo(Oat),Fn(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Pde=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Nde="__ $YJS$ __";Pde[Nde]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Pde[Nde]=!0;const Fat=3e4;var Lde=class extends Ait{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=uf();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,o)=>{o!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(o)&&n.push(o)}),n.length>0&&yA(this,n,"timeout")},ad(Fat/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,o=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:uf()});const i=[],s=[],a=[],l=[];e===null?l.push(t):o==null?e!=null&&i.push(t):(s.push(t),rA(o,e)||a.push(t)),(i.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:i,updated:a,removed:l},"local"]),this.emit("update",[{added:i,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const yA=(e,t,n)=>{const r=[];for(let o=0;o<t.length;o++){const i=t[o];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){const s=e.meta.get(i);e.meta.set(i,{clock:s.clock+1,lastUpdated:uf()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},xg=(e,t,n=e.states)=>{const r=t.length,o=ya();Fn(o,r);for(let i=0;i<r;i++){const s=t[i],a=n.get(s)||null,l=e.meta.get(s).clock;Fn(o,s),Fn(o,l),Ua(o,JSON.stringify(a))}return Gi(o)},Mde=(e,t,n)=>{const r=zp(t),o=uf(),i=[],s=[],a=[],l=[],c=Fr(r);for(let u=0;u<c;u++){const d=Fr(r);let f=Fr(r);const h=JSON.parse(ku(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:o}),p===void 0&&h!==null?i.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(rA(h,m)||a.push(d),s.push(d)))}(i.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:i,updated:a,removed:l},n]),(i.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:i,updated:s,removed:l},n])};var Dde=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 Bat(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 GH(e){return new Promise(t=>setTimeout(t,e))}function Hat(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),o=Math.floor(n);n=Math.floor(Math.random()*(o-r+1))+r}return Math.round(n)}async function zat(e,t){const n=Bat(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}},o=n.calculateDelay||Hat;async function i(){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=o(r,n);return c&&await GH(c),i()};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 GH(s),r.attemptNum<1&&n.initialJitter){const a=o(r,n);a&&await GH(a)}return i()}const Ode=e=>$ot(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let Ol=(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})({}),Fl=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var JN=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=ya(),this.decoder=zp(new Uint8Array(this.data))}peekVarString(){return Fot(this.decoder)}readVarUint(){return Fr(this.decoder)}readVarString(){return ku(this.decoder)}readVarUint8Array(){return ul(this.decoder)}writeVarUint(e){return Fn(this.encoder,e)}writeVarString(e){return Ua(this.encoder,e)}writeVarUint8Array(e){return ys(this.encoder,e)}length(){return wN(this.encoder)}},Fde=class extends Dde{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=Fl.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===Fl.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===Fl.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:zat(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:o=>{(!this.shouldConnect||r)&&o.abort()}}).catch(o=>{if(o&&o.code!=="ATTEMPT_ABORTED")throw o}),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),o=l=>this.emit("close",{event:l}),i=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:o,open:i,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=Fl.Connecting,this.emit("status",{status:Fl.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=uf();const t=new JN(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Fl.Connected,this.emit("status",{status:Fl.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===Fl.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=uf()-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=Ode(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===Wot.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===Fl.Connected&&(this.status=Fl.Disconnected,this.emit("status",{status:Fl.Disconnected}),this.emit("disconnect",{event:e})),e.code===Wce.code&&(e.reason===Wce.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===Got.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===Vot.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!==Fl.Disconnected&&(this.status=Fl.Disconnected,this.emit("status",{status:Fl.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 yIr=0,bIr=1,vIr=2,ZN=(e,t)=>{Fn(e,0);const n=_st(t);ys(e,n)},WH=(e,t,n)=>{Fn(e,1),ys(e,AH(t,n))},Uat=(e,t,n)=>WH(t,n,ul(e)),Bde=(e,t,n,r)=>{try{Uue(t,ul(e),n)}catch(o){r?.(o),console.error("Caught error while handling a Yjs update",o)}},Hde=(e,t)=>{Fn(e,2),ys(e,t)},Vat=Bde,zde=(e,t,n,r,o)=>{const i=Fr(e);switch(i){case 0:Uat(e,t,n);break;case 1:Bde(e,n,r,o);break;case 2:Vat(e,n,r,o);break;default:throw new Error("Unknown message type")}return i};var ch=class{encoder;type;constructor(){this.encoder=ya()}get(e){return e.encoder}toUint8Array(){return Gi(this.encoder)}},Ude=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(),o=n.length();switch(r){case Ol.Sync:this.applySyncMessage(e,t);break;case Ol.Awareness:this.applyAwarenessMessage(e);break;case Ol.Auth:this.applyAuthMessage(e);break;case Ol.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Ol.Stateless:e.receiveStateless(ku(n.decoder));break;case Ol.SyncStatus:this.applySyncStatusMessage(e,IN(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>o+1&&(this.broadcasted?e.broadcast(ch,{encoder:n.encoder}):e.send(ch,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(Ol.Sync);const r=zde(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;Mde(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;Uot(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(Ol.Awareness),t.writeVarUint8Array(xg(e.awareness,Array.from(e.awareness.getStates().keys())))}},Vde=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Gi(this.encoder)}send(e){e?.send(this.create())}broadcast(e){tb(e,this.create())}},Gat=class extends ch{type=Ol.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),zot(this.encoder,e.token),this.encoder}},QN=class extends ch{type=Ol.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");Ua(this.encoder,e.documentName),Fn(this.encoder,this.type);let t;return e.states===void 0?t=xg(e.awareness,e.clients):t=xg(e.awareness,e.clients,e.states),ys(this.encoder,t),this.encoder}},Wat=class extends ch{type=Ol.CLOSE;description="Ask the server to close the connection";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),this.encoder}},jat=class extends ch{type=Ol.QueryAwareness;description="Queries awareness states";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),this.encoder}},qat=class extends ch{type=Ol.Stateless;description="A stateless message";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),Ua(this.encoder,e.payload??""),this.encoder}},jH=class extends ch{type=Ol.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 Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),ZN(this.encoder,e.document),this.encoder}},Kat=class extends ch{type=Ol.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 Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),WH(this.encoder,e.document),this.encoder}},Yat=class extends ch{type=Ol.Sync;description="A document update";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),Hde(this.encoder,e.update),this.encoder}},Xat=class extends Error{code=1001},Jat=class extends Dde{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=Fl.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=oue();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Gp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new Lde(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:jce(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:jce(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 Fde({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(jH,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&yA(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(qat,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Yat,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const o=e.concat(t).concat(n);this.send(QN,{awareness:this.awareness,clients:o,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(Gat,{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(jH,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(QN,{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 Vde(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new JN(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new JN(e.data)}),new Ude(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&yA(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&&(yA(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(Wat,{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=Fl.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 JN(e),n=t.readVarString();t.writeVarString(n),new Ude(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(nue(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(jH,{document:this.document,documentName:this.configuration.name}),this.broadcast(Kat,{document:this.document,documentName:this.configuration.name}),this.broadcast(jat,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(QN,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(QN,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(rue(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new Vde(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new Xat(`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 Kc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",_k="application/pdf",$N="text/html",Zat={docx:Kc,pdf:_k,html:$N},qH=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),la={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"},Rk=e=>typeof e!="string"?"":e.trim(),eL=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},KH=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},Pk=e=>{const t=e??{},n=Rk(t.id),r=eL(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},Gde=({current:e,other:t})=>{const n=Pk(e),r=Pk(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},bA=({actor:e,fallbackKey:t=""})=>{const n=Pk(e);if(n.hasId)return`id:${n.id}`;if(n.hasEmail)return`email:${n.email}`;const r=typeof t=="number"?String(t):typeof t=="string"?t.trim():"";return r?`fallback:${r}`:""};var Qat=(e,t)=>hf(e,t,ZH),Wde=(e,t)=>hf(e,t,plt),$at=(e,t)=>{const n=Wde(e,t);return n?n.toLowerCase():null},jde=(e,t)=>hf(e,t,mlt),elt=(e,t)=>{const n=jde(e,t);return n?n.toLowerCase():null},tlt=(e,t)=>hf(e,t,Kde),nlt=(e,t)=>hf(e,t,ult),rlt=(e,t)=>hf(e,t,dlt),olt=(e,t,n)=>hlt(e,t,n),ilt=(e,t)=>hf(e,t,glt),slt=(e,t)=>hf(e,t,flt),alt={decimal:Qat,decimalZero:slt,lowerRoman:$at,upperRoman:Wde,lowerLetter:elt,upperLetter:jde,ordinal:tlt,ordinalText:nlt,cardinalText:rlt,custom:olt,japaneseCounting:ilt};const qde=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const o=alt[n];return o?o(e,t,r):null};var llt=(e,t)=>typeof t!="string"?"":e.reduce((n,r,o)=>Number(r)>9?n.replace(/^0/,"").replace(`%${o+1}`,r):n.replace(`%${o+1}`,r),t),hf=(e,t,n)=>llt(e.map((r,o)=>n(r,o)),t),Kde=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},YH=["","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],clt=["","","Twentieth","Thirtieth","Fortieth","Fiftieth","Sixtieth","Seventieth","Eightieth","Ninetieth"],XH=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],JH=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],ult=e=>{if(!Number.isFinite(e)||e<1)return"";if(e<YH.length)return YH[e];if(e<100){const t=Math.floor(e/10),n=e%10;return n===0?clt[t]:`${JH[t]}-${YH[n]}`}return Kde(e)},dlt=e=>{if(!Number.isFinite(e)||e<1)return"";if(e<XH.length)return XH[e];if(e<100){const t=Math.floor(e/10),n=e%10;return n===0?JH[t]:`${JH[t]}-${XH[n]}`}return String(e)},flt=(e,t)=>e>=10||t===0?String(e):`0${e}`,hlt=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return hf(e,t,ZH);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const o=r[1].length;return hf(e,t,i=>String(i).padStart(o,"0"))},ZH=e=>String(e),plt=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:o,numeral:i}of t)for(;r>=o;)n+=i,r-=o;return n},mlt=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const glt=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",o=e,i=0;for(;o>0;){const s=o%10;if(s!==0?r=(s===1&&i>0?"":t[s])+(i>0?n[i]:"")+r:r&&o>0&&!r.startsWith("零")&&o%100!==0&&(r="零"+r),o=Math.floor(o/10),i+=1,i>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var ylt=new Set(["","","○","o","■","□"]);const QH=e=>!e||!ylt.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Yde=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 tL=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Yde(e[e.length-1]);return t!=null&&t>0?t:void 0},Nk=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,o=typeof t.customFormat=="string"?t.customFormat:void 0,i=Array.isArray(t.path)?t.path.map(Yde).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!i||i.length===0)))return{markerText:n,numberingType:r,...i&&i.length>0?{path:i}:{},...o?{customFormat:o}:{}}};function blt(e){return typeof e.captureStackTrace=="function"}var nL=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",blt(Error)&&Error.captureStackTrace(this,this.constructor)}},vlt=class extends nL{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},wlt=class extends nL{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const rL=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new vlt(e);const s=atob(i[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 wlt(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const o=await r.blob();return new File([o],t,{type:n})}catch(r){throw r instanceof nL?r:new nL("Failed to create file object",r)}};function Alt(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,s=r[o]||0;if(i>s)return 1;if(i<s)return-1}return 0}var $H={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 Slt(e){return e[1].user!==void 0}const Tlt=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(Slt).filter(([r,o])=>{const i=bA({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=bA({actor:o.user,fallbackKey:r});let s=e.userColorMap.get(i);return s||(s=o.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(i,s),e.colorIndex++),{clientId:r,...o.user,color:s}})},Ilt=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 xlt="https://ingest.superdoc.dev/v1/collect";const wIr="community-and-eval-agplv3";function klt(){try{return"1.44.2"}catch{return"unknown"}}var Clt=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||xlt,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=klt()}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 Elt(e,t){return e.type.name===t}function _lt(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function Rlt(e,t){return e.type.name===t}function ar(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function Pi(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var Qn=class mtt{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=Pi(ar(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi(ar(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new mtt(t)}};function Plt(e){return Qn.create(e)}var Bl=class gtt{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=Pi(ar(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi(ar(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new gtt(t)}};function Nlt(e){return Bl.create(e)}var ez=Zr(((e,t)=>{t.exports={}})),Llt=Zr((e=>{(function(t){t.parser=function(B,D){return new r(B,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(B,D){if(!(this instanceof r))return new r(B,D);var N=this;i(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=!!B,N.noscript=!!(B||N.opt.noscript),N.state=k.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=!B),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),E(N,"onready")}Object.create||(Object.create=function(B){function D(){}return D.prototype=B,new D}),Object.keys||(Object.keys=function(B){var D=[];for(var N in B)B.hasOwnProperty(N)&&D.push(N);return D});function o(B){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,V=0,re=n.length;V<re;V++){var J=B[n[V]].length;if(J>D)switch(n[V]){case"textNode":W(B);break;case"cdata":H(B,"oncdata",B.cdata),B.cdata="";break;case"script":H(B,"onscript",B.script),B.script="";break;default:U(B,"Max buffer length exceeded: "+n[V])}N=Math.max(N,J)}B.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+B.position}function i(B){for(var D=0,N=n.length;D<N;D++)B[n[D]]=""}function s(B){W(B),B.cdata!==""&&(H(B,"oncdata",B.cdata),B.cdata=""),B.script!==""&&(H(B,"onscript",B.script),B.script="")}r.prototype={end:function(){F(this)},write:_e,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=ez().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(B){return B!=="error"&&B!=="end"});function c(B,D){return new d(B,D)}function u(B,D){if(B.length>=2){if(B[0]===255&&B[1]===254)return"utf-16le";if(B[0]===254&&B[1]===255)return"utf-16be"}return B.length>=3&&B[0]===239&&B[1]===187&&B[2]===191?"utf8":B.length>=4?B[0]===60&&B[1]===0&&B[2]===63&&B[3]===0?"utf-16le":B[0]===0&&B[1]===60&&B[2]===0&&B[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(B,D){if(!(this instanceof d))return new d(B,D);a.apply(this),this._parser=new r(B,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(V){N.emit("error",V),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(V){Object.defineProperty(N,"on"+V,{get:function(){return N._parser["on"+V]},set:function(re){if(!re)return N.removeAllListeners(V),N._parser["on"+V]=re,re;N.on(V,re)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(B,D){if(this._decoderBuffer&&(B=Buffer.concat([this._decoderBuffer,B]),this._decoderBuffer=null),!this._decoder){var N=u(B,D);if(!N)return this._decoderBuffer=B,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(B,{stream:!D})},d.prototype.write=function(B){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(B))B=this._decodeBuffer(B,!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(B.toString()),this.emit("data",B),!0},d.prototype.end=function(B){if(B&&B.length&&this.write(B),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(B,D){var N=this;return!N._parser["on"+B]&&l.indexOf(B)!==-1&&(N._parser["on"+B]=function(){var V=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);V.splice(0,0,B),N.emit.apply(N,V)}),a.prototype.on.call(N,B,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]/,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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,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]/,A=/[#:_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 S(B){return B===" "||B===`
5
+ `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&OH(r,this,o,a,s.attributes||{})}else s.retain!==void 0?Tde(r,this,o,s.retain,s.attributes||{}):s.delete!==void 0&&xde(r,o,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??Ml();const o=[],i=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;i.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),o.push(h),a=""}}const u=()=>{for(;l!==null;){if(ob(l,t)||n!==void 0&&ob(l,n))switch(l.content.constructor){case Ig:{const d=i.get("ychange");t!==void 0&&!ob(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ob(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),a+=l.content.str;break}case Wp:case Ek:{c();const d={insert:l.content.getContent()[0]};if(i.size>0){const f={};d.attributes=f,i.forEach((h,p)=>{f[p]=h})}o.push(d);break}case Wa:ob(l,t)&&(c(),mA(i,l.content));break}l=l.right}c()};return t||n?Ri(s,d=>{t&&kH(d,t),n&&kH(d,n),u()},"cleanup"):u(),o}insert(t,n,r){if(n.length<=0)return;const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),OH(i,this,s,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!r);OH(i,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?Ri(r,o=>{xde(o,KN(o,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const o=this.doc;o!==null?Ri(o,i=>{const s=KN(i,this,t,!1);s.right!==null&&Tde(i,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{jN(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{NH(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return LH(this,t)}getAttributes(){return yde(this)}_write(t){t.writeTypeRef(_at)}},lat=e=>new Ck,FH=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ml()}[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===Dl||t.constructor===gA)&&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})}},gA=class Nse 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 Nse}clone(){const t=new Nse;return t.insert(0,this.toArray().map(n=>n instanceof Ga?n.clone():n)),t}get length(){return this.doc??Ml(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new FH(this,t)}querySelector(t){t=t.toUpperCase();const n=new FH(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),Hp(new FH(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){GN(this,t,new dat(this,n,t))}toString(){return fde(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const o=t.createDocumentFragment();return r!==void 0&&r._createAssociation(o,this),kk(this,i=>{o.insertBefore(i.toDOM(t,n,r),null)}),o}insert(t,n){this.doc!==null?Ri(this.doc,r=>{mde(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)Ri(this.doc,r=>{const o=t&&t instanceof Ga?t._item:t;WN(r,this,o,n)});else{const r=this._prelimContent,o=t===null?0:r.findIndex(i=>i===t)+1;if(o===0&&t!==null)throw ah("Reference item not found");r.splice(o,0,...n)}}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{gde(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return ude(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return hde(this,t)}slice(t=0,n=this.length){return cde(this,t,n)}forEach(t){kk(this,t)}_write(t){t.writeTypeRef(Pat)}},cat=e=>new gA,Dl=class Lse extends gA{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,o)=>{this.setAttribute(o,r)}),this._prelimAttrs=null}_copy(){return new Lse(this.nodeName)}clone(){const t=new Lse(this.nodeName),n=this.getAttributes();return Qot(n,(r,o)=>{t.setAttribute(o,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 o=r.length;for(let s=0;s<o;s++){const a=r[s];n.push(a+'="'+t[a]+'"')}const i=this.nodeName.toLocaleLowerCase();return`<${i}${n.length>0?" "+n.join(" "):""}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{jN(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{NH(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return LH(this,t)}hasAttribute(t){return bde(this,t)}getAttributes(t){return t?$st(this,t):yde(this)}toDOM(t=document,n={},r){const o=t.createElement(this.nodeName),i=this.getAttributes();for(const s in i){const a=i[s];typeof a=="string"&&o.setAttribute(s,a)}return kk(this,s=>{o.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(Rat),t.writeKey(this.nodeName)}},uat=e=>new Dl(e.readKey()),dat=class extends UN{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)})}},fat=class Mse extends Sg{constructor(t){super(),this.hookName=t}_copy(){return new Mse(this.hookName)}clone(){const t=new Mse(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const o=n[this.hookName];let i;return o!==void 0?i=o.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(Nat),t.writeKey(this.hookName)}},hat=e=>new fat(e.readKey()),ff=class Dse extends Ck{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 Dse}clone(){const t=new Dse;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const o=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(o,this),o}toString(){return this.toDelta().map(t=>{const n=[];for(const o in t.attributes){const i=[];for(const s in t.attributes[o])i.push({key:s,value:t.attributes[o][s]});i.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:o,attrs:i})}n.sort((o,i)=>o.nodeName<i.nodeName?-1:1);let r="";for(let o=0;o<n.length;o++){const i=n[o];r+=`<${i.nodeName}`;for(let s=0;s<i.attrs.length;s++){const a=i.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=t.insert;for(let o=n.length-1;o>=0;o--)r+=`</${n[o].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Lat)}},pat=e=>new ff,BH=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw ld()}mergeWith(e){return!1}write(e,t,n){throw ld()}integrate(e,t){throw ld()}},mat=0,ud=class extends BH{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),Jue(e.doc.store,this)}write(e,t){e.writeInfo(mat),e.writeLen(this.length-t)}getMissing(e,t){return null}},HH=class utt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new utt(this.content)}splice(t){throw ld()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},gat=e=>new HH(e.readBuf()),kde=class Ose{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ose(this.len)}splice(t){const n=new Ose(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){vk(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}},yat=e=>new kde(e.readLen()),Cde=(e,t)=>new Gp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),zH=class dtt{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 dtt(Cde(this.doc.guid,this.opts))}splice(t){throw ld()}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}},bat=e=>new zH(Cde(e.readString(),e.readAny())),Ek=class ftt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ftt(this.embed)}splice(t){throw ld()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},vat=e=>new Ek(e.readJSON()),Wa=class htt{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new htt(this.key,this.value)}splice(t){throw ld()}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}},wat=e=>new Wa(e.readKey(),e.readJSON()),Aat=class Fse{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Fse(this.arr)}splice(t){const n=new Fse(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 o=n;o<r;o++){const i=this.arr[o];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},Sat=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const o=e.readString();o==="undefined"?n.push(void 0):n.push(JSON.parse(o))}return new Aat(n)},Tat=EN("node_env")==="development",YN=class Bse{constructor(t){this.arr=t,Tat&&Zce(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Bse(this.arr)}splice(t){const n=new Bse(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 o=n;o<r;o++){const i=this.arr[o];t.writeAny(i)}}getRef(){return 8}},Iat=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new YN(n)},Ig=class Hse{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Hse(this.str)}splice(t){const n=new Hse(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}},xat=e=>new Ig(e.readString()),kat=[tat,rat,lat,uat,cat,hat,pat],Cat=0,Eat=1,_at=2,Rat=3,Pat=4,Nat=5,Lat=6,Wp=class ptt{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ptt(this.type._copy())}splice(t){throw ld()}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}},Mat=e=>new Wp(kat[e.readTypeRef()](e)),UH=(e,t)=>{let n=t,r=0,o;do r>0&&(n=Qr(n.client,n.clock+r)),o=pA(e,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof Wi);return{item:o,diff:r}},VH=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},XN=(e,t,n)=>{const{client:r,clock:o}=t.id,i=new Wi(Qr(r,o+n),t,Qr(r,o+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=Qr(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},Ede=(e,t)=>V7(e,n=>cA(n.deletions,t)),_de=(e,t,n,r,o,i)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return qc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||_de(e,u,n,r,o,i)===null))return null;for(;u.redone!==null;)u=qc(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:qc(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:qc(e,g.redone);if(g!==null&&g.parent._item===u){f=g;break}f=f.right}}else if(f=null,t.right&&!o){for(d=t;d!==null&&d.right!==null&&(d.right.redone||cA(r,d.right.id)||Ede(i.undoStack,d.right.id)||Ede(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=qc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=Qr(l,Js(a,l)),m=new Wi(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,VH(m,!0),m.integrate(e,0),m},Wi=class zse extends BH{constructor(t,n,r,o,i,s,a,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=o,this.rightOrigin=i,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>=Js(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Js(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===fA&&this.id.client!==this.parent.client&&this.parent.clock>=Js(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Zue(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=qc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ud||this.right&&this.right.constructor===ud)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===zse?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===zse&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===fA){const r=pA(n,this.parent);r.constructor===ud?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Zue(t,t.doc.store,Qr(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,o;if(r!==null)o=r.right;else if(this.parentSub!==null)for(o=this.parent._map.get(this.parentSub)||null;o!==null&&o.left!==null;)o=o.left;else o=this.parent._start;const i=new Set,s=new Set;for(;o!==null&&o!==this.right;){if(s.add(o),i.add(o),hA(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,i.clear();else if(hA(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&s.has(pA(t.doc.store,o.origin)))i.has(pA(t.doc.store,o.origin))||(r=o,i.clear());else break;o=o.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),Jue(t.doc.store,this),this.content.integrate(t,this),ede(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new ud(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:Qr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&hA(t.origin,this.lastId)&&this.right===t&&hA(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(),vk(t.deleteSet,this.id.client,this.id.clock,this.length),ede(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw lc();this.content.gc(t),n?Ost(t,this,new ud(this.id,this.length)):this.content=new kde(this.length)}write(t,n){const r=n>0?Qr(this.id.client,this.id.clock+n-1):this.origin,o=this.rightOrigin,i=this.parentSub,s=this.content.getRef()&31|(r===null?0:128)|(o===null?0:64)|(i===null?0:32);if(t.writeInfo(s),r!==null&&t.writeLeftID(r),o!==null&&t.writeRightID(o),r===null&&o===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=Ak(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===fA?(t.writeParentInfo(!1),t.writeLeftID(a)):lc();i!==null&&t.writeString(i)}this.content.write(t,n)}},Rde=(e,t)=>Dat[t&31](e),Dat=[()=>{lc()},yat,Sat,gat,xat,vat,wat,Mat,Iat,bat,()=>{lc()}],Oat=10,dd=class extends BH{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){lc()}write(e,t){e.writeInfo(Oat),Fn(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Pde=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Nde="__ $YJS$ __";Pde[Nde]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Pde[Nde]=!0;const Fat=3e4;var Lde=class extends Ait{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=uf();this.getLocalState()!==null&&3e4/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((r,o)=>{o!==this.clientID&&3e4<=t-r.lastUpdated&&this.states.has(o)&&n.push(o)}),n.length>0&&yA(this,n,"timeout")},ad(Fat/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,o=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:uf()});const i=[],s=[],a=[],l=[];e===null?l.push(t):o==null?e!=null&&i.push(t):(s.push(t),rA(o,e)||a.push(t)),(i.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:i,updated:a,removed:l},"local"]),this.emit("update",[{added:i,updated:s,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const yA=(e,t,n)=>{const r=[];for(let o=0;o<t.length;o++){const i=t[o];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){const s=e.meta.get(i);e.meta.set(i,{clock:s.clock+1,lastUpdated:uf()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},xg=(e,t,n=e.states)=>{const r=t.length,o=ya();Fn(o,r);for(let i=0;i<r;i++){const s=t[i],a=n.get(s)||null,l=e.meta.get(s).clock;Fn(o,s),Fn(o,l),Ua(o,JSON.stringify(a))}return Gi(o)},Mde=(e,t,n)=>{const r=zp(t),o=uf(),i=[],s=[],a=[],l=[],c=Fr(r);for(let u=0;u<c;u++){const d=Fr(r);let f=Fr(r);const h=JSON.parse(ku(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:o}),p===void 0&&h!==null?i.push(d):p!==void 0&&h===null?l.push(d):h!==null&&(rA(h,m)||a.push(d),s.push(d)))}(i.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:i,updated:a,removed:l},n]),(i.length>0||s.length>0||l.length>0)&&e.emit("update",[{added:i,updated:s,removed:l},n])};var Dde=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 Bat(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 GH(e){return new Promise(t=>setTimeout(t,e))}function Hat(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),o=Math.floor(n);n=Math.floor(Math.random()*(o-r+1))+r}return Math.round(n)}async function zat(e,t){const n=Bat(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}},o=n.calculateDelay||Hat;async function i(){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=o(r,n);return c&&await GH(c),i()};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 GH(s),r.attemptNum<1&&n.initialJitter){const a=o(r,n);a&&await GH(a)}return i()}const Ode=e=>$ot(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let Ol=(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})({}),Fl=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var JN=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=ya(),this.decoder=zp(new Uint8Array(this.data))}peekVarString(){return Fot(this.decoder)}readVarUint(){return Fr(this.decoder)}readVarString(){return ku(this.decoder)}readVarUint8Array(){return ul(this.decoder)}writeVarUint(e){return Fn(this.encoder,e)}writeVarString(e){return Ua(this.encoder,e)}writeVarUint8Array(e){return ys(this.encoder,e)}length(){return wN(this.encoder)}},Fde=class extends Dde{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=Fl.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===Fl.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===Fl.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:zat(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:o=>{(!this.shouldConnect||r)&&o.abort()}}).catch(o=>{if(o&&o.code!=="ATTEMPT_ABORTED")throw o}),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),o=l=>this.emit("close",{event:l}),i=l=>this.emit("open",l),s=l=>{t(l)};this.webSocketHandlers[n]={message:r,close:o,open:i,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=Fl.Connecting,this.emit("status",{status:Fl.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=uf();const t=new JN(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Fl.Connected,this.emit("status",{status:Fl.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===Fl.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=uf()-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=Ode(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===Wot.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===Fl.Connected&&(this.status=Fl.Disconnected,this.emit("status",{status:Fl.Disconnected}),this.emit("disconnect",{event:e})),e.code===Wce.code&&(e.reason===Wce.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===Got.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===Vot.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!==Fl.Disconnected&&(this.status=Fl.Disconnected,this.emit("status",{status:Fl.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 yIr=0,bIr=1,vIr=2,ZN=(e,t)=>{Fn(e,0);const n=_st(t);ys(e,n)},WH=(e,t,n)=>{Fn(e,1),ys(e,AH(t,n))},Uat=(e,t,n)=>WH(t,n,ul(e)),Bde=(e,t,n,r)=>{try{Uue(t,ul(e),n)}catch(o){r?.(o),console.error("Caught error while handling a Yjs update",o)}},Hde=(e,t)=>{Fn(e,2),ys(e,t)},Vat=Bde,zde=(e,t,n,r,o)=>{const i=Fr(e);switch(i){case 0:Uat(e,t,n);break;case 1:Bde(e,n,r,o);break;case 2:Vat(e,n,r,o);break;default:throw new Error("Unknown message type")}return i};var ch=class{encoder;type;constructor(){this.encoder=ya()}get(e){return e.encoder}toUint8Array(){return Gi(this.encoder)}},Ude=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(),o=n.length();switch(r){case Ol.Sync:this.applySyncMessage(e,t);break;case Ol.Awareness:this.applyAwarenessMessage(e);break;case Ol.Auth:this.applyAuthMessage(e);break;case Ol.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Ol.Stateless:e.receiveStateless(ku(n.decoder));break;case Ol.SyncStatus:this.applySyncStatusMessage(e,IN(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>o+1&&(this.broadcasted?e.broadcast(ch,{encoder:n.encoder}):e.send(ch,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(Ol.Sync);const r=zde(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;Mde(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;Uot(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(Ol.Awareness),t.writeVarUint8Array(xg(e.awareness,Array.from(e.awareness.getStates().keys())))}},Vde=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Gi(this.encoder)}send(e){e?.send(this.create())}broadcast(e){tb(e,this.create())}},Gat=class extends ch{type=Ol.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),zot(this.encoder,e.token),this.encoder}},QN=class extends ch{type=Ol.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");Ua(this.encoder,e.documentName),Fn(this.encoder,this.type);let t;return e.states===void 0?t=xg(e.awareness,e.clients):t=xg(e.awareness,e.clients,e.states),ys(this.encoder,t),this.encoder}},Wat=class extends ch{type=Ol.CLOSE;description="Ask the server to close the connection";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),this.encoder}},jat=class extends ch{type=Ol.QueryAwareness;description="Queries awareness states";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),this.encoder}},qat=class extends ch{type=Ol.Stateless;description="A stateless message";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),Ua(this.encoder,e.payload??""),this.encoder}},jH=class extends ch{type=Ol.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 Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),ZN(this.encoder,e.document),this.encoder}},Kat=class extends ch{type=Ol.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 Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),WH(this.encoder,e.document),this.encoder}},Yat=class extends ch{type=Ol.Sync;description="A document update";get(e){return Ua(this.encoder,e.documentName),Fn(this.encoder,this.type),Hde(this.encoder,e.update),this.encoder}},Xat=class extends Error{code=1001},Jat=class extends Dde{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=Fl.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=oue();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Gp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new Lde(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:jce(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:jce(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 Fde({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(jH,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&yA(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(qat,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Yat,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const o=e.concat(t).concat(n);this.send(QN,{awareness:this.awareness,clients:o,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(Gat,{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(jH,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(QN,{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 Vde(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new JN(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new JN(e.data)}),new Ude(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&yA(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&&(yA(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(Wat,{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=Fl.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 JN(e),n=t.readVarString();t.writeVarString(n),new Ude(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(nue(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(jH,{document:this.document,documentName:this.configuration.name}),this.broadcast(Kat,{document:this.document,documentName:this.configuration.name}),this.broadcast(jat,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(QN,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(QN,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(rue(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new Vde(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new Xat(`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 Kc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",_k="application/pdf",$N="text/html",Zat={docx:Kc,pdf:_k,html:$N},qH=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),la={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"},Rk=e=>typeof e!="string"?"":e.trim(),eL=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},KH=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},Pk=e=>{const t=e??{},n=Rk(t.id),r=eL(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},Gde=({current:e,other:t})=>{const n=Pk(e),r=Pk(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},bA=({actor:e,fallbackKey:t=""})=>{const n=Pk(e);if(n.hasId)return`id:${n.id}`;if(n.hasEmail)return`email:${n.email}`;const r=typeof t=="number"?String(t):typeof t=="string"?t.trim():"";return r?`fallback:${r}`:""};var Qat=(e,t)=>hf(e,t,ZH),Wde=(e,t)=>hf(e,t,plt),$at=(e,t)=>{const n=Wde(e,t);return n?n.toLowerCase():null},jde=(e,t)=>hf(e,t,mlt),elt=(e,t)=>{const n=jde(e,t);return n?n.toLowerCase():null},tlt=(e,t)=>hf(e,t,Kde),nlt=(e,t)=>hf(e,t,ult),rlt=(e,t)=>hf(e,t,dlt),olt=(e,t,n)=>hlt(e,t,n),ilt=(e,t)=>hf(e,t,glt),slt=(e,t)=>hf(e,t,flt),alt={decimal:Qat,decimalZero:slt,lowerRoman:$at,upperRoman:Wde,lowerLetter:elt,upperLetter:jde,ordinal:tlt,ordinalText:nlt,cardinalText:rlt,custom:olt,japaneseCounting:ilt};const qde=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const o=alt[n];return o?o(e,t,r):null};var llt=(e,t)=>typeof t!="string"?"":e.reduce((n,r,o)=>Number(r)>9?n.replace(/^0/,"").replace(`%${o+1}`,r):n.replace(`%${o+1}`,r),t),hf=(e,t,n)=>llt(e.map((r,o)=>n(r,o)),t),Kde=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},YH=["","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],clt=["","","Twentieth","Thirtieth","Fortieth","Fiftieth","Sixtieth","Seventieth","Eightieth","Ninetieth"],XH=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],JH=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],ult=e=>{if(!Number.isFinite(e)||e<1)return"";if(e<YH.length)return YH[e];if(e<100){const t=Math.floor(e/10),n=e%10;return n===0?clt[t]:`${JH[t]}-${YH[n]}`}return Kde(e)},dlt=e=>{if(!Number.isFinite(e)||e<1)return"";if(e<XH.length)return XH[e];if(e<100){const t=Math.floor(e/10),n=e%10;return n===0?JH[t]:`${JH[t]}-${XH[n]}`}return String(e)},flt=(e,t)=>e>=10||t===0?String(e):`0${e}`,hlt=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return hf(e,t,ZH);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const o=r[1].length;return hf(e,t,i=>String(i).padStart(o,"0"))},ZH=e=>String(e),plt=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:o,numeral:i}of t)for(;r>=o;)n+=i,r-=o;return n},mlt=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const glt=e=>{const t=["","一","二","三","四","五","六","七","八","九"],n=["","十","百","千"];if(e===0)return"零";if(e<10)return t[e];let r="",o=e,i=0;for(;o>0;){const s=o%10;if(s!==0?r=(s===1&&i>0?"":t[s])+(i>0?n[i]:"")+r:r&&o>0&&!r.startsWith("零")&&o%100!==0&&(r="零"+r),o=Math.floor(o/10),i+=1,i>3)break}return e>=10&&e<20&&(r=r.replace(/^一十/,"十")),r};var ylt=new Set(["","","○","o","■","□"]);const QH=e=>!e||!ylt.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Yde=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 tL=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Yde(e[e.length-1]);return t!=null&&t>0?t:void 0},Nk=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,o=typeof t.customFormat=="string"?t.customFormat:void 0,i=Array.isArray(t.path)?t.path.map(Yde).filter(s=>s!=null):void 0;if(!(!n&&!r&&(!i||i.length===0)))return{markerText:n,numberingType:r,...i&&i.length>0?{path:i}:{},...o?{customFormat:o}:{}}};function blt(e){return typeof e.captureStackTrace=="function"}var nL=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",blt(Error)&&Error.captureStackTrace(this,this.constructor)}},vlt=class extends nL{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},wlt=class extends nL{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const rL=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new vlt(e);const s=atob(i[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 wlt(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const o=await r.blob();return new File([o],t,{type:n})}catch(r){throw r instanceof nL?r:new nL("Failed to create file object",r)}};function Alt(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,s=r[o]||0;if(i>s)return 1;if(i<s)return-1}return 0}var $H={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 Slt(e){return e[1].user!==void 0}const Tlt=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(Slt).filter(([r,o])=>{const i=bA({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=bA({actor:o.user,fallbackKey:r});let s=e.userColorMap.get(i);return s||(s=o.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(i,s),e.colorIndex++),{clientId:r,...o.user,color:s}})},Ilt=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 xlt="https://ingest.superdoc.dev/v1/collect";const wIr="community-and-eval-agplv3";function klt(){try{return"1.45.0"}catch{return"unknown"}}var Clt=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||xlt,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=klt()}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 Elt(e,t){return e.type.name===t}function _lt(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function Rlt(e,t){return e.type.name===t}function ar(e,t,n={name:""}){const r=e.config[t];return typeof r=="function"?r.bind({...n}):r}function Pi(e,t=null,...n){if(typeof e=="function"){const r=e;return t?r.bind(t)(...n):r(...n)}return e}var Qn=class mtt{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=Pi(ar(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi(ar(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new mtt(t)}};function Plt(e){return Qn.create(e)}var Bl=class gtt{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=Pi(ar(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi(ar(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new gtt(t)}};function Nlt(e){return Bl.create(e)}var ez=Zr(((e,t)=>{t.exports={}})),Llt=Zr((e=>{(function(t){t.parser=function(B,D){return new r(B,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(B,D){if(!(this instanceof r))return new r(B,D);var N=this;i(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=!!B,N.noscript=!!(B||N.opt.noscript),N.state=k.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=!B),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),E(N,"onready")}Object.create||(Object.create=function(B){function D(){}return D.prototype=B,new D}),Object.keys||(Object.keys=function(B){var D=[];for(var N in B)B.hasOwnProperty(N)&&D.push(N);return D});function o(B){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,V=0,re=n.length;V<re;V++){var J=B[n[V]].length;if(J>D)switch(n[V]){case"textNode":W(B);break;case"cdata":H(B,"oncdata",B.cdata),B.cdata="";break;case"script":H(B,"onscript",B.script),B.script="";break;default:U(B,"Max buffer length exceeded: "+n[V])}N=Math.max(N,J)}B.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+B.position}function i(B){for(var D=0,N=n.length;D<N;D++)B[n[D]]=""}function s(B){W(B),B.cdata!==""&&(H(B,"oncdata",B.cdata),B.cdata=""),B.script!==""&&(H(B,"onscript",B.script),B.script="")}r.prototype={end:function(){F(this)},write:_e,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=ez().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(B){return B!=="error"&&B!=="end"});function c(B,D){return new d(B,D)}function u(B,D){if(B.length>=2){if(B[0]===255&&B[1]===254)return"utf-16le";if(B[0]===254&&B[1]===255)return"utf-16be"}return B.length>=3&&B[0]===239&&B[1]===187&&B[2]===191?"utf8":B.length>=4?B[0]===60&&B[1]===0&&B[2]===63&&B[3]===0?"utf-16le":B[0]===0&&B[1]===60&&B[2]===0&&B[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(B,D){if(!(this instanceof d))return new d(B,D);a.apply(this),this._parser=new r(B,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(V){N.emit("error",V),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(V){Object.defineProperty(N,"on"+V,{get:function(){return N._parser["on"+V]},set:function(re){if(!re)return N.removeAllListeners(V),N._parser["on"+V]=re,re;N.on(V,re)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(B,D){if(this._decoderBuffer&&(B=Buffer.concat([this._decoderBuffer,B]),this._decoderBuffer=null),!this._decoder){var N=u(B,D);if(!N)return this._decoderBuffer=B,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(B,{stream:!D})},d.prototype.write=function(B){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(B))B=this._decodeBuffer(B,!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(B.toString()),this.emit("data",B),!0},d.prototype.end=function(B){if(B&&B.length&&this.write(B),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(B,D){var N=this;return!N._parser["on"+B]&&l.indexOf(B)!==-1&&(N._parser["on"+B]=function(){var V=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);V.splice(0,0,B),N.emit.apply(N,V)}),a.prototype.on.call(N,B,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]/,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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,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]/,A=/[#:_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 S(B){return B===" "||B===`
6
6
  `||B==="\r"||B===" "}function w(B){return B==='"'||B==="'"}function T(B){return B===">"||S(B)}function x(B,D){return B.test(D)}function C(B,D){return!x(B,D)}var k=0;t.STATE={BEGIN:k++,BEGIN_WHITESPACE:k++,TEXT:k++,TEXT_ENTITY:k++,OPEN_WAKA:k++,SGML_DECL:k++,SGML_DECL_QUOTED:k++,DOCTYPE:k++,DOCTYPE_QUOTED:k++,DOCTYPE_DTD:k++,DOCTYPE_DTD_QUOTED:k++,COMMENT_STARTING:k++,COMMENT:k++,COMMENT_ENDING:k++,COMMENT_ENDED:k++,CDATA:k++,CDATA_ENDING:k++,CDATA_ENDING_2:k++,PROC_INST:k++,PROC_INST_BODY:k++,PROC_INST_ENDING:k++,OPEN_TAG:k++,OPEN_TAG_SLASH:k++,ATTRIB:k++,ATTRIB_NAME:k++,ATTRIB_NAME_SAW_WHITE:k++,ATTRIB_VALUE:k++,ATTRIB_VALUE_QUOTED:k++,ATTRIB_VALUE_CLOSED:k++,ATTRIB_VALUE_UNQUOTED:k++,ATTRIB_VALUE_ENTITY_Q:k++,ATTRIB_VALUE_ENTITY_U:k++,CLOSE_TAG:k++,CLOSE_TAG_SAW_WHITE:k++,SCRIPT:k++,SCRIPT_ENDING:k++},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(B){var D=t.ENTITIES[B],N=typeof D=="number"?String.fromCharCode(D):D;t.ENTITIES[B]=N});for(var P in t.STATE)t.STATE[t.STATE[P]]=P;k=t.STATE;function E(B,D,N){B[D]&&B[D](N)}function L(B){var D=B&&B.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return D?D[2]:null}function R(B){return B?B.toLowerCase().replace(/[^a-z0-9]/g,""):null}function M(B,D){const N=R(B),V=R(D);return!N||!V?!0:V==="utf16"?N==="utf16le"||N==="utf16be":N===V}function O(B,D){if(!(!B.strict||!B.encoding||!D||D.name!=="xml")){var N=L(D.body);N&&!M(B.encoding,N)&&ne(B,"XML declaration encoding "+N+" does not match detected stream encoding "+B.encoding.toUpperCase())}}function H(B,D,N){B.textNode&&W(B),E(B,D,N)}function W(B){B.textNode=G(B.opt,B.textNode),B.textNode&&E(B,"ontext",B.textNode),B.textNode=""}function G(B,D){return B.trim&&(D=D.trim()),B.normalize&&(D=D.replace(/\s+/g," ")),D}function U(B,D){return W(B),B.trackPosition&&(D+=`
7
7
  Line: `+B.line+`
8
8
  Column: `+B.column+`
@@ -97,7 +97,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`))}},fEe=new WeakMap,Tq=nu
97
97
  `,`
98
98
  `);ds({editor:e,partId:r.partId,operation:"mutate",source:`story-runtime:commit:${n.storyType}`,mutate({part:s}){ORe(s,r,n.noteId,i)}})}function g$t(e,t,n){const r=t?e.footnotes:e.endnotes;if(!Array.isArray(r))return null;const o=r.find(i=>String(i.id)===String(n));return o?Array.isArray(o.content)?rv({type:"doc",content:o.content.length>0?o.content:[{type:"paragraph"}]}):o.doc&&typeof o.doc=="object"?rv(o.doc):o.type==="doc"||o.type==="footnoteBody"||o.type==="endnoteBody"?rv(o):null:null}function y$t(e,t,n,r){const o=TO(e,t.childElementName).find(s=>s.attributes?.["w:id"]===n);if(!o)return!1;const i=r;return JK(i,t.childElementName),o.elements=i,!0}var oY=new WeakMap;function b$t(e){const t=oY.get(e);if(t)return t;const n={counters:new Map};return oY.set(e,n),n}function v$t(e){return oY.get(e)}function w$t(e,t){const n=e.counters.get(t)??0;return String(n)}function A$t(e,t){const n=(e.counters.get(t)??0)+1;return e.counters.set(t,n),String(n)}var zS=new WeakMap;function S$t(e){let t=zS.get(e);return t||(t=new Map,zS.set(e,t)),t}function ePe(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 T$t(e,t,n){const r=S$t(e),o=t.storyKey;return r.set(o,{storyKey:o,editor:n,runtime:t}),()=>{x$t(e,o,n)}}function iY(e,t){const n=zS.get(e)?.get(t);return n?ePe(n):null}function I$t(e){const t=zS.get(e);if(!t||t.size===0)return 0;let n=0;for(const r of[...t.values()])ePe(r).commit?.(e),n+=1;return n}function x$t(e,t,n){const r=zS.get(e);if(!r)return;const o=r.get(t);o&&(n&&o.editor!==n||(r.delete(t),r.size===0&&zS.delete(e)))}var jE=new WeakMap,sY=new WeakMap;function k$t(e,t){return sY.get(e)?.has(t)??!1}function C$t(e,t){let n=sY.get(e);n||(n=new Set,sY.set(e,n)),n.add(t)}function tPe(e){let t=jE.get(e);return t||(t=new fWt,jE.set(e,t),E$t(e)),t}function E$t(e){typeof e.on=="function"&&(e.on("notes-part-changed",()=>{const t=jE.get(e);t&&(t.invalidateByPrefix("fn:"),t.invalidateByPrefix("en:"))}),e.on("partChanged",t=>{const n=jE.get(e);n&&t.parts.some(r=>nv(r.partId))&&n.invalidateByPrefix("hf:")}))}var _$t={kind:"story",storyType:"body"};function R$t(e){return{locator:_$t,storyKey:If,editor:e,kind:"body"}}function yl(e,t,n={}){if(t===void 0||t.storyType==="body")return P$t(e);if(t.storyType==="textbox")throw new Be("CAPABILITY_UNAVAILABLE","Textbox stories are not supported by the v1 document-api runtime.",{target:t});const r=Ti(t),o=iY(e,r);if(o)return o;const i=tPe(e),s=i.get(r);if(s)return s;let a;switch(t.storyType){case"headerFooterSlot":a=SQt(e,t,n);break;case"headerFooterPart":a=TQt(e,t);break;case"footnote":case"endnote":a=d$t(e,t);break;default:{const c=t;throw new Be("INVALID_INPUT",`Unknown story type on locator: ${JSON.stringify(c)}`)}}UG(a.editor);const l=v$t(e);if(l){const c=w$t(l,r);vAe(a.editor,c)}return VG(a.editor),l&&!k$t(a.editor,r)&&(C$t(a.editor,r),a.editor.on("transaction",({transaction:c})=>{c.getMeta?.("superdoc/block-identity-repair")||c.docChanged&&A$t(l,r)})),a.cacheable!==!1&&i.set(r,a),a}function P$t(e){const t=tPe(e),n=t.get(If);if(n)return n;const r=R$t(e);return t.set(If,r),r}function N$t(e){return jE.get(e)}function aY(e,t){const n=yl(e,t.in).editor.state.doc;return iO(n,0,n.content.size,`
99
99
  `,`
100
- `,{textModel:"visible"})}const nPe=e=>{const t=e?.doc;if(!t)return[];const n=[];try{t.descendants((r,o)=>{if(r.isText)return!1;const i=r?.attrs?.paragraphProperties?.change;i&&typeof i.id=="string"&&i.id&&i.paragraphProperties&&n.push({id:i.id,from:o,to:o+r.nodeSize,author:i.author||"",authorEmail:i.authorEmail||"",authorImage:i.authorImage||"",date:i.date||"",formerProperties:i.paragraphProperties||{},subtype:"paragraph-format"})})}catch{return n}return n};function iv(e,t){return e!=="structural"?e:t?.subtype==="table-delete"||t?.side==="deletion"?"delete":"insert"}function L$t(e,t){return e[0]<t[1]&&t[0]<e[1]}function rPe(e){try{const t=Ic(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function M$t(e){return e.rawId}function qE(e){return e.structural?"structural":e.hasFormat?"format":e.hasInsert&&e.hasDelete?"replacement":e.hasDelete?"delete":"insert"}var oPe=new WeakMap;function D$t(e){return e?.options?.trackedChanges?.replacements==="independent"?"independent":"paired"}function iPe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function O$t(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function lY(e,t,n){const r=xr(e.sourceId);return r?`word:${t}:${r}`:n}function sPe(e){return e==="trackInsert"||e==="trackDelete"||e==="trackFormat"}function F$t(e){const t=[e.rawId,e.commandRawId,e.id,xr(e.attrs.id),xr(e.attrs.replacementGroupId),xr(e.attrs.sourceId)];return Array.from(new Set(t.filter(n=>!!n)))}function B$t(e){if(e.hasInsert===e.hasDelete)return null;const t=xr(e.attrs.replacementGroupId);return t?`group:${t}`:e.commandRawId?`command:${e.commandRawId}`:null}function H$t(e,t){const n=new Map;if(t==="paired"){const r=new Map;for(const o of e){if(o.hasInsert&&o.hasDelete)continue;const i=B$t(o);if(!i)continue;const s=r.get(i)??[];s.push(o),r.set(i,s)}for(const o of r.values()){const i=o.find(a=>a.hasInsert&&!a.hasDelete),s=o.find(a=>a.hasDelete&&!a.hasInsert);!i||!s||(n.set(i,i.id),n.set(s,i.id))}}for(const r of e)n.has(r)||n.set(r,r.id);return n}function aPe(e,t){const n=qE(e);return{id:e.id,rawId:e.rawId,commandRawId:e.commandRawId,type:iv(n,e.structural),relationship:t}}function z$t(e,t){const n=iv(qE(e),e.structural),r=iv(qE(t),t.structural);if(n!==r){if(n==="delete")return-1;if(r==="delete")return 1}return e.from!==t.from?e.from-t.from:e.id.localeCompare(t.id)}function U$t(e){if(e.length<2)return;const t=new Map;for(const r of e)for(const o of F$t(r))t.has(o)||t.set(o,r);const n=new Map;for(const r of e){const o=xr(r.attrs.overlapParentId);if(!o)continue;const i=t.get(o);if(!i||i===r)continue;const s=n.get(i)??[];s.push(r),n.set(i,s)}for(const[r,o]of n.entries()){const i=o.slice().sort(z$t),s=[aPe(r,"parent"),...i.map(l=>aPe(l,"child"))],a=s.find(l=>l.relationship==="child"&&l.type==="delete")??s.find(l=>l.relationship==="child");r.overlap={visualLayers:s,...a?{preferredContextTargetId:a.id,preferredContextTarget:a}:{}}}}function lPe(e){const t=e.type.name;if(!sPe(t))return null;const n=e.attrs??{},r=xr(n.id);return r?lY(n,t,r):null}function V$t(e,t){return t?(Array.isArray(e.node?.marks)?e.node.marks:[]).some(n=>{const r=n?.type?.name;return sPe(r)?xr(n?.attrs?.overlapParentId)===t:!1}):!1}function G$t(e,t){const n=t.node?.text;return typeof n=="string"?n:e.state.doc.textBetween(t.from,t.to," ","")}function W$t(e,t){return cPe(e.mark,t)}function cPe(e,t){const n=e.attrs??{},r=xr(n.id);if(!r)return!1;const o=e.type.name,i=lY(n,o,r);return i===t.rawId||i===t.id||r===t.commandRawId||r===t.id}function j$t(e,t){let n=null,r=null;try{e.state.doc.nodesBetween(t.from,t.to,(o,i)=>{if(n)return!1;if(!o.isText)return!0;if(!(Array.isArray(o.marks)?o.marks:[]).some(a=>cPe(a,t)))return!1;const s=typeof o.text=="string"?o.text.length:o.nodeSize;if(s>1){const a=i+1;return n={from:a,to:a},!1}return!r&&s>0&&(r={from:i,to:i+s}),!1})}catch{return null}return n??r}function uPe(e,t){const n=cY(e,t);if(!n||n.structural)return null;const r=j$t(e,n);if(r)return r;const o=rPe(e).filter(a=>W$t(a,n)).filter(a=>Number.isFinite(a.from)&&Number.isFinite(a.to)&&a.to>a.from).sort((a,l)=>a.from!==l.from?a.from-l.from:a.to-l.to),i=o.find(a=>a.to-a.from>1);if(i){const a=i.from+1;return{from:a,to:a}}const s=o[0];if(s)return{from:s.from,to:s.to};if(n.to>n.from){if(n.to-n.from>1){const a=n.from+1;return{from:a,to:a}}return{from:n.from,to:n.to}}return null}function KE(e){const t=e.state.doc,n=oPe.get(e);if(n&&n.doc===t)return n.grouped;const r=rPe(e),o=new Map,i=new Map;for(const u of r){const d=u.mark?.attrs??{},f=xr(d.id);if(!f)continue;const h=u.mark.type.name,p=lY(d,h,f),m=o.get(p),g=h===Ki,y=h===ui,b=h===vs,v=xr(d.sourceId),A=O$t(h),S=!v||!V$t(u,f)?G$t(e,u):"",w=[u.from,u.to],T=i.get(p);if(T?T.push({from:u.from,to:u.to}):i.set(p,[{from:u.from,to:u.to}]),!m){o.set(p,{rawId:p,commandRawId:f,from:u.from,to:u.to,hasInsert:g,hasDelete:y,hasFormat:b,attrs:{...d},excerptParts:S?[S]:[],excerptRanges:S?[w]:[],wordRevisionIds:A?iPe(void 0,A,v??void 0):void 0});continue}m.from=Math.min(m.from,u.from),m.to=Math.max(m.to,u.to),m.hasInsert=m.hasInsert||g,m.hasDelete=m.hasDelete||y,m.hasFormat=m.hasFormat||b,Object.keys(m.attrs).length===0&&Object.keys(d).length>0&&(m.attrs={...d}),S&&!m.excerptRanges.some(x=>L$t(x,w))&&(m.excerptRanges.push(w),m.excerptParts.push(S)),A&&(m.wordRevisionIds=iPe(m.wordRevisionIds,A,v??void 0))}const s=Array.from(o.values()).map(({excerptParts:u,excerptRanges:d,...f})=>{const h=!!xr(f.attrs.sourceId),p=u.join(""),m={...f,excerpt:u.length>0?p:h?"":void 0};return{...m,id:M$t(m)}}).sort((u,d)=>u.from!==d.from?u.from-d.from:u.id.localeCompare(d.id));U$t(s);const a=BS(e.state),l=a.filter(u=>u.decidable&&u.wholeTable).map(u=>({from:u.tableFrom,to:u.tableTo}));if(l.length>0){const u=d=>l.some(f=>d.from>=f.from&&d.to<=f.to);for(let d=s.length-1;d>=0;d-=1){const f=s[d];(i.get(f.rawId)??[{from:f.from,to:f.to}]).every(u)&&s.splice(d,1)}}for(const u of a){const d=NE(e.state.doc.textBetween(u.tableFrom,u.tableTo," ","")),f=u.sourceId?`word:structural:${u.sourceId}`:u.id;s.push({rawId:f,commandRawId:u.id,id:f,from:u.tableFrom,to:u.tableTo,hasInsert:!1,hasDelete:!1,hasFormat:!1,structural:{side:u.side,subtype:u.subtype},attrs:{id:u.id,sourceId:u.sourceId||void 0,author:u.author||void 0,authorEmail:u.authorEmail||void 0,authorImage:u.authorImage||void 0,date:u.date||void 0,importedAuthor:u.importedAuthor||void 0,origin:u.sourceId?"word":void 0,revisionGroupId:u.revisionGroupId||void 0},excerpt:d,wordRevisionIds:u.sourceId?u.side==="insertion"?{insert:u.sourceId}:{delete:u.sourceId}:void 0})}const c=nPe(e.state);for(const u of c){const d=NE(e.state.doc.textBetween(u.from,u.to," ",""));s.push({rawId:u.id,commandRawId:u.id,id:u.id,from:u.from,to:u.to,hasInsert:!1,hasDelete:!1,hasFormat:!0,attrs:{id:u.id,author:u.author||void 0,authorEmail:u.authorEmail||void 0,authorImage:u.authorImage||void 0,date:u.date||void 0},excerpt:d})}return s.sort((u,d)=>u.from!==d.from?u.from-d.from:u.id.localeCompare(d.id)),oPe.set(e,{doc:t,grouped:s}),s}function cY(e,t){const{baseId:n}=dY(t);return KE(e).find(r=>r.id===n)??null}function uY(e){const t=KE(e),n=H$t(t,D$t(e)),r=new Map;for(const o of t){const i=n.get(o)??o.id;r.set(o.rawId,i),r.set(o.id,i),o.commandRawId&&r.set(o.commandRawId,i);const s=xr(o.attrs.replacementGroupId);s&&r.set(s,i),r.set(i,i),r.set(`${i}#inserted`,i),r.set(`${i}#deleted`,i)}return r}function dY(e){return e.endsWith("#inserted")?{baseId:e.slice(0,-9),side:"inserted"}:e.endsWith("#deleted")?{baseId:e.slice(0,-8),side:"deleted"}:{baseId:e,side:null}}function q$t(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function sv(e,t){const n=q$t(t),r=n.entityId,o=n.story??{kind:"story",storyType:"body"};if((n.story?Ti(n.story):"body")==="body"){const a=dPe(e,r);return a?{editor:e,story:o,runtimeRef:{storyKey:If,rawId:a.rawId},change:a}:null}let i;try{i=yl(e,o)}catch{return null}const s=dPe(i.editor,r);return s?{editor:i.editor,story:i.locator,runtimeRef:{storyKey:i.storyKey,rawId:s.rawId},change:s,commit:i.commit}:null}function dPe(e,t){const{baseId:n}=dY(t);return KE(e).find(r=>r.id===n||r.rawId===n||r.commandRawId===n)??null}const fPe=["structuredContent","structuredContentBlock"],YE="structuredContentBlock",K$t="structuredContent";function XE(e){return fPe.includes(e.type.name)}function v0(e){const t=[];return e.descendants((n,r)=>(XE(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function Rn(e,t){const n=t.nodeId,r=v0(e).filter(o=>String(o.node.attrs.id)===n);if(r.length===0)throw new Be("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new Be("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function Ca(e,t){return e?.elements?.find(n=>n.name===t)}function hPe(e,t){return Ca(e,t)?.attributes}function xO(e,t,n){const r=e.elements?[...e.elements]:[],o=r.findIndex(i=>i.name===t);return o>=0?r[o]=n:r.push(n),{...e,elements:r}}function pPe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var Y$t=new Set(fPe);function av(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((i,s)=>r!==null?!1:Y$t.has(i.type.name)&&String(i.attrs.id)===String(t)?(r=s,!1):!0),r===null)return!1;const o=e.state.tr;for(const[i,s]of Object.entries(n))o.setNodeAttribute(r,i,s);if(o.steps.length===0)return!0;if(e.view?.dispatch)e.view.dispatch(o);else if(typeof e.dispatch=="function")e.dispatch(o);else return!1;return!0}function Pf(e,t,n,r){const o=Rn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},i=r(Ca(o,n));let s;return i===null?s=pPe(o,n):s=xO(o,n,i),av(e,t.nodeId,{sdtPr:s})}function fY(e,t,n,r,o,i){return Pf(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:{[o]:i}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[o]:i}}:l.push(u),{...a,elements:l}})}function X$t(e,t,n,r){return Pf(e,t,n,o=>({name:n,type:"element",...o,elements:r}))}var J$t=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],Z$t=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],Q$t=["boundingBox","tags","hidden"];function vm(e){const t=e.controlType??e.type;return typeof t=="string"&&J$t.includes(t)?t:"unknown"}function kO(e){const t=e.lockMode;return typeof t=="string"&&Z$t.includes(t)?t:"unlocked"}function mPe(e){const t=e.appearance;if(typeof t=="string"&&Q$t.includes(t))return t}function gPe(e){const t=e.sdtPr;if(!t)return;const n=hPe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],o=n["w:xpath"];if(!(!r||!o))return{storeItemId:r,xpath:o,prefixMappings:n["w:prefixMappings"]}}function Ko(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function hY(e){const t=(Ca(e,"w14:checkbox")??Ca(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 pY(e,t){const n=Ca(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 $$t(e,t){if(!t)return{};switch(e){case"text":{const n=hPe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=Ca(t,"w:date");if(!n)return{};const r=Ca(n,"w:dateFormat"),o=Ca(n,"w:lid"),i=Ca(n,"w:storeMappedDataAs"),s=Ca(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:o?.attributes?.["w:val"],storageFormat:i?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=Ca(t,"w14:checkbox")??Ca(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(i=>i.name==="w14:checkedState"),o=n.elements?.find(i=>i.name==="w14:uncheckedState");return{checked:hY(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:o?{font:String(o.attributes?.["w14:font"]??""),char:String(o.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return pY(t,e);case"repeatingSection":{const n=Ca(t,"w15:repeatingSection")??Ca(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(i=>i.name==="w15:allowInsertDeleteSection"||i.name==="w:allowInsertDeleteSection"),o=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:o==="1"||o==="true"||o===!0}}default:return{}}}function w0(e){const t=e.node.attrs,n=String(t.id??""),r=vm(t),o=kO(t),i=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=$$t(r,i);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:o,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:mPe(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:gPe(t),raw:i,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function een(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:vm(n),lockMode:kO(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:mPe(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 bl(e,t){const n=kO(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new Be("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Hh(e,t){const n=kO(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new Be("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Ea(e,t,n){const r=vm(e.node.attrs),o=Array.isArray(t)?t:[t];if(!o.includes(r))throw new Be("TYPE_MISMATCH",`Operation "${n}" requires control type ${o.join(" or ")}, but found "${r}".`,{expected:o,actual:r,operation:n})}function yPe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function zh(e,t){return{success:!1,failure:{code:e,message:t}}}function JE(e,t){const n=e.length,r=t?.offset??0,o=t?.limit??n;return{items:e.slice(r,r+o),total:n}}function ZE(e,t){const n=zn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"||r.nodeType==="heading"));if(n.length===0)throw new Be("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new Be("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function bPe(e,t,n){const r=ZE(e,t),o=ZE(e,n);if(r.pos>o.pos)throw new Be("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return zn(e).candidates.filter(i=>(i.nodeType==="paragraph"||i.nodeType==="listItem"||i.nodeType==="heading")&&i.pos>=r.pos&&i.pos<=o.pos)}function Md(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const o=r.elements.find(i=>i.name==="w:abstractNumId")?.attributes?.["w:val"];return o!=null?Number(o):void 0}function US(e){return zn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>CO(e,t))}function vl(e,t){if(t.numId==null)return[t];const n=US(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const o=t.numId;let i=r;for(let a=r-1;a>=0&&n[a].numId===o;a--)i=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===o;a++)s=a;return n.slice(i,s+1)}function vPe(e,t){const n=vl(e,t),r=n.findIndex(o=>o.address.nodeId===t.address.nodeId);return n.slice(r)}function wPe(e,t){const n=vl(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function ten(e,t){if(t.numId==null)return"";const n=vl(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function APe(e){const t=new Map;let n,r;for(const o of e){if(o.numId==null){t.set(o.address.nodeId,""),n=void 0,r=void 0;continue}o.numId!==n&&(n=o.numId,r=o.address.nodeId),t.set(o.address.nodeId,`${n}:${r}`)}return t}function VS(e,t,n){if(t.numId==null)return null;const r=US(e),o=vl(e,t);if(n==="withNext"){const i=o[o.length-1],s=r.findIndex(a=>a.address.nodeId===i.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:vl(e,l),numId:l.numId,abstractNumId:Md(e,l.numId)}}}else{const i=o[0],s=r.findIndex(a=>a.address.nodeId===i.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:vl(e,l),numId:l.numId,abstractNumId:Md(e,l.numId)}}}return null}function nen(e,t){if(t.numId==null)return null;const n=Md(e,t.numId);if(n==null)return null;const r=US(e),o=vl(e,t)[0],i=r.findIndex(s=>s.address.nodeId===o.address.nodeId);for(let s=i-1;s>=0;s--){const a=r[s];if(a.numId!=null&&Md(e,a.numId)===n&&a.numId!==t.numId)return{sequence:vl(e,a),numId:a.numId}}return null}function SPe(e,t,n){const r=VS(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 o=t.numId!=null?Md(e,t.numId):void 0;if(o==null||r.abstractNumId==null||o!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const i=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${i}`}}function TPe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=Md(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=US(e),o=vl(e,t)[0],i=r.findIndex(a=>a.address.nodeId===o.address.nodeId);let s=!1;for(let a=i-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,Md(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=vl(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 IPe(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:kf(n?.numId??r?.numId),level:kf(n?.ilvl??r?.ilvl)}}function ren(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=$n.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),o=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":void 0}catch{return}}function oen(e,t,n,r){const o=(t.node.attrs??{}).listRendering?.numberingType;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":ren(e,n,r)}function ien(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function CO(e,t){const n=t.node.attrs??{};let{numId:r,level:o}=IPe(t.node);if(r==null)try{const c=ml(e,t.node,e.state.doc.resolve(t.pos))?.numberingProperties;c&&(r=kf(c.numId),o=kf(c.ilvl)??o??0)}catch{}const i=Nk(n.listRendering),s=i?.path,a=tL(s),l=i?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:o,kind:oen(e,t,r,o),marker:l,path:s,ordinal:a,text:ien(t)}}function xPe(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 sen(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 aen(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 Be("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new Be("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function len(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function cen(e,t){if(t?.within&&t.within.kind!=="block")throw new Be("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});m0(t?.offset,t?.limit);const n=zn(e),r=aen(n,t?.within),o=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>CO(e,f)),i=o.filter(f=>len(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=or(e),c=APe(o);let u=0;const d=[];for(const f of i){if(!sen(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=xPe(f,p),g=Li(m.address.nodeId,"stable","list"),{address:y,marker:b,ordinal:v,path:A,level:S,kind:w,text:T}=m;d.push(cs(m.address.nodeId,g,{address:y,listId:p,marker:b,ordinal:v,path:A,level:S,kind:w,text:T}))}return ji({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function uen(e){const{numId:t}=IPe(e.node);return t!=null?!0:Nk((e.node.attrs??{}).listRendering)!=null}function is(e,t){const n=zn(e);let r=n.candidates.filter(o=>o.nodeType==="listItem"&&o.nodeId===t.nodeId);if(r.length===0&&(r=n.candidates.filter(o=>o.nodeId===t.nodeId&&uen(o))),r.length===0)throw new Be("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(r.length>1)throw new Be("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:r.length});return CO(e,r[0])}var den=new Set(["text","date","checkbox","comboBox","dropDownList"]),kPe=new WeakMap;function fen(e){const t=e.state.doc,n=kPe.get(e),r=RPe(e);if(n&&n.doc===t)return CPe(n.counts,r);const o=hen(e);return kPe.set(e,{doc:t,counts:o}),CPe(o,r)}function hen(e){const t=aY(e,{}),n=zn(e),r=f0(e),o=pen(n),i=men(r);return{words:EPe(t),characters:t.length,paragraphs:o.paragraphs,headings:o.headings,tables:o.tables,images:o.blockImages+i,comments:gen(r),trackedChanges:yen(e),sdtFields:ben(e),lists:ven(e,n)}}function CPe(e,t){return t!=null?{...e,pages:t}:{...e}}function EPe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function pen(e){let t=0,n=0,r=0,o=0;for(const i of e.candidates)switch(i.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":o++;break}return{paragraphs:t,headings:n,tables:r,blockImages:o}}function men(e){return e.byType.get("image")?.length??0}function gen(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const o=nO(r.attrs??{});o&&n.add(o)}return n.size}function yen(e){return KE(e).length}function ben(e){return v0(e.state.doc).filter(t=>den.has(vm(t.node.attrs??{}))).length}function ven(e,t){const n=wen(e,t);if(n.length===0)return 0;const r=APe(n);let o=0,i,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==i&&(o+=1),i=l,s=void 0;continue}i=void 0,(!s||Aen(s,a))&&(o+=1),s=a}return o}function wen(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>CO(e,n))}function Aen(e,t){return Sen(e,t)?!0:Ten(e,t)}function Sen(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function Ten(e,t){const n=_Pe(e),r=_Pe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function _Pe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function RPe(e){return e.currentTotalPages}function GS(e){const t=aY(e,{});return{words:EPe(t),characters:Ien(t),charactersWithSpaces:xen(t),pages:RPe(e)}}function EO(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 lv(e){return e.options?.parentEditor??e}function Ien(e){return e.replace(/\s/g,"").length}function xen(e){return e.replace(/\n/g,"").length}function PPe(e){const t=new Map,n=GS(lv(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const o=EO(r,n);o!=null&&t.set(r,o)}return t}const mY="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",ken="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",Cen="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var NPe="/APA.XSL",LPe="APA",MPe="6",DPe=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"}),Een=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"}),gY=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"}),_en=Object.freeze(Object.fromEntries(Object.entries(gY).map(([e,t])=>[t,e])));function A0(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function _O(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function WS(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function RO(e,t){const n=t??dq;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function OPe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(A0(n.name)==="Person"){t.push(n);continue}OPe(n,t)}}}function Ren(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=A0(n.name),o=_O(n);o&&(r==="First"&&(t.first=o),r==="Middle"&&(t.middle=o),r==="Last"&&(t.last=o))}return typeof t.last=="string"&&t.last.length>0?t:null}function yY(e,t){const n=(e?.elements??[]).find(o=>o?.type==="element"&&A0(o.name)===t);if(!n)return[];const r=[];return OPe(n,r),r.map(Ren).filter(Boolean)}function Pen(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():"",o=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(WS("b:Last",n)),r&&t.push(WS("b:First",r)),o&&t.push(WS("b:Middle",o)),{type:"element",name:"b:Person",elements:t}}function Nen(e){const t=(e??[]).map(Pen).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function bY(e,t){const n=Nen(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 Len(e){return DPe[typeof e=="string"?e.trim():""]??DPe.misc}function Men(e){return Een[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function vY(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",o=e.fields&&typeof e.fields=="object"?e.fields:{},i={};for(const s of Object.keys(gY)){const a=o[s];typeof a=="string"&&a.trim().length>0&&(i[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=o[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&&(i[s]=l)}return{tag:n,type:r,fields:i}}function Den(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=A0(a.name);if(l==="Tag"){n=_O(a);continue}if(l==="SourceType"){r=Men(_O(a));continue}const c=_en[l];if(!c)continue;const u=_O(a);u&&(t[c]=u)}const o=yY(e,"Author");o.length>0&&(t.authors=o);const i=yY(e,"Editor");i.length>0&&(t.editor=i);const s=yY(e,"Translator");return s.length>0&&(t.translator=s),vY({tag:n,type:r,fields:t})}function Oen(e){const t=vY(e);if(!t)return null;const n=[WS("b:Tag",t.tag),WS("b:SourceType",Len(t.type))];for(const[s,a]of Object.entries(gY)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(WS(`b:${a}`,l))}const r=bY("Author",t.fields?.authors);r&&n.push(r);const o=bY("Editor",t.fields?.editor);o&&n.push(o);const i=bY("Translator",t.fields?.translator);return i&&n.push(i),{type:"element",name:"b:Source",elements:n}}function Fen(e){if(!e||e.type!=="element"||A0(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 FPe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function Ben(e){return e.startsWith("customXml/")?`../${e}`:e}function Hen(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>A0(n.name)==="Relationships")||null}function zen(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=RO({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=>A0(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 Uen(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const o=/^rId(\d+)$/.exec(r);return o?Number.parseInt(o[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function Ven(e){const t=new Set;for(const r of Object.keys(e??{})){const o=/customXml\/item(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10));const i=/customXml\/itemProps(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function Gen(e,t){const n=e.map(Oen).filter(Boolean),r=t.selectedStyle||NPe,o=t.styleName||LPe,i=t.version||MPe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":mY,xmlns:mY,SelectedStyle:r,StyleName:o,Version:i},elements:n}}function Wen(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function jen(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":mY}}]}]}}function qen(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:Cen,Target:e}}]}}function BPe(e){const t=new Map;for(const n of e){const r=vY(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function wY(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function HPe(e){const t=wY(),n=Hen(e);if(!n?.elements?.length)return t;const r=[];for(const o of n.elements){if(o?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const i=o?.attributes?.Target,s=jp(i,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(Fen(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=FPe(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"||A0(l.name)!=="Source")continue;const c=Den(l);c&&r.push(c)}}}return t.sources=BPe(r),t}function Ken(e,t){const n=HPe(e),r=BPe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...wY(),sources:[]};const o=t?.partPath||n.partPath,i=FPe(o),s=i??Ven(e),a=i?o:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??NPe,d=t?.styleName??n.styleName??LPe,f=t?.version??n.version??MPe,h=e[a]?.declaration;e[a]=RO(Gen(r,{selectedStyle:u,styleName:d,version:f}),h);const p=zen(e),m=Ben(a);p.elements.some(v=>v?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:jp(v?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:Uen(p),Type:ken,Target:m}});const g=e[l],y=g?.declaration;e[l]=RO(jen(Wen(g)||`{${hn().toUpperCase()}}`),y);const b=e[c]?.declaration;return e[c]=RO(qen(`itemProps${s}.xml`),b),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function Yen(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var Xen=sc(kg(),1),Jen=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"}),zPe="sans-serif",Zen=10,Qen="1.44.2",$en="SuperdocDocumentOrigin",etn=new Set(["word","google-docs","unknown","superdoc"]),UPe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:o})=>{if(!e?.elements?.length||!o)return;const i=e.elements.find(l=>l.name==="w:rFonts");if(i?.attributes){const l=i.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!o.typeface)&&u.typeface&&(o.typeface=u.typeface),(t||!o.panose)&&u.panose&&(o.panose=u.panose)}const c=i.attributes["w:ascii"];(t||!o.typeface)&&c&&(o.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)){o.fallbackSzTwips===void 0&&(o.fallbackSzTwips=l);const c=l/2;(n||o.fontSizePt===void 0)&&(o.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||o.kern===void 0)&&(o.kern=a.attributes["w:val"])},Bu=class Ei{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 o=r.elements.find(i=>i.name==="w:fonts");return o?.elements?.length&&o.elements.find(i=>i?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=Ei.getFontTableEntry(t,n)?.elements?.find(o=>o.name==="w:family")?.attributes?.["w:val"];return r?Jen[r.toLowerCase()]||zPe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=Ei.getFallbackFromFontTable(n,t)||zPe;return r.split(",").map(o=>o.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.wordIdAllocator=null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=wY(),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 xzt}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]=dCe(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"]=dCe(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(Xen.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 o=new Ei,i=r.content,s=o.parseXmlToJson(i)?.elements?.find(l=>Ei._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>Ei._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,o=!1){try{const i="docProps/custom.xml";t[i]||(t[i]=ttn());const s=t[i].elements?.find(d=>Ei._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=Ei._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>Ei._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&o)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)Ei._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(i){return console.warn(`Error setting custom property ${n}:`,i),null}}static getStoredSuperdocVersion(t){return Ei.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=Qen){return Ei.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"||Ei._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||Ei._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(i=>i.name==="cp:coreProperties"||Ei._matchesElementName(i.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let o=r.elements.find(i=>i.name==="dcterms:created"||Ei._matchesElementName(i.name,"created"));o?.elements?.[0]?o.elements[0].text=t:(o={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(o))}static extractDocumentGuid(t){try{const n=t.find(i=>i.name==="word/settings.xml");if(!n)return null;const r=new Ei().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const o=r.elements?.find(i=>i.name==="w15:docId");if(o?.attributes?.["w15:val"])return o.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return Ei.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?Ei.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=Ei.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(Ei.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Ufe(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${hn().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-${hn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Ufe(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${hn().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=hn()),n||this.setDocumentCreatedTimestamp(Ei.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||hn(),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"),o={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},i=n?.elements?.find(l=>l.name==="w:rPrDefault");UPe(i?.elements?.find(l=>l.name==="w:rPr")??i,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),UPe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),o.fontSizePt===void 0&&(Number.isFinite(o.fallbackSzTwips)?o.fontSizePt=o.fallbackSzTwips/2:o.fontSizePt=Zen);const s=o.typeface?Ei.toCssFontFamily(o.typeface,this.convertedXml):void 0,a={};return o.fontSizePt!==void 0&&(a.fontSizePt=o.fontSizePt),o.kern!==void 0&&(a.kern=o.kern),o.typeface&&(a.typeface=o.typeface),o.panose&&(a.panose=o.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,o=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,i=r||(o?o.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return i&&!f.includes(i)&&f.push(i),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")||{},o=[];let i="";for(const s of n){const a=r.find(b=>b.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)continue;const l=this.fonts[`word/${a}`];if(!l?.buffer)continue;const c=Xfe(l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength),s.attributes["w:fontKey"]);if(!c)continue;const u=cEe(c);if(!(u&&u.embeddable))continue;const d=new Blob([c],{type:"font/ttf"}),f=URL.createObjectURL(d),h=s.name.includes("Regular"),p=s.name.includes("Bold"),m=s.name.includes("Italic"),g=s.name.includes("Light"),y=h?"normal":p?"bold":g?"200":"normal";o.includes(s.fontFamily)||o.push(s.fontFamily),i+=`
100
+ `,{textModel:"visible"})}const nPe=e=>{const t=e?.doc;if(!t)return[];const n=[];try{t.descendants((r,o)=>{if(r.isText)return!1;const i=r?.attrs?.paragraphProperties?.change;i&&typeof i.id=="string"&&i.id&&i.paragraphProperties&&n.push({id:i.id,from:o,to:o+r.nodeSize,author:i.author||"",authorEmail:i.authorEmail||"",authorImage:i.authorImage||"",date:i.date||"",formerProperties:i.paragraphProperties||{},subtype:"paragraph-format"})})}catch{return n}return n};function iv(e,t){return e!=="structural"?e:t?.subtype==="table-delete"||t?.side==="deletion"?"delete":"insert"}function L$t(e,t){return e[0]<t[1]&&t[0]<e[1]}function rPe(e){try{const t=Ic(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function M$t(e){return e.rawId}function qE(e){return e.structural?"structural":e.hasFormat?"format":e.hasInsert&&e.hasDelete?"replacement":e.hasDelete?"delete":"insert"}var oPe=new WeakMap;function D$t(e){return e?.options?.trackedChanges?.replacements==="independent"?"independent":"paired"}function iPe(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function O$t(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function lY(e,t,n){const r=xr(e.sourceId);return r?`word:${t}:${r}`:n}function sPe(e){return e==="trackInsert"||e==="trackDelete"||e==="trackFormat"}function F$t(e){const t=[e.rawId,e.commandRawId,e.id,xr(e.attrs.id),xr(e.attrs.replacementGroupId),xr(e.attrs.sourceId)];return Array.from(new Set(t.filter(n=>!!n)))}function B$t(e){if(e.hasInsert===e.hasDelete)return null;const t=xr(e.attrs.replacementGroupId);return t?`group:${t}`:e.commandRawId?`command:${e.commandRawId}`:null}function H$t(e,t){const n=new Map;if(t==="paired"){const r=new Map;for(const o of e){if(o.hasInsert&&o.hasDelete)continue;const i=B$t(o);if(!i)continue;const s=r.get(i)??[];s.push(o),r.set(i,s)}for(const o of r.values()){const i=o.find(a=>a.hasInsert&&!a.hasDelete),s=o.find(a=>a.hasDelete&&!a.hasInsert);!i||!s||(n.set(i,i.id),n.set(s,i.id))}}for(const r of e)n.has(r)||n.set(r,r.id);return n}function aPe(e,t){const n=qE(e);return{id:e.id,rawId:e.rawId,commandRawId:e.commandRawId,type:iv(n,e.structural),relationship:t}}function z$t(e,t){const n=iv(qE(e),e.structural),r=iv(qE(t),t.structural);if(n!==r){if(n==="delete")return-1;if(r==="delete")return 1}return e.from!==t.from?e.from-t.from:e.id.localeCompare(t.id)}function U$t(e){if(e.length<2)return;const t=new Map;for(const r of e)for(const o of F$t(r))t.has(o)||t.set(o,r);const n=new Map;for(const r of e){const o=xr(r.attrs.overlapParentId);if(!o)continue;const i=t.get(o);if(!i||i===r)continue;const s=n.get(i)??[];s.push(r),n.set(i,s)}for(const[r,o]of n.entries()){const i=o.slice().sort(z$t),s=[aPe(r,"parent"),...i.map(l=>aPe(l,"child"))],a=s.find(l=>l.relationship==="child"&&l.type==="delete")??s.find(l=>l.relationship==="child");r.overlap={visualLayers:s,...a?{preferredContextTargetId:a.id,preferredContextTarget:a}:{}}}}function lPe(e){const t=e.type.name;if(!sPe(t))return null;const n=e.attrs??{},r=xr(n.id);return r?lY(n,t,r):null}function V$t(e,t){return t?(Array.isArray(e.node?.marks)?e.node.marks:[]).some(n=>{const r=n?.type?.name;return sPe(r)?xr(n?.attrs?.overlapParentId)===t:!1}):!1}function G$t(e,t){const n=t.node?.text;return typeof n=="string"?n:e.state.doc.textBetween(t.from,t.to," ","")}function W$t(e,t){return cPe(e.mark,t)}function cPe(e,t){const n=e.attrs??{},r=xr(n.id);if(!r)return!1;const o=e.type.name,i=lY(n,o,r);return i===t.rawId||i===t.id||r===t.commandRawId||r===t.id}function j$t(e,t){let n=null,r=null;try{e.state.doc.nodesBetween(t.from,t.to,(o,i)=>{if(n)return!1;if(!o.isText)return!0;if(!(Array.isArray(o.marks)?o.marks:[]).some(a=>cPe(a,t)))return!1;const s=typeof o.text=="string"?o.text.length:o.nodeSize;if(s>1){const a=i+1;return n={from:a,to:a},!1}return!r&&s>0&&(r={from:i,to:i+s}),!1})}catch{return null}return n??r}function uPe(e,t){const n=cY(e,t);if(!n||n.structural)return null;const r=j$t(e,n);if(r)return r;const o=rPe(e).filter(a=>W$t(a,n)).filter(a=>Number.isFinite(a.from)&&Number.isFinite(a.to)&&a.to>a.from).sort((a,l)=>a.from!==l.from?a.from-l.from:a.to-l.to),i=o.find(a=>a.to-a.from>1);if(i){const a=i.from+1;return{from:a,to:a}}const s=o[0];if(s)return{from:s.from,to:s.to};if(n.to>n.from){if(n.to-n.from>1){const a=n.from+1;return{from:a,to:a}}return{from:n.from,to:n.to}}return null}function KE(e){const t=e.state.doc,n=oPe.get(e);if(n&&n.doc===t)return n.grouped;const r=rPe(e),o=new Map,i=new Map;for(const u of r){const d=u.mark?.attrs??{},f=xr(d.id);if(!f)continue;const h=u.mark.type.name,p=lY(d,h,f),m=o.get(p),g=h===Ki,y=h===ui,b=h===vs,v=xr(d.sourceId),A=O$t(h),S=!v||!V$t(u,f)?G$t(e,u):"",w=[u.from,u.to],T=i.get(p);if(T?T.push({from:u.from,to:u.to}):i.set(p,[{from:u.from,to:u.to}]),!m){o.set(p,{rawId:p,commandRawId:f,from:u.from,to:u.to,hasInsert:g,hasDelete:y,hasFormat:b,attrs:{...d},excerptParts:S?[S]:[],excerptRanges:S?[w]:[],wordRevisionIds:A?iPe(void 0,A,v??void 0):void 0});continue}m.from=Math.min(m.from,u.from),m.to=Math.max(m.to,u.to),m.hasInsert=m.hasInsert||g,m.hasDelete=m.hasDelete||y,m.hasFormat=m.hasFormat||b,Object.keys(m.attrs).length===0&&Object.keys(d).length>0&&(m.attrs={...d}),S&&!m.excerptRanges.some(x=>L$t(x,w))&&(m.excerptRanges.push(w),m.excerptParts.push(S)),A&&(m.wordRevisionIds=iPe(m.wordRevisionIds,A,v??void 0))}const s=Array.from(o.values()).map(({excerptParts:u,excerptRanges:d,...f})=>{const h=!!xr(f.attrs.sourceId),p=u.join(""),m={...f,excerpt:u.length>0?p:h?"":void 0};return{...m,id:M$t(m)}}).sort((u,d)=>u.from!==d.from?u.from-d.from:u.id.localeCompare(d.id));U$t(s);const a=BS(e.state),l=a.filter(u=>u.decidable&&u.wholeTable).map(u=>({from:u.tableFrom,to:u.tableTo}));if(l.length>0){const u=d=>l.some(f=>d.from>=f.from&&d.to<=f.to);for(let d=s.length-1;d>=0;d-=1){const f=s[d];(i.get(f.rawId)??[{from:f.from,to:f.to}]).every(u)&&s.splice(d,1)}}for(const u of a){const d=NE(e.state.doc.textBetween(u.tableFrom,u.tableTo," ","")),f=u.sourceId?`word:structural:${u.sourceId}`:u.id;s.push({rawId:f,commandRawId:u.id,id:f,from:u.tableFrom,to:u.tableTo,hasInsert:!1,hasDelete:!1,hasFormat:!1,structural:{side:u.side,subtype:u.subtype},attrs:{id:u.id,sourceId:u.sourceId||void 0,author:u.author||void 0,authorEmail:u.authorEmail||void 0,authorImage:u.authorImage||void 0,date:u.date||void 0,importedAuthor:u.importedAuthor||void 0,origin:u.sourceId?"word":void 0,revisionGroupId:u.revisionGroupId||void 0},excerpt:d,wordRevisionIds:u.sourceId?u.side==="insertion"?{insert:u.sourceId}:{delete:u.sourceId}:void 0})}const c=nPe(e.state);for(const u of c){const d=NE(e.state.doc.textBetween(u.from,u.to," ",""));s.push({rawId:u.id,commandRawId:u.id,id:u.id,from:u.from,to:u.to,hasInsert:!1,hasDelete:!1,hasFormat:!0,attrs:{id:u.id,author:u.author||void 0,authorEmail:u.authorEmail||void 0,authorImage:u.authorImage||void 0,date:u.date||void 0},excerpt:d})}return s.sort((u,d)=>u.from!==d.from?u.from-d.from:u.id.localeCompare(d.id)),oPe.set(e,{doc:t,grouped:s}),s}function cY(e,t){const{baseId:n}=dY(t);return KE(e).find(r=>r.id===n)??null}function uY(e){const t=KE(e),n=H$t(t,D$t(e)),r=new Map;for(const o of t){const i=n.get(o)??o.id;r.set(o.rawId,i),r.set(o.id,i),o.commandRawId&&r.set(o.commandRawId,i);const s=xr(o.attrs.replacementGroupId);s&&r.set(s,i),r.set(i,i),r.set(`${i}#inserted`,i),r.set(`${i}#deleted`,i)}return r}function dY(e){return e.endsWith("#inserted")?{baseId:e.slice(0,-9),side:"inserted"}:e.endsWith("#deleted")?{baseId:e.slice(0,-8),side:"deleted"}:{baseId:e,side:null}}function q$t(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function sv(e,t){const n=q$t(t),r=n.entityId,o=n.story??{kind:"story",storyType:"body"};if((n.story?Ti(n.story):"body")==="body"){const a=dPe(e,r);return a?{editor:e,story:o,runtimeRef:{storyKey:If,rawId:a.rawId},change:a}:null}let i;try{i=yl(e,o)}catch{return null}const s=dPe(i.editor,r);return s?{editor:i.editor,story:i.locator,runtimeRef:{storyKey:i.storyKey,rawId:s.rawId},change:s,commit:i.commit}:null}function dPe(e,t){const{baseId:n}=dY(t);return KE(e).find(r=>r.id===n||r.rawId===n||r.commandRawId===n)??null}const fPe=["structuredContent","structuredContentBlock"],YE="structuredContentBlock",K$t="structuredContent";function XE(e){return fPe.includes(e.type.name)}function v0(e){const t=[];return e.descendants((n,r)=>(XE(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function Rn(e,t){const n=t.nodeId,r=v0(e).filter(o=>String(o.node.attrs.id)===n);if(r.length===0)throw new Be("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new Be("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function Ca(e,t){return e?.elements?.find(n=>n.name===t)}function hPe(e,t){return Ca(e,t)?.attributes}function xO(e,t,n){const r=e.elements?[...e.elements]:[],o=r.findIndex(i=>i.name===t);return o>=0?r[o]=n:r.push(n),{...e,elements:r}}function pPe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var Y$t=new Set(fPe);function av(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((i,s)=>r!==null?!1:Y$t.has(i.type.name)&&String(i.attrs.id)===String(t)?(r=s,!1):!0),r===null)return!1;const o=e.state.tr;for(const[i,s]of Object.entries(n))o.setNodeAttribute(r,i,s);if(o.steps.length===0)return!0;if(e.view?.dispatch)e.view.dispatch(o);else if(typeof e.dispatch=="function")e.dispatch(o);else return!1;return!0}function Pf(e,t,n,r){const o=Rn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},i=r(Ca(o,n));let s;return i===null?s=pPe(o,n):s=xO(o,n,i),av(e,t.nodeId,{sdtPr:s})}function fY(e,t,n,r,o,i){return Pf(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:{[o]:i}};return c>=0?l[c]={...l[c],attributes:{...l[c].attributes??{},[o]:i}}:l.push(u),{...a,elements:l}})}function X$t(e,t,n,r){return Pf(e,t,n,o=>({name:n,type:"element",...o,elements:r}))}var J$t=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],Z$t=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],Q$t=["boundingBox","tags","hidden"];function vm(e){const t=e.controlType??e.type;return typeof t=="string"&&J$t.includes(t)?t:"unknown"}function kO(e){const t=e.lockMode;return typeof t=="string"&&Z$t.includes(t)?t:"unlocked"}function mPe(e){const t=e.appearance;if(typeof t=="string"&&Q$t.includes(t))return t}function gPe(e){const t=e.sdtPr;if(!t)return;const n=hPe(t,"w:dataBinding");if(!n)return;const r=n["w:storeItemID"],o=n["w:xpath"];if(!(!r||!o))return{storeItemId:r,xpath:o,prefixMappings:n["w:prefixMappings"]}}function Ko(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function hY(e){const t=(Ca(e,"w14:checkbox")??Ca(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 pY(e,t){const n=Ca(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 $$t(e,t){if(!t)return{};switch(e){case"text":{const n=hPe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=Ca(t,"w:date");if(!n)return{};const r=Ca(n,"w:dateFormat"),o=Ca(n,"w:lid"),i=Ca(n,"w:storeMappedDataAs"),s=Ca(n,"w:calendar");return{dateFormat:r?.attributes?.["w:val"],dateLocale:o?.attributes?.["w:val"],storageFormat:i?.attributes?.["w:val"],calendar:s?.attributes?.["w:val"]}}case"checkbox":{const n=Ca(t,"w14:checkbox")??Ca(t,"w:checkbox");if(!n)return{};const r=n.elements?.find(i=>i.name==="w14:checkedState"),o=n.elements?.find(i=>i.name==="w14:uncheckedState");return{checked:hY(t),checkedSymbol:r?{font:String(r.attributes?.["w14:font"]??""),char:String(r.attributes?.["w14:val"]??"")}:void 0,uncheckedSymbol:o?{font:String(o.attributes?.["w14:font"]??""),char:String(o.attributes?.["w14:val"]??"")}:void 0}}case"comboBox":case"dropDownList":return pY(t,e);case"repeatingSection":{const n=Ca(t,"w15:repeatingSection")??Ca(t,"w:repeatingSection");if(!n)return{};const r=n.elements?.find(i=>i.name==="w15:allowInsertDeleteSection"||i.name==="w:allowInsertDeleteSection"),o=r?.attributes?.["w15:val"]??r?.attributes?.["w:val"];return{allowInsertDelete:o==="1"||o==="true"||o===!0}}default:return{}}}function w0(e){const t=e.node.attrs,n=String(t.id??""),r=vm(t),o=kO(t),i=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=$$t(r,i);return{nodeType:"sdt",kind:e.kind,id:n,controlType:r,lockMode:o,properties:{tag:typeof t.tag=="string"?t.tag:void 0,alias:typeof t.alias=="string"?t.alias:void 0,appearance:mPe(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:gPe(t),raw:i,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function een(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:vm(n),lockMode:kO(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:mPe(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 bl(e,t){const n=kO(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new Be("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Hh(e,t){const n=kO(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new Be("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Ea(e,t,n){const r=vm(e.node.attrs),o=Array.isArray(t)?t:[t];if(!o.includes(r))throw new Be("TYPE_MISMATCH",`Operation "${n}" requires control type ${o.join(" or ")}, but found "${r}".`,{expected:o,actual:r,operation:n})}function yPe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function zh(e,t){return{success:!1,failure:{code:e,message:t}}}function JE(e,t){const n=e.length,r=t?.offset??0,o=t?.limit??n;return{items:e.slice(r,r+o),total:n}}function ZE(e,t){const n=zn(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"||r.nodeType==="heading"));if(n.length===0)throw new Be("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new Be("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function bPe(e,t,n){const r=ZE(e,t),o=ZE(e,n);if(r.pos>o.pos)throw new Be("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return zn(e).candidates.filter(i=>(i.nodeType==="paragraph"||i.nodeType==="listItem"||i.nodeType==="heading")&&i.pos>=r.pos&&i.pos<=o.pos)}function Md(e,t){const n=e.converter?.numbering?.definitions;if(!n)return;const r=n[t];if(!r?.elements)return;const o=r.elements.find(i=>i.name==="w:abstractNumId")?.attributes?.["w:val"];return o!=null?Number(o):void 0}function US(e){return zn(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>CO(e,t))}function vl(e,t){if(t.numId==null)return[t];const n=US(e),r=n.findIndex(a=>a.address.nodeId===t.address.nodeId);if(r===-1)return[t];const o=t.numId;let i=r;for(let a=r-1;a>=0&&n[a].numId===o;a--)i=a;let s=r;for(let a=r+1;a<n.length&&n[a].numId===o;a++)s=a;return n.slice(i,s+1)}function vPe(e,t){const n=vl(e,t),r=n.findIndex(o=>o.address.nodeId===t.address.nodeId);return n.slice(r)}function wPe(e,t){const n=vl(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function ten(e,t){if(t.numId==null)return"";const n=vl(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function APe(e){const t=new Map;let n,r;for(const o of e){if(o.numId==null){t.set(o.address.nodeId,""),n=void 0,r=void 0;continue}o.numId!==n&&(n=o.numId,r=o.address.nodeId),t.set(o.address.nodeId,`${n}:${r}`)}return t}function VS(e,t,n){if(t.numId==null)return null;const r=US(e),o=vl(e,t);if(n==="withNext"){const i=o[o.length-1],s=r.findIndex(a=>a.address.nodeId===i.address.nodeId);for(let a=s+1;a<r.length;a++){const l=r[a];if(l.numId!=null)return{sequence:vl(e,l),numId:l.numId,abstractNumId:Md(e,l.numId)}}}else{const i=o[0],s=r.findIndex(a=>a.address.nodeId===i.address.nodeId);for(let a=s-1;a>=0;a--){const l=r[a];if(l.numId!=null)return{sequence:vl(e,l),numId:l.numId,abstractNumId:Md(e,l.numId)}}}return null}function nen(e,t){if(t.numId==null)return null;const n=Md(e,t.numId);if(n==null)return null;const r=US(e),o=vl(e,t)[0],i=r.findIndex(s=>s.address.nodeId===o.address.nodeId);for(let s=i-1;s>=0;s--){const a=r[s];if(a.numId!=null&&Md(e,a.numId)===n&&a.numId!==t.numId)return{sequence:vl(e,a),numId:a.numId}}return null}function SPe(e,t,n){const r=VS(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 o=t.numId!=null?Md(e,t.numId):void 0;if(o==null||r.abstractNumId==null||o!==r.abstractNumId)return{canJoin:!1,reason:"INCOMPATIBLE_DEFINITIONS"};const i=r.sequence[0]?.address.nodeId??"";return{canJoin:!0,adjacentListId:`${r.numId}:${i}`}}function TPe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=Md(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=US(e),o=vl(e,t)[0],i=r.findIndex(a=>a.address.nodeId===o.address.nodeId);let s=!1;for(let a=i-1;a>=0;a--){const l=r[a];if(l.numId==null||(s=!0,Md(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=vl(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 IPe(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:kf(n?.numId??r?.numId),level:kf(n?.ilvl??r?.ilvl)}}function ren(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=$n.getListDefinitionDetails({numId:t,level:n,listType:void 0,editor:e}),o=typeof r?.listNumberingType=="string"?r.listNumberingType:void 0;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":void 0}catch{return}}function oen(e,t,n,r){const o=(t.node.attrs??{}).listRendering?.numberingType;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":ren(e,n,r)}function ien(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function CO(e,t){const n=t.node.attrs??{};let{numId:r,level:o}=IPe(t.node);if(r==null)try{const c=ml(e,t.node,e.state.doc.resolve(t.pos))?.numberingProperties;c&&(r=kf(c.numId),o=kf(c.ilvl)??o??0)}catch{}const i=Nk(n.listRendering),s=i?.path,a=tL(s),l=i?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:o,kind:oen(e,t,r,o),marker:l,path:s,ordinal:a,text:ien(t)}}function xPe(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 sen(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 aen(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 Be("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new Be("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function len(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function cen(e,t){if(t?.within&&t.within.kind!=="block")throw new Be("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});m0(t?.offset,t?.limit);const n=zn(e),r=aen(n,t?.within),o=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>CO(e,f)),i=o.filter(f=>len(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=or(e),c=APe(o);let u=0;const d=[];for(const f of i){if(!sen(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=xPe(f,p),g=Li(m.address.nodeId,"stable","list"),{address:y,marker:b,ordinal:v,path:A,level:S,kind:w,text:T}=m;d.push(cs(m.address.nodeId,g,{address:y,listId:p,marker:b,ordinal:v,path:A,level:S,kind:w,text:T}))}return ji({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function uen(e){const{numId:t}=IPe(e.node);return t!=null?!0:Nk((e.node.attrs??{}).listRendering)!=null}function is(e,t){const n=zn(e);let r=n.candidates.filter(o=>o.nodeType==="listItem"&&o.nodeId===t.nodeId);if(r.length===0&&(r=n.candidates.filter(o=>o.nodeId===t.nodeId&&uen(o))),r.length===0)throw new Be("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(r.length>1)throw new Be("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:r.length});return CO(e,r[0])}var den=new Set(["text","date","checkbox","comboBox","dropDownList"]),kPe=new WeakMap;function fen(e){const t=e.state.doc,n=kPe.get(e),r=RPe(e);if(n&&n.doc===t)return CPe(n.counts,r);const o=hen(e);return kPe.set(e,{doc:t,counts:o}),CPe(o,r)}function hen(e){const t=aY(e,{}),n=zn(e),r=f0(e),o=pen(n),i=men(r);return{words:EPe(t),characters:t.length,paragraphs:o.paragraphs,headings:o.headings,tables:o.tables,images:o.blockImages+i,comments:gen(r),trackedChanges:yen(e),sdtFields:ben(e),lists:ven(e,n)}}function CPe(e,t){return t!=null?{...e,pages:t}:{...e}}function EPe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function pen(e){let t=0,n=0,r=0,o=0;for(const i of e.candidates)switch(i.nodeType){case"paragraph":t++;break;case"heading":n++;break;case"table":r++;break;case"image":o++;break}return{paragraphs:t,headings:n,tables:r,blockImages:o}}function men(e){return e.byType.get("image")?.length??0}function gen(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const o=nO(r.attrs??{});o&&n.add(o)}return n.size}function yen(e){return KE(e).length}function ben(e){return v0(e.state.doc).filter(t=>den.has(vm(t.node.attrs??{}))).length}function ven(e,t){const n=wen(e,t);if(n.length===0)return 0;const r=APe(n);let o=0,i,s;for(const a of n){const l=r.get(a.address.nodeId)??"";if(l){l!==i&&(o+=1),i=l,s=void 0;continue}i=void 0,(!s||Aen(s,a))&&(o+=1),s=a}return o}function wen(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>CO(e,n))}function Aen(e,t){return Sen(e,t)?!0:Ten(e,t)}function Sen(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function Ten(e,t){const n=_Pe(e),r=_Pe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function _Pe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function RPe(e){return e.currentTotalPages}function GS(e){const t=aY(e,{});return{words:EPe(t),characters:Ien(t),charactersWithSpaces:xen(t),pages:RPe(e)}}function EO(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 lv(e){return e.options?.parentEditor??e}function Ien(e){return e.replace(/\s/g,"").length}function xen(e){return e.replace(/\n/g,"").length}function PPe(e){const t=new Map,n=GS(lv(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const o=EO(r,n);o!=null&&t.set(r,o)}return t}const mY="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",ken="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",Cen="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var NPe="/APA.XSL",LPe="APA",MPe="6",DPe=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"}),Een=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"}),gY=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"}),_en=Object.freeze(Object.fromEntries(Object.entries(gY).map(([e,t])=>[t,e])));function A0(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function _O(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function WS(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function RO(e,t){const n=t??dq;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function OPe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(A0(n.name)==="Person"){t.push(n);continue}OPe(n,t)}}}function Ren(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=A0(n.name),o=_O(n);o&&(r==="First"&&(t.first=o),r==="Middle"&&(t.middle=o),r==="Last"&&(t.last=o))}return typeof t.last=="string"&&t.last.length>0?t:null}function yY(e,t){const n=(e?.elements??[]).find(o=>o?.type==="element"&&A0(o.name)===t);if(!n)return[];const r=[];return OPe(n,r),r.map(Ren).filter(Boolean)}function Pen(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():"",o=typeof e.middle=="string"?e.middle.trim():"";return n&&t.push(WS("b:Last",n)),r&&t.push(WS("b:First",r)),o&&t.push(WS("b:Middle",o)),{type:"element",name:"b:Person",elements:t}}function Nen(e){const t=(e??[]).map(Pen).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function bY(e,t){const n=Nen(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 Len(e){return DPe[typeof e=="string"?e.trim():""]??DPe.misc}function Men(e){return Een[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function vY(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",o=e.fields&&typeof e.fields=="object"?e.fields:{},i={};for(const s of Object.keys(gY)){const a=o[s];typeof a=="string"&&a.trim().length>0&&(i[s]=a.trim())}for(const s of["authors","editor","translator"]){const a=o[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&&(i[s]=l)}return{tag:n,type:r,fields:i}}function Den(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=A0(a.name);if(l==="Tag"){n=_O(a);continue}if(l==="SourceType"){r=Men(_O(a));continue}const c=_en[l];if(!c)continue;const u=_O(a);u&&(t[c]=u)}const o=yY(e,"Author");o.length>0&&(t.authors=o);const i=yY(e,"Editor");i.length>0&&(t.editor=i);const s=yY(e,"Translator");return s.length>0&&(t.translator=s),vY({tag:n,type:r,fields:t})}function Oen(e){const t=vY(e);if(!t)return null;const n=[WS("b:Tag",t.tag),WS("b:SourceType",Len(t.type))];for(const[s,a]of Object.entries(gY)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(WS(`b:${a}`,l))}const r=bY("Author",t.fields?.authors);r&&n.push(r);const o=bY("Editor",t.fields?.editor);o&&n.push(o);const i=bY("Translator",t.fields?.translator);return i&&n.push(i),{type:"element",name:"b:Source",elements:n}}function Fen(e){if(!e||e.type!=="element"||A0(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 FPe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function Ben(e){return e.startsWith("customXml/")?`../${e}`:e}function Hen(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>A0(n.name)==="Relationships")||null}function zen(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=RO({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=>A0(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 Uen(e){const t=(e?.elements??[]).map(n=>{const r=n?.attributes?.Id;if(typeof r!="string")return NaN;const o=/^rId(\d+)$/.exec(r);return o?Number.parseInt(o[1],10):NaN}).filter(n=>Number.isFinite(n));return`rId${(t.length>0?Math.max(...t):0)+1}`}function Ven(e){const t=new Set;for(const r of Object.keys(e??{})){const o=/customXml\/item(\d+)\.xml$/i.exec(r);o&&t.add(Number.parseInt(o[1],10));const i=/customXml\/itemProps(\d+)\.xml$/i.exec(r);i&&t.add(Number.parseInt(i[1],10))}let n=1;for(;t.has(n);)n+=1;return n}function Gen(e,t){const n=e.map(Oen).filter(Boolean),r=t.selectedStyle||NPe,o=t.styleName||LPe,i=t.version||MPe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":mY,xmlns:mY,SelectedStyle:r,StyleName:o,Version:i},elements:n}}function Wen(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function jen(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":mY}}]}]}}function qen(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:Cen,Target:e}}]}}function BPe(e){const t=new Map;for(const n of e){const r=vY(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function wY(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function HPe(e){const t=wY(),n=Hen(e);if(!n?.elements?.length)return t;const r=[];for(const o of n.elements){if(o?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")continue;const i=o?.attributes?.Target,s=jp(i,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(Fen(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=FPe(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"||A0(l.name)!=="Source")continue;const c=Den(l);c&&r.push(c)}}}return t.sources=BPe(r),t}function Ken(e,t){const n=HPe(e),r=BPe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...wY(),sources:[]};const o=t?.partPath||n.partPath,i=FPe(o),s=i??Ven(e),a=i?o:`customXml/item${s}.xml`,l=`customXml/itemProps${s}.xml`,c=`customXml/_rels/item${s}.xml.rels`,u=t?.selectedStyle??n.selectedStyle??NPe,d=t?.styleName??n.styleName??LPe,f=t?.version??n.version??MPe,h=e[a]?.declaration;e[a]=RO(Gen(r,{selectedStyle:u,styleName:d,version:f}),h);const p=zen(e),m=Ben(a);p.elements.some(v=>v?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:jp(v?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:Uen(p),Type:ken,Target:m}});const g=e[l],y=g?.declaration;e[l]=RO(jen(Wen(g)||`{${hn().toUpperCase()}}`),y);const b=e[c]?.declaration;return e[c]=RO(qen(`itemProps${s}.xml`),b),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function Yen(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var Xen=sc(kg(),1),Jen=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"}),zPe="sans-serif",Zen=10,Qen="1.45.0",$en="SuperdocDocumentOrigin",etn=new Set(["word","google-docs","unknown","superdoc"]),UPe=(e,{allowOverrideTypeface:t=!0,allowOverrideSize:n=!0,themeResolver:r,state:o})=>{if(!e?.elements?.length||!o)return;const i=e.elements.find(l=>l.name==="w:rFonts");if(i?.attributes){const l=i.attributes["w:asciiTheme"];if(l){const u=r?.(l)||{};(t||!o.typeface)&&u.typeface&&(o.typeface=u.typeface),(t||!o.panose)&&u.panose&&(o.panose=u.panose)}const c=i.attributes["w:ascii"];(t||!o.typeface)&&c&&(o.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)){o.fallbackSzTwips===void 0&&(o.fallbackSzTwips=l);const c=l/2;(n||o.fontSizePt===void 0)&&(o.fontSizePt=c)}}const a=e.elements.find(l=>l.name==="w:kern");a?.attributes?.["w:val"]&&(n||o.kern===void 0)&&(o.kern=a.attributes["w:val"])},Bu=class Ei{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 o=r.elements.find(i=>i.name==="w:fonts");return o?.elements?.length&&o.elements.find(i=>i?.attributes?.["w:name"]===n)||null}static getFallbackFromFontTable(t,n){const r=Ei.getFontTableEntry(t,n)?.elements?.find(o=>o.name==="w:family")?.attributes?.["w:val"];return r?Jen[r.toLowerCase()]||zPe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=Ei.getFallbackFromFontTable(n,t)||zPe;return r.split(",").map(o=>o.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.wordIdAllocator=null,this.addedMedia={},this.comments=[],this.footnotes=[],this.footnoteProperties=null,this.bibliographyPart=wY(),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 xzt}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]=dCe(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"]=dCe(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(Xen.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 o=new Ei,i=r.content,s=o.parseXmlToJson(i)?.elements?.find(l=>Ei._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>Ei._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,o=!1){try{const i="docProps/custom.xml";t[i]||(t[i]=ttn());const s=t[i].elements?.find(d=>Ei._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=Ei._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>Ei._matchesElementName(d.name,"property")&&d.attributes?.name===n);if(c&&o)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)Ei._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(i){return console.warn(`Error setting custom property ${n}:`,i),null}}static getStoredSuperdocVersion(t){return Ei.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=Qen){return Ei.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"||Ei._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||Ei._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(i=>i.name==="cp:coreProperties"||Ei._matchesElementName(i.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let o=r.elements.find(i=>i.name==="dcterms:created"||Ei._matchesElementName(i.name,"created"));o?.elements?.[0]?o.elements[0].text=t:(o={type:"element",name:"dcterms:created",attributes:{"xsi:type":"dcterms:W3CDTF"},elements:[{type:"text",text:t}]},r.elements.push(o))}static extractDocumentGuid(t){try{const n=t.find(i=>i.name==="word/settings.xml");if(!n)return null;const r=new Ei().parseXmlToJson(n.content).elements?.[0];if(!r)return null;const o=r.elements?.find(i=>i.name==="w15:docId");if(o?.attributes?.["w15:val"])return o.attributes["w15:val"].replace(/[{}]/g,"")}catch{}return Ei.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?Ei.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=Ei.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(Ei.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Ufe(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${hn().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-${hn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Ufe(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${hn().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=hn()),n||this.setDocumentCreatedTimestamp(Ei.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||hn(),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"),o={typeface:void 0,panose:void 0,fontSizePt:void 0,kern:void 0,fallbackSzTwips:void 0},i=n?.elements?.find(l=>l.name==="w:rPrDefault");UPe(i?.elements?.find(l=>l.name==="w:rPr")??i,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),UPe(r?.elements?.find(l=>l.name==="w:rPr")??null,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),o.fontSizePt===void 0&&(Number.isFinite(o.fallbackSzTwips)?o.fontSizePt=o.fallbackSzTwips/2:o.fontSizePt=Zen);const s=o.typeface?Ei.toCssFontFamily(o.typeface,this.convertedXml):void 0,a={};return o.fontSizePt!==void 0&&(a.fontSizePt=o.fontSizePt),o.kern!==void 0&&(a.kern=o.kern),o.typeface&&(a.typeface=o.typeface),o.panose&&(a.panose=o.panose),s&&(a.fontFamilyCss=s),a}getDocumentFonts(){const t=[...new Set(this.inlineDocumentFonts||[])],n=this.getDocumentDefaultStyles?.()||{},r=typeof n.typeface=="string"?n.typeface:null,o=typeof n.fontFamilyCss=="string"?n.fontFamilyCss:null,i=r||(o?o.split(",")[0]?.replace(/["']/g,"").trim():null),s=d=>{const f=[...d];return i&&!f.includes(i)&&f.push(i),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")||{},o=[];let i="";for(const s of n){const a=r.find(b=>b.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)continue;const l=this.fonts[`word/${a}`];if(!l?.buffer)continue;const c=Xfe(l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength),s.attributes["w:fontKey"]);if(!c)continue;const u=cEe(c);if(!(u&&u.embeddable))continue;const d=new Blob([c],{type:"font/ttf"}),f=URL.createObjectURL(d),h=s.name.includes("Regular"),p=s.name.includes("Bold"),m=s.name.includes("Italic"),g=s.name.includes("Light"),y=h?"normal":p?"bold":g?"200":"normal";o.includes(s.fontFamily)||o.push(s.fontFamily),i+=`
101
101
  @font-face {
102
102
  font-style: ${m?"italic":"normal"};
103
103
  font-weight: ${y};
@@ -813,7 +813,7 @@ function print() { __p += __j.call(arguments, '') }
813
813
  `;tn(),Yn();var Wkn={class:"search-input-ctn"},jkn={class:"sd-row"},qkn=["onKeydown"],Kkn={__name:"SearchInput",props:{searchRef:{type:Object}},emits:["submit"],setup(e,{emit:t}){const n=Ne(""),r=t,o=()=>{r("submit",{value:n.value})};return(i,s)=>(Ge(),it("div",Wkn,[yt("div",jkn,[of(yt("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:lf(rr(o,["stop","prevent"]),["enter"])},null,40,qkn),[[Fp,n.value]])]),yt("div",{class:"sd-row sd-submit"},[yt("button",{class:"sd-submit-btn",onClick:o},"Apply")])]))}},Ykn=jn(Kkn,[["__scopeId","data-v-d25821a5"]]);function $6e(e=AS){return pEe(e).map(t=>({label:t.logicalFamily,key:xq(t),fontWeight:400,props:{style:{fontFamily:_Gt(t)},"data-item":"btn-fontFamily-option"}}))}const Xkn=$6e(AS);function eBe(e){return String(e??"").trim().toLowerCase()}function Jkn(e,t){return String(e.label??"").trim().localeCompare(String(t.label??"").trim(),"en",{sensitivity:"base"})}function Zkn(e,t,n=AS){if(t)return t;if(!n.packConfigured&&!e?.length)return;const r=$6e(n),o=new Set(r.map(s=>eBe(s.label))),i=[...r];for(const s of e??[]){const a=eBe(s.logicalFamily);o.has(a)||(o.add(a),i.push({label:s.logicalFamily,key:s.logicalFamily,fontWeight:400,props:{style:{fontFamily:s.previewFamily||s.logicalFamily},"data-item":"btn-fontFamily-option"}}))}return i.sort(Jkn)}const Qkn=[{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"}}],W_={sm:768,md:1024,lg:1280,xl:1410},G5={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",tableOfContents:"table-of-contents-insert",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},tBe={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"},nBe=Object.values(tBe),$kn=[...new Set([...Object.values(G5),...nBe])];var eCn=new Set(["link"]);const rBe=new Set(Object.keys(G5).filter(e=>!eCn.has(e)));tn();var $h=e=>{e.expand.value=!1};const tCn=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=_o({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??Xkn).map(zIn),u=_o({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:Ie}={},j=!1)=>{if(j){u.label.value="",u.selectedValue.value="";return}if(!Ie)return;Ie=Ie.split(",")[0],u.label.value=Ie;const we=c.find(ue=>ue.label===u.defaultLabel.value),Je=c.find(ue=>ue.label===Ie);Je?u.selectedValue.value=Je.key:we?u.selectedValue.value=we.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const Ie=c.find(j=>j.label===u.defaultLabel.value);Ie?u.selectedValue.value=Ie.key:u.selectedValue.value=""}}),d=_o({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 Ie="";if(e.activeEditor){const{state:we}=e.activeEditor,{from:Je,to:ue,empty:Ke}=we.selection;Ie=Ke?"":we.doc.textBetween(Je,ue)}return sa("div",{},[sa(H5,{handleClose:()=>{$h(d)},selectedText:Ie,editor:e.activeEditor,apiKey:e.config.aiApiKey,endpoint:e.config.aiEndpoint,superToolbar:e})])}}]}),f=Qkn,h=_o({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:Ie},j=!1)=>{if(j){h.label.value="",h.selectedValue.value="";return}const we=f.find(ze=>ze.label===String(h.defaultLabel.value));if(!Ie){h.label.value=h.defaultLabel.value,we?h.selectedValue.value=we.key:h.selectedValue.value="";return}let Je=BIn(Ie,12);Je<8&&(Je=8),Je>96&&(Je=96);let ue=String(Je);const Ke=f.find(ze=>ze.label===ue||ze.key===ue);Ke?h.selectedValue.value=Ke.key:h.selectedValue.value="",h.label.value=ue},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const Ie=f.find(j=>j.label===String(h.defaultLabel.value));Ie?h.selectedValue.value=Ie.key:h.selectedValue.value=""}}),p=_o({type:"separator",name:"separator",isNarrow:!0}),m=_o({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),g=_o({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),y=_o({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),b=_o({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:()=>BZ(e,b,[],!0)}],onActivate:({color:Ie})=>{b.iconColor.value=Ie||""},onDeactivate:()=>b.iconColor.value=""}),v=_o({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:()=>BZ(e,v)}],onActivate:({color:Ie})=>{v.iconColor.value=Ie},onDeactivate:()=>v.iconColor.value="#000"}),A=Ne(null),S=_o({type:"dropdown",name:"search",active:!1,icon:t.search,tooltip:n.search,group:"right",inputRef:A,attributes:{ariaLabel:"Search"},options:[{type:"render",key:"searchDropdown",render:()=>w()}]}),w=()=>sa("div",{},[sa(Ykn,{onSubmit:({value:j})=>{e.activeEditor.commands.search(j,{searchModel:"visible"})},searchRef:A})]),T=_o({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>x(T)}],onActivate:({href:Ie})=>{Ie?T.attributes.value={href:Ie}:T.attributes.value={}},onDeactivate:()=>{T.attributes.value={},T.expand.value=!1}});function x(Ie){return sa("div",{},[sa(G_,{editor:e.activeEditor,closePopover:()=>$h(Ie),goToAnchor:()=>{if($h(Ie),!e.activeEditor||!Ie.attributes.value?.href)return;const j=Ie.attributes.value?.href?.slice(1),we=e.activeEditor.element.querySelector(`a[name='${j}']`);we&&Vkn(we)}})])}const C=_o({type:"options",name:"linkInput",command:"toggleLink",active:!1});T.childItem=C,C.parentItem=T;const k=_o({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),P=_o({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),E=_o({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:()=>L(E)}]});function L(Ie){return sa("div",{},[sa(Z6e,{onSelect:we=>{e.emitCommand({item:Ie,argument:we}),$h(Ie)}})])}const R=_o({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(R)}]}),M=[{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(Ie){return sa(Q6e,{options:M,onSelect:j=>{$h(Ie);const{command:we}=j;e.emitCommand({item:Ie,argument:{command:we}})}})}const H=_o({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:()=>sa("div",{},[sa(Gxn,{onSelect:j=>{$h(H);const we={...H,command:"setTextAlign"};we.command="setTextAlign",e.emitCommand({item:we,argument:j}),W(H,j)}})]),key:"alignment"}],onActivate:({textAlign:Ie})=>{W(H,Ie)},onDeactivate:()=>{W(H,"left")}}),W=(Ie,j)=>{let we=j==="both"?"justify":j,Je={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},ue=Je[we]??Je.left;Ie.icon.value=ue},G=_o({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Ie=j=>{$h(G);const we={...G,command:"toggleBulletListStyle"};e.emitCommand({item:we,argument:j})};return sa(Y6e,{buttons:qxn,iconSize:25,selectedStyle:G.selectedValue.value,onSelect:Ie})}}]}),U=_o({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Ie=j=>{$h(U);const we={...U,command:"toggleOrderedListStyle"};e.emitCommand({item:we,argument:j})};return sa(Y6e,{buttons:Kxn,iconSize:30,selectedStyle:U.selectedValue.value,onSelect:Ie})}}]}),F=_o({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),ne=_o({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),Y=_o({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),ve=_o({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:Ie})=>{Ie&&(ve.label.value=Ie)}}),Z=_o({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),X=_o({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),ae=_o({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),he=_o({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),Ae=_o({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),ke=_o({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),_e=(Ie,j)=>Ie==="editor"?j:Ie==="suggester"?j.filter(we=>we.value==="suggesting"):j.filter(we=>we.value==="viewing"),B=Ie=>Ie==="editor"?"Editing":Ie==="suggester"?"Suggesting":"Viewing",D=_o({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:B(s),label:B(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:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>V(D)}]}),N=[{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 V(Ie){return sa(tkn,{options:_e(s,N),onSelect:j=>{$h(Ie);const{label:we,icon:Je}=j;D.label.value=we,D.icon.value=Je,e.emitCommand({item:D,argument:we})}})}const re=new Map([["separator",20],["zoom",71],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["ai",32],["default",32]]),J=_o({type:"button",name:"ruler",command:"toggleRuler",icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),K=_o({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),$=Ne(null),me=_o({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:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Ie=j=>{$h(me);const we={...me,command:"setLinkedStyle"};e.emitCommand({item:we,argument:j}),$.value=j.id};return sa("div",{},[sa(ikn,{editor:e.activeEditor,onSelect:Ie,selectedOption:$.value})])}}],onActivate:({styleId:Ie})=>{const j=SJ(e.activeEditor)?.find(we=>we.id===Ie);me.label.value=j&&j.id!=="Normal"?j.definition.attrs.name:n.formatText,me.disabled.value=!1},onDeactivate:()=>{me.disabled.value=!0,me.label.value=n.formatText}}),ye=(Ie,j)=>{if(j.value==Ie)return sa("div",{innerHTML:Gkn,class:"dropdown-select-icon"})},ee=_o({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(Ie=>({label:Ie.toFixed(2),key:Ie,icon:()=>ye(Ie,ee.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),de=20,be=120,oe=32,te=["linkedStyles","clearFormatting","copyFormat","ruler","formattingMarks"],xe=["zoom","fontFamily","fontSize","redo"],Ce=i<=W_.lg,De=e.config?.showFormattingMarksButton===!0,Ve=e.config?.showTableOfContentsButton===!0;Ce&&(D.attributes.value={...D.attributes.value,className:`${D.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),Ce&&(me.attributes.value={...me.attributes.value,className:`${me.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let at=[Z,X,ae,he,ve,u,p,h,p,l,m,g,y,v,b,p,T,k,...Ve?[P]:[],E,R,p,H,G,U,F,ne,ee,p,me,p,J,...De?[K]:[],ke,Ae,d,Y,D];if(e.config?.superdoc?.config?.modules?.ai||(at=at.filter(Ie=>Ie.name.value!=="ai")),i<=W_.md&&o&&(at=at.filter(Ie=>Ie.type!=="separator")),e.config.mode!=="docx"){const Ie=at.findIndex(we=>we.name.value==="linkedStyles");at.splice(Ie-1,2);const j=["ruler","zoom","undo","redo"];at=at.filter(we=>!j.includes(we.name.value))}const ce=[];a||(s==="viewer"&&ce.push(ae,he),at=at.filter(Ie=>!ce.includes(Ie)));const pe=[S,Z,Y,D].map(Ie=>Ie.name),Re=Ie=>pe.includes(Ie.name),le=[],ge=[];let Q=oe+be;return at.forEach(Ie=>{const j=re.get(Ie.name.value)||re.get("default");if(i<W_.xl+de&&te.includes(Ie.name.value)&&o){if(le.push(Ie),Ie.name.value==="linkedStyles"){const we=at.findIndex(Je=>Je.name.value==="linkedStyles");at.splice(we+1,1)}return}if(i<W_.sm&&xe.includes(Ie.name.value)&&o){le.push(Ie);return}if(Re(Ie)){ge.push(Ie),Q+=j;return}Q<i||!o?(ge.push(Ie),Q+=j):le.push(Ie)}),{defaultItems:ge,overflowItems:le.filter(Ie=>Ie.type!=="separator")}};tn(),Yn();var nCn={class:"sd-toolbar-icon"},rCn=["innerHTML"],oCn={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ut(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ut(()=>["color","highlight"].includes(t.name));return(o,i)=>(Ge(),it("div",nCn,[yt("div",{class:gr(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,rCn),r.value?(Ge(),it("div",{key:0,class:"color-bar",style:Cn(n.value)},null,4)):Ht("",!0)]))}},oBe=jn(oCn,[["__scopeId","data-v-521c3d93"]]);tn(),Yn();var iCn=["role","aria-label"],sCn=["data-item"],aCn=["data-item"],lCn={key:1,class:"sd-button-label"},cCn=["data-item","aria-label"],uCn=["innerHTML"],dCn={key:1,class:"sd-button-label"},fCn={key:2,class:"sd-toolbar-button__field sd-toolbar-split-field__main"},hCn=["onKeydown","id"],pCn=["placeholder","onKeydown","id"],mCn=["data-item","aria-label","disabled"],gCn=["innerHTML"],yCn=["innerHTML"],bCn={"aria-live":"polite",class:"sd-visually-hidden"},vCn={__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},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick","tabOut"],setup(e,{emit:t}){const n=t,r=e,{name:o,active:i,icon:s,label:a,hideLabel:l,iconColor:c,hasCaret:u,splitButton:d,disabled:f,expand:h,inlineTextInputVisible:p,hasInlineTextInput:m,minWidth:g,style:y,attributes:b}=r.toolbarItem,v=ut(()=>!!d?.value&&!!u?.value),A=ut(()=>o?.value==="fontSize"&&!!m?.value&&!!u?.value),S=Ne(a),w=Ne(null),{isHighContrastMode:T}=Qh(),x=()=>{En(()=>{w.value?.select()})},C=()=>{m&&En(()=>{w.value?.focus(),x()}),n("buttonClick")},k=W=>{f?.value||(W?.stopPropagation(),n("mainClick"))},P=()=>{v.value||C()},E=W=>{if(v.value){k(W);return}C()},L=W=>{r.allowEnterPropagation||W.stopPropagation(),E(W)},R=()=>{const W=S.value,G=W.match(/^\d+(\.5)?$/)?W:Math.floor(parseFloat(W)).toString();n("textSubmit",G),S.value=G},M=W=>{o?.value==="fontSize"&&(W.preventDefault(),R(),w.value?.blur(),n("tabOut",W))},O=ut(()=>y.value?y.value:{minWidth:r.minWidth}),H=ut(()=>h?.value?Yi.dropdownCaretUp:Yi.dropdownCaretDown);return(W,G)=>(Ge(),it("div",{class:gr(["sd-toolbar-item",kt(b).className]),style:Cn(O.value),role:e.isOverflowItem?"menuitem":"button","aria-label":kt(b).ariaLabel,"data-sd-part":"toolbar-item",onClick:P,onKeydown:G[5]||(G[5]=lf(U=>L(U),["enter"])),tabindex:"0"},[yt("div",{class:gr(["sd-toolbar-button",{"sd-active":kt(i),"sd-disabled":kt(f),narrow:e.isNarrow,wide:e.isWide,split:v.value,"split-field":A.value,"sd-toolbar-split-field":A.value,"has-inline-text-input":kt(m),"high-contrast":kt(T)}]),"data-item":`btn-${kt(o)||""}`},[v.value?(Ge(),it("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${kt(o)||""}-main`,onClick:G[0]||(G[0]=U=>k(U))},[kt(s)?(Ge(),wr(oBe,{key:0,color:kt(c),class:"sd-toolbar-icon",icon:kt(s),name:kt(o)},null,8,["color","icon","name"])):Ht("",!0),kt(a)&&!kt(l)&&!kt(p)?(Ge(),it("div",lCn,Zn(kt(a)),1)):Ht("",!0)],8,aCn)):Ht("",!0),v.value?(Ge(),it("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${kt(o)||""}-caret`,"aria-label":`${kt(b).ariaLabel} options`,role:"button"},[yt("div",{class:"sd-dropdown-caret",innerHTML:H.value,style:Cn({opacity:kt(f)?.6:1})},null,12,uCn)],8,cCn)):(Ge(),it(On,{key:2},[kt(s)?(Ge(),wr(oBe,{key:0,color:kt(c),class:"sd-toolbar-icon",icon:kt(s),name:kt(o)},null,8,["color","icon","name"])):Ht("",!0),kt(a)&&!kt(l)&&!kt(p)?(Ge(),it("div",dCn,Zn(kt(a)),1)):Ht("",!0),kt(p)?(Ge(),it("span",fCn,[kt(o)==="fontSize"?of((Ge(),it("input",{key:0,"onUpdate:modelValue":G[1]||(G[1]=U=>S.value=U),onKeydown:[lf(rr(R,["prevent"]),["enter"]),lf(M,["tab"])],onFocus:x,onClick:G[2]||(G[2]=rr(()=>{},["stop"])),type:"text",class:gr(["button-text-input button-text-input--font-size",{"high-contrast":kt(T)}]),id:"inlineTextInput-"+kt(o),autocomplete:"off",ref_key:"inlineInput",ref:w},null,42,hCn)),[[Fp,S.value]]):of((Ge(),it("input",{key:1,"onUpdate:modelValue":G[3]||(G[3]=U=>S.value=U),placeholder:kt(a),onKeydown:lf(rr(R,["prevent"]),["enter"]),type:"text",class:"button-text-input",id:"inlineTextInput-"+kt(o),autocomplete:"off",ref_key:"inlineInput",ref:w},null,40,pCn)),[[Fp,S.value]])])):Ht("",!0),A.value?(Ge(),it("button",{key:3,type:"button",class:"sd-toolbar-button__field-caret sd-toolbar-split-field__caret","data-item":`btn-${kt(o)||""}-caret`,"aria-label":`${kt(b).ariaLabel} options`,disabled:kt(f),tabindex:"-1",onMousedown:G[4]||(G[4]=rr(()=>{},["prevent"]))},[yt("span",{class:"sd-dropdown-caret",innerHTML:H.value,style:Cn({opacity:kt(f)?.6:1})},null,12,gCn)],40,mCn)):kt(u)?(Ge(),it("div",{key:4,class:"sd-dropdown-caret",innerHTML:H.value,style:Cn({opacity:kt(f)?.6:1})},null,12,yCn)):Ht("",!0)],64)),yt("div",bCn,Zn(`${kt(b).ariaLabel} ${kt(i)?"selected":"unset"}`),1)],10,sCn)],46,iCn))}},zZ=jn(vCn,[["__scopeId","data-v-2caa0057"]]);tn(),Yn();var wCn={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},ACn={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=Qh(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(Ge(),it("div",wCn,[yt("div",{class:"separator-inner",style:Cn({backgroundColor:r()})},null,4)]))}},SCn=jn(ACn,[["__scopeId","data-v-d027f7fc"]]);tn(),Yn();var TCn={class:"overflow-menu"},ICn={class:"overflow-menu-trigger"},xCn={key:0,class:"overflow-menu_items",role:"group"},kCn={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=jc(),r=t,o=e,i=ut(()=>o.toolbarItem.expand.value),s=Ne(!1),a=ut(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},c=({item:d,argument:f})=>{n.$toolbar.emitCommand({item:d,argument:f})},u=d=>{d.key==="Escape"&&i.value&&!s.value&&(d.preventDefault(),r("close"))};return Do(()=>{document.addEventListener("keydown",u,!0)}),ti(()=>{document.removeEventListener("keydown",u,!0)}),(d,f)=>(Ge(),it("div",TCn,[yt("div",ICn,[Er(zZ,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(Ge(),it("div",xCn,[Er(j5,{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"])])):Ht("",!0)]))}},CCn=jn(kCn,[["__scopeId","data-v-35b48dff"]]);tn(),Yn();var ECn={class:"toolbar-dropdown"},_Cn=["onClick"],RCn={key:0,class:"toolbar-dropdown-option__icon"},PCn={class:"toolbar-dropdown-option__label"},W5='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',NCn={__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,o=Ne(null),i=Ne(null),s=Ne({top:"0px",left:"0px",maxHeight:"none"}),a=Ne([]),l=Ne(-1),c=ut(()=>!!n.show),u=ut(()=>n.options.some(Z=>Z?.type==="render")),d=ut(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),f=ut(()=>{const{class:Z,style:X,...ae}=d.value;return ae}),h=ut(()=>{const Z=d.value.class,X=n.options.length>0&&n.options.every(ae=>ae&&ae.type==="render");return["toolbar-dropdown-menu",Z,{"toolbar-dropdown-menu--render-only":X}]}),p=ut(()=>{const Z=d.value.style||{};return{...n.contentStyle,...Z}}),m=ut(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),g=Z=>{r("update:show",Z)},y=()=>{c.value&&g(!1)},b=()=>{if(!o.value)return;const Z=o.value.getBoundingClientRect(),X=i.value,ae=X?.offsetWidth??0,he=X?.scrollHeight??X?.offsetHeight??0,Ae=window.innerWidth||document.documentElement.clientWidth||0,ke=window.innerHeight||document.documentElement.clientHeight||0,_e=8,B=4,D=Z.bottom+B,N=Z.top-B,V=Math.max(0,ke-D-_e),re=Math.max(0,N-_e),J=V<he&&re>V,K=J?re:V,$=he?Math.min(he,K):K,me=J?Math.max(_e,N-$):D;let ye=Z.left;n.placement==="bottom-end"&&(ye=Z.right-ae);const ee=Math.max(_e,Ae-ae-_e);ye=Math.min(Math.max(_e,ye),ee),s.value={top:`${me}px`,left:`${ye}px`,maxHeight:`${K}px`}},v=()=>{n.disabled||g(!c.value)},A=Z=>typeof n.nodeProps!="function"?{}:n.nodeProps(Z)||{},S=Z=>{Z?.disabled||Z?.type!=="render"&&(r("select",Z?.key,Z),y())},w=Z=>Z?.type==="render",T=Z=>!Z?.disabled&&Z?.type!=="render",x=Z=>typeof Z?.icon=="function"||!!Z?.icon,C=Z=>typeof Z?.icon=="function"?Z.icon(Z):Z?.icon||null,k=Z=>Z?typeof Z=="string"?Z.split(/\s+/).includes("sd-selected"):Array.isArray(Z)?Z.some(k):typeof Z=="object"?!!Z["sd-selected"]:!1:!1,P=Z=>k(Z?.props?.class)||k(Z?.class),E=()=>n.options.map((Z,X)=>T(Z)?X:-1).filter(Z=>Z>=0),L=()=>{const Z=n.options.findIndex(X=>T(X)&&P(X));return Z>=0?Z:E()[0]??-1},R=(Z,X)=>{if(!Z){delete a.value[X];return}a.value[X]=Z},M=()=>{a.value.forEach((X,ae)=>{X&&X.setAttribute("tabindex",ae===l.value?"0":"-1")});const Z=a.value[l.value];Z&&typeof Z.focus=="function"&&(Z.focus(),Z.scrollIntoView?.({block:"nearest",inline:"nearest"}))},O=Z=>{const X=E();if(!X.length){l.value=-1;return}const ae=X.indexOf(l.value);if(ae<0){l.value=Z>0?X[0]:X[X.length-1];return}l.value=X[(ae+Z+X.length)%X.length]},H=()=>{let Z=n.options[l.value];if(!T(Z)){const X=E()[0];Z=X===void 0?null:n.options[X]}Z&&S(Z)},W=ek({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(Z){return()=>typeof Z.option.render!="function"?null:Z.option.render()}}),G=ek({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(Z){return()=>C(Z.option)}}),U=Z=>{if(!c.value)return;const X=Z.target;if(!(X instanceof Element))return;const ae=o.value?.contains(X),he=i.value?.contains(X);ae||he||y()},F=Ne(null),ne=()=>{const Z=o.value,X=document.activeElement;if(Z&&X instanceof HTMLElement&&Z.contains(X)){F.value=X;return}F.value=Z?.matches?.(W5)?Z:Z?.querySelector(W5)},Y=()=>{const Z=F.value;if(Z instanceof HTMLElement&&document.contains(Z)){Z.focus();return}const X=o.value;if(!X)return;const ae=X.matches?.(W5)?X:X.querySelector(W5);if(ae instanceof HTMLElement){ae.focus();return}X.setAttribute("tabindex","-1"),X.focus()},ve=Z=>{if(!c.value)return;const{key:X}=Z;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(X)){if(X==="Escape"){Z.preventDefault(),y(),En(()=>{requestAnimationFrame(Y)});return}if(!u.value){if(Z.preventDefault(),X==="ArrowDown"){O(1),M();return}if(X==="ArrowUp"){O(-1),M();return}X==="Enter"&&H()}}};return kn(c,async Z=>{if(!Z){l.value=-1,a.value=[];return}ne(),await En(),b(),!u.value&&(l.value=L(),await En(),M())},{immediate:!0}),kn(c,Z=>{Z?(document.addEventListener("pointerdown",U,!0),document.addEventListener("keydown",ve,!0),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)):(document.removeEventListener("pointerdown",U,!0),document.removeEventListener("keydown",ve,!0),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0))},{immediate:!0}),ti(()=>{document.removeEventListener("pointerdown",U,!0),document.removeEventListener("keydown",ve,!0),window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),(Z,X)=>(Ge(),it("div",ECn,[yt("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:v},[nk(Z.$slots,"trigger",{},void 0,!0)],512),(Ge(),wr(Jy,{to:"body"},[Er(E7,{name:"fade-in-scale-up-transition"},{default:Iu(()=>[c.value?(Ge(),it("div",Lp({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:h.value,style:m.value},f.value),[(Ge(!0),it(On,null,So(e.options,(ae,he)=>(Ge(),it("div",Lp({key:ae.key,ref_for:!0,ref:Ae=>R(Ae,he),class:["toolbar-dropdown-option",[ae.class,ae.props?.class,{"sd-disabled":ae.disabled,"sd-render":w(ae)}]],tabindex:"-1",onClick:Ae=>S(ae)},{ref_for:!0},{...ae.props,...A(ae)}),[w(ae)?(Ge(),wr(kt(W),{key:0,option:ae},null,8,["option"])):(Ge(),it(On,{key:1},[x(ae)?(Ge(),it("span",RCn,[Er(kt(G),{option:ae},null,8,["option"])])):Ht("",!0),yt("span",PCn,Zn(ae.label),1)],64))],16,_Cn))),128))],16)):Ht("",!0)]),_:1})]))]))}},LCn=jn(NCn,[["__scopeId","data-v-69732782"]]),iBe=e=>String(e??"").trim().toLowerCase();const j_=(e,t)=>{const n=iBe(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(iBe(t[r]).startsWith(n))return r;return-1},MCn=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=j_(r,t),i=o>=0?String(t[o]??""):"";return n&&o>=0&&i.length>r.length?{matchIndex:o,display:i,selectionStart:r.length,selectionEnd:i.length}:{matchIndex:o,display:r,selectionStart:r.length,selectionEnd:r.length}};var DCn=e=>{let t=String(e??"").trim();for(;t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"));)t=t.slice(1,-1).trim();return t};const OCn=e=>DCn((String(e??"").split(",")[0]??"").replace(/[\u0000-\u001f\u007f]/g,"")).replace(/\s+/g," ").trim();tn(),Yn();var FCn=["value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant"],BCn=["aria-label","disabled"],HCn=["innerHTML"],zCn=["id","aria-label"],UCn=["id","aria-selected","aria-label","onMousedown","onMouseenter"],VCn={class:"toolbar-dropdown-option__label"},GCn={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},WCn={__name:"FontFamilyCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t,{isHighContrastMode:o}=Qh(),i=Ne(null),s=Ne(null),a=Ne(null),l=Ne([]),c=Ne(!1),u=Ne(!1),d=Ne(-1),f=Ne(""),h=Ne(""),p=Ne(!1),m=Ne({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),g=ut(()=>n.item.nestedOptions?.value??[]),y=ut(()=>g.value.map(K=>String(K?.label??""))),b=ut(()=>String(n.item.label?.value??"")),v=ut(()=>!!n.item.disabled?.value),A=ut(()=>n.item.attributes?.value?.ariaLabel??"Font family"),S=ut(()=>c.value?h.value:b.value),w=ut(()=>`sd-fontfamily-listbox-${n.item.id?.value??"default"}`),T=K=>`${w.value}-option-${K}`,x=ut(()=>u.value&&d.value>=0?T(d.value):void 0),C=ut(()=>u.value?Yi.dropdownCaretUp:Yi.dropdownCaretDown),k=K=>{const $=String(K??"").trim().toLowerCase();return g.value.find(me=>String(me?.label??"").trim().toLowerCase()===$)?.props?.style?.fontFamily||K||n.uiFontFamily},P=ut(()=>({fontFamily:k(c.value?h.value:b.value)})),E=()=>{const K=n.item.selectedValue?.value;if(K){const $=g.value.findIndex(me=>me?.key===K);if($>=0)return $}return y.value.findIndex($=>$.toLowerCase()===b.value.toLowerCase())},L=(K,$)=>{const me=i.value;if(!(!me||typeof me.setSelectionRange!="function"))try{me.setSelectionRange(K,$)}catch{}},R=()=>{l.value[d.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},M=()=>{const K=s.value;if(!K)return;const $=K.getBoundingClientRect(),me=a.value,ye=me?.scrollHeight??me?.offsetHeight??0,ee=window.innerHeight||document.documentElement.clientHeight||0,de=window.innerWidth||document.documentElement.clientWidth||0,be=8,oe=4,te=$.bottom+oe,xe=$.top-oe,Ce=Math.max(0,ee-te-be),De=Math.max(0,xe-be),Ve=Ce<ye&&De>Ce,at=Ve?De:Ce,ce=ye?Math.min(ye,at):at,pe=Ve?Math.max(be,xe-ce):te,Re=Math.min(Math.max(be,$.left),Math.max(be,de-$.width-be));m.value={top:`${pe}px`,left:`${Re}px`,minWidth:`${$.width}px`,maxHeight:`${at}px`}},O=ut(()=>({position:"fixed",top:m.value.top,left:m.value.left,minWidth:m.value.minWidth,maxHeight:m.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),H=K=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=K)},W=(K,{focusInput:$=!1}={})=>{if(v.value||!g.value.length){H(!1);return}u.value=!0,H(!0),d.value=K??-1,$&&(c.value=!0,h.value=b.value,i.value?.focus()),En(()=>{M(),R()})},G=({syncItem:K=!0}={})=>{u.value=!1,d.value=-1,K&&H(!1)},U=()=>{G(),c.value=!1,f.value="",h.value=b.value},F=()=>{v.value||(r("item-clicked"),c.value=!0,f.value="",h.value=b.value,En(()=>L(0,h.value.length)))},ne=K=>{if(v.value)return;const $=document.activeElement===i.value;if(r("item-clicked"),c.value=!0,$||(f.value="",h.value=b.value,K.preventDefault(),i.value?.focus(),L(0,b.value.length)),!u.value){const me=j_(f.value,y.value);if(me>=0)W(me);else if($)W(-1);else{const ye=E();W(ye>=0?ye:0)}}},Y=K=>{const $=K.relatedTarget;$ instanceof Node&&s.value?.contains($)||$ instanceof Node&&a.value?.contains($)||U()},ve=K=>{if(p.value)return;const $=K.target,me=$.value,ye=typeof $.selectionStart=="number"?$.selectionStart:me.length,ee=typeof $.selectionEnd=="number"?$.selectionEnd:ye,de=typeof K.inputType=="string"&&K.inputType.startsWith("delete"),be=ye===me.length&&ee===me.length;f.value=me;const oe=MCn(me,y.value,{autocomplete:!de&&be});h.value=oe.display,$.value=oe.display,oe.display===me&&!be?L(ye,ee):L(oe.selectionStart,oe.selectionEnd),u.value&&(d.value=oe.matchIndex,En(R))},Z=K=>{p.value=!1,ve(K)},X=K=>{if(!g.value.length)return;const $=g.value.length;d.value=((d.value<0?K>0?-1:0:d.value)+K+$)%$,En(R)},ae=(K,$)=>{r("item-clicked"),r("command",{item:n.item,argument:K,option:$}),$&&(n.item.selectedValue.value=$.key)},he=K=>{K&&(ae(K.label,K),c.value=!1,f.value="",h.value=K.label,G())},Ae=()=>{if(u.value&&d.value>=0)return he(g.value[d.value]),!0;const K=j_(f.value,y.value);if(K>=0)return he(g.value[K]),!0;const $=OCn(f.value);return $?(ae($,null),c.value=!1,f.value="",h.value=$,G(),!0):!1},ke=K=>{if(!(K.isComposing||p.value||K.keyCode===229)&&!(K.ctrlKey||K.metaKey||K.altKey))switch(K.key){case"ArrowDown":if(K.preventDefault(),u.value)X(1);else{const $=j_(f.value,y.value),me=$>=0?$:E();W(me>=0?me:0)}break;case"ArrowUp":if(K.preventDefault(),u.value)X(-1);else{const $=j_(f.value,y.value),me=$>=0?$:E();W(me>=0?me:g.value.length-1)}break;case"Enter":K.preventDefault(),Ae()&&r("editor-handoff"),i.value?.blur();break;case"Tab":K.preventDefault(),Ae(),G(),i.value?.blur(),r("tab-out",K);break;case"Escape":K.preventDefault(),U(),En(()=>i.value?.focus());break;default:break}},_e=K=>{if(K.preventDefault(),!v.value)if(r("item-clicked"),c.value||(c.value=!0,h.value=b.value,i.value?.focus()),u.value)G();else{const $=E();W($>=0?$:0)}},B=(K,$)=>{K.preventDefault(),he($),r("editor-handoff"),i.value?.blur()},D=K=>{d.value=K},N=K=>{if(!u.value)return;const $=K.target;$ instanceof Element&&(s.value?.contains($)||a.value?.contains($)||G())};kn(u,K=>{K?(document.addEventListener("pointerdown",N,!0),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0)):(document.removeEventListener("pointerdown",N,!0),window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0),l.value=[])},{immediate:!0}),ti(()=>{document.removeEventListener("pointerdown",N,!0),window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)});const V=(K,$)=>{if(!K){delete l.value[$];return}l.value[$]=K},re=K=>K===d.value,J=K=>K?.key&&K.key===n.item.selectedValue?.value;return kn(b,K=>{c.value||(h.value=K)}),kn(()=>!!n.item.expand?.value,K=>{if(K&&!u.value){const $=E();W($>=0?$:0,{focusInput:!0});return}!K&&u.value&&G({syncItem:!1})}),(K,$)=>(Ge(),it("div",{ref_key:"rootRef",ref:s,class:gr(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":v.value,"high-contrast":kt(o)}]),style:Cn(n.item.style?.value),"data-item":"btn-fontFamily"},[yt("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:ne},[yt("input",{ref_key:"inputRef",ref:i,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:S.value,style:Cn(P.value),disabled:v.value,"aria-label":A.value,"aria-expanded":u.value?"true":"false","aria-controls":w.value,"aria-activedescendant":x.value,"aria-haspopup":"listbox","aria-autocomplete":"both",onFocus:F,onBlur:Y,onInput:ve,onKeydown:ke,onCompositionstart:$[0]||($[0]=me=>p.value=!0),onCompositionend:Z},null,44,FCn)],32),yt("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":"btn-fontFamily-toggle",tabindex:"-1","aria-label":`${A.value} options`,disabled:v.value,onMousedown:_e},[yt("span",{class:"sd-dropdown-caret",innerHTML:C.value},null,8,HCn)],40,BCn),(Ge(),wr(Jy,{to:"body"},[u.value?(Ge(),it("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:w.value,"aria-label":A.value,class:gr(["sd-font-combobox__listbox",{"high-contrast":kt(o)}]),style:Cn(O.value)},[(Ge(!0),it(On,null,So(g.value,(me,ye)=>(Ge(),it("div",Lp({key:me.key,ref_for:!0,ref:ee=>V(ee,ye),id:T(ye),role:"option",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":re(ye),"sd-selected":J(me)}],"aria-selected":J(me)?"true":"false","aria-label":`${A.value} - ${me.label}`},{ref_for:!0},me.props,{onMousedown:ee=>B(ee,me),onMouseenter:ee=>D(ye)}),[yt("span",VCn,Zn(me.label),1)],16,UCn))),128))],14,zCn)):Ht("",!0)])),yt("span",GCn,Zn(b.value),1)],6))}},jCn=jn(WCn,[["__scopeId","data-v-588a0c5f"]]);tn(),Yn();var qCn=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},autoHideDuration:{type:Number,default:0},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=crt(),r=Ne(!1),o=Ne(null),i=Ne(null),s=Ne({top:"0px",left:"0px"});let a=null,l=null,c=null;const u=ut(()=>["sd-tooltip-content",n.class]),d=ut(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),f=()=>{a&&(window.clearTimeout(a),a=null)},h=()=>{l&&(window.clearTimeout(l),l=null)},p=()=>{c&&(window.clearTimeout(c),c=null)},m=()=>{p(),!(t.autoHideDuration<=0)&&(c=window.setTimeout(()=>{c=null,b()},t.autoHideDuration))},g=()=>{if(!o.value||!i.value)return;const k=o.value.getBoundingClientRect(),P=i.value.offsetWidth,E=i.value.offsetHeight,L=window.innerWidth||document.documentElement.clientWidth||0,R=8;let M=k.left+k.width/2-P/2;M=Math.max(R,Math.min(M,L-P-R)),s.value={top:`${k.top-E-10}px`,left:`${M}px`}},y=async()=>{t.disabled||(f(),h(),!r.value&&(r.value=!0,await En(),g(),m()))},b=()=>{h(),f(),p(),r.value&&(r.value=!1)},v=()=>{if(f(),h(),!r.value){if(t.delay===0){y();return}l=window.setTimeout(()=>{l=null,y()},t.delay)}},A=()=>{if(h(),f(),!!r.value){if(t.duration===0){b();return}a=window.setTimeout(()=>{a=null,b()},t.duration)}},S=()=>{t.trigger==="hover"&&v()},w=()=>{t.trigger==="hover"&&A()},T=()=>{h(),f()},x=()=>{A()},C=k=>{k.key==="Escape"&&b()};return kn(()=>t.disabled,k=>{k&&b()}),kn(r,k=>{k?(window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),document.addEventListener("keydown",C,!0)):(window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),document.removeEventListener("keydown",C,!0))}),ti(()=>{h(),f(),p(),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),document.removeEventListener("keydown",C,!0)}),(k,P)=>(Ge(),it(On,null,[yt("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:S,onMouseleave:w,onFocusin:S,onFocusout:w},[nk(k.$slots,"trigger",{},void 0,!0)],544),(Ge(),wr(Jy,{to:"body"},[Er(E7,{name:"fade-in-scale-up-transition"},{default:Iu(()=>[r.value&&!e.disabled?(Ge(),it("div",{key:0,ref_key:"contentRef",ref:i,class:gr(u.value),style:Cn(d.value),onMouseenter:T,onMouseleave:x},[P[0]||(P[0]=yt("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),nk(k.$slots,"default",{},void 0,!0)],38)):Ht("",!0)]),_:3})]))],64))}}),UZ=jn(qCn,[["__scopeId","data-v-f0925f67"]]);tn(),Yn();var KCn=["data-toolbar-position"],YCn=["onKeydown","tabindex","data-item-id"],XCn={key:0},JCn={key:0},ZCn={key:0},QCn={key:0},VZ=3e3,$Cn={__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}=jc(),o=Ne([]),i=Ne(null),s=e,a=Ne(null),{isHighContrastMode:l}=Qh(),c=window.matchMedia("(max-width: 768px)").matches,u=ut(()=>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=N=>N.type==="button",f=N=>N.type==="dropdown",h=N=>N.type==="dropdown"&&N.name?.value==="fontFamily",p=N=>N.type==="separator",m=N=>N.type==="overflow",g=N=>!!N.nestedOptions?.value?.length,y=N=>{if(!N)return!1;const V=N.expand;return typeof V=="object"&&V!==null&&"value"in V?!!V.value:!!V},b=(N,V)=>{N?.expand&&(N.expand.value=V)},v=(N,V=null)=>{if(!N.disabled.value){if(m(N)){const re=!y(N);re&&w(),b(N,re),a.value=re?N:null,n("item-clicked");return}f(N)||(a.value&&f(a.value)&&y(a.value)&&w(),n("item-clicked"),n("command",{item:N,argument:V??N.argument?.value??null}))}},A=(N,V)=>{N.disabled.value||(a.value=null,n("command",{item:N,argument:V}))},S=N=>{if(N.disabled.value)return;w();const V=N.splitButtonCommand,re=N.command,J=V||re;if(!J)return;const K={...N,command:J};n("item-clicked"),n("command",{item:K,argument:null})},w=(N=null)=>{const V=r?.$toolbar?.toolbarItems||[],re=r?.$toolbar?.overflowItems||[],J=[...V,...re];(J.length?J:s.toolbarItems).forEach(K=>{if(K===N)return;const $=m(K)&&!s.fromOverflow;(f(K)||$)&&b(K,!1)}),(!N||a.value!==N)&&(a.value=null)},T=(N,V)=>{w(),n("command",{item:N,argument:N.dropdownValueKey.value?V[N.dropdownValueKey.value]:V.label,option:V}),N.selectedValue.value=V.key},x=N=>{w(N),n("item-clicked")},C=N=>{n("command",N)},k=()=>new Promise(N=>requestAnimationFrame(N)),P=()=>!!r?.$toolbar?.flushPendingMarkCommands?.(),E=()=>{P(),itn(r?.$toolbar?.activeEditor),G()},L=(N,V)=>{w(),P(),V.shiftKey?ve(N,-1,()=>Y()||G()):ve(N,1,!0)},R=(N,V)=>{if(w(),N.name.value==="fontSize"&&!V.shiftKey){E();return}V.shiftKey?Z(V,-1):Z(V,1)||G()},M=N=>N.nestedOptions?.value?.length?N.nestedOptions.value.map(V=>{const re=V?.type!=="render"&&N.selectedValue.value===V.key;return{...V,props:{...V.props,class:re?"sd-selected":""}}}):[],O=(N,V)=>({role:"menuitem",ariaLabel:`${V.attributes.value.ariaLabel} - ${N.label}`}),H=N=>{const V=N.target,re=N.target.closest(".sd-toolbar-item-ctn").nextElementSibling;re&&(V.setAttribute("tabindex","-1"),re.setAttribute("tabindex","0"),re.focus())},W=N=>{const V=N.target,re=N.target.closest(".sd-toolbar-item-ctn").previousElementSibling;re&&(V.setAttribute("tabindex","-1"),re.setAttribute("tabindex","0"),re.focus())},G=()=>{const N=r?.$toolbar?.activeEditor;if(N&&typeof N.focus=="function")return N.focus(),!0;const V=N?.view?.dom;return V instanceof HTMLElement?(V.focus(),!0):!1},U=N=>!(N instanceof HTMLElement)||N.classList.contains("sd-disabled")?null:N.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||N.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),F=()=>{if(o.value.length)return o.value;const N=document.querySelector(`.button-group[data-toolbar-position="${s.position}"]`);return N?Array.from(N.querySelectorAll(":scope > .sd-toolbar-item-ctn")):[]},ne=(N,V)=>{if(N<0)return!1;const re=F();let J=N+V;for(;J>=0&&J<re.length;){const K=re[J],$=U(K);if($ instanceof HTMLElement)return re[N]?.setAttribute("tabindex","-1"),K.setAttribute("tabindex","0"),$.focus(),!0;J+=V}return!1},Y=()=>{const N=i.value?.previousElementSibling;return N instanceof HTMLElement?(N.setAttribute("tabindex","0"),N.focus(),!0):!1},ve=async(N,V,re=!1)=>{if(await En(),await k(),!ne(N,V)){if(typeof re=="function"){re();return}re&&G()}},Z=(N,V)=>{const re=N.target.closest(".sd-toolbar-item-ctn");if(!(re instanceof HTMLElement))return!1;let J=V>0?re.nextElementSibling:re.previousElementSibling;for(;J;){const K=U(J);if(K instanceof HTMLElement)return re.setAttribute("tabindex","-1"),J.setAttribute("tabindex","0"),K.focus(),!0;J=V>0?J.nextElementSibling:J.previousElementSibling}return!1},X=N=>{const V=N.target.closest(".button-group").nextElementSibling;V?(V.setAttribute("tabindex","0"),V.focus()):G()},ae=N=>{const V=N.target.closest(".button-group").previousElementSibling;V&&(V.setAttribute("tabindex","0"),V.focus())},he=N=>{if(!N.disabled.value){if(f(N)){_e(!y(N),N);return}v(N,null,!1)}},Ae=(N,V)=>{const re=N.target.nodeName==="INPUT"||N.target.nodeName==="TEXTAREA",J=V.name.value==="fontSize"||V.name.value==="fontFamily";if(!(re&&J)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(N.key))switch(N.preventDefault(),N.key){case"Enter":case" ":case"Spacebar":he(V);break;case"Escape":w();break;case"ArrowRight":w(),H(N);break;case"ArrowLeft":w(),W(N);break;case"Tab":N.shiftKey?ae(N):X(N);break;default:break}},ke=N=>{const V=o.value.find(re=>!re.classList.contains("sd-disabled"));V&&(V.setAttribute("tabindex","0"),V.focus())},_e=(N,V)=>{if(n("item-clicked"),!N){w(),n("dropdown-update-show",!1);return}w(),a.value=V,b(V,!0),n("dropdown-update-show",!0)},B=N=>{if(!a.value)return;const V=N.target;V instanceof Element&&(V.closest(".sd-toolbar-dropdown-menu, .sd-font-combobox__listbox")||i.value?.contains(V)||w())};return kn(()=>y(a.value),N=>{N?document.addEventListener("pointerdown",B,!0):document.removeEventListener("pointerdown",B,!0)},{immediate:!0}),ti(()=>{document.removeEventListener("pointerdown",B,!0)}),(N,V)=>(Ge(),it("div",{style:Cn(u.value),class:"button-group",role:"group",onFocus:ke,ref_key:"buttonGroupRef",ref:i,"data-toolbar-position":s.position},[(Ge(!0),it(On,null,So(e.toolbarItems,(re,J)=>(Ge(),it("div",{key:re.id.value,class:gr([{narrow:re.isNarrow.value,wide:re.isWide.value,"sd-disabled":re.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:K=>Ae(K,re),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:J===0?0:-1,"data-item-id":re.id.value},[p(re)?(Ge(),wr(SCn,{key:0,style:{width:"20px"}})):Ht("",!0),h(re)&&g(re)?(Ge(),wr(UZ,{key:1,trigger:"hover",disabled:!re.tooltip?.value,"auto-hide-duration":VZ,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Iu(()=>[Er(jCn,{item:re,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:C,onItemClicked:K=>x(re),onTabOut:K=>L(J,K),onEditorHandoff:E},null,8,["item","ui-font-family","onItemClicked","onTabOut"])]),default:Iu(()=>[yt("div",null,[hg(Zn(re.tooltip)+" ",1),re.disabled.value?(Ge(),it("span",XCn,"(disabled)")):Ht("",!0)])]),_:2},1032,["disabled","content-style"])):f(re)&&g(re)?(Ge(),wr(LCn,{key:2,options:M(re),disabled:re.disabled.value,show:y(re),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(K,$)=>T(re,$),"onUpdate:show":K=>_e(K,re),style:Cn(re.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":kt(l)}]}),"node-props":K=>O(K,re)},{trigger:Iu(()=>[Er(UZ,{trigger:"hover",disabled:!re.tooltip?.value,"auto-hide-duration":VZ,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Iu(()=>[Er(zZ,{"toolbar-item":re,disabled:re.disabled.value,"allow-enter-propagation":!0,onTextSubmit:K=>A(re,K),onMainClick:K=>S(re),onTabOut:K=>R(re,K)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick","onTabOut"])]),default:Iu(()=>[yt("div",null,[hg(Zn(re.tooltip)+" ",1),re.disabled.value?(Ge(),it("span",JCn,"(disabled)")):Ht("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(re)?(Ge(),wr(UZ,{key:3,trigger:"hover",class:"sd-editor-toolbar-tooltip","auto-hide-duration":VZ,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Iu(()=>[Er(zZ,{"toolbar-item":re,"is-overflow-item":e.fromOverflow,onTextSubmit:K=>A(re,K),onButtonClick:K=>v(re)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Iu(()=>[re.tooltip?(Ge(),it("div",ZCn,[hg(Zn(re.tooltip)+" ",1),re.disabled.value?(Ge(),it("span",QCn,"(disabled)")):Ht("",!0)])):Ht("",!0)]),_:2},1032,["content-style"])):Ht("",!0),m(re)&&e.overflowItems.length?(Ge(),wr(CCn,{key:4,"toolbar-item":re,onButtonClick:K=>v(re),"overflow-items":e.overflowItems,onClose:w},null,8,["toolbar-item","onButtonClick","overflow-items"])):Ht("",!0)],42,YCn))),128))],44,KCn))}},j5=jn($Cn,[["__scopeId","data-v-181bd035"]]);tn(),Yn();var eEn="Arial, Helvetica, sans-serif",tEn={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=jc();let r=Ne(1);const o=Ne(!1);let i=null;const s=ut(()=>{const S=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof S=="string"&&S.trim()?S.trim():eEn}),a=n.$toolbar.config?.toolbarGroups?.includes("left"),l=n.$toolbar.config?.toolbarGroups?.includes("right"),c=n.$toolbar.config?.toolbarButtonsExclude||[],u=S=>n.$toolbar.getToolbarItemByGroup(S).filter(w=>!c.includes(w.name.value)),d=()=>{o.value=n.$toolbar.getAvailableWidth()<=W_.lg},f=async S=>{if(S.metaKey&&S.key==="f"){const w=n.$toolbar.getToolbarItemByName("search");w&&(S.preventDefault(),w.expand.value=!0,await En(),w.inputRef.value&&w.inputRef.value.focus())}},p=HIn(async()=>{await n.$toolbar.onToolbarResize(),d(),r.value+=1},300),m=()=>{r.value+=1};function g(){window.removeEventListener("resize",p),window.removeEventListener("keydown",f),n.$toolbar.off?.("toolbar-items-changed",m),i?.disconnect(),i=null}function y(){g(),window.addEventListener("resize",p),window.addEventListener("keydown",f),n.$toolbar.on?.("toolbar-items-changed",m),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(i=new ResizeObserver(()=>{p()}),i.observe(n.$toolbar.toolbarContainer)),d()}Do(y),ile(y),sle(g),ti(g);const b=({item:S,argument:w,option:T})=>{n.$toolbar.emitCommand({item:S,argument:w,option:T})},v=()=>{const S=n.$toolbar.activeEditor;S&&(S.options?.isHeaderOrFooter||S.commands?.restoreSelection())},A=S=>{S.target.closest('input, textarea, [contenteditable="true"]')||S.preventDefault()};return(S,w)=>(Ge(),it("div",{class:"superdoc-toolbar",key:kt(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:A},[kt(a)?(Ge(),wr(j5,{key:0,tabindex:"0","toolbar-items":u("left"),"compact-side-groups":o.value,"ui-font-family":s.value,position:"left",onCommand:b,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Ht("",!0),Er(j5,{tabindex:"0","toolbar-items":u("center"),"overflow-items":kt(n).$toolbar.overflowItems,"compact-side-groups":o.value,"ui-font-family":s.value,position:"center",onCommand:b,onItemClicked:v},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),kt(l)?(Ge(),wr(j5,{key:1,tabindex:"0","toolbar-items":u("right"),"compact-side-groups":o.value,"ui-font-family":s.value,position:"right",onCommand:b,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Ht("",!0)],32))}},sBe=jn(tEn,[["__scopeId","data-v-938eaa1b"]]);const aBe={bold:"Bold",fontFamily:"Font family",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",tableOfContents:"Table of contents",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",directionLtr:"Left-to-right",directionRtl:"Right-to-left",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",formattingMarks:"Show or hide formatting marks",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"},nEn=(e,t={})=>{const n=e?.runProperties?.fontFamily;if(!n)return null;const[r]=Og({fontFamily:n},t);return r?.attrs?.fontFamily??null},rEn=e=>{let t=null;return e&&(e.startsWith("#")||e.startsWith(".")?t=document.querySelector(e):t=document.getElementById(e),!t)?null:t};tn();var lBe=class $se extends s4.default{static#e=new Set(["bold","italic","underline","strike","highlight","color","fontSize","fontFamily"]);config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Yi},texts:{...aBe},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,editor:null,aiApiKey:null,aiEndpoint:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;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={...Yi,...t.icons},this.config.texts={...aBe,...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,fontsChanged:null},this._lastFontOptionsSignature="",this._restoreFocusTimeoutId=null,!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=rEn(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.#r({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=fk(sBe),this.app.directive("click-outside",$H),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?MIn({superdoc:this.superdoc,commands:$kn}):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))}#o(){!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.activeEditor.off("fonts-changed",this._boundEditorHandlers.fontsChanged),this._boundEditorHandlers.transaction=null,this._boundEditorHandlers.selectionUpdate=null,this._boundEditorHandlers.focus=null,this._boundEditorHandlers.fontsChanged=null)}setActiveEditor(t){const n=t===this.activeEditor,r=!!this._boundEditorHandlers.transaction;if(n&&(!t||r)){this.updateToolbarState();return}this.#o(),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._boundEditorHandlers.fontsChanged=this.onEditorFontsChanged.bind(this),this.activeEditor.on("transaction",this._boundEditorHandlers.transaction),this.activeEditor.on("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.on("focus",this._boundEditorHandlers.focus),this.activeEditor.on("fonts-changed",this._boundEditorHandlers.fontsChanged)),this.#s(),this._lastFontOptionsSignature=this.#c(),this.updateToolbarState()}getToolbarItemByGroup(t){return this.toolbarItems.filter(n=>(n.group?.value||"center")===t)}getToolbarItemByName(t){return this.#n().find(n=>n.name.value===t)}#n(){return[...this.toolbarItems,...this.overflowItems]}getAvailableWidth(){const t=document.documentElement.clientWidth,n=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?n:t}#r({superToolbar:t,icons:n,texts:r,fonts:o,hideButtons:i,isDev:s=!1}={}){const a=this.getAvailableWidth(),{defaultItems:l,overflowItems:c}=tCn({superToolbar:t,toolbarIcons:n,toolbarTexts:r,toolbarFonts:this.#i(o),hideButtons:i,availableWidth:a,role:this.role,isDev:s}),u=this.config.customButtons||[];u.length&&l.push(...u.map(f=>_o({...f})));let d=[...l.map(f=>f.name.value),...c.map(f=>f.name.value)];this.config.groups&&(d=Object.values(this.config.groups).flatMap(f=>f)),this.toolbarItems=l.filter(f=>d.includes(f.name.value)).filter(f=>!this.config.excludeItems.includes(f.name.value)),this.overflowItems=c.filter(f=>d.includes(f.name.value))}#i(t){return Zkn(this.superdoc?.fonts?.getDocumentFontOptions?.()??[],t,bEe(this.superdoc?.config?.fonts))}#s(){this.#r({superToolbar:this,icons:this.config.icons,texts:this.config.texts,fonts:this.config.fonts,hideButtons:this.config.hideButtons,isDev:this.isDev}),this.emit("toolbar-items-changed")}#c(){if(this.config.fonts)return"custom-fonts";const t=this.superdoc?.fonts?.getDocumentFontOptions?.()??[];return JSON.stringify(t.map(n=>[n.logicalFamily,n.previewFamily]))}#u(){if(!this.activeEditor||!this.activeEditor.converter)return;const{typeface:t="Arial",fontSizePt:n=12}=this.activeEditor.converter.getDocumentDefaultStyles()??{},r=this.toolbarItems.find(i=>i.name.value==="fontSize");r&&(r.defaultLabel.value=n);const o=this.toolbarItems.find(i=>i.name.value==="fontFamily");o&&(o.defaultLabel.value=t)}#d(){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=Pkn(),r=7,o=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(er(a)),s},[]),i={key:"color",type:"render",render:()=>BZ(this,t,o,!0)};t.nestedOptions.value=[i]}#f(){const t=this.getToolbarItemByName("documentMode");if(!t)return;const n=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),r=this.config.texts||{},o=this.config.icons||{},i={editing:{label:r.documentEditingMode||"Editing",icon:o.documentEditingMode||o.documentMode},suggesting:{label:r.documentSuggestingMode||"Suggesting",icon:o.documentSuggestingMode||o.documentMode},viewing:{label:r.documentViewingMode||"Viewing",icon:o.documentViewingMode||o.documentMode}},s=i[n]||i.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)}#p(){if(!this.activeEditor?.state)return null;const{state:t}=this.activeEditor,n=t.selection;if(!n?.empty)return null;const r=Gl(o=>o.type.name==="paragraph")(n);return!r||r.node?.content?.size!==0?null:nEn(ml(this.activeEditor,r.node,t.doc.resolve(r.pos)),this.activeEditor?.converter?.convertedXml??{})||null}#a(t){return!!t?.active&&t?.value==null}#b(t){if(t.name.value==="tableActions"){const a=nBe.map(l=>this.snapshot?.commands?.[l]).some(l=>l&&!l.disabled);return t.setDisabled(!a),!0}const n=G5[t.name.value];if(!n)return!1;const r=this.snapshot?.commands?.[n],o=()=>{t.setDisabled(!!r?.disabled)},i={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.#f()},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}if(this.#a(r)){t.activate({},!0);return}const a=this.#p();if(a){t.activate({fontFamily:a});return}t.deactivate()},fontSize:()=>{if(r?.value!=null){t.activate({fontSize:r.value});return}if(this.#a(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=oSe(r.value)):(t.deactivate(),t.selectedValue.value=null)},numberedlist:()=>{r?.active?(t.activate(),t.selectedValue.value=r.value):(t.deactivate(),t.selectedValue.value=null)},default:()=>{r?.active?t.activate():t.deactivate()}},s=i[t.name.value]??i.default;return o(),s(),!0}#l(t,n){const r=t?.name?.value==="tableActions",o=r?tBe[n?.command]:G5[t?.name?.value];return!o||!this.controller?.execute?!1:(r?this.controller.execute(o):this.controller.execute(o,n),!0)}updateToolbarState(){this.#f(),this.#u(),this.#d();const t=this.snapshot?.commands?.["document-mode"]?.value||"editing";if(!this.activeEditor||t==="viewing"){this.#S(),this.#n().forEach(r=>{r.allowWithoutEditor?.value&&this.#b(r)});return}const{state:n}=this.activeEditor;if(!n){this.#S();return}this.#n().forEach(r=>{r.resetDisabled(),this.#b(r)})}onToolbarResize=()=>{this.#r({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.#S(),this.updateToolbarState()};#S(){this.activeEditor=null,this.#n().forEach(t=>{const{allowWithoutEditor:n}=t;n.value||t.setDisabled(!0)})}onEditorTransaction({transaction:t}){!t.docChanged&&!t.selectionSet||this.updateToolbarState()}#T(){!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 o=this.activeEditor?.view?.hasFocus,i=!!(typeof o=="function"&&o.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(!i&&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.#l(t,n)){this.updateToolbarState();return}if(rBe.has(t?.name?.value)&&this.#l(t,n)){a&&this.#y(),this.updateToolbarState(),l&&this.#T();return}if(s==="insertTableOfContents"&&this.activeEditor)pOe(this.activeEditor);else 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.#y(),this.updateToolbarState(),l&&this.#T()}}}flushPendingMarkCommands(){if(!this.activeEditor||!this.pendingMarkCommands.length)return!1;const t=this.pendingMarkCommands;return this.pendingMarkCommands=[],t.forEach(({command:n,argument:r,item:o})=>{if(n)try{if(rBe.has(o?.name?.value)&&this.#l(o,r)){this.#v({command:n,argument:r});return}this.activeEditor.commands&&n in this.activeEditor.commands&&this.activeEditor.commands[n](r),this.#v({command:n,argument:r})}catch(i){const s=new Error(`[super-toolbar 🎨] Failed to execute pending command: ${n}`);this.emit("exception",{error:s,editor:this.activeEditor,originalError:i}),console.error(s,i)}}),this.#y(),this.updateToolbarState(),!0}onEditorSelectionUpdate(){this.activeEditor&&(this.flushPendingMarkCommands()||this.#w()&&this.updateToolbarState())}onEditorFontsChanged(){const t=this.#c();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#s()),this.updateToolbarState()}onEditorFocus(){if(this.pendingMarkCommands.length){this.onEditorSelectionUpdate();return}this.#w()&&this.updateToolbarState()}isMarkToggle(t){const n=t?.name?.value;return $se.#e.has(n)}#y(){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:o}=t||{};if(!r?.empty||o?.length||!n?.dispatch||!t?.tr||kd(this.activeEditor).some(s=>$se.#e.has(s.name)))return!1;const i=t.tr.setStoredMarks(this.stickyStoredMarks);return n.dispatch(i),!0}#v({command:t,argument:n}){if(!this.activeEditor||!this.activeEditor.state?.selection?.empty||this.activeEditor.state?.storedMarks?.length||t!=="setFontSize")return;const{state:r,view:o}=this.activeEditor,i=r.schema?.marks?.textStyle;if(!i||!o?.dispatch||!r?.tr)return;const[s,a]=uh(n??"");if(Number.isNaN(s))return;const l=Math.min(96,Math.max(8,Number(s))),c=a||"pt",u=i.create({fontSize:`${l}${c}`}),d=r.tr.setStoredMarks([u]);o.dispatch(d)}destroy(){this._restoreFocusTimeoutId!==null&&(clearTimeout(this._restoreFocusTimeoutId),this._restoreFocusTimeoutId=null),this.#o(),this.destroyHeadlessToolbar(),this.app?.unmount()}},oEn=class eae{static createSchemaByExtensions(t,n){const r=t.filter(a=>a.type==="node"),o=t.filter(a=>a.type==="mark"),i=r.find(a=>ar(a,"topNode"))?.name,s=dn.getAttributesFromExtensions(t);return new wfe({topNode:i,nodes:eae.#e(r,s,n),marks:eae.#t(o,s,n)})}static#e(t,n,r){const o=t.map(i=>{const s=n.filter(p=>p.type===i.name),a={name:i.name,options:i.options,storage:i.storage,editor:r},l=Object.fromEntries(s.map(p=>[p.name,{default:p?.attribute?.default}])),c=t.reduce((p,m)=>{const g=ar(m,"extendNodeSchema",a);return{...p,...g?g(i):{}}},{}),u=jV({content:Pi(ar(i,"content",a)),group:Pi(ar(i,"group",a)),marks:Pi(ar(i,"marks",a)),inline:Pi(ar(i,"inline",a)),atom:Pi(ar(i,"atom",a)),selectable:Pi(ar(i,"selectable",a)),draggable:Pi(ar(i,"draggable",a)),code:Pi(ar(i,"code",a)),defining:Pi(ar(i,"defining",a)),isolating:Pi(ar(i,"isolating",a)),leafText:ar(i,"leafText",a),summary:ar(i,"summary",a),attrs:l,...c});(typeof i.validChildren=="function"||Array.isArray(i.validChildren))&&Object.defineProperty(u,"validChildren",{enumerable:!1,configurable:!1,get:()=>i.validChildren});const d=Pi(ar(i,"parseDOM",a));d&&(u.parseDOM=d.map(p=>dn.insertExtensionAttrsToParseRule(p,s)));const f=ar(i,"renderDOM",a);f&&(u.toDOM=p=>f({node:p,htmlAttributes:dn.getAttributesToRender(p,s)}));const h=ar(i,"renderText",a);return h&&(u.toText=h),[i.name,u]});return Object.fromEntries(o)}static#t(t,n,r){const o=t.map(i=>{const s=n.filter(f=>f.type===i.name),a={name:i.name,options:i.options,storage:i.storage,editor:r},l=Object.fromEntries(s.map(f=>[f.name,{default:f?.attribute?.default}])),c=jV({group:Pi(ar(i,"group",a)),inclusive:Pi(ar(i,"inclusive",a)),excludes:Pi(ar(i,"excludes",a)),spanning:Pi(ar(i,"spanning",a)),code:Pi(ar(i,"code",a)),attrs:l}),u=Pi(ar(i,"parseDOM",a));u&&(c.parseDOM=u.map(f=>dn.insertExtensionAttrsToParseRule(f,s)));const d=ar(i,"renderDOM",a);return d&&(c.toDOM=f=>d({mark:f,htmlAttributes:dn.getAttributesToRender(f,s)})),[i.name,c]});return Object.fromEntries(o)}},MT,cBe,uBe,dBe,fBe,iEn=Oe((()=>{MT=class extends Error{constructor(e){super(e),this.name="EditorError"}},cBe=class extends MT{constructor(e){super(e),this.name="InvalidStateError"}},uBe=class extends MT{constructor(e){super(e),this.name="NoSourcePathError"}},dBe=class extends MT{constructor(e){super(e),this.name="FileSystemNotAvailableError"}},fBe=class extends MT{constructor(e,t){super(e),this.name="DocumentLoadError",this.cause=t}}})),_a,ps,q_=Oe((()=>{iEn(),_a={PASSWORD_REQUIRED:"DOCX_PASSWORD_REQUIRED",PASSWORD_INVALID:"DOCX_PASSWORD_INVALID",ENCRYPTION_UNSUPPORTED:"DOCX_ENCRYPTION_UNSUPPORTED",DECRYPTION_FAILED:"DOCX_DECRYPTION_FAILED"},ps=class extends MT{constructor(e,t,n){super(t),this.name="DocxEncryptionError",this.code=e,this.cause=n}}}));const sEn=bo.create({name:"commands",addCommands(){return{...jsn}}});var GZ=e=>{const t=e?.state?.tr;t&&e.dispatch?.(tM(t))},WZ=e=>e?.view?.composing===!0;const aEn=e=>{if(WZ(e))return!1;const{view:t}=e;return GZ(t),e.commands.first(({commands:n})=>[()=>n.splitRunToParagraph?.()??!1,()=>n.newlineInCode(),()=>n.createParagraphNear(),()=>n.liftEmptyBlock(),()=>n.splitBlock()])},K_=e=>{if(WZ(e))return!1;const{view:t}=e;return GZ(t),e.commands.first(({commands:n,tr:r})=>[()=>n.undoInputRule(),()=>(r.setMeta("inputType","deleteContentBackward"),!1),()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.selectInlineSdtBeforeRunStart(),()=>n.selectFootnoteMarkerBefore?.()??!1,()=>n.deleteSelectedNoteMarker?.()??!1,()=>n.selectBlockSdtBeforeTextBlockStart(),()=>n.moveIntoBlockSdtBeforeTextBlockStart(),()=>n.backspaceEmptyRunParagraph(),()=>n.backspaceSkipEmptyRun(),()=>n.backspaceAtomBefore(),()=>n.backspaceNextToRun(),()=>n.backspaceAcrossRuns(),()=>n.mixedBidiBackspace?.()??!1,()=>n.deleteSelection(),()=>n.removeNumberingProperties(),()=>n.joinBackward(),()=>n.selectNodeBackward()])},DT=e=>{if(WZ(e))return!1;const{view:t}=e;return GZ(t),e.commands.first(({commands:n})=>[()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.selectInlineSdtAfterRunEnd(),()=>n.selectFootnoteMarkerAfter?.()??!1,()=>n.deleteSelectedNoteMarker?.()??!1,()=>n.selectBlockSdtAfterTextBlockEnd(),()=>n.moveIntoBlockSdtAfterTextBlockEnd(),()=>n.deleteSkipEmptyRun(),()=>n.deleteAtomAfter(),()=>n.deleteNextToRun(),()=>n.deleteSelection(),()=>n.joinForward(),()=>n.selectNodeForward()])},lEn=bo.create({name:"keymap",addShortcuts(){const e={Enter:()=>aEn(this.editor),"Shift-Enter":()=>this.editor.commands.insertLineBreak(),"Mod-Enter":()=>this.editor.commands.insertPageBreak(),Backspace:()=>K_(this.editor),"Mod-Backspace":()=>K_(this.editor),"Shift-Backspace":()=>K_(this.editor),Delete:()=>DT(this.editor),"Mod-Delete":()=>DT(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":()=>K_(this.editor),"Alt-Backspace":()=>K_(this.editor),"Ctrl-d":()=>DT(this.editor),"Ctrl-Alt-Backspace":()=>DT(this.editor),"Alt-Delete":()=>DT(this.editor),"Alt-d":()=>DT(this.editor),"Ctrl-a":()=>this.editor.commands.selectAll(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd(),"Ctrl-t":()=>this.editor.commands.insertTabChar()};return rz()||Blt()?n:t}});var cEn=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},hBe=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"},OT=(e,t,n,r,o={})=>{if(!hBe(n))return;let i=null;const s=e?.dom?.ownerDocument?.getSelection?.()??null;try{e?.dom&&s?.anchorNode&&e.dom.contains(s.anchorNode)&&(i=e.posAtDOM(s.anchorNode,s.anchorOffset,-1))}catch{i=null}cEn({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:i,...o})},pBe=e=>e?.type?.name==="structuredContent"&&e.isInline,uEn=(e,t)=>{if(typeof t!="number"||t<0||t>e.content.size)return!1;const n=e.resolve(t),r=n.parent.childBefore(n.parentOffset).node,o=n.parent.childAfter(n.parentOffset).node;return pBe(r)||pBe(o)},dEn=e=>{const{selection:t}=e;if(!t.empty)return t;const n=VPe(e);return n&&!n.empty?n:t},fEn=(e,t,n)=>{const r=t?.inputType==="insertText",o=typeof t?.data=="string"&&t.data.length>0,i=t?.isComposing===!0;if(OT(e,t,n,"beforeinput:start",{isInsertTextInput:r,hasTextData:o,isComposing:i}),!r||!o||i)return OT(e,t,n,"beforeinput:skip"),!1;const s=dEn(e.state),a=hBe(n)||uEn(e.state.doc,e.state.selection.from);if(s.empty&&!a)return OT(e,t,n,"beforeinput:skip-empty-selection"),!1;const l=e.state.tr.insertText(t.data,s.from,s.to),c=Math.max(0,Math.min(s.from+t.data.length,l.doc.content.size));try{l.setSelection(Et.create(l.doc,c))}catch{l.setSelection(Ln.near(l.doc.resolve(c),1))}return s.empty||l.setMeta(Hu,{focused:!1,preservedSelection:null,showVisualSelection:!1,skipFocusReset:!1}),l.setMeta("inputType","insertText"),e.dispatch(l),t.preventDefault(),OT(e,t,n,"beforeinput:handled"),!0},hEn=(e,t)=>{if(!e.composing||t?.isComposing)return!1;const n=t?.inputType??null;return n?!["insertCompositionText","deleteCompositionText"].includes(n):!1},pEn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);const mEn=bo.create({name:"editable",addPmPlugins(){const e=this.editor,t=()=>!e.options.editable&&!e.options.allowSelectionInViewMode,n=(r,o)=>e.options.editable?!1:(o.preventDefault(),!0);return[new _r({key:new oo("editable"),props:{editable:()=>e.options.editable,handleDOMEvents:{beforeinput:(r,o)=>(OT(r,o,e,"dom:beforeinput"),e.options.editable?(hEn(r,o)&&XRt(r),!!fEn(r,o,e)):(o.preventDefault(),!0)),input:(r,o)=>(OT(r,o,e,"dom:input"),!1),compositionstart:(r,o)=>n(r,o),compositionupdate:(r,o)=>n(r,o),compositionend:(r,o)=>n(r,o),mousedown:(r,o)=>t()?(o.preventDefault(),!0):!1,focus:(r,o)=>t()?(o.preventDefault(),r.dom.blur(),!0):!1},handleClick:()=>t(),handleDoubleClick:()=>t(),handleTripleClick:()=>t(),handleKeyDown:(r,o)=>e.options.editable?!1:!(e.options.allowSelectionInViewMode&&(pEn.has(o.key)||(o.ctrlKey||o.metaKey)&&["c","a"].includes(o.key.toLowerCase()))),handlePaste:()=>!e.options.editable,handleDrop:()=>!e.options.editable}})]}}),gEn=bo.create({name:"editorFocus",addPmPlugins(){const e=this.editor;return[new _r({key:new oo("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}}}})]}}),yEn=bo.create({name:"positionTracker",addStorage(){return{tracker:null}},addPmPlugins(){return[uwn()]},onCreate(){const e=this.editor?.positionTracker??this.storage.tracker;if(e){this.storage.tracker=e,this.editor.positionTracker=e;return}const t=new M5e(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}}),bEn=bo.create({name:"selectionHandle",addPmPlugins(){return[ltn()]}});var Y_=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 o of n)try{o.apply(this,t)}catch(i){r.push(i instanceof Error?i:new Error(String(i)))}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 vEn(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}var wEn=class DP{editor;schema;extensions;externalExtensions=[];splittableMarks=[];constructor(t,n,r){this.editor=r,this.externalExtensions=n||[],this.externalExtensions=this.externalExtensions.map(o=>({...o,isExternal:!0})),this.extensions=DP.getResolvedExtensions([...t,...this.externalExtensions]),this.schema=oEn.createSchemaByExtensions(this.extensions,r),this.#e()}static create(...t){return new DP(...t)}static getResolvedExtensions(t){return DP.sortByPriority(t)}static sortByPriority(t){return t.sort((r,o)=>{const i=ar(r,"priority")||100,s=ar(o,"priority")||100;return i>s?-1:i<s?1:0})}get attributes(){return dn.getAttributesFromExtensions(this.extensions)}get commands(){let t={};for(const n of this.extensions){const r=ar(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:$A(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 o=ar(n,"addHelpers",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:$A(n.name,this.schema)});o&&(t[r]=o())}return t}get plugins(){const t=this.editor,n=DP.sortByPriority([...this.extensions].reverse()),r=[],o=n.map(i=>{const s={name:i.name,options:i.options,storage:i.storage,editor:t,type:$A(i.name,this.schema)},a=[],l=ar(i,"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(iPt(c));const u=ar(i,"addInputRules",s);vEn(i,t.options.enableInputRules)&&u&&r.push(...u());const d=ar(i,"addPmPlugins",s);return d&&a.push(...d()),a}).flat();return[vMt({editor:t,rules:r}),...o]}get nodeViews(){const{editor:t}=this,n=this.extensions.filter(r=>r.type==="node").filter(r=>!!ar(r,"addNodeView")).map(r=>{const o=this.attributes.filter(l=>l.type===r.name),i=ar(r,"addNodeView",{name:r.name,options:r.options,storage:r.storage,editor:t,type:Lu(r.name,this.schema)});if(!i)return null;const s=i();if(!s)return null;const a=(l,c,u,d)=>s({editor:t,node:l,getPos:u,decorations:d,htmlAttributes:dn.getAttributesToRender(l,o),extension:r,extensionAttrs:o});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:$A(t.name,this.schema)};t.type==="mark"&&(Pi(ar(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:$A(t.name,this.schema)},r=ar(t,"onBeforeCreate",n),o=ar(t,"onCreate",n),i=ar(t,"onUpdate",n),s=ar(t,"onSelectionUpdate",n),a=ar(t,"onTransaction",n),l=ar(t,"onFocus",n),c=ar(t,"onBlur",n),u=ar(t,"onDestroy",n);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),i&&this.editor.on("update",i),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)}},AEn={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((o,i)=>{if(o.type.name==="paragraph"){const{attrs:s}=o,{spacing:a}=s;if(!a)return;const l={line:lb(ba(a.line)),lineSpaceBefore:lb(ba(a.lineSpaceBefore)),lineSpaceAfter:lb(ba(a.lineSpaceAfter))};r.setNodeMarkup(i,void 0,{...s,spacing:{...a,...l}})}}),n(r),!0}};const mBe=e=>{if(e==="initial"||e==="0.4.14")return Object.values(AEn)};var jZ=Zr(((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,o,i){function s(c,u){if(!o[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=o[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,o,i)}return o[c].exports}for(var a=typeof require=="function"&&require,l=0;l<i.length;l++)s(i[l]);return s})({1:[function(n,r,o){"use strict";var i=n("./utils"),s=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(l){for(var c,u,d,f,h,p,m,g=[],y=0,b=l.length,v=b,A=i.getTypeOf(l)!=="string";y<l.length;)v=b-y,d=A?(c=l[y++],u=y<b?l[y++]:0,y<b?l[y++]:0):(c=l.charCodeAt(y++),u=y<b?l.charCodeAt(y++):0,y<b?l.charCodeAt(y++):0),f=c>>2,h=(3&c)<<4|u>>4,p=1<v?(15&u)<<2|d>>6:64,m=2<v?63&d:64,g.push(a.charAt(f)+a.charAt(h)+a.charAt(p)+a.charAt(m));return g.join("")},o.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 b,v=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&v--,l.charAt(l.length-2)===a.charAt(64)&&v--,v%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=s.uint8array?new Uint8Array(0|v):new Array(0|v);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++))),b[g++]=c,h!==64&&(b[g++]=u),p!==64&&(b[g++]=d);return b}},{"./support":30,"./utils":32}],2:[function(n,r,o){"use strict";var i=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(i.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(i.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,o){"use strict";var i=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){"use strict";var i=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?i.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,o){"use strict";o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){"use strict";var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,o){"use strict";var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),c=i?"uint8array":"array";function u(d,f){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=f,this.meta={}}o.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})}},o.compressWorker=function(d){return new u("Deflate",d)},o.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){"use strict";function i(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,b){var v,A,S=h.file,w=h.compression,T=b!==c.utf8encode,x=a.transformTo("string",b(S.name)),C=a.transformTo("string",c.utf8encode(S.name)),k=S.comment,P=a.transformTo("string",b(k)),E=a.transformTo("string",c.utf8encode(k)),L=C.length!==S.name.length,R=E.length!==k.length,M="",O="",H="",W=S.dir,G=S.date,U={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(U.crc32=h.crc32,U.compressedSize=h.compressedSize,U.uncompressedSize=h.uncompressedSize);var F=0;p&&(F|=8),T||!L&&!R||(F|=2048);var ne=0,Y=0;W&&(ne|=16),y==="UNIX"?(Y=798,ne|=(function(Z,X){var ae=Z;return Z||(ae=X?16893:33204),(65535&ae)<<16})(S.unixPermissions,W)):(Y=20,ne|=(function(Z){return 63&(Z||0)})(S.dosPermissions)),v=G.getUTCHours(),v<<=6,v|=G.getUTCMinutes(),v<<=5,v|=G.getUTCSeconds()/2,A=G.getUTCFullYear()-1980,A<<=4,A|=G.getUTCMonth()+1,A<<=5,A|=G.getUTCDate(),L&&(O=i(1,1)+i(u(x),4)+C,M+="up"+i(O.length,2)+O),R&&(H=i(1,1)+i(u(P),4)+E,M+="uc"+i(H.length,2)+H);var ve="";return ve+=`
814
814
  \0`,ve+=i(F,2),ve+=w.magic,ve+=i(v,2),ve+=i(A,2),ve+=i(U.crc32,4),ve+=i(U.compressedSize,4),ve+=i(U.uncompressedSize,4),ve+=i(x.length,2),ve+=i(M.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ve+x+M,dirRecord:d.CENTRAL_FILE_HEADER+i(Y,2)+ve+i(P.length,2)+"\0\0\0\0"+i(ne,4)+i(g,4)+x+M+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+i(g.crc32,4)+i(g.compressedSize,4)+i(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,b,v,A,S){var w=a.transformTo("string",S(A));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(b,4)+i(v,4)+i(w.length,2)+w})(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,o){"use strict";var i=n("../compressions"),s=n("./ZipFileWorker");o.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(b,v){var A=b||v,S=i[A];if(!S)throw new Error(A+" is not a valid compression method !");return S})(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,o){"use strict";function i(){if(!(this instanceof i))return new i;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 i;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(s,a){return new i().loadAsync(s,a)},i.external=n("./external"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){"use strict";var i=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=i.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.")):i.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 b=0;b<y.length;b++)g.push(d(y[b]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,b=0;b<y.length;b++){var v=y[b],A=v.fileNameStr,S=i.resolve(v.fileNameStr);p.file(S,v.decompressed,{binary:!0,optimizedBinaryString:!0,date:v.date,dir:v.dir,comment:v.fileCommentStr.length?v.fileCommentStr:null,unixPermissions:v.unixPermissions,dosPermissions:v.dosPermissions,createFolders:h.createFolders}),v.dir||(p.file(S).unsafeOriginalName=A)}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,o){"use strict";var i=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)}i.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,o){"use strict";var i=n("readable-stream").Readable;function s(a,l,c){i.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,i),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,s);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,s)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var s=new Buffer(i);return s.fill(0),s},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,r,o){"use strict";function i(A,S,w){var T,x=a.getTypeOf(S),C=a.extend(w||{},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&&(A=y(A)),C.createFolders&&(T=g(A))&&b.call(this,T,!0);var k=x==="string"&&C.binary===!1&&C.base64===!1;w&&w.binary!==void 0||(C.binary=!k),(S instanceof d&&S.uncompressedSize===0||C.dir||!S||S.length===0)&&(C.base64=!1,C.binary=!0,S="",C.compression="STORE",x="string");var P=null;P=S instanceof d||S instanceof l?S:p.isNode&&p.isStream(S)?new m(A,S):a.prepareContent(A,S,C.binary,C.optimizedBinaryString,C.base64);var E=new f(A,P,C);this.files[A]=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(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var S=A.lastIndexOf("/");return 0<S?A.substring(0,S):""},y=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},b=function(A,S){return S=S!==void 0?S:u.createFolders,A=y(A),this.files[A]||i.call(this,A,null,{dir:!0,createFolders:S}),this.files[A]};function v(A){return Object.prototype.toString.call(A)==="[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(A){var S,w,T;for(S in this.files)T=this.files[S],(w=S.slice(this.root.length,S.length))&&S.slice(0,this.root.length)===this.root&&A(w,T)},filter:function(A){var S=[];return this.forEach(function(w,T){A(w,T)&&S.push(T)}),S},file:function(A,S,w){if(arguments.length!==1)return A=this.root+A,i.call(this,A,S,w),this;if(v(A)){var T=A;return this.filter(function(C,k){return!k.dir&&T.test(C)})}var x=this.files[this.root+A];return x&&!x.dir?x:null},folder:function(A){if(!A)return this;if(v(A))return this.filter(function(x,C){return C.dir&&A.test(x)});var S=this.root+A,w=b.call(this,S),T=this.clone();return T.root=w.name,T},remove:function(A){A=this.root+A;var S=this.files[A];if(S||(A.slice(-1)!=="/"&&(A+="/"),S=this.files[A]),S&&!S.dir)delete this.files[A];else for(var w=this.filter(function(x,C){return C.name.slice(0,A.length)===A}),T=0;T<w.length;T++)delete this.files[w[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(A){var S,w={};try{if((w=a.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=w.type.toLowerCase(),w.compression=w.compression.toUpperCase(),w.type==="binarystring"&&(w.type="string"),!w.type)throw new Error("No output type specified.");a.checkSupport(w.type),w.platform!=="darwin"&&w.platform!=="freebsd"&&w.platform!=="linux"&&w.platform!=="sunos"||(w.platform="UNIX"),w.platform==="win32"&&(w.platform="DOS");var T=w.comment||this.comment||"";S=h.generateWorker(this,w,T)}catch(x){(S=new l("error")).error(x)}return new c(S,w.type||"string",w.mimeType)},generateAsync:function(A,S){return this.generateInternalStream(A).accumulate(S)},generateNodeStream:function(A,S){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(S)}}},{"./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,o){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,i),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,o){"use strict";var i=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 i.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,o){"use strict";var i=n("./Uint8ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),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,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),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,o){"use strict";var i=n("./ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),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,o){"use strict";var i=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(d){var f=i.getTypeOf(d);return i.checkSupport(f),f!=="string"||s.uint8array?f==="nodebuffer"?new c(d):s.uint8array?new u(i.transformTo("uint8array",d)):new a(i.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){"use strict";o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){"use strict";var i=n("./GenericWorker"),s=n("../utils");function a(l){i.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,i),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,o){"use strict";var i=n("./GenericWorker"),s=n("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,i),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,o){"use strict";var i=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.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,o){"use strict";var i=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=i.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}i.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,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.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,o){"use strict";function i(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}i.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=i},{}],29:[function(n,r,o){"use strict";var i=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 b=[],v=p._internalType,A=p._outputType,S=p._mimeType;p.on("data",function(w,T){b.push(w),m&&m(T)}).on("error",function(w){b=[],y(w)}).on("end",function(){try{g((function(w,T,x){switch(w){case"blob":return i.newBlob(i.transformTo("arraybuffer",T),x);case"base64":return l.encode(T);default:return i.transformTo(w,T)}})(A,(function(w,T){var x,C=0,k=null,P=0;for(x=0;x<T.length;x++)P+=T[x].length;switch(w){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(k=new Uint8Array(P),x=0;x<T.length;x++)k.set(T[x],C),C+=T[x].length;return k;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+w+"'")}})(v,b),S))}catch(w){y(w)}b=[]}).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,i.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(b){this._worker=new a("error"),this._worker.error(b)}}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(){i.delay(m,arguments,g)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(i.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,o){"use strict";if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var i=new ArrayBuffer(0);try{o.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(i),o.blob=s.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){"use strict";for(var i=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")}o.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(p){var m,g,y,b,v,A=p.length,S=0;for(b=0;b<A;b++)(64512&(g=p.charCodeAt(b)))==55296&&b+1<A&&(64512&(y=p.charCodeAt(b+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),b++),S+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(S):new Array(S),b=v=0;v<S;b++)(64512&(g=p.charCodeAt(b)))==55296&&b+1<A&&(64512&(y=p.charCodeAt(b+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),b++),g<128?m[v++]=g:(g<2048?m[v++]=192|g>>>6:(g<65536?m[v++]=224|g>>>12:(m[v++]=240|g>>>18,m[v++]=128|g>>>12&63),m[v++]=128|g>>>6&63),m[v++]=128|63&g);return m})(h)},o.utf8decode=function(h){return s.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,b,v=p.length,A=new Array(2*v);for(m=g=0;m<v;)if((y=p[m++])<128)A[g++]=y;else if(4<(b=c[y]))A[g++]=65533,m+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&m<v;)y=y<<6|63&p[m++],b--;1<b?A[g++]=65533:y<65536?A[g++]=y:(y-=65536,A[g++]=55296|y>>10&1023,A[g++]=56320|1023&y)}return A.length!==g&&(A.subarray?A=A.subarray(0,g):A.length=g),i.applyFromCharCode(A)})(h=i.transformTo(s.uint8array?"uint8array":"array",h))},i.inherits(d,l),d.prototype.processChunk=function(h){var p=i.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(b,v){var A;for((v=v||b.length)>b.length&&(v=b.length),A=v-1;0<=A&&(192&b[A])==128;)A--;return A<0||A===0?v:A+c[b[A]]>v?A:v})(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:o.utf8decode(y),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=d,i.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){"use strict";var i=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"),o.newBlob=function(m,g){o.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 b=[],v=0,A=m.length;if(A<=y)return String.fromCharCode.apply(null,m);for(;v<A;)g==="array"||g==="nodebuffer"?b.push(String.fromCharCode.apply(null,m.slice(v,Math.min(v+y,A)))):b.push(String.fromCharCode.apply(null,m.subarray(v,Math.min(v+y,A)))),v+=y;return b.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 i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=o.getTypeOf(m),b=!0;if(y==="uint8array"?b=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(b=d.applyCanBeUsed.nodebuffer),b)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}o.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},o.transformTo=function(m,g){return g=g||"",m?(o.checkSupport(m),p[o.getTypeOf(g)][m](g)):g},o.resolve=function(m){for(var g=m.split("/"),y=[],b=0;b<g.length;b++){var v=g[b];v==="."||v===""&&b!==0&&b!==g.length-1||(v===".."?y.pop():y.push(v))}return y.join("/")},o.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":i.nodebuffer&&a.isBuffer(m)?"nodebuffer":i.uint8array&&m instanceof Uint8Array?"uint8array":i.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(m){if(!i[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(m){var g,y,b="";for(y=0;y<(m||"").length;y++)b+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return b},o.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},o.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},o.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},o.prepareContent=function(m,g,y,b,v){return l.Promise.resolve(g).then(function(A){return i.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,w){var T=new FileReader;T.onload=function(x){S(x.target.result)},T.onerror=function(x){w(x.target.error)},T.readAsArrayBuffer(A)}):A}).then(function(A){var S=o.getTypeOf(A);return S?(S==="arraybuffer"?A=o.transformTo("uint8array",A):S==="string"&&(v?A=s.decode(A):y&&b!==!0&&(A=(function(w){return u(w,i.uint8array?new Uint8Array(w.length):new Array(w.length))})(A))),A):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,o){"use strict";var i=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=i(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,o){"use strict";var i=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=i(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=i(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=i(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,o){"use strict";function i(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");i.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 b=!this._dataBinary;b&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!b&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(v){(m=new u("error")).error(v)}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++)i.prototype[d[h]]=f;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){"use strict";var s,a,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var c=0,u=new l(p),d=i.document.createTextNode("");u.observe(d,{characterData:!0}),s=function(){d.data=c=++c%2}}else if(i.setImmediate||i.MessageChannel===void 0)s="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var m=i.document.createElement("script");m.onreadystatechange=function(){p(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},i.document.documentElement.appendChild(m)}:function(){setTimeout(p,0)};else{var f=new i.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,o){"use strict";var i=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,b,v){this.promise=y,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof v=="function"&&(this.onRejected=v,this.callRejected=this.otherCallRejected)}function h(y,b,v){i(function(){var A;try{A=b(v)}catch(S){return a.reject(y,S)}A===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,A)})}function p(y){var b=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof b=="function")return function(){b.apply(y,arguments)}}function m(y,b){var v=!1;function A(T){v||(v=!0,a.reject(y,T))}function S(T){v||(v=!0,a.resolve(y,T))}var w=g(function(){b(S,A)});w.status==="error"&&A(w.value)}function g(y,b){var v={};try{v.value=y(b),v.status="success"}catch(A){v.status="error",v.value=A}return v}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var b=this.constructor;return this.then(function(v){return b.resolve(y()).then(function(){return v})},function(v){return b.resolve(y()).then(function(){throw v})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,b){if(typeof y!="function"&&this.state===c||typeof b!="function"&&this.state===l)return this;var v=new this.constructor(s);return this.state!==u?h(v,this.state===c?y:b,this.outcome):this.queue.push(new f(v,y,b)),v},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,b){var v=g(p,b);if(v.status==="error")return a.reject(y,v.value);var A=v.value;if(A)m(y,A);else{y.state=c,y.outcome=b;for(var S=-1,w=y.queue.length;++S<w;)y.queue[S].callFulfilled(b)}return y},a.reject=function(y,b){y.state=l,y.outcome=b;for(var v=-1,A=y.queue.length;++v<A;)y.queue[v].callRejected(b);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var b=new this(s);return a.reject(b,y)},d.all=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=y.length,A=!1;if(!v)return this.resolve([]);for(var S=new Array(v),w=0,T=-1,x=new this(s);++T<v;)C(y[T],T);return x;function C(k,P){b.resolve(k).then(function(E){S[P]=E,++w!==v||A||(A=!0,a.resolve(x,S))},function(E){A||(A=!0,a.reject(x,E))})}},d.race=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=y.length,A=!1;if(!v)return this.resolve([]);for(var S=-1,w=new this(s);++S<v;)T=y[S],b.resolve(T).then(function(x){A||(A=!0,a.resolve(w,x))},function(x){A||(A=!0,a.reject(w,x))});var T;return w}},{immediate:36}],38:[function(n,r,o){"use strict";var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){"use strict";var i=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 b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var v=i.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(v!==d)throw new Error(l[v]);if(b.header&&i.deflateSetHeader(this.strm,b.header),b.dictionary){var A;if(A=typeof b.dictionary=="string"?a.string2buf(b.dictionary):u.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(v=i.deflateSetDictionary(this.strm,A))!==d)throw new Error(l[v]);this._dict_set=!0}}function g(y,b){var v=new m(b);if(v.push(y,!0),v.err)throw v.msg||l[v.err];return v.result}m.prototype.push=function(y,b){var v,A,S=this.strm,w=this.options.chunkSize;if(this.ended)return!1;A=b===~~b?b:b===!0?4:0,typeof y=="string"?S.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?S.input=new Uint8Array(y):S.input=y,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(w),S.next_out=0,S.avail_out=w),(v=i.deflate(S,A))!==1&&v!==d)return this.onEnd(v),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(S.output,S.next_out))):this.onData(s.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&v!==1);return A===4?(v=i.deflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===d):A!==2||(this.onEnd(d),!(S.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},o.Deflate=m,o.deflate=g,o.deflateRaw=function(y,b){return(b=b||{}).raw=!0,g(y,b)},o.gzip=function(y,b){return(b=b||{}).gzip=!0,g(y,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){"use strict";var i=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=i.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,i.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,b,v,A,S,w,T=this.strm,x=this.options.chunkSize,C=this.options.dictionary,k=!1;if(this.ended)return!1;b=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(x),T.next_out=0,T.avail_out=x),(y=i.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(w=typeof C=="string"?a.string2buf(C):f.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=i.inflateSetDictionary(this.strm,w)),y===l.Z_BUF_ERROR&&k===!0&&(y=l.Z_OK,k=!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||b!==l.Z_FINISH&&b!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(v=a.utf8border(T.output,T.next_out),A=T.next_out-v,S=a.buf2string(T.output,v),T.next_out=A,T.avail_out=x-A,A&&s.arraySet(T.output,T.output,v,A,0),this.onData(S)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(k=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(b=l.Z_FINISH),b===l.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):b!==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},o.Inflate=h,o.inflate=p,o.inflateRaw=function(m,g){return(g=g||{}).raw=!0,p(m,g)},o.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,o){"use strict";var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.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},o.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)}};o.setTyped=function(l){l?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,s)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(i)},{}],42:[function(n,r,o){"use strict";var i=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 i.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,i.shrinkBuf(d,f));for(var h="",p=0;p<f;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,o.string2buf=function(d){var f,h,p,m,g,y=d.length,b=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++),b+=h<128?1:h<2048?2:h<65536?3:4;for(f=new i.Buf8(b),m=g=0;g<b;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},o.buf2binstring=function(d){return u(d,d.length)},o.binstring2buf=function(d){for(var f=new i.Buf8(d.length),h=0,p=f.length;h<p;h++)f[h]=d.charCodeAt(h);return f},o.buf2string=function(d,f){var h,p,m,g,y=f||d.length,b=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)b[p++]=m;else if(4<(g=l[m]))b[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?b[p++]=65533:m<65536?b[p++]=m:(m-=65536,b[p++]=55296|m>>10&1023,b[p++]=56320|1023&m)}return u(b,p)},o.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,o){"use strict";r.exports=function(i,s,a,l){for(var c=65535&i|0,u=i>>>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,o){"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,o){"use strict";var i=(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=i,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,o){"use strict";var i,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,b=8,v=9,A=286,S=30,w=19,T=2*A+1,x=15,C=3,k=258,P=k+C+1,E=42,L=113,R=1,M=2,O=3,H=4;function W(N,V){return N.msg=u[V],V}function G(N){return(N<<1)-(4<N?9:0)}function U(N){for(var V=N.length;0<=--V;)N[V]=0}function F(N){var V=N.state,re=V.pending;re>N.avail_out&&(re=N.avail_out),re!==0&&(s.arraySet(N.output,V.pending_buf,V.pending_out,re,N.next_out),N.next_out+=re,V.pending_out+=re,N.total_out+=re,N.avail_out-=re,V.pending-=re,V.pending===0&&(V.pending_out=0))}function ne(N,V){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,V),N.block_start=N.strstart,F(N.strm)}function Y(N,V){N.pending_buf[N.pending++]=V}function ve(N,V){N.pending_buf[N.pending++]=V>>>8&255,N.pending_buf[N.pending++]=255&V}function Z(N,V){var re,J,K=N.max_chain_length,$=N.strstart,me=N.prev_length,ye=N.nice_match,ee=N.strstart>N.w_size-P?N.strstart-(N.w_size-P):0,de=N.window,be=N.w_mask,oe=N.prev,te=N.strstart+k,xe=de[$+me-1],Ce=de[$+me];N.prev_length>=N.good_match&&(K>>=2),ye>N.lookahead&&(ye=N.lookahead);do if(de[(re=V)+me]===Ce&&de[re+me-1]===xe&&de[re]===de[$]&&de[++re]===de[$+1]){$+=2,re++;do;while(de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&de[++$]===de[++re]&&$<te);if(J=k-(te-$),$=te-k,me<J){if(N.match_start=V,ye<=(me=J))break;xe=de[$+me-1],Ce=de[$+me]}}while((V=oe[V&be])>ee&&--K!=0);return me<=N.lookahead?me:N.lookahead}function X(N){var V,re,J,K,$,me,ye,ee,de,be,oe=N.w_size;do{if(K=N.window_size-N.lookahead-N.strstart,N.strstart>=oe+(oe-P)){for(s.arraySet(N.window,N.window,oe,oe,0),N.match_start-=oe,N.strstart-=oe,N.block_start-=oe,V=re=N.hash_size;J=N.head[--V],N.head[V]=oe<=J?J-oe:0,--re;);for(V=re=oe;J=N.prev[--V],N.prev[V]=oe<=J?J-oe:0,--re;);K+=oe}if(N.strm.avail_in===0)break;if(me=N.strm,ye=N.window,ee=N.strstart+N.lookahead,de=K,be=void 0,be=me.avail_in,de<be&&(be=de),re=be===0?0:(me.avail_in-=be,s.arraySet(ye,me.input,me.next_in,be,ee),me.state.wrap===1?me.adler=l(me.adler,ye,be,ee):me.state.wrap===2&&(me.adler=c(me.adler,ye,be,ee)),me.next_in+=be,me.total_in+=be,be),N.lookahead+=re,N.lookahead+N.insert>=C)for($=N.strstart-N.insert,N.ins_h=N.window[$],N.ins_h=(N.ins_h<<N.hash_shift^N.window[$+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[$+C-1])&N.hash_mask,N.prev[$&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=$,$++,N.insert--,!(N.lookahead+N.insert<C)););}while(N.lookahead<P&&N.strm.avail_in!==0)}function ae(N,V){for(var re,J;;){if(N.lookahead<P){if(X(N),N.lookahead<P&&V===d)return R;if(N.lookahead===0)break}if(re=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,re=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),re!==0&&N.strstart-re<=N.w_size-P&&(N.match_length=Z(N,re)),N.match_length>=C)if(J=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,re=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 J=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++;if(J&&(ne(N,!1),N.strm.avail_out===0))return R}return N.insert=N.strstart<C-1?N.strstart:C-1,V===f?(ne(N,!0),N.strm.avail_out===0?O:H):N.last_lit&&(ne(N,!1),N.strm.avail_out===0)?R:M}function he(N,V){for(var re,J,K;;){if(N.lookahead<P){if(X(N),N.lookahead<P&&V===d)return R;if(N.lookahead===0)break}if(re=0,N.lookahead>=C&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,re=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,re!==0&&N.prev_length<N.max_lazy_match&&N.strstart-re<=N.w_size-P&&(N.match_length=Z(N,re),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(K=N.strstart+N.lookahead-C,J=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<=K&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+C-1])&N.hash_mask,re=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++,J&&(ne(N,!1),N.strm.avail_out===0))return R}else if(N.match_available){if((J=a._tr_tally(N,0,N.window[N.strstart-1]))&&ne(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&&(J=a._tr_tally(N,0,N.window[N.strstart-1]),N.match_available=0),N.insert=N.strstart<C-1?N.strstart:C-1,V===f?(ne(N,!0),N.strm.avail_out===0?O:H):N.last_lit&&(ne(N,!1),N.strm.avail_out===0)?R:M}function Ae(N,V,re,J,K){this.good_length=N,this.max_lazy=V,this.nice_length=re,this.max_chain=J,this.func=K}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=b,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*S+1)),this.bl_tree=new s.Buf16(2*(2*w+1)),U(this.dyn_ltree),U(this.dyn_dtree),U(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(x+1),this.heap=new s.Buf16(2*A+1),U(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),U(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 _e(N){var V;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(V=N.state).pending=0,V.pending_out=0,V.wrap<0&&(V.wrap=-V.wrap),V.status=V.wrap?E:L,N.adler=V.wrap===2?0:1,V.last_flush=d,a._tr_init(V),h):W(N,p)}function B(N){var V=_e(N);return V===h&&(function(re){re.window_size=2*re.w_size,U(re.head),re.max_lazy_match=i[re.level].max_lazy,re.good_match=i[re.level].good_length,re.nice_match=i[re.level].nice_length,re.max_chain_length=i[re.level].max_chain,re.strstart=0,re.block_start=0,re.lookahead=0,re.insert=0,re.match_length=re.prev_length=C-1,re.match_available=0,re.ins_h=0})(N.state),V}function D(N,V,re,J,K,$){if(!N)return p;var me=1;if(V===m&&(V=6),J<0?(me=0,J=-J):15<J&&(me=2,J-=16),K<1||v<K||re!==b||J<8||15<J||V<0||9<V||$<0||g<$)return W(N,p);J===8&&(J=9);var ye=new ke;return(N.state=ye).strm=N,ye.wrap=me,ye.gzhead=null,ye.w_bits=J,ye.w_size=1<<ye.w_bits,ye.w_mask=ye.w_size-1,ye.hash_bits=K+7,ye.hash_size=1<<ye.hash_bits,ye.hash_mask=ye.hash_size-1,ye.hash_shift=~~((ye.hash_bits+C-1)/C),ye.window=new s.Buf8(2*ye.w_size),ye.head=new s.Buf16(ye.hash_size),ye.prev=new s.Buf16(ye.w_size),ye.lit_bufsize=1<<K+6,ye.pending_buf_size=4*ye.lit_bufsize,ye.pending_buf=new s.Buf8(ye.pending_buf_size),ye.d_buf=1*ye.lit_bufsize,ye.l_buf=3*ye.lit_bufsize,ye.level=V,ye.strategy=$,ye.method=re,B(N)}i=[new Ae(0,0,0,0,function(N,V){var re=65535;for(re>N.pending_buf_size-5&&(re=N.pending_buf_size-5);;){if(N.lookahead<=1){if(X(N),N.lookahead===0&&V===d)return R;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var J=N.block_start+re;if((N.strstart===0||N.strstart>=J)&&(N.lookahead=N.strstart-J,N.strstart=J,ne(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-P&&(ne(N,!1),N.strm.avail_out===0))return R}return N.insert=0,V===f?(ne(N,!0),N.strm.avail_out===0?O:H):(N.strstart>N.block_start&&(ne(N,!1),N.strm.avail_out),R)}),new Ae(4,4,8,4,ae),new Ae(4,5,16,8,ae),new Ae(4,6,32,32,ae),new Ae(4,4,16,16,he),new Ae(8,16,32,32,he),new Ae(8,16,128,128,he),new Ae(8,32,128,256,he),new Ae(32,128,258,1024,he),new Ae(32,258,258,4096,he)],o.deflateInit=function(N,V){return D(N,V,b,15,8,0)},o.deflateInit2=D,o.deflateReset=B,o.deflateResetKeep=_e,o.deflateSetHeader=function(N,V){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=V,h):p},o.deflate=function(N,V){var re,J,K,$;if(!N||!N.state||5<V||V<0)return N?W(N,p):p;if(J=N.state,!N.output||!N.input&&N.avail_in!==0||J.status===666&&V!==f)return W(N,N.avail_out===0?-5:p);if(J.strm=N,re=J.last_flush,J.last_flush=V,J.status===E)if(J.wrap===2)N.adler=0,Y(J,31),Y(J,139),Y(J,8),J.gzhead?(Y(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(J.gzhead.extra?4:0)+(J.gzhead.name?8:0)+(J.gzhead.comment?16:0)),Y(J,255&J.gzhead.time),Y(J,J.gzhead.time>>8&255),Y(J,J.gzhead.time>>16&255),Y(J,J.gzhead.time>>24&255),Y(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),Y(J,255&J.gzhead.os),J.gzhead.extra&&J.gzhead.extra.length&&(Y(J,255&J.gzhead.extra.length),Y(J,J.gzhead.extra.length>>8&255)),J.gzhead.hcrc&&(N.adler=c(N.adler,J.pending_buf,J.pending,0)),J.gzindex=0,J.status=69):(Y(J,0),Y(J,0),Y(J,0),Y(J,0),Y(J,0),Y(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),Y(J,3),J.status=L);else{var me=b+(J.w_bits-8<<4)<<8;me|=(2<=J.strategy||J.level<2?0:J.level<6?1:J.level===6?2:3)<<6,J.strstart!==0&&(me|=32),me+=31-me%31,J.status=L,ve(J,me),J.strstart!==0&&(ve(J,N.adler>>>16),ve(J,65535&N.adler)),N.adler=1}if(J.status===69)if(J.gzhead.extra){for(K=J.pending;J.gzindex<(65535&J.gzhead.extra.length)&&(J.pending!==J.pending_buf_size||(J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),F(N),K=J.pending,J.pending!==J.pending_buf_size));)Y(J,255&J.gzhead.extra[J.gzindex]),J.gzindex++;J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),J.gzindex===J.gzhead.extra.length&&(J.gzindex=0,J.status=73)}else J.status=73;if(J.status===73)if(J.gzhead.name){K=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),F(N),K=J.pending,J.pending===J.pending_buf_size)){$=1;break}$=J.gzindex<J.gzhead.name.length?255&J.gzhead.name.charCodeAt(J.gzindex++):0,Y(J,$)}while($!==0);J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),$===0&&(J.gzindex=0,J.status=91)}else J.status=91;if(J.status===91)if(J.gzhead.comment){K=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),F(N),K=J.pending,J.pending===J.pending_buf_size)){$=1;break}$=J.gzindex<J.gzhead.comment.length?255&J.gzhead.comment.charCodeAt(J.gzindex++):0,Y(J,$)}while($!==0);J.gzhead.hcrc&&J.pending>K&&(N.adler=c(N.adler,J.pending_buf,J.pending-K,K)),$===0&&(J.status=103)}else J.status=103;if(J.status===103&&(J.gzhead.hcrc?(J.pending+2>J.pending_buf_size&&F(N),J.pending+2<=J.pending_buf_size&&(Y(J,255&N.adler),Y(J,N.adler>>8&255),N.adler=0,J.status=L)):J.status=L),J.pending!==0){if(F(N),N.avail_out===0)return J.last_flush=-1,h}else if(N.avail_in===0&&G(V)<=G(re)&&V!==f)return W(N,-5);if(J.status===666&&N.avail_in!==0)return W(N,-5);if(N.avail_in!==0||J.lookahead!==0||V!==d&&J.status!==666){var ye=J.strategy===2?(function(ee,de){for(var be;;){if(ee.lookahead===0&&(X(ee),ee.lookahead===0)){if(de===d)return R;break}if(ee.match_length=0,be=a._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++,be&&(ne(ee,!1),ee.strm.avail_out===0))return R}return ee.insert=0,de===f?(ne(ee,!0),ee.strm.avail_out===0?O:H):ee.last_lit&&(ne(ee,!1),ee.strm.avail_out===0)?R:M})(J,V):J.strategy===3?(function(ee,de){for(var be,oe,te,xe,Ce=ee.window;;){if(ee.lookahead<=k){if(X(ee),ee.lookahead<=k&&de===d)return R;if(ee.lookahead===0)break}if(ee.match_length=0,ee.lookahead>=C&&0<ee.strstart&&(oe=Ce[te=ee.strstart-1])===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]){xe=ee.strstart+k;do;while(oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&oe===Ce[++te]&&te<xe);ee.match_length=k-(xe-te),ee.match_length>ee.lookahead&&(ee.match_length=ee.lookahead)}if(ee.match_length>=C?(be=a._tr_tally(ee,1,ee.match_length-C),ee.lookahead-=ee.match_length,ee.strstart+=ee.match_length,ee.match_length=0):(be=a._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++),be&&(ne(ee,!1),ee.strm.avail_out===0))return R}return ee.insert=0,de===f?(ne(ee,!0),ee.strm.avail_out===0?O:H):ee.last_lit&&(ne(ee,!1),ee.strm.avail_out===0)?R:M})(J,V):i[J.level].func(J,V);if(ye!==O&&ye!==H||(J.status=666),ye===R||ye===O)return N.avail_out===0&&(J.last_flush=-1),h;if(ye===M&&(V===1?a._tr_align(J):V!==5&&(a._tr_stored_block(J,0,0,!1),V===3&&(U(J.head),J.lookahead===0&&(J.strstart=0,J.block_start=0,J.insert=0))),F(N),N.avail_out===0))return J.last_flush=-1,h}return V!==f?h:J.wrap<=0?1:(J.wrap===2?(Y(J,255&N.adler),Y(J,N.adler>>8&255),Y(J,N.adler>>16&255),Y(J,N.adler>>24&255),Y(J,255&N.total_in),Y(J,N.total_in>>8&255),Y(J,N.total_in>>16&255),Y(J,N.total_in>>24&255)):(ve(J,N.adler>>>16),ve(J,65535&N.adler)),F(N),0<J.wrap&&(J.wrap=-J.wrap),J.pending!==0?h:1)},o.deflateEnd=function(N){var V;return N&&N.state?(V=N.state.status)!==E&&V!==69&&V!==73&&V!==91&&V!==103&&V!==L&&V!==666?W(N,p):(N.state=null,V===L?W(N,-3):h):p},o.deflateSetDictionary=function(N,V){var re,J,K,$,me,ye,ee,de,be=V.length;if(!N||!N.state||($=(re=N.state).wrap)===2||$===1&&re.status!==E||re.lookahead)return p;for($===1&&(N.adler=l(N.adler,V,be,0)),re.wrap=0,be>=re.w_size&&($===0&&(U(re.head),re.strstart=0,re.block_start=0,re.insert=0),de=new s.Buf8(re.w_size),s.arraySet(de,V,be-re.w_size,re.w_size,0),V=de,be=re.w_size),me=N.avail_in,ye=N.next_in,ee=N.input,N.avail_in=be,N.next_in=0,N.input=V,X(re);re.lookahead>=C;){for(J=re.strstart,K=re.lookahead-(C-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[J+C-1])&re.hash_mask,re.prev[J&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=J,J++,--K;);re.strstart=J,re.lookahead=C-1,X(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=C-1,re.match_available=0,N.next_in=ye,N.input=ee,N.avail_in=me,re.wrap=$,h},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){"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,o){"use strict";r.exports=function(i,s){var a=i.state,l=i.next_in,c,u,d,f,h,p,m,g,y,b,v,A,S,w,T,x,C,k,P,E,L,R=i.input,M;c=l+(i.avail_in-5),u=i.next_out,M=i.output,d=u-(s-i.avail_out),f=u+(i.avail_out-257),h=a.dmax,p=a.wsize,m=a.whave,g=a.wnext,y=a.window,b=a.hold,v=a.bits,A=a.lencode,S=a.distcode,w=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{v<15&&(b+=R[l++]<<v,v+=8,b+=R[l++]<<v,v+=8),x=A[b&w];t:for(;;){if(b>>>=C=x>>>24,v-=C,(C=x>>>16&255)===0)M[u++]=65535&x;else{if(!(16&C)){if((64&C)==0){x=A[(65535&x)+(b&(1<<C)-1)];continue t}if(32&C){a.mode=12;break e}i.msg="invalid literal/length code",a.mode=30;break e}k=65535&x,(C&=15)&&(v<C&&(b+=R[l++]<<v,v+=8),k+=b&(1<<C)-1,b>>>=C,v-=C),v<15&&(b+=R[l++]<<v,v+=8,b+=R[l++]<<v,v+=8),x=S[b&T];n:for(;;){if(b>>>=C=x>>>24,v-=C,!(16&(C=x>>>16&255))){if((64&C)==0){x=S[(65535&x)+(b&(1<<C)-1)];continue n}i.msg="invalid distance code",a.mode=30;break e}if(P=65535&x,v<(C&=15)&&(b+=R[l++]<<v,(v+=8)<C&&(b+=R[l++]<<v,v+=8)),h<(P+=b&(1<<C)-1)){i.msg="invalid distance too far back",a.mode=30;break e}if(b>>>=C,v-=C,(C=u-d)<P){if(m<(C=P-C)&&a.sane){i.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(E=0)===g){if(E+=p-C,C<k){for(k-=C;M[u++]=y[E++],--C;);E=u-P,L=M}}else if(g<C){if(E+=p+g-C,(C-=g)<k){for(k-=C;M[u++]=y[E++],--C;);if(E=0,g<k){for(k-=C=g;M[u++]=y[E++],--C;);E=u-P,L=M}}}else if(E+=g-C,C<k){for(k-=C;M[u++]=y[E++],--C;);E=u-P,L=M}for(;2<k;)M[u++]=L[E++],M[u++]=L[E++],M[u++]=L[E++],k-=3;k&&(M[u++]=L[E++],1<k&&(M[u++]=L[E++]))}else{for(E=u-P;M[u++]=M[E++],M[u++]=M[E++],M[u++]=M[E++],2<(k-=3););k&&(M[u++]=M[E++],1<k&&(M[u++]=M[E++]))}break}}break}}while(l<c&&u<f);l-=k=v>>3,b&=(1<<(v-=k<<3))-1,i.next_in=l,i.next_out=u,i.avail_in=l<c?c-l+5:5-(l-c),i.avail_out=u<f?f-u+257:257-(u-f),a.hold=b,a.bits=v}},{}],49:[function(n,r,o){"use strict";var i=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 b(){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 i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(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 i.Buf32(m),L.distcode=L.distdyn=new i.Buf32(g),L.sane=1,L.back=-1,f):h}function A(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,v(E)):h}function S(E,L){var R,M;return E&&E.state?(M=E.state,L<0?(R=0,L=-L):(R=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(M.window!==null&&M.wbits!==L&&(M.window=null),M.wrap=R,M.wbits=L,A(E))):h}function w(E,L){var R,M;return E?(M=new b,(E.state=M).window=null,(R=S(E,L))!==f&&(E.state=null),R):h}var T,x,C=!0;function k(E){if(C){var L;for(T=new i.Buf32(512),x=new i.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,x,0,E.work,{bits:5}),C=!1}E.lencode=T,E.lenbits=9,E.distcode=x,E.distbits=5}function P(E,L,R,M){var O,H=E.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new i.Buf8(H.wsize)),M>=H.wsize?(i.arraySet(H.window,L,R-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(M<(O=H.wsize-H.wnext)&&(O=M),i.arraySet(H.window,L,R-M,O,H.wnext),(M-=O)?(i.arraySet(H.window,L,R-M,M,0),H.wnext=M,H.whave=H.wsize):(H.wnext+=O,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=O))),0}o.inflateReset=A,o.inflateReset2=S,o.inflateResetKeep=v,o.inflateInit=function(E){return w(E,15)},o.inflateInit2=w,o.inflate=function(E,L){var R,M,O,H,W,G,U,F,ne,Y,ve,Z,X,ae,he,Ae,ke,_e,B,D,N,V,re,J,K=0,$=new i.Buf8(4),me=[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),W=E.next_out,O=E.output,U=E.avail_out,H=E.next_in,M=E.input,G=E.avail_in,F=R.hold,ne=R.bits,Y=G,ve=U,V=f;e:for(;;)switch(R.mode){case p:if(R.wrap===0){R.mode=13;break}for(;ne<16;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(2&R.wrap&&F===35615){$[R.check=0]=255&F,$[1]=F>>>8&255,R.check=a(R.check,$,2,0),ne=F=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&F)<<8)+(F>>8))%31){E.msg="incorrect header check",R.mode=30;break}if((15&F)!=8){E.msg="unknown compression method",R.mode=30;break}if(ne-=4,N=8+(15&(F>>>=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&F?10:12,ne=F=0;break;case 2:for(;ne<16;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(R.flags=F,(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=F>>8&1),512&R.flags&&($[0]=255&F,$[1]=F>>>8&255,R.check=a(R.check,$,2,0)),ne=F=0,R.mode=3;case 3:for(;ne<32;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.head&&(R.head.time=F),512&R.flags&&($[0]=255&F,$[1]=F>>>8&255,$[2]=F>>>16&255,$[3]=F>>>24&255,R.check=a(R.check,$,4,0)),ne=F=0,R.mode=4;case 4:for(;ne<16;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.head&&(R.head.xflags=255&F,R.head.os=F>>8),512&R.flags&&($[0]=255&F,$[1]=F>>>8&255,R.check=a(R.check,$,2,0)),ne=F=0,R.mode=5;case 5:if(1024&R.flags){for(;ne<16;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.length=F,R.head&&(R.head.extra_len=F),512&R.flags&&($[0]=255&F,$[1]=F>>>8&255,R.check=a(R.check,$,2,0)),ne=F=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(G<(Z=R.length)&&(Z=G),Z&&(R.head&&(N=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),i.arraySet(R.head.extra,M,H,Z,N)),512&R.flags&&(R.check=a(R.check,M,Z,H)),G-=Z,H+=Z,R.length-=Z),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(G===0)break e;for(Z=0;N=M[H+Z++],R.head&&N&&R.length<65536&&(R.head.name+=String.fromCharCode(N)),N&&Z<G;);if(512&R.flags&&(R.check=a(R.check,M,Z,H)),G-=Z,H+=Z,N)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(G===0)break e;for(Z=0;N=M[H+Z++],R.head&&N&&R.length<65536&&(R.head.comment+=String.fromCharCode(N)),N&&Z<G;);if(512&R.flags&&(R.check=a(R.check,M,Z,H)),G-=Z,H+=Z,N)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;ne<16;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(F!==(65535&R.check)){E.msg="header crc mismatch",R.mode=30;break}ne=F=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(;ne<32;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}E.adler=R.check=y(F),ne=F=0,R.mode=11;case 11:if(R.havedict===0)return E.next_out=W,E.avail_out=U,E.next_in=H,E.avail_in=G,R.hold=F,R.bits=ne,2;E.adler=R.check=1,R.mode=12;case 12:if(L===5||L===6)break e;case 13:if(R.last){F>>>=7&ne,ne-=7&ne,R.mode=27;break}for(;ne<3;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}switch(R.last=1&F,ne-=1,3&(F>>>=1)){case 0:R.mode=14;break;case 1:if(k(R),R.mode=20,L!==6)break;F>>>=2,ne-=2;break e;case 2:R.mode=17;break;case 3:E.msg="invalid block type",R.mode=30}F>>>=2,ne-=2;break;case 14:for(F>>>=7&ne,ne-=7&ne;ne<32;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if((65535&F)!=(F>>>16^65535)){E.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&F,ne=F=0,R.mode=15,L===6)break e;case 15:R.mode=16;case 16:if(Z=R.length){if(G<Z&&(Z=G),U<Z&&(Z=U),Z===0)break e;i.arraySet(O,M,H,Z,W),G-=Z,H+=Z,U-=Z,W+=Z,R.length-=Z;break}R.mode=12;break;case 17:for(;ne<14;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(R.nlen=257+(31&F),F>>>=5,ne-=5,R.ndist=1+(31&F),F>>>=5,ne-=5,R.ncode=4+(15&F),F>>>=4,ne-=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(;ne<3;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.lens[me[R.have++]]=7&F,F>>>=3,ne-=3}for(;R.have<19;)R.lens[me[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,re={bits:R.lenbits},V=c(0,R.lens,0,19,R.lencode,0,R.work,re),R.lenbits=re.bits,V){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(;Ae=(K=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ke=65535&K,!((he=K>>>24)<=ne);){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(ke<16)F>>>=he,ne-=he,R.lens[R.have++]=ke;else{if(ke===16){for(J=he+2;ne<J;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(F>>>=he,ne-=he,R.have===0){E.msg="invalid bit length repeat",R.mode=30;break}N=R.lens[R.have-1],Z=3+(3&F),F>>>=2,ne-=2}else if(ke===17){for(J=he+3;ne<J;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}ne-=he,N=0,Z=3+(7&(F>>>=he)),F>>>=3,ne-=3}else{for(J=he+7;ne<J;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}ne-=he,N=0,Z=11+(127&(F>>>=he)),F>>>=7,ne-=7}if(R.have+Z>R.nlen+R.ndist){E.msg="invalid bit length repeat",R.mode=30;break}for(;Z--;)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,re={bits:R.lenbits},V=c(u,R.lens,0,R.nlen,R.lencode,0,R.work,re),R.lenbits=re.bits,V){E.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,re={bits:R.distbits},V=c(d,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,re),R.distbits=re.bits,V){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<=G&&258<=U){E.next_out=W,E.avail_out=U,E.next_in=H,E.avail_in=G,R.hold=F,R.bits=ne,l(E,ve),W=E.next_out,O=E.output,U=E.avail_out,H=E.next_in,M=E.input,G=E.avail_in,F=R.hold,ne=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;Ae=(K=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ke=65535&K,!((he=K>>>24)<=ne);){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(Ae&&(240&Ae)==0){for(_e=he,B=Ae,D=ke;Ae=(K=R.lencode[D+((F&(1<<_e+B)-1)>>_e)])>>>16&255,ke=65535&K,!(_e+(he=K>>>24)<=ne);){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}F>>>=_e,ne-=_e,R.back+=_e}if(F>>>=he,ne-=he,R.back+=he,R.length=ke,Ae===0){R.mode=26;break}if(32&Ae){R.back=-1,R.mode=12;break}if(64&Ae){E.msg="invalid literal/length code",R.mode=30;break}R.extra=15&Ae,R.mode=22;case 22:if(R.extra){for(J=R.extra;ne<J;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.length+=F&(1<<R.extra)-1,F>>>=R.extra,ne-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;Ae=(K=R.distcode[F&(1<<R.distbits)-1])>>>16&255,ke=65535&K,!((he=K>>>24)<=ne);){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if((240&Ae)==0){for(_e=he,B=Ae,D=ke;Ae=(K=R.distcode[D+((F&(1<<_e+B)-1)>>_e)])>>>16&255,ke=65535&K,!(_e+(he=K>>>24)<=ne);){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}F>>>=_e,ne-=_e,R.back+=_e}if(F>>>=he,ne-=he,R.back+=he,64&Ae){E.msg="invalid distance code",R.mode=30;break}R.offset=ke,R.extra=15&Ae,R.mode=24;case 24:if(R.extra){for(J=R.extra;ne<J;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}R.offset+=F&(1<<R.extra)-1,F>>>=R.extra,ne-=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(U===0)break e;if(Z=ve-U,R.offset>Z){if((Z=R.offset-Z)>R.whave&&R.sane){E.msg="invalid distance too far back",R.mode=30;break}X=Z>R.wnext?(Z-=R.wnext,R.wsize-Z):R.wnext-Z,Z>R.length&&(Z=R.length),ae=R.window}else ae=O,X=W-R.offset,Z=R.length;for(U<Z&&(Z=U),U-=Z,R.length-=Z;O[W++]=ae[X++],--Z;);R.length===0&&(R.mode=21);break;case 26:if(U===0)break e;O[W++]=R.length,U--,R.mode=21;break;case 27:if(R.wrap){for(;ne<32;){if(G===0)break e;G--,F|=M[H++]<<ne,ne+=8}if(ve-=U,E.total_out+=ve,R.total+=ve,ve&&(E.adler=R.check=R.flags?a(R.check,O,ve,W-ve):s(R.check,O,ve,W-ve)),ve=U,(R.flags?F:y(F))!==R.check){E.msg="incorrect data check",R.mode=30;break}ne=F=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;ne<32;){if(G===0)break e;G--,F+=M[H++]<<ne,ne+=8}if(F!==(4294967295&R.total)){E.msg="incorrect length check",R.mode=30;break}ne=F=0}R.mode=29;case 29:V=1;break e;case 30:V=-3;break e;case 31:return-4;default:return h}return E.next_out=W,E.avail_out=U,E.next_in=H,E.avail_in=G,R.hold=F,R.bits=ne,(R.wsize||ve!==E.avail_out&&R.mode<30&&(R.mode<27||L!==4))&&P(E,E.output,E.next_out,ve-E.avail_out)?(R.mode=31,-4):(Y-=E.avail_in,ve-=E.avail_out,E.total_in+=Y,E.total_out+=ve,R.total+=ve,R.wrap&&ve&&(E.adler=R.check=R.flags?a(R.check,O,ve,E.next_out-ve):s(R.check,O,ve,E.next_out-ve)),E.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(Y==0&&ve===0||L===4)&&V===f&&(V=-5),V)},o.inflateEnd=function(E){if(!E||!E.state)return h;var L=E.state;return L.window&&(L.window=null),E.state=null,f},o.inflateGetHeader=function(E,L){var R;return E&&E.state?(2&(R=E.state).wrap)==0?h:((R.head=L).done=!1,f):h},o.inflateSetDictionary=function(E,L){var R,M=L.length;return E&&E.state?(R=E.state).wrap!==0&&R.mode!==11?h:R.mode===11&&s(1,L,M,0)!==R.check?-3:P(E,L,M,M)?(R.mode=31,-4):(R.havedict=1,f):h},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){"use strict";var i=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 b,v,A,S,w,T,x,C,k,P=y.bits,E=0,L=0,R=0,M=0,O=0,H=0,W=0,G=0,U=0,F=0,ne=null,Y=0,ve=new i.Buf16(16),Z=new i.Buf16(16),X=null,ae=0;for(E=0;E<=15;E++)ve[E]=0;for(L=0;L<h;L++)ve[d[f+L]]++;for(O=P,M=15;1<=M&&ve[M]===0;M--);if(M<O&&(O=M),M===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(R=1;R<M&&ve[R]===0;R++);for(O<R&&(O=R),E=G=1;E<=15;E++)if(G<<=1,(G-=ve[E])<0)return-1;if(0<G&&(u===0||M!==1))return-1;for(Z[1]=0,E=1;E<15;E++)Z[E+1]=Z[E]+ve[E];for(L=0;L<h;L++)d[f+L]!==0&&(g[Z[d[f+L]]++]=L);if(T=u===0?(ne=X=g,19):u===1?(ne=s,Y-=257,X=a,ae-=257,256):(ne=l,X=c,-1),E=R,w=m,W=L=F=0,A=-1,S=(U=1<<(H=O))-1,u===1&&852<U||u===2&&592<U)return 1;for(;;){for(x=E-W,k=g[L]<T?(C=0,g[L]):g[L]>T?(C=X[ae+g[L]],ne[Y+g[L]]):(C=96,0),b=1<<E-W,R=v=1<<H;p[w+(F>>W)+(v-=b)]=x<<24|C<<16|k|0,v!==0;);for(b=1<<E-1;F&b;)b>>=1;if(b!==0?(F&=b-1,F+=b):F=0,L++,--ve[E]==0){if(E===M)break;E=d[f+g[L]]}if(O<E&&(F&S)!==A){for(W===0&&(W=O),w+=R,G=1<<(H=E-W);H+W<M&&!((G-=ve[H+W])<=0);)H++,G<<=1;if(U+=1<<H,u===1&&852<U||u===2&&592<U)return 1;p[A=F&S]=O<<24|H<<16|w-m|0}}return F!==0&&(p[w+F]=E-W<<24|4194304),y.bits=O,0}},{"../utils/common":41}],51:[function(n,r,o){"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,o){"use strict";var i=n("../utils/common"),s=0,a=1;function l(K){for(var $=K.length;0<=--$;)K[$]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,b=7,v=256,A=16,S=17,w=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],x=[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],k=[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 M=new Array(u);l(M);var O,H,W,G=new Array(h);function U(K,$,me,ye,ee){this.static_tree=K,this.extra_bits=$,this.extra_base=me,this.elems=ye,this.max_length=ee,this.has_stree=K&&K.length}function F(K,$){this.dyn_tree=K,this.max_code=0,this.stat_desc=$}function ne(K){return K<256?L[K]:L[256+(K>>>7)]}function Y(K,$){K.pending_buf[K.pending++]=255&$,K.pending_buf[K.pending++]=$>>>8&255}function ve(K,$,me){K.bi_valid>y-me?(K.bi_buf|=$<<K.bi_valid&65535,Y(K,K.bi_buf),K.bi_buf=$>>y-K.bi_valid,K.bi_valid+=me-y):(K.bi_buf|=$<<K.bi_valid&65535,K.bi_valid+=me)}function Z(K,$,me){ve(K,me[2*$],me[2*$+1])}function X(K,$){for(var me=0;me|=1&K,K>>>=1,me<<=1,0<--$;);return me>>>1}function ae(K,$,me){var ye,ee,de=new Array(g+1),be=0;for(ye=1;ye<=g;ye++)de[ye]=be=be+me[ye-1]<<1;for(ee=0;ee<=$;ee++){var oe=K[2*ee+1];oe!==0&&(K[2*ee]=X(de[oe]++,oe))}}function he(K){var $;for($=0;$<f;$++)K.dyn_ltree[2*$]=0;for($=0;$<h;$++)K.dyn_dtree[2*$]=0;for($=0;$<p;$++)K.bl_tree[2*$]=0;K.dyn_ltree[2*v]=1,K.opt_len=K.static_len=0,K.last_lit=K.matches=0}function Ae(K){8<K.bi_valid?Y(K,K.bi_buf):0<K.bi_valid&&(K.pending_buf[K.pending++]=K.bi_buf),K.bi_buf=0,K.bi_valid=0}function ke(K,$,me,ye){var ee=2*$,de=2*me;return K[ee]<K[de]||K[ee]===K[de]&&ye[$]<=ye[me]}function _e(K,$,me){for(var ye=K.heap[me],ee=me<<1;ee<=K.heap_len&&(ee<K.heap_len&&ke($,K.heap[ee+1],K.heap[ee],K.depth)&&ee++,!ke($,ye,K.heap[ee],K.depth));)K.heap[me]=K.heap[ee],me=ee,ee<<=1;K.heap[me]=ye}function B(K,$,me){var ye,ee,de,be,oe=0;if(K.last_lit!==0)for(;ye=K.pending_buf[K.d_buf+2*oe]<<8|K.pending_buf[K.d_buf+2*oe+1],ee=K.pending_buf[K.l_buf+oe],oe++,ye===0?Z(K,ee,$):(Z(K,(de=R[ee])+d+1,$),(be=T[de])!==0&&ve(K,ee-=M[de],be),Z(K,de=ne(--ye),me),(be=x[de])!==0&&ve(K,ye-=G[de],be)),oe<K.last_lit;);Z(K,v,$)}function D(K,$){var me,ye,ee,de=$.dyn_tree,be=$.stat_desc.static_tree,oe=$.stat_desc.has_stree,te=$.stat_desc.elems,xe=-1;for(K.heap_len=0,K.heap_max=m,me=0;me<te;me++)de[2*me]!==0?(K.heap[++K.heap_len]=xe=me,K.depth[me]=0):de[2*me+1]=0;for(;K.heap_len<2;)de[2*(ee=K.heap[++K.heap_len]=xe<2?++xe:0)]=1,K.depth[ee]=0,K.opt_len--,oe&&(K.static_len-=be[2*ee+1]);for($.max_code=xe,me=K.heap_len>>1;1<=me;me--)_e(K,de,me);for(ee=te;me=K.heap[1],K.heap[1]=K.heap[K.heap_len--],_e(K,de,1),ye=K.heap[1],K.heap[--K.heap_max]=me,K.heap[--K.heap_max]=ye,de[2*ee]=de[2*me]+de[2*ye],K.depth[ee]=(K.depth[me]>=K.depth[ye]?K.depth[me]:K.depth[ye])+1,de[2*me+1]=de[2*ye+1]=ee,K.heap[1]=ee++,_e(K,de,1),2<=K.heap_len;);K.heap[--K.heap_max]=K.heap[1],(function(Ce,De){var Ve,at,ce,pe,Re,le,ge=De.dyn_tree,Q=De.max_code,Ie=De.stat_desc.static_tree,j=De.stat_desc.has_stree,we=De.stat_desc.extra_bits,Je=De.stat_desc.extra_base,ue=De.stat_desc.max_length,Ke=0;for(pe=0;pe<=g;pe++)Ce.bl_count[pe]=0;for(ge[2*Ce.heap[Ce.heap_max]+1]=0,Ve=Ce.heap_max+1;Ve<m;Ve++)ue<(pe=ge[2*ge[2*(at=Ce.heap[Ve])+1]+1]+1)&&(pe=ue,Ke++),ge[2*at+1]=pe,Q<at||(Ce.bl_count[pe]++,Re=0,Je<=at&&(Re=we[at-Je]),le=ge[2*at],Ce.opt_len+=le*(pe+Re),j&&(Ce.static_len+=le*(Ie[2*at+1]+Re)));if(Ke!==0){do{for(pe=ue-1;Ce.bl_count[pe]===0;)pe--;Ce.bl_count[pe]--,Ce.bl_count[pe+1]+=2,Ce.bl_count[ue]--,Ke-=2}while(0<Ke);for(pe=ue;pe!==0;pe--)for(at=Ce.bl_count[pe];at!==0;)Q<(ce=Ce.heap[--Ve])||(ge[2*ce+1]!==pe&&(Ce.opt_len+=(pe-ge[2*ce+1])*ge[2*ce],ge[2*ce+1]=pe),at--)}})(K,$),ae(de,xe,K.bl_count)}function N(K,$,me){var ye,ee,de=-1,be=$[1],oe=0,te=7,xe=4;for(be===0&&(te=138,xe=3),$[2*(me+1)+1]=65535,ye=0;ye<=me;ye++)ee=be,be=$[2*(ye+1)+1],++oe<te&&ee===be||(oe<xe?K.bl_tree[2*ee]+=oe:ee!==0?(ee!==de&&K.bl_tree[2*ee]++,K.bl_tree[2*A]++):oe<=10?K.bl_tree[2*S]++:K.bl_tree[2*w]++,de=ee,xe=(oe=0)===be?(te=138,3):ee===be?(te=6,3):(te=7,4))}function V(K,$,me){var ye,ee,de=-1,be=$[1],oe=0,te=7,xe=4;for(be===0&&(te=138,xe=3),ye=0;ye<=me;ye++)if(ee=be,be=$[2*(ye+1)+1],!(++oe<te&&ee===be)){if(oe<xe)for(;Z(K,ee,K.bl_tree),--oe!=0;);else ee!==0?(ee!==de&&(Z(K,ee,K.bl_tree),oe--),Z(K,A,K.bl_tree),ve(K,oe-3,2)):oe<=10?(Z(K,S,K.bl_tree),ve(K,oe-3,3)):(Z(K,w,K.bl_tree),ve(K,oe-11,7));de=ee,xe=(oe=0)===be?(te=138,3):ee===be?(te=6,3):(te=7,4)}}l(G);var re=!1;function J(K,$,me,ye){ve(K,(c<<1)+(ye?1:0),3),(function(ee,de,be,oe){Ae(ee),oe&&(Y(ee,be),Y(ee,~be)),i.arraySet(ee.pending_buf,ee.window,de,be,ee.pending),ee.pending+=be})(K,$,me,!0)}o._tr_init=function(K){re||((function(){var $,me,ye,ee,de,be=new Array(g+1);for(ee=ye=0;ee<u-1;ee++)for(M[ee]=ye,$=0;$<1<<T[ee];$++)R[ye++]=ee;for(R[ye-1]=ee,ee=de=0;ee<16;ee++)for(G[ee]=de,$=0;$<1<<x[ee];$++)L[de++]=ee;for(de>>=7;ee<h;ee++)for(G[ee]=de<<7,$=0;$<1<<x[ee]-7;$++)L[256+de++]=ee;for(me=0;me<=g;me++)be[me]=0;for($=0;$<=143;)P[2*$+1]=8,$++,be[8]++;for(;$<=255;)P[2*$+1]=9,$++,be[9]++;for(;$<=279;)P[2*$+1]=7,$++,be[7]++;for(;$<=287;)P[2*$+1]=8,$++,be[8]++;for(ae(P,f+1,be),$=0;$<h;$++)E[2*$+1]=5,E[2*$]=X($,5);O=new U(P,T,d+1,f,g),H=new U(E,x,0,h,g),W=new U(new Array(0),C,0,p,b)})(),re=!0),K.l_desc=new F(K.dyn_ltree,O),K.d_desc=new F(K.dyn_dtree,H),K.bl_desc=new F(K.bl_tree,W),K.bi_buf=0,K.bi_valid=0,he(K)},o._tr_stored_block=J,o._tr_flush_block=function(K,$,me,ye){var ee,de,be=0;0<K.level?(K.strm.data_type===2&&(K.strm.data_type=(function(oe){var te,xe=4093624447;for(te=0;te<=31;te++,xe>>>=1)if(1&xe&&oe.dyn_ltree[2*te]!==0)return s;if(oe.dyn_ltree[18]!==0||oe.dyn_ltree[20]!==0||oe.dyn_ltree[26]!==0)return a;for(te=32;te<d;te++)if(oe.dyn_ltree[2*te]!==0)return a;return s})(K)),D(K,K.l_desc),D(K,K.d_desc),be=(function(oe){var te;for(N(oe,oe.dyn_ltree,oe.l_desc.max_code),N(oe,oe.dyn_dtree,oe.d_desc.max_code),D(oe,oe.bl_desc),te=p-1;3<=te&&oe.bl_tree[2*k[te]+1]===0;te--);return oe.opt_len+=3*(te+1)+5+5+4,te})(K),ee=K.opt_len+3+7>>>3,(de=K.static_len+3+7>>>3)<=ee&&(ee=de)):ee=de=me+5,me+4<=ee&&$!==-1?J(K,$,me,ye):K.strategy===4||de===ee?(ve(K,2+(ye?1:0),3),B(K,P,E)):(ve(K,4+(ye?1:0),3),(function(oe,te,xe,Ce){var De;for(ve(oe,te-257,5),ve(oe,xe-1,5),ve(oe,Ce-4,4),De=0;De<Ce;De++)ve(oe,oe.bl_tree[2*k[De]+1],3);V(oe,oe.dyn_ltree,te-1),V(oe,oe.dyn_dtree,xe-1)})(K,K.l_desc.max_code+1,K.d_desc.max_code+1,be+1),B(K,K.dyn_ltree,K.dyn_dtree)),he(K),ye&&Ae(K)},o._tr_tally=function(K,$,me){return K.pending_buf[K.d_buf+2*K.last_lit]=$>>>8&255,K.pending_buf[K.d_buf+2*K.last_lit+1]=255&$,K.pending_buf[K.l_buf+K.last_lit]=255&me,K.last_lit++,$===0?K.dyn_ltree[2*me]++:(K.matches++,$--,K.dyn_ltree[2*(R[me]+d+1)]++,K.dyn_dtree[2*ne($)]++),K.last_lit===K.lit_bufsize-1},o._tr_align=function(K){ve(K,2,3),Z(K,v,P),(function($){$.bi_valid===16?(Y($,$.bi_buf),$.bi_buf=0,$.bi_valid=0):8<=$.bi_valid&&($.pending_buf[$.pending++]=255&$.bi_buf,$.bi_buf>>=8,$.bi_valid-=8)})(K)}},{"../utils/common":41}],53:[function(n,r,o){"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,o){(function(i){(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(A){process.nextTick(function(){b(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,S=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=S,A}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",v,!1):s.attachEvent("onmessage",v),function(A){s.postMessage(d+A,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(A){b(A.data)},function(A){u.port2.postMessage(A)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(A){var S=m.createElement("script");S.onreadystatechange=function(){b(A),S.onreadystatechange=null,c.removeChild(S),S=null},c.appendChild(S)}):function(A){setTimeout(b,0,A)},g.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var S=new Array(arguments.length-1),w=0;w<S.length;w++)S[w]=arguments[w+1];return h[f]={callback:A,args:S},l(f),f++},g.clearImmediate=y}function y(A){delete h[A]}function b(A){if(p)setTimeout(b,0,A);else{var S=h[A];if(S){p=!0;try{(function(w){var T=w.callback,x=w.args;switch(x.length){case 0:T();break;case 1:T(x[0]);break;case 2:T(x[0],x[1]);break;case 3:T(x[0],x[1],x[2]);break;default:T.apply(a,x)}})(S)}finally{y(A),p=!1}}}}function v(A){A.source===s&&typeof A.data=="string"&&A.data.indexOf(d)===0&&b(+A.data.slice(d.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),gBe=sc(jZ(),1);const yBe=e=>/\.xml$|\.rels$/i.test(e);function SEn(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 bBe(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function qZ(e){if(typeof e=="string")return bBe(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=SEn(t);let r=new TextDecoder(n).decode(t);return r=bBe(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const KZ=[{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 TEn=sc(kg(),1),IEn="SD_OPC_QUOT",xEn=/SD_OPC_QUOT/g;function kEn(e){return String(e).replace(/&quot;/g,IEn).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(xEn,"&quot;")}function vBe(e){return TEn.js2xml(e,{spaces:0,attributeValueFn:kEn})}var CEn=sc(kg(),1),EEn="http://schemas.openxmlformats.org/package/2006/relationships";function YZ(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 _En(e,t,n){return YZ(e,t,n)!=null}function wBe(e){try{return CEn.xml2js(e,{compact:!1})}catch{return null}}function ABe(e){return vBe(e)}function SBe(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function TBe(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:EEn},elements:[]}]}}function REn(e){let t=0;for(const n of e.elements||[]){const r=n.attributes?.Id;if(!r)continue;const o=r.match(/^rId(\d+)$/);o&&(t=Math.max(t,parseInt(o[1],10)))}return t}function PEn(e,t){e.elements||(e.elements=[]);const n=new Map;for(const i of KZ)n.set(`/${i.zipPath}`,i);const r=new Map;for(let i=0;i<e.elements.length;i++){const s=e.elements[i];if(s.name!=="Override")continue;const a=s.attributes?.PartName;!a||!n.has(a)||(r.has(a)||r.set(a,[]),r.get(a).push(i))}const o=new Set;for(const[i,s]of n){const a=t.has(s.zipPath),l=r.get(i)||[];if(!a){for(const c of l)o.add(c);continue}if(l.length===0)e.elements.push({type:"element",name:"Override",attributes:{PartName:i,ContentType:s.contentType}});else{e.elements[l[0]].attributes.ContentType=s.contentType;for(let c=1;c<l.length;c++)o.add(l[c])}}if(o.size>0){const i=[...o].sort((s,a)=>a-s);for(const s of i)e.elements.splice(s,1)}}function NEn(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of KZ)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 o=new Set;let i=REn(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)o.add(u);continue}if(c.length===0)i++,e.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${i}`,Type:s,Target:a.zipPath}});else{c[0].element.attributes.Target=a.zipPath;for(let u=1;u<c.length;u++)o.add(c[u].index)}}if(o.size>0){const s=[...o].sort((a,l)=>l-a);for(const a of s)e.elements.splice(a,1)}}function IBe({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of KZ)_En(c.zipPath,e,t)&&n.add(c.zipPath);const r=YZ("[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 o=wBe(r);if(!o)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 i=SBe(o,"Types");if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");PEn(i,n);const s=YZ("_rels/.rels",e,t);let a;if(s==null)a=TBe();else if(a=wBe(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=SBe(a,"Relationships");return l||(a=TBe(),l=a.elements[0]),NEn(l,n),{contentTypesXml:ABe(o),relsXml:ABe(a)}}var LEn=sc(kg(),1);const xBe=[{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 MEn(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 DEn(e,t){if(!e)return e;let n;try{n=LEn.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 o=!1,i=MEn(r.elements);for(const s of xBe)t(s.zipPath)&&(r.elements.some(a=>a.attributes?.Type===s.relationshipType)||(i++,r.elements.push({type:"element",name:"Relationship",attributes:{Id:`rId${i}`,Type:s.relationshipType,Target:s.relTarget}}),o=!0));return o?vBe(n):e}var OEn=Rs({detectContainerType:()=>XZ},1);function kBe(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 XZ(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return kBe(t,CBe)?"zip":kBe(t,EBe)?"cfb":"unknown"}var CBe,EBe,_Be=Oe((()=>{CBe=[80,75,3,4],EBe=[208,207,17,224,161,177,26,225]}));function RBe(e){const t=e.reduce((o,i)=>o+i.length,0),n=new Uint8Array(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function FEn(e,t){return(e+1)*t}function X_(e,t){return e.getUint16(t,!0)}function Xl(e,t){return e.getUint32(t,!0)}function BEn(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function HEn(e){return PBe.decode(e).replace(/\u0000+$/g,"")}var JZ,zEn,UEn,VEn,GEn,WEn,jEn,ZZ,qEn,KEn,J_,YEn,XEn,JEn,PBe,ZEn=Oe((()=>{JZ=new Uint8Array([208,207,17,224,161,177,26,225]),zEn=512,UEn=128,VEn=109,GEn=512,WEn=4096,jEn=4294967295,ZZ=4294967294,qEn=4294967292,KEn=4294967295,J_={STORAGE:1,STREAM:2,ROOT:5},YEn=65534,XEn=3,JEn=4,PBe=new TextDecoder("utf-16le")}));function Z_(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function NBe(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function QEn(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<JZ.length;c++)if(e[c]!==JZ[c])throw new Error("Invalid CFB signature");const t=Z_(e),n=X_(t,26),r=X_(t,28),o=X_(t,30),i=X_(t,32),s=1<<o,a=1<<i;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=Xl(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:Xl(t,44),firstDirectorySector:Xl(t,48),miniStreamCutoffSize:Xl(t,56),firstMiniFatSector:Xl(t,60),numberOfMiniFatSectors:Xl(t,64),firstDifatSector:Xl(t,68),numberOfDifatSectors:Xl(t,72),difatEntries:l}}function QZ(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=FEn(n,t.sectorSize);return NBe(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function $En(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let o=0;o<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);o++){const i=Z_(QZ(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=Xl(i,a*4);l!==4294967295&&n.push(l)}r=Xl(i,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 e_n(e,t){const n=$En(e,t),r=[];for(const o of n){const i=Z_(QZ(e,t,o)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(Xl(i,a*4))}return r}function q5(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const o=[],i=new Set;let s=r;for(;s!==ZZ;){if(i.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`);i.add(s),o.push(QZ(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return RBe(o)}function t_n(e,t){const n=BEn(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 n_n(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),o=Z_(r),i=X_(o,64),s=r.subarray(0,Math.max(0,Math.min(i,64)-2));t.push({name:HEn(s),objectType:r[66],leftSiblingId:Xl(o,68),rightSiblingId:Xl(o,72),childId:Xl(o,76),startSector:Xl(o,116),streamSize:t_n(o,120)})}return t}function $Z(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 o=e[t];return!!($Z(e,o.leftSiblingId,n,r)||n(o)===!0||$Z(e,o.rightSiblingId,n,r))}function r_n(e,t){const n=t.split("/").map(o=>o.trim()).filter(Boolean);let r=e[0];for(const o of n){if(r.objectType!==J_.ROOT&&r.objectType!==J_.STORAGE)return null;let i=null;if($Z(e,r.childId,s=>s.name.toLowerCase()===o.toLowerCase()?(i=s,!0):!1),!i)return null;r=i}return r}function o_n(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):q5(t,n,r,e.startSector).subarray(0,e.streamSize)}function i_n(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=q5(e,t,n,t.firstMiniFatSector),o=Z_(r),i=Math.floor(r.length/4),s=[];for(let a=0;a<i;a++)s.push(Xl(o,a*4));return s}function s_n(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const o=[],i=new Set;let s=r;for(;s!==ZZ;){if(i.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`);i.add(s);const a=s*n;NBe(e,a,n,`mini sector ${s}`),o.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 RBe(o)}function a_n(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=QEn(t),r=e_n(t,n),o=n_n(q5(t,n,r,n.firstDirectorySector));if(o.length===0||o[0].objectType!==J_.ROOT)throw new Error("CFB root directory entry is missing");const i=o[0],s=i_n(t,n,r),a=o_n(i,t,n,r);return{getStream(l){const c=r_n(o,l);return!c||c.objectType!==J_.STREAM?null:c.streamSize<n.miniStreamCutoffSize?s_n(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):q5(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var l_n=Oe((()=>{ZEn()}));function c_n(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=a_n(t)}catch(i){throw new ps(_a.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",i instanceof Error?i:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new ps(_a.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const o=n.getStream("/EncryptedPackage");if(!o)throw new ps(_a.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:o}}var u_n=Oe((()=>{l_n(),q_()}));function LBe(e,t){return e[t]|e[t+1]<<8}function eQ(e,t){const n=new RegExp(`<(?:\\w+:)?${t}\\b([^>]*)/?>`),r=e.match(n);if(!r)return null;const o={},i=/(\w+)="([^"]*)"/g;let s;for(;(s=i.exec(r[1]))!==null;)o[s[1]]=s[2];return o}function d_n(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 FT(e,t,n){const r=e?.[t];if(r==null)throw new ps(_a.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function Dv(e,t,n){return d_n(FT(e,t,n))}function BT(e,t,n){const r=parseInt(FT(e,t,n),10);if(Number.isNaN(r))throw new ps(_a.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function f_n(e){const t=new TextDecoder("utf-8").decode(e),n=eQ(t,"keyData"),r=eQ(t,"dataIntegrity"),o=eQ(t,"encryptedKey");return{keySalt:Dv(n,"saltValue","keyData"),keyBits:BT(n,"keyBits","keyData"),hashAlgorithm:FT(n,"hashAlgorithm","keyData"),hashSize:BT(n,"hashSize","keyData"),blockSize:BT(n,"blockSize","keyData"),cipherAlgorithm:FT(n,"cipherAlgorithm","keyData"),cipherChaining:FT(n,"cipherChaining","keyData"),spinCount:BT(o,"spinCount","encryptedKey"),passwordSalt:Dv(o,"saltValue","encryptedKey"),passwordHashAlgorithm:FT(o,"hashAlgorithm","encryptedKey"),passwordKeyBits:BT(o,"keyBits","encryptedKey"),passwordBlockSize:BT(o,"blockSize","encryptedKey"),encryptedVerifierHashInput:Dv(o,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:Dv(o,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:Dv(o,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:Dv(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:Dv(r,"encryptedHmacValue","dataIntegrity")}}function h_n(e){if(e.length<K5)throw new ps(_a.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${K5})`);const t=LBe(e,0),n=LBe(e,2);if(t===MBe&&n===DBe)return{type:"agile",params:f_n(e.subarray(K5))};throw(t===OBe||t===FBe)&&n===BBe?new ps(_a.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new ps(_a.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new ps(_a.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var MBe,DBe,OBe,FBe,BBe,K5,p_n=Oe((()=>{q_(),MBe=4,DBe=4,OBe=3,FBe=4,BBe=3,K5=8}));function tQ(){const e=globalThis.crypto?.subtle;if(!e)throw new ps(_a.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function Q_(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 ps(_a.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function m_n(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 HT(...e){const t=e.reduce((o,i)=>o+i.length,0),n=new Uint8Array(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function HBe(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 zT(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function UT(e,t){const n=await tQ().digest(e,zT(t));return new Uint8Array(n)}async function VT(e,t,n){const r=tQ(),o=16,i=await r.importKey("raw",zT(e),{name:"AES-CBC"},!1,["encrypt","decrypt"]),s=n.subarray(n.length-o),a=new Uint8Array(o);a.fill(o);const l=new Uint8Array(await r.encrypt({name:"AES-CBC",iv:zT(s)},i,a)).subarray(0,o),c=new Uint8Array(n.length+o);c.set(n),c.set(l,n.length);const u=await r.decrypt({name:"AES-CBC",iv:zT(t)},i,c);return new Uint8Array(u).subarray(0,n.length)}async function nQ(e,t,n,r,o,i){const s=Q_(o);let a=await UT(s,HT(t,m_n(e)));for(let d=0;d<n;d++)a=await UT(s,HT(HBe(d),a));const l=await UT(s,HT(a,i)),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 rQ(e,t,n,r){let o;if(n?o=await UT(Q_(e),HT(t,n)):o=t,o.length>=r)return o.subarray(0,r);const i=new Uint8Array(r);return i.set(o),i.fill(54,o.length),i}async function g_n(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:o,passwordKeyBits:i,passwordBlockSize:s}=t,a=await nQ(e,n,r,i,o,UBe),l=await nQ(e,n,r,i,o,VBe),c=await nQ(e,n,r,i,o,GBe),u=await rQ(o,n,void 0,s),d=await VT(a,u,t.encryptedVerifierHashInput),f=await VT(l,u,t.encryptedVerifierHashValue),h=await UT(Q_(o),d);if(!zBe(h,f.subarray(0,h.length)))throw new ps(_a.PASSWORD_INVALID,"The password is incorrect");return VT(c,u,t.encryptedKeyValue)}function zBe(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 y_n(e,t,n){const{keySalt:r,hashAlgorithm:o,blockSize:i}=t,s=Q_(o);if(n.length<oQ)throw new ps(_a.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(oQ),c=Math.ceil(l.length/Y5),u=[];for(let d=0;d<c;d++){const f=d*Y5,h=Math.min(f+Y5,l.length),p=l.subarray(f,h),m=await UT(s,HT(r,HBe(d))),g=await VT(e,m.length>=i?m.subarray(0,i):m,p);u.push(g)}return HT(...u).subarray(0,a)}async function b_n(e,t,n){const{keySalt:r,hashAlgorithm:o,blockSize:i,hashSize:s}=t,a=Q_(o),l=tQ(),c=(await VT(e,await rQ(o,r,WBe,i),t.encryptedHmacKey)).subarray(0,s),u=await VT(e,await rQ(o,r,jBe,i),t.encryptedHmacValue),d=await l.importKey("raw",zT(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,zT(n)));if(!zBe(f,u.subarray(0,f.length)))throw new ps(_a.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function v_n(e,t,n){try{const r=await g_n(e,t);return await b_n(r,t,n),await y_n(r,t,n)}catch(r){throw r instanceof ps?r:new ps(_a.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var UBe,VBe,GBe,WBe,jBe,Y5,oQ,w_n=Oe((()=>{q_(),UBe=new Uint8Array([254,167,210,118,59,75,158,121]),VBe=new Uint8Array([215,170,15,109,48,97,52,78]),GBe=new Uint8Array([20,110,11,231,171,172,208,214]),WBe=new Uint8Array([95,178,173,1,12,185,225,246]),jBe=new Uint8Array([160,103,127,2,178,44,132,51]),Y5=4096,oQ=8})),A_n=Rs({decryptDocxIfNeeded:()=>T_n},1);function S_n(e){if(XZ(e)!=="zip")throw new ps(_a.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function T_n(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=XZ(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new ps(_a.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new ps(_a.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const o=c_n(n),{params:i}=h_n(o.encryptionInfo),s=await v_n(t.password,i,o.encryptedPackage);return S_n(s),{data:s,wasEncrypted:!0}}var I_n=Oe((()=>{_Be(),u_n(),p_n(),w_n(),q_()})),qBe=sc(kg(),1),iQ=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),sQ={tif:"tiff",jpg:"jpeg",svg:"svg+xml"},x_n="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",KBe={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},k_n=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new gBe.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(()=>(_Be(),OEn)),o=r(await this.#e(e,8));let i=e;if(o==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(I_n(),A_n)),c=await l(e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer()),{password:n.password});i=c.data,this.decryptedFileData=c.data}const s=await this.unzip(i),a=Object.entries(s.files);for(const[,l]of a){const c=l.name;if(yBe(c)){const u=qZ(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((!iQ.has(d)||d==="tmp")&&(f=gL(u),f&&(d=f)),iQ.has(d)){const h=sQ[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={},o={}){const i=Object.keys(r||{}),s=Object.keys(t).map(E=>this.getFileExtension(E)).filter(E=>E&&iQ.has(E)),a=Object.entries(t).filter(([E])=>!this.getFileExtension(E)).map(([E,L])=>({name:E,contentType:this.#o(L)})).filter(E=>E.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(E=>E.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=Oct(c),f=new Set;for(let E of s){if(d.includes(E)||f.has(E))continue;const L=`<Default Extension="${E}" ContentType="image/${sQ[E]||E}"/>`;u+=L,f.add(E)}if(o){const E=new Set(Object.keys(o).map(L=>this.getFileExtension(L)).filter(L=>L&&KBe[L]));for(const L of E)d.includes(L)||f.has(L)||(u+=`<Default Extension="${L}" ContentType="${KBe[L]}"/>`,f.add(L))}const h=JSON.parse(qBe.xml2json(c,null,2)).elements?.find(E=>E.name==="Types")||{},p=E=>h.elements?.some(L=>L.name==="Override"&&L.attributes.PartName===E);for(const{name:E,contentType:L}of a){const R=`/${E}`;p(R)||(u+=`<Override PartName="${R}" ContentType="${L}" />`)}const m=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/commentsIds.xml"),b=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/commentsExtensible.xml"),v=E=>r&&Object.prototype.hasOwnProperty.call(r,E)?r[E]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(L=>L.name===E):!!e.files[E]:!1;v("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),v("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),v("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),v("word/commentsExtensible.xml")&&(b||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const A=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/footnotes.xml"),S=h.elements?.some(E=>E.name==="Override"&&E.attributes.PartName==="/word/endnotes.xml");v("word/footnotes.xml")&&(A||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),v("word/endnotes.xml")&&(S||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const E of xBe)v(E.zipPath)&&!p(`/${E.zipPath}`)&&(u+=`<Override PartName="/${E.zipPath}" ContentType="${E.contentType}" />`);const w=new Set(i);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(E=>w.add(E.name)):Object.keys(e.files).forEach(E=>w.add(E))),w.forEach(E=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(E)||!v(E))return;const L=`/${E}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${x_n}" />`)}),w.forEach(E=>{if(E.includes(".rels")||!E.includes("header")&&!E.includes("footer"))return;const L=h.elements?.some(M=>M.name==="Override"&&M.attributes.PartName===`/${E}`),R=`<Override PartName="/${E}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${E.includes("header")?"header":"footer"}+xml"/>`;L||(u+=R)});const T=uq.map(E=>`/word/${E}`).filter(E=>!v(E.slice(1))),x="application/vnd.openxmlformats-officedocument.customXmlProperties+xml";if(h?.elements?.length)for(const E of h.elements){if(E?.name!=="Override"||E?.attributes?.ContentType!==x)continue;const L=E?.attributes?.PartName;typeof L!="string"||!L.startsWith("/")||v(L.slice(1))||T.push(L)}const C='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let k=c.replace(C,`${C}${u}`);for(const E of T){const L=E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=new RegExp(`\\s*<Override[^>]*PartName="${L}"[^>]*/>`,"g");k=k.replace(R,"")}let P=r["word/_rels/document.xml.rels"];if(P||(n?Array.isArray(e.files)?P=e.files.find(E=>E.name==="word/_rels/document.xml.rels")?.content:P=e.files?.["word/_rels/document.xml.rels"]:P=await e.file("word/_rels/document.xml.rels")?.async("string")),P)try{qBe.xml2js(P,{compact:!1}).elements?.find(E=>E.name==="Relationships")?.elements?.forEach(E=>{const L=E.attributes?.Type,R=E.attributes?.Target;if(!L||!R)return;const M=L.includes("/header"),O=L.includes("/footer");if(!M&&!O)return;let H=R.replace(/^\.\//,"");H.startsWith("../")&&(H=H.slice(3)),H.startsWith("/")&&(H=H.slice(1));const W=H.startsWith("word/")?H:`word/${H}`;w.add(W)})}catch(E){console.warn("Failed to parse document relationships while updating content types",E)}if(w.forEach(E=>{if(E.includes(".rels")||!E.includes("header")&&!E.includes("footer")||k.includes(`PartName="/${E}"`))return;const L=`<Override PartName="/${E}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${E.includes("header")?"header":"footer"}+xml"/>`;k=k.replace("</Types>",`${L}</Types>`)}),P){const E=DEn(P,v);E!==P&&(n?r["word/_rels/document.xml.rels"]=E:e.file("word/_rels/document.xml.rels",E))}if(n)return k;e.file(l,k)}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:o,relsXml:i}=IBe({baseFiles:t,updatedDocs:{}});e.file("[Content_Types].xml",o),e.file("_rels/.rels",i)}async unzip(e){return await this.zip.loadAsync(e)}async updateZip({docx:e,updatedDocs:t,originalDocxFile:n,media:r,fonts:o,isHeadless:i,compression:s="DEFLATE"}){let a;n?a=await this.exportFromOriginalFile(n,t,r,o):a=await this.exportFromCollaborativeDocx(e,t,r,o);const l=i?"nodebuffer":"blob";return await a.generateAsync({type:l,mimeType:Kc,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 o=new gBe.default;for(const i of e){const s=i.content;o.file(i.name,s)}Object.keys(t).forEach(i=>{t[i]===null?o.remove(i):o.file(i,t[i])}),Object.keys(n).forEach(i=>{const s=n[i],a=typeof s=="string"?zk(s):s;o.file(i,a)});for(const[i,s]of Object.entries(r))o.file(i,s);return await this.updateContentTypes(o,n,!1,t,r),await this.#t(o),o}async exportFromOriginalFile(e,t,n,r){const o=await this.unzip(e),i=[];if(o.forEach((s,a)=>{const l=a.async("uint8array").then(c=>{o.file(a.name,yBe(a.name)?qZ(c):c)});i.push(l)}),await Promise.all(i),Object.keys(t).forEach(s=>{t[s]===null?o.remove(s):o.file(s,t[s])}),Object.keys(n).forEach(s=>{o.file(s,n[s])}),r)for(const[s,a]of Object.entries(r))o.file(s,a);return await this.updateContentTypes(o,n,!1,t,r),await this.#t(o),o}#o(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=gL(new Uint8Array(e)):ArrayBuffer.isView(e)?t=gL(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=gL(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${sQ[t]||t}`:null}},aQ=k_n;const C_n=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const o=e.state.tr.setSelection(gn.create(n,t));return e.dispatch(o),!0}return!1};function E_n(e,t="sans-serif"){const n=(r,o)=>{const i=document.createElement("canvas").getContext("2d");i.textBaseline="top";const s="abcdefghijklmnopqrstuvwxyz0123456789";i.font=`72px ${o}`;const a=i.measureText(s),l=a.width,c=a.actualBoundingBoxDescent;i.font=`72px "${r}", ${o}`;const u=i.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 $_=(...e)=>{};const __n=e=>{const t=[];if($_("ATTEMPTING MIGRATIONS"),!e.converter.numbering)return t;const{state:n}=e,{doc:r}=n,o=typeof e.view?.dispatch=="function"?e.view.dispatch.bind(e.view):e.dispatch.bind(e),i=["orderedList","bulletList"];let s=0;r.descendants((l,c)=>{if(!i.includes(l.type.name)||c<s)return;const u=X5(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);$_("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,o(a),t};function X5(e,t,n=0,r=null){const o=[],i=["orderedList","bulletList"],s=e.type.name,a=R_n(e),l=P_n(e,t);if($_("Needs migration?",a),!a)return l?o:N_n(e,t);let c=parseInt(e.attrs?.listId);$_("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=$n.getNewListId(t)),(!$n.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=$n.getNewListId(t),$_("Genearted new list ID",c,"for list type",s),$n.generateNewListDefinition({numId:c,listType:s,editor:t})),r||(r=c);for(const u of e.content.content)if(!u.content.content?.length)o.push({node:u,baseLevel:n});else if(u.content.content.length===1){const d=u.content.content[0];if(i.includes(d.type.name)){const f=X5(d,t,n+1,r);o.push(...f)}else{const f=$n.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});o.push({node:f,baseLevel:n})}}else{const d=u.content.content[0];if(i.includes(d.type.name)){const f=X5(d,t,n+1,r);o.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=$n.createSchemaOrderedListNode({level:n,numId:r,listType:e.type.name,editor:t,contentNode:d.toJSON(),listLevel:u.attrs.listLevel||[1]});o.push({node:f,baseLevel:n})}else o.push({node:d});for(let f of u.content.content.slice(1))if(i.includes(f.type.name)){const h=X5(f,t,n+1,r);o.push(...h)}else o.push({node:f})}return o}var R_n=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:o,listNumberingType:i}=r||{};return typeof o>"u"||!i?!0:(n?.content?.content).filter(s=>["bulletList","orderedList"].includes(s.type.name)).length>0}return!1},P_n=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:o,level:i}=r||{},{abstract:s}=$n.getListDefinitionDetails({numId:o,level:i,listType:n,editor:t})||{};return!!s},N_n=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:o}=r||{};return $n.generateNewListDefinition({numId:o,listType:n,editor:t})};const L_n=async(e=[],t)=>{const n=Uu(t.state),r=[];if(!n.length)return e;for(const o of n){const i=o.node?.attrs?.type,s=e.find(l=>l.input_id===o.node.attrs.fieldId);if(s&&(!i||i!=="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},M_n=(e,t={})=>e.options.isChildEditor?null:new Um({...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:D_n,...t,isChildEditor:!0,parentEditor:e});var D_n=e=>{const{editor:t,numbering:n}=e,{parentEditor:r={}}=t.options,{converter:o}=r;if(!o)return;o.numbering=n;const{tr:i}=r.state;i.setMeta("updatedListItemNodeViews",!0),r.dispatch(i)};function YBe(e,t=[]){const n="[SuperValidator]",r="color: teal; font-weight: bold;",o=[n,...t.map(a=>`[${a}]`)],i=o.map(()=>"%c%s").join(" "),s=o.map(a=>[r,a]).flat();return{debug:(...a)=>{e&&console.debug(i,...s,...a)},withPrefix:a=>YBe(e,[...t,a])}}function O_n(e,t,n,r){let o=!1;const i=[];return e.forEach(({node:s,pos:a})=>{const{rId:l,src:c}=s.attrs;if(!l&&c){const u=Ub(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}),i.push(`Added missing rId to image at pos ${a}`),o=!0)}}),{modified:o,results:i}}function F_n({editor:e,logger:t}){const n=(r,o)=>{const i=[O_n(o.image||[],e,r,t)];return{modified:i.some(s=>s.modified),results:i.flatMap(s=>s.results)}};return n.requiredElements={nodes:["image"]},n}function B_n(e,t,n,r){let o=!1;const i=[];return e.forEach(({mark:s,from:a,to:l})=>{const{rId:c,href:u,anchor:d}=s.attrs;if(!c&&u&&!d){const f=Ub(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),i.push(`Added missing rId to link from pos ${a} to ${l}`),o=!0}}}),{modified:o,results:i}}function H_n({editor:e,logger:t}){const n=(r,o)=>{const i=[B_n(o.link||[],e,r,t)];return{modified:i.some(s=>s.modified),results:i.flatMap(s=>s.results)}};return n.requiredElements={marks:["link"]},n}const z_n={imageNodeValidator:F_n,linkMarkValidator:H_n};function U_n({editor:e,logger:t}){return()=>{const n=[];let r=!1;const o=e?.converter?.convertedXml,i="word/numbering.xml",s=o?.[i];if(!s||!s.elements?.length||!s.elements[0].elements?.length)return n.push(`${i} is not a valid xml`),{results:n,modified:r};const a=[];let l=s.elements[0];return XBe(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 XBe(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 o=(r.attributes||{})["w:numId"],i=o==null?null:String(o).trim();if(i==null||i===""||/^null$/i.test(i)||!/^\d+$/.test(i)){t.push(i??"missing node");continue}}Array.isArray(r.elements)&&r.elements.length&&XBe(r,t)}n.push(r)}e.elements=n}function V_n({editor:e,logger:t}){return()=>{const n=[];let r=!1;const o=e?.converter?.convertedXml;if(!o||typeof o!="object")return{results:n,modified:r};const{relsKey:i,wasNormalized:s}=G_n(o,n);if(!i)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=W_n(o[i],i,n);if(!a)return{results:n,modified:r};l&&(r=!0),j_n(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=q_n(a,o,n);d&&(r=!0),K_n(o,c,n,t)&&(r=!0);const f=o["[Content_Types].xml"];return u.size>0||f?Y_n(o,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function G_n(e,t){const n=["word/_rels/document.xml.rels","word/document.xml.rels","_rels/document.xml.rels","document.xml.rels"].find(o=>e?.[o]?.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 W_n(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 o="http://schemas.openxmlformats.org/package/2006/relationships";let i=!1;return r.name!=="Relationships"&&(r.name="Relationships",n.push('Fixed relationships root element name to "Relationships"'),i=!0),r.attributes=r.attributes||{},r.attributes.xmlns!==o&&(r.attributes.xmlns=o,n.push(`Set relationships xmlns to ${o}`),i=!0),{root:r,wasFixed:i}}function j_n(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 q_n(e,t,n){const r=new Set,o=new Set;let i=!1;const s=b=>{const v=/^rId(\d+)$/.exec(String(b||""));return v?parseInt(v[1],10):null},a=(b,v)=>typeof b=="string"&&new RegExp(`/relationships/${v}$`,"i").test(b),l=b=>a(b,"hyperlink"),c=b=>a(b,"image"),u=b=>/^https?:\/\//i.test(b||"")||/^mailto:/i.test(b||""),d=new Set;let f=0;for(const b of e.elements){b.attributes=b.attributes||{};const v=b.attributes.Id,A=s(v);Number.isInteger(A)&&(f=Math.max(f,A)),typeof v=="string"&&v&&d.add(v)}let h=f;const p=b=>{if(b&&!d.has(b))return d.add(b),b;let v;do h+=1,v=`rId${h}`;while(d.has(v));return d.add(v),v},m=new Set,g=[];function y(b,v){return typeof b[v]=="string"?b[v].trim():""}for(const b of e.elements){b.attributes=b.attributes||{};const v=b.attributes;let A=y(v,"Id");const S=y(v,"Type");let w=y(v,"Target"),T=y(v,"TargetMode");if(!w){n.push(`Removed relationship "${A}" without Target`),i=!0;continue}if(l(S)&&u(w)&&T.toLowerCase()!=="external"&&(v.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${A}`),i=!0),c(S)){const x=jp(w,"word");x&&/^media\/.+\.bin$/i.test(w)&&x in t&&r.add(`/${x}`)}if(T.toLowerCase()!=="external"&&!u(w)&&!(jp(w,"word")in t))if(c(S))n.push(`Warning: image relationship ${A} target not found: ${w}.`);else{n.push(`Removed relationship ${A} with missing target: ${w}`),i=!0;continue}if(!A){const x=p(null);v.Id=x,n.push(`Assigned missing Id "${x}"`),i=!0,A=x}if(m.has(A)){n.push(`Removed duplicate relationship with ID "${A}"`),i=!0;continue}m.add(A),g.push(b)}(e.elements.length!==g.length||e.elements.some((b,v)=>b!==g[v]))&&(e.elements=g,i=!0);for(const b of e.elements){const v=b.attributes?.Id;typeof v=="string"&&v&&o.add(v)}return{filteredIds:o,binMediaTargets:r,wasProcessed:i}}function K_n(e,t,n,r){const o=e["word/document.xml"];if(o?.elements?.length){const i=o.elements[0];if(i?.type==="element"){const s=[];if(JBe(i,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 Y_n(e,t,n){const r="[Content_Types].xml",o=e[r];return typeof o=="string"?X_n(o,t,n,e,r):o?.elements?.length?J_n(o,t,n):!1}function X_n(e,t,n,r,o){const i='<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(i,`${i}<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(i,`${i}<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[o]=l,!0):!1}function J_n(e,t,n){const r=e.elements.find(c=>c.name==="Types")||e.elements[0];r.elements=r.elements||[];const o=c=>r.elements.some(u=>u.name==="Default"&&u.attributes?.Extension===c),i=(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;o("rels")||(i("rels","application/vnd.openxmlformats-package.relationships+xml"),l=!0),o("xml")||(i("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 JBe(e,t,n){if(e?.elements?.length)for(const r of e.elements){if(r?.type!=="element")continue;const o=r.attributes?.["r:id"];typeof o=="string"&&!t.has(o)&&(delete r.attributes["r:id"],n.push(`Removed invalid r:id="${o}"`)),JBe(r,t,n)}}const Z_n={numberingValidator:U_n,relationshipsValidator:V_n};var ZBe=class{#e;#t;#o;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=YBe(this.debug);const{stateValidators:t,xmlValidators:n,nodeTypes:r,markTypes:o}=this.#i();this.#t=t,this.#o=n,this.#n=r,this.#r=o}#i(){const e=new Set,t=new Set,n=r=>Object.fromEntries(Object.entries(r).map(([o,i])=>{const s=this.logger.withPrefix(o),a=i({editor:this.#e,logger:s});return this.#s(a,e,t),[o,a]}));return{stateValidators:n(z_n),xmlValidators:n(Z_n),nodeTypes:e,markTypes:t}}#s(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,o)=>{this.#n.has(r.type.name)&&t[r.type.name].push({node:r,pos:o}),r.isText&&r.marks&&r.marks.forEach(i=>{this.#r.has(i.type.name)&&t[i.type.name].push({mark:i,node:r,pos:o,from:o,to:o+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 o=[];return Object.entries(this.#t).forEach(([i,s])=>{this.logger.debug(`🕵 Validating with ${i}...`);const{results:a,modified:l}=s(t,n);o.push({key:i,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:",o),{modified:r,results:o}}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.#o).forEach(([o,i])=>{this.logger.debug(`🕵 Validating export with ${o}...`);const{results:s,modified:a}=i();r.push({key:o,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)}},J5=null;const GT=()=>{if(J5!==null)return J5;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return J5=e,e}catch{return J5=!1,!1}};function Z5(e){return e.replace(/\r\n?/g,`
815
815
  `).split(`
816
- `).map(t=>({type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}]}]}))}var Q_n="1.44.2",$_n=["group","content","marks","inline","atom","defining","code","tableRole","summary"],e2n=["group","inclusive","excludes","spanning","code"];function QBe(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 $Be(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function t2n(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((i,s)=>{r.push({name:i,attrs:QBe(s.attrs),...$Be(s,$_n)})});const o=[];return e.spec.marks.forEach((i,s)=>{o.push({name:i,attrs:QBe(s.attrs),...$Be(s,e2n)})}),{version:Q_n,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:o}}const n2n=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],o=i=>{for(;r.length&&r[r.length-1].level>=i;){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(i=>{if(i.nodeType!==Node.ELEMENT_NODE){n.push(i.outerHTML||i.textContent);return}if(i.tagName.toLowerCase()==="ol"||i.tagName.toLowerCase()==="ul"){const s=o2n(i),a=i2n(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=i.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",r2n(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)o(a+1);else if(r[r.length-1].tag!==u){o(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else o(0),n.push(i.outerHTML)}),o(0),n.join("")},r2n=(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 o2n(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const i2n=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var s2n=/^Heading[1-9]$/i;function a2n(e,t){const n=e.content.firstChild;if(!n||n.type.name==="paragraph")return e;const r=t.selection.$from,o=t.selection.$to;if(!r||!o)return e;let i=null,s=-1;for(let d=r.depth;d>=0;d--){const f=r.node(d);if(f?.type?.name==="paragraph"){o.depth>=d&&o.node(d)===f&&(i=f,s=d);break}}if(!i)return e;const a=r.parentOffset,l=o.parentOffset;if(a!==0||l!==i.content.size||r.depth!==s||o.depth!==s)return e;const c=i.attrs?.paragraphProperties?.styleId;if(typeof c!="string"||!s2n.test(c))return e;const u=i.type.create(i.attrs,e.content,i.marks);return new Bt(_t.from(u),0,0)}var l2n=1,c2n=10,u2n=150,d2n=1.2,f2n=1,h2n=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),p2n="span.sd-paragraph-content",e8e="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",m2n='<meta name="Generator" content="Microsoft Word">',g2n=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function t8e(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(e8e))return r}n=n.parentNode}return null}function y2n(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(e8e)}function b2n(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),o=e.style.fontFamily||"",i=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}`),o&&t.push(`font-family: ${o}`),i&&t.push(`font-size: ${i}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function v2n(e,t){const n=e.cloneContents();if(y2n(n))return n;const r=t8e(e.startContainer,t.dom),o=t8e(e.endContainer,t.dom);if(!r||r!==o)return n;const i=r.cloneNode(!1),s=b2n(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),i.appendChild(l)}else i.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(i),a}function w2n(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 o=r.resolve(n);for(let i=o.depth;i>0;i-=1){const s=o.node(i);if(s.type.name==="paragraph")return s}return null}function A2n(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 S2n(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const o=r.getAttribute("data-sd-block-id");if(!o)return;const i=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(o)??o}"]`);if(!i)return;const s=w2n(t,i),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 T2n(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 I2n(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const o=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${o}`}function x2n(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 k2n(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(o=>{const i=Number.parseInt(o.getAttribute("data-level")||"0",10)||0,s=i+1,a=o.getAttribute("data-num-id")||"1",l=a,c=o.getAttribute("data-num-fmt")||o.getAttribute("data-list-numbering-type")||"decimal",u=g2n.get(c)||"decimal",d=o.getAttribute("data-marker-type")||o.getAttribute("data-lvl-text")||"1.",f=I2n(i,c,d,o.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=o.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;o.setAttribute("class","MsoListParagraph"),o.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=T2n(o.getAttribute("data-list-level")),y=g[i]??g[g.length-1]??1,b=c==="bullet"?d:`${d}`.trim()||`${y}.`;o.prepend(x2n(b))}),`${m2n}<style>${n.join(`
816
+ `).map(t=>({type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}]}]}))}var Q_n="1.45.0",$_n=["group","content","marks","inline","atom","defining","code","tableRole","summary"],e2n=["group","inclusive","excludes","spanning","code"];function QBe(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 $Be(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function t2n(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((i,s)=>{r.push({name:i,attrs:QBe(s.attrs),...$Be(s,$_n)})});const o=[];return e.spec.marks.forEach((i,s)=>{o.push({name:i,attrs:QBe(s.attrs),...$Be(s,e2n)})}),{version:Q_n,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:o}}const n2n=e=>{const t=document.createElement("div");t.innerHTML=e;const n=[],r=[],o=i=>{for(;r.length&&r[r.length-1].level>=i;){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(i=>{if(i.nodeType!==Node.ELEMENT_NODE){n.push(i.outerHTML||i.textContent);return}if(i.tagName.toLowerCase()==="ol"||i.tagName.toLowerCase()==="ul"){const s=o2n(i),a=i2n(s),l=s.getAttribute("data-num-fmt"),c=s.getAttribute("data-lvl-text"),u=i.tagName.toLowerCase(),d=s.cloneNode(!0);if(d.setAttribute("aria-level",a+1),d.style.setProperty("list-style-type",r2n(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)o(a+1);else if(r[r.length-1].tag!==u){o(a);const f=document.createElement(u);r.push({tag:u,level:a,el:f})}r[r.length-1].el.appendChild(d)}else o(0),n.push(i.outerHTML)}),o(0),n.join("")},r2n=(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 o2n(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const i2n=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var s2n=/^Heading[1-9]$/i;function a2n(e,t){const n=e.content.firstChild;if(!n||n.type.name==="paragraph")return e;const r=t.selection.$from,o=t.selection.$to;if(!r||!o)return e;let i=null,s=-1;for(let d=r.depth;d>=0;d--){const f=r.node(d);if(f?.type?.name==="paragraph"){o.depth>=d&&o.node(d)===f&&(i=f,s=d);break}}if(!i)return e;const a=r.parentOffset,l=o.parentOffset;if(a!==0||l!==i.content.size||r.depth!==s||o.depth!==s)return e;const c=i.attrs?.paragraphProperties?.styleId;if(typeof c!="string"||!s2n.test(c))return e;const u=i.type.create(i.attrs,e.content,i.marks);return new Bt(_t.from(u),0,0)}var l2n=1,c2n=10,u2n=150,d2n=1.2,f2n=1,h2n=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),p2n="span.sd-paragraph-content",e8e="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",m2n='<meta name="Generator" content="Microsoft Word">',g2n=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function t8e(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(e8e))return r}n=n.parentNode}return null}function y2n(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(e8e)}function b2n(e){const t=[],n=globalThis.getComputedStyle?.(e),r=e.style.color||(n?.color&&n.color!=="rgb(0, 0, 0)"?n.color:""),o=e.style.fontFamily||"",i=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}`),o&&t.push(`font-family: ${o}`),i&&t.push(`font-size: ${i}`),s&&t.push(`text-transform: ${s}`),a&&t.push(`font-weight: ${a}`),t.join("; ")}function v2n(e,t){const n=e.cloneContents();if(y2n(n))return n;const r=t8e(e.startContainer,t.dom),o=t8e(e.endContainer,t.dom);if(!r||r!==o)return n;const i=r.cloneNode(!1),s=b2n(r);if(s){const l=document.createElement("span");l.setAttribute("style",s),l.appendChild(n),i.appendChild(l)}else i.appendChild(n);const a=document.createDocumentFragment();return a.appendChild(i),a}function w2n(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 o=r.resolve(n);for(let i=o.depth;i>0;i-=1){const s=o.node(i);if(s.type.name==="paragraph")return s}return null}function A2n(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 S2n(e,t){const n=Array.from(e.querySelectorAll("[data-sd-block-id]"));n.length!==0&&n.forEach(r=>{const o=r.getAttribute("data-sd-block-id");if(!o)return;const i=t.dom.querySelector(`[data-sd-block-id="${globalThis.CSS?.escape?.(o)??o}"]`);if(!i)return;const s=w2n(t,i),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 T2n(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 I2n(e,t,n,r){if(t==="bullet")return n||r||"•";if(r?.includes("%"))return r;const o=n.match(/[.)]$/)?.[0]||".";return`%${e+1}${o}`}function x2n(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 k2n(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(o=>{const i=Number.parseInt(o.getAttribute("data-level")||"0",10)||0,s=i+1,a=o.getAttribute("data-num-id")||"1",l=a,c=o.getAttribute("data-num-fmt")||o.getAttribute("data-list-numbering-type")||"decimal",u=g2n.get(c)||"decimal",d=o.getAttribute("data-marker-type")||o.getAttribute("data-lvl-text")||"1.",f=I2n(i,c,d,o.getAttribute("data-lvl-text")),h=`${l}:${s}:${a}`,p=o.getAttribute("style"),m=`mso-list:l${l} level${s} lfo${a}`;o.setAttribute("class","MsoListParagraph"),o.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=T2n(o.getAttribute("data-list-level")),y=g[i]??g[g.length-1]??1,b=c==="bullet"?d:`${d}`.trim()||`${y}.`;o.prepend(x2n(b))}),`${m2n}<style>${n.join(`
817
817
  `)}</style>${t.innerHTML}`}function n8e(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 C2n(e,t){const n=n8e(e.root);if(!n||n.isCollapsed||n.rangeCount===0)return null;const r=document.createElement("div");let o=!1;for(let i=0;i<n.rangeCount;i+=1){const s=n.getRangeAt(i),a=s.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;a&&!e.dom.contains(a)||(r.appendChild(v2n(s,e)),o=!0)}return o?(r.querySelectorAll(h2n).forEach(i=>{i.parentNode?.removeChild(i)}),r.querySelectorAll(p2n).forEach(i=>{const s=i.parentNode;if(s){for(;i.firstChild;)s.insertBefore(i.firstChild,i);s.removeChild(i)}}),r.querySelectorAll("[contenteditable], [draggable], [spellcheck], [data-pm-slice]").forEach(i=>{i.removeAttribute("contenteditable"),i.removeAttribute("draggable"),i.removeAttribute("spellcheck"),i.removeAttribute("data-pm-slice")}),r.querySelectorAll("[class]").forEach(i=>{const s=(i.getAttribute("class")||"").split(/\s+/).filter(Boolean).filter(a=>!a.startsWith("ProseMirror"));s.length>0?i.setAttribute("class",s.join(" ")):i.removeAttribute("class")}),hMt(r,e,t),A2n(r),S2n(r,e),k2n(r)||r.innerHTML||null):null}var r8e=class{constructor(){this.view=null,this.eventListenerCleanups=[],this.resizeTimeoutId=null}attach({element:e,state:t,editorProps:n={},dispatchTransaction:r,handleClick:o}){return this.view?.destroy(),this.view=new wwe(e,{...n&&typeof n=="object"?n:{},dispatchTransaction:r,state:t,handleClick:o}),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(!GT()){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"),m5(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.#o(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:o,fontFamilyCss:i}=e.converter.getDocumentDefaultStyles()??{},s=i||r;s&&(t.style.fontFamily=s),o&&(t.style.fontSize=`${o}pt`),n.style.lineHeight=e.options.isHeaderOrFooter?String(f2n):String(d2n),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"}#o(e,t,n){const{pageSize:r,pageMargins:o}=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`)),o&&(t.style.paddingLeft=`${o.left}in`,t.style.paddingRight=`${o.right}in`),e.presentationEditor&&o?.top!=null?n.style.paddingTop=`${o.top}in`:e.presentationEditor?n.style.paddingTop=`${l2n}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 i=n,s=document.documentElement.clientWidth-c2n;e.options.scale=Math.min(1,s/i);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=`${i*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 o=()=>{this.resizeTimeoutId!==null&&clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=setTimeout(()=>{r(),this.resizeTimeoutId=null},u2n)};if("orientation"in screen&&"addEventListener"in screen.orientation)screen.orientation.addEventListener("change",o),this.eventListenerCleanups.push(()=>{screen.orientation.removeEventListener("change",o)});else{const i=typeof window.matchMedia=="function"?window.matchMedia("(orientation: portrait)"):null;i?.addEventListener&&(i.addEventListener("change",o),this.eventListenerCleanups.push(()=>{i.removeEventListener("change",o)}))}window.addEventListener("resize",o),this.eventListenerCleanups.push(()=>{window.removeEventListener("resize",o)})}registerCopyHandler(e){const t=this.view?.dom;if(!t||!GT())return;const n=r=>{try{const o=r.clipboardData;if(!o||(r.preventDefault(),!this.view))return;const{from:i,to:s}=this.view.state.selection;let a="",l="";if(i!==s){const g=a2n(this.view.state.doc.slice(i,s),this.view.state);a=JSON.stringify(g.toJSON()),o.setData("application/x-superdoc-slice",a),l=wSe(a,e),l&&o.setData(vSe,l)}const c=C2n(this.view,e),u=this.view.state.doc.attrs?.bodySectPr,d=u&&TSe(u)?JSON.stringify(u):"";if(c){o.setData("text/html",yW(c,a,d,l)),o.setData("text/plain",n8e(this.view.root)?.toString()??"");return}const f=this.view.state.doc.slice(i,s).content,h=document.createElement("div"),p=dh.fromSchema(this.view.state.schema);h.appendChild(p.serializeFragment(f)),bW(h,f,e);const m=n2n(h.innerHTML);o.setData("text/html",yW(m,a,d,l)),o.setData("text/plain",this.view.state.doc.textBetween(i,s,`
818
818
  `))}catch(o){console.warn("Failed to transform copied content:",o)}};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 E2n="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==";function Ov(e){return e?.textModel==="visible"}function _2n(e){return e.marks?.some(t=>t.type.name==="trackDelete")??!1}function e2(e,t){return t2(e,t)}function o8e(e,t){return c8e(e,t)??{kind:"run",run:{text:""}}}function i8e(e,t){const{nodeType:n,anchor:r,attrs:o}=t,i=s8e(e,r);return n==="hyperlink"?{kind:"hyperlink",hyperlink:{...typeof o?.href=="string"?{href:o.href}:{},...typeof o?.anchor=="string"?{anchor:o.anchor}:{},...typeof o?.tooltip=="string"?{tooltip:o.tooltip}:{},inlines:[{kind:"run",run:{text:i}}]}}:{kind:"run",run:{text:i}}}function R2n(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 s8e(e,t){try{const n=e.state.doc;let r="";return n.descendants((o,i)=>{if(R2n(o,t.start.blockId)&&o.isBlock){const s=i+1+t.start.offset,a=i+1+t.end.offset;return r=n.textBetween(s,Math.min(a,i+o.nodeSize-1),""),!1}return!0}),r}catch{return""}}function P2n(e,t){const n=e.state.doc,r=[],o={textModel:"visible"};n.forEach(a=>{r.push(t2(a,o))});const i=N2n(e),s=D2n(e);return{modelVersion:"sdm/1",body:r,...i.length>0&&{sections:i},...s&&{numbering:s}}}function N2n(e){let t;try{t=Os(e)}catch{return[]}return t.map(n=>L2n(n.domain))}function L2n(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 M2n=new Set(["bullet"]);function D2n(e){const t=e.converter?.translatedNumbering;if(!t)return;const{definitions:n={},abstracts:r={}}=t,o=Object.entries(n);if(o.length===0)return;const i={definitions:{}};for(const[s,a]of o){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&&M2n.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&&(i.definitions[s]={levels:u})}return Object.keys(i.definitions).length>0?i:void 0}function t2(e,t){const n=e.type.name;switch(n){case"paragraph":return O2n(e,t);case"heading":return F2n(e,t);case"table":return H2n(e,t);case"bulletList":case"orderedList":return V2n(e,n==="orderedList",t);case"listItem":return W2n(e,t);case"image":return j2n(e);case"tableOfContents":return q2n(e);case"sdt":case"structuredContentBlock":return Y2n(e,t);case"sectionBreak":return J2n(e);case"pageBreak":case"horizontalRule":return Z2n(e);case"drawing":return Q2n(e);default:return $2n(e,t)}}function O2n(e,t){const n=e.attrs,r=PS(n?.paragraphProperties?.styleId);return r&&r>=1&&r<=6?a8e(e,n,r,t):B2n(e,n,t)}function F2n(e,t){const n=e.attrs;return a8e(e,n,e.attrs?.level??PS(n?.paragraphProperties?.styleId)??1,t)}function B2n(e,t,n){const r=n2(e,n),o={kind:"paragraph",id:Ff(e),paragraph:{inlines:r}},i=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;i&&(o.paragraph.styleRef=i);const s=f8e(t);return s&&(o.paragraph.props=s),o}function a8e(e,t,n,r){const o=n2(e,r),i={kind:"heading",id:Ff(e),heading:{level:n,inlines:o}},s=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;s&&(i.heading.styleRef=s);const a=f8e(t);return a&&(i.heading.props=a),i}function H2n(e,t){const n=e.attrs,r=e.attrs,o=[];e.forEach(c=>{c.type.name==="tableRow"&&o.push(z2n(c,t))});const i={kind:"table",id:Ff(e),table:{rows:o}},s=n?.tableProperties?.tableStyleId??r?.tableStyleId;s&&(i.table.styleRef=s);const a=dRn(n,r);a&&(i.table.props=a);const l=r?.grid??r?.tableGridModel??n?.tableGrid?.colWidths;if(l&&Array.isArray(l)){const c=l.map(u=>typeof u=="number"?u:u?.col??u?.width).filter(u=>typeof u=="number"&&Number.isFinite(u)).map(u=>({width:u}));c.length>0&&(i.table.columns=c)}if(r?.needsTableStyleNormalization===!0){const c=lQ(i.ext)?{...i.ext}:{},u=lQ(c.superdoc)?{...c.superdoc}:{};u.needsTableStyleNormalization=!0,i.ext={...c,superdoc:u}}return i}function z2n(e,t){const n=[];e.forEach(i=>{(i.type.name==="tableCell"||i.type.name==="tableHeader")&&n.push(U2n(i,t))});const r={cells:n},o=e.attrs;return(o?.minHeight!==void 0||o?.cantSplit!==void 0)&&(r.props={},o.minHeight!==void 0&&(r.props.minHeight=o.minHeight),o.cantSplit!==void 0&&(r.props.cantSplit=o.cantSplit)),r}function U2n(e,t){const n=e.attrs,r=[];e.forEach(s=>{r.push(t2(s,t))});const o={content:r};n?.colspan&&n.colspan>1&&(o.colSpan=n.colspan),n?.rowspan&&n.rowspan>1&&(o.rowSpan=n.rowspan);const i=n?.tableCellProperties?.vAlign??n?.verticalAlign;return i&&(o.props={verticalAlign:i}),o}function V2n(e,t,n){const r=[];e.forEach(s=>{s.type.name==="listItem"&&r.push(G2n(s,n))});const o={kind:"list",id:Ff(e),list:{items:r,levels:[{level:0,kind:t?"ordered":"bullet"}]}},i=e.attrs;return i?.listStyleId&&(o.list.styleRef=i.listStyleId),o}function G2n(e,t){const n=[];return e.forEach(r=>{n.push(t2(r,t))}),{level:e.attrs?.level??0,content:n}}function W2n(e,t){const n=n2(e,t);return{kind:"paragraph",id:Ff(e),paragraph:{inlines:n}}}function j2n(e){const t=e.attrs;return{kind:"image",id:Ff(e),image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function q2n(e){const t=e.attrs?.instruction??"",n=Av(t);return{kind:"toc",id:Ff(e),toc:{...t?{instruction:t}:{},...n.source?{sourceConfig:n.source}:{},...n.display?{displayConfig:n.display}:{},...n.preserved?{preservedSwitches:n.preserved}:{},entryCount:e.childCount}}}var K2n={unlocked:"none",sdtLocked:"sdt",contentLocked:"content",sdtContentLocked:"both"};function l8e(e){const t=K2n[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 Y2n(e,t){const n=[];return e.forEach(r=>{n.push(t2(r,t))}),{kind:"sdt",id:d8e(e),sdt:{...l8e(e.attrs??{}),scope:"block",...n.length>0?{content:n}:{}}}}function X2n(e,t){const n=n2(e,t);return{kind:"sdt",id:d8e(e),sdt:{...l8e(e.attrs??{}),scope:"inline",...n.length>0?{inlines:n}:{}}}}function J2n(e){return{kind:"sectionBreak",id:Ff(e),sectionBreak:{targetSectionId:e.attrs?.targetSectionId??""}}}function Z2n(e){const t=e.attrs?.breakType??"page";return{kind:"break",id:Ff(e),break:{type:t==="column"?"column":"page"}}}function Q2n(e){return{kind:"drawing",id:Ff(e),drawing:{source:e.attrs?.source??{type:"unknown"},...e.attrs?.geometry?{geometry:e.attrs.geometry}:{},...e.attrs?.layout?{layout:e.attrs.layout}:{}}}}function $2n(e,t){const n=n2(e,t);return{kind:"paragraph",id:Ff(e),paragraph:{inlines:n}}}function n2(e,t){const n=[];return e.forEach(r=>{const o=c8e(r,t);o&&n.push(o)}),n}function c8e(e,t){if(e.isText)return nRn(e,t);switch(e.type.name){case"run":return eRn(e,t);case"image":return oRn(e);case"tab":return iRn();case"hardBreak":case"lineBreak":return sRn();case"footnoteRef":case"footnoteReference":return aRn(e);case"endnoteRef":case"endnoteReference":return lRn(e);case"field":return cRn(e);case"structuredContent":return X2n(e,t);default:return uRn(e,t)}}function eRn(e,t){const n=(e.attrs??{}).runProperties,r=Ov(t)?h0(e,t):e.textContent;if(Ov(t)&&r.length===0)return null;let o;if(e.forEach(l=>{o||(o=l.marks?.find(c=>c.type.name==="link"))}),o)return tRn(e,o,t);const i={kind:"run",run:{text:r}},s=typeof n?.rStyle=="string"?n.rStyle:typeof n?.styleId=="string"?n.styleId:void 0;s&&(i.run.styleRef=s);const a=u8e(n);return a&&(i.run.props=a),i}function tRn(e,t,n){const r=t.attrs,o=Ov(n)?h0(e,n):e.textContent;if(Ov(n)&&o.length===0)return null;const i={kind:"run",run:{text:o}},s=e.attrs?.runProperties,a=u8e(s);return a&&(i.run.props=a),{kind:"hyperlink",hyperlink:{...typeof r.href=="string"?{href:r.href}:{},...typeof r.anchor=="string"?{anchor:r.anchor}:{},...typeof r.tooltip=="string"?{tooltip:r.tooltip}:{},inlines:[i]}}}function u8e(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 o=e.underline??e.u;if(o!==void 0&&o!=="none"&&o!==!1&&(t.underline=typeof o=="object"?o:{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 i=e.sz??e.size??e.fontSize;if(typeof i=="number")t.fontSize=i,n=!0;else if(typeof i=="string"){const l=Number.parseFloat(i);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 nRn(e,t){if(Ov(t)&&_2n(e))return null;const n=e.marks,r=n.find(a=>a.type.name==="link");if(r)return rRn(e,r);const o={kind:"run",run:{text:e.text??""}},i=pRn(n);i&&(o.run.styleRef=i);const s=mRn(n);return s&&(o.run.props=s),o}function rRn(e,t){const n=t.attrs,r={kind:"run",run:{text:e.text??""}},o=e.marks.filter(a=>a!==t),i=p8e(o);i&&(r.run.props=i);const s=h8e(o);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 oRn(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 iRn(){return{kind:"tab",tab:{}}}function sRn(){return{kind:"lineBreak",lineBreak:{}}}function aRn(e){return{kind:"footnoteRef",footnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function lRn(e){return{kind:"endnoteRef",endnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function cRn(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 uRn(e,t){const n=Ov(t)?h0(e,t):e.textContent??"";return Ov(t)&&n.length===0?null:{kind:"run",run:{text:n}}}function Ff(e){const t=e.attrs?.sdBlockId;return typeof t=="string"&&t.length>0?t:void 0}function d8e(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 lQ(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dRn(e,t){const n=e?.tableProperties,r={};let o=!1;const i=hRn(n?.tableWidth??t?.tableWidth);i&&(r.width=i,o=!0);const s=n?.tableLayout??t?.tableLayout;(s==="fixed"||s==="autofit")&&(r.layout=s,o=!0);const a=fRn(n?.justification??t?.justification);return a&&(r.alignment=a,o=!0),o?r:void 0}function fRn(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 hRn(e){if(!lQ(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 f8e(e){const t=e?.paragraphProperties;if(!t)return;const n=t,r={};let o=!1;return t.justification&&(r.alignment=t.justification==="both"?"justify":t.justification,o=!0),t.indent&&(r.indent=t.indent,o=!0),t.spacing&&(r.spacing=t.spacing,o=!0),t.keepNext!==void 0&&(r.keepWithNext=t.keepNext,o=!0),t.keepLines!==void 0&&(r.keepLines=t.keepLines,o=!0),t.pageBreakBefore!==void 0&&(r.pageBreakBefore=t.pageBreakBefore,o=!0),t.widowControl!==void 0&&(r.widowControl=t.widowControl,o=!0),t.outlineLvl!==void 0&&(r.outlineLevel=t.outlineLvl,o=!0),t.numberingProperties&&(r.numbering={numId:String(t.numberingProperties.numId??""),level:t.numberingProperties.ilvl},o=!0),n.tabs&&(r.tabs=n.tabs,o=!0),n.borders&&(r.borders=n.borders,o=!0),n.shading&&(r.shading=n.shading,o=!0),n.rightToLeft!==void 0&&(r.bidi=n.rightToLeft,o=!0),n.markRunProps&&(r.markRunProps=n.markRunProps,o=!0),o?r:void 0}function pRn(e){return h8e(e)}function h8e(e){const t=e.find(n=>n.type.name==="textStyle");if(t)return typeof t.attrs?.rStyle=="string"?t.attrs.rStyle:void 0}function mRn(e){return p8e(e)}function p8e(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 o=r.attrs?.color;typeof o=="string"&&(t.highlight=o,n=!0);break}case"textStyle":{const o=r.attrs;if(!o)break;o.color&&(t.color=o.color,n=!0),o.fontSize!==void 0&&(t.fontSize=o.fontSize,n=!0),o.fontSizeCs!==void 0&&(t.fontSizeCs=o.fontSizeCs,n=!0),o.fontFamily&&(t.fontFamily=o.fontFamily,n=!0),o.fonts&&(t.fonts=o.fonts,n=!0),o.caps&&(t.caps=!0,n=!0),o.smallCaps&&(t.smallCaps=!0,n=!0),o.vanish&&(t.vanish=!0,n=!0),o.characterSpacing!==void 0&&(t.characterSpacing=o.characterSpacing,n=!0);break}}return n?t:void 0}function gRn(e,t){return P2n(e,t.options)}function Q5(e){if(typeof e=="number")return e;if(e&&typeof e=="object"&&typeof e.value=="number")return e.value}function yRn(e){switch(e){case"start":return"left";case"end":return"right";case"left":case"center":case"right":return e;default:return}}function cQ(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,o=t?.justification,i=o==="both"?"justify":o,s=t?.numberingProperties?{numId:kf(t.numberingProperties.numId),level:kf(t.numberingProperties.ilvl)}:void 0;return{styleId:t?.styleId??void 0,alignment:i??void 0,indentation:n,spacing:r,keepWithNext:t?.keepNext??void 0,outlineLevel:t?.outlineLvl??void 0,paragraphNumbering:s}}function bRn(e){const t=Nk(e?.listRendering);if(!t)return;const n={};return t.markerText&&(n.marker=t.markerText),Array.isArray(t.path)&&(n.path=t.path),n.ordinal=tL(t.path),Object.keys(n).length?n:void 0}function vRn(e){const t=e.node.attrs;return{nodeType:"paragraph",kind:"block",properties:cQ(t)}}function wRn(e){const t=e.node.attrs,n=cQ(t),r=PS(t?.paragraphProperties?.styleId)??(n.outlineLevel!=null?n.outlineLevel+1:void 0);if(!r||r<1||r>6)throw new Be("INVALID_TARGET",`Node "${e.nodeId}" does not have a valid heading level.`);return{nodeType:"heading",kind:"block",properties:{...n,headingLevel:r}}}function ARn(e){const t=e.node.attrs;return{nodeType:"listItem",kind:"block",properties:{...cQ(t),numbering:bRn(t)}}}function SRn(e){const t=e.node.attrs?.tableProperties??void 0;return{nodeType:"table",kind:"block",properties:{layout:t?.tableLayout??void 0,width:Q5(t?.tableWidth??null)??void 0,alignment:yRn(t?.justification)}}}function TRn(){return{nodeType:"tableRow",kind:"block",properties:{}}}function IRn(e){const t=e.node.attrs,n=t?.tableCellProperties??void 0;return{nodeType:"tableCell",kind:"block",properties:{width:Q5(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:Q5(n?.cellMargins?.top??null)??Q5(t?.cellMargins?.top??null)}}}function xRn(e){const t=e.node,n=t.attrs?.instruction??"",r=Av(n),o=t.childCount;return{nodeType:"tableOfContents",kind:"block",properties:{instruction:n,sourceConfig:r.source,displayConfig:r.display,preservedSwitches:r.preserved,entryCount:o}}}function kRn(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 CRn(e,t){if(!e)return!1;try{const n=e.resolve(t),r=n.depth-1;if(r<0)return!1;const o=n.before(r+1)+n.node(r+1).nodeSize;if(o>=e.content.size)return!1;const i=e.nodeAt(o);return!i||i.type.name!=="paragraph"?!1:i.attrs?.paragraphProperties?.styleId==="Caption"}catch{return!1}}function ERn(e,t,n,r){const o=!!e?.isAnchor,i=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:o?"floating":"inline",wrap:{type:i?.type??"Inline",attrs:i?.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:kRn(e?.clipPath),lockAspectRatio:e?.lockAspectRatio??!0,decorative:e?.decorative??!1,hyperlink:e?.hyperlink??null,hasCaption:r!=null?CRn(n,r):!1}}}function _Rn(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 RRn(e){const t=nO(e.mark?.attrs??e.attrs??{});if(!t)throw new Be("INVALID_TARGET","Comment node is missing a commentId attribute.");return{nodeType:"comment",kind:"inline",properties:{commentId:t}}}function PRn(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 NRn(e){const t=e.node?.attrs??e.attrs??{};return{nodeType:"footnoteRef",kind:"inline",properties:{noteId:typeof t.id=="string"?t.id:void 0}}}function LRn(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 WT(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="string")return LRn(e);if(e&&typeof e=="object"){const t=e,n=WT(t.val??t.value??t.type??t["w:val"]??t["w:value"]);return n??!0}}function MRn(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=WT(t);if(n!=null)return n}}function DRn(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 ORn(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 o=n.trim();return o?o.toLowerCase()==="none"?"transparent":o:void 0}const r=t.fill??t["w:fill"];if(typeof r=="string"){const o=r.trim();return!o||o.toLowerCase()==="auto"?void 0:o.startsWith("#")?o:`#${o}`}}}function FRn(e){const t=e.rFonts;if(t&&typeof t=="object"){const r=t,o=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof o=="string")return o}const n=e.fontFamily;if(typeof n=="string")return n;if(n&&typeof n=="object"){const r=n,o=r.ascii??r.hAnsi??r.eastAsia??r.cs;if(typeof o=="string")return o}}function BRn(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 HRn(e){const t=e.node?.attrs??e.attrs??{},n=t.runProperties&&typeof t.runProperties=="object"?t.runProperties:void 0,r=MRn([n?.underline,n?.u]),o=WT(n?.strike)??WT(n?.dstrike)??void 0,i=n?.lang,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.val=="string"?i.val:void 0;return{nodeType:"run",kind:"inline",properties:{bold:WT(n?.bold)??void 0,italic:WT(n?.italic)??void 0,underline:r??void 0,strike:o,font:n?FRn(n):void 0,size:n?BRn(n):void 0,color:DRn(n?.color),highlight:ORn(n?.highlight),styleId:typeof n?.rStyle=="string"?n.rStyle:typeof n?.styleId=="string"?n.styleId:void 0,language:s}}}function zRn(){return{nodeType:"tab",kind:"inline",properties:{}}}function URn(){return{nodeType:"lineBreak",kind:"inline",properties:{}}}function jT(e){return"anchor"in e}function m8e(e,t,n){const r=t??e.nodeType,o=jT(e)?"inline":"block";switch(r){case"paragraph":if(o!=="block")throw new Be("INVALID_TARGET","Paragraph nodes can only be resolved as blocks.");return vRn(e);case"heading":if(o!=="block")throw new Be("INVALID_TARGET","Heading nodes can only be resolved as blocks.");return wRn(e);case"listItem":if(o!=="block")throw new Be("INVALID_TARGET","ListItem nodes can only be resolved as blocks.");return ARn(e);case"table":if(o!=="block")throw new Be("INVALID_TARGET","Table nodes can only be resolved as blocks.");return SRn(e);case"tableRow":if(o!=="block")throw new Be("INVALID_TARGET","TableRow nodes can only be resolved as blocks.");return TRn();case"tableCell":if(o!=="block")throw new Be("INVALID_TARGET","TableCell nodes can only be resolved as blocks.");return IRn(e);case"image":{const i=e.node?.attrs;return ERn(i,o,n,e.pos)}case"sdt":{const i=e.node?.attrs;return een(i,o)}case"tableOfContents":if(o!=="block")throw new Be("INVALID_TARGET","TableOfContents nodes can only be resolved as blocks.");return xRn(e);case"hyperlink":if(!jT(e))throw new Be("INVALID_TARGET","Hyperlink nodes can only be resolved inline.");return _Rn(e);case"comment":if(!jT(e))throw new Be("INVALID_TARGET","Comment nodes can only be resolved inline.");return RRn(e);case"run":if(!jT(e))throw new Be("INVALID_TARGET","Run nodes can only be resolved inline.");return HRn(e);case"bookmark":if(!jT(e))throw new Be("INVALID_TARGET","Bookmark nodes can only be resolved inline.");return PRn(e);case"footnoteRef":if(!jT(e))throw new Be("INVALID_TARGET","Footnote references can only be resolved inline.");return NRn(e);case"tab":return zRn();case"lineBreak":return URn();default:throw new Be("INVALID_TARGET",`Node type "${r}" is not implemented yet.`)}}function g8e(e,t,n,r){if(n.kind==="block"){const i=Bh(t,n);return i?m8e(i,n.nodeType,e.state.doc):void 0}const o=PE(r??f0(e),n);if(o)return m8e(o,n.nodeType)}function VRn(e,t,n){const r=[];let o;for(const i of n){if(i.kind==="inline"){o??=f0(e);const a=g8e(e,t,i,o);a&&r.push(a);continue}const s=g8e(e,t,i);s&&r.push(s)}return r}function GRn(e,t){return{kind:"inline",nodeType:t??e.nodeType,anchor:e.anchor}}function uQ(e,t,n,r){const o=OE(t,n,r);if(!o.ok)return{matches:[],total:0};const i=f0(e),s=n.select;let a,l;if(s.type==="node"){if(s.kind&&s.kind!=="inline")return p0(r,"Only inline nodes are supported by the current inline adapter."),{matches:[],total:0};if(s.nodeType){if(!P2e(s.nodeType))return p0(r,`Node type "${s.nodeType}" is not an inline type.`),{matches:[],total:0};a=s.nodeType,l=s.nodeType}}else return{matches:[],total:0};let c=a?tO(i,a):i.candidates;c=lO(c,o.range);const u=Ii(c.map(d=>GRn(d,l)),n.offset,n.limit);return{matches:u.items,total:u.total}}function y8e(e,t,n,r){const o={...n,offset:void 0,limit:void 0},i=P3(t,o,r),s=uQ(e,t,o,r),a=Ii(_dn(e,t,[...i.matches,...s.matches]),n.offset,n.limit);return{matches:a.items,total:a.total}}function WRn(e){const t={};for(const n of e)switch(n.type.name){case"bold":t.bold=!x3(n.attrs.value);break;case"italic":t.italic=!x3(n.attrs.value);break;case"strike":t.strike=!x3(n.attrs.value);break;case"underline":{const r=n.attrs.underlineType;r==="none"?t.underline={"w:val":"none"}:r?t.underline={"w:val":r}:t.underline={"w:val":"single"};break}case"runProperties":typeof n.attrs.styleId=="string"&&n.attrs.styleId&&(t.styleId=n.attrs.styleId);break}return t}function jRn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function qRn(e){if(e.length===0)return[];const t=[...e].sort((i,s)=>i.from-s.from),n=[];let r=0;for(;r<t.length&&t[r].from>=t[r].to;)r++;if(r>=t.length)return[];let o={...t[r]};for(let i=r+1;i<t.length;i++){const s=t[i];s.from>=s.to||(s.from===o.to&&jRn(o.marks,s.marks)?o={from:o.from,to:s.to,charCount:o.charCount+s.charCount,marks:o.marks}:(o.charCount>0&&n.push(o),o={...s}))}return o.charCount>0&&n.push(o),n}function KRn(e,t){const n=C3(e,"bold"),r=C3(e,"italic"),o=C3(e,"underline"),i=C3(e,"strike"),s={bold:n,italic:r,underline:o,strike:i},a=kL(n),l=kL(r),c=kL(o),u=kL(i),d={bold:a.effective,italic:l.effective,underline:c.effective,strike:u.effective};if(t&&(n==="clear"||r==="clear"||o==="clear"||i==="clear")){const T=WRn(e),x=nu(t.resolverParams,T,t.paragraphProperties);if(n==="clear"&&(d.bold=x.bold??!1),r==="clear"&&(d.italic=x.italic??!1),i==="clear"&&(d.strike=x.strike??!1),o==="clear"){const C=x.underline?.["w:val"];d.underline=C!=null&&C!=="none"}}const f={direct:s,effective:d},h=e.find(T=>T.type.name==="runProperties"),p=e.find(T=>T.type.name==="textStyle"),m=H0(h,"color")??H0(p,"color"),g=m!=null?b8e(String(m)):void 0;g&&(f.color=g);const y=H0(h,"highlight")??H0(p,"highlight"),b=y!=null?b8e(String(y)):void 0;b&&(f.highlight=b);const v=H0(h,"fontFamily")??H0(p,"fontFamily");typeof v=="string"&&v.trim().length>0&&(f.fontFamily=v);const A=H0(h,"fontSize"),S=A??H0(p,"fontSize"),w=XRn((A!=null?"runProperties":"textStyle")=="runProperties"&&typeof S=="number"?S/2:S);return w!==void 0&&(f.fontSizePt=w),f}function H0(e,t){if(!e)return;const n=e.attrs[t];return n??void 0}function YRn(e){const t=e.find(r=>r.type.name==="runProperties");if(!t)return;const n=t.attrs.styleId;return typeof n=="string"&&n.length>0?n:void 0}function b8e(e){if(!e||typeof e!="string")return;const t=e.trim().toLowerCase();if(!t)return;if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t)){const[,o,i,s]=t;return`#${o}${o}${i}${i}${s}${s}`}if(/^[0-9a-f]{6}$/.test(t))return`#${t}`;const n=t.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);if(n){const[,o,i,s]=n,a=parseInt(o,10),l=parseInt(i,10),c=parseInt(s,10);if(a<=255&&l<=255&&c<=255)return`#${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}const r=ZRn[t];if(r)return r}function XRn(e){if(e==null)return;let t;if(typeof e=="number")t=e;else if(typeof e=="string"){const n=e.replace(/\s*(pt|px|hp)$/i,"").trim();t=parseFloat(n)}else return;if(!(!Number.isFinite(t)||t<0))return Math.round(t*10)/10}function JRn(e,t,n){if(e.length===0){if(t.start!==t.end)throw on("INTERNAL_ERROR",`run-tiling: no runs for non-empty block range in block ${n}`);return}if(e[0].range.start!==t.start)throw on("INTERNAL_ERROR",`run-tiling: first run starts at ${e[0].range.start} but block range starts at ${t.start} in block ${n}`);if(e[e.length-1].range.end!==t.end)throw on("INTERNAL_ERROR",`run-tiling: last run ends at ${e[e.length-1].range.end} but block range ends at ${t.end} in block ${n}`);for(let r=0;r<e.length-1;r++)if(e[r].range.end!==e[r+1].range.start)throw on("INTERNAL_ERROR",`run-tiling: gap or overlap between runs[${r}] and runs[${r+1}] in block ${n}`)}var ZRn={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function QRn(e){return`text:${btoa(JSON.stringify(e))}`}function $5(e,t,n,r,o,i,s){return dT({v:4,rev:t,storyKey:e,scope:r,matchId:n,segments:o,blockIndex:i,runIndex:s})}function $Rn(e,t){const n=e[0],r=e[e.length-1],o={kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start},end:{kind:"text",blockId:r.blockId,offset:r.range.end}};return t&&(o.story=t),o}function ePn(e,t){const n=e[0],r=e[e.length-1],o={kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start},end:{kind:"text",blockId:r.blockId,offset:r.range.end}};return t&&(o.story=t),o}function dQ(e,t){const n=t.node;return n&&typeof n.childCount=="number"&&n.childCount>0?h0(n,{textModel:"visible"}):e.state.doc.textBetween(t.pos+1,t.end-1,`
819
819
  `,"")}function tPn(e,t,n,r,o,i){const s=zn(e),a=e.state.doc,l=new Map,c=[];for(const d of t){const f=l.get(d.blockId);f?f.push(d):(l.set(d.blockId,[d]),c.push(d.blockId))}const u=[];for(let d=0;d<c.length;d++){const f=c[d],h=l.get(f),p=s.candidates.find(E=>E.nodeId===f);if(!p)continue;const m=Math.min(...h.map(E=>E.range.start)),g=Math.max(...h.map(E=>E.range.end)),y=[...h].sort((E,L)=>E.range.start-L.range.start);for(let E=0;E<y.length-1;E++)if(y[E].range.end<y[E+1].range.start){const L=y[E].range.end,R=y[E+1].range.start,M=Math.min(...y.map(H=>H.range.start)),O=Math.max(...y.map(H=>H.range.end));throw on("INVALID_INPUT",`discontiguous text ranges in block ${f}: gap between ${L} and ${R}. Two or more edits target the same block with untouched text between them and cannot be coalesced safely. Fix by: (a) splitting the edits across separate superdoc_mutations batches — preferred, works in both direct and tracked change modes; or (b) combining the edits into a single text.rewrite covering offsets ${M}..${O} — direct mode only, since in tracked mode the untouched middle would be recorded as deleted+reinserted.`,void 0,{blockId:f,gap:{start:L,end:R},coveringRange:{start:M,end:O},rangeCount:y.length,ranges:y.map(H=>({start:H.range.start,end:H.range.end})),remediation:{preferred:"split-batches",optionA:"Split into separate superdoc_mutations batches (works in direct and tracked modes).",optionB:`Combine into one text.rewrite covering offsets ${M}..${O} (direct mode only — pollutes tracked history).`}})}const b=dQ(e,p),v=b.slice(m,g),A=a.nodeAt(p.pos),S=A?.type.name??"paragraph",w=nPn(A),T=i?{resolverParams:i,paragraphProperties:A?.attrs?.paragraphProperties??null}:void 0,x=qRn(fT(e,p.pos,m,g,{textModel:"visible"}).runs),C={start:m,end:g},k=x.map((E,L)=>({range:{start:E.from,end:E.to},text:b.slice(E.from,E.to),styleId:YRn(E.marks),styles:KRn(E.marks,T),ref:$5(o,n,r,"run",[{blockId:f,start:E.from,end:E.to}],d,L)}));for(const E of k)E.styleId===void 0&&delete E.styleId;JRn(k,C,f);const P={blockId:f,nodeType:S,range:C,text:v,ref:$5(o,n,r,"block",[{blockId:f,start:m,end:g}],d),runs:k};w&&(P.paragraphStyle=w),u.push(P)}return u}function nPn(e){if(!e)return;const t=e.attrs,n=t?.paragraphProperties?.styleId,r=t?.listRendering,o=r!=null,i=o?r?.level:void 0;if(!(n||o))return;const s={};return typeof n=="string"&&n.length>0&&(s.styleId=n),o&&(s.isListItem=!0),typeof i=="number"&&i>=0&&(s.listLevel=i),s}function rPn(e,t){if(!e.state?.doc||t.length===0)return;const n=zn(e),r=t.map(p=>p.text).join(`
@@ -825,7 +825,7 @@ function print() { __p += __j.call(arguments, '') }
825
825
  `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}var AHn=Oe((()=>{})),SHn=Oe((()=>{AHn()})),Tze,THn=Oe((()=>{Tze={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 IHn(e,t){const n=t||{};return Oee({file:n.file||void 0,location:!1,schema:n.space==="svg"?_6:E6,verbose:n.verbose||!1},e)}function Oee(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},R6(e,r,n),n}case"#document":case"#document-fragment":{const r=t,o="mode"in r?r.mode==="quirks"||r.mode==="limited-quirks":!1;if(n={type:"root",children:Ize(e,t.childNodes),data:{quirksMode:o}},e.file&&e.location){const i=String(e.file),s=wHn(i),a=s.toPoint(0),l=s.toPoint(i.length);n.position={start:a,end:l}}return n}case"#documentType":{const r=t;return n={type:"doctype"},R6(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},R6(e,r,n),n}default:return n=xHn(e,t),n}}function Ize(e,t){let n=-1;const r=[];for(;++n<t.length;){const o=Oee(e,t[n]);r.push(o)}return r}function xHn(e,t){const n=e.schema;e.schema=t.namespaceURI===Tze.svg?_6:E6;let r=-1;const o={};for(;++r<t.attrs.length;){const s=t.attrs[r],a=(s.prefix?s.prefix+":":"")+s.name;Fee.call(kze,a)||(o[a]=s.value)}const i=(e.schema.space==="svg"?Aze:wze)(t.tagName,o,Ize(e,t.childNodes));if(R6(e,t,i),i.tagName==="template"){const s=t,a=s.sourceCodeLocation,l=a&&a.startTag&&SI(a.startTag),c=a&&a.endTag&&SI(a.endTag),u=Oee(e,s.content);l&&c&&e.file&&(u.position={start:l.end,end:c.start}),i.content=u}return e.schema=n,i}function R6(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=kHn(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function kHn(e,t,n){const r=SI(n);if(t.type==="element"){const o=t.children[t.children.length-1];if(r&&!n.endTag&&o&&o.position&&o.position.end&&(r.end=Object.assign({},o.position.end)),e.verbose){const i={};let s;if(n.attrs)for(s in n.attrs)Fee.call(n.attrs,s)&&(i[fze(e.schema,s).property]=SI(n.attrs[s]));n.startTag;const a=SI(n.startTag),l=n.endTag?SI(n.endTag):void 0,c={opening:a};l&&(c.closing=l),c.properties=i,t.data={position:c}}}return r}function SI(e){const t=xze({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=xze({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function xze(e){return e.line&&e.column?e:void 0}var Fee,kze,CHn=Oe((()=>{Gb(),vHn(),Lee(),SHn(),THn(),Fee={}.hasOwnProperty,kze=Object.prototype})),EHn=Oe((()=>{CHn()}));function Cze(e){return e>=55296&&e<=57343}function _Hn(e){return e>=56320&&e<=57343}function RHn(e,t){return(e-55296)*1024+9216+t}function Eze(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function _ze(e){return e>=64976&&e<=65007||Rze.has(e)}var Rze,PHn,He,Mc,Bee=Oe((()=>{Rze=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]),PHn="�",(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"})(He||(He={})),Mc={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"}})),xt,P6=Oe((()=>{(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"})(xt||(xt={}))})),Pze,Nze,NHn=Oe((()=>{Bee(),P6(),Pze=65536,Nze=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=Pze,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:o}=this,i=r+t,s=o+t;return{code:e,startLine:n,endLine:n,startCol:i,endCol:i,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(_Hn(t))return this.pos++,this._addGap(),RHn(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,He.EOF;return this._err(xt.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,He.EOF;const n=this.html.charCodeAt(t);return n===He.CARRIAGE_RETURN?He.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,He.EOF;let e=this.html.charCodeAt(this.pos);return e===He.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,He.LINE_FEED):e===He.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Cze(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===He.LINE_FEED||e===He.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){Eze(e)?this._err(xt.controlCharacterInInputStream):_ze(e)&&this._err(xt.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}}));function Lze(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 Yo,Hee=Oe((()=>{(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"})(Yo||(Yo={}))})),Mze,LHn=Oe((()=>{Mze=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 MHn(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Dze.get(e))!==null&&t!==void 0?t:e}var zee,Dze,DHn,OHn=Oe((()=>{Dze=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]]),DHn=(zee=String.fromCodePoint)!==null&&zee!==void 0?zee: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 Uee(e){return e>=ol.ZERO&&e<=ol.NINE}function FHn(e){return e>=ol.UPPER_A&&e<=ol.UPPER_F||e>=ol.LOWER_A&&e<=ol.LOWER_F}function BHn(e){return e>=ol.UPPER_A&&e<=ol.UPPER_Z||e>=ol.LOWER_A&&e<=ol.LOWER_Z||Uee(e)}function HHn(e){return e===ol.EQUALS||BHn(e)}function zHn(e,t,n,r){const o=(t&Q0.BRANCH_LENGTH)>>7,i=t&Q0.JUMP_TABLE;if(o===0)return i!==0&&r===i?n:-1;if(i){const l=r-i;return l<0||l>=o?-1:e[n+l]-1}let s=n,a=s+o-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+o]}return-1}var ol,Oze,Q0,il,Hm,Fze,UHn=Oe((()=>{OHn(),LHn(),(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"})(ol||(ol={})),Oze=32,(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Q0||(Q0={})),(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"})(il||(il={})),(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Hm||(Hm={})),Fze=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=il.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Hm.Strict}startEntity(e){this.decodeMode=e,this.state=il.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case il.EntityStart:return e.charCodeAt(t)===ol.NUM?(this.state=il.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=il.NamedEntity,this.stateNamedEntity(e,t));case il.NumericStart:return this.stateNumericStart(e,t);case il.NumericDecimal:return this.stateNumericDecimal(e,t);case il.NumericHex:return this.stateNumericHex(e,t);case il.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|Oze)===ol.LOWER_X?(this.state=il.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=il.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){const o=n-t;this.result=this.result*Math.pow(r,o)+Number.parseInt(e.substr(t,o),r),this.consumed+=o}}stateNumericHex(e,t){const n=t;for(;t<e.length;){const r=e.charCodeAt(t);if(Uee(r)||FHn(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(Uee(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===ol.SEMI)this.consumed+=1;else if(this.decodeMode===Hm.Strict)return 0;return this.emitCodePoint(MHn(this.result),this.consumed),this.errors&&(e!==ol.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){const{decodeTree:n}=this;let r=n[this.treeIndex],o=(r&Q0.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const i=e.charCodeAt(t);if(this.treeIndex=zHn(n,r,this.treeIndex+Math.max(1,o),i),this.treeIndex<0)return this.result===0||this.decodeMode===Hm.Attribute&&(o===0||HHn(i))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],o=(r&Q0.VALUE_LENGTH)>>14,o!==0){if(i===ol.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Hm.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]&Q0.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]&~Q0.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case il.NamedEntity:return this.result!==0&&(this.decodeMode!==Hm.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case il.NumericDecimal:return this.emitNumericEntity(0,2);case il.NumericHex:return this.emitNumericEntity(0,3);case il.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case il.EntityStart:return 0}}}}));function N6(e){var t;return(t=Bze.get(e))!==null&&t!==void 0?t:q.UNKNOWN}var Wt,Xv,Ud,vt,q,Bze,Xt,Hze,L6,VHn,$0=Oe((()=>{(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/"})(Wt||(Wt={})),(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"})(Xv||(Xv={})),(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Ud||(Ud={})),(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"})(vt||(vt={})),(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"})(q||(q={})),Bze=new Map([[vt.A,q.A],[vt.ADDRESS,q.ADDRESS],[vt.ANNOTATION_XML,q.ANNOTATION_XML],[vt.APPLET,q.APPLET],[vt.AREA,q.AREA],[vt.ARTICLE,q.ARTICLE],[vt.ASIDE,q.ASIDE],[vt.B,q.B],[vt.BASE,q.BASE],[vt.BASEFONT,q.BASEFONT],[vt.BGSOUND,q.BGSOUND],[vt.BIG,q.BIG],[vt.BLOCKQUOTE,q.BLOCKQUOTE],[vt.BODY,q.BODY],[vt.BR,q.BR],[vt.BUTTON,q.BUTTON],[vt.CAPTION,q.CAPTION],[vt.CENTER,q.CENTER],[vt.CODE,q.CODE],[vt.COL,q.COL],[vt.COLGROUP,q.COLGROUP],[vt.DD,q.DD],[vt.DESC,q.DESC],[vt.DETAILS,q.DETAILS],[vt.DIALOG,q.DIALOG],[vt.DIR,q.DIR],[vt.DIV,q.DIV],[vt.DL,q.DL],[vt.DT,q.DT],[vt.EM,q.EM],[vt.EMBED,q.EMBED],[vt.FIELDSET,q.FIELDSET],[vt.FIGCAPTION,q.FIGCAPTION],[vt.FIGURE,q.FIGURE],[vt.FONT,q.FONT],[vt.FOOTER,q.FOOTER],[vt.FOREIGN_OBJECT,q.FOREIGN_OBJECT],[vt.FORM,q.FORM],[vt.FRAME,q.FRAME],[vt.FRAMESET,q.FRAMESET],[vt.H1,q.H1],[vt.H2,q.H2],[vt.H3,q.H3],[vt.H4,q.H4],[vt.H5,q.H5],[vt.H6,q.H6],[vt.HEAD,q.HEAD],[vt.HEADER,q.HEADER],[vt.HGROUP,q.HGROUP],[vt.HR,q.HR],[vt.HTML,q.HTML],[vt.I,q.I],[vt.IMG,q.IMG],[vt.IMAGE,q.IMAGE],[vt.INPUT,q.INPUT],[vt.IFRAME,q.IFRAME],[vt.KEYGEN,q.KEYGEN],[vt.LABEL,q.LABEL],[vt.LI,q.LI],[vt.LINK,q.LINK],[vt.LISTING,q.LISTING],[vt.MAIN,q.MAIN],[vt.MALIGNMARK,q.MALIGNMARK],[vt.MARQUEE,q.MARQUEE],[vt.MATH,q.MATH],[vt.MENU,q.MENU],[vt.META,q.META],[vt.MGLYPH,q.MGLYPH],[vt.MI,q.MI],[vt.MO,q.MO],[vt.MN,q.MN],[vt.MS,q.MS],[vt.MTEXT,q.MTEXT],[vt.NAV,q.NAV],[vt.NOBR,q.NOBR],[vt.NOFRAMES,q.NOFRAMES],[vt.NOEMBED,q.NOEMBED],[vt.NOSCRIPT,q.NOSCRIPT],[vt.OBJECT,q.OBJECT],[vt.OL,q.OL],[vt.OPTGROUP,q.OPTGROUP],[vt.OPTION,q.OPTION],[vt.P,q.P],[vt.PARAM,q.PARAM],[vt.PLAINTEXT,q.PLAINTEXT],[vt.PRE,q.PRE],[vt.RB,q.RB],[vt.RP,q.RP],[vt.RT,q.RT],[vt.RTC,q.RTC],[vt.RUBY,q.RUBY],[vt.S,q.S],[vt.SCRIPT,q.SCRIPT],[vt.SEARCH,q.SEARCH],[vt.SECTION,q.SECTION],[vt.SELECT,q.SELECT],[vt.SOURCE,q.SOURCE],[vt.SMALL,q.SMALL],[vt.SPAN,q.SPAN],[vt.STRIKE,q.STRIKE],[vt.STRONG,q.STRONG],[vt.STYLE,q.STYLE],[vt.SUB,q.SUB],[vt.SUMMARY,q.SUMMARY],[vt.SUP,q.SUP],[vt.TABLE,q.TABLE],[vt.TBODY,q.TBODY],[vt.TEMPLATE,q.TEMPLATE],[vt.TEXTAREA,q.TEXTAREA],[vt.TFOOT,q.TFOOT],[vt.TD,q.TD],[vt.TH,q.TH],[vt.THEAD,q.THEAD],[vt.TITLE,q.TITLE],[vt.TR,q.TR],[vt.TRACK,q.TRACK],[vt.TT,q.TT],[vt.U,q.U],[vt.UL,q.UL],[vt.SVG,q.SVG],[vt.VAR,q.VAR],[vt.WBR,q.WBR],[vt.XMP,q.XMP]]),Xt=q,Hze={[Wt.HTML]:new Set([Xt.ADDRESS,Xt.APPLET,Xt.AREA,Xt.ARTICLE,Xt.ASIDE,Xt.BASE,Xt.BASEFONT,Xt.BGSOUND,Xt.BLOCKQUOTE,Xt.BODY,Xt.BR,Xt.BUTTON,Xt.CAPTION,Xt.CENTER,Xt.COL,Xt.COLGROUP,Xt.DD,Xt.DETAILS,Xt.DIR,Xt.DIV,Xt.DL,Xt.DT,Xt.EMBED,Xt.FIELDSET,Xt.FIGCAPTION,Xt.FIGURE,Xt.FOOTER,Xt.FORM,Xt.FRAME,Xt.FRAMESET,Xt.H1,Xt.H2,Xt.H3,Xt.H4,Xt.H5,Xt.H6,Xt.HEAD,Xt.HEADER,Xt.HGROUP,Xt.HR,Xt.HTML,Xt.IFRAME,Xt.IMG,Xt.INPUT,Xt.LI,Xt.LINK,Xt.LISTING,Xt.MAIN,Xt.MARQUEE,Xt.MENU,Xt.META,Xt.NAV,Xt.NOEMBED,Xt.NOFRAMES,Xt.NOSCRIPT,Xt.OBJECT,Xt.OL,Xt.P,Xt.PARAM,Xt.PLAINTEXT,Xt.PRE,Xt.SCRIPT,Xt.SECTION,Xt.SELECT,Xt.SOURCE,Xt.STYLE,Xt.SUMMARY,Xt.TABLE,Xt.TBODY,Xt.TD,Xt.TEMPLATE,Xt.TEXTAREA,Xt.TFOOT,Xt.TH,Xt.THEAD,Xt.TITLE,Xt.TR,Xt.TRACK,Xt.UL,Xt.WBR,Xt.XMP]),[Wt.MATHML]:new Set([Xt.MI,Xt.MO,Xt.MN,Xt.MS,Xt.MTEXT,Xt.ANNOTATION_XML]),[Wt.SVG]:new Set([Xt.TITLE,Xt.FOREIGN_OBJECT,Xt.DESC]),[Wt.XLINK]:new Set,[Wt.XML]:new Set,[Wt.XMLNS]:new Set},L6=new Set([Xt.H1,Xt.H2,Xt.H3,Xt.H4,Xt.H5,Xt.H6]),VHn=new Set([vt.STYLE,vt.SCRIPT,vt.XMP,vt.IFRAME,vt.NOEMBED,vt.NOFRAMES,vt.PLAINTEXT])}));function GHn(e){return e>=He.DIGIT_0&&e<=He.DIGIT_9}function I2(e){return e>=He.LATIN_CAPITAL_A&&e<=He.LATIN_CAPITAL_Z}function WHn(e){return e>=He.LATIN_SMALL_A&&e<=He.LATIN_SMALL_Z}function ey(e){return WHn(e)||I2(e)}function zze(e){return ey(e)||GHn(e)}function M6(e){return e+32}function Uze(e){return e===He.SPACE||e===He.LINE_FEED||e===He.TABULATION||e===He.FORM_FEED}function Vze(e){return Uze(e)||e===He.SOLIDUS||e===He.GREATER_THAN_SIGN}function jHn(e){return e===He.NULL?xt.nullCharacterReference:e>1114111?xt.characterReferenceOutsideUnicodeRange:Cze(e)?xt.surrogateCharacterReference:_ze(e)?xt.noncharacterCharacterReference:Eze(e)||e===He.CARRIAGE_RETURN?xt.controlCharacterReference:null}var Ye,Dc,Gze,Wze=Oe((()=>{NHn(),Bee(),Hee(),UHn(),P6(),$0(),(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"})(Ye||(Ye={})),Dc={DATA:Ye.DATA,RCDATA:Ye.RCDATA,RAWTEXT:Ye.RAWTEXT,SCRIPT_DATA:Ye.SCRIPT_DATA,PLAINTEXT:Ye.PLAINTEXT,CDATA_SECTION:Ye.CDATA_SECTION},Gze=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=Ye.DATA,this.returnState=Ye.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Nze(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new Fze(Mze,(n,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(n)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(xt.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(xt.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const r=jHn(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:Yo.START_TAG,tagName:"",tagID:q.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Yo.END_TAG,tagName:"",tagID:q.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:Yo.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:Yo.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(Lze(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(xt.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=N6(e.tagName),e.type===Yo.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(xt.endTagWithAttributes),e.selfClosing&&this._err(xt.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 Yo.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case Yo.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case Yo.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:Yo.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=Uze(e)?Yo.WHITESPACE_CHARACTER:e===He.NULL?Yo.NULL_CHARACTER:Yo.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(Yo.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=Ye.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Hm.Attribute:Hm.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===Ye.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===Ye.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===Ye.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case Ye.DATA:this._stateData(e);break;case Ye.RCDATA:this._stateRcdata(e);break;case Ye.RAWTEXT:this._stateRawtext(e);break;case Ye.SCRIPT_DATA:this._stateScriptData(e);break;case Ye.PLAINTEXT:this._statePlaintext(e);break;case Ye.TAG_OPEN:this._stateTagOpen(e);break;case Ye.END_TAG_OPEN:this._stateEndTagOpen(e);break;case Ye.TAG_NAME:this._stateTagName(e);break;case Ye.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case Ye.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case Ye.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case Ye.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case Ye.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case Ye.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case Ye.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case Ye.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case Ye.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case Ye.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case Ye.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case Ye.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case Ye.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case Ye.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case Ye.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case Ye.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case Ye.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case Ye.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case Ye.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case Ye.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case Ye.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case Ye.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case Ye.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case Ye.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case Ye.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case Ye.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case Ye.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case Ye.BOGUS_COMMENT:this._stateBogusComment(e);break;case Ye.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case Ye.COMMENT_START:this._stateCommentStart(e);break;case Ye.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case Ye.COMMENT:this._stateComment(e);break;case Ye.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case Ye.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case Ye.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case Ye.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case Ye.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case Ye.COMMENT_END:this._stateCommentEnd(e);break;case Ye.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case Ye.DOCTYPE:this._stateDoctype(e);break;case Ye.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case Ye.DOCTYPE_NAME:this._stateDoctypeName(e);break;case Ye.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case Ye.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case Ye.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case Ye.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case Ye.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case Ye.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case Ye.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case Ye.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case Ye.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case Ye.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case Ye.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case Ye.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case Ye.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case Ye.CDATA_SECTION:this._stateCdataSection(e);break;case Ye.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case Ye.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case Ye.CHARACTER_REFERENCE:this._stateCharacterReference();break;case Ye.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw new Error("Unknown state")}}_stateData(e){switch(e){case He.LESS_THAN_SIGN:this.state=Ye.TAG_OPEN;break;case He.AMPERSAND:this._startCharacterReference();break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitCodePoint(e);break;case He.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case He.AMPERSAND:this._startCharacterReference();break;case He.LESS_THAN_SIGN:this.state=Ye.RCDATA_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case He.LESS_THAN_SIGN:this.state=Ye.RAWTEXT_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(ey(e))this._createStartTagToken(),this.state=Ye.TAG_NAME,this._stateTagName(e);else switch(e){case He.EXCLAMATION_MARK:this.state=Ye.MARKUP_DECLARATION_OPEN;break;case He.SOLIDUS:this.state=Ye.END_TAG_OPEN;break;case He.QUESTION_MARK:this._err(xt.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=Ye.BOGUS_COMMENT,this._stateBogusComment(e);break;case He.EOF:this._err(xt.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(xt.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=Ye.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(ey(e))this._createEndTagToken(),this.state=Ye.TAG_NAME,this._stateTagName(e);else switch(e){case He.GREATER_THAN_SIGN:this._err(xt.missingEndTagName),this.state=Ye.DATA;break;case He.EOF:this._err(xt.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break;default:this._err(xt.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=Ye.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.BEFORE_ATTRIBUTE_NAME;break;case He.SOLIDUS:this.state=Ye.SELF_CLOSING_START_TAG;break;case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentTagToken();break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.tagName+="�";break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(I2(e)?M6(e):e)}}_stateRcdataLessThanSign(e){e===He.SOLIDUS?this.state=Ye.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=Ye.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){ey(e)?(this.state=Ye.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=Ye.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 He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=Ye.BEFORE_ATTRIBUTE_NAME,!1;case He.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=Ye.SELF_CLOSING_START_TAG,!1;case He.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=Ye.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Ye.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===He.SOLIDUS?this.state=Ye.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=Ye.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){ey(e)?(this.state=Ye.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=Ye.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Ye.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case He.SOLIDUS:this.state=Ye.SCRIPT_DATA_END_TAG_OPEN;break;case He.EXCLAMATION_MARK:this.state=Ye.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break;default:this._emitChars("<"),this.state=Ye.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){ey(e)?(this.state=Ye.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=Ye.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Ye.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===He.HYPHEN_MINUS?(this.state=Ye.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=Ye.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===He.HYPHEN_MINUS?(this.state=Ye.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=Ye.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case He.HYPHEN_MINUS:this.state=Ye.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case He.HYPHEN_MINUS:this.state=Ye.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.state=Ye.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Ye.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case He.HYPHEN_MINUS:this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case He.GREATER_THAN_SIGN:this.state=Ye.SCRIPT_DATA,this._emitChars(">");break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.state=Ye.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Ye.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===He.SOLIDUS?this.state=Ye.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ey(e)?(this._emitChars("<"),this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=Ye.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){ey(e)?(this.state=Ye.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=Ye.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=Ye.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(Mc.SCRIPT,!1)&&Vze(this.preprocessor.peek(Mc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<Mc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=Ye.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case He.HYPHEN_MINUS:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case He.HYPHEN_MINUS:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case He.HYPHEN_MINUS:this._emitChars("-");break;case He.LESS_THAN_SIGN:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case He.GREATER_THAN_SIGN:this.state=Ye.SCRIPT_DATA,this._emitChars(">");break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case He.EOF:this._err(xt.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===He.SOLIDUS?(this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(Mc.SCRIPT,!1)&&Vze(this.preprocessor.peek(Mc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<Mc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=Ye.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=Ye.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.SOLIDUS:case He.GREATER_THAN_SIGN:case He.EOF:this.state=Ye.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case He.EQUALS_SIGN:this._err(xt.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=Ye.ATTRIBUTE_NAME;break;default:this._createAttr(""),this.state=Ye.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:case He.SOLIDUS:case He.GREATER_THAN_SIGN:case He.EOF:this._leaveAttrName(),this.state=Ye.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case He.EQUALS_SIGN:this._leaveAttrName(),this.state=Ye.BEFORE_ATTRIBUTE_VALUE;break;case He.QUOTATION_MARK:case He.APOSTROPHE:case He.LESS_THAN_SIGN:this._err(xt.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.currentAttr.name+="�";break;default:this.currentAttr.name+=String.fromCodePoint(I2(e)?M6(e):e)}}_stateAfterAttributeName(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.SOLIDUS:this.state=Ye.SELF_CLOSING_START_TAG;break;case He.EQUALS_SIGN:this.state=Ye.BEFORE_ATTRIBUTE_VALUE;break;case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentTagToken();break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this._createAttr(""),this.state=Ye.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.QUOTATION_MARK:this.state=Ye.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case He.APOSTROPHE:this.state=Ye.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case He.GREATER_THAN_SIGN:this._err(xt.missingAttributeValue),this.state=Ye.DATA,this.emitCurrentTagToken();break;default:this.state=Ye.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case He.QUOTATION_MARK:this.state=Ye.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case He.AMPERSAND:this._startCharacterReference();break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case He.APOSTROPHE:this.state=Ye.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case He.AMPERSAND:this._startCharacterReference();break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this._leaveAttrValue(),this.state=Ye.BEFORE_ATTRIBUTE_NAME;break;case He.AMPERSAND:this._startCharacterReference();break;case He.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Ye.DATA,this.emitCurrentTagToken();break;case He.NULL:this._err(xt.unexpectedNullCharacter),this.currentAttr.value+="�";break;case He.QUOTATION_MARK:case He.APOSTROPHE:case He.LESS_THAN_SIGN:case He.EQUALS_SIGN:case He.GRAVE_ACCENT:this._err(xt.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this._leaveAttrValue(),this.state=Ye.BEFORE_ATTRIBUTE_NAME;break;case He.SOLIDUS:this._leaveAttrValue(),this.state=Ye.SELF_CLOSING_START_TAG;break;case He.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=Ye.DATA,this.emitCurrentTagToken();break;case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this._err(xt.missingWhitespaceBetweenAttributes),this.state=Ye.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case He.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=Ye.DATA,this.emitCurrentTagToken();break}case He.EOF:this._err(xt.eofInTag),this._emitEOFToken();break;default:this._err(xt.unexpectedSolidusInTag),this.state=Ye.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentComment(t);break;case He.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.data+="�";break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(Mc.DASH_DASH,!0)?(this._createCommentToken(Mc.DASH_DASH.length+1),this.state=Ye.COMMENT_START):this._consumeSequenceIfMatch(Mc.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Mc.DOCTYPE.length+1),this.state=Ye.DOCTYPE):this._consumeSequenceIfMatch(Mc.CDATA_START,!0)?this.inForeignNode?this.state=Ye.CDATA_SECTION:(this._err(xt.cdataInHtmlContent),this._createCommentToken(Mc.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=Ye.BOGUS_COMMENT):this._ensureHibernation()||(this._err(xt.incorrectlyOpenedComment),this._createCommentToken(2),this.state=Ye.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case He.HYPHEN_MINUS:this.state=Ye.COMMENT_START_DASH;break;case He.GREATER_THAN_SIGN:{this._err(xt.abruptClosingOfEmptyComment),this.state=Ye.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=Ye.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case He.HYPHEN_MINUS:this.state=Ye.COMMENT_END;break;case He.GREATER_THAN_SIGN:this._err(xt.abruptClosingOfEmptyComment),this.state=Ye.DATA,this.emitCurrentComment(t);break;case He.EOF:this._err(xt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=Ye.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case He.HYPHEN_MINUS:this.state=Ye.COMMENT_END_DASH;break;case He.LESS_THAN_SIGN:t.data+="<",this.state=Ye.COMMENT_LESS_THAN_SIGN;break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.data+="�";break;case He.EOF:this._err(xt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case He.EXCLAMATION_MARK:t.data+="!",this.state=Ye.COMMENT_LESS_THAN_SIGN_BANG;break;case He.LESS_THAN_SIGN:t.data+="<";break;default:this.state=Ye.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===He.HYPHEN_MINUS?this.state=Ye.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=Ye.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===He.HYPHEN_MINUS?this.state=Ye.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=Ye.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==He.GREATER_THAN_SIGN&&e!==He.EOF&&this._err(xt.nestedComment),this.state=Ye.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case He.HYPHEN_MINUS:this.state=Ye.COMMENT_END;break;case He.EOF:this._err(xt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=Ye.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentComment(t);break;case He.EXCLAMATION_MARK:this.state=Ye.COMMENT_END_BANG;break;case He.HYPHEN_MINUS:t.data+="-";break;case He.EOF:this._err(xt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--",this.state=Ye.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case He.HYPHEN_MINUS:t.data+="--!",this.state=Ye.COMMENT_END_DASH;break;case He.GREATER_THAN_SIGN:this._err(xt.incorrectlyClosedComment),this.state=Ye.DATA,this.emitCurrentComment(t);break;case He.EOF:this._err(xt.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--!",this.state=Ye.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.BEFORE_DOCTYPE_NAME;break;case He.GREATER_THAN_SIGN:this.state=Ye.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case He.EOF:{this._err(xt.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(xt.missingWhitespaceBeforeDoctypeName),this.state=Ye.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(I2(e))this._createDoctypeToken(String.fromCharCode(M6(e))),this.state=Ye.DOCTYPE_NAME;else switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.NULL:this._err(xt.unexpectedNullCharacter),this._createDoctypeToken("�"),this.state=Ye.DOCTYPE_NAME;break;case He.GREATER_THAN_SIGN:{this._err(xt.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Ye.DATA;break}case He.EOF:{this._err(xt.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=Ye.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.AFTER_DOCTYPE_NAME;break;case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.name+="�";break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(I2(e)?M6(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(Mc.PUBLIC,!1)?this.state=Ye.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Mc.SYSTEM,!1)?this.state=Ye.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(xt.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case He.QUOTATION_MARK:this._err(xt.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=Ye.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:this._err(xt.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=Ye.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case He.GREATER_THAN_SIGN:this._err(xt.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.QUOTATION_MARK:t.publicId="",this.state=Ye.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:t.publicId="",this.state=Ye.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case He.GREATER_THAN_SIGN:this._err(xt.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case He.QUOTATION_MARK:this.state=Ye.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.publicId+="�";break;case He.GREATER_THAN_SIGN:this._err(xt.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.EOF:this._err(xt.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 He.APOSTROPHE:this.state=Ye.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.publicId+="�";break;case He.GREATER_THAN_SIGN:this._err(xt.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.EOF:this._err(xt.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 He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case He.GREATER_THAN_SIGN:this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.QUOTATION_MARK:this._err(xt.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:this._err(xt.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.QUOTATION_MARK:t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:this.state=Ye.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case He.QUOTATION_MARK:this._err(xt.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:this._err(xt.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case He.GREATER_THAN_SIGN:this._err(xt.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.QUOTATION_MARK:t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case He.APOSTROPHE:t.systemId="",this.state=Ye.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case He.GREATER_THAN_SIGN:this._err(xt.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.DATA,this.emitCurrentDoctype(t);break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case He.QUOTATION_MARK:this.state=Ye.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.systemId+="�";break;case He.GREATER_THAN_SIGN:this._err(xt.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.EOF:this._err(xt.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 He.APOSTROPHE:this.state=Ye.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case He.NULL:this._err(xt.unexpectedNullCharacter),t.systemId+="�";break;case He.GREATER_THAN_SIGN:this._err(xt.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.EOF:this._err(xt.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 He.SPACE:case He.LINE_FEED:case He.TABULATION:case He.FORM_FEED:break;case He.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.EOF:this._err(xt.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(xt.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=Ye.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case He.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=Ye.DATA;break;case He.NULL:this._err(xt.unexpectedNullCharacter);break;case He.EOF:this.emitCurrentDoctype(t),this._emitEOFToken();break;default:}}_stateCdataSection(e){switch(e){case He.RIGHT_SQUARE_BRACKET:this.state=Ye.CDATA_SECTION_BRACKET;break;case He.EOF:this._err(xt.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===He.RIGHT_SQUARE_BRACKET?this.state=Ye.CDATA_SECTION_END:(this._emitChars("]"),this.state=Ye.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case He.GREATER_THAN_SIGN:this.state=Ye.DATA;break;case He.RIGHT_SQUARE_BRACKET:this._emitChars("]");break;default:this._emitChars("]]"),this.state=Ye.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(He.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&zze(this.preprocessor.peek(1))?Ye.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){zze(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===He.SEMICOLON&&this._err(xt.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}}})),Vee,Gee,x2,jze,qze,Wee,jee,Kze,Yze,Xze,Jze,Zze,qHn=Oe((()=>{$0(),Vee=new Set([q.DD,q.DT,q.LI,q.OPTGROUP,q.OPTION,q.P,q.RB,q.RP,q.RT,q.RTC]),Gee=new Set([...Vee,q.CAPTION,q.COLGROUP,q.TBODY,q.TD,q.TFOOT,q.TH,q.THEAD,q.TR]),x2=new Set([q.APPLET,q.CAPTION,q.HTML,q.MARQUEE,q.OBJECT,q.TABLE,q.TD,q.TEMPLATE,q.TH]),jze=new Set([...x2,q.OL,q.UL]),qze=new Set([...x2,q.BUTTON]),Wee=new Set([q.ANNOTATION_XML,q.MI,q.MN,q.MO,q.MS,q.MTEXT]),jee=new Set([q.DESC,q.FOREIGN_OBJECT,q.TITLE]),Kze=new Set([q.TR,q.TEMPLATE,q.HTML]),Yze=new Set([q.TBODY,q.TFOOT,q.THEAD,q.TEMPLATE,q.HTML]),Xze=new Set([q.TABLE,q.TEMPLATE,q.HTML]),Jze=new Set([q.TD,q.TH]),Zze=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=q.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===q.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Wt.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])!==Wt.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(L6,Wt.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Jze,Wt.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(Xze,Wt.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Yze,Wt.HTML)}clearBackToTableRowContext(){this.clearBackTo(Kze,Wt.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]===q.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]===q.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 Wt.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case Wt.SVG:if(jee.has(r))return!1;break;case Wt.MATHML:if(Wee.has(r))return!1;break}}return!0}hasInScope(e){return this.hasInDynamicScope(e,x2)}hasInListItemScope(e){return this.hasInDynamicScope(e,jze)}hasInButtonScope(e){return this.hasInDynamicScope(e,qze)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case Wt.HTML:if(L6.has(t))return!0;if(x2.has(t))return!1;break;case Wt.SVG:if(jee.has(t))return!1;break;case Wt.MATHML:if(Wee.has(t))return!1;break}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Wt.HTML)switch(this.tagIDs[t]){case e:return!0;case q.TABLE:case q.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===Wt.HTML)switch(this.tagIDs[e]){case q.TBODY:case q.THEAD:case q.TFOOT:return!0;case q.TABLE:case q.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Wt.HTML)switch(this.tagIDs[t]){case e:return!0;case q.OPTION:case q.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&Vee.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Gee.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&Gee.has(this.currentTagId);)this.pop()}}})),D6,rp,qee,Qze,KHn=Oe((()=>{D6=3,(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(rp||(rp={})),qee={type:rp.Marker},Qze=class{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const n=[],r=t.length,o=this.treeAdapter.getTagName(e),i=this.treeAdapter.getNamespaceURI(e);for(let s=0;s<this.entries.length;s++){const a=this.entries[s];if(a.type===rp.Marker)break;const{element:l}=a;if(this.treeAdapter.getTagName(l)===o&&this.treeAdapter.getNamespaceURI(l)===i){const c=this.treeAdapter.getAttrList(l);c.length===r&&n.push({idx:s,attrs:c})}}return n}_ensureNoahArkCondition(e){if(this.entries.length<D6)return;const t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<D6)return;const r=new Map(t.map(i=>[i.name,i.value]));let o=0;for(let i=0;i<n.length;i++){const s=n[i];s.attrs.every(a=>r.get(a.name)===a.value)&&(o+=1,o>=D6&&this.entries.splice(s.idx,1))}}insertMarker(){this.entries.unshift(qee)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:rp.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:rp.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(qee);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){const t=this.entries.find(n=>n.type===rp.Marker||this.treeAdapter.getTagName(n.element)===e);return t&&t.type===rp.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===rp.Element&&t.element===e)}}})),zm,Kee=Oe((()=>{$0(),zm={createDocument(){return{nodeName:"#document",mode:Ud.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 o=e.childNodes.find(i=>i.nodeName==="#documentType");if(o)o.name=t,o.publicId=n,o.systemId=r;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};zm.appendChild(e,i)}},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(zm.isTextNode(n)){n.value+=t;return}}zm.appendChild(e,zm.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&zm.isTextNode(r)?r.value+=t:zm.insertBefore(e,zm.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 $ze(e,t){return t.some(n=>e.startsWith(n))}function YHn(e){return e.name===Yee&&e.publicId===null&&(e.systemId===null||e.systemId===eUe)}function XHn(e){if(e.name!==Yee)return Ud.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===tUe)return Ud.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),rUe.has(n))return Ud.QUIRKS;let r=t===null?nUe:Xee;if($ze(n,r))return Ud.QUIRKS;if(r=t===null?Jee:oUe,$ze(n,r))return Ud.LIMITED_QUIRKS}return Ud.NO_QUIRKS}var Yee,eUe,tUe,Xee,nUe,rUe,Jee,oUe,JHn=Oe((()=>{$0(),Yee="html",eUe="about:legacy-compat",tUe="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",Xee=["+//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//"],nUe=[...Xee,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],rUe=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Jee=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],oUe=[...Jee,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"]}));function ZHn(e){const t=e.tagID;return t===q.FONT&&e.attrs.some(({name:n})=>n===Xv.COLOR||n===Xv.SIZE||n===Xv.FACE)||fUe.has(t)}function iUe(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===aUe){e.attrs[t].name=lUe;break}}function sUe(e){for(let t=0;t<e.attrs.length;t++){const n=cUe.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Zee(e){for(let t=0;t<e.attrs.length;t++){const n=uUe.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 QHn(e){const t=dUe.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=N6(e.tagName))}function $Hn(e,t){return t===Wt.MATHML&&(e===q.MI||e===q.MO||e===q.MN||e===q.MS||e===q.MTEXT)}function ezn(e,t,n){if(t===Wt.MATHML&&e===q.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===Xv.ENCODING){const o=n[r].value.toLowerCase();return o===Qee.TEXT_HTML||o===Qee.APPLICATION_XML}}return t===Wt.SVG&&(e===q.FOREIGN_OBJECT||e===q.DESC||e===q.TITLE)}function tzn(e,t,n,r){return(!r||r===Wt.HTML)&&ezn(e,t,n)||(!r||r===Wt.MATHML)&&$Hn(e,t)}var Qee,aUe,lUe,cUe,uUe,dUe,fUe,hUe=Oe((()=>{$0(),Qee={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},aUe="definitionurl",lUe="definitionURL",cUe=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])),uUe=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Wt.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Wt.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Wt.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Wt.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Wt.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Wt.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Wt.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Wt.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Wt.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Wt.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Wt.XMLNS}]]),dUe=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])),fUe=new Set([q.B,q.BIG,q.BLOCKQUOTE,q.BODY,q.BR,q.CENTER,q.CODE,q.DD,q.DIV,q.DL,q.DT,q.EM,q.EMBED,q.H1,q.H2,q.H3,q.H4,q.H5,q.H6,q.HEAD,q.HR,q.I,q.IMG,q.LI,q.LISTING,q.MENU,q.META,q.NOBR,q.OL,q.P,q.PRE,q.RUBY,q.S,q.SMALL,q.SPAN,q.STRONG,q.STRIKE,q.SUB,q.SUP,q.TABLE,q.TT,q.U,q.UL,q.VAR])}));function nzn(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):wUe(e,t),n}function rzn(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const o=e.openElements.items[r];if(o===t.element)break;e._isSpecialElement(o,e.openElements.tagIDs[r])&&(n=o)}return n||(e.openElements.shortenToLength(Math.max(r,0)),e.activeFormattingElements.removeEntry(t)),n}function ozn(e,t,n){let r=t,o=e.openElements.getCommonAncestor(t);for(let i=0,s=o;s!==n;i++,s=o){o=e.openElements.getCommonAncestor(s);const a=e.activeFormattingElements.getElementEntry(s),l=a&&i>=NUe;!a||l?(l&&e.activeFormattingElements.removeEntry(a),e.openElements.remove(s)):(s=izn(e,a),r===t&&(e.activeFormattingElements.bookmark=a),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(s,r),r=s)}return r}function izn(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 szn(e,t,n){const r=N6(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const o=e.treeAdapter.getNamespaceURI(t);r===q.TEMPLATE&&o===Wt.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function azn(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:o}=n,i=e.treeAdapter.createElement(o.tagName,r,o.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,o),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,o.tagID)}function $ee(e,t){for(let n=0;n<PUe;n++){const r=nzn(e,t);if(!r)break;const o=rzn(e,r);if(!o)break;e.activeFormattingElements.bookmark=r;const i=ozn(e,o,r.element),s=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),s&&szn(e,s,i),azn(e,o,r)}}function ete(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function lzn(e,t){e._appendCommentNode(t,e.openElements.items[0])}function czn(e,t){e._appendCommentNode(t,e.document)}function tte(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],o=e.treeAdapter.getNodeSourceCodeLocation(r);if(o&&!o.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],s=e.treeAdapter.getNodeSourceCodeLocation(i);s&&!s.endTag&&e._setEndLocation(i,t)}}}}function uzn(e,t){e._setDocumentType(t);const n=t.forceQuirks?Ud.QUIRKS:XHn(t);YHn(t)||e._err(t,xt.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=ot.BEFORE_HTML}function k2(e,t){e._err(t,xt.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Ud.QUIRKS),e.insertionMode=ot.BEFORE_HTML,e._processToken(t)}function dzn(e,t){t.tagID===q.HTML?(e._insertElement(t,Wt.HTML),e.insertionMode=ot.BEFORE_HEAD):C2(e,t)}function fzn(e,t){const n=t.tagID;(n===q.HTML||n===q.HEAD||n===q.BODY||n===q.BR)&&C2(e,t)}function C2(e,t){e._insertFakeRootElement(),e.insertionMode=ot.BEFORE_HEAD,e._processToken(t)}function hzn(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.HEAD:e._insertElement(t,Wt.HTML),e.headElement=e.openElements.current,e.insertionMode=ot.IN_HEAD;break;default:E2(e,t)}}function pzn(e,t){const n=t.tagID;n===q.HEAD||n===q.BODY||n===q.HTML||n===q.BR?E2(e,t):e._err(t,xt.endTagWithoutMatchingOpenElement)}function E2(e,t){e._insertFakeElement(vt.HEAD,q.HEAD),e.headElement=e.openElements.current,e.insertionMode=ot.IN_HEAD,e._processToken(t)}function Hf(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.BASE:case q.BASEFONT:case q.BGSOUND:case q.LINK:case q.META:e._appendElement(t,Wt.HTML),t.ackSelfClosing=!0;break;case q.TITLE:e._switchToTextParsing(t,Dc.RCDATA);break;case q.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,Dc.RAWTEXT):(e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_HEAD_NO_SCRIPT);break;case q.NOFRAMES:case q.STYLE:e._switchToTextParsing(t,Dc.RAWTEXT);break;case q.SCRIPT:e._switchToTextParsing(t,Dc.SCRIPT_DATA);break;case q.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=ot.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(ot.IN_TEMPLATE);break;case q.HEAD:e._err(t,xt.misplacedStartTagForHeadElement);break;default:_2(e,t)}}function mzn(e,t){switch(t.tagID){case q.HEAD:e.openElements.pop(),e.insertionMode=ot.AFTER_HEAD;break;case q.BODY:case q.BR:case q.HTML:_2(e,t);break;case q.TEMPLATE:Jv(e,t);break;default:e._err(t,xt.endTagWithoutMatchingOpenElement)}}function Jv(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==q.TEMPLATE&&e._err(t,xt.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(q.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,xt.endTagWithoutMatchingOpenElement)}function _2(e,t){e.openElements.pop(),e.insertionMode=ot.AFTER_HEAD,e._processToken(t)}function gzn(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.BASEFONT:case q.BGSOUND:case q.HEAD:case q.LINK:case q.META:case q.NOFRAMES:case q.STYLE:Hf(e,t);break;case q.NOSCRIPT:e._err(t,xt.nestedNoscriptInHead);break;default:R2(e,t)}}function yzn(e,t){switch(t.tagID){case q.NOSCRIPT:e.openElements.pop(),e.insertionMode=ot.IN_HEAD;break;case q.BR:R2(e,t);break;default:e._err(t,xt.endTagWithoutMatchingOpenElement)}}function R2(e,t){const n=t.type===Yo.EOF?xt.openElementsLeftAfterEof:xt.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=ot.IN_HEAD,e._processToken(t)}function bzn(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.BODY:e._insertElement(t,Wt.HTML),e.framesetOk=!1,e.insertionMode=ot.IN_BODY;break;case q.FRAMESET:e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_FRAMESET;break;case q.BASE:case q.BASEFONT:case q.BGSOUND:case q.LINK:case q.META:case q.NOFRAMES:case q.SCRIPT:case q.STYLE:case q.TEMPLATE:case q.TITLE:e._err(t,xt.abandonedHeadElementChild),e.openElements.push(e.headElement,q.HEAD),Hf(e,t),e.openElements.remove(e.headElement);break;case q.HEAD:e._err(t,xt.misplacedStartTagForHeadElement);break;default:P2(e,t)}}function vzn(e,t){switch(t.tagID){case q.BODY:case q.HTML:case q.BR:P2(e,t);break;case q.TEMPLATE:Jv(e,t);break;default:e._err(t,xt.endTagWithoutMatchingOpenElement)}}function P2(e,t){e._insertFakeElement(vt.BODY,q.BODY),e.insertionMode=ot.IN_BODY,O6(e,t)}function O6(e,t){switch(t.type){case Yo.CHARACTER:mUe(e,t);break;case Yo.WHITESPACE_CHARACTER:pUe(e,t);break;case Yo.COMMENT:ete(e,t);break;case Yo.START_TAG:Jl(e,t);break;case Yo.END_TAG:F6(e,t);break;case Yo.EOF:AUe(e,t);break;default:}}function pUe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function mUe(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function wzn(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Azn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function Szn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_FRAMESET)}function Tzn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML)}function Izn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&L6.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Wt.HTML)}function xzn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function kzn(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML),n||(e.formElement=e.openElements.current))}function Czn(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const o=e.openElements.tagIDs[r];if(n===q.LI&&o===q.LI||(n===q.DD||n===q.DT)&&(o===q.DD||o===q.DT)){e.openElements.generateImpliedEndTagsWithExclusion(o),e.openElements.popUntilTagNamePopped(o);break}if(o!==q.ADDRESS&&o!==q.DIV&&o!==q.P&&e._isSpecialElement(e.openElements.items[r],o))break}e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML)}function Ezn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML),e.tokenizer.state=Dc.PLAINTEXT}function _zn(e,t){e.openElements.hasInScope(q.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(q.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML),e.framesetOk=!1}function Rzn(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(vt.A);n&&($ee(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Pzn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Nzn(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(q.NOBR)&&($ee(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Wt.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Lzn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function Mzn(e,t){e.treeAdapter.getDocumentMode(e.document)!==Ud.QUIRKS&&e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._insertElement(t,Wt.HTML),e.framesetOk=!1,e.insertionMode=ot.IN_TABLE}function gUe(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Wt.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function yUe(e){const t=Lze(e,Xv.TYPE);return t!=null&&t.toLowerCase()===RUe}function Dzn(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Wt.HTML),yUe(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function Ozn(e,t){e._appendElement(t,Wt.HTML),t.ackSelfClosing=!0}function Fzn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._appendElement(t,Wt.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Bzn(e,t){t.tagName=vt.IMG,t.tagID=q.IMG,gUe(e,t)}function Hzn(e,t){e._insertElement(t,Wt.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Dc.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=ot.TEXT}function zzn(e,t){e.openElements.hasInButtonScope(q.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Dc.RAWTEXT)}function Uzn(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Dc.RAWTEXT)}function bUe(e,t){e._switchToTextParsing(t,Dc.RAWTEXT)}function Vzn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===ot.IN_TABLE||e.insertionMode===ot.IN_CAPTION||e.insertionMode===ot.IN_TABLE_BODY||e.insertionMode===ot.IN_ROW||e.insertionMode===ot.IN_CELL?ot.IN_SELECT_IN_TABLE:ot.IN_SELECT}function Gzn(e,t){e.openElements.currentTagId===q.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML)}function Wzn(e,t){e.openElements.hasInScope(q.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Wt.HTML)}function jzn(e,t){e.openElements.hasInScope(q.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(q.RTC),e._insertElement(t,Wt.HTML)}function qzn(e,t){e._reconstructActiveFormattingElements(),iUe(t),Zee(t),t.selfClosing?e._appendElement(t,Wt.MATHML):e._insertElement(t,Wt.MATHML),t.ackSelfClosing=!0}function Kzn(e,t){e._reconstructActiveFormattingElements(),sUe(t),Zee(t),t.selfClosing?e._appendElement(t,Wt.SVG):e._insertElement(t,Wt.SVG),t.ackSelfClosing=!0}function vUe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Wt.HTML)}function Jl(e,t){switch(t.tagID){case q.I:case q.S:case q.B:case q.U:case q.EM:case q.TT:case q.BIG:case q.CODE:case q.FONT:case q.SMALL:case q.STRIKE:case q.STRONG:Pzn(e,t);break;case q.A:Rzn(e,t);break;case q.H1:case q.H2:case q.H3:case q.H4:case q.H5:case q.H6:Izn(e,t);break;case q.P:case q.DL:case q.OL:case q.UL:case q.DIV:case q.DIR:case q.NAV:case q.MAIN:case q.MENU:case q.ASIDE:case q.CENTER:case q.FIGURE:case q.FOOTER:case q.HEADER:case q.HGROUP:case q.DIALOG:case q.DETAILS:case q.ADDRESS:case q.ARTICLE:case q.SEARCH:case q.SECTION:case q.SUMMARY:case q.FIELDSET:case q.BLOCKQUOTE:case q.FIGCAPTION:Tzn(e,t);break;case q.LI:case q.DD:case q.DT:Czn(e,t);break;case q.BR:case q.IMG:case q.WBR:case q.AREA:case q.EMBED:case q.KEYGEN:gUe(e,t);break;case q.HR:Fzn(e,t);break;case q.RB:case q.RTC:Wzn(e,t);break;case q.RT:case q.RP:jzn(e,t);break;case q.PRE:case q.LISTING:xzn(e,t);break;case q.XMP:zzn(e,t);break;case q.SVG:Kzn(e,t);break;case q.HTML:wzn(e,t);break;case q.BASE:case q.LINK:case q.META:case q.STYLE:case q.TITLE:case q.SCRIPT:case q.BGSOUND:case q.BASEFONT:case q.TEMPLATE:Hf(e,t);break;case q.BODY:Azn(e,t);break;case q.FORM:kzn(e,t);break;case q.NOBR:Nzn(e,t);break;case q.MATH:qzn(e,t);break;case q.TABLE:Mzn(e,t);break;case q.INPUT:Dzn(e,t);break;case q.PARAM:case q.TRACK:case q.SOURCE:Ozn(e,t);break;case q.IMAGE:Bzn(e,t);break;case q.BUTTON:_zn(e,t);break;case q.APPLET:case q.OBJECT:case q.MARQUEE:Lzn(e,t);break;case q.IFRAME:Uzn(e,t);break;case q.SELECT:Vzn(e,t);break;case q.OPTION:case q.OPTGROUP:Gzn(e,t);break;case q.NOEMBED:case q.NOFRAMES:bUe(e,t);break;case q.FRAMESET:Szn(e,t);break;case q.TEXTAREA:Hzn(e,t);break;case q.NOSCRIPT:e.options.scriptingEnabled?bUe(e,t):vUe(e,t);break;case q.PLAINTEXT:Ezn(e,t);break;case q.COL:case q.TH:case q.TD:case q.TR:case q.HEAD:case q.FRAME:case q.TBODY:case q.TFOOT:case q.THEAD:case q.CAPTION:case q.COLGROUP:break;default:vUe(e,t)}}function Yzn(e,t){if(e.openElements.hasInScope(q.BODY)&&(e.insertionMode=ot.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Xzn(e,t){e.openElements.hasInScope(q.BODY)&&(e.insertionMode=ot.AFTER_BODY,EUe(e,t))}function Jzn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function Zzn(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(q.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(q.FORM):n&&e.openElements.remove(n))}function Qzn(e){e.openElements.hasInButtonScope(q.P)||e._insertFakeElement(vt.P,q.P),e._closePElement()}function $zn(e){e.openElements.hasInListItemScope(q.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(q.LI),e.openElements.popUntilTagNamePopped(q.LI))}function eUn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function tUn(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function nUn(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function rUn(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(vt.BR,q.BR),e.openElements.pop(),e.framesetOk=!1}function wUe(e,t){const n=t.tagName,r=t.tagID;for(let o=e.openElements.stackTop;o>0;o--){const i=e.openElements.items[o],s=e.openElements.tagIDs[o];if(r===s&&(r!==q.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=o&&e.openElements.shortenToLength(o);break}if(e._isSpecialElement(i,s))break}}function F6(e,t){switch(t.tagID){case q.A:case q.B:case q.I:case q.S:case q.U:case q.EM:case q.TT:case q.BIG:case q.CODE:case q.FONT:case q.NOBR:case q.SMALL:case q.STRIKE:case q.STRONG:$ee(e,t);break;case q.P:Qzn(e);break;case q.DL:case q.UL:case q.OL:case q.DIR:case q.DIV:case q.NAV:case q.PRE:case q.MAIN:case q.MENU:case q.ASIDE:case q.BUTTON:case q.CENTER:case q.FIGURE:case q.FOOTER:case q.HEADER:case q.HGROUP:case q.DIALOG:case q.ADDRESS:case q.ARTICLE:case q.DETAILS:case q.SEARCH:case q.SECTION:case q.SUMMARY:case q.LISTING:case q.FIELDSET:case q.BLOCKQUOTE:case q.FIGCAPTION:Jzn(e,t);break;case q.LI:$zn(e);break;case q.DD:case q.DT:eUn(e,t);break;case q.H1:case q.H2:case q.H3:case q.H4:case q.H5:case q.H6:tUn(e);break;case q.BR:rUn(e);break;case q.BODY:Yzn(e,t);break;case q.HTML:Xzn(e,t);break;case q.FORM:Zzn(e);break;case q.APPLET:case q.OBJECT:case q.MARQUEE:nUn(e,t);break;case q.TEMPLATE:Jv(e,t);break;default:wUe(e,t)}}function AUe(e,t){e.tmplInsertionModeStack.length>0?CUe(e,t):tte(e,t)}function oUn(e,t){var n;t.tagID===q.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function iUn(e,t){e._err(t,xt.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function nte(e,t){if(e.openElements.currentTagId!==void 0&&ite.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=ot.IN_TABLE_TEXT,t.type){case Yo.CHARACTER:TUe(e,t);break;case Yo.WHITESPACE_CHARACTER:SUe(e,t);break}else L2(e,t)}function sUn(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_CAPTION}function aUn(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_COLUMN_GROUP}function lUn(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(vt.COLGROUP,q.COLGROUP),e.insertionMode=ot.IN_COLUMN_GROUP,rte(e,t)}function cUn(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_TABLE_BODY}function uUn(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(vt.TBODY,q.TBODY),e.insertionMode=ot.IN_TABLE_BODY,H6(e,t)}function dUn(e,t){e.openElements.hasInTableScope(q.TABLE)&&(e.openElements.popUntilTagNamePopped(q.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function fUn(e,t){yUe(t)?e._appendElement(t,Wt.HTML):L2(e,t),t.ackSelfClosing=!0}function hUn(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Wt.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function TI(e,t){switch(t.tagID){case q.TD:case q.TH:case q.TR:uUn(e,t);break;case q.STYLE:case q.SCRIPT:case q.TEMPLATE:Hf(e,t);break;case q.COL:lUn(e,t);break;case q.FORM:hUn(e,t);break;case q.TABLE:dUn(e,t);break;case q.TBODY:case q.TFOOT:case q.THEAD:cUn(e,t);break;case q.INPUT:fUn(e,t);break;case q.CAPTION:sUn(e,t);break;case q.COLGROUP:aUn(e,t);break;default:L2(e,t)}}function N2(e,t){switch(t.tagID){case q.TABLE:e.openElements.hasInTableScope(q.TABLE)&&(e.openElements.popUntilTagNamePopped(q.TABLE),e._resetInsertionMode());break;case q.TEMPLATE:Jv(e,t);break;case q.BODY:case q.CAPTION:case q.COL:case q.COLGROUP:case q.HTML:case q.TBODY:case q.TD:case q.TFOOT:case q.TH:case q.THEAD:case q.TR:break;default:L2(e,t)}}function L2(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,O6(e,t),e.fosterParentingEnabled=n}function SUe(e,t){e.pendingCharacterTokens.push(t)}function TUe(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function M2(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)L2(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}function pUn(e,t){const n=t.tagID;lte.has(n)?e.openElements.hasInTableScope(q.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(q.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=ot.IN_TABLE,TI(e,t)):Jl(e,t)}function mUn(e,t){const n=t.tagID;switch(n){case q.CAPTION:case q.TABLE:e.openElements.hasInTableScope(q.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(q.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=ot.IN_TABLE,n===q.TABLE&&N2(e,t));break;case q.BODY:case q.COL:case q.COLGROUP:case q.HTML:case q.TBODY:case q.TD:case q.TFOOT:case q.TH:case q.THEAD:case q.TR:break;default:F6(e,t)}}function rte(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.COL:e._appendElement(t,Wt.HTML),t.ackSelfClosing=!0;break;case q.TEMPLATE:Hf(e,t);break;default:B6(e,t)}}function gUn(e,t){switch(t.tagID){case q.COLGROUP:e.openElements.currentTagId===q.COLGROUP&&(e.openElements.pop(),e.insertionMode=ot.IN_TABLE);break;case q.TEMPLATE:Jv(e,t);break;case q.COL:break;default:B6(e,t)}}function B6(e,t){e.openElements.currentTagId===q.COLGROUP&&(e.openElements.pop(),e.insertionMode=ot.IN_TABLE,e._processToken(t))}function H6(e,t){switch(t.tagID){case q.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_ROW;break;case q.TH:case q.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(vt.TR,q.TR),e.insertionMode=ot.IN_ROW,z6(e,t);break;case q.CAPTION:case q.COL:case q.COLGROUP:case q.TBODY:case q.TFOOT:case q.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE,TI(e,t));break;default:TI(e,t)}}function ote(e,t){const n=t.tagID;switch(t.tagID){case q.TBODY:case q.TFOOT:case q.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE);break;case q.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE,N2(e,t));break;case q.BODY:case q.CAPTION:case q.COL:case q.COLGROUP:case q.HTML:case q.TD:case q.TH:case q.TR:break;default:N2(e,t)}}function z6(e,t){switch(t.tagID){case q.TH:case q.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,Wt.HTML),e.insertionMode=ot.IN_CELL,e.activeFormattingElements.insertMarker();break;case q.CAPTION:case q.COL:case q.COLGROUP:case q.TBODY:case q.TFOOT:case q.THEAD:case q.TR:e.openElements.hasInTableScope(q.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE_BODY,H6(e,t));break;default:TI(e,t)}}function IUe(e,t){switch(t.tagID){case q.TR:e.openElements.hasInTableScope(q.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE_BODY);break;case q.TABLE:e.openElements.hasInTableScope(q.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE_BODY,ote(e,t));break;case q.TBODY:case q.TFOOT:case q.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(q.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=ot.IN_TABLE_BODY,ote(e,t));break;case q.BODY:case q.CAPTION:case q.COL:case q.COLGROUP:case q.HTML:case q.TD:case q.TH:break;default:N2(e,t)}}function yUn(e,t){const n=t.tagID;lte.has(n)?(e.openElements.hasInTableScope(q.TD)||e.openElements.hasInTableScope(q.TH))&&(e._closeTableCell(),z6(e,t)):Jl(e,t)}function bUn(e,t){const n=t.tagID;switch(n){case q.TD:case q.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=ot.IN_ROW);break;case q.TABLE:case q.TBODY:case q.TFOOT:case q.THEAD:case q.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),IUe(e,t));break;case q.BODY:case q.CAPTION:case q.COL:case q.COLGROUP:case q.HTML:break;default:F6(e,t)}}function xUe(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.OPTION:e.openElements.currentTagId===q.OPTION&&e.openElements.pop(),e._insertElement(t,Wt.HTML);break;case q.OPTGROUP:e.openElements.currentTagId===q.OPTION&&e.openElements.pop(),e.openElements.currentTagId===q.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Wt.HTML);break;case q.HR:e.openElements.currentTagId===q.OPTION&&e.openElements.pop(),e.openElements.currentTagId===q.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Wt.HTML),t.ackSelfClosing=!0;break;case q.INPUT:case q.KEYGEN:case q.TEXTAREA:case q.SELECT:e.openElements.hasInSelectScope(q.SELECT)&&(e.openElements.popUntilTagNamePopped(q.SELECT),e._resetInsertionMode(),t.tagID!==q.SELECT&&e._processStartTag(t));break;case q.SCRIPT:case q.TEMPLATE:Hf(e,t);break;default:}}function kUe(e,t){switch(t.tagID){case q.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===q.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===q.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===q.OPTGROUP&&e.openElements.pop();break;case q.OPTION:e.openElements.currentTagId===q.OPTION&&e.openElements.pop();break;case q.SELECT:e.openElements.hasInSelectScope(q.SELECT)&&(e.openElements.popUntilTagNamePopped(q.SELECT),e._resetInsertionMode());break;case q.TEMPLATE:Jv(e,t);break;default:}}function vUn(e,t){const n=t.tagID;n===q.CAPTION||n===q.TABLE||n===q.TBODY||n===q.TFOOT||n===q.THEAD||n===q.TR||n===q.TD||n===q.TH?(e.openElements.popUntilTagNamePopped(q.SELECT),e._resetInsertionMode(),e._processStartTag(t)):xUe(e,t)}function wUn(e,t){const n=t.tagID;n===q.CAPTION||n===q.TABLE||n===q.TBODY||n===q.TFOOT||n===q.THEAD||n===q.TR||n===q.TD||n===q.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(q.SELECT),e._resetInsertionMode(),e.onEndTag(t)):kUe(e,t)}function AUn(e,t){switch(t.tagID){case q.BASE:case q.BASEFONT:case q.BGSOUND:case q.LINK:case q.META:case q.NOFRAMES:case q.SCRIPT:case q.STYLE:case q.TEMPLATE:case q.TITLE:Hf(e,t);break;case q.CAPTION:case q.COLGROUP:case q.TBODY:case q.TFOOT:case q.THEAD:e.tmplInsertionModeStack[0]=ot.IN_TABLE,e.insertionMode=ot.IN_TABLE,TI(e,t);break;case q.COL:e.tmplInsertionModeStack[0]=ot.IN_COLUMN_GROUP,e.insertionMode=ot.IN_COLUMN_GROUP,rte(e,t);break;case q.TR:e.tmplInsertionModeStack[0]=ot.IN_TABLE_BODY,e.insertionMode=ot.IN_TABLE_BODY,H6(e,t);break;case q.TD:case q.TH:e.tmplInsertionModeStack[0]=ot.IN_ROW,e.insertionMode=ot.IN_ROW,z6(e,t);break;default:e.tmplInsertionModeStack[0]=ot.IN_BODY,e.insertionMode=ot.IN_BODY,Jl(e,t)}}function SUn(e,t){t.tagID===q.TEMPLATE&&Jv(e,t)}function CUe(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(q.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):tte(e,t)}function TUn(e,t){t.tagID===q.HTML?Jl(e,t):U6(e,t)}function EUe(e,t){var n;if(t.tagID===q.HTML){if(e.fragmentContext||(e.insertionMode=ot.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===q.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 U6(e,t)}function U6(e,t){e.insertionMode=ot.IN_BODY,O6(e,t)}function IUn(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.FRAMESET:e._insertElement(t,Wt.HTML);break;case q.FRAME:e._appendElement(t,Wt.HTML),t.ackSelfClosing=!0;break;case q.NOFRAMES:Hf(e,t);break;default:}}function xUn(e,t){t.tagID===q.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==q.FRAMESET&&(e.insertionMode=ot.AFTER_FRAMESET))}function kUn(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.NOFRAMES:Hf(e,t);break;default:}}function CUn(e,t){t.tagID===q.HTML&&(e.insertionMode=ot.AFTER_AFTER_FRAMESET)}function EUn(e,t){t.tagID===q.HTML?Jl(e,t):V6(e,t)}function V6(e,t){e.insertionMode=ot.IN_BODY,O6(e,t)}function _Un(e,t){switch(t.tagID){case q.HTML:Jl(e,t);break;case q.NOFRAMES:Hf(e,t);break;default:}}function RUn(e,t){t.chars="�",e._insertCharacters(t)}function PUn(e,t){e._insertCharacters(t),e.framesetOk=!1}function _Ue(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Wt.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function NUn(e,t){if(ZHn(t))_Ue(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===Wt.MATHML?iUe(t):r===Wt.SVG&&(QHn(t),sUe(t)),Zee(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function LUn(e,t){if(t.tagID===q.P||t.tagID===q.BR){_Ue(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)===Wt.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(r);if(o.toLowerCase()===t.tagName){t.tagName=o,e.openElements.shortenToLength(n);break}}}var RUe,PUe,NUe,ot,LUe,ite,ste,ate,lte,MUn=Oe((()=>{Wze(),qHn(),KHn(),Kee(),JHn(),hUe(),P6(),Bee(),$0(),Hee(),RUe="hidden",PUe=8,NUe=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"})(ot||(ot={})),LUe={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},ite=new Set([q.TABLE,q.TBODY,q.TFOOT,q.THEAD,q.TR]),ste={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:zm,onParseError:null},ate=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=ot.INITIAL,this.originalInsertionMode=ot.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={...ste,...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 Gze(this.options,this),this.activeFormattingElements=new Qze(this.treeAdapter),this.fragmentContextID=n?N6(this.treeAdapter.getTagName(n)):q.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new Zze(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={...ste,...t};e!=null||(e=n.treeAdapter.createElement(vt.TEMPLATE,Wt.HTML,[]));const r=n.treeAdapter.createElement("documentmock",Wt.HTML,[]),o=new this(n,r,e);return o.fragmentContextID===q.TEMPLATE&&o.tmplInsertionModeStack.unshift(ot.IN_TEMPLATE),o._initTokenizerForFragmentParsing(),o._insertFakeRootElement(),o._resetInsertionMode(),o._findFormInFragmentContext(),o}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 o=(r=e.location)!==null&&r!==void 0?r:LUe,i={code:t,startLine:o.startLine,startCol:o.startCol,startOffset:o.startOffset,endLine:n?o.startLine:o.endLine,endCol:n?o.startCol:o.endCol,endOffset:n?o.startOffset:o.endOffset};this.onParseError(i)}onItemPush(e,t,n){var r,o;(o=(r=this.treeAdapter).onItemPush)===null||o===void 0||o.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 o,i;this.openElements.stackTop===0&&this.fragmentContext?(o=this.fragmentContext,i=this.fragmentContextID):{current:o,currentTagId:i}=this.openElements,this._setContextModes(o,i)}}_setContextModes(e,t){const n=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===Wt.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,Wt.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=ot.TEXT}switchToPlaintextParsing(){this.insertionMode=ot.TEXT,this.originalInsertionMode=ot.IN_BODY,this.tokenizer.state=Dc.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)===vt.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Wt.HTML))switch(this.fragmentContextID){case q.TITLE:case q.TEXTAREA:this.tokenizer.state=Dc.RCDATA;break;case q.STYLE:case q.XMP:case q.IFRAME:case q.NOEMBED:case q.NOFRAMES:case q.NOSCRIPT:this.tokenizer.state=Dc.RAWTEXT;break;case q.SCRIPT:this.tokenizer.state=Dc.SCRIPT_DATA;break;case q.PLAINTEXT:this.tokenizer.state=Dc.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 o=this.treeAdapter.getChildNodes(this.document).find(i=>this.treeAdapter.isDocumentTypeNode(i));o&&this.treeAdapter.setNodeSourceCodeLocation(o,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,Wt.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,Wt.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(vt.HTML,Wt.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,q.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),o=r[(n?r.lastIndexOf(n):r.length)-1];if(this.treeAdapter.getNodeSourceCodeLocation(o)){const{endLine:i,endCol:s,endOffset:a}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(o,{endLine:i,endCol:s,endOffset:a})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(o,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),o=t.type===Yo.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,o)}}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===q.SVG&&this.treeAdapter.getTagName(t)===vt.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===Wt.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===q.MGLYPH||e.tagID===q.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,Wt.HTML)}_processToken(e){switch(e.type){case Yo.CHARACTER:this.onCharacter(e);break;case Yo.NULL_CHARACTER:this.onNullCharacter(e);break;case Yo.COMMENT:this.onComment(e);break;case Yo.DOCTYPE:this.onDoctype(e);break;case Yo.START_TAG:this._processStartTag(e);break;case Yo.END_TAG:this.onEndTag(e);break;case Yo.EOF:this.onEof(e);break;case Yo.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e);break}}_isIntegrationPoint(e,t,n){const r=this.treeAdapter.getNamespaceURI(t),o=this.treeAdapter.getAttrList(t);return tzn(e,r,o,n)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(r=>r.type===rp.Marker||this.openElements.contains(r.element)),n=t===-1?e-1:t-1;for(let r=n;r>=0;r--){const o=this.activeFormattingElements.entries[r];this._insertElement(o.token,this.treeAdapter.getNamespaceURI(o.element)),o.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=ot.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(q.P),this.openElements.popUntilTagNamePopped(q.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case q.TR:this.insertionMode=ot.IN_ROW;return;case q.TBODY:case q.THEAD:case q.TFOOT:this.insertionMode=ot.IN_TABLE_BODY;return;case q.CAPTION:this.insertionMode=ot.IN_CAPTION;return;case q.COLGROUP:this.insertionMode=ot.IN_COLUMN_GROUP;return;case q.TABLE:this.insertionMode=ot.IN_TABLE;return;case q.BODY:this.insertionMode=ot.IN_BODY;return;case q.FRAMESET:this.insertionMode=ot.IN_FRAMESET;return;case q.SELECT:this._resetInsertionModeForSelect(e);return;case q.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case q.HTML:this.insertionMode=this.headElement?ot.AFTER_HEAD:ot.BEFORE_HEAD;return;case q.TD:case q.TH:if(e>0){this.insertionMode=ot.IN_CELL;return}break;case q.HEAD:if(e>0){this.insertionMode=ot.IN_HEAD;return}break}this.insertionMode=ot.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const n=this.openElements.tagIDs[t];if(n===q.TEMPLATE)break;if(n===q.TABLE){this.insertionMode=ot.IN_SELECT_IN_TABLE;return}}this.insertionMode=ot.IN_SELECT}_isElementCausesFosterParenting(e){return ite.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 q.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===Wt.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case q.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 Hze[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){PUn(this,e);return}switch(this.insertionMode){case ot.INITIAL:k2(this,e);break;case ot.BEFORE_HTML:C2(this,e);break;case ot.BEFORE_HEAD:E2(this,e);break;case ot.IN_HEAD:_2(this,e);break;case ot.IN_HEAD_NO_SCRIPT:R2(this,e);break;case ot.AFTER_HEAD:P2(this,e);break;case ot.IN_BODY:case ot.IN_CAPTION:case ot.IN_CELL:case ot.IN_TEMPLATE:mUe(this,e);break;case ot.TEXT:case ot.IN_SELECT:case ot.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case ot.IN_TABLE:case ot.IN_TABLE_BODY:case ot.IN_ROW:nte(this,e);break;case ot.IN_TABLE_TEXT:TUe(this,e);break;case ot.IN_COLUMN_GROUP:B6(this,e);break;case ot.AFTER_BODY:U6(this,e);break;case ot.AFTER_AFTER_BODY:V6(this,e);break;default:}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){RUn(this,e);return}switch(this.insertionMode){case ot.INITIAL:k2(this,e);break;case ot.BEFORE_HTML:C2(this,e);break;case ot.BEFORE_HEAD:E2(this,e);break;case ot.IN_HEAD:_2(this,e);break;case ot.IN_HEAD_NO_SCRIPT:R2(this,e);break;case ot.AFTER_HEAD:P2(this,e);break;case ot.TEXT:this._insertCharacters(e);break;case ot.IN_TABLE:case ot.IN_TABLE_BODY:case ot.IN_ROW:nte(this,e);break;case ot.IN_COLUMN_GROUP:B6(this,e);break;case ot.AFTER_BODY:U6(this,e);break;case ot.AFTER_AFTER_BODY:V6(this,e);break;default:}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){ete(this,e);return}switch(this.insertionMode){case ot.INITIAL:case ot.BEFORE_HTML:case ot.BEFORE_HEAD:case ot.IN_HEAD:case ot.IN_HEAD_NO_SCRIPT:case ot.AFTER_HEAD:case ot.IN_BODY:case ot.IN_TABLE:case ot.IN_CAPTION:case ot.IN_COLUMN_GROUP:case ot.IN_TABLE_BODY:case ot.IN_ROW:case ot.IN_CELL:case ot.IN_SELECT:case ot.IN_SELECT_IN_TABLE:case ot.IN_TEMPLATE:case ot.IN_FRAMESET:case ot.AFTER_FRAMESET:ete(this,e);break;case ot.IN_TABLE_TEXT:M2(this,e);break;case ot.AFTER_BODY:lzn(this,e);break;case ot.AFTER_AFTER_BODY:case ot.AFTER_AFTER_FRAMESET:czn(this,e);break;default:}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case ot.INITIAL:uzn(this,e);break;case ot.BEFORE_HEAD:case ot.IN_HEAD:case ot.IN_HEAD_NO_SCRIPT:case ot.AFTER_HEAD:this._err(e,xt.misplacedDoctype);break;case ot.IN_TABLE_TEXT:M2(this,e);break;default:}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,xt.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?NUn(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case ot.INITIAL:k2(this,e);break;case ot.BEFORE_HTML:dzn(this,e);break;case ot.BEFORE_HEAD:hzn(this,e);break;case ot.IN_HEAD:Hf(this,e);break;case ot.IN_HEAD_NO_SCRIPT:gzn(this,e);break;case ot.AFTER_HEAD:bzn(this,e);break;case ot.IN_BODY:Jl(this,e);break;case ot.IN_TABLE:TI(this,e);break;case ot.IN_TABLE_TEXT:M2(this,e);break;case ot.IN_CAPTION:pUn(this,e);break;case ot.IN_COLUMN_GROUP:rte(this,e);break;case ot.IN_TABLE_BODY:H6(this,e);break;case ot.IN_ROW:z6(this,e);break;case ot.IN_CELL:yUn(this,e);break;case ot.IN_SELECT:xUe(this,e);break;case ot.IN_SELECT_IN_TABLE:vUn(this,e);break;case ot.IN_TEMPLATE:AUn(this,e);break;case ot.AFTER_BODY:TUn(this,e);break;case ot.IN_FRAMESET:IUn(this,e);break;case ot.AFTER_FRAMESET:kUn(this,e);break;case ot.AFTER_AFTER_BODY:EUn(this,e);break;case ot.AFTER_AFTER_FRAMESET:_Un(this,e);break;default:}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?LUn(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case ot.INITIAL:k2(this,e);break;case ot.BEFORE_HTML:fzn(this,e);break;case ot.BEFORE_HEAD:pzn(this,e);break;case ot.IN_HEAD:mzn(this,e);break;case ot.IN_HEAD_NO_SCRIPT:yzn(this,e);break;case ot.AFTER_HEAD:vzn(this,e);break;case ot.IN_BODY:F6(this,e);break;case ot.TEXT:oUn(this,e);break;case ot.IN_TABLE:N2(this,e);break;case ot.IN_TABLE_TEXT:M2(this,e);break;case ot.IN_CAPTION:mUn(this,e);break;case ot.IN_COLUMN_GROUP:gUn(this,e);break;case ot.IN_TABLE_BODY:ote(this,e);break;case ot.IN_ROW:IUe(this,e);break;case ot.IN_CELL:bUn(this,e);break;case ot.IN_SELECT:kUe(this,e);break;case ot.IN_SELECT_IN_TABLE:wUn(this,e);break;case ot.IN_TEMPLATE:SUn(this,e);break;case ot.AFTER_BODY:EUe(this,e);break;case ot.IN_FRAMESET:xUn(this,e);break;case ot.AFTER_FRAMESET:CUn(this,e);break;case ot.AFTER_AFTER_BODY:V6(this,e);break;default:}}onEof(e){switch(this.insertionMode){case ot.INITIAL:k2(this,e);break;case ot.BEFORE_HTML:C2(this,e);break;case ot.BEFORE_HEAD:E2(this,e);break;case ot.IN_HEAD:_2(this,e);break;case ot.IN_HEAD_NO_SCRIPT:R2(this,e);break;case ot.AFTER_HEAD:P2(this,e);break;case ot.IN_BODY:case ot.IN_TABLE:case ot.IN_CAPTION:case ot.IN_COLUMN_GROUP:case ot.IN_TABLE_BODY:case ot.IN_ROW:case ot.IN_CELL:case ot.IN_SELECT:case ot.IN_SELECT_IN_TABLE:AUe(this,e);break;case ot.TEXT:iUn(this,e);break;case ot.IN_TABLE_TEXT:M2(this,e);break;case ot.IN_TEMPLATE:CUe(this,e);break;case ot.AFTER_BODY:case ot.IN_FRAMESET:case ot.AFTER_FRAMESET:case ot.AFTER_AFTER_BODY:case ot.AFTER_AFTER_FRAMESET:tte(this,e);break;default:}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===He.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 ot.IN_HEAD:case ot.IN_HEAD_NO_SCRIPT:case ot.AFTER_HEAD:case ot.TEXT:case ot.IN_COLUMN_GROUP:case ot.IN_SELECT:case ot.IN_SELECT_IN_TABLE:case ot.IN_FRAMESET:case ot.AFTER_FRAMESET:this._insertCharacters(e);break;case ot.IN_BODY:case ot.IN_CAPTION:case ot.IN_CELL:case ot.IN_TEMPLATE:case ot.AFTER_BODY:case ot.AFTER_AFTER_BODY:case ot.AFTER_AFTER_FRAMESET:pUe(this,e);break;case ot.IN_TABLE:case ot.IN_TABLE_BODY:case ot.IN_ROW:nte(this,e);break;case ot.IN_TABLE_TEXT:SUe(this,e);break;default:}}},lte=new Set([q.CAPTION,q.COL,q.COLGROUP,q.TBODY,q.TD,q.TFOOT,q.TH,q.THEAD,q.TR])})),DUn,OUn=Oe((()=>{$0(),Kee(),DUn=new Set([vt.AREA,vt.BASE,vt.BASEFONT,vt.BGSOUND,vt.BR,vt.COL,vt.EMBED,vt.FRAME,vt.HR,vt.IMG,vt.INPUT,vt.KEYGEN,vt.LINK,vt.META,vt.PARAM,vt.SOURCE,vt.TRACK,vt.WBR])}));function FUn(e,t){return ate.parse(e,t)}function BUn(e,t,n){typeof e=="string"&&(n=t,t=e,e=null);const r=ate.getFragmentParser(e,n);return r.tokenizer.write(t,!0),r.getFragment()}var HUn=Oe((()=>{MUn(),Kee(),OUn(),P6(),hUe(),$0(),Hee(),Wze()})),MUe,zUn=Oe((()=>{MUe={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 UUn(e,t){const n=t||zUe,r=n.onerror,o=e instanceof xM?e:new xM(e),i=n.fragment?BUn:FUn,s=String(o);return IHn(i(s,{sourceCodeLocationInfo:!0,onParseError:n.onerror?a:null,scriptingEnabled:!1}),{file:o,space:n.space,verbose:n.verbose});function a(l){const c=l.code,u=VUn(c),d=n[u],f=d??!0,h=typeof f=="number"?f:f?1:0;if(h){const m=MUe[u],g=new ql(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"});o.path&&(g.file=o.path,g.name=o.path+":"+g.name),g.fatal=HUe[h],g.note=p(m.description),g.url=m.url===!1?void 0:DUe+c,r(g)}function p(m){return m.replace(FUe,g).replace(BUe,y);function g(b,v,A){const S=(A?Number.parseInt(A,10):0)*(v==="-"?-1:1);return WUn(s.charAt(l.startOffset+S))}function y(){return jUn(s.charCodeAt(l.startOffset))}}}}function VUn(e){return e.replace(OUe,GUn)}function GUn(e){return e.charAt(1).toUpperCase()}function WUn(e){return e==="`"?"` ` `":e}function jUn(e){return"0x"+e.toString(16).toUpperCase()}var DUe,OUe,FUe,BUe,HUe,zUe,qUn=Oe((()=>{Gb(),EHn(),HUn(),WSe(),USe(),zUn(),DUe="https://html.spec.whatwg.org/multipage/parsing.html#parse-error-",OUe=/-[a-z]/g,FUe=/%c(?:([-+])(\d+))?/g,BUe=/%x/g,HUe={2:!0,1:!1,0:null},zUe={}})),KUn=Oe((()=>{qUn()}));function YUn(e){const t=this,{emitParseErrors:n,...r}={...t.data("settings"),...e};t.parser=o;function o(i,s){return UUn(i,{...r,onerror:n?function(a){s.path&&(a.name=s.path+":"+a.name,a.file=s.path),s.messages.push(a)}:void 0})}}var XUn=Oe((()=>{KUn()})),JUn=Rs({default:()=>YUn},1),ZUn=Oe((()=>{XUn()})),QUn,$Un,eVn,tVn,nVn,rVn,oVn,iVn,sVn,aVn,UUe=Oe((()=>{QUn=-1,$Un=0,eVn=1,tVn=2,nVn=3,rVn=4,oVn=5,iVn=6,sVn=7,aVn=8})),cte,VUe,ute,lVn=Oe((()=>{UUe(),cte=typeof self=="object"?self:globalThis,VUe=(e,t)=>{const n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);const[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{const a=n([],o);for(const l of s)a.push(r(l));return a}case 2:{const a=n({},o);for(const[l,c]of s)a[r(l)]=r(c);return a}case 3:return n(new Date(s),o);case 4:{const{source:a,flags:l}=s;return n(new RegExp(a,l),o)}case 5:{const a=n(new Map,o);for(const[l,c]of s)a.set(r(l),r(c));return a}case 6:{const a=n(new Set,o);for(const l of s)a.add(r(l));return a}case 7:{const{name:a,message:l}=s;return n(new cte[a](l),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o);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 cte[i](s),o)};return r},ute=e=>VUe(new Map,e)(0)})),Zv,GUe,WUe,II,D2,jUe,dte,cVn=Oe((()=>{UUe(),Zv="",{toString:GUe}={},{keys:WUe}=Object,II=e=>{const t=typeof e;if(t!=="object"||!e)return[0,t];const n=GUe.call(e).slice(8,-1);switch(n){case"Array":return[1,Zv];case"Object":return[2,Zv];case"Date":return[3,Zv];case"RegExp":return[4,Zv];case"Map":return[5,Zv];case"Set":return[6,Zv];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},D2=([e,t])=>e===0&&(t==="function"||t==="symbol"),jUe=(e,t,n,r)=>{const o=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},i=s=>{if(n.has(s))return n.get(s);let[a,l]=II(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 o([-1],s)}return o([a,u],s)}case 1:{if(l){let f=s;return l==="DataView"?f=new Uint8Array(s.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(s)),o([l,[...f]],s)}const u=[],d=o([a,u],s);for(const f of s)u.push(i(f));return d}case 2:{if(l)switch(l){case"BigInt":return o([l,s.toString()],s);case"Boolean":case"Number":case"String":return o([l,s.valueOf()],s)}if(t&&"toJSON"in s)return i(s.toJSON());const u=[],d=o([a,u],s);for(const f of WUe(s))(e||!D2(II(s[f])))&&u.push([i(f),i(s[f])]);return d}case 3:return o([a,s.toISOString()],s);case 4:{const{source:u,flags:d}=s;return o([a,{source:u,flags:d}],s)}case 5:{const u=[],d=o([a,u],s);for(const[f,h]of s)(e||!(D2(II(f))||D2(II(h))))&&u.push([i(f),i(h)]);return d}case 6:{const u=[],d=o([a,u],s);for(const f of s)(e||!D2(II(f)))&&u.push(i(f));return d}}const{message:c}=s;return o([a,{name:l,message:c}],s)};return i},dte=(e,{json:t,lossy:n}={})=>{const r=[];return jUe(!(t||n),!!t,new Map,r)(e),r}})),fte,qUe=Oe((()=>{lVn(),cVn(),fte=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ute(dte(e,t)):structuredClone(e):(e,t)=>ute(dte(e,t))}));function uVn(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Vd(e[n]);return hte(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function dVn(e){return hte(t);function t(n){return n.tagName===e}}function hte(e){return t;function t(n,r,o){return!!(KUe(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function fVn(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function KUe(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var G6,Vd,hVn=Oe((()=>{G6=(function(e,t,n,r,o){const i=Vd(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 KUe(e)?i.call(o,e,n,r):!1}),Vd=(function(e){if(e==null)return fVn;if(typeof e=="string")return dVn(e);if(typeof e=="object")return uVn(e);if(typeof e=="function")return hte(e);throw new Error("Expected function, string, or array as `test`")})})),W6=Oe((()=>{hVn()})),pte,pVn=Oe((()=>{W6(),pte=Vd(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"})})),YUe=Oe((()=>{pVn()}));function XUe(e){return typeof e=="object"?e.type==="text"?JUe(e.value):!1:JUe(e)}function JUe(e){return e.replace(ZUe,"")===""}var ZUe,mVn=Oe((()=>{ZUe=/[ \t\n\f\r]/g})),QUe=Oe((()=>{mVn()})),$Ue,gVn=Oe((()=>{$Ue=["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"]})),eVe,yVn=Oe((()=>{eVe=["button","input","select","textarea"]})),tVe,bVn=Oe((()=>{tVe=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"]}));function vVn(e,t){nVe(e,{collapse:kVn((t||aVe).newlines?IVn:xVn),whitespace:"normal"})}function nVe(e,t){if("children"in e){const n={...t};return(e.type==="root"||iVe(e))&&(n.before=!0,n.after=!0),n.whitespace=CVn(e,t),AVn(e,n)}if(e.type==="text"){if(t.whitespace==="normal")return wVn(e,t);t.whitespace==="nowrap"&&(e.value=t.collapse(e.value))}return{ignore:j6(e),stripAtStart:!1,remove:!1}}function wVn(e,t){const n=t.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1};let o=0,i=n.length;return t.before&&sVe(n.charAt(0))&&o++,o!==i&&sVe(n.charAt(i-1))&&(t.after?i--:r.stripAtStart=!0),o===i?r.remove=!0:e.value=n.slice(o,i),r}function AVn(e,t){let n=t.before;const r=t.after,o=e.children;let i=o.length,s=-1;for(;++s<i;){const a=nVe(o[s],{...t,after:rVe(o,s,r),before:n});a.remove?(o.splice(s,1),s--,i--):a.ignore||(n=a.stripAtStart),oVe(o[s])&&(n=!1)}return{ignore:!1,stripAtStart:!!(n||r),remove:!1}}function rVe(e,t,n){for(;++t<e.length;){const r=e[t];let o=SVn(r);if(o===void 0&&"children"in r&&!TVn(r)&&(o=rVe(r.children,-1)),typeof o=="boolean")return o}return n}function SVn(e){if(e.type==="element"){if(oVe(e))return!1;if(iVe(e))return!0}else if(e.type==="text"){if(!XUe(e))return!1}else if(!j6(e))return!1}function oVe(e){return pte(e)||G6(e,eVe)}function iVe(e){return G6(e,$Ue)}function TVn(e){return!!(e.type==="element"&&e.properties.hidden)||j6(e)||G6(e,tVe)}function sVe(e){return e===" "||e===`
826
826
  `}function IVn(e){const t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function xVn(){return" "}function kVn(e){return t;function t(n){return String(n).replace(/[\t\n\v\f\r ]+/g,e)}}function CVn(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 aVe,j6,EVn=Oe((()=>{YUe(),W6(),QUe(),eE(),gVn(),yVn(),bVn(),aVe={},j6=Wb(["comment","doctype"])})),_Vn=Oe((()=>{EVn()}));function RVn(e){return function(t){vVn(t,e)}}var PVn=Oe((()=>{_Vn()})),NVn=Oe((()=>{PVn()}));function lVe(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 LVn(e){const t=uVe(e),n=cVe(e);if(t&&n)return{start:t,end:n}}var cVe,uVe,MVn=Oe((()=>{cVe=lVe("end"),uVe=lVe("start")})),DVn=Oe((()=>{MVn()}));function OVn(e,t){const n=t.properties||{},r=e.all(t),o={type:"link",url:e.resolve(String(n.href||"")||null),title:n.title?String(n.title):null,children:r};return e.patch(t,o),o}var FVn=Oe((()=>{}));function BVn(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)}var HVn=Oe((()=>{}));function zVn(e,t){const n={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,n),n}var UVn=Oe((()=>{}));function VVn(e,t){const n={type:"break"};return e.patch(t,n),n}var GVn=Oe((()=>{})),mte,WVn=Oe((()=>{eE(),mte=(function(e,t,n){const r=Wb(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]})})),jVn=Oe((()=>{WVn()}));function O2(e,t){const n=t||{},r="children"in e?e.children:[],o=wte(e),i=hVe(e,{whitespace:n.whitespace||"normal",breakBefore:!1,breakAfter:!1}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...fVe(e,{whitespace:i,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)s.push(...dVe(r[a],e,{whitespace:i,breakBefore:a?void 0:o,breakAfter:a<r.length-1?q6(r[a+1]):o}));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(`
827
827
  `.repeat(c)||" "),c=-1,l.push(u))}return l.join("")}function dVe(e,t,n){return e.type==="element"?qVn(e,t,n):e.type==="text"?n.whitespace==="normal"?fVe(e,n):KVn(e):[]}function qVn(e,t,n){const r=hVe(e,n),o=e.children||[];let i=-1,s=[];if(mVe(e))return s;let a,l;for(q6(e)||vte(e)&&mte(t,e,vte)?l=`
828
- `:pVe(e)?(a=2,l=2):wte(e)&&(a=1,l=1);++i<o.length;)s=s.concat(dVe(o[i],e,{whitespace:r,breakBefore:i?void 0:a,breakAfter:i<o.length-1?q6(o[i+1]):l}));return bte(e)&&mte(t,e,bte)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function fVe(e,t){const n=String(e.value),r=[],o=[];let i=0;for(;i<=n.length;){gte.lastIndex=i;const l=gte.exec(n),c=l&&"index"in l?l.index:n.length;r.push(YVn(n.slice(i,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),i===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),i=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?(o.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&o.push(a),o.push(r[s]),a=0):(s===0||s===r.length-1)&&o.push(0);return o}function KVn(e){return[String(e.value)]}function YVn(e,t,n){const r=[];let o=0,i;for(;o<e.length;){yte.lastIndex=o;const s=yte.exec(e);i=s?s.index:e.length,!o&&!i&&s&&!t&&r.push(""),o!==i&&r.push(e.slice(o,i)),o=s?i+s[0].length:i}return o!==i&&!n&&r.push(""),r.join(" ")}function hVe(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 XVn(e){return!!(e.properties||{}).hidden}function JVn(e){return e.tagName==="td"||e.tagName==="th"}function ZVn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var gte,yte,q6,bte,pVe,vte,mVe,wte,QVn=Oe((()=>{jVn(),W6(),gte=/\n/g,yte=/[\t ]+/g,q6=Vd("br"),bte=Vd(JVn),pVe=Vd("p"),vte=Vd("tr"),mVe=Vd(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",XVn,ZVn]),wte=Vd(["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"])})),F2=Oe((()=>{QVn()}));function $Vn(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 eGn=Oe((()=>{}));function K6(e,t){const n=t.children;let r=-1,o,i;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)){o=a.properties.className;break}}if(o){for(r=-1;++r<o.length;)if(String(o[r]).slice(0,9)===gVe){i=String(o[r]).slice(9);break}}const s={type:"code",lang:i||null,meta:null,value:$Vn(O2(t))};return e.patch(t,s),s}var gVe,tGn=Oe((()=>{F2(),eGn(),gVe="language-"}));function nGn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var rGn=Oe((()=>{}));function Ate(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var oGn=Oe((()=>{}));function Ste(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var yVe=Oe((()=>{}));function iGn(e,t){const n=[],r=[];let o=-1;for(;++o<t.children.length;){const a=t.children[o];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let i={definitions:[],titles:[]};for(o=-1;++o<n.length;){const a=n[o];if(a.type==="element"&&a.tagName==="dt"){const l=n[o-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(i),i={definitions:[],titles:[]}),i.titles.push(a)}else i.definitions.push(a)}r.push(i),o=-1;const s=[];for(;++o<r.length;){const a=[...bVe(e,r[o].titles),...bVe(e,r[o].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:Ste(s),children:s};return e.patch(t,a),a}}function bVe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,sGn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:Ste(r),children:r}]}function sGn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var aGn=Oe((()=>{yVe()}));function Y6(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var lGn=Oe((()=>{}));function Tte(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 Ite=Oe((()=>{}));function xI(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:Tte(e.all(t))};return e.patch(t,n),n}var cGn=Oe((()=>{Ite()}));function uGn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var dGn=Oe((()=>{}));function fGn(e,t){const n=t.properties||{},r=String(n.src||""),o=String(n.title||"");if(r&&o){const i={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:o}]};return e.patch(t,i),i}}var hGn=Oe((()=>{}));function vVe(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 pGn=Oe((()=>{}));function B2(e,t){const n={type:"inlineCode",value:O2(t)};return e.patch(t,n),n}var mGn=Oe((()=>{F2()}));function wVe(e,t){const n=[],r=[],o=t||e.properties||{},i=AVe(e),s=Math.min(Number.parseInt(String(o.size),10),0)||(o.multiple?4:1);let a=-1;for(;++a<i.length;){const u=i[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:i,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=O2(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function AVe(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(...AVe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var SVe=Oe((()=>{F2()}));function gGn(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||TVe:e.options.unchecked||IVe};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 o=[];if(r)o=[[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"&&(o=wVe(c,n))}if(o.length===0)return;if(n.type==="password"&&(o[0]=["•".repeat(o[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<o.length;){const u=e.resolve(o[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:o[c][1]||u}]};l.push(d),c!==o.length-1&&l.push({type:"text",value:", "})}return l}const i=[];let s=-1;for(;++s<o.length;)i.push(o[s][1]?o[s][1]+" ("+o[s][0]+")":o[s][0]);const a={type:"text",value:i.join(", ")};return e.patch(t,a),a}var TVe,IVe,yGn=Oe((()=>{SVe(),TVe="[x]",IVe="[ ]"}));function bGn(e,t){const n=e.type==="element"&&xVe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var xVe,vGn=Oe((()=>{xVe={}.hasOwnProperty})),wGn=Oe((()=>{vGn()}));function AGn(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(!kVe.has(String(t[n])))return!1;return!0}var kVe,SGn=Oe((()=>{kVe=new Set(["pingback","prefetch","stylesheet"])})),TGn=Oe((()=>{SGn()}));function CVe(e){return!!(e.type==="text"||EVe(e)||pte(e)||AGn(e)||_Ve(e)&&bGn(e,"itemProp"))}var EVe,_Ve,IGn=Oe((()=>{YUe(),wGn(),TGn(),W6(),EVe=Vd(["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"]),_Ve=Vd("meta")})),RVe=Oe((()=>{IGn()}));function xte(e,t){const{rest:n,checkbox:r}=NVe(t),o=r?!!r.properties.checked:null,i={type:"listItem",spread:PVe(n),checked:o,children:e.toFlow(e.all(n))};return e.patch(t,i),i}function PVe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(CVe(r))continue;if(r.tagName==="p"||n||PVe(r))return!0;n=!0}}return!1}function NVe(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}=NVe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var xGn=Oe((()=>{RVe()}));function kte(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),kGn);let o=null;n&&(o=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const i={type:"list",ordered:n,start:o,spread:Ste(r),children:r};return e.patch(t,i),i}function kGn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var CGn=Oe((()=>{yVe()}));function X6(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!DVe(n)||"children"in n&&X6(n.children))return!0}return!1}function LVe(e){return MVe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?XUe(r.value):!1})?[]:[{type:"paragraph",children:Tte(n)}]}}function EGn(e){return MVe(e.children,t,n);function t(r){const o=Cte(e);return o.children=r,[o]}function n(r){if("children"in r&&"children"in e){const o=Cte(e),i=Cte(r);return o.children=r.children,i.children.push(o),i}return{...r}}}function MVe(e,t,n){const r=_Gn(e),o=[];let i=[],s=-1;for(;++s<r.length;){const a=r[s];DVe(a)?i.push(a):(i.length>0&&(o.push(...t(i)),i=[]),o.push(n(a)))}return i.length>0&&(o.push(...t(i)),i=[]),o}function _Gn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&X6(r.children)?t.push(...EGn(r)):t.push(r)}return t}function DVe(e){const t=e.data&&e.data.hName;return t?CVe({type:"element",tagName:t,properties:{},children:[]}):nj(e)}function Cte(e){return fte({...e,children:[]})}var Ete=Oe((()=>{qUe(),RVe(),QUe(),CIe(),Ite()}));function OVe(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let o=String(n.src||""),i=-1,s=!1,a=e.all(t);if(nE({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||X6(a))return a;for(;!o&&++i<t.children.length;){const u=t.children[i];u.type==="element"&&u.tagName==="source"&&u.properties&&(o=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:_M(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(o),children:l};return e.patch(t,c),c}var RGn=Oe((()=>{RM(),GM(),Ete()}));function FVe(e,t){const n=Tte(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var PGn=Oe((()=>{Ite()}));function NGn(e,t){const n=e.options.quotes||BVe;e.qNesting++;const r=e.all(t);e.qNesting--;const o=n[e.qNesting%n.length],i=r[0],s=r[r.length-1],a=o.charAt(0),l=o.length>1?o.charAt(1):o;return i&&i.type==="text"?i.value=a+i.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var BVe,LGn=Oe((()=>{BVe=['"']}));function MGn(e,t){let n=e.all(t);(e.options.document||X6(n))&&(n=LVe(n));const r={type:"root",children:n};return e.patch(t,r),r}var DGn=Oe((()=>{Ete()}));function OGn(e,t){const n=wVe(t);let r=-1;const o=[];for(;++r<n.length;){const i=n[r];o.push(i[1]?i[1]+" ("+i[0]+")":i[0])}if(o.length>0){const i={type:"text",value:o.join(", ")};return e.patch(t,i),i}}var FGn=Oe((()=>{SVe()}));function HVe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var BGn=Oe((()=>{}));function zVe(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,o=t.properties.colSpan;if(r||o){const i=n.data||(n.data={});r&&(i.hastUtilToMdastTemporaryRowSpan=r),o&&(i.hastUtilToMdastTemporaryColSpan=o)}}return n}var HGn=Oe((()=>{}));function zGn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),UGn)};return e.patch(t,n),n}function UGn(){return{type:"tableCell",children:[]}}var VGn=Oe((()=>{}));function GGn(e,t){if(e.inTable){const c={type:"text",value:O2(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=WGn(t),o=e.toSpecificContent(e.all(t),UVe);r&&o.unshift(UVe());let i=-1;for(;++i<o.length;){const c=o[i];c.children=e.toSpecificContent(c.children,jGn)}let s=1;for(i=-1;++i<o.length;){const c=o[i].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=i-1;for(;++m<i+p;){let g=u-1;for(;++g<u+h&&o[m];){const y=[];(m!==i||g!==u)&&y.push({type:"tableCell",children:[]}),o[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(i=-1;++i<o.length;){const c=o[i].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:o};return e.patch(t,l),l}function WGn(e){const t={align:[null],headless:!0};let n=0,r=0;return nE(e,function(o){if(o.type==="element"){if(o.tagName==="table"&&e!==o)return QTe;if((o.tagName==="th"||o.tagName==="td")&&o.properties){if(!t.align[r]){const i=String(o.properties.align||"")||null;(i==="center"||i==="left"||i==="right"||i===null)&&(t.align[r]=i)}t.headless&&n<2&&o.tagName==="th"&&(t.headless=!1),r++}else o.tagName==="thead"?t.headless=!1:o.tagName==="tr"&&(n++,r=0)}}),t}function jGn(){return{type:"tableCell",children:[]}}function UVe(){return{type:"tableRow",children:[]}}var qGn=Oe((()=>{F2(),GM()}));function KGn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var YGn=Oe((()=>{}));function XGn(e,t){const n={type:"text",value:O2(t)};return e.patch(t,n),n}var JGn=Oe((()=>{F2()}));function ZGn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var QGn=Oe((()=>{}));function vo(e,t){return e.all(t)}function pa(e,t){return e.toFlow(e.all(t))}function wo(){}var VVe,GVe,$Gn=Oe((()=>{FVn(),HVn(),UVn(),GVn(),tGn(),rGn(),oGn(),aGn(),lGn(),cGn(),dGn(),hGn(),pGn(),mGn(),yGn(),xGn(),CGn(),RGn(),PGn(),LGn(),DGn(),FGn(),BGn(),HGn(),VGn(),qGn(),YGn(),JGn(),QGn(),VVe={comment:nGn,doctype:wo,root:MGn,text:KGn},GVe={applet:wo,area:wo,basefont:wo,bgsound:wo,caption:wo,col:wo,colgroup:wo,command:wo,content:wo,datalist:wo,dialog:wo,element:wo,embed:wo,frame:wo,frameset:wo,isindex:wo,keygen:wo,link:wo,math:wo,menu:wo,menuitem:wo,meta:wo,nextid:wo,noembed:wo,noframes:wo,optgroup:wo,option:wo,param:wo,script:wo,shadow:wo,source:wo,spacer:wo,style:wo,svg:wo,template:wo,title:wo,track:wo,abbr:vo,acronym:vo,bdi:vo,bdo:vo,big:vo,blink:vo,button:vo,canvas:vo,cite:vo,data:vo,details:vo,dfn:vo,font:vo,ins:vo,label:vo,map:vo,marquee:vo,meter:vo,nobr:vo,noscript:vo,object:vo,output:vo,progress:vo,rb:vo,rbc:vo,rp:vo,rt:vo,rtc:vo,ruby:vo,slot:vo,small:vo,span:vo,sup:vo,sub:vo,tbody:vo,tfoot:vo,thead:vo,time:vo,address:pa,article:pa,aside:pa,body:pa,center:pa,div:pa,fieldset:pa,figcaption:pa,figure:pa,form:pa,footer:pa,header:pa,hgroup:pa,html:pa,legend:pa,main:pa,multicol:pa,nav:pa,picture:pa,section:pa,a:OVn,audio:OVe,b:HVe,base:BVn,blockquote:zVn,br:VVn,code:B2,dir:kte,dl:iGn,dt:xte,dd:xte,del:Ate,em:Y6,h1:xI,h2:xI,h3:xI,h4:xI,h5:xI,h6:xI,hr:uGn,i:Y6,iframe:fGn,img:vVe,image:vVe,input:gGn,kbd:B2,li:xte,listing:K6,mark:Y6,ol:kte,p:FVe,plaintext:K6,pre:K6,q:NGn,s:Ate,samp:B2,select:OGn,strike:Ate,strong:HVe,summary:FVe,table:GGn,td:zVe,textarea:XGn,th:zVe,tr:zGn,tt:B2,u:Y6,ul:kte,var:B2,video:OVe,wbr:ZGn,xmp:K6}}));function eWn(e){return{all:tWn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...GVe,...e.handlers},inTable:!1,nodeHandlers:{...VVe,...e.nodeHandlers},one:nWn,options:e,patch:rWn,qNesting:0,resolve:oWn,toFlow:iWn,toSpecificContent:sWn}}function tWn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const o=t[r],i=this.one(o,e);Array.isArray(i)?n.push(...i):i&&n.push(i)}return n}function nWn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(_te.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(_te.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 rWn(e,t){e.position&&(t.position=LVn(e))}function oWn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function iWn(e){return LVe(e)}function sWn(e,t){const n=t(),r=[];let o=[],i=-1;for(;++i<e.length;){const a=e[i];if(s(a))o.length>0&&(a.children.unshift(...o),o=[]),r.push(a);else{const l=a;o.push(l)}}if(o.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...o),o=[]}return r;function s(a){return a.type===n.type}}var _te,aWn=Oe((()=>{DVn(),$Gn(),Ete(),_te={}.hasOwnProperty}));function WVe(e,t){const n=fte(e),r=t||jVe,o=RVn({newlines:r.newlines===!0}),i=eWn(r);let s;o(n),nE(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!i.elementById.has(c)&&i.elementById.set(c,l)}});const a=i.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},nE(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 jVe,lWn=Oe((()=>{qUe(),NVn(),GM(),aWn(),jVe={}})),cWn=Oe((()=>{lWn()}));function uWn(e,t){return e&&"run"in e?async function(n,r){const o=WVe(n,{...Rte,...t});await e.run(o,r)}:function(n){return WVe(n,{...Rte,...e})}}var Rte,dWn=Oe((()=>{cWn(),Rte={document:!0}})),fWn=Rs({default:()=>uWn},1),hWn=Oe((()=>{dWn()}));function pWn(e){const t=e.modules?.trackChanges,n=e.trackedChanges;if(!t&&!n)return e;const r={...n??{},...t??{}};return{...e,trackedChanges:r}}var mWn="1.44.2",Pte=96,gWn=50,yWn=20,bWn=new Set([Ki,ui,vs]),J6=e=>!!(e?.type?.name&&bWn.has(e.type.name)),qVe=e=>{if(!J6(e))return null;const t=typeof e.attrs?.id=="string"?e.attrs.id:"";return`${e.type?.name??""}:${t}`},H2=e=>{const t=new Set;if(!e)return t;for(const n of e.marks??[]){const r=qVe(n);r&&t.add(r)}return t},KVe=e=>!!(e.isInline&&e.marks?.some(J6)),Z6=(e,t,n)=>{if(t>=n)return!1;const r=0,o=e.content.size,i=Math.max(r,Math.min(o,t)),s=Math.max(r,Math.min(o,n));if(i>=s)return!1;let a=!1;return e.nodesBetween(i,s,l=>{if(KVe(l))return a=!0,!1}),a},YVe=(e,t,n)=>{if(t>=n)return!1;const r=0,o=e.content.size,i=Math.max(r,Math.min(o,t)),s=Math.max(r,Math.min(o,n));if(i>=s)return!1;let a=!1,l=!1,c=!1;return e.nodesBetween(i,s,(u,d)=>{if(!u.isInline||!u.isLeaf||d+u.nodeSize<=i||d>=s)return;const f=(u.marks??[]).filter(J6);if(!f.length){l=!0;return}a=!0,f.every(h=>h.type?.name==="trackInsert")||(c=!0)}),a&&!l&&!c},vWn=(e,t,n)=>{if(!YVe(e,t,n))return null;const r=[],o=new Set;return e.nodesBetween(t,n,(i,s)=>{if(!i.isInline||!i.isLeaf||s+i.nodeSize<=t||s>=n)return;const a=(i.marks??[]).find(c=>c.type?.name===Ki),l=typeof a?.attrs?.id=="string"?a.attrs.id:null;!a||!l||o.has(l)||(o.add(l),r.push(a))}),r.length===1?r[0]:null},XVe=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=r.nodeBefore?.marks?.find(l=>l.type?.name==="trackInsert")??null,i=r.nodeAfter?.marks?.find(l=>l.type?.name==="trackInsert")??null,s=typeof o?.attrs?.id=="string"?o.attrs.id:null,a=typeof i?.attrs?.id=="string"?i.attrs.id:null;return!o||!i||!s||s!==a?null:o},wWn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof qr))return null;const r=(t.docs??[])[0]??e.doc,o=n.from!==n.to&&n.slice.content.size===0?vWn(r,n.from,n.to):n.from===n.to&&n.slice.content.size>0?XVe(r,n.from):null;return o?{insertedMark:o,deletionMark:null,formatMark:null,deletionNodes:[],step:n,emitCommentEvent:!0}:null},JVe=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=H2(r.nodeBefore);if(!o.size)return!1;const i=H2(r.nodeAfter);for(const s of o)if(i.has(s))return!0;return!1},AWn=e=>{let t=!1;return e.descendants?.(n=>{if(KVe(n))return t=!0,!1}),t},SWn=(e,t,n)=>{const r=XVe(e,t);if(!r)return!1;if(!n.content)return!0;const o=typeof r.attrs?.id=="string"?r.attrs.id:null;if(!o)return!1;let i=!0;return n.content.descendants?.(s=>{if(!i||!s.isInline)return i?void 0:!1;const a=(s.marks??[]).filter(J6);if(a.length&&!a.every(l=>l.type?.name==="trackInsert"&&l.attrs?.id===o))return i=!1,!1}),i},TWn=(e,t,n)=>{if(!n.content||!AWn(n.content))return!1;const r=Math.max(0,Math.min(e.content.size,t)),o=e.resolve(r);return H2(o.nodeBefore).size>0||H2(o.nodeAfter).size>0},IWn=(e,t)=>e instanceof qr?e.from!==e.to&&e.slice.content.size===0&&YVe(t,e.from,e.to)||e.from===e.to&&e.slice.content.size>0&&SWn(t,e.from,e.slice)||e.from===e.to&&e.slice.content.size>0&&JVe(t,e.from)?!1:Z6(t,e.from,e.to)?!0:e.from===e.to&&e.slice.content.size>0?JVe(t,e.from)||TWn(t,e.from,e.slice):!1:e instanceof wh||e instanceof mc?Z6(t,e.from,e.to):e instanceof gc?Z6(t,e.from,e.to)||Z6(t,e.gapFrom,e.gapTo):!1,xWn=(e,t)=>{if(!t.docChanged||!t.steps.length)return!1;const n=t.docs??[];return t.steps.some((r,o)=>IWn(r,n[o]??e.doc))},kWn=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=H2(r.nodeAfter);if(!o.size)return[];const i=[];for(const s of r.nodeBefore?.marks??[]){const a=qVe(s);a&&o.has(a)&&i.push(s)}return i},CWn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof qr)||n.from!==n.to||n.slice.content.size===0)return null;const r=kWn((t.docs??[])[0]??e.doc,n.from);return r.length?{from:n.from,to:n.from+n.slice.size,marks:r}:null},EWn=800,ZVe=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 _Wn(e){const t=(e.attrs?.colwidth??[]).reduce((i,s)=>i+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,o=n?.right??0;return Math.max(t-r-o,0)}var Um=class cg extends Y_{#e;#t=null;#o=!1;#n="initialized";#r=null;#i=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#s=null;#c=!1;#u=null;#d=0;#f=null;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=pWn(t),r=GT(),o=!!n.isHeadless,i=!!(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&&i&&!o)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!o&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#f=n.fragment??null,this.#L(n),this.setOptions(n),this.#t=n.renderer??(r?new r8e:null),this.#S();const{setHighContrastMode:l}=Qh();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#v(),this.#n="initialized";else{const c={docx:()=>this.#E(),text:()=>this.#R(),html:()=>this.#R(),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)}#p(t){this.#t?.initContainerElement?.(t)}#a(){return GT()&&!this.options.isHeadless}#b(){return this.options.document??this.options.mockDocument??(GT()?document:null)}#l(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#T()}#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.#s=new Clt({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#T(){this.getDocumentIdentifier().then(t=>{if(!(!this.#s||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()??null;this.#s.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new cBe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#w(t,n,r,o){this.#n=t;try{const i=await o();return this.#n=n,i}catch(i){throw this.#n=r,i}}#v(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?O5():Lv()),this.#O(),this.#F(),this.#te(),this.#C()}#C(){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.#D.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.#Ae.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.options.onFontsChanged&&this.on("fonts-changed",this.options.onFontsChanged),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}#x(){this.on("pointerDown",()=>{this.#d=Date.now()})}async#h(t,n){try{const r=n?.mode??this.options.mode??"docx",o=n?.isNewFile,i=Object.prototype.hasOwnProperty.call(n??{},"fragment"),s={...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,fragment:i?n?.fragment??null:this.options.fragment??this.#f},a=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const c=ez().readFileSync(t),[u,d,f,h,p]=await cg.loadXmlData(c,!0,a);s.content=u,s.mediaFiles=f,s.fonts=h,s.fileSource=p??c,s.isNewFile=o??!1,this.#i=p?null:t}else{const c=await fetch(t);if(!c.ok)throw console.debug("[SuperDoc] Fetch failed:",c.status,c.statusText),new Error(`Fetch failed: ${c.status} ${c.statusText}`);const u=await c.blob(),[d,f,h,p,m]=await cg.loadXmlData(u,!1,a);s.content=d,s.mediaFiles=h,s.fonts=p,s.fileSource=m??u,s.isNewFile=o??!1,this.#i=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const c=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),u=typeof Blob<"u"&&t instanceof Blob,d=t instanceof ArrayBuffer,f=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(c||u||d||f){const[h,p,m,g,y]=await cg.loadXmlData(t,c,a);s.content=h,s.mediaFiles=m,s.fonts=g,s.fileSource=y??t,s.isNewFile=o??!1,this.#i=null}else{const[h,p,m,g,y]=await cg.loadXmlData(t,!1,a);s.content=h,s.mediaFiles=m,s.fonts=g,s.fileSource=y??t,s.isNewFile=o??!1,this.#i=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:c,mediaFiles:u,fonts:d,fileSource:f}=await this.#X();s.content=c,s.mediaFiles={...u,...n?.mediaFiles??{}},s.fonts={...d,...n?.fonts??{}},s.fileSource=f,s.isNewFile=o??!0,this.#i=null}else s.content=n?.content??[],s.mediaFiles=n?.mediaFiles??{},s.fonts=n?.fonts??{},s.fileSource=null,s.isNewFile=o??!n?.content,this.#i=null;this.setOptions(s),this.#V(),T6(this),this.#I(),this.#W();const l=this.#a();if(l&&(this.#p(this.options),this.#le()),this.#$({includePlugins:!l}),!l){const c=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#z(c)}l&&(this.mount(this.options.element),this.#pe()),l||this.#l(),l&&(this.initDefaultStyles(),this.#H()),(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.#k(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#ee(),l&&(this.#re(),this.#A())}catch(r){if(r instanceof ps)throw console.debug("[SuperDoc] Document load error:",r.message),r;const o=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",o.message),new fBe(`Failed to load document: ${o.message}`,o)}}#m(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=gm(this);t&&(t.state={...Lpe},t.initialized=!1,t.editableBaseline=null),this.#i=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this.options.fragment=null,this._state=void 0,this.#u=null,this.#d=0}#I(){const t=gm(this);t&&(t.state=ev(this.converter?Rf(this.converter):null),t.initialized=!0)}#k(){const t=gm(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#E(){this.#O(),this.#F(),this.#te(),this.#V(),T6(this),this.#I(),this.#W(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#a();if(this.#$({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#z(n)}t&&(this.#p(this.options),this.#le(),this.mount(this.options.element),this.#pe()),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.#D.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.#Ae.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.options.onFontsChanged&&this.on("fonts-changed",this.options.onFontsChanged),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#H()),(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.#k(),!this.options.ydoc&&!this.options.isChildEditor&&this.#ee(),t&&(this.#re(),this.#A())}#R(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Lv()),this.#O(),this.#F(),this.#te(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#a();this.#$({includePlugins:!t}),t&&(this.#p(this.options),this.mount(this.options.element),this.#pe()),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.#D.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.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l()}mount(t){this.#de(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#T()}unmount(){this.view?.dom?.removeEventListener("compositionend",this.#ie),this.view?.dom?.removeEventListener("blur",this.#ie),this.#ce=null,this.#me=[],this.#ne=void 0,this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#D({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#L(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.#i}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.#y("ready","saving"),this.#r||(this.#r=Owt(V7n(this))),this.#r}#M(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=QHe(this);return WPe(this,n,t??this.#M())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=$He(this);return WPe(this,n,t??this.#M())}resolveSelectionHandle(t){this.#y("ready","saving");const n=ctn(t);return n?xee(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),utn(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),q7n(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),K7n(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#o||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 o=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 i=uxe(this.state);i&&this.view?.dispatch(this.state.tr.setSelection(i)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),o&&o.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),o&&o.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),o&&o.classList.remove("view-mode"));FS(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,o=Math.max(0,Math.min(t,r));try{const{node:i}=this.view.domAtPos(o);return i&&i.nodeType===1?i:i&&i.nodeType===3?i.parentElement:i?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,o=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(o)){const i=this.presentationEditor.hitTest(r,o);if(i)return{pos:i.pos,inside:i.pos}}}return this.view?this.view.posAtCoords(t):null}#A(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await Vnn(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||cv(this.options.collaborationProvider,()=>{this.#G()})}replaceContent(t){this.setOptions({content:t}),this.#V(),this.initDefaultStyles(),this.#V(),T6(this),this.#W();const n=this.#ue(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#z(r)}#_(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},o=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(o.size===0)return;const i=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of o){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;i(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#z(s)}#G(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#ue(),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.#z(r);const o=this.options.ydoc;o&&o.getMap("meta").set("bodySectPr",n),this.#_(t.attrs??{}),setTimeout(()=>{this.#ee()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},o=Object.getOwnPropertyDescriptors(n);for(const[i,s]of Object.entries(o))s.enumerable||Object.prototype.hasOwnProperty.call(t,i)||Object.defineProperty(r,i,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)}#oe(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.#oe(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,o=this.options.shouldLoadComments,i=this.options.collaborationIsReady,s=this._state,a=()=>{HNe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=o,this.options.collaborationIsReady=i,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}}#O(){const t=["extension","node","mark"],n=[mEn,sEn,gEn,lEn,yEn,bEn],r=this.options.externalExtensions||[],o=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>ZVe(s)),i=r.map(s=>ZVe(s));this.extensionService=wEn.create(o,i,this)}#F(){this.#e=tAe.create({editor:this})}#V(){this.options.converter?this.converter=this.options.converter:this.converter=new Bu({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#X(){const t=await Wfe(E2n),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let o;if(n)o=Buffer.from(r);else if(typeof Blob<"u")o=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[i,s,a,l]=await cg.loadXmlData(o,n);return{content:i,mediaFiles:a,fonts:l,fileSource:o}}async#J(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#X();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#W(){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())}#le(){this.#t?.initFonts?.(this)}async#H(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#Z(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#Z(t){return t.filter(n=>{const r=E_n(n),o=this.fontsImported.includes(n);return!r&&!o})}static async loadXmlData(t,n=!1,r){if(!t)return;const o=new aQ;return[await o.getDocxData(t,n,{password:r?.password}),o.media,o.mediaFiles,o.fonts,o.decryptedFileData]}static getDocumentVersion(t){return Bu.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=Bu.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return Bu.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),cg.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(o=>!!o?.config?.excludeFromSummaryJSON).map(o=>o.name)),r=t2n(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(o=>!n.has(o.name)),marks:r.marks.filter(o=>!n.has(o.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),o=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(o.cause=n),o}}#te(){this.schema=this.extensionService.schema}#ue(){let t;try{const{mode:n,content:r,fragment:o,loadFromSchema:i}=this.options,s=this.#b(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?i&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#Le(t)):(t=sve(this.converter,this.schema,this),t=this.#Le(t),this.options.markdown?t=bj(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=qC(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)),o&&(GY(o),t=lLt(o,this.schema))):(n==="text"||n==="html")&&(i&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=qC(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.#ue(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let o=k1.create(r);t&&(o=o.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=o,this._state=o}#pe(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#de(t){if(this._state||this.#$(),!this.#t){if(!GT())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new r8e}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#z.bind(this),state:this.state,handleClick:this.#Ne.bind(this)}),this.view?.dom?.addEventListener("compositionend",this.#ie),this.view?.dom?.addEventListener("blur",this.#ie),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){const t=this.converter?.pageStyles,n=this.options.parentEditor?.converter?.pageStyles,r=t?.pageSize,o=r?.width&&r?.height?t:n??t;if(!o)return{};let i=0;const{$head:s}=this.state.selection;for(let b=s.depth;b>0;b--){const v=s.node(b);if(v.type.name==="tableCell"||v.type.name==="tableHeader"){i=_Wn(v);break}}if(this.isWebLayout())return i>0?{width:i,height:1/0}:{};const{pageSize:a={},pageMargins:l={}}=o,{width:c,height:u}=a;if(!c||!u)return{};const d=b=>(l?.[b]??0)*Pte,f=d("top"),h=d("bottom"),p=d("left"),m=d("right"),g=u*Pte-f-h-gWn,y=c*Pte-p-m-yWn;return i>0?{width:i,height:g}:{width:y,height:g}}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)}#Ae({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#mt(),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.#z(r),this.options.isNewFile||this.#ee()}#ee(){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(Eo,{type:"force"});this.#z(r)},50)}#ce=null;#me=[];#ne=void 0;#Pe(t,n){if(!t.steps.length)return!1;const r=this.#ce;for(let o=0;o<t.steps.length;o+=1){const i=t.steps[o];if(!(i instanceof qr))return!1;if(i.from<i.to&&(!r||i.from<r.from||i.to>r.to)){const s=t.docs[o]??n.doc;if(!this.#Ie(i,s))return!1}}return!0}#Ie(t,n){if(t.slice.size===0)return!1;let r=!1,o=!1;return n.nodesBetween(t.from,t.to,i=>o?!1:i.type.name.includes("table")||i.isLeaf&&!i.isText?(o=!0,!1):(i.isText&&i.text&&(r=!0),!0)),r&&!o}#K(t){const n=[],r=this.#ce;return t.steps.forEach((o,i)=>{if(!(o instanceof qr)||o.from>=o.to||r&&o.from>=r.from&&o.to<=r.to)return;const s=t.docs[i]??this.state.doc;if(!this.#Ie(o,s))return;const a=t.mapping.slice(i+1);n.push({pos:a.map(o.from+o.slice.size,1),slice:s.slice(o.from,o.to)})}),n}#Se(t){const n=this.#ce;return!n||!t.steps.length?!1:t.steps.every(r=>r instanceof qr&&r.from<r.to&&r.from>=n.from&&r.to<=n.to)}#Te(t,n){if(!this.#ce&&!n)return;let r=this.#ce;for(const o of t){if(r){const i=o.mapping.map(r.from,-1),s=o.mapping.map(r.to,1);r=i<s?{from:i,to:s}:null}o===n&&o.steps.forEach((i,s)=>{if(!(i instanceof qr)||i.slice.size===0)return;const a=o.mapping.slice(s+1),l=a.map(i.from,-1),c=a.map(i.from+i.slice.size,1);r=r?{from:Math.min(r.from,l),to:Math.max(r.to,c)}:{from:l,to:c}})}this.#ce=r}#Oe(t){this.#me.length&&(this.#me=this.#xe(this.#me,t))}#xe(t,n){return!t.length||!n.length?t:t.map(r=>{let o=r.pos;for(const i of n)o=i.mapping.map(o,-1);return{...r,pos:o}})}#be(){const t=this.#ce,n=this.#me,r=this.#ne;if(this.#ce=null,this.#me=[],this.#ne=void 0,!t||this.isDestroyed||!this.view)return;const o=this.state;if(!ho.getState(o)?.isTrackChangesActive)return;const i=Math.max(0,Math.min(t.from,o.doc.content.size)),s=Math.max(i,Math.min(t.to,o.doc.content.size));if(i>=s)return;const a=o.schema.marks[Ki];if(!a)return;let l=!0;if(o.doc.nodesBetween(i,s,g=>(g.isText&&!a.isInSet(g.marks)&&(l=!1),!g.isText)),l&&!n.length)return;const c=o.tr,u=Math.floor(Date.now()/6e5)*6e5,d=new Date(u).toISOString(),f=this.options.user??{};let h=l?null:e5({tr:c,from:i,to:s,user:f,date:d});const p=h&&n.length&&this.options.trackedChanges?.replacements!=="independent"?h.attrs.id:"";if(h&&p){const g=h.type.create({...h.attrs,changeType:Kn.Replacement,replacementGroupId:p,replacementSideId:`${p}#inserted`});c.removeMark(i,s,h),c.addMark(i,s,g),h=g}let m=null;n.forEach(g=>{const y=c.mapping.map(g.pos,-1),b=c.doc.content.size;c.replace(y,y,g.slice);const v=y+(c.doc.content.size-b);if(v<=y)return;const A=MJ({tr:c,from:y,to:v,user:f,date:d,id:p||void 0}),S=p?A.deletionMark.type.create({...A.deletionMark.attrs,changeType:Kn.Replacement,replacementGroupId:p,replacementSideId:`${p}#deleted`}):A.deletionMark;S!==A.deletionMark&&(c.removeMark(y,v,A.deletionMark),c.addMark(y,v,S)),m={deletionMark:S,deletionNodes:A.nodes}}),c.setMeta("skipTrackChanges",!0),c.setMeta("compositionTrackingFlush",!0),r!==void 0&&c.setMeta("composition",r),c.setMeta(ho,{...h?{insertedMark:h}:{},...m??{}}),this.view.dispatch(c)}#ie=t=>{const n=t?.type==="blur";queueMicrotask(()=>{if(this.#ce&&!(this.view?.composing&&!n)){try{this.view?.domObserver?.flush?.()}catch{}this.view?.composing&&!n||this.#be()}})};#z(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),o=r(),i=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=ho.getState(i)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=wWn(i,a),y=xWn(i,a);y&&m&&a.setMeta("protectTrackedReviewState",!0);const b=(p||c)&&!m,v=b||y,A=v?null:CWn(i,a);if(!v&&!A&&g&&!a.getMeta(ho)&&a.setMeta(ho,g),A){for(const P of A.marks)a.removeMark(A.from,A.to,P);const k=i.schema.marks;for(const P of[Ki,ui,vs]){const E=k[P];E&&a.removeStoredMark(E)}}if(v&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");const S=b&&(C_(a)||this.view?.composing===!0&&this.#Se(a))&&this.#Pe(a,i),w=S?this.#K(a):[];if(S){const k=a.getMeta("composition");k!==void 0&&(this.#ne=k)}const T=this.options.user??{};a=v&&!S?D3e({tr:a,state:i,user:T,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:x,transactions:C}=i.applyTransaction(a);s=x,this.#Te(C,S?a:null),this.#Oe(C),w.length&&this.#me.push(...this.#xe(w,C.slice(1))),S&&this.view?.composing!==!0&&this.#ie(),l=C.find(k=>k.docChanged)??a}catch(p){if(c)throw p;s=i.apply(a),console.log(p)}const u=!i.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const d=r();this.emit("transaction",{editor:this,transaction:a,duration:d-o}),u&&this.emit("selectionUpdate",{editor:this,transaction:a}),this.#B({transaction:a,nextState:s,selectionHasChanged:u});const f=a.getMeta("focus");f&&this.emit("focus",{editor:this,event:f.event,transaction:a});const h=a.getMeta("blur");h&&this.emit("blur",{editor:this,event:h.event,transaction:a}),l.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:l}))}#B({transaction:t,nextState:n,selectionHasChanged:r}){const o=t.getMeta("uiEvent"),i=Date.now()-this.#d<=EWn,s=o==="click"||i?"pointer":"keyboard",a=n.selection?this.#_e(n.selection):[],l=a[0]??null;if(r){const c=this.#u;c?.id!==l?.id&&(l?this.emit("contentControlFocus",{active:l,previous:c,activePath:a,source:s}):c&&this.emit("contentControlBlur",{active:null,previous:c,activePath:[],source:s}),this.#u=l)}o==="click"&&l&&this.emit("contentControlClick",{target:l,source:"pointer"})}#_e(t){const n=[],r=new Set,o=t instanceof gn?t.node:null;if(o&&(o.type?.name==="structuredContent"||o.type?.name==="structuredContentBlock")){const s=this.#ke(o);s&&(n.push(s),r.add(s.id))}const i=t.$anchor;if(i&&typeof i.depth=="number"&&typeof i.node=="function")for(let s=i.depth;s>=0;s-=1){const a=i.node(s);if(!a)continue;const l=a?.type?.name;if(l!=="structuredContent"&&l!=="structuredContentBlock")continue;const c=this.#ke(a);c&&(r.has(c.id)||(n.push(c),r.add(c.id)))}return n}#ke(t){const n=t.attrs,r=n?.id;if(typeof r!="string"||r.length===0)return null;const o=t.type.name==="structuredContent"?"inline":"block";return{id:r,tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,controlType:typeof n.controlType=="string"?n.controlType:"unknown",scope:o}}dispatch(t){this.#z(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 dn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return lve(this.state,r,o)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,o=this.converter;o&&o.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=o.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.#b();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"),o=dh.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(o);let i=r.innerHTML;return t&&(i=hSe(i,n)),i}async getMarkdown(){const t=this.#b();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,o=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:i},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(NW(),lDt)),Promise.resolve().then(()=>(ZUn(),JUn)),Promise.resolve().then(()=>(hWn(),fWn)),Promise.resolve().then(()=>(T8e(),gPn)),Promise.resolve().then(()=>(hj(),Q6t))]),u=this.getHTML(),d=i().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{o&&(o.document===void 0?delete n.document:n.document=o.document,o.window===void 0?delete n.window:n.window=o.window,o.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",o.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return M_n(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&&!gv()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#z(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#Ne(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return C_n(t,n)}#Le(t){const n=k1.create({schema:this.schema,doc:t}),{tr:r,doc:o}=n;return ton(o,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:__n(this)}#Re(t=[]){const n=this.state.doc,r=new mV(n);return eon(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#Re()}#Je(){if(!this.converter)return;const t=uUt(),n=(l,c)=>{const u=l?.sourceId;pE(u)&&t.reserve(c,u)},r=(l,c)=>{l&&l.descendants(u=>{if(Array.isArray(u.marks))for(const d of u.marks){const f=d.type.name;f!=="trackInsert"&&f!=="trackDelete"&&f!=="trackFormat"||n(d.attrs,c)}})},o=(l,c)=>{if(!l||typeof l!="object")return;const u=l;if(Array.isArray(u.marks))for(const d of u.marks)d.type!=="trackInsert"&&d.type!=="trackDelete"&&d.type!=="trackFormat"||n(d.attrs,c);if(Array.isArray(u.content))for(const d of u.content)o(d,c)},i=(l,c)=>{if(typeof l!="string"||!l)return c;const u=l.replace(/^\/+/,"");return u.startsWith("word/")?u:`word/${u}`},s=this.converter.convertedXml?.["word/_rels/document.xml.rels"]?.elements?.find(l=>l.name==="Relationships"),a=(l,c)=>{const u=s?.elements?.find(d=>d.attributes?.Id===l)?.attributes?.Target;return i(u,c)};r(this.state?.doc,"word/document.xml");for(const[l,c]of Object.entries(this.converter.headers||{})){const u=a(l,"word/header1.xml"),d=this.converter.headerEditors?.find(f=>f.id===l);r(d?.editor?.state?.doc,u),o(c,u)}for(const[l,c]of Object.entries(this.converter.footers||{})){const u=a(l,"word/footer1.xml"),d=this.converter.footerEditors?.find(f=>f.id===l);r(d?.editor?.state?.doc,u),o(c,u)}o(this.converter.footnotes,"word/footnotes.xml"),o(this.converter.endnotes,"word/endnotes.xml"),this.converter.wordIdAllocator=t}#fe(){if(!this.converter)return;const t=this.converter.wordIdAllocator?.getSourceIdMap?.()??{};if(Object.keys(t).length===0&&!this.#Ce())return;const n=JSON.stringify({version:1,parts:t});Bu.setStoredCustomProperty(this.converter.convertedXml,lCe,n,!1)}#Ce(){return!!this.converter?.convertedXml?.["docProps/custom.xml"]?.elements?.find(n=>{const r=n?.name;return r==="Properties"||r?.endsWith(":Properties")})?.elements?.some(n=>{const r=n?.name;return(r==="property"||r?.endsWith(":property"))&&n.attributes?.name==="SuperdocTrackedChangeSourceIds"})}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:o=!1,comments:i,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{I$t(lv(this));const c=(i??this.converter.comments??[]).map(X=>{const ae=Array.isArray(X.elements)&&X.elements.length?X.elements:void 0,he=X.commentJSON??ae??(typeof X.commentText=="string"?Z5(X.commentText):void 0);return{...X,commentJSON:he}}),u=this.#Re(c);this.#Je();const d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#at(),o||r)return d;this.#fe();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=REe(this.converter.convertedXml["word/footnotes.xml"],{converter:this.converter,documentXml:this.converter.convertedXml["word/document.xml"],type:"footnote"}),b=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,v=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],A=v?.elements?.[0]?this.converter.schemaToXml(v.elements[0]):null,S=REe(this.converter.convertedXml["word/endnotes.xml"],{converter:this.converter,documentXml:this.converter.convertedXml["word/document.xml"],type:"endnote"}),w=S?.elements?.[0]?this.converter.schemaToXml(S.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],x=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,C=this.converter.convertedXml["word/_rels/settings.xml.rels"],k=C?.elements?.[0]?this.converter.schemaToXml(C.elements[0]):null,P=this.converter.addedMedia,E={};Object.entries(this.converter.convertedXml).forEach(([X,ae])=>{if(X.includes("header")||X.includes("footer")){const he=ae,Ae=this.converter.schemaToXml(he.elements?.[0]);E[X]=String(Ae.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,M=this.converter.convertedXml["docProps/app.xml"],O=M?.elements?.[0]?this.converter.schemaToXml(M.elements[0]):null,H=this.converter.convertedXml["docProps/core.xml"],W=H?.elements?.[0]?this.converter.schemaToXml(H.elements[0]):null,G={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),...R?{"word/numbering.xml":String(R)}:{},"word/styles.xml":String(h),...E,...O?{"docProps/app.xml":String(O)}:{},...W?{"docProps/core.xml":String(W)}:{}};if(p){let X=String(m);k?G["word/_rels/settings.xml.rels"]=String(k):/<\w+:attachedTemplate\b/i.test(X)&&(X=X.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),G["word/settings.xml"]=X}b&&(G["word/footnotes.xml"]=String(b)),A&&(G["word/_rels/footnotes.xml.rels"]=String(A)),w&&(G["word/endnotes.xml"]=String(w)),x&&(G["word/_rels/endnotes.xml.rels"]=String(x));const U=uq.map(X=>`word/${X}`);for(const X of U){const ae=this.converter.convertedXml[X];ae?.elements?.[0]?G[X]=String(this.converter.schemaToXml(ae.elements[0])):G[X]=null}const F=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const X of F){const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}if(t){const X=m9n(this,this.converter.convertedXml,{finalDoc:!0});for(const[ae,he]of Object.entries(X))G[ae]=he}for(const X of Object.keys(this.converter.convertedXml)){if(!X.startsWith("customXml/")||!X.endsWith(".xml")&&!X.endsWith(".rels")||Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}const ne=Object.keys(this.converter.convertedXml).filter(X=>/^word\/theme\/[^/]+\.xml$/.test(X)||X==="word/fontTable.xml"||X==="word/webSettings.xml");for(const X of ne){if(Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}for(const X of["[Content_Types].xml","word/_rels/document.xml.rels"]){if(Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}const Y=this.converter.removedCustomXmlPaths;if(Y instanceof Set)for(const X of Y)G[X]=null;const ve=new aQ;if(s){G["[Content_Types].xml"]=await ve.updateContentTypes({files:this.options.content},P,!0,G,this.options.fonts);const X=this.options.content,{contentTypesXml:ae,relsXml:he}=IBe({baseFiles:Array.isArray(X)||X&&typeof X=="object"?X:null,updatedDocs:G});return G["[Content_Types].xml"]=ae,G["_rels/.rels"]=he,G}const Z=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#J():this.options.content;return await ve.updateZip({docx:Z,updatedDocs:G,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));throw this.emit("exception",{error:u,editor:this}),console.error(u),u}}#Ze(){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.#y("initialized","closed"),await this.#w("documentLoading","ready","closed",async()=>{await this.#h(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#i})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:o,markdown:i,json:s,fragment:a,isCommentsEnabled:l,suppressDefaultDocxStyles:c,documentMode:u,content:d,mediaFiles:f,fonts:h,isNewFile:p,password:m,...g}=r,y={mode:r.mode,html:o,markdown:i,json:s,fragment:a,isCommentsEnabled:l,suppressDefaultDocxStyles:c,documentMode:u,content:d,mediaFiles:f,fonts:h,isNewFile:p,password:m},b=new cg({...g,deferDocumentLoad:!0});return await b.open(t,y),b}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#m(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#i)throw new uBe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#w("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#P(this.#i,n)})}async saveTo(t,n){this.#y("ready"),await this.#w("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#P(t,r),this.#i=t})}async exportDocument(t){return this.#y("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#P(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,o=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||o)try{const i=ez(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());i.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const i=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await i.write(n),await i.close();return}throw new dBe("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.#o=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#Ze(),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 o of r)o?.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=mBe(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",mWn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=mBe(t)||[],r=this.state.plugins.find(i=>this.#oe(i).startsWith("y-sync"));if(!r)return this.options.ydoc;let o=!1;for(const i of n)if(console.debug("🏃‍♂️ Running migration",i.name),i(this))o=!0;else throw new Error("Migration failed at "+i.name);if(o)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,o,i,s,a]=await cg.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:o,mediaFiles:i,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#V(),T6(this),this.#W(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#G(),UO(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=cv(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.#G();this.options.ydoc||this.#ee(),this.emit("documentReplaced",{editor:this})}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}=Tj;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const o=t.pos,i=o+t.node.nodeSize,s=qC(n,this);r.replaceWith(o,i,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=w3.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await L_n(t,this)}annotate(t=[],n=[],r=!1){const{state:o,schema:i}=this;let s=o.tr;if(s=w3.processTables({state:this.state,tr:s,annotationValues:t}),s=w3.annotateDocument({tr:s,schema:i,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)}#mt(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ZBe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#at(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ZBe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#re(){this.#t?.initDevTools?.(this)}},ty=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),ny={EXT:ty("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:ty("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:ty("--sd-comments-highlight-external-faded","#B1124B20"),INT:ty("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:ty("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:ty("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:ty("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:ty("--sd-comments-highlight-internal-nested-border","#07838399")},Q6="track-change-focused",QVe=".superdoc-comment-highlight",RWn="[data-track-change-id], [data-track-change-ids]";function Nte(e){return e?e.split(",").filter(Boolean):[]}function PWn(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 $Ve(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function Lte(e,t){$Ve(e,"backgroundColor",t.css,t.fallback)}function NWn(e,t){$Ve(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 LWn=class{#e=null;#t=new Set;#o="";#n=null;setContainer(e){this.#n=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}setActiveTrackChangeIds(e){const t=Array.from(new Set(e.filter(r=>r.length>0))),n=t.join("\0");return this.#o===n?!1:(this.#o=n,this.#t=new Set(t),!0)}apply(){const e=this.#n;e&&(this.#r(e),this.#s(e))}destroy(){const e=this.#n;if(!e)return;const t=e.querySelectorAll(QVe);for(let r=0;r<t.length;r++){const o=t[r];o.style.backgroundColor="",o.style.boxShadow=""}const n=e.querySelectorAll(`.${Q6}`);for(let r=0;r<n.length;r++)n[r].classList.remove(Q6)}#r(e){const t=this.#e,n=e.querySelectorAll(QVe);for(let r=0;r<n.length;r++){const o=n[r],i=Nte(o.dataset.commentIds);if(i.length===0)continue;const s=new Set(Nte(o.dataset.commentInternalIds)),a=s.has(i[0]),l=o.classList.contains("highlighted")&&(o.classList.contains("track-insert-dec")||o.classList.contains("track-delete-dec"));if(t==null){l?o.style.backgroundColor="":Lte(o,a?ny.INT:ny.EXT),o.style.boxShadow="";continue}const c=this.#i(t,i,o.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?o.style.backgroundColor="":Lte(o,u?ny.INT_ACTIVE:ny.EXT_ACTIVE),i.length>1?NWn(o,u?ny.INT_NESTED_BDR:ny.EXT_NESTED_BDR):o.style.boxShadow=""}else l?o.style.backgroundColor="":Lte(o,a?ny.INT_FADED:ny.EXT_FADED),o.style.boxShadow=""}}#i(e,t,n){if(t.includes(e))return e;if(n){const r=PWn(n).get(e);if(r&&t.includes(r))return r}return null}#s(e){const t=this.#e,n=this.#t,r=e.querySelectorAll(RWn);for(let o=0;o<r.length;o++){const i=r[o];this.#c(i,n,t)?i.classList.add(Q6):i.classList.remove(Q6)}}#c(e,t,n){const r=[e.dataset.trackChangeId,e.dataset.trackChangePreferredTargetId,...Nte(e.dataset.trackChangeIds)].filter(o=>!!o);return n&&r.includes(n)?!0:r.some(o=>t.has(o))}},MWn=[ho,Eo,o_,Hu,mT,v5],DWn=new Set([...MWn]),OWn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],Mte=`
828
+ `:pVe(e)?(a=2,l=2):wte(e)&&(a=1,l=1);++i<o.length;)s=s.concat(dVe(o[i],e,{whitespace:r,breakBefore:i?void 0:a,breakAfter:i<o.length-1?q6(o[i+1]):l}));return bte(e)&&mte(t,e,bte)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function fVe(e,t){const n=String(e.value),r=[],o=[];let i=0;for(;i<=n.length;){gte.lastIndex=i;const l=gte.exec(n),c=l&&"index"in l?l.index:n.length;r.push(YVn(n.slice(i,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),i===0?t.breakBefore:!0,c===n.length?t.breakAfter:!0)),i=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?(o.push(r[s]),a=void 0):r[s]?(typeof a=="number"&&o.push(a),o.push(r[s]),a=0):(s===0||s===r.length-1)&&o.push(0);return o}function KVn(e){return[String(e.value)]}function YVn(e,t,n){const r=[];let o=0,i;for(;o<e.length;){yte.lastIndex=o;const s=yte.exec(e);i=s?s.index:e.length,!o&&!i&&s&&!t&&r.push(""),o!==i&&r.push(e.slice(o,i)),o=s?i+s[0].length:i}return o!==i&&!n&&r.push(""),r.join(" ")}function hVe(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 XVn(e){return!!(e.properties||{}).hidden}function JVn(e){return e.tagName==="td"||e.tagName==="th"}function ZVn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var gte,yte,q6,bte,pVe,vte,mVe,wte,QVn=Oe((()=>{jVn(),W6(),gte=/\n/g,yte=/[\t ]+/g,q6=Vd("br"),bte=Vd(JVn),pVe=Vd("p"),vte=Vd("tr"),mVe=Vd(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",XVn,ZVn]),wte=Vd(["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"])})),F2=Oe((()=>{QVn()}));function $Vn(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 eGn=Oe((()=>{}));function K6(e,t){const n=t.children;let r=-1,o,i;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)){o=a.properties.className;break}}if(o){for(r=-1;++r<o.length;)if(String(o[r]).slice(0,9)===gVe){i=String(o[r]).slice(9);break}}const s={type:"code",lang:i||null,meta:null,value:$Vn(O2(t))};return e.patch(t,s),s}var gVe,tGn=Oe((()=>{F2(),eGn(),gVe="language-"}));function nGn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var rGn=Oe((()=>{}));function Ate(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var oGn=Oe((()=>{}));function Ste(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var yVe=Oe((()=>{}));function iGn(e,t){const n=[],r=[];let o=-1;for(;++o<t.children.length;){const a=t.children[o];a.type==="element"&&a.tagName==="div"?n.push(...a.children):n.push(a)}let i={definitions:[],titles:[]};for(o=-1;++o<n.length;){const a=n[o];if(a.type==="element"&&a.tagName==="dt"){const l=n[o-1];l&&l.type==="element"&&l.tagName==="dd"&&(r.push(i),i={definitions:[],titles:[]}),i.titles.push(a)}else i.definitions.push(a)}r.push(i),o=-1;const s=[];for(;++o<r.length;){const a=[...bVe(e,r[o].titles),...bVe(e,r[o].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:Ste(s),children:s};return e.patch(t,a),a}}function bVe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,sGn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:Ste(r),children:r}]}function sGn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var aGn=Oe((()=>{yVe()}));function Y6(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var lGn=Oe((()=>{}));function Tte(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 Ite=Oe((()=>{}));function xI(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:Tte(e.all(t))};return e.patch(t,n),n}var cGn=Oe((()=>{Ite()}));function uGn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var dGn=Oe((()=>{}));function fGn(e,t){const n=t.properties||{},r=String(n.src||""),o=String(n.title||"");if(r&&o){const i={type:"link",title:null,url:e.resolve(r),children:[{type:"text",value:o}]};return e.patch(t,i),i}}var hGn=Oe((()=>{}));function vVe(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 pGn=Oe((()=>{}));function B2(e,t){const n={type:"inlineCode",value:O2(t)};return e.patch(t,n),n}var mGn=Oe((()=>{F2()}));function wVe(e,t){const n=[],r=[],o=t||e.properties||{},i=AVe(e),s=Math.min(Number.parseInt(String(o.size),10),0)||(o.multiple?4:1);let a=-1;for(;++a<i.length;){const u=i[a];u&&u.properties&&u.properties.selected&&n.push(u)}const l=n.length>0?n:i,c=Math.min(l.length,s);for(a=-1;++a<c;){const u=l[a],d=u.properties||{},f=O2(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function AVe(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(...AVe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var SVe=Oe((()=>{F2()}));function gGn(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||TVe:e.options.unchecked||IVe};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 o=[];if(r)o=[[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"&&(o=wVe(c,n))}if(o.length===0)return;if(n.type==="password"&&(o[0]=["•".repeat(o[0][0].length),void 0]),n.type==="email"||n.type==="url"){const l=[];let c=-1;for(;++c<o.length;){const u=e.resolve(o[c][0]),d={type:"link",title:null,url:n.type==="email"?"mailto:"+u:u,children:[{type:"text",value:o[c][1]||u}]};l.push(d),c!==o.length-1&&l.push({type:"text",value:", "})}return l}const i=[];let s=-1;for(;++s<o.length;)i.push(o[s][1]?o[s][1]+" ("+o[s][0]+")":o[s][0]);const a={type:"text",value:i.join(", ")};return e.patch(t,a),a}var TVe,IVe,yGn=Oe((()=>{SVe(),TVe="[x]",IVe="[ ]"}));function bGn(e,t){const n=e.type==="element"&&xVe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var xVe,vGn=Oe((()=>{xVe={}.hasOwnProperty})),wGn=Oe((()=>{vGn()}));function AGn(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(!kVe.has(String(t[n])))return!1;return!0}var kVe,SGn=Oe((()=>{kVe=new Set(["pingback","prefetch","stylesheet"])})),TGn=Oe((()=>{SGn()}));function CVe(e){return!!(e.type==="text"||EVe(e)||pte(e)||AGn(e)||_Ve(e)&&bGn(e,"itemProp"))}var EVe,_Ve,IGn=Oe((()=>{YUe(),wGn(),TGn(),W6(),EVe=Vd(["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"]),_Ve=Vd("meta")})),RVe=Oe((()=>{IGn()}));function xte(e,t){const{rest:n,checkbox:r}=NVe(t),o=r?!!r.properties.checked:null,i={type:"listItem",spread:PVe(n),checked:o,children:e.toFlow(e.all(n))};return e.patch(t,i),i}function PVe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(CVe(r))continue;if(r.tagName==="p"||n||PVe(r))return!0;n=!0}}return!1}function NVe(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}=NVe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var xGn=Oe((()=>{RVe()}));function kte(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),kGn);let o=null;n&&(o=t.properties&&t.properties.start?Number.parseInt(String(t.properties.start),10):1);const i={type:"list",ordered:n,start:o,spread:Ste(r),children:r};return e.patch(t,i),i}function kGn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var CGn=Oe((()=>{yVe()}));function X6(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!DVe(n)||"children"in n&&X6(n.children))return!0}return!1}function LVe(e){return MVe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?XUe(r.value):!1})?[]:[{type:"paragraph",children:Tte(n)}]}}function EGn(e){return MVe(e.children,t,n);function t(r){const o=Cte(e);return o.children=r,[o]}function n(r){if("children"in r&&"children"in e){const o=Cte(e),i=Cte(r);return o.children=r.children,i.children.push(o),i}return{...r}}}function MVe(e,t,n){const r=_Gn(e),o=[];let i=[],s=-1;for(;++s<r.length;){const a=r[s];DVe(a)?i.push(a):(i.length>0&&(o.push(...t(i)),i=[]),o.push(n(a)))}return i.length>0&&(o.push(...t(i)),i=[]),o}function _Gn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&X6(r.children)?t.push(...EGn(r)):t.push(r)}return t}function DVe(e){const t=e.data&&e.data.hName;return t?CVe({type:"element",tagName:t,properties:{},children:[]}):nj(e)}function Cte(e){return fte({...e,children:[]})}var Ete=Oe((()=>{qUe(),RVe(),QUe(),CIe(),Ite()}));function OVe(e,t){const n=t.properties||{},r=t.tagName==="video"?String(n.poster||""):"";let o=String(n.src||""),i=-1,s=!1,a=e.all(t);if(nE({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||X6(a))return a;for(;!o&&++i<t.children.length;){const u=t.children[i];u.type==="element"&&u.tagName==="source"&&u.properties&&(o=String(u.properties.src||""))}if(r){const u={type:"image",title:null,url:e.resolve(r),alt:_M(a)};e.patch(t,u),a=[u]}const l=a,c={type:"link",title:n.title?String(n.title):null,url:e.resolve(o),children:l};return e.patch(t,c),c}var RGn=Oe((()=>{RM(),GM(),Ete()}));function FVe(e,t){const n=Tte(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var PGn=Oe((()=>{Ite()}));function NGn(e,t){const n=e.options.quotes||BVe;e.qNesting++;const r=e.all(t);e.qNesting--;const o=n[e.qNesting%n.length],i=r[0],s=r[r.length-1],a=o.charAt(0),l=o.length>1?o.charAt(1):o;return i&&i.type==="text"?i.value=a+i.value:r.unshift({type:"text",value:a}),s&&s.type==="text"?s.value+=l:r.push({type:"text",value:l}),r}var BVe,LGn=Oe((()=>{BVe=['"']}));function MGn(e,t){let n=e.all(t);(e.options.document||X6(n))&&(n=LVe(n));const r={type:"root",children:n};return e.patch(t,r),r}var DGn=Oe((()=>{Ete()}));function OGn(e,t){const n=wVe(t);let r=-1;const o=[];for(;++r<n.length;){const i=n[r];o.push(i[1]?i[1]+" ("+i[0]+")":i[0])}if(o.length>0){const i={type:"text",value:o.join(", ")};return e.patch(t,i),i}}var FGn=Oe((()=>{SVe()}));function HVe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var BGn=Oe((()=>{}));function zVe(e,t){const n={type:"tableCell",children:e.all(t)};if(e.patch(t,n),t.properties){const r=t.properties.rowSpan,o=t.properties.colSpan;if(r||o){const i=n.data||(n.data={});r&&(i.hastUtilToMdastTemporaryRowSpan=r),o&&(i.hastUtilToMdastTemporaryColSpan=o)}}return n}var HGn=Oe((()=>{}));function zGn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),UGn)};return e.patch(t,n),n}function UGn(){return{type:"tableCell",children:[]}}var VGn=Oe((()=>{}));function GGn(e,t){if(e.inTable){const c={type:"text",value:O2(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=WGn(t),o=e.toSpecificContent(e.all(t),UVe);r&&o.unshift(UVe());let i=-1;for(;++i<o.length;){const c=o[i];c.children=e.toSpecificContent(c.children,jGn)}let s=1;for(i=-1;++i<o.length;){const c=o[i].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=i-1;for(;++m<i+p;){let g=u-1;for(;++g<u+h&&o[m];){const y=[];(m!==i||g!==u)&&y.push({type:"tableCell",children:[]}),o[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(i=-1;++i<o.length;){const c=o[i].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:o};return e.patch(t,l),l}function WGn(e){const t={align:[null],headless:!0};let n=0,r=0;return nE(e,function(o){if(o.type==="element"){if(o.tagName==="table"&&e!==o)return QTe;if((o.tagName==="th"||o.tagName==="td")&&o.properties){if(!t.align[r]){const i=String(o.properties.align||"")||null;(i==="center"||i==="left"||i==="right"||i===null)&&(t.align[r]=i)}t.headless&&n<2&&o.tagName==="th"&&(t.headless=!1),r++}else o.tagName==="thead"?t.headless=!1:o.tagName==="tr"&&(n++,r=0)}}),t}function jGn(){return{type:"tableCell",children:[]}}function UVe(){return{type:"tableRow",children:[]}}var qGn=Oe((()=>{F2(),GM()}));function KGn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var YGn=Oe((()=>{}));function XGn(e,t){const n={type:"text",value:O2(t)};return e.patch(t,n),n}var JGn=Oe((()=>{F2()}));function ZGn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var QGn=Oe((()=>{}));function vo(e,t){return e.all(t)}function pa(e,t){return e.toFlow(e.all(t))}function wo(){}var VVe,GVe,$Gn=Oe((()=>{FVn(),HVn(),UVn(),GVn(),tGn(),rGn(),oGn(),aGn(),lGn(),cGn(),dGn(),hGn(),pGn(),mGn(),yGn(),xGn(),CGn(),RGn(),PGn(),LGn(),DGn(),FGn(),BGn(),HGn(),VGn(),qGn(),YGn(),JGn(),QGn(),VVe={comment:nGn,doctype:wo,root:MGn,text:KGn},GVe={applet:wo,area:wo,basefont:wo,bgsound:wo,caption:wo,col:wo,colgroup:wo,command:wo,content:wo,datalist:wo,dialog:wo,element:wo,embed:wo,frame:wo,frameset:wo,isindex:wo,keygen:wo,link:wo,math:wo,menu:wo,menuitem:wo,meta:wo,nextid:wo,noembed:wo,noframes:wo,optgroup:wo,option:wo,param:wo,script:wo,shadow:wo,source:wo,spacer:wo,style:wo,svg:wo,template:wo,title:wo,track:wo,abbr:vo,acronym:vo,bdi:vo,bdo:vo,big:vo,blink:vo,button:vo,canvas:vo,cite:vo,data:vo,details:vo,dfn:vo,font:vo,ins:vo,label:vo,map:vo,marquee:vo,meter:vo,nobr:vo,noscript:vo,object:vo,output:vo,progress:vo,rb:vo,rbc:vo,rp:vo,rt:vo,rtc:vo,ruby:vo,slot:vo,small:vo,span:vo,sup:vo,sub:vo,tbody:vo,tfoot:vo,thead:vo,time:vo,address:pa,article:pa,aside:pa,body:pa,center:pa,div:pa,fieldset:pa,figcaption:pa,figure:pa,form:pa,footer:pa,header:pa,hgroup:pa,html:pa,legend:pa,main:pa,multicol:pa,nav:pa,picture:pa,section:pa,a:OVn,audio:OVe,b:HVe,base:BVn,blockquote:zVn,br:VVn,code:B2,dir:kte,dl:iGn,dt:xte,dd:xte,del:Ate,em:Y6,h1:xI,h2:xI,h3:xI,h4:xI,h5:xI,h6:xI,hr:uGn,i:Y6,iframe:fGn,img:vVe,image:vVe,input:gGn,kbd:B2,li:xte,listing:K6,mark:Y6,ol:kte,p:FVe,plaintext:K6,pre:K6,q:NGn,s:Ate,samp:B2,select:OGn,strike:Ate,strong:HVe,summary:FVe,table:GGn,td:zVe,textarea:XGn,th:zVe,tr:zGn,tt:B2,u:Y6,ul:kte,var:B2,video:OVe,wbr:ZGn,xmp:K6}}));function eWn(e){return{all:tWn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...GVe,...e.handlers},inTable:!1,nodeHandlers:{...VVe,...e.nodeHandlers},one:nWn,options:e,patch:rWn,qNesting:0,resolve:oWn,toFlow:iWn,toSpecificContent:sWn}}function tWn(e){const t=e.children||[],n=[];let r=-1;for(;++r<t.length;){const o=t[r],i=this.one(o,e);Array.isArray(i)?n.push(...i):i&&n.push(i)}return n}function nWn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(_te.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(_te.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 rWn(e,t){e.position&&(t.position=LVn(e))}function oWn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function iWn(e){return LVe(e)}function sWn(e,t){const n=t(),r=[];let o=[],i=-1;for(;++i<e.length;){const a=e[i];if(s(a))o.length>0&&(a.children.unshift(...o),o=[]),r.push(a);else{const l=a;o.push(l)}}if(o.length>0){let a=r[r.length-1];a||(a=t(),r.push(a)),a.children.push(...o),o=[]}return r;function s(a){return a.type===n.type}}var _te,aWn=Oe((()=>{DVn(),$Gn(),Ete(),_te={}.hasOwnProperty}));function WVe(e,t){const n=fte(e),r=t||jVe,o=RVn({newlines:r.newlines===!0}),i=eWn(r);let s;o(n),nE(n,function(l){if(l&&l.type==="element"&&l.properties){const c=String(l.properties.id||"")||void 0;c&&!i.elementById.has(c)&&i.elementById.set(c,l)}});const a=i.one(n,void 0);return a?Array.isArray(a)?s={type:"root",children:a}:s=a:s={type:"root",children:[]},nE(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 jVe,lWn=Oe((()=>{qUe(),NVn(),GM(),aWn(),jVe={}})),cWn=Oe((()=>{lWn()}));function uWn(e,t){return e&&"run"in e?async function(n,r){const o=WVe(n,{...Rte,...t});await e.run(o,r)}:function(n){return WVe(n,{...Rte,...e})}}var Rte,dWn=Oe((()=>{cWn(),Rte={document:!0}})),fWn=Rs({default:()=>uWn},1),hWn=Oe((()=>{dWn()}));function pWn(e){const t=e.modules?.trackChanges,n=e.trackedChanges;if(!t&&!n)return e;const r={...n??{},...t??{}};return{...e,trackedChanges:r}}var mWn="1.45.0",Pte=96,gWn=50,yWn=20,bWn=new Set([Ki,ui,vs]),J6=e=>!!(e?.type?.name&&bWn.has(e.type.name)),qVe=e=>{if(!J6(e))return null;const t=typeof e.attrs?.id=="string"?e.attrs.id:"";return`${e.type?.name??""}:${t}`},H2=e=>{const t=new Set;if(!e)return t;for(const n of e.marks??[]){const r=qVe(n);r&&t.add(r)}return t},KVe=e=>!!(e.isInline&&e.marks?.some(J6)),Z6=(e,t,n)=>{if(t>=n)return!1;const r=0,o=e.content.size,i=Math.max(r,Math.min(o,t)),s=Math.max(r,Math.min(o,n));if(i>=s)return!1;let a=!1;return e.nodesBetween(i,s,l=>{if(KVe(l))return a=!0,!1}),a},YVe=(e,t,n)=>{if(t>=n)return!1;const r=0,o=e.content.size,i=Math.max(r,Math.min(o,t)),s=Math.max(r,Math.min(o,n));if(i>=s)return!1;let a=!1,l=!1,c=!1;return e.nodesBetween(i,s,(u,d)=>{if(!u.isInline||!u.isLeaf||d+u.nodeSize<=i||d>=s)return;const f=(u.marks??[]).filter(J6);if(!f.length){l=!0;return}a=!0,f.every(h=>h.type?.name==="trackInsert")||(c=!0)}),a&&!l&&!c},vWn=(e,t,n)=>{if(!YVe(e,t,n))return null;const r=[],o=new Set;return e.nodesBetween(t,n,(i,s)=>{if(!i.isInline||!i.isLeaf||s+i.nodeSize<=t||s>=n)return;const a=(i.marks??[]).find(c=>c.type?.name===Ki),l=typeof a?.attrs?.id=="string"?a.attrs.id:null;!a||!l||o.has(l)||(o.add(l),r.push(a))}),r.length===1?r[0]:null},XVe=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=r.nodeBefore?.marks?.find(l=>l.type?.name==="trackInsert")??null,i=r.nodeAfter?.marks?.find(l=>l.type?.name==="trackInsert")??null,s=typeof o?.attrs?.id=="string"?o.attrs.id:null,a=typeof i?.attrs?.id=="string"?i.attrs.id:null;return!o||!i||!s||s!==a?null:o},wWn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof qr))return null;const r=(t.docs??[])[0]??e.doc,o=n.from!==n.to&&n.slice.content.size===0?vWn(r,n.from,n.to):n.from===n.to&&n.slice.content.size>0?XVe(r,n.from):null;return o?{insertedMark:o,deletionMark:null,formatMark:null,deletionNodes:[],step:n,emitCommentEvent:!0}:null},JVe=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=H2(r.nodeBefore);if(!o.size)return!1;const i=H2(r.nodeAfter);for(const s of o)if(i.has(s))return!0;return!1},AWn=e=>{let t=!1;return e.descendants?.(n=>{if(KVe(n))return t=!0,!1}),t},SWn=(e,t,n)=>{const r=XVe(e,t);if(!r)return!1;if(!n.content)return!0;const o=typeof r.attrs?.id=="string"?r.attrs.id:null;if(!o)return!1;let i=!0;return n.content.descendants?.(s=>{if(!i||!s.isInline)return i?void 0:!1;const a=(s.marks??[]).filter(J6);if(a.length&&!a.every(l=>l.type?.name==="trackInsert"&&l.attrs?.id===o))return i=!1,!1}),i},TWn=(e,t,n)=>{if(!n.content||!AWn(n.content))return!1;const r=Math.max(0,Math.min(e.content.size,t)),o=e.resolve(r);return H2(o.nodeBefore).size>0||H2(o.nodeAfter).size>0},IWn=(e,t)=>e instanceof qr?e.from!==e.to&&e.slice.content.size===0&&YVe(t,e.from,e.to)||e.from===e.to&&e.slice.content.size>0&&SWn(t,e.from,e.slice)||e.from===e.to&&e.slice.content.size>0&&JVe(t,e.from)?!1:Z6(t,e.from,e.to)?!0:e.from===e.to&&e.slice.content.size>0?JVe(t,e.from)||TWn(t,e.from,e.slice):!1:e instanceof wh||e instanceof mc?Z6(t,e.from,e.to):e instanceof gc?Z6(t,e.from,e.to)||Z6(t,e.gapFrom,e.gapTo):!1,xWn=(e,t)=>{if(!t.docChanged||!t.steps.length)return!1;const n=t.docs??[];return t.steps.some((r,o)=>IWn(r,n[o]??e.doc))},kWn=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=H2(r.nodeAfter);if(!o.size)return[];const i=[];for(const s of r.nodeBefore?.marks??[]){const a=qVe(s);a&&o.has(a)&&i.push(s)}return i},CWn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof qr)||n.from!==n.to||n.slice.content.size===0)return null;const r=kWn((t.docs??[])[0]??e.doc,n.from);return r.length?{from:n.from,to:n.from+n.slice.size,marks:r}:null},EWn=800,ZVe=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 _Wn(e){const t=(e.attrs?.colwidth??[]).reduce((i,s)=>i+(s||0),0),n=e.attrs?.cellMargins,r=n?.left??0,o=n?.right??0;return Math.max(t-r-o,0)}var Um=class cg extends Y_{#e;#t=null;#o=!1;#n="initialized";#r=null;#i=null;get currentTotalPages(){if(this.presentationEditor){const t=this.presentationEditor.getPages();return t.length>0?t.length:void 0}}#s=null;#c=!1;#u=null;#d=0;#f=null;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=pWn(t),r=GT(),o=!!n.isHeadless,i=!!(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&&i&&!o)throw new Error("[super-editor] Cannot mount an editor without a DOM. Provide DOM globals (e.g. via JSDOM) or pass { isHeadless: true }.");!r&&!o&&(n.isHeadless=!0),n.isHeadless&&(n.element=null,n.selector=null),this.#f=n.fragment??null,this.#L(n),this.setOptions(n),this.#t=n.renderer??(r?new r8e:null),this.#S();const{setHighContrastMode:l}=Qh();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#v(),this.#n="initialized";else{const c={docx:()=>this.#E(),text:()=>this.#R(),html:()=>this.#R(),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)}#p(t){this.#t?.initContainerElement?.(t)}#a(){return GT()&&!this.options.isHeadless}#b(){return this.options.document??this.options.mockDocument??(GT()?document:null)}#l(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#T()}#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.#s=new Clt({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#T(){this.getDocumentIdentifier().then(t=>{if(!(!this.#s||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()??null;this.#s.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new cBe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#w(t,n,r,o){this.#n=t;try{const i=await o();return this.#n=n,i}catch(i){throw this.#n=r,i}}#v(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?O5():Lv()),this.#O(),this.#F(),this.#te(),this.#C()}#C(){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.#D.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.#Ae.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.options.onFontsChanged&&this.on("fonts-changed",this.options.onFontsChanged),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}#x(){this.on("pointerDown",()=>{this.#d=Date.now()})}async#h(t,n){try{const r=n?.mode??this.options.mode??"docx",o=n?.isNewFile,i=Object.prototype.hasOwnProperty.call(n??{},"fragment"),s={...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,fragment:i?n?.fragment??null:this.options.fragment??this.#f},a=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const c=ez().readFileSync(t),[u,d,f,h,p]=await cg.loadXmlData(c,!0,a);s.content=u,s.mediaFiles=f,s.fonts=h,s.fileSource=p??c,s.isNewFile=o??!1,this.#i=p?null:t}else{const c=await fetch(t);if(!c.ok)throw console.debug("[SuperDoc] Fetch failed:",c.status,c.statusText),new Error(`Fetch failed: ${c.status} ${c.statusText}`);const u=await c.blob(),[d,f,h,p,m]=await cg.loadXmlData(u,!1,a);s.content=d,s.mediaFiles=h,s.fonts=p,s.fileSource=m??u,s.isNewFile=o??!1,this.#i=t.split("/").pop()||null}else if(t!=null&&typeof t=="object"){const c=typeof Buffer<"u"&&(Buffer.isBuffer(t)||t instanceof Buffer),u=typeof Blob<"u"&&t instanceof Blob,d=t instanceof ArrayBuffer,f=typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer;if(c||u||d||f){const[h,p,m,g,y]=await cg.loadXmlData(t,c,a);s.content=h,s.mediaFiles=m,s.fonts=g,s.fileSource=y??t,s.isNewFile=o??!1,this.#i=null}else{const[h,p,m,g,y]=await cg.loadXmlData(t,!1,a);s.content=h,s.mediaFiles=m,s.fonts=g,s.fileSource=y??t,s.isNewFile=o??!1,this.#i=null}}else if(r==="docx"&&!n?.content&&!n?.html&&!n?.markdown){const{content:c,mediaFiles:u,fonts:d,fileSource:f}=await this.#X();s.content=c,s.mediaFiles={...u,...n?.mediaFiles??{}},s.fonts={...d,...n?.fonts??{}},s.fileSource=f,s.isNewFile=o??!0,this.#i=null}else s.content=n?.content??[],s.mediaFiles=n?.mediaFiles??{},s.fonts=n?.fonts??{},s.fileSource=null,s.isNewFile=o??!n?.content,this.#i=null;this.setOptions(s),this.#V(),T6(this),this.#I(),this.#W();const l=this.#a();if(l&&(this.#p(this.options),this.#le()),this.#$({includePlugins:!l}),!l){const c=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#z(c)}l&&(this.mount(this.options.element),this.#pe()),l||this.#l(),l&&(this.initDefaultStyles(),this.#H()),(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.#k(),this.initializeCollaborationData(),!this.options.ydoc&&!this.options.isChildEditor&&this.#ee(),l&&(this.#re(),this.#A())}catch(r){if(r instanceof ps)throw console.debug("[SuperDoc] Document load error:",r.message),r;const o=r instanceof Error?r:new Error(String(r));throw console.debug("[SuperDoc] Document load error:",o.message),new fBe(`Failed to load document: ${o.message}`,o)}}#m(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=gm(this);t&&(t.state={...Lpe},t.initialized=!1,t.editableBaseline=null),this.#i=null,this.options.initialState=null,this.options.content="",this.options.fileSource=null,this.options.fragment=null,this._state=void 0,this.#u=null,this.#d=0}#I(){const t=gm(this);t&&(t.state=ev(this.converter?Rf(this.converter):null),t.initialized=!0)}#k(){const t=gm(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#E(){this.#O(),this.#F(),this.#te(),this.#V(),T6(this),this.#I(),this.#W(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#a();if(this.#$({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#z(n)}t&&(this.#p(this.options),this.#le(),this.mount(this.options.element),this.#pe()),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.#D.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.#Ae.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.options.onFontsChanged&&this.on("fonts-changed",this.options.onFontsChanged),this.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#H()),(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.#k(),!this.options.ydoc&&!this.options.isChildEditor&&this.#ee(),t&&(this.#re(),this.#A())}#R(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Lv()),this.#O(),this.#F(),this.#te(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#a();this.#$({includePlugins:!t}),t&&(this.#p(this.options),this.mount(this.options.element),this.#pe()),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.#D.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.#x(),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#l()}mount(t){this.#de(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#T()}unmount(){this.view?.dom?.removeEventListener("compositionend",this.#ie),this.view?.dom?.removeEventListener("blur",this.#ie),this.#ce=null,this.#me=[],this.#ne=void 0,this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#D({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#L(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.#i}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.#y("ready","saving"),this.#r||(this.#r=Owt(V7n(this))),this.#r}#M(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=QHe(this);return WPe(this,n,t??this.#M())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=$He(this);return WPe(this,n,t??this.#M())}resolveSelectionHandle(t){this.#y("ready","saving");const n=ctn(t);return n?xee(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),utn(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),q7n(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),K7n(this)}get helpers(){return this.extensionService.helpers}get isEditable(){return!!(this.options.editable&&this.view&&this.view.editable)}get isDestroyed(){return!!(this.#o||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 o=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 i=uxe(this.state);i&&this.view?.dispatch(this.state.tr.setSelection(i)),this.setEditable(!1,!1),this.setOptions({documentMode:"viewing"}),o&&o.classList.add("view-mode")}else r==="suggesting"?(this.commands.disableTrackChangesShowOriginal?.(),this.commands.enableTrackChanges?.(),this.setOptions({documentMode:"suggesting"}),this.setEditable(!0,!1),o&&o.classList.remove("view-mode")):r==="editing"&&(this.commands.disableTrackChangesShowOriginal?.(),this.commands.disableTrackChanges?.(),this.setEditable(!0,!1),this.setOptions({documentMode:"editing"}),o&&o.classList.remove("view-mode"));FS(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,o=Math.max(0,Math.min(t,r));try{const{node:i}=this.view.domAtPos(o);return i&&i.nodeType===1?i:i&&i.nodeType===3?i.parentElement:i?.parentElement??null}catch{return null}}posAtCoords(t){if(typeof this.presentationEditor?.hitTest=="function"){const n=t,r=n?.clientX??n?.left??n?.x??null,o=n?.clientY??n?.top??n?.y??null;if(Number.isFinite(r)&&Number.isFinite(o)){const i=this.presentationEditor.hitTest(r,o);if(i)return{pos:i.pos,inside:i.pos}}}return this.view?this.view.posAtCoords(t):null}#A(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await Vnn(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||cv(this.options.collaborationProvider,()=>{this.#G()})}replaceContent(t){this.setOptions({content:t}),this.#V(),this.initDefaultStyles(),this.#V(),T6(this),this.#W();const n=this.#ue(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#z(r)}#_(t={}){const n=this.state.doc?.attrs??{},r=this.schema?.topNodeType?.spec?.attrs??{},o=new Set([...Object.keys(r),...Object.keys(n),...Object.keys(t)]);if(o.size===0)return;const i=(l,c)=>l===c||JSON.stringify(l)===JSON.stringify(c),s=this.state.tr.setMeta("addToHistory",!1);let a=!1;for(const l of o){const c=Object.prototype.hasOwnProperty.call(t,l)?t[l]:r[l]?.default;i(n[l],c)||(s.setDocAttribute(l,c),a=!0)}a&&this.#z(s)}#G(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#ue(),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.#z(r);const o=this.options.ydoc;o&&o.getMap("meta").set("bodySectPr",n),this.#_(t.attrs??{}),setTimeout(()=>{this.#ee()},50)}setOptions(t={}){const n=this.options??{},r={...n,...t},o=Object.getOwnPropertyDescriptors(n);for(const[i,s]of Object.entries(o))s.enumerable||Object.prototype.hasOwnProperty.call(t,i)||Object.defineProperty(r,i,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)}#oe(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.#oe(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,o=this.options.shouldLoadComments,i=this.options.collaborationIsReady,s=this._state,a=()=>{HNe(this),this.options.ydoc=void 0,this.options.collaborationProvider=r,this.options.shouldLoadComments=o,this.options.collaborationIsReady=i,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}}#O(){const t=["extension","node","mark"],n=[mEn,sEn,gEn,lEn,yEn,bEn],r=this.options.externalExtensions||[],o=[...n,...this.options.extensions].filter(s=>{const a=typeof s?.type=="string"?s.type:void 0;return a?t.includes(a):!1}).map(s=>ZVe(s)),i=r.map(s=>ZVe(s));this.extensionService=wEn.create(o,i,this)}#F(){this.#e=tAe.create({editor:this})}#V(){this.options.converter?this.converter=this.options.converter:this.converter=new Bu({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#X(){const t=await Wfe(E2n),n=typeof process<"u"&&!!process.versions?.node&&typeof Buffer<"u",r=new Uint8Array(t);let o;if(n)o=Buffer.from(r);else if(typeof Blob<"u")o=new Blob([r]);else throw new Error("Blob is not available to create blank DOCX");const[i,s,a,l]=await cg.loadXmlData(o,n);return{content:i,mediaFiles:a,fonts:l,fileSource:o}}async#J(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#X();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#W(){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())}#le(){this.#t?.initFonts?.(this)}async#H(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#Z(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#Z(t){return t.filter(n=>{const r=E_n(n),o=this.fontsImported.includes(n);return!r&&!o})}static async loadXmlData(t,n=!1,r){if(!t)return;const o=new aQ;return[await o.getDocxData(t,n,{password:r?.password}),o.media,o.mediaFiles,o.fonts,o.decryptedFileData]}static getDocumentVersion(t){return Bu.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=Bu.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return Bu.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),cg.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(o=>!!o?.config?.excludeFromSummaryJSON).map(o=>o.name)),r=t2n(this.schema,t);return n.size?{...r,nodes:r.nodes.filter(o=>!n.has(o.name)),marks:r.marks.filter(o=>!n.has(o.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),o=new Error(`Invalid document for current schema: ${r}`);throw n instanceof Error&&(o.cause=n),o}}#te(){this.schema=this.extensionService.schema}#ue(){let t;try{const{mode:n,content:r,fragment:o,loadFromSchema:i}=this.options,s=this.#b(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?i&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#Le(t)):(t=sve(this.converter,this.schema,this),t=this.#Le(t),this.options.markdown?t=bj(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=qC(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)),o&&(GY(o),t=lLt(o,this.schema))):(n==="text"||n==="html")&&(i&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=qC(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.#ue(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let o=k1.create(r);t&&(o=o.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=o,this._state=o}#pe(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#de(t){if(this._state||this.#$(),!this.#t){if(!GT())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new r8e}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#z.bind(this),state:this.state,handleClick:this.#Ne.bind(this)}),this.view?.dom?.addEventListener("compositionend",this.#ie),this.view?.dom?.addEventListener("blur",this.#ie),this.createNodeViews()}createNodeViews(){this.options.skipViewCreation||typeof this.view?.setProps!="function"||this.view.setProps({nodeViews:this.extensionService.nodeViews})}getMaxContentSize(){const t=this.converter?.pageStyles,n=this.options.parentEditor?.converter?.pageStyles,r=t?.pageSize,o=r?.width&&r?.height?t:n??t;if(!o)return{};let i=0;const{$head:s}=this.state.selection;for(let b=s.depth;b>0;b--){const v=s.node(b);if(v.type.name==="tableCell"||v.type.name==="tableHeader"){i=_Wn(v);break}}if(this.isWebLayout())return i>0?{width:i,height:1/0}:{};const{pageSize:a={},pageMargins:l={}}=o,{width:c,height:u}=a;if(!c||!u)return{};const d=b=>(l?.[b]??0)*Pte,f=d("top"),h=d("bottom"),p=d("left"),m=d("right"),g=u*Pte-f-h-gWn,y=c*Pte-p-m-yWn;return i>0?{width:i,height:g}:{width:y,height:g}}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)}#Ae({editor:t,ydoc:n}){if(this.options.collaborationIsReady||this.isDestroyed||!this.converter||!this.state)return;console.debug("🔗 [super-editor] Collaboration ready"),this.#mt(),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.#z(r),this.options.isNewFile||this.#ee()}#ee(){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(Eo,{type:"force"});this.#z(r)},50)}#ce=null;#me=[];#ne=void 0;#Pe(t,n){if(!t.steps.length)return!1;const r=this.#ce;for(let o=0;o<t.steps.length;o+=1){const i=t.steps[o];if(!(i instanceof qr))return!1;if(i.from<i.to&&(!r||i.from<r.from||i.to>r.to)){const s=t.docs[o]??n.doc;if(!this.#Ie(i,s))return!1}}return!0}#Ie(t,n){if(t.slice.size===0)return!1;let r=!1,o=!1;return n.nodesBetween(t.from,t.to,i=>o?!1:i.type.name.includes("table")||i.isLeaf&&!i.isText?(o=!0,!1):(i.isText&&i.text&&(r=!0),!0)),r&&!o}#K(t){const n=[],r=this.#ce;return t.steps.forEach((o,i)=>{if(!(o instanceof qr)||o.from>=o.to||r&&o.from>=r.from&&o.to<=r.to)return;const s=t.docs[i]??this.state.doc;if(!this.#Ie(o,s))return;const a=t.mapping.slice(i+1);n.push({pos:a.map(o.from+o.slice.size,1),slice:s.slice(o.from,o.to)})}),n}#Se(t){const n=this.#ce;return!n||!t.steps.length?!1:t.steps.every(r=>r instanceof qr&&r.from<r.to&&r.from>=n.from&&r.to<=n.to)}#Te(t,n){if(!this.#ce&&!n)return;let r=this.#ce;for(const o of t){if(r){const i=o.mapping.map(r.from,-1),s=o.mapping.map(r.to,1);r=i<s?{from:i,to:s}:null}o===n&&o.steps.forEach((i,s)=>{if(!(i instanceof qr)||i.slice.size===0)return;const a=o.mapping.slice(s+1),l=a.map(i.from,-1),c=a.map(i.from+i.slice.size,1);r=r?{from:Math.min(r.from,l),to:Math.max(r.to,c)}:{from:l,to:c}})}this.#ce=r}#Oe(t){this.#me.length&&(this.#me=this.#xe(this.#me,t))}#xe(t,n){return!t.length||!n.length?t:t.map(r=>{let o=r.pos;for(const i of n)o=i.mapping.map(o,-1);return{...r,pos:o}})}#be(){const t=this.#ce,n=this.#me,r=this.#ne;if(this.#ce=null,this.#me=[],this.#ne=void 0,!t||this.isDestroyed||!this.view)return;const o=this.state;if(!ho.getState(o)?.isTrackChangesActive)return;const i=Math.max(0,Math.min(t.from,o.doc.content.size)),s=Math.max(i,Math.min(t.to,o.doc.content.size));if(i>=s)return;const a=o.schema.marks[Ki];if(!a)return;let l=!0;if(o.doc.nodesBetween(i,s,g=>(g.isText&&!a.isInSet(g.marks)&&(l=!1),!g.isText)),l&&!n.length)return;const c=o.tr,u=Math.floor(Date.now()/6e5)*6e5,d=new Date(u).toISOString(),f=this.options.user??{};let h=l?null:e5({tr:c,from:i,to:s,user:f,date:d});const p=h&&n.length&&this.options.trackedChanges?.replacements!=="independent"?h.attrs.id:"";if(h&&p){const g=h.type.create({...h.attrs,changeType:Kn.Replacement,replacementGroupId:p,replacementSideId:`${p}#inserted`});c.removeMark(i,s,h),c.addMark(i,s,g),h=g}let m=null;n.forEach(g=>{const y=c.mapping.map(g.pos,-1),b=c.doc.content.size;c.replace(y,y,g.slice);const v=y+(c.doc.content.size-b);if(v<=y)return;const A=MJ({tr:c,from:y,to:v,user:f,date:d,id:p||void 0}),S=p?A.deletionMark.type.create({...A.deletionMark.attrs,changeType:Kn.Replacement,replacementGroupId:p,replacementSideId:`${p}#deleted`}):A.deletionMark;S!==A.deletionMark&&(c.removeMark(y,v,A.deletionMark),c.addMark(y,v,S)),m={deletionMark:S,deletionNodes:A.nodes}}),c.setMeta("skipTrackChanges",!0),c.setMeta("compositionTrackingFlush",!0),r!==void 0&&c.setMeta("composition",r),c.setMeta(ho,{...h?{insertedMark:h}:{},...m??{}}),this.view.dispatch(c)}#ie=t=>{const n=t?.type==="blur";queueMicrotask(()=>{if(this.#ce&&!(this.view?.composing&&!n)){try{this.view?.domObserver?.flush?.()}catch{}this.view?.composing&&!n||this.#be()}})};#z(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),o=r(),i=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=ho.getState(i)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=wWn(i,a),y=xWn(i,a);y&&m&&a.setMeta("protectTrackedReviewState",!0);const b=(p||c)&&!m,v=b||y,A=v?null:CWn(i,a);if(!v&&!A&&g&&!a.getMeta(ho)&&a.setMeta(ho,g),A){for(const P of A.marks)a.removeMark(A.from,A.to,P);const k=i.schema.marks;for(const P of[Ki,ui,vs]){const E=k[P];E&&a.removeStoredMark(E)}}if(v&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");const S=b&&(C_(a)||this.view?.composing===!0&&this.#Se(a))&&this.#Pe(a,i),w=S?this.#K(a):[];if(S){const k=a.getMeta("composition");k!==void 0&&(this.#ne=k)}const T=this.options.user??{};a=v&&!S?D3e({tr:a,state:i,user:T,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:x,transactions:C}=i.applyTransaction(a);s=x,this.#Te(C,S?a:null),this.#Oe(C),w.length&&this.#me.push(...this.#xe(w,C.slice(1))),S&&this.view?.composing!==!0&&this.#ie(),l=C.find(k=>k.docChanged)??a}catch(p){if(c)throw p;s=i.apply(a),console.log(p)}const u=!i.selection.eq(s.selection);this._state=s,this.view&&this.view.updateState(s);const d=r();this.emit("transaction",{editor:this,transaction:a,duration:d-o}),u&&this.emit("selectionUpdate",{editor:this,transaction:a}),this.#B({transaction:a,nextState:s,selectionHasChanged:u});const f=a.getMeta("focus");f&&this.emit("focus",{editor:this,event:f.event,transaction:a});const h=a.getMeta("blur");h&&this.emit("blur",{editor:this,event:h.event,transaction:a}),l.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:l}))}#B({transaction:t,nextState:n,selectionHasChanged:r}){const o=t.getMeta("uiEvent"),i=Date.now()-this.#d<=EWn,s=o==="click"||i?"pointer":"keyboard",a=n.selection?this.#_e(n.selection):[],l=a[0]??null;if(r){const c=this.#u;c?.id!==l?.id&&(l?this.emit("contentControlFocus",{active:l,previous:c,activePath:a,source:s}):c&&this.emit("contentControlBlur",{active:null,previous:c,activePath:[],source:s}),this.#u=l)}o==="click"&&l&&this.emit("contentControlClick",{target:l,source:"pointer"})}#_e(t){const n=[],r=new Set,o=t instanceof gn?t.node:null;if(o&&(o.type?.name==="structuredContent"||o.type?.name==="structuredContentBlock")){const s=this.#ke(o);s&&(n.push(s),r.add(s.id))}const i=t.$anchor;if(i&&typeof i.depth=="number"&&typeof i.node=="function")for(let s=i.depth;s>=0;s-=1){const a=i.node(s);if(!a)continue;const l=a?.type?.name;if(l!=="structuredContent"&&l!=="structuredContentBlock")continue;const c=this.#ke(a);c&&(r.has(c.id)||(n.push(c),r.add(c.id)))}return n}#ke(t){const n=t.attrs,r=n?.id;if(typeof r!="string"||r.length===0)return null;const o=t.type.name==="structuredContent"?"inline":"block";return{id:r,tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,controlType:typeof n.controlType=="string"?n.controlType:"unknown",scope:o}}dispatch(t){this.#z(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 dn.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return lve(this.state,r,o)}getJSON(){const t=this.state.doc.toJSON();try{const n=t,r=n.attrs,o=this.converter;o&&o.bodySectPr&&(n.attrs=r||{},n.attrs.bodySectPr=o.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.#b();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"),o=dh.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(o);let i=r.innerHTML;return t&&(i=hSe(i,n)),i}async getMarkdown(){const t=this.#b();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,o=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:i},{default:s},{default:a},{default:l},{default:c}]=await Promise.all([Promise.resolve().then(()=>(NW(),lDt)),Promise.resolve().then(()=>(ZUn(),JUn)),Promise.resolve().then(()=>(hWn(),fWn)),Promise.resolve().then(()=>(T8e(),gPn)),Promise.resolve().then(()=>(hj(),Q6t))]),u=this.getHTML(),d=i().use(s,{fragment:!0}).use(a).use(c).use(l,{bullet:"-",fences:!0}).processSync(u);return String(d)}finally{o&&(o.document===void 0?delete n.document:n.document=o.document,o.window===void 0?delete n.window:n.window=o.window,o.navigatorDescriptor?Object.defineProperty(globalThis,"navigator",o.navigatorDescriptor):delete n.navigator)}}getDocumentVersion(){return this.converter?.getSuperdocVersion()||null}createChildEditor(t){return M_n(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&&!gv()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#z(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#Ne(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return C_n(t,n)}#Le(t){const n=k1.create({schema:this.schema,doc:t}),{tr:r,doc:o}=n;return ton(o,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:__n(this)}#Re(t=[]){const n=this.state.doc,r=new mV(n);return eon(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#Re()}#Je(){if(!this.converter)return;const t=uUt(),n=(l,c)=>{const u=l?.sourceId;pE(u)&&t.reserve(c,u)},r=(l,c)=>{l&&l.descendants(u=>{if(Array.isArray(u.marks))for(const d of u.marks){const f=d.type.name;f!=="trackInsert"&&f!=="trackDelete"&&f!=="trackFormat"||n(d.attrs,c)}})},o=(l,c)=>{if(!l||typeof l!="object")return;const u=l;if(Array.isArray(u.marks))for(const d of u.marks)d.type!=="trackInsert"&&d.type!=="trackDelete"&&d.type!=="trackFormat"||n(d.attrs,c);if(Array.isArray(u.content))for(const d of u.content)o(d,c)},i=(l,c)=>{if(typeof l!="string"||!l)return c;const u=l.replace(/^\/+/,"");return u.startsWith("word/")?u:`word/${u}`},s=this.converter.convertedXml?.["word/_rels/document.xml.rels"]?.elements?.find(l=>l.name==="Relationships"),a=(l,c)=>{const u=s?.elements?.find(d=>d.attributes?.Id===l)?.attributes?.Target;return i(u,c)};r(this.state?.doc,"word/document.xml");for(const[l,c]of Object.entries(this.converter.headers||{})){const u=a(l,"word/header1.xml"),d=this.converter.headerEditors?.find(f=>f.id===l);r(d?.editor?.state?.doc,u),o(c,u)}for(const[l,c]of Object.entries(this.converter.footers||{})){const u=a(l,"word/footer1.xml"),d=this.converter.footerEditors?.find(f=>f.id===l);r(d?.editor?.state?.doc,u),o(c,u)}o(this.converter.footnotes,"word/footnotes.xml"),o(this.converter.endnotes,"word/endnotes.xml"),this.converter.wordIdAllocator=t}#fe(){if(!this.converter)return;const t=this.converter.wordIdAllocator?.getSourceIdMap?.()??{};if(Object.keys(t).length===0&&!this.#Ce())return;const n=JSON.stringify({version:1,parts:t});Bu.setStoredCustomProperty(this.converter.convertedXml,lCe,n,!1)}#Ce(){return!!this.converter?.convertedXml?.["docProps/custom.xml"]?.elements?.find(n=>{const r=n?.name;return r==="Properties"||r?.endsWith(":Properties")})?.elements?.some(n=>{const r=n?.name;return(r==="property"||r?.endsWith(":property"))&&n.attributes?.name==="SuperdocTrackedChangeSourceIds"})}async exportDocx({isFinalDoc:t=!1,commentsType:n="external",exportJsonOnly:r=!1,exportXmlOnly:o=!1,comments:i,getUpdatedDocs:s=!1,fieldsHighlightColor:a=null,compression:l}={}){try{I$t(lv(this));const c=(i??this.converter.comments??[]).map(X=>{const ae=Array.isArray(X.elements)&&X.elements.length?X.elements:void 0,he=X.commentJSON??ae??(typeof X.commentText=="string"?Z5(X.commentText):void 0);return{...X,commentJSON:he}}),u=this.#Re(c);this.#Je();const d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#at(),o||r)return d;this.#fe();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=REe(this.converter.convertedXml["word/footnotes.xml"],{converter:this.converter,documentXml:this.converter.convertedXml["word/document.xml"],type:"footnote"}),b=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,v=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],A=v?.elements?.[0]?this.converter.schemaToXml(v.elements[0]):null,S=REe(this.converter.convertedXml["word/endnotes.xml"],{converter:this.converter,documentXml:this.converter.convertedXml["word/document.xml"],type:"endnote"}),w=S?.elements?.[0]?this.converter.schemaToXml(S.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],x=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,C=this.converter.convertedXml["word/_rels/settings.xml.rels"],k=C?.elements?.[0]?this.converter.schemaToXml(C.elements[0]):null,P=this.converter.addedMedia,E={};Object.entries(this.converter.convertedXml).forEach(([X,ae])=>{if(X.includes("header")||X.includes("footer")){const he=ae,Ae=this.converter.schemaToXml(he.elements?.[0]);E[X]=String(Ae.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,M=this.converter.convertedXml["docProps/app.xml"],O=M?.elements?.[0]?this.converter.schemaToXml(M.elements[0]):null,H=this.converter.convertedXml["docProps/core.xml"],W=H?.elements?.[0]?this.converter.schemaToXml(H.elements[0]):null,G={...this.options.customUpdatedFiles,"word/document.xml":String(d),"docProps/custom.xml":String(f),"word/_rels/document.xml.rels":String(g),...R?{"word/numbering.xml":String(R)}:{},"word/styles.xml":String(h),...E,...O?{"docProps/app.xml":String(O)}:{},...W?{"docProps/core.xml":String(W)}:{}};if(p){let X=String(m);k?G["word/_rels/settings.xml.rels"]=String(k):/<\w+:attachedTemplate\b/i.test(X)&&(X=X.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),G["word/settings.xml"]=X}b&&(G["word/footnotes.xml"]=String(b)),A&&(G["word/_rels/footnotes.xml.rels"]=String(A)),w&&(G["word/endnotes.xml"]=String(w)),x&&(G["word/_rels/endnotes.xml.rels"]=String(x));const U=uq.map(X=>`word/${X}`);for(const X of U){const ae=this.converter.convertedXml[X];ae?.elements?.[0]?G[X]=String(this.converter.schemaToXml(ae.elements[0])):G[X]=null}const F=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const X of F){const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}if(t){const X=m9n(this,this.converter.convertedXml,{finalDoc:!0});for(const[ae,he]of Object.entries(X))G[ae]=he}for(const X of Object.keys(this.converter.convertedXml)){if(!X.startsWith("customXml/")||!X.endsWith(".xml")&&!X.endsWith(".rels")||Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}const ne=Object.keys(this.converter.convertedXml).filter(X=>/^word\/theme\/[^/]+\.xml$/.test(X)||X==="word/fontTable.xml"||X==="word/webSettings.xml");for(const X of ne){if(Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}for(const X of["[Content_Types].xml","word/_rels/document.xml.rels"]){if(Object.prototype.hasOwnProperty.call(G,X))continue;const ae=this.converter.convertedXml[X];ae?.elements?.[0]&&(G[X]=String(this.converter.schemaToXml(ae.elements[0])))}const Y=this.converter.removedCustomXmlPaths;if(Y instanceof Set)for(const X of Y)G[X]=null;const ve=new aQ;if(s){G["[Content_Types].xml"]=await ve.updateContentTypes({files:this.options.content},P,!0,G,this.options.fonts);const X=this.options.content,{contentTypesXml:ae,relsXml:he}=IBe({baseFiles:Array.isArray(X)||X&&typeof X=="object"?X:null,updatedDocs:G});return G["[Content_Types].xml"]=ae,G["_rels/.rels"]=he,G}const Z=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#J():this.options.content;return await ve.updateZip({docx:Z,updatedDocs:G,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));throw this.emit("exception",{error:u,editor:this}),console.error(u),u}}#Ze(){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.#y("initialized","closed"),await this.#w("documentLoading","ready","closed",async()=>{await this.#h(t,n)}),this.emit("documentOpen",{editor:this,sourcePath:this.#i})}static async open(t,n){const r={mode:"docx",isHeadless:!(n?.element!=null||n?.selector!=null),...n},{html:o,markdown:i,json:s,fragment:a,isCommentsEnabled:l,suppressDefaultDocxStyles:c,documentMode:u,content:d,mediaFiles:f,fonts:h,isNewFile:p,password:m,...g}=r,y={mode:r.mode,html:o,markdown:i,json:s,fragment:a,isCommentsEnabled:l,suppressDefaultDocxStyles:c,documentMode:u,content:d,mediaFiles:f,fonts:h,isNewFile:p,password:m},b=new cg({...g,deferDocumentLoad:!0});return await b.open(t,y),b}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#m(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#i)throw new uBe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#w("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#P(this.#i,n)})}async saveTo(t,n){this.#y("ready"),await this.#w("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#P(t,r),this.#i=t})}async exportDocument(t){return this.#y("ready","saving"),await this.exportDocx({isFinalDoc:t?.isFinalDoc,commentsType:t?.commentsType,comments:t?.comments,fieldsHighlightColor:t?.fieldsHighlightColor,compression:t?.compression})}async#P(t,n){const r=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process.versions?.node!=null,o=typeof Buffer<"u"&&typeof Buffer.isBuffer=="function";if(r||o)try{const i=ez(),s=Buffer.isBuffer(n)?n:Buffer.from(await n.arrayBuffer());i.writeFileSync(t,s);return}catch{}if(typeof window<"u"&&"showSaveFilePicker"in window){const i=await(await window.showSaveFilePicker({suggestedName:t.split("/").pop()||"document.docx",types:[{description:"Word Document",accept:{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"]}}]})).createWritable();await i.write(n),await i.close();return}throw new dBe("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.#o=!0,this.emit("destroy"),this.unmount(),this.destroyHeaderFooterEditors(),this.#Ze(),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 o of r)o?.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=mBe(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",mWn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=mBe(t)||[],r=this.state.plugins.find(i=>this.#oe(i).startsWith("y-sync"));if(!r)return this.options.ydoc;let o=!1;for(const i of n)if(console.debug("🏃‍♂️ Running migration",i.name),i(this))o=!0;else throw new Error("Migration failed at "+i.name);if(o)return(r?.getState(this.state)).doc}async replaceFile(t,n){this.setOptions({annotations:!0});const[r,o,i,s,a]=await cg.loadXmlData(t,!1,n);if(this.setOptions({fileSource:a??(t instanceof ArrayBuffer?new Blob([t]):t),content:r,media:o,mediaFiles:i,fonts:s,isNewFile:!0}),this.options.shouldLoadComments=!0,this.options.replacedFile=!0,this.#V(),T6(this),this.#W(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#G(),UO(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=cv(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.#G();this.options.ydoc||this.#ee(),this.emit("documentReplaced",{editor:this})}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}=Tj;return n(this.state.doc,r=>r.type.name===t)}replaceNodeWithHTML(t,n){const{tr:r}=this.state;if(!t||!n)return;const o=t.pos,i=o+t.node.nodeSize,s=qC(n,this);r.replaceWith(o,i,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=w3.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await L_n(t,this)}annotate(t=[],n=[],r=!1){const{state:o,schema:i}=this;let s=o.tr;if(s=w3.processTables({state:this.state,tr:s,annotationValues:t}),s=w3.annotateDocument({tr:s,schema:i,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)}#mt(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ZBe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#at(){this.options.isHeaderOrFooter||this.options.isChildEditor||new ZBe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#re(){this.#t?.initDevTools?.(this)}},ty=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),ny={EXT:ty("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:ty("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:ty("--sd-comments-highlight-external-faded","#B1124B20"),INT:ty("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:ty("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:ty("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:ty("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:ty("--sd-comments-highlight-internal-nested-border","#07838399")},Q6="track-change-focused",QVe=".superdoc-comment-highlight",RWn="[data-track-change-id], [data-track-change-ids]";function Nte(e){return e?e.split(",").filter(Boolean):[]}function PWn(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 $Ve(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function Lte(e,t){$Ve(e,"backgroundColor",t.css,t.fallback)}function NWn(e,t){$Ve(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 LWn=class{#e=null;#t=new Set;#o="";#n=null;setContainer(e){this.#n=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}setActiveTrackChangeIds(e){const t=Array.from(new Set(e.filter(r=>r.length>0))),n=t.join("\0");return this.#o===n?!1:(this.#o=n,this.#t=new Set(t),!0)}apply(){const e=this.#n;e&&(this.#r(e),this.#s(e))}destroy(){const e=this.#n;if(!e)return;const t=e.querySelectorAll(QVe);for(let r=0;r<t.length;r++){const o=t[r];o.style.backgroundColor="",o.style.boxShadow=""}const n=e.querySelectorAll(`.${Q6}`);for(let r=0;r<n.length;r++)n[r].classList.remove(Q6)}#r(e){const t=this.#e,n=e.querySelectorAll(QVe);for(let r=0;r<n.length;r++){const o=n[r],i=Nte(o.dataset.commentIds);if(i.length===0)continue;const s=new Set(Nte(o.dataset.commentInternalIds)),a=s.has(i[0]),l=o.classList.contains("highlighted")&&(o.classList.contains("track-insert-dec")||o.classList.contains("track-delete-dec"));if(t==null){l?o.style.backgroundColor="":Lte(o,a?ny.INT:ny.EXT),o.style.boxShadow="";continue}const c=this.#i(t,i,o.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?o.style.backgroundColor="":Lte(o,u?ny.INT_ACTIVE:ny.EXT_ACTIVE),i.length>1?NWn(o,u?ny.INT_NESTED_BDR:ny.EXT_NESTED_BDR):o.style.boxShadow=""}else l?o.style.backgroundColor="":Lte(o,a?ny.INT_FADED:ny.EXT_FADED),o.style.boxShadow=""}}#i(e,t,n){if(t.includes(e))return e;if(n){const r=PWn(n).get(e);if(r&&t.includes(r))return r}return null}#s(e){const t=this.#e,n=this.#t,r=e.querySelectorAll(RWn);for(let o=0;o<r.length;o++){const i=r[o];this.#c(i,n,t)?i.classList.add(Q6):i.classList.remove(Q6)}}#c(e,t,n){const r=[e.dataset.trackChangeId,e.dataset.trackChangePreferredTargetId,...Nte(e.dataset.trackChangeIds)].filter(o=>!!o);return n&&r.includes(n)?!0:r.some(o=>t.has(o))}},MWn=[ho,Eo,o_,Hu,mT,v5],DWn=new Set([...MWn]),OWn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],Mte=`
829
829
  `,Dte=`
830
830
  `;function FWn(e,t,n,r){const o=e.content.size;if(t<=0)return 0;if(t>=e.textBetween(0,o,n,r).length)return o;let i=0,s=o;for(;i<s;){const a=Math.floor((i+s)/2);e.textBetween(0,a,n,r).length<t?i=a+1:s=a}return i}function eGe(e,t,n){if(!t)return null;const r=e.content.size,o=e.textBetween(0,r,Mte,Dte),i=[];let s=0;for(;;){const f=o.indexOf(t,s);if(f===-1)break;i.push(f),s=f+1}if(i.length===0)return null;const a=f=>FWn(e,f,Mte,Dte),l=i[0];let c;n==null?c=l:c=i.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 BWn(e,t,n){if(!n.text)return null;const r=eGe(e,n.text,n.from);return!r||r.from<0||r.to<=r.from||r.to>t?null:r}function tGe(e,t,n){const r=[];for(const o of n){const i=BWn(e,t,o);i&&r.push({...o,from:i.from,to:i.to})}return r}function nGe(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 HWn(e,t,n,r){if(e.length===0||!t?.length)return e;const o=tGe(n,r,t);if(o.length===0)return e;const i=nGe(e),s=nGe(o);return!i||!s?e:i.from>=s.from&&i.to<=s.to&&s.to-s.from>i.to-i.from?o:e}var zWn=class tae{#e=new WeakMap;#t=[];#o=[];#n=new Map;#r=!1;#i=new Map;#s=!1;#c=!1;#u=0;#d=new Map;#f=new Map;sync(t,n,r){this.#a(t);const o=t.doc.content.size,i=r?.restoreEmptyDecorations!==!1;i||(this.#s=!0);const s=this.#t.length>0?this.#S(t,n,o,i):new Map;return this.#r=this.#t.length>0,this.#L(s,n,o)}recordTransaction(t){this.#c=!!t?.docChanged,t?.docChanged&&(this.#u+=1,this.#d.set(this.#u,t.mapping))}hasChanges(t){if(this.#a(t),this.#t.length===0)return this.#r;for(const n of this.#t)if(this.#I(n,t)!==this.#n.get(n))return!0;return!1}hasCurrentRanges(t){if(this.#a(t),this.#t.length===0)return!1;const n=t.doc.content.size;for(const r of this.#t){const o=this.#I(r,t);if(o!==Hn.empty)for(const i of o.find(0,n)){if(!this.#k(i))continue;const s=this.#E(i);if((s.classes.length>0||s.dataEntries.length>0||s.styleEntries.length>0)&&!(i.from>=i.to))return!0}}return!1}collectDecorationRanges(t){this.#a(t);const n=[],r=t.doc.content.size;for(const o of this.#t){const{ranges:i,decorationSet:s}=this.#y(o,t,r),a=this.#i.get(o),l=!this.#s&&a&&a.length>0,{effectiveRanges:c,rangesToStore:u}=this.#w(i,a,t.doc,r,l,this.#c);this.#v(o,u.length>0?[...u]:[]),this.#n.set(o,s),n.push(...c)}return this.#p(),n}#p(){this.#s&&(this.#s=!1)}destroy(){this.#t=[],this.#o=[],this.#n.clear(),this.#i.clear(),this.#f.clear(),this.#r=!1,this.#s=!1,this.#c=!1,this.#u=0,this.#d.clear()}#a(t){if(t.plugins===this.#o)return;this.#o=t.plugins,this.#t=t.plugins.filter(r=>!(!r.props.decorations||this.#b(r)||this.#l(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.#i.keys())n.has(r)||this.#i.delete(r);for(const r of this.#f.keys())n.has(r)||this.#f.delete(r);this.#h()}#b(t){const n=t.spec?.key;return n!=null&&DWn.has(n)}#l(t){const n=t.key??"";return OWn.some(r=>n===r||n.startsWith(`${r}$`))}#S(t,n,r,o){const i=new Map;for(const s of this.#t){const{ranges:a,decorationSet:l}=this.#y(s,t,r),c=this.#i.get(s),{effectiveRanges:u,rangesToStore:d}=this.#w(a,c,t.doc,r,o,this.#c);if(a.length>0||u.length>0){this.#T(i,n,u),this.#v(s,d.length>0?[...d]:[]),this.#n.set(s,l);continue}if(!o){this.#v(s,[]),this.#n.set(s,l);continue}this.#v(s,[]),this.#n.set(s,l)}return i}#T(t,n,r){for(const o of r){const i=n.findEntriesInRange(o.from,o.to);for(const s of i){const a=this.#D(t,s.el);for(const l of o.classes)a.classes.add(l);for(const[l,c]of Object.entries(o.dataAttrs))a.dataAttrs.set(l,c);if(o.style)for(const[l,c]of tae.#R(o.style))a.styleProps.set(l,c)}}}#y(t,n,r){const o=this.#I(t,n),i=this.#n.get(t),s=this.#m(t,o,i,n.doc,r);if(s)return{ranges:s,decorationSet:o};const a=[];if(o!==Hn.empty){const l=o.find(0,r);for(const c of l){if(!this.#k(c))continue;const u=this.#E(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,Mte,Dte):void 0;a.push({from:c.from,to:c.to,classes:u.classes,style:f,dataAttrs:d,...h?{text:h}:{}})}}return{ranges:a,decorationSet:o}}#w(t,n,r,o,i,s){let a=t;a.length===0&&i&&n?.length&&(a=tGe(r,o,n));const l=s&&i&&n?.length?HWn(a,n,r,o):a,c=s&&l!==a;return{effectiveRanges:l,rangesToStore:t.length>0?c?l:t:l}}#v(t,n){this.#i.set(t,n),this.#f.set(t,this.#u),this.#h()}#C(t){if(t>=this.#u)return[];const n=[];for(let r=t+1;r<=this.#u;r+=1){const o=this.#d.get(r);if(!o)return[];n.push(o)}return n}#x(t,n,r){let o=t;for(const i of r)o=i.map(o,n);return o}#h(){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)}#m(t,n,r,o,i){if(!r||r!==n)return null;const s=this.#i.get(t);if(!s?.length)return null;const a=this.#f.get(t)??-1;if(a===this.#u)return s;const l=this.#C(a);if(l.length===0)return null;const c=[];for(const u of s){if(u.text){const h=eGe(o,u.text,u.from);if(h&&h.from>=0&&h.to>h.from&&h.to<=i){c.push({from:h.from,to:h.to,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text});continue}}const d=this.#x(u.from,-1,l),f=this.#x(u.to,1,l);d<0||f<=d||f>i||c.push({from:d,to:f,classes:u.classes,style:u.style,dataAttrs:u.dataAttrs,text:u.text})}return c.length===0?null:c}#I(t,n){try{const r=t.props.decorations?.call(t,n);return r instanceof Hn?r:Hn.empty}catch{return Hn.empty}}#k(t){return t.inline===!0}#E(t){const n=t.type?.attrs??{},r=typeof n.class=="string"?n.class.split(/\s+/).filter(i=>i.length>0):[],o=[];for(const[i,s]of Object.entries(n))i==="class"||i==="style"||i.startsWith("data-")&&typeof s=="string"&&o.push([i,s]);return{classes:r,dataEntries:o,styleEntries:typeof n.style=="string"?tae.#R(n.style):[]}}static#R(t){if(!t.trim())return[];const n=document.createElement("span");n.style.cssText=t;const r=[];for(let o=0;o<n.style.length;o++){const i=n.style.item(o),s=n.style.getPropertyValue(i);i&&s&&r.push([i,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}#L(t,n,r){let o=!1;for(const[s,a]of t){const l=this.#e.get(s);l?this.#oe(s,l,a)&&(o=!0):(this.#M(s,a),o=!0)}const i=r>0?n.findEntriesInRange(0,r):[];for(const s of i){if(t.has(s.el))continue;const a=this.#e.get(s.el);a&&(this.#O(s.el,a),o=!0)}return o}#M(t,n){const r={classes:new Set,dataAttrs:new Map,styleProps:new Map,priorClasses:new Set,priorDataAttrs:new Map,priorStyleProps:new Map};for(const o of n.classes)t.classList.contains(o)&&r.priorClasses.add(o),t.classList.add(o),r.classes.add(o);for(const[o,i]of n.dataAttrs){const s=t.getAttribute(o);s!==null&&r.priorDataAttrs.set(o,s),t.setAttribute(o,i),r.dataAttrs.set(o,i)}for(const[o,i]of n.styleProps){const s=t.style.getPropertyValue(o);s&&r.priorStyleProps.set(o,s),t.style.setProperty(o,i),r.styleProps.set(o,i)}this.#e.set(t,r)}#A(t,n,r){const o=n.classes.has(r),i=t.classList.contains(r);return o&&i?!1:(!o&&i&&n.priorClasses.add(r),t.classList.add(r),n.classes.add(r),!0)}#_(t,n,r,o){const i=n.dataAttrs.get(r),s=t.getAttribute(r);return i===o&&s===o?!1:(!n.dataAttrs.has(r)&&s!==null&&n.priorDataAttrs.set(r,s),t.setAttribute(r,o),n.dataAttrs.set(r,o),!0)}#G(t,n,r,o){const i=n.styleProps.get(r),s=t.style.getPropertyValue(r);return i===o&&s===o?!1:(!n.styleProps.has(r)&&s&&n.priorStyleProps.set(r,s),t.style.setProperty(r,o),n.styleProps.set(r,o),!0)}#oe(t,n,r){let o=!1;for(const i of r.classes)this.#A(t,n,i)&&(o=!0);for(const i of n.classes)r.classes.has(i)||(n.priorClasses.has(i)||t.classList.remove(i),n.priorClasses.delete(i),n.classes.delete(i),o=!0);for(const[i,s]of r.dataAttrs)this.#_(t,n,i,s)&&(o=!0);for(const i of n.dataAttrs.keys())if(!r.dataAttrs.has(i)){const s=n.priorDataAttrs.get(i);s!=null?t.setAttribute(i,s):t.removeAttribute(i),n.priorDataAttrs.delete(i),n.dataAttrs.delete(i),o=!0}for(const[i,s]of r.styleProps)this.#G(t,n,i,s)&&(o=!0);for(const i of n.styleProps.keys())if(!r.styleProps.has(i)){const s=n.priorStyleProps.get(i);s?t.style.setProperty(i,s):t.style.removeProperty(i),n.priorStyleProps.delete(i),n.styleProps.delete(i),o=!0}return n.classes.size===0&&n.dataAttrs.size===0&&n.styleProps.size===0&&this.#e.delete(t),o}#O(t,n){for(const r of n.classes)n.priorClasses.has(r)||t.classList.remove(r);for(const r of n.dataAttrs.keys()){const o=n.priorDataAttrs.get(r);o!=null?t.setAttribute(r,o):t.removeAttribute(r)}for(const r of n.styleProps.keys()){const o=n.priorStyleProps.get(r);o?t.style.setProperty(r,o):t.style.removeProperty(r)}this.#e.delete(t)}},Ote="interactionEpoch",Fte="displayLabelSource",Bte={CANONICAL:"canonical",DERIVED:"derived"};function UWn(e,t){const n=e.dataset[xi.DISPLAY_LABEL],r=e.dataset[Fte];if(n!==void 0&&r!==Bte.DERIVED)return{source:Bte.CANONICAL,value:n};const o=t?.textContent?.trim()??"";return o.length===0?null:{source:Bte.DERIVED,value:o}}var VWn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e),n=this.#e.querySelectorAll(A5());for(let r=0;r<n.length;r+=1){const o=n[r];if(o.dataset[Ote]===t)continue;o.dataset[Ote]=t,o.draggable=!0,o.dataset[xi.DRAGGABLE]="true";const i=UWn(o,o.querySelector(`.${qt.ANNOTATION_CONTENT}`));i!==null&&(o.dataset[xi.DISPLAY_LABEL]=i.value,o.dataset[Fte]=i.source);const s=o.dataset[xi.TYPE];s&&(o.dataset[xi.VARIANT]=s),this.#t(o)}}clear(){if(!this.#e)return;const e=this.#e.querySelectorAll(A5());for(let t=0;t<e.length;t+=1){const n=e[t];n.removeAttribute("draggable"),delete n.dataset[xi.DRAGGABLE],delete n.dataset[xi.DISPLAY_LABEL],delete n.dataset[xi.VARIANT],delete n.dataset[Ote],delete n.dataset[Fte],n.querySelector(`.${qt.ANNOTATION_CARET_ANCHOR}`)?.remove()}}#t(e){if(e.querySelector(`.${qt.ANNOTATION_CARET_ANCHOR}`))return;const t=e.dataset[xi.PM_END],n=e.dataset[xi.LAYOUT_EPOCH];if(t==null)return;const r=this.#e?.ownerDocument;if(!r)return;const o=r.createElement("span");o.dataset[xi.PM_START]=t,o.dataset[xi.PM_END]=t,o.dataset[xi.LAYOUT_EPOCH]=n??"",o.classList.add(qt.ANNOTATION_CARET_ANCHOR),o.style.position="absolute",o.style.left="100%",o.style.top="0",o.style.width="0",o.style.height="1em",o.style.overflow="hidden",o.style.pointerEvents="none",o.style.userSelect="none",o.style.opacity="0",o.textContent="​",e.style.position||(e.style.position="relative"),e.appendChild(o)}},Hte="imageInteractionEpoch";function rGe(e){return e&&e.trim().length>0?e:null}function oGe(e){const t=[],n=new Set,r=o=>{!o||n.has(o)||(n.add(o),t.push(o))};for(const o of Array.from(e.querySelectorAll(`.${qt.IMAGE_FRAGMENT}`)))!o.hasAttribute("data-image-metadata")&&o.querySelector?.("[data-image-metadata]")==null||r(o);for(const o of Array.from(e.querySelectorAll(`.${qt.INLINE_IMAGE_CLIP_WRAPPER}`)))o.querySelector?.("[data-image-metadata]")!=null&&r(o);for(const o of Array.from(e.querySelectorAll(`.${qt.INLINE_IMAGE}`)))o.hasAttribute("data-image-metadata")&&o.closest(`.${qt.INLINE_IMAGE_CLIP_WRAPPER}`)==null&&r(o);return t}function GWn(e){const t=e.dataset[xi.DISPLAY_LABEL];if(t)return t;const n=e.tagName==="IMG"?e:e.querySelector("img"),r=n?.getAttribute("alt")?.trim();if(r)return r;const o=n?.getAttribute("title")?.trim();return o||(e.getAttribute("data-block-id")??e.getAttribute("data-sd-block-id")??"Image")}function WWn(e){return e.classList.contains(qt.IMAGE_FRAGMENT)?"block":"inline"}function jWn(e){return e.closest("[data-behind-doc-section]")?.dataset.behindDocSection??null}function qWn(e,t){const n=jWn(e);return n?n===t:!0}function iGe(e){e.removeAttribute("draggable"),delete e.dataset.dragSourceKind,delete e.dataset.imageKind,delete e.dataset.nodeType,delete e.dataset.displayLabel,delete e.dataset[Hte]}var KWn=class{#e=null;setContainer(e){this.#e=e}apply(e,t={}){if(!this.#e)return;const n=String(e);for(const r of oGe(this.#e)){if(!qWn(r,t.activeHeaderFooterMode??"body")){iGe(r);continue}if(r.dataset[Hte]===n)continue;const o=rGe(r.dataset.pmStart),i=rGe(r.dataset.pmEnd);!o||!i||(r.dataset[Hte]=n,r.draggable=!0,r.dataset.dragSourceKind="existingImage",r.dataset.imageKind=WWn(r),r.dataset.nodeType="image",r.dataset.displayLabel=GWn(r),r.dataset.pmStart=o,r.dataset.pmEnd=i)}}clear(){if(this.#e)for(const e of oGe(this.#e))iGe(e)}},sGe=".superdoc-structured-content__label",aGe=`.${qt.INLINE_SDT_WRAPPER}__label`,zte="structuredContentInteractionEpoch",YWn=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=Array.from(this.#e.querySelectorAll(`${sGe}, ${aGe}`));for(const n of t){if(n.dataset[zte]===String(e))continue;const r=n.closest(`.${qt.BLOCK_SDT}, .${qt.INLINE_SDT_WRAPPER}`);if(!r?.dataset.sdtId||!r.dataset.pmStart||!r.dataset.pmEnd)continue;const o=r.dataset.lockMode??"unlocked";if(o!=="unlocked"){n.draggable=!1;continue}const i=r.dataset.sdtScope??(r.classList.contains(qt.BLOCK_SDT)?"block":"inline"),s=n.textContent?.trim()||"Structured content";n.dataset[zte]=String(e),n.draggable=!0,n.dataset.dragSourceKind="structuredContent",n.dataset.sdtId=r.dataset.sdtId,n.dataset.pmStart=r.dataset.pmStart,n.dataset.pmEnd=r.dataset.pmEnd,n.dataset.sdtScope=i,n.dataset.lockMode=o,n.dataset[xi.DISPLAY_LABEL]=s,n.dataset.nodeType=i==="block"?"structuredContentBlock":"structuredContent"}}clear(){if(!this.#e)return;const e=Array.from(this.#e.querySelectorAll(`${sGe}, ${aGe}`));for(const t of e)t.removeAttribute("draggable"),delete t.dataset.dragSourceKind,delete t.dataset.sdtId,delete t.dataset.pmStart,delete t.dataset.pmEnd,delete t.dataset.sdtScope,delete t.dataset.lockMode,delete t.dataset.nodeType,delete t.dataset[xi.DISPLAY_LABEL],delete t.dataset[zte]}};const Al={SPELLING:"sd-proofing-spelling",GRAMMAR:"sd-proofing-grammar",STYLE:"sd-proofing-style",DATA_ATTR:"data-sd-proofing",SPLIT_ATTR:"data-sd-proofing-split"};function lGe(e){switch(e){case"spelling":return Al.SPELLING;case"grammar":return Al.GRAMMAR;case"style":return Al.STYLE}}var cGe=new WeakMap;function XWn(e,t,n,r){const o=new Set;o.add(e),o.add(t);for(const a of r){const l=Math.max(a.pmFrom,e),c=Math.min(a.pmTo,t);l>e&&o.add(l),c<t&&o.add(c)}const i=Array.from(o).sort((a,l)=>a-l),s=[];for(let a=0;a<i.length-1;a+=1){const l=i[a],c=i[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=lGe(p.kind);break}s.push({textStart:u,textEnd:f,pmStart:l,pmEnd:c,proofingClass:h})}return s}function JWn(e,t,n){const r=e.parentNode;if(!r)return[];const o=e.ownerDocument,i=[];for(const l of t){const c=n.slice(l.textStart,l.textEnd);if(c.length===0)continue;const u=o.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(Al.SPLIT_ATTR,""),u.setAttribute(Al.DATA_ATTR,""),u.textContent="",u.appendChild(o.createTextNode(c)),cGe.set(u,e),i.push(u)}e.style.display="none",e.setAttribute(Al.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 i)r.insertBefore(l,e);return i}function ZWn(e){const t=Array.from(e.querySelectorAll(`[${Al.SPLIT_ATTR}]`));if(t.length===0)return!1;const n=new Map;for(const i of t){const s=cGe.get(i);if(!s)continue;const a=n.get(s);a?a.push(i):n.set(s,[i])}for(const[i,s]of n){const a=i.parentNode;if(a){uGe(i);for(const l of s)a.removeChild(l)}}const r=Array.from(e.querySelectorAll(`[${Al.SPLIT_ATTR}]`));for(const i of r)i.parentNode?.removeChild(i);const o=Array.from(e.querySelectorAll(`[${Al.DATA_ATTR}="original"]`));for(const i of o)uGe(i);return!0}function uGe(e){e.style.display="",e.style.cssText||e.removeAttribute("style"),e.removeAttribute(Al.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 QWn(e,t){const n=Ute(e);if(t.length===0)return n;const r=[...t].sort((s,a)=>s.pmFrom-a.pmFrom),o=Array.from(e.querySelectorAll("[data-pm-start][data-pm-end]"));let i=!1;for(const s of o){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||!$Wn(s))continue;const c=ejn(r,a,l);if(c.length===0)continue;const u=s.textContent??"";if(u.length===0)continue;if(tjn(a,l,c)){s.classList.add(lGe(c[0].kind)),s.setAttribute(Al.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),i=!0;continue}const d=XWn(a,l,u,c);if(d.length>1){JWn(s,d,u),i=!0;continue}d.length===1&&d[0].proofingClass&&(s.classList.add(d[0].proofingClass),s.setAttribute(Al.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),i=!0)}return i||n}function Ute(e){let t=!1;const n=ZWn(e),r=Array.from(e.querySelectorAll(`[${Al.DATA_ATTR}]`));for(const o of r)o.classList.remove(Al.SPELLING,Al.GRAMMAR,Al.STYLE),o.removeAttribute(Al.DATA_ATTR),o.removeAttribute("aria-invalid"),t=!0;return t||n}function $Wn(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 ejn(e,t,n){const r=[];for(const o of e){if(o.pmFrom>=n)break;o.pmTo>t&&r.push(o)}return r}function tjn(e,t,n){return n.some(r=>r.pmFrom<=e&&r.pmTo>=t)}var njn=class{#e=null;setContainer(e){this.#e=e}applyAnnotations(e){const t=this.#e;return t?!e||e.length===0?Ute(t):QWn(t,e):!1}clear(){const e=this.#e;return e?Ute(e):!1}},rjn=class{#e;#t;#o;#n;#r;#i;constructor(e={}){this.#e=e.fieldAnnotationLayer??new VWn,this.#t=e.imageLayer??new KWn,this.#o=e.structuredContentLayer??new YWn,this.#n=e.commentHighlightDecorator??new LWn,this.#r=e.decorationBridge??new zWn,this.#i=e.proofingDecorator??new njn}setContainer(e){this.#e.setContainer(e),this.#t.setContainer(e),this.#o.setContainer(e),this.#n.setContainer(e),this.#i.setContainer(e)}setActiveComment(e){return this.#n.setActiveComment(e)}setActiveTrackChangeIds(e){return this.#n.setActiveTrackChangeIds(e)}recordDecorationTransaction(e){this.#r.recordTransaction(e)}hasDecorationChanges(e){return this.#r.hasChanges(e)}hasCurrentDecorationRanges(e){return this.#r.hasCurrentRanges(e)}collectDecorationRanges(e){return this.#r.collectDecorationRanges(e)}syncDecorations(e,t,n){return e?this.#r.sync(e,t,n):!1}applyCommentHighlights(){this.#n.apply()}syncInlineStyleLayers(e,t){return this.applyCommentHighlights(),this.syncDecorations(e,t)}applyProofingAnnotations(e,t){const n=this.#i.applyAnnotations(e);return n&&t(),n}refreshAfterPaint(e){this.#e.apply(e.layoutEpoch),e.rebuildDomPositionIndex(),this.#t.apply(e.layoutEpoch,{activeHeaderFooterMode:e.activeHeaderFooterMode}),this.#o.apply(e.layoutEpoch),this.syncInlineStyleLayers(e.editorState,e.domPositionIndex),this.applyProofingAnnotations(e.proofingAnnotations,e.rebuildDomPositionIndex),e.reapplyStructuredContentHover?.(),e.reapplyTocGroupHover?.()}destroy(){this.#i.clear(),this.#e.clear(),this.#t.clear(),this.#o.clear(),this.#n.destroy(),this.#r.destroy()}},dGe=class{#e;#t=null;constructor(e){this.handleMouseEnter=t=>{const n=t.target?.closest?.(this.#e.entrySelector);if(!n)return;const r=this.#e.getId(n);r&&this.#o(r)},this.handleMouseLeave=t=>{const n=t.target?.closest?.(this.#e.entrySelector);if(!n)return;const r=this.#e.getId(n);if(!r)return;const o=t.relatedTarget;if(o){const i=o.closest?.(this.#e.entrySelector);if(i&&this.#e.getId(i)===r)return}this.clear()},this.#e=e}reapply(){if(!this.#t)return;const{id:e}=this.#t,t=this.#e.queryGroup(e);if(t.length===0){this.#t=null;return}this.#n(t),this.#e.onApply?.(t),this.#t={id:e,elements:t}}clear(){if(this.#t){for(const e of this.#t.elements)e.classList.remove(this.#e.hoverClass),this.#e.onClear?.(e);this.#t=null}}#o(e){if(this.#t?.id===e)return;this.clear();const t=this.#e.queryGroup(e);t.length!==0&&(this.#n(t),this.#e.onApply?.(t),this.#t={id:e,elements:t})}#n(e){const t=this.#e.shouldApplyTo;for(const n of e)t&&!t(n)||n.classList.add(this.#e.hoverClass)}},ojn=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 o=this.#e.get(r);if(!o)continue;const i=[];for(const s of o){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,i.push(s))}i.length>0?this.#e.set(r,i):this.#e.delete(r)}}replaceBatchResults(e,t,n){for(const r of t){const o=this.#e.get(r);if(!o)continue;const i=o.filter(s=>s.recheckId===null||!e.has(s.recheckId));i.length>0?this.#e.set(r,i):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 o of r)o.kind==="spelling"&&(ijn(o,t)||n.push(o));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 ijn(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 sjn(e,t){const n=ajn(e);if(n)return n;const r=ljn(e);return r||t}function ajn(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 ljn(e){return e.attrs.paragraphProperties?.lang?.val??null}function fGe(e,t,n){const r=[],o=new Map,i=new Map;return cjn(e,(s,a,l)=>{const{text:c,slices:u}=djn(s,a);if(c.length===0)return;const d=mjn(s,a),f=sjn(s,t??null),h=n?.(a);r.push({id:d,text:c,language:f,metadata:{blockId:s.attrs.sdBlockId,pageIndex:h,surface:l}}),o.set(d,{segmentId:d,slices:u}),i.set(d,a)}),{segments:r,offsetMaps:o,segmentPositions:i}}function cjn(e,t){e.descendants((n,r)=>{const o=n.type.name;return o==="header"||o==="footer"?!1:o==="paragraph"?(t(n,r,ujn(e,r)?"table-cell":"body"),!1):!0})}function ujn(e,t){const n=e.resolve(t);for(let r=n.depth;r>0;r--){const o=n.node(r);if(o.type.name==="tableCell"||o.type.name==="tableHeader")return!0}return!1}function djn(e,t){const n=[],r=[];let o=0;const i=t+1;return e.forEach((l,c)=>{s(l,i+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(fjn(l))return;const d=l.text,f=c,h=c+d.length;r.push({textStart:o,textEnd:o+d.length,pmFrom:f,pmTo:h}),n.push(d),o+=d.length;return}if(pjn(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(" "),o+=1)}}function fjn(e){return e.marks?.some(t=>t.type.name==="trackDelete")??!1}var hjn=new Set(["fieldAnnotation","image","equation","hardBreak","lineBreak","tab","footnoteReference","symbol"]);function pjn(e){return hjn.has(e)}function mjn(e,t){const n=e.attrs.sdBlockId;return n?`blk-${n}`:`pos-${t}`}function gjn(e,t){const n=hGe(e.start,t),r=hGe(e.end,t);return n===null||r===null||n>=r?null:{...e,pmFrom:n,pmTo:r}}function hGe(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 yjn(e,t,n){if(n.length===0)return new Set;const r=new Set,o=e.map(i=>({id:i.id,pos:t.get(i.id)??-1})).filter(i=>i.pos>=0).sort((i,s)=>i.pos-s.pos);for(const i of n)for(let s=0;s<o.length;s++){const a=o[s],l=o[s+1]?.pos??1/0;a.pos<i.to&&l>i.from&&r.add(a.id),a.pos<=i.from&&l>=i.from&&s>0&&r.add(o[s-1].id)}return r}function pGe(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 bjn(e,t){const n=t.getVisiblePageIndices();if(!n||n.length===0)return e;const r=new Set(n),o=[],i=[];for(const s of e){const a=s.metadata.pageIndex;a!==void 0&&r.has(a)?o.push(s):i.push(s)}return[...o,...i]}function vjn(e){const t=e.filter(i=>i.kind==="spelling");if(t.length===0)return[];const n=[...t].sort((i,s)=>i.pmFrom-s.pmFrom||i.pmTo-s.pmTo),r=[];let o=null;for(const i of n){if(!o){o={pmFrom:i.pmFrom,pmTo:i.pmTo,kind:"spelling",issue:i};continue}i.pmFrom<=o.pmTo?o.pmTo=Math.max(o.pmTo,i.pmTo):(r.push(o),o={pmFrom:i.pmFrom,pmTo:i.pmTo,kind:"spelling",issue:i})}return o&&r.push(o),r}function wjn(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=n+r>>>1,i=e[o];if(t<i.pmFrom)r=o-1;else if(t>=i.pmTo)n=o+1;else return i}return null}var Ajn=500,Sjn=2e3,Tjn=1e4,Ijn=2,xjn=20,kjn=5,mGe=class{#e;#t=null;#o=null;#n="disabled";#r=new ojn;#i=new Map;#s=new Map;#c=null;#u=new Set;#d=0;#f=0;#p=!1;#a=[];#b=0;#l=!1;#S=0;#T=null;#y=null;#w=null;#v=null;#C=[];constructor(e={}){this.onResultsChanged=null,this.#e={enabled:e.enabled??!1,debounceMs:e.debounceMs??Ajn,maxSuggestions:e.maxSuggestions??kjn,visibleFirst:e.visibleFirst??!0,allowIgnoreWord:e.allowIgnoreWord??!0,defaultLanguage:e.defaultLanguage??null,ignoredWords:e.ignoredWords??[],timeoutMs:e.timeoutMs??Tjn,maxConcurrentRequests:e.maxConcurrentRequests??Ijn,maxSegmentsPerBatch:e.maxSegmentsPerBatch??xjn,onProofingError:e.onProofingError??null,onStatusChange:e.onStatusChange??null},e.provider&&(this.#t=e.provider),this.#e.enabled&&this.#t&&this.#_("idle")}get status(){return this.#n}get isEnabled(){return this.#e.enabled&&this.#t!==null}get config(){return this.#e}setVisibilitySource(e){this.#T=e}setDocumentId(e){this.#y=e}setPageResolver(e){this.#w=e}setComposing(e){this.#l=e,!e&&this.#C.length>0&&this.isEnabled&&this.#h(this.#C)}getPaintSlices(e){if(!this.isEnabled)return[];const t=vjn(this.#r.getDisplayIssues(this.#e.ignoredWords));return e?t.filter(n=>n.pmTo<=e.from||n.pmFrom>=e.to):t}getIssueAtPosition(e,t){return wjn(this.getPaintSlices(t),e)?.issue??null}updateConfig(e,t){const n=this.#e.enabled,r=this.#t,o=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.#o=null),e.enabled!==void 0){if(this.#e.enabled=e.enabled,!e.enabled){this.#A(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#_("disabled"),this.onResultsChanged?.();return}if(e.enabled&&!n&&t){this.#_("idle"),this.#x(t);return}}o&&this.isEnabled&&t&&(this.#A(),this.#f++,this.#r.clear(),this.#s.clear(),this.onResultsChanged?.(),this.#x(t))}onDocumentChanged(e,t,n){if(!this.isEnabled)return;this.#f++,this.#v=e;const{segments:r,offsetMaps:o,segmentPositions:i}=fGe(e,this.#e.defaultLanguage,this.#w??void 0);this.#C=r,this.#i=o;const s=yjn(r,i,t);for(const a of s)this.#s.delete(a);if(s.size>0){const a=this.#b++;this.#r.remapIssues(s,n,a),this.#r.removeOrphanedSegments(new Set(r.map(l=>l.id)))}this.#h(r)}runInitialCheck(e){this.isEnabled&&this.#x(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.#p=!0,this.#A(),this.#r.clear(),this.#i.clear(),this.#s.clear(),this.#v=null,this.#C=[],this.#a=[],this.#t?.dispose?.(),this.#t=null,this.#_("disabled")}#x(e){this.#v=e;const{segments:t,offsetMaps:n}=fGe(e,this.#e.defaultLanguage,this.#w??void 0);this.#C=t,this.#i=n,this.#s.clear(),this.#r.clear(),this.#h(t)}#h(e){if(this.#l)return;this.#c!==null&&clearTimeout(this.#c);const t=Date.now()-this.#S;this.#S>0&&t>=Sjn?this.#m(e):this.#c=setTimeout(()=>{this.#c=null,this.#m(e)},this.#e.debounceMs)}#m(e){this.#S=Date.now(),this.#I(e)}async#I(e){if(this.#p||!this.#t)return;if(!this.#o&&this.#t.getCapabilities)try{this.#o=await this.#t.getCapabilities()}catch{}const t=e.filter(s=>{const a=pGe(s.text);return this.#s.get(s.id)!==a});if(t.length===0){this.#_("idle");return}const n=this.#r.getActiveRecheckIds(),r=this.#e.visibleFirst&&this.#T?bjn(t,this.#T):t,o=this.#M(r),i=this.#f;this.#a=[];for(let s=0;s<o.length;s++){if(this.#p||i!==this.#f)return;if(this.#d>=this.#e.maxConcurrentRequests){for(let a=s;a<o.length;a++)this.#a.push(...o[a]);break}this.#k(o[s],i,n)}}async#k(e,t,n){if(!this.#t||this.#p)return;const r=new AbortController;this.#u.add(r),this.#d++,this.#_("checking");const o=setTimeout(()=>r.abort(),this.#e.timeoutMs),i={documentId:this.#y,defaultLanguage:this.#e.defaultLanguage,maxSuggestions:this.#e.maxSuggestions,segments:e,signal:r.signal};try{const s=await this.#t.check(i);if(clearTimeout(o),!this.#u.delete(r))return;if(this.#d--,t!==this.#f||this.#p){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.#i.get(u.segmentId);if(!d)continue;const f=gjn(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.#s.set(u.id,pGe(u.text));this.#_(this.#d>0?"checking":"idle"),this.onResultsChanged?.(),this.#E(t,n)}catch(s){if(clearTimeout(o),!this.#u.delete(r)||(this.#d--,this.#p))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.#_(this.#d>0?"checking":"degraded"),this.#E(t,n)}}#E(e,t){if(this.#p||e!==this.#f||this.#a.length===0||this.#d>=this.#e.maxConcurrentRequests)return;const n=this.#a.splice(0,this.#e.maxSegmentsPerBatch);n.length>0&&this.#k(n,e,t)}#R(){this.#p||this.#a.length===0||this.#E(this.#f,this.#r.getActiveRecheckIds())}#D(e,t,n){if(!t.has(e.segmentId))return this.#L(`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.#L(`Invalid offsets [${e.start}, ${e.end}) for segment "${e.segmentId}" (length ${r.text.length})`,[e.segmentId]),!1):!0:!1}#L(e,t){this.#e.onProofingError?.({kind:"validation-error",message:e,segmentIds:t})}#M(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}#A(){this.#c!==null&&(clearTimeout(this.#c),this.#c=null);for(const e of this.#u)e.abort();this.#u.clear(),this.#d=0,this.#a=[]}#_(e){this.#n!==e&&(this.#n=e,this.#e.onStatusChange?.(e))}},gGe=20,Qv=500,ry=5e3,Zl=["#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#70AD47"],oy="#595959",z2="#E0E0E0",U2="#333",$6="#666",ju="Calibri, Arial, sans-serif",Cjn="#f8f9fa",Ejn="#dee2e6",yGe="#6c757d",zr="http://www.w3.org/2000/svg",Xn={top:30,right:20,bottom:50,left:60},qu=5;function _jn(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?Ql(e,r,"No chart data"):t.chartType==="barChart"?Wjn(e,r,t,n):t.chartType==="lineChart"||t.chartType==="stockChart"?LGe(e,r,t,n):t.chartType==="areaChart"?zjn(e,r,t,n):t.chartType==="scatterChart"?Djn(e,r,t,n):t.chartType==="bubbleChart"?Ojn(e,r,t,n):t.chartType==="radarChart"?Bjn(e,r,t,n):t.chartType==="pieChart"?NGe(e,r,t,n):t.chartType==="doughnutChart"?Vjn(e,r,t,n):t.chartType==="ofPieChart"?NGe(e,r,t,n):Ql(e,r,`Chart: ${t.chartType}`)}function Ql(e,t,n){t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.background=Cjn,t.style.border=`1px solid ${Ejn}`,t.style.borderRadius="4px",t.style.color=yGe,t.style.fontSize="13px",t.style.fontFamily=ju;const r=e.createElement("span");r.textContent="📊 ",t.appendChild(r);const o=e.createElement("span");return o.textContent=n,t.appendChild(o),t}function eB(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 kI(e){let t=!1,n=e.series;return n.length>gGe&&(n=n.slice(0,gGe),t=!0),n=n.map(r=>r.values.length<=Qv&&r.categories.length<=Qv?r:(t=!0,{name:r.name,categories:r.categories.slice(0,Qv),values:r.values.slice(0,Qv),...r.xValues&&{xValues:r.xValues.slice(0,Qv)},...r.bubbleSizes&&{bubbleSizes:r.bubbleSizes.slice(0,Qv)}})),{series:n,truncated:t}}function Rjn(e,t,n){const r=Math.max(1,e-Xn.left-Xn.right),o=Math.max(1,t-Xn.top-Xn.bottom),i=n.flatMap(m=>m.values),s=Math.max(0,...i),a=Math.min(0,...i),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:o,groupWidth:f,barWidth:Math.max(1,p/d),barGap:h,baselineY:Xn.top+o*(s/l),valueRange:l,minValue:a,maxValue:s}}function Pjn(e,t,n,r){const{groupWidth:o,barGap:i,barWidth:s,baselineY:a,valueRange:l,plotHeight:c}=r;for(let u=0;u<n.length;u++){const d=n[u],f=Zl[u%Zl.length];for(let h=0;h<d.values.length;h++){const p=d.values[h],m=Math.abs(p/l)*c,g=Xn.left+h*o+i+u*s,y=p>=0?a-m:a,b=e.createElementNS(zr,"rect");b.setAttribute("x",String(g)),b.setAttribute("y",String(y)),b.setAttribute("width",String(s)),b.setAttribute("height",String(Math.max(.5,m))),b.setAttribute("fill",f),t.appendChild(b)}}}function Njn(e,t,n){const{plotWidth:r,plotHeight:o,baselineY:i}=n,s=e.createElementNS(zr,"line");s.setAttribute("x1",String(Xn.left)),s.setAttribute("y1",String(Xn.top)),s.setAttribute("x2",String(Xn.left)),s.setAttribute("y2",String(Xn.top+o)),s.setAttribute("stroke",oy),s.setAttribute("stroke-width","1"),t.appendChild(s);const a=e.createElementNS(zr,"line");a.setAttribute("x1",String(Xn.left)),a.setAttribute("y1",String(i)),a.setAttribute("x2",String(Xn.left+r)),a.setAttribute("y2",String(i)),a.setAttribute("stroke",oy),a.setAttribute("stroke-width","1"),t.appendChild(a)}function Ljn(e,t,n,r,o){const{groupWidth:i,plotHeight:s}=r,a=Math.max(1,n.length),l=Math.max(8,Math.min(12,o/a/5));for(let c=0;c<n.length;c++){const u=Xn.left+c*i+i/2,d=e.createElementNS(zr,"text");d.setAttribute("x",String(u)),d.setAttribute("y",String(Xn.top+s+16)),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size",String(l)),d.setAttribute("fill",U2),d.setAttribute("font-family",ju),d.textContent=n[c]??"",t.appendChild(d)}}function Mjn(e,t,n,r){const{plotWidth:o,plotHeight:i,valueRange:s,minValue:a}=n,l=s/qu,c=Math.max(8,Math.min(11,r/30));for(let u=0;u<=qu;u++){const d=a+l*u,f=Xn.top+i-i*(d-a)/s,h=e.createElementNS(zr,"text");if(h.setAttribute("x",String(Xn.left-6)),h.setAttribute("y",String(f+3)),h.setAttribute("text-anchor","end"),h.setAttribute("font-size",String(c)),h.setAttribute("fill",$6),h.setAttribute("font-family",ju),h.textContent=eB(d),t.appendChild(h),u>0&&u<qu){const p=e.createElementNS(zr,"line");p.setAttribute("x1",String(Xn.left)),p.setAttribute("y1",String(f)),p.setAttribute("x2",String(Xn.left+o)),p.setAttribute("y2",String(f)),p.setAttribute("stroke",z2),p.setAttribute("stroke-width","0.5"),t.appendChild(p)}}}function CI(e,t,n,r){const o=r-12;let i=Xn.left;for(let s=0;s<n.length;s++){const a=n[s],l=Zl[s%Zl.length],c=e.createElementNS(zr,"rect");c.setAttribute("x",String(i)),c.setAttribute("y",String(o-8)),c.setAttribute("width","10"),c.setAttribute("height","10"),c.setAttribute("fill",l),t.appendChild(c);const u=e.createElementNS(zr,"text");u.setAttribute("x",String(i+14)),u.setAttribute("y",String(o)),u.setAttribute("font-size","10"),u.setAttribute("fill",U2),u.setAttribute("font-family",ju),u.textContent=a.name,t.appendChild(u),i+=14+a.name.length*6+16}}function iy(e,t,n){const r=e.createElementNS(zr,"text");r.setAttribute("x",String(n-8)),r.setAttribute("y","14"),r.setAttribute("text-anchor","end"),r.setAttribute("font-size","10"),r.setAttribute("fill",yGe),r.setAttribute("font-family",ju),r.textContent="Data truncated for display",t.appendChild(r)}function bGe(e,t,n,r=!1){const o=Math.max(1,e-Xn.left-Xn.right),i=Math.max(1,t-Xn.top-Xn.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=Xn.top+i-i*d,h=Math.max(1,n[0]?.categories?.length??n[0]?.values?.length??1);return{plotWidth:o,plotHeight:i,minValue:a,maxValue:l,valueRange:c,baselineY:f,categoryCount:h}}function EI(e,t){return e.categoryCount<=1?Xn.left+e.plotWidth/2:Xn.left+e.plotWidth*t/(e.categoryCount-1)}function Vte(e,t){return Xn.top+e.plotHeight-(t-e.minValue)/e.valueRange*e.plotHeight}function vGe(e,t,n){const r=e.createElementNS(zr,"line");r.setAttribute("x1",String(Xn.left)),r.setAttribute("y1",String(Xn.top)),r.setAttribute("x2",String(Xn.left)),r.setAttribute("y2",String(Xn.top+n.plotHeight)),r.setAttribute("stroke",oy),r.setAttribute("stroke-width","1"),t.appendChild(r);const o=e.createElementNS(zr,"line");o.setAttribute("x1",String(Xn.left)),o.setAttribute("y1",String(n.baselineY)),o.setAttribute("x2",String(Xn.left+n.plotWidth)),o.setAttribute("y2",String(n.baselineY)),o.setAttribute("stroke",oy),o.setAttribute("stroke-width","1"),t.appendChild(o)}function wGe(e,t,n,r,o){const i=n.length?n:Array.from({length:r.categoryCount},(l,c)=>String(c+1)),s=Math.max(1,i.length),a=Math.max(8,Math.min(12,o/s/4));for(let l=0;l<i.length;l++){const c=e.createElementNS(zr,"text");c.setAttribute("x",String(EI(r,l))),c.setAttribute("y",String(Xn.top+r.plotHeight+16)),c.setAttribute("text-anchor","middle"),c.setAttribute("font-size",String(a)),c.setAttribute("fill",U2),c.setAttribute("font-family",ju),c.textContent=i[l]??"",t.appendChild(c)}}function AGe(e,t,n,r){const o=n.valueRange/qu,i=Math.max(8,Math.min(11,r/30));for(let s=0;s<=qu;s++){const a=n.minValue+o*s,l=Xn.top+n.plotHeight-n.plotHeight*(a-n.minValue)/n.valueRange,c=e.createElementNS(zr,"text");if(c.setAttribute("x",String(Xn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(i)),c.setAttribute("fill",$6),c.setAttribute("font-family",ju),c.textContent=eB(a),t.appendChild(c),s>0&&s<qu){const u=e.createElementNS(zr,"line");u.setAttribute("x1",String(Xn.left)),u.setAttribute("y1",String(l)),u.setAttribute("x2",String(Xn.left+n.plotWidth)),u.setAttribute("y2",String(l)),u.setAttribute("stroke",z2),u.setAttribute("stroke-width","0.5"),t.appendChild(u)}}}function SGe(e){const t=e.values,n=e.xValues?.length?e.xValues:t.map((s,a)=>a+1),r=e.bubbleSizes??[],o=Math.min(n.length,t.length),i=[];for(let s=0;s<o;s++){const a=n[s],l=t[s];if(!Number.isFinite(a)||!Number.isFinite(l))continue;const c=r[s];i.push({x:a,y:l,...Number.isFinite(c)?{size:c}:{}})}return i}function TGe(e,t,n,r=!1){const o=Math.max(1,e-Xn.left-Xn.right),i=Math.max(1,t-Xn.top-Xn.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=Xn.left+o*f,m=Xn.top+i-i*h;return{plotWidth:o,plotHeight:i,minX:s,maxX:a,xRange:u,minY:l,maxY:c,yRange:d,axisX:p,axisY:m}}function IGe(e,t){return Xn.left+(t-e.minX)/e.xRange*e.plotWidth}function xGe(e,t){return Xn.top+e.plotHeight-(t-e.minY)/e.yRange*e.plotHeight}function kGe(e,t,n){const r=e.createElementNS(zr,"line");r.setAttribute("x1",String(n.axisX)),r.setAttribute("y1",String(Xn.top)),r.setAttribute("x2",String(n.axisX)),r.setAttribute("y2",String(Xn.top+n.plotHeight)),r.setAttribute("stroke",oy),r.setAttribute("stroke-width","1"),t.appendChild(r);const o=e.createElementNS(zr,"line");o.setAttribute("x1",String(Xn.left)),o.setAttribute("y1",String(n.axisY)),o.setAttribute("x2",String(Xn.left+n.plotWidth)),o.setAttribute("y2",String(n.axisY)),o.setAttribute("stroke",oy),o.setAttribute("stroke-width","1"),t.appendChild(o)}function CGe(e,t,n,r){const o=Math.max(8,Math.min(11,r/30));for(let i=0;i<=qu;i++){const s=i/qu,a=n.minY+n.yRange*s,l=Xn.top+n.plotHeight-n.plotHeight*s,c=e.createElementNS(zr,"text");if(c.setAttribute("x",String(Xn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(o)),c.setAttribute("fill",$6),c.setAttribute("font-family",ju),c.textContent=eB(a),t.appendChild(c),i>0&&i<qu){const h=e.createElementNS(zr,"line");h.setAttribute("x1",String(Xn.left)),h.setAttribute("y1",String(l)),h.setAttribute("x2",String(Xn.left+n.plotWidth)),h.setAttribute("y2",String(l)),h.setAttribute("stroke",z2),h.setAttribute("stroke-width","0.5"),t.appendChild(h)}const u=n.minX+n.xRange*s,d=Xn.left+n.plotWidth*s,f=e.createElementNS(zr,"text");f.setAttribute("x",String(d)),f.setAttribute("y",String(Xn.top+n.plotHeight+16)),f.setAttribute("text-anchor","middle"),f.setAttribute("font-size",String(o)),f.setAttribute("fill",$6),f.setAttribute("font-family",ju),f.textContent=eB(u),t.appendChild(f)}}function EGe(e,t){const n=e.reduce((a,l)=>a+l.length,0),r=2,o=(qu+1)*2,i=Math.max(0,qu-1),s=t?e.length*2:0;return n+r+o+i+s}function Djn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s.map(SGe),c=l.flat();if(c.length===0)return Ql(e,t,"No chart data");const u=n.legendPosition!==void 0,d=EGe(l,u);if(d>ry)return Ql(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=TGe(o,i,c,!1),h=e.createElementNS(zr,"svg");h.setAttribute("viewBox",`0 0 ${o} ${i}`),h.setAttribute("width","100%"),h.setAttribute("height","100%"),h.style.display="block",kGe(e,h,f),CGe(e,h,f,i);for(let p=0;p<l.length;p++){const m=l[p],g=Zl[p%Zl.length];for(const y of m){const b=e.createElementNS(zr,"circle");b.setAttribute("cx",String(IGe(f,y.x))),b.setAttribute("cy",String(xGe(f,y.y))),b.setAttribute("r","3"),b.setAttribute("fill",g),b.setAttribute("fill-opacity","0.85"),h.appendChild(b)}}return u&&CI(e,h,s,i),a&&iy(e,h,o),t.appendChild(h),t}function Ojn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s.map(SGe),c=l.flat();if(c.length===0)return Ql(e,t,"No chart data");const u=n.legendPosition!==void 0,d=EGe(l,u);if(d>ry)return Ql(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=TGe(o,i,c,!1),h=c.map(g=>g.size).filter(g=>g!=null&&g>0),p=h.length?Math.max(...h):1,m=e.createElementNS(zr,"svg");m.setAttribute("viewBox",`0 0 ${o} ${i}`),m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.style.display="block",kGe(e,m,f),CGe(e,m,f,i);for(let g=0;g<l.length;g++){const y=l[g],b=Zl[g%Zl.length];for(const v of y){const A=v.size&&v.size>0?v.size:p*.5,S=p>0?4+A/p*10:6,w=e.createElementNS(zr,"circle");w.setAttribute("cx",String(IGe(f,v.x))),w.setAttribute("cy",String(xGe(f,v.y))),w.setAttribute("r",String(Math.max(2,S))),w.setAttribute("fill",b),w.setAttribute("fill-opacity","0.45"),w.setAttribute("stroke",b),w.setAttribute("stroke-width","1"),m.appendChild(w)}}return u&&CI(e,m,s,i),a&&iy(e,m,o),t.appendChild(m),t}function Fjn(e,t,n){const r=4+t,o=t,i=e.reduce((a,l)=>a+1+Math.min(t,l.values.length),0),s=n?e.length*2:0;return r+o+i+s}function Bjn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s[0]?.categories??[],c=Math.max(3,l.length,...s.map(w=>w.values.length)),u=n.legendPosition!==void 0,d=Fjn(s,c,u);if(d>ry)return Ql(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=s.flatMap(w=>w.values).filter(w=>Number.isFinite(w)),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(zr,"svg");g.setAttribute("viewBox",`0 0 ${o} ${i}`),g.setAttribute("width","100%"),g.setAttribute("height","100%"),g.style.display="block";const y=u?34:10,b=Math.max(10,Math.min(o-60,i-y-60)/2),v=o/2,A=Xn.top+(i-Xn.top-y)/2,S=4;for(let w=1;w<=S;w++){const T=b*w/S,x=[];for(let k=0;k<c;k++){const P=-Math.PI/2+k*Math.PI*2/c;x.push(`${v+T*Math.cos(P)},${A+T*Math.sin(P)}`)}const C=e.createElementNS(zr,"polygon");C.setAttribute("points",x.join(" ")),C.setAttribute("fill","none"),C.setAttribute("stroke",z2),C.setAttribute("stroke-width","0.8"),g.appendChild(C)}for(let w=0;w<c;w++){const T=-Math.PI/2+w*Math.PI*2/c,x=v+b*Math.cos(T),C=A+b*Math.sin(T),k=e.createElementNS(zr,"line");k.setAttribute("x1",String(v)),k.setAttribute("y1",String(A)),k.setAttribute("x2",String(x)),k.setAttribute("y2",String(C)),k.setAttribute("stroke",z2),k.setAttribute("stroke-width","0.8"),g.appendChild(k);const P=b+14,E=v+P*Math.cos(T),L=A+P*Math.sin(T),R=e.createElementNS(zr,"text");R.setAttribute("x",String(E)),R.setAttribute("y",String(L)),R.setAttribute("font-size","10"),R.setAttribute("fill",U2),R.setAttribute("font-family",ju),R.setAttribute("text-anchor",Math.abs(Math.cos(T))<.2?"middle":Math.cos(T)>0?"start":"end"),R.textContent=l[w]??`Category ${w+1}`,g.appendChild(R)}for(let w=0;w<s.length;w++){const T=s[w],x=Zl[w%Zl.length],C=[],k=[],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)*b,M=-Math.PI/2+E*Math.PI*2/c,O=v+R*Math.cos(M),H=A+R*Math.sin(M);C.push(`${O},${H}`),k.push({x:O,y:H})}if(C.length>0){const E=e.createElementNS(zr,"polygon");E.setAttribute("points",C.join(" ")),E.setAttribute("fill",x),E.setAttribute("fill-opacity","0.18"),E.setAttribute("stroke",x),E.setAttribute("stroke-width","1.8"),g.appendChild(E)}for(const E of k){const L=e.createElementNS(zr,"circle");L.setAttribute("cx",String(E.x)),L.setAttribute("cy",String(E.y)),L.setAttribute("r","2.5"),L.setAttribute("fill",x),g.appendChild(L)}}return u&&CI(e,g,s,i),a&&iy(e,g,o),t.appendChild(g),t}function _Ge(e,t,n,r){const o=e.reduce((d,f)=>d+f.values.length,0),i=e.length,s=r?o:0,a=2,l=(qu+1)*2,c=t.length,u=n?e.length*2:0;return i+s+a+l+c+u}function RGe(e){let t=!1;const n=Math.min(e.values.length,Qv);e.values.length>n&&(t=!0);const r=[];for(let o=0;o<n;o++){const i=Number(e.values[o]),s=Number.isFinite(i)&&i>0?i:0;r.push({label:e.categories[o]??`Category ${o+1}`,value:s,color:Zl[o%Zl.length]})}return{slices:r,truncated:t}}function Hjn(e,t,n,r,o,i){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(zr,"circle");y.setAttribute("cx",String(r)),y.setAttribute("cy",String(o)),y.setAttribute("r",String(i)),y.setAttribute("fill",l.color),y.setAttribute("stroke","#fff"),y.setAttribute("stroke-width",String(Math.max(1,i*.01))),t.appendChild(y);break}const u=a+c,d=r+i*Math.cos(a),f=o+i*Math.sin(a),h=r+i*Math.cos(u),p=o+i*Math.sin(u),m=c>Math.PI?1:0,g=e.createElementNS(zr,"path");g.setAttribute("d",`M ${r} ${o} L ${d} ${f} A ${i} ${i} 0 ${m} 1 ${h} ${p} Z`),g.setAttribute("fill",l.color),g.setAttribute("stroke","#fff"),g.setAttribute("stroke-width",String(Math.max(1,i*.01))),t.appendChild(g),a=u}}function PGe(e,t,n,r,o){const i=n.reduce((l,c)=>l+14+c.label.length*6+16,0);let s=Math.max(10,(r-i)/2);const a=o-14;for(const l of n){const c=e.createElementNS(zr,"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(zr,"text");u.setAttribute("x",String(s+14)),u.setAttribute("y",String(a)),u.setAttribute("font-size","10"),u.setAttribute("fill",U2),u.setAttribute("font-family",ju),u.textContent=l.label,t.appendChild(u),s+=14+l.label.length*6+16}}function NGe(e,t,n,r){const o=n.series[0];if(!o)return Ql(e,t,"No chart data");const{slices:i,truncated:s}=RGe(o);if(i.reduce((A,S)=>A+S.value,0)<=0)return Ql(e,t,"No chart data");if(i.length*3>ry)return Ql(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=o.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,b=Math.max(8,Math.min(p,m)*.45),v=e.createElementNS(zr,"svg");if(v.setAttribute("viewBox",`0 0 ${a} ${l}`),v.setAttribute("width","100%"),v.setAttribute("height","100%"),v.style.display="block",d){const A=e.createElementNS(zr,"text");A.setAttribute("x",String(g)),A.setAttribute("y","24"),A.setAttribute("text-anchor","middle"),A.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),A.setAttribute("fill",oy),A.setAttribute("font-family",ju),A.textContent=u,v.appendChild(A)}return Hjn(e,v,i,g,y,b),c&&PGe(e,v,i,a,l),s&&iy(e,v,a),t.appendChild(v),t}function LGe(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=_Ge(s,l,c,!0);if(u>ry)return Ql(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=bGe(o,i,s,!1),f=e.createElementNS(zr,"svg");f.setAttribute("viewBox",`0 0 ${o} ${i}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",vGe(e,f,d),AGe(e,f,d,i),wGe(e,f,l,d,o);for(let h=0;h<s.length;h++){const p=s[h],m=Zl[h%Zl.length],g=[];for(let b=0;b<p.values.length;b++){const v=EI(d,b),A=Vte(d,p.values[b]??0);g.push(`${v},${A}`)}if(g.length===0)continue;const y=e.createElementNS(zr,"polyline");y.setAttribute("points",g.join(" ")),y.setAttribute("fill","none"),y.setAttribute("stroke",m),y.setAttribute("stroke-width","2"),f.appendChild(y);for(let b=0;b<p.values.length;b++){const v=e.createElementNS(zr,"circle");v.setAttribute("cx",String(EI(d,b))),v.setAttribute("cy",String(Vte(d,p.values[b]??0))),v.setAttribute("r","2.5"),v.setAttribute("fill",m),f.appendChild(v)}}return c&&CI(e,f,s,i),a&&iy(e,f,o),t.appendChild(f),t}function zjn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=_Ge(s,l,c,!1)+s.length;if(u>ry)return Ql(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=bGe(o,i,s,!0),f=e.createElementNS(zr,"svg");f.setAttribute("viewBox",`0 0 ${o} ${i}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",vGe(e,f,d),AGe(e,f,d,i),wGe(e,f,l,d,o);for(let h=0;h<s.length;h++){const p=s[h];if(p.values.length===0)continue;const m=Zl[h%Zl.length],g=[`M ${EI(d,0)} ${d.baselineY}`];for(let v=0;v<p.values.length;v++)g.push(`L ${EI(d,v)} ${Vte(d,p.values[v]??0)}`);const y=EI(d,Math.max(0,p.values.length-1));g.push(`L ${y} ${d.baselineY} Z`);const b=e.createElementNS(zr,"path");b.setAttribute("d",g.join(" ")),b.setAttribute("fill",m),b.setAttribute("fill-opacity","0.35"),b.setAttribute("stroke",m),b.setAttribute("stroke-width","1.5"),f.appendChild(b)}return c&&CI(e,f,s,i),a&&iy(e,f,o),t.appendChild(f),t}function Ujn(e,t,n,r,o,i,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 w=e.createElementNS(zr,"circle");w.setAttribute("cx",String(r)),w.setAttribute("cy",String(o)),w.setAttribute("r",String((i+s)/2)),w.setAttribute("fill","none"),w.setAttribute("stroke",c.color),w.setAttribute("stroke-width",String(Math.max(1,i-s))),t.appendChild(w);break}const d=l+u,f=r+i*Math.cos(l),h=o+i*Math.sin(l),p=r+i*Math.cos(d),m=o+i*Math.sin(d),g=r+s*Math.cos(l),y=o+s*Math.sin(l),b=r+s*Math.cos(d),v=o+s*Math.sin(d),A=u>Math.PI?1:0,S=e.createElementNS(zr,"path");S.setAttribute("d",`M ${f} ${h} A ${i} ${i} 0 ${A} 1 ${p} ${m} L ${b} ${v} A ${s} ${s} 0 ${A} 0 ${g} ${y} Z`),S.setAttribute("fill",c.color),S.setAttribute("stroke","#fff"),S.setAttribute("stroke-width","1"),t.appendChild(S),l=d}}function Vjn(e,t,n,r){const o=n.series[0];if(!o)return Ql(e,t,"No chart data");const{slices:i,truncated:s}=RGe(o);if(i.reduce((S,w)=>S+w.value,0)<=0)return Ql(e,t,"No chart data");if(i.length*3>ry)return Ql(e,t,"Chart too large");const{width:a,height:l}=r,c=n.legendPosition!==void 0,u=o.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,b=Math.max(8,Math.min(p,m)*.45),v=Math.max(2,b*.58),A=e.createElementNS(zr,"svg");if(A.setAttribute("viewBox",`0 0 ${a} ${l}`),A.setAttribute("width","100%"),A.setAttribute("height","100%"),A.style.display="block",d){const S=e.createElementNS(zr,"text");S.setAttribute("x",String(g)),S.setAttribute("y","24"),S.setAttribute("text-anchor","middle"),S.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),S.setAttribute("fill",oy),S.setAttribute("font-family",ju),S.textContent=u,A.appendChild(S)}return Ujn(e,A,i,g,y,b,v),c&&PGe(e,A,i,a,l),s&&iy(e,A,a),t.appendChild(A),t}function Gjn(e,t,n){const r=e.reduce((l,c)=>l+c.values.length,0),o=2,i=t.length,s=(qu+1)*2,a=n?e.length*2:0;return r+o+i+s+a}function Wjn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=kI(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=Gjn(s,l,c);if(u>ry)return Ql(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=e.createElementNS(zr,"svg");d.setAttribute("viewBox",`0 0 ${o} ${i}`),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.style.display="block";const f=Rjn(o,i,s);return Pjn(e,d,s,f),Njn(e,d,f),Ljn(e,d,l,f,o),Mjn(e,d,f,i),c&&CI(e,d,s,i),a&&iy(e,d,o),t.appendChild(d),t}var tB=96,MGe=25,sy=tB/8;function jjn(e){const t=e.ppi??tB,n=e.heightPx??MGe,{pageSize:r,pageMargins:o}=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(o.left)||o.left<0)throw new Error(`Invalid left margin: ${o.left}. Must be a non-negative finite number.`);if(!Number.isFinite(o.right)||o.right<0)throw new Error(`Invalid right margin: ${o.right}. Must be a non-negative finite number.`);if(o.left+o.right>=r.width)throw new Error(`Invalid margins: left (${o.left}) + right (${o.right}) must be less than page width (${r.width}).`);const i=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+=sy;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=sy;if(s.push({size:"half",height:"40%",x:a}),a+=sy,c<=.5)break;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=sy}return{widthPx:i,heightPx:n,ticks:s,leftMarginPx:o.left*t,rightMarginPx:i-o.right*t,pageWidthInches:r.width}}function qjn(e,t,n,r=tB){return t==="left"?e/r:(n-e)/r}function Kjn(e,t,n,r,o=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(o))throw new Error(`Invalid minContentWidthPx: ${o}. Must be a finite number.`);if(t==="left"){const s=n-o;return Math.max(0,Math.min(s,e))}else{const i=n+o;return Math.max(i,Math.min(r,e))}}function Yjn(e){const t=e.ppi??tB,n=e.heightPx??MGe,{pageWidthPx:r,leftMarginPx:o,rightMarginPx:i}=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(o)||o<0)throw new Error(`Invalid left margin: ${o}px. Must be a non-negative finite number.`);if(!Number.isFinite(i)||i<0)throw new Error(`Invalid right margin: ${i}px. Must be a non-negative finite number.`);if(o+i>=r)throw new Error(`Invalid margins: left (${o}px) + right (${i}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+=sy;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=sy;if(a.push({size:"half",height:"40%",x:l}),l+=sy,u<=.5)break;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=sy}return{widthPx:r,heightPx:n,ticks:a,leftMarginPx:o,rightMarginPx:r-i,pageWidthInches:s}}const As={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 Xjn(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 o=n.createElement("div");o.className=As.ruler,o.style.cssText=`
831
831
  position: relative;
@@ -2136,7 +2136,7 @@ or
2136
2136
  bash: npm install skia-canvas
2137
2137
  js: import "konva/skia-backend";
2138
2138
  `,QZe=()=>{if(typeof document>"u")throw new Error(Xpr)},qf=class lnt{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 lnt(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),o=this.m[0]*n+this.m[2]*r,i=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]=o,this.m[1]=i,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,o=this.m[1]+this.m[3]*n,i=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=i,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],o=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=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]=o,this.m[3]=i,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,o=-this.m[2]*t,i=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]=o,this.m[3]=i,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],o=this.m[3],i=this.m[4],s=this.m[5],a=t*o-n*r,l={x:i,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*o)/a,l.skewY=0}else if(r!=0||o!=0){const c=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/c):-Math.acos(r/c)),l.scaleX=a/c,l.scaleY=c,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=mt._getRotation(l.rotation),l}},Jpr="[object Array]",Zpr="[object Number]",Qpr="[object String]",$pr="[object Boolean]",emr=Math.PI/180,tmr=180/Math.PI,jR="#",nmr="",rmr="0",omr="Konva warning: ",$Ze="Konva error: ",imr="rgb(",oie={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]},smr=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Q8=[],qR=null,amr=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const mt={_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)===Jpr},_isNumber(e){return Object.prototype.toString.call(e)===Zpr&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===Qpr},_isBoolean(e){return Object.prototype.toString.call(e)===$pr},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){Q8.push(e),Q8.length===1&&amr(function(){const t=Q8;Q8=[],t.forEach(function(n){n()})})},createCanvasElement(){QZe();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return QZe(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=mt.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(jR,nmr);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=rmr+e;return jR+e},isCanvasFarblingActive(){if(qR!==null)return qR;if(typeof document>"u")return qR=!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 o=0;o<100;o++)if(n[o*4]!==40||n[o*4+1]!==40||n[o*4+2]!==40||n[o*4+3]!==255){r=!0;break}return qR=r,this.releaseCanvas(e),qR},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),jR+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return jR+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 oie?(t=oie[e],{r:t[0],g:t[1],b:t[2]}):e[0]===jR?this._hexToRgb(e.substring(1)):e.substr(0,4)===imr?(t=smr.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",mt._namedColorToRBA(e)||mt._hex3ColorToRGBA(e)||mt._hex4ColorToRGBA(e)||mt._hex6ColorToRGBA(e)||mt._hex8ColorToRGBA(e)||mt._rgbColorToRGBA(e)||mt._rgbaColorToRGBA(e)||mt._hslColorToRGBA(e)},_namedColorToRBA(e){const t=oie[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,o=Number(n[1])/100,i=Number(n[2])/100;let s,a,l;if(o===0)return l=i*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};i<.5?s=i*(1+o):s=i+o-i*o;const c=2*i-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*emr},radToDeg(e){return e*tmr},_degToRad(e){return mt.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),mt.degToRad(e)},_radToDeg(e){return mt.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),mt.radToDeg(e)},_getRotation(e){return fn.angleDeg?mt.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error($Ze+e)},error(e){console.error($Ze+e)},warn(e){fn.showWarnings&&console.warn(omr+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,o,i){let s,a,l;const c=(e-n)*(e-n)+(t-r)*(t-r);if(c==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const u=((o-e)*(n-e)+(i-t)*(r-t))/c;u<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):u>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+u*(n-e),a=t+u*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=mt.cloneObject(e);let o=Number.MAX_VALUE;return t.forEach(function(i,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=mt._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),c=l[0],u=l[1],d=l[2];d<o&&(r.x=c,r.y=u,o=d)}),r},_prepareArrayForTween(e,t,n){const r=[],o=[];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)o.push({x:t[s],y:t[s+1]});const i=[];return o.forEach(function(s){const a=mt._getProjectionToLine(s,r,n);i.push(a.x),i.push(a.y)}),i},_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||mt._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(mt._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){fn.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let o=t<0?t:0,i=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(o+s,i),e.lineTo(o+t-a,i),e.arc(o+t-a,i+a,a,Math.PI*3/2,0,!1),e.lineTo(o+t,i+n-c),e.arc(o+t-c,i+n-c,c,0,Math.PI/2,!1),e.lineTo(o+l,i+n),e.arc(o+l,i+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(o,i+s),e.arc(o+s,i+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,o){r=Math.abs(r);for(let i=0;i<n;i++){const s=t[(i-1+n)%n],a=t[i],l=t[(i+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 o=="number"?h=o:h=i<o.length?o[i]: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};i===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 lmr(e){const t=[],n=e.length,r=mt;for(let o=0;o<n;o++){let i=e[o];r._isNumber(i)?i=Math.round(i*1e3)/1e3:r._isString(i)||(i=i+""),t.push(i)}return t}var eQe=",",cmr="(",umr=")",dmr="([",fmr="])",hmr=";",pmr="()",mmr="=",tQe=["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"],gmr=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],ymr=100,$8=null;function nQe(){if($8!==null)return $8;try{const e=mt.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:($8=!1,!1)}catch{return $8=!1,!1}}var e9=class{constructor(e){this.canvas=e,fn.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,o="",i,s,a,l;for(i=0;i<r;i++)s=n[i],a=s.method,a?(l=s.args,o+=a,e?o+=pmr:mt._isArray(l[0])?o+=dmr+l.join(eQe)+fmr:(t&&(l=l.map(c=>typeof c=="number"?Math.floor(c):c)),o+=cmr+l.join(eQe)+umr)):(o+=s.property,e||(o+=mmr+s.val)),o+=hmr;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=ymr&&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,o,i){this._context.arc(e,t,n,r,o,i)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,i){this._context.bezierCurveTo(e,t,n,r,o,i)}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,o,i){return this._context.createRadialGradient(e,t,n,r,o,i)}drawImage(e,t,n,r,o,i,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,o):c.length===9&&u.drawImage(e,t,n,r,o,i,s,a,l)}ellipse(e,t,n,r,o,i,s,a){this._context.ellipse(e,t,n,r,o,i,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,o){this._context.roundRect(e,t,n,r,o)}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,o,i){this._context.setTransform(e,t,n,r,o,i)}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,o,i){this._context.transform(e,t,n,r,o,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=tQe.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=lmr(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:o}),l}};for(r=0;r<t;r++)i(tQe[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)}};gmr.forEach(function(e){Object.defineProperty(e9.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var bmr=class extends e9{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 o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const i=e.getFillRadialGradientColorStops();if(i&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):i&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let i=0;i<r.length;i+=2)o.addColorStop(r[i],r[i+1]);this.setAttr("strokeStyle",o)}}_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 o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(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",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(c),Math.abs(u))),this.setAttr("shadowOffsetX",s.x*c),this.setAttr("shadowOffsetY",s.y*u)}},vmr=class extends e9{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 o=this.getCanvas().getPixelRatio();this.setTransform(o,0,0,o,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()}}},t9;function wmr(){if(t9)return t9;const e=mt.createCanvasElement(),t=e.getContext("2d");return t9=(function(){return(fn._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),mt.releaseCanvas(e),t9}var iie=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||fn.pixelRatio||wmr(),this._canvas=mt.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 mt.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},Sy=class extends iie{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new bmr(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},sie=class extends iie{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new vmr(this),this.setSize(e.width,e.height)}};const Jo={get isDragging(){let e=!1;return Jo._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Jo._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Jo._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=mt._getFirstPointerId(e));const s=i._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=o.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,n),t.push(o)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Jo._dragElements.forEach(n=>{const{node:r}=n,o=r.getStage();if(e&&o.setPointersPositions(e),!o._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Jo.justDragged=!0,fn._mouseListenClick=!1,fn._touchListenClick=!1,fn._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof fn.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Jo._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Jo._dragElements.delete(n)})}};fn.isBrowser&&(window.addEventListener("mouseup",Jo._endDragBefore,!0),window.addEventListener("touchend",Jo._endDragBefore,!0),window.addEventListener("touchcancel",Jo._endDragBefore,!0),window.addEventListener("mousemove",Jo._drag),window.addEventListener("touchmove",Jo._drag),window.addEventListener("mouseup",Jo._endDragAfter,!1),window.addEventListener("touchend",Jo._endDragAfter,!1),window.addEventListener("touchcancel",Jo._endDragAfter,!1));function Ty(e){return mt._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||mt._isBoolean(e)?e:Object.prototype.toString.call(e)}function rQe(e){return e>255?255:e<0?0:Math.round(e)}function ln(){if(fn.isUnminified)return function(e,t){return mt._isNumber(e)||mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function n9(e){if(fn.isUnminified)return function(t,n){let r=mt._isNumber(t),o=mt._isArray(t)&&t.length==e;return!r&&!o&&mt.warn(Ty(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function aie(){if(fn.isUnminified)return function(e,t){return mt._isNumber(e)||e==="auto"||mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function bw(){if(fn.isUnminified)return function(e,t){return mt._isString(e)||mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function oQe(){if(fn.isUnminified)return function(e,t){const n=mt._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function Amr(){if(fn.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(mt._isArray(e)?e.forEach(function(r){mt._isNumber(r)||mt.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Kf(){if(fn.isUnminified)return function(e,t){return e===!0||e===!1||mt.warn(Ty(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function Smr(e){if(fn.isUnminified)return function(t,n){return t==null||mt.isObject(t)||mt.warn(Ty(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var KR="get",YR="set";const $e={addGetterSetter(e,t,n,r,o){$e.addGetter(e,t,n),$e.addSetter(e,t,r,o),$e.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=KR+mt._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const o=this.attrs[t];return o===void 0?n:o}},addSetter(e,t,n,r){const o=YR+mt._capitalize(t);e.prototype[o]||$e.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=YR+mt._capitalize(t);e.prototype[o]=function(i){return n&&i!==void 0&&i!==null&&(i=n.call(this,i,t)),this._setAttr(t,i),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,o){const i=n.length,s=mt._capitalize,a=KR+s(t),l=YR+s(t);e.prototype[a]=function(){const u={};for(let d=0;d<i;d++){const f=n[d];u[f]=this.getAttr(t+s(f))}return u};const c=Smr(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),o&&o.call(this),this},$e.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=mt._capitalize(t),r=YR+n,o=KR+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){mt.error("Adding deprecated "+t);const o=KR+mt._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){mt.error(i);const s=this.attrs[t];return s===void 0?n:s},$e.addSetter(e,t,r,function(){mt.error(i)}),$e.addOverloadedGetterSetter(e,t)},backCompat(e,t){mt.each(t,function(n,r){const o=e.prototype[r],i=KR+mt._capitalize(n),s=YR+mt._capitalize(n);function a(){o.apply(this,arguments),mt.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[i]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function Tmr(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,o]=n;switch(r){case"blur":{const i=parseFloat(o.replace("px",""));return function(s){this.blurRadius(i*.5);const a=fn.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const i=o.includes("%")?parseFloat(o)/100:parseFloat(o);return function(s){this.brightness(i);const a=fn.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const i=parseFloat(o);return function(s){const a=100*(Math.sqrt(i)-1);this.contrast(a);const l=fn.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=fn.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=fn.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=fn.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:mt.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var r9="absoluteOpacity",iQe="allEventListeners",Km="absoluteTransform",sQe="absoluteScale",vw="canvas",Imr="Change",xmr="children",kmr="konva",lie="listening",Cmr="mouseenter",Emr="mouseleave",_mr="pointerenter",Rmr="pointerleave",Pmr="touchenter",Nmr="touchleave",aQe="set",lQe="Shape",o9=" ",cQe="stage",Iy="transform",Lmr="Stage",cie="visible",Mmr=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(o9),Dmr=1,pn=class OP{constructor(t){this._id=Dmr++,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===Iy||t===Km)&&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===Iy||t===Km)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const o=n.map(i=>i+"Change.konva").join(o9);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(vw)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Km&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(vw)){const{scene:t,filter:n,hit:r}=this._cache.get(vw);mt.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(vw)}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 o=Math.ceil(n.width||r.width),i=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(!o||!i){mt.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;o+=c*2+f,i+=c*2+h,a-=c,l-=c;const p=new Sy({pixelRatio:s,width:o,height:i}),m=new Sy({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),g=new sie({pixelRatio:d,width:o,height:i}),y=p.getContext(),b=g.getContext(),v=new Sy({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),A=v.getContext();return g.isCache=!0,p.isCache=!0,this._cache.delete(vw),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),y.save(),b.save(),A.save(),y.translate(-a,-l),b.translate(-a,-l),A.translate(-a,-l),v.x=a,v.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(r9),this._clearSelfAndDescendantCache(sQe),this.drawScene(p,this,v),this.drawHit(g,this),this._isUnderCache=!1,y.restore(),b.restore(),u&&(y.save(),y.beginPath(),y.rect(0,0,o,i),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),mt.releaseCanvas(v._canvas),this._cache.set(vw,{scene:p,filter:m,hit:g,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(vw)}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 o=1/0,i=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(c){const u=l.point(c);o===void 0&&(o=s=u.x,i=a=u.y),o=Math.min(o,u.x),i=Math.min(i,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}),{x:o,y:i,width:s-o,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),o=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/o,r.height/o),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,o=n.filter,i=o.getContext(),s,a,l,c;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let u=!0;for(let f=0;f<t.length;f++)if(typeof t[f]=="string"&&nQe(),typeof t[f]!="string"||!nQe()){u=!1;break}const d=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),u){const f=t.join(" ");return i.save(),i.setAttr("filter",f),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)c=t[l],typeof c=="string"&&(c=Tmr(c)),c.call(this,a),i.putImageData(a,0,0)}catch(f){mt.error("Unable to apply filter. "+f.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(iQe),t.length===3)return this._delegate.apply(this,t);const o=n.split(o9);for(let i=0;i<o.length;i++){const s=o[i].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(o9),o=r.length,i,s,a,l,c,u;if(this._cache&&this._cache.delete(iQe),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],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 o=this;return this.on(t,function(i){const s=i.target.findAncestors(n,!0,o);for(let a=0;a<s.length;a++)i=mt.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Jo._dragElements.delete(this._id),Jo._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Jo._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Km),this._clearSelfAndDescendantCache(r9),this._clearSelfAndDescendantCache(sQe),this._clearSelfAndDescendantCache(cQe),this._clearSelfAndDescendantCache(cie),this._clearSelfAndDescendantCache(lie)}_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"+mt._capitalize(t);return mt._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!==xmr&&(r=aQe+mt._capitalize(n),mt._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(lie,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(cie,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 o=!1;Jo._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!fn.hitOnDragEnabled&&(o||fn.isTransforming());return this.isListening()&&this.isVisible()&&!i}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,o,i,s,a;function l(u){for(o=[],i=u.length,s=0;s<i;s++)a=u[s],r++,a.nodeType!==lQe&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const c=this.getStage();return n.nodeType!==Lmr&&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(Iy),this._clearSelfAndDescendantCache(Km)),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 o=this.getAbsoluteTransform(t).getMatrix(),i=new qf,s=this.offset();return i.m=o.slice(),i.translate(s.x,s.y),i.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...o}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(Iy);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(o),this.setPosition({x:t.x,y:t.y}),this._clearCache(Iy),this._clearSelfAndDescendantCache(Km),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,o=this.x(),i=this.y();return n!==void 0&&(o+=n),r!==void 0&&(i+=r),this.setPosition({x:o,y:i}),this}_eachAncestorReverse(t,n){let r=[],o=this.getParent(),i,s;if(!(n&&n._id===this._id)){for(r.unshift(this);o&&(!n||o._id!==n._id);)r.unshift(o),o=o.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return mt.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 mt.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 mt.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 mt.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 mt.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&mt.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(r9,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,o,i,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=mt.isObject(r)&&!mt._isPlainObject(r)&&!mt._isArray(r),!s&&(o=typeof this[n]=="function"&&this[n],delete t[n],i=o?o.call(this):null,t[n]=r,i!==r&&(a.attrs[n]=r));return mt._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const o=[];n&&this._isMatch(t)&&o.push(this);let i=this.parent;for(;i;){if(i===r)return o;i._isMatch(t)&&o.push(i),i=i.parent}return o}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,o,i;for(o=0;o<r;o++)if(i=n[o],mt.isValidSelector(i)||(mt.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),mt.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),mt.warn("Konva is awesome, right?")),i.charAt(0)==="#"){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)==="."){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(cQe,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(Km,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new qf,this._eachAncestorReverse(function(r){const o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(Km)||new qf,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 o=this.attrs.x||0,i=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(o-s,i-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(Iy,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(Iy)||new qf;r.reset();const o=this.x(),i=this.y(),s=fn.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(o!==0||i!==0)&&r.translate(o,i),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=mt.cloneObject(this.attrs),r,o,i,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(o=this.eventListeners[r],i=o.length,s=0;s<i;s++)a=o[s],a.name.indexOf(kmr)<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(),o=t.x!==void 0?t.x:Math.floor(n.x),i=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new Sy({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 Sy({width:a.width/a.pixelRatio+Math.abs(o),height:a.height/a.pixelRatio+Math.abs(i),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(o||i)&&l.translate(-1*o,-1*i),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,o=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(o),o}toImage(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,mt._urlToImage(this.toDataURL(t),function(i){n(i),o?.(i)})}catch(o){r(o)}})}toBlob(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,this.toCanvas(t).toBlob(i=>{n(i),o?.(i)},t?.mimeType,t?.quality)}catch(o){r(o)}})}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():fn.dragDistance}_off(t,n,r){let o=this.eventListeners[t],i,s,a;for(i=0;i<o.length;i++)if(s=o[i].name,a=o[i].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(o.splice(i,1),o.length===0){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,n,r){this._fire(t+Imr,{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[aQe+mt._capitalize(t)];return mt._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(fn.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!mt.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 o;r!==void 0&&(o=this.attrs[t],o||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,o,r))}_fireAndBubble(t,n,r){n&&this.nodeType===lQe&&(n.target=this);const o=[Cmr,Emr,_mr,Rmr,Pmr,Nmr];if(!(o.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const i=o.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!i&&(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:o}=this,i=OP.protoListenerMap.get(o)||{};let s=i?.[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)}i[t]=s,OP.protoListenerMap.set(o,i)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const i=r.slice();for(let s=0;s<i.length;s++)i[s].handler.call(this,n)}const o=this.eventListeners[t];if(o){const i=o.slice(),s=i.length;for(let l=0;l<i.length;l++)i[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(),o=this.getAbsolutePosition();if(!r)return;const i=r._getPointerById(n)||r._changedPointerPositions[0]||o;Jo._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-o.x,y:i.y-o.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Jo._dragElements.has(this._id)||this._createDragElement(t);const r=Jo._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 o={x:r.x-n.offset.x,y:r.y-n.offset.y};const i=this.dragBoundFunc();if(i!==void 0){const s=i.call(this,o,t);s?o=s:mt.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==o.x||this._lastPos.y!==o.y)&&(this.setAbsolutePosition(o),this._requestDraw()),this._lastPos=o}stopDrag(t){const n=Jo._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Jo._endDragBefore(t),Jo._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Jo._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||fn.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Jo._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=Jo._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Jo._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 mt.haveIntersection(r,this.getClientRect())}static create(t,n){return mt._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=OP.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),fn[r]||(mt.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=fn[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(OP._createNode(o[a]));return i}};pn.protoListenerMap=new Map,pn.prototype.nodeType="Node",pn.prototype._attrsAffectingSize=[],pn.prototype.eventListeners={},pn.prototype.on(Mmr,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Iy),this._clearSelfAndDescendantCache(Km)}),pn.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(cie)}),pn.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(lie)}),pn.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(r9)});var Fi=$e.addGetterSetter;Fi(pn,"zIndex"),Fi(pn,"absolutePosition"),Fi(pn,"position"),Fi(pn,"x",0,ln()),Fi(pn,"y",0,ln()),Fi(pn,"globalCompositeOperation","source-over",bw()),Fi(pn,"opacity",1,ln()),Fi(pn,"name","",bw()),Fi(pn,"id","",bw()),Fi(pn,"rotation",0,ln()),$e.addComponentsGetterSetter(pn,"scale",["x","y"]),Fi(pn,"scaleX",1,ln()),Fi(pn,"scaleY",1,ln()),$e.addComponentsGetterSetter(pn,"skew",["x","y"]),Fi(pn,"skewX",0,ln()),Fi(pn,"skewY",0,ln()),$e.addComponentsGetterSetter(pn,"offset",["x","y"]),Fi(pn,"offsetX",0,ln()),Fi(pn,"offsetY",0,ln()),Fi(pn,"dragDistance",void 0,ln()),Fi(pn,"width",0,ln()),Fi(pn,"height",0,ln()),Fi(pn,"listening",!0,Kf()),Fi(pn,"preventDefault",!0,Kf()),Fi(pn,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Fi(pn,"visible",!0,Kf()),Fi(pn,"transformsEnabled","all",bw()),Fi(pn,"size"),Fi(pn,"dragBoundFunc"),Fi(pn,"draggable",!1,Kf()),$e.backCompat(pn,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var $u=class extends pn{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 o=r._isMatch(e);return o&&n.push(r),!!(o&&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=pn.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=pn.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(),o=e||r&&r.getCanvas(),i=o&&o.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=o&&o.isCache;if(!this.isVisible()&&!l)return this;if(a){i.save();const c=this.getAbsoluteTransform(t).getMatrix();i.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",o,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),i=this._getCanvasCache();if(i&&i.hit){o.save();const s=this.getAbsoluteTransform(t).getMatrix();o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var o;const i=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){i.save();const f=this.getAbsoluteTransform(n);let h=f.getMatrix();i.transform(h[0],h[1],h[2],h[3],h[4],h[5]),i.beginPath();let p;if(l)p=l.call(this,i,this);else{const m=this.clipX(),g=this.clipY();i.rect(m||0,g||0,s,a)}i.clip.apply(i,p),h=f.copy().invert().getMatrix(),i.transform(h[0],h[1],h[2],h[3],h[4],h[5])}const d=!u&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(f){f[e](t,n,r)}),d&&i.restore(),c&&i.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let o,i,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||(o===void 0?(o=h.x,i=h.y,s=h.x+h.width,a=h.y+h.height):(o=Math.min(o,h.x),i=Math.min(i,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&&o!==void 0?l={x:o,y:i,width:s-o,height:a-i}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};$e.addComponentsGetterSetter($u,"clip",["x","y","width","height"]),$e.addGetterSetter($u,"clipX",void 0,ln()),$e.addGetterSetter($u,"clipY",void 0,ln()),$e.addGetterSetter($u,"clipWidth",void 0,ln()),$e.addGetterSetter($u,"clipHeight",void 0,ln()),$e.addGetterSetter($u,"clipFunc");var XR=new Map,uQe=fn._global.PointerEvent!==void 0;function uie(e){return XR.get(e)}function die(e){return{evt:e,pointerId:e.pointerId}}function dQe(e,t){return XR.get(e)===t}function fQe(e,t){JR(e),t.getStage()&&(XR.set(e,t),uQe&&t._fire("gotpointercapture",die(new PointerEvent("gotpointercapture"))))}function JR(e,t){const n=XR.get(e);if(!n)return;const r=n.getStage();r&&r.content,XR.delete(e),uQe&&n._fire("lostpointercapture",die(new PointerEvent("lostpointercapture")))}var Omr="Stage",Fmr="string",hQe="px",Bmr="mouseout",pQe="mouseleave",mQe="mouseover",gQe="mouseenter",yQe="mousemove",bQe="mousedown",vQe="mouseup",ZR="pointermove",QR="pointerdown",fx="pointerup",$R="pointercancel",Hmr="lostpointercapture",i9="pointerout",eP="pointerleave",s9="pointerover",a9="pointerenter",fie="contextmenu",wQe="touchstart",AQe="touchend",SQe="touchmove",TQe="touchcancel",hie="wheel",zmr=5,Umr=[[gQe,"_pointerenter"],[bQe,"_pointerdown"],[yQe,"_pointermove"],[vQe,"_pointerup"],[pQe,"_pointerleave"],[wQe,"_pointerdown"],[SQe,"_pointermove"],[AQe,"_pointerup"],[TQe,"_pointercancel"],[mQe,"_pointerover"],[hie,"_wheel"],[fie,"_contextmenu"],[QR,"_pointerdown"],[ZR,"_pointermove"],[fx,"_pointerup"],[$R,"_pointercancel"],[eP,"_pointerleave"],[Hmr,"_lostpointercapture"]],pie={mouse:{[i9]:Bmr,[eP]:pQe,[s9]:mQe,[a9]:gQe,[ZR]:yQe,[QR]:bQe,[fx]:vQe,[$R]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[i9]:"touchout",[eP]:"touchleave",[s9]:"touchover",[a9]:"touchenter",[ZR]:SQe,[QR]:wQe,[fx]:AQe,[$R]:TQe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[i9]:i9,[eP]:eP,[s9]:s9,[a9]:a9,[ZR]:ZR,[QR]:QR,[fx]:fx,[$R]:$R,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},tP=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",hx=e=>{const t=tP(e);if(t==="pointer")return fn.pointerEventsEnabled&&pie.pointer;if(t==="touch")return pie.touch;if(t==="mouse")return pie.mouse};function IQe(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&mt.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var Vmr="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 nP=[];var l9=class extends $u{constructor(e){super(IQe(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),nP.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{IQe(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||mt.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===Fmr){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"),$u.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&mt._isInDocument(e)&&this.container().removeChild(e);const t=nP.indexOf(this);return t>-1&&nP.splice(t,1),mt.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}:(mt.warn(Vmr),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 Sy({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(o){if(!o.isVisible())return;const i=o._toKonvaCanvas(e);n.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const o=t[r].getIntersection(e);if(o)return o}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+hQe,this.content.style.height=t+hQe),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>zmr&&mt.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(),fn.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return dQe(e,this)}setPointerCapture(e){fQe(e,this)}releaseCapture(e){JR(e,this)}getLayers(){return this.children}_bindContentEvents(){fn.isBrowser&&Umr.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=hx(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=hx(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=hx(e.type),n=tP(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(fn.isDragging()||fn.isTransforming())||fn.hitOnDragEnabled;r&&o?(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):o&&(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=hx(e.type),n=tP(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Jo.justDragged=!1,fn["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}fn.capturePointerEventsEnabled&&i.setPointerCapture(o.id),this[n+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const s=e.type.indexOf("touch")>=0;i.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=hx(e.type),n=tP(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(fn.isDragging()&&Jo.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(fn.isDragging()||fn.isTransforming())||fn.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=uie(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(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!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)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=hx(e.type),n=tP(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],i={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=uie(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const c=a.id,u={evt:e,pointerId:c};let d=!1;fn["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Jo.justDragged||(fn["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){fn["_"+n+"InDblClickWindow"]=!1},fn.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...u}),fn["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...u}),d&&o&&o===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),fn["_"+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}),fn["_"+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(fie,{evt:e}):this._fire(fie,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(hie,{evt:e}):this._fire(hie,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=uie(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(fx,die(e)),JR(e.pointerId)}_lostpointercapture(e){JR(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,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.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:mt._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:mt._getFirstPointerId(e)}])}_setPointerPosition(e){mt.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 Sy({width:this.width(),height:this.height()}),this.bufferHitCanvas=new sie({pixelRatio:1,width:this.width(),height:this.height()}),!fn.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 mt.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}};l9.prototype.nodeType=Omr,Is(l9),$e.addGetterSetter(l9,"container"),fn.isBrowser&&document.addEventListener("visibilitychange",()=>{nP.forEach(e=>{e.batchDraw()})});var xQe="hasShadow",kQe="shadowRGBA",CQe="patternImage",EQe="linearGradient",_Qe="radialGradient",c9;function mie(){return c9||(c9=mt.createCanvasElement().getContext("2d"),c9)}const rP={};function Gmr(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function Wmr(e){e.stroke()}function jmr(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function qmr(e){e.stroke()}function Kmr(){this._clearCache(xQe)}function Ymr(){this._clearCache(kQe)}function Xmr(){this._clearCache(CQe)}function Jmr(){this._clearCache(EQe)}function Zmr(){this._clearCache(_Qe)}var Qt=class extends pn{constructor(e){super(e);let t,n=0;for(;t=mt.getHitColor(),!(t&&!(t in rP));)if(n++,n>=1e4){mt.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=mt.getRandomColor();break}this.colorKey=t,rP[t]=this}getContext(){return mt.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return mt.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(xQe,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(CQe,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=mie().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new qf;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(fn.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(EQe,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=mie(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}_getRadialGradient(){return this._getCache(_Qe,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=mie(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}getShadowRGBA(){return this._getCache(kQe,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=mt.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 pn.prototype.destroy.call(this),delete rP[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(),o=this.getAbsoluteOpacity()!==1;if(n&&r&&o)return!0;const i=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&i&&s)}setStrokeHitEnabled(e){mt.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,o=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=i.width+s,l=i.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)+i.x,y:-(s/2+p)+Math.min(d,0)+i.y};return r?m:this._transformedRect(m,o)}drawScene(e,t,n){const r=this.getLayer(),o=(e||r.getCanvas()).getContext(),i=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const c=t===this;if(!this.isVisible()&&!c)return this;if(i){o.save();const u=this.getAbsoluteTransform(t).getMatrix();return o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.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&&o._applyShadow(this),c||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(u._canvas,u.x||0,u.y||0,u.width/h,u.height/h)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!c){const u=this.getAbsoluteTransform(t).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}a&&o._applyShadow(this),s.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),o=e||r.hitCanvas,i=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||mt.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){i.save();const c=this.getAbsoluteTransform(t).getMatrix();return i.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const c=this.getAbsoluteTransform(t).getMatrix();i.transform(c[0],c[1],c[2],c[3],c[4],c[5])}return s.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),i=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,i,s);try{const a=o.getImageData(0,0,i,s),l=a.data,c=l.length,u=mt._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;o.putImageData(a,0,0)}catch(a){mt.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return dQe(e,this)}setPointerCapture(e){fQe(e,this)}releaseCapture(e){JR(e,this)}};Qt.prototype._fillFunc=Gmr,Qt.prototype._strokeFunc=Wmr,Qt.prototype._fillFuncHit=jmr,Qt.prototype._strokeFuncHit=qmr,Qt.prototype._centroid=!1,Qt.prototype.nodeType="Shape",Is(Qt),Qt.prototype.eventListeners={},Qt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Kmr),Qt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",Ymr),Qt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",Xmr),Qt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",Jmr),Qt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",Zmr),$e.addGetterSetter(Qt,"stroke",void 0,oQe()),$e.addGetterSetter(Qt,"strokeWidth",2,ln()),$e.addGetterSetter(Qt,"fillAfterStrokeEnabled",!1),$e.addGetterSetter(Qt,"hitStrokeWidth","auto",aie()),$e.addGetterSetter(Qt,"strokeHitEnabled",!0,Kf()),$e.addGetterSetter(Qt,"perfectDrawEnabled",!0,Kf()),$e.addGetterSetter(Qt,"shadowForStrokeEnabled",!0,Kf()),$e.addGetterSetter(Qt,"lineJoin"),$e.addGetterSetter(Qt,"lineCap"),$e.addGetterSetter(Qt,"miterLimit"),$e.addGetterSetter(Qt,"sceneFunc"),$e.addGetterSetter(Qt,"hitFunc"),$e.addGetterSetter(Qt,"dash"),$e.addGetterSetter(Qt,"dashOffset",0,ln()),$e.addGetterSetter(Qt,"shadowColor",void 0,bw()),$e.addGetterSetter(Qt,"shadowBlur",0,ln()),$e.addGetterSetter(Qt,"shadowOpacity",1,ln()),$e.addComponentsGetterSetter(Qt,"shadowOffset",["x","y"]),$e.addGetterSetter(Qt,"shadowOffsetX",0,ln()),$e.addGetterSetter(Qt,"shadowOffsetY",0,ln()),$e.addGetterSetter(Qt,"fillPatternImage"),$e.addGetterSetter(Qt,"fill",void 0,oQe()),$e.addGetterSetter(Qt,"fillPatternX",0,ln()),$e.addGetterSetter(Qt,"fillPatternY",0,ln()),$e.addGetterSetter(Qt,"fillLinearGradientColorStops"),$e.addGetterSetter(Qt,"strokeLinearGradientColorStops"),$e.addGetterSetter(Qt,"fillRadialGradientStartRadius",0),$e.addGetterSetter(Qt,"fillRadialGradientEndRadius",0),$e.addGetterSetter(Qt,"fillRadialGradientColorStops"),$e.addGetterSetter(Qt,"fillPatternRepeat","repeat"),$e.addGetterSetter(Qt,"fillEnabled",!0),$e.addGetterSetter(Qt,"strokeEnabled",!0),$e.addGetterSetter(Qt,"shadowEnabled",!0),$e.addGetterSetter(Qt,"dashEnabled",!0),$e.addGetterSetter(Qt,"strokeScaleEnabled",!0),$e.addGetterSetter(Qt,"fillPriority","color"),$e.addComponentsGetterSetter(Qt,"fillPatternOffset",["x","y"]),$e.addGetterSetter(Qt,"fillPatternOffsetX",0,ln()),$e.addGetterSetter(Qt,"fillPatternOffsetY",0,ln()),$e.addComponentsGetterSetter(Qt,"fillPatternScale",["x","y"]),$e.addGetterSetter(Qt,"fillPatternScaleX",1,ln()),$e.addGetterSetter(Qt,"fillPatternScaleY",1,ln()),$e.addComponentsGetterSetter(Qt,"fillLinearGradientStartPoint",["x","y"]),$e.addComponentsGetterSetter(Qt,"strokeLinearGradientStartPoint",["x","y"]),$e.addGetterSetter(Qt,"fillLinearGradientStartPointX",0),$e.addGetterSetter(Qt,"strokeLinearGradientStartPointX",0),$e.addGetterSetter(Qt,"fillLinearGradientStartPointY",0),$e.addGetterSetter(Qt,"strokeLinearGradientStartPointY",0),$e.addComponentsGetterSetter(Qt,"fillLinearGradientEndPoint",["x","y"]),$e.addComponentsGetterSetter(Qt,"strokeLinearGradientEndPoint",["x","y"]),$e.addGetterSetter(Qt,"fillLinearGradientEndPointX",0),$e.addGetterSetter(Qt,"strokeLinearGradientEndPointX",0),$e.addGetterSetter(Qt,"fillLinearGradientEndPointY",0),$e.addGetterSetter(Qt,"strokeLinearGradientEndPointY",0),$e.addComponentsGetterSetter(Qt,"fillRadialGradientStartPoint",["x","y"]),$e.addGetterSetter(Qt,"fillRadialGradientStartPointX",0),$e.addGetterSetter(Qt,"fillRadialGradientStartPointY",0),$e.addComponentsGetterSetter(Qt,"fillRadialGradientEndPoint",["x","y"]),$e.addGetterSetter(Qt,"fillRadialGradientEndPointX",0),$e.addGetterSetter(Qt,"fillRadialGradientEndPointY",0),$e.addGetterSetter(Qt,"fillPatternRotation",0),$e.addGetterSetter(Qt,"fillRule",void 0,bw()),$e.backCompat(Qt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Qmr="beforeDraw",$mr="draw",RQe=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],egr=RQe.length,ww=class extends $u{constructor(e){super(e),this.canvas=new Sy,this.hitCanvas=new sie({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(){pn.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(!pn.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(pn.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(pn.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 pn.prototype.remove.call(this),e&&e.parentNode&&mt._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"&&mt.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(),pn.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(){mt.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){mt.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,mt.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<egr;r++){const o=RQe[r],i=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),s=i.shape;if(s)return s;if(n=!!i.antialiased,!i.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 o=rP[mt.getHitColorKey(n[0],n[1],n[2])];return o?{shape:o}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas();return this._fire(Qmr,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),$u.prototype.drawScene.call(this,o,t,n),this._fire($mr,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),$u.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){mt.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return mt.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 mt.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};ww.prototype.nodeType="Layer",Is(ww),$e.addGetterSetter(ww,"imageSmoothingEnabled",!0),$e.addGetterSetter(ww,"clearBeforeDraw",!0),$e.addGetterSetter(ww,"hitGraphEnabled",!0,Kf());var gie=class extends ww{constructor(e){super(e),this.listening(!1),mt.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};gie.prototype.nodeType="FastLayer",Is(gie);var px=class extends $u{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&mt.throw("You may only add groups and shapes to groups.")}};px.prototype.nodeType="Group",Is(px);var yie=(function(){return yw.performance&&yw.performance.now?function(){return yw.performance.now()}:function(){return new Date().getTime()}})(),mx=class Dx{constructor(t,n){this.id=Dx.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:yie(),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 o=0;o<r;o++)if(n[o]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Dx.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=yie(),Dx._addAnimation(this),this}stop(){return Dx._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,o=r.length;for(let i=0;i<o;i++)if(r[i].id===n){this.animations.splice(i,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const o=n[r],i=o.layers,s=o.func;o._updateFrameObject(yie());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let c=0;c<a;c++){const u=i[c];u._id!==void 0&&(t[u._id]=u)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Dx;t.animations.length?(t._runFrames(),mt.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,mt.requestAnimFrame(this._animationLoop))}};mx.animations=[],mx.animIdCounter=0,mx.animRunning=!1;var tgr={node:1,duration:1,easing:1,onFinish:1,yoyo:1},ngr=1,PQe=2,NQe=3,LQe=["fill","stroke","shadowColor"],rgr=0,ogr=class{constructor(e,t,n,r,o,i,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=i,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=o-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=PQe,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=NQe,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===PQe?this.setTime(e):this.state===NQe&&this.setTime(this.duration-e)}pause(){this.state=ngr,this.fire("onPause")}getTimer(){return new Date().getTime()}},u9=class Xs{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||oP.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=rgr++;const c=r.getLayer()||(r instanceof fn.Stage?r.getLayers():null);c||mt.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new mx(function(){n.tween.onEnterFrame()},c),this.tween=new ogr(l,function(u){n._tweenFunc(u)},i,0,1,a*1e3,s),this._addListeners(),Xs.attrs[o]||(Xs.attrs[o]={}),Xs.attrs[o][this._id]||(Xs.attrs[o][this._id]={}),Xs.tweens[o]||(Xs.tweens[o]={});for(l in t)tgr[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,o=r._id;let i,s,a,l,c;const u=Xs.tweens[o][t];u&&delete Xs.attrs[o][u][t];let d=r.getAttr(t);if(mt._isArray(n))if(i=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=mt._prepareArrayForTween(d,n,r.closed())):(a=n,n=mt._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let f=0;f<s;f++)if(f%2===0)i.push(n[f]-d[f]);else{const h=mt.colorToRGBA(d[f]);c=mt.colorToRGBA(n[f]),d[f]=h,i.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++)i.push(n[f]-d[f]);else LQe.indexOf(t)!==-1?(d=mt.colorToRGBA(d),c=mt.colorToRGBA(n),i={r:c.r-d.r,g:c.g-d.g,b:c.b-d.b,a:c.a-d.a}):i=n-d;Xs.attrs[o][this._id][t]={start:d,diff:i,end:n,trueEnd:a,trueStart:l},Xs.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=Xs.attrs[n._id][this._id];let o,i,s,a,l,c,u,d;for(o in r){if(i=r[o],s=i.start,a=i.diff,d=i.end,mt._isArray(s))if(l=[],u=Math.max(s.length,d.length),o.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 LQe.indexOf(o)!==-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(o,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=Xs.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=Xs.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=Xs.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete Xs.tweens[t][o];delete Xs.attrs[t][n],Xs.tweens[t]&&(Object.keys(Xs.tweens[t]).length===0&&delete Xs.tweens[t],Object.keys(Xs.attrs[t]).length===0&&delete Xs.attrs[t])}};u9.attrs={},u9.tweens={},pn.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new u9(e).play()};const oP={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 o=1.70158;return(e/=r/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+t:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+t},ElasticEaseIn(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t)},ElasticEaseOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),o*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/i)+n+t)},ElasticEaseInOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r/2)===2?t+n:(i||(i=r*(.3*1.5)),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),e<1?-.5*(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i)*.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-oP.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?oP.BounceEaseIn(e*2,0,n,r)*.5+t:oP.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}},MQe=mt._assign(fn,{Util:mt,Transform:qf,Node:pn,Container:$u,Stage:l9,stages:nP,Layer:ww,FastLayer:gie,Group:px,DD:Jo,Shape:Qt,shapes:rP,Animation:mx,Tween:u9,Easings:oP,Context:e9,Canvas:iie});var Ym=class extends Qt{_sceneFunc(e){const t=fn.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=fn.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),i=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=o*(o>0?e:t),c=i*(i>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}}};Ym.prototype._centroid=!0,Ym.prototype.className="Arc",Ym.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Is(Ym),$e.addGetterSetter(Ym,"innerRadius",0,ln()),$e.addGetterSetter(Ym,"outerRadius",0,ln()),$e.addGetterSetter(Ym,"angle",0,ln()),$e.addGetterSetter(Ym,"clockwise",!1,Kf());function bie(e,t,n,r,o,i,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2)),c=s*a/(a+l),u=s*l/(a+l);return[n-c*(o-e),r-c*(i-t),n+u*(o-e),r+u*(i-t)]}function DQe(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=bie(e[o-2],e[o-1],e[o],e[o+1],e[o+2],e[o+3],t);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(e[o]),r.push(e[o+1]),r.push(i[2]),r.push(i[3]))}return r}function igr(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 o=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(o!==0){const i=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=i*i-4*o*s;if(a>=0){const l=Math.sqrt(a);n.push((-i+l)/(2*o)),n.push((-i-l)/(2*o))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(o=>{const i=1-r;return i*i*i*o[0]+3*i*i*r*o[1]+3*i*r*r*o[2]+r*r*r*o[3]}))}var Xm=class extends Qt{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(),o=this.closed(),i=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=o?0:4,o||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++]);o||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(i)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]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():DQe(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=bie(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=bie(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=DQe(e,n);return[r[2],r[3]].concat(i).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[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],...igr(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],o=e[1],i,s;for(let a=0;a<e.length/2;a++)i=e[a*2],s=e[a*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);return{x:t,y:r,width:n-t,height:o-r}}};Xm.prototype.className="Line",Xm.prototype._attrsAffectingSize=["points","bezier","tension"],Is(Xm),$e.addGetterSetter(Xm,"closed",!1),$e.addGetterSetter(Xm,"bezier",!1),$e.addGetterSetter(Xm,"tension",0,ln()),$e.addGetterSetter(Xm,"points",[],Amr());const sgr=[[],[],[-.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]],agr=[[],[],[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]],lgr=[[1],[1,1],[1,2,1],[1,3,3,1]],OQe=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*sgr[20][a]+s,r+=agr[20][a]*cgr(e,t,o);return s*r},FQe=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],o=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+o*o),l=4*(r*i+o*s),c=i*i+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 cgr(e,t,n){const r=vie(1,n,e),o=vie(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var vie=(e,t,n)=>{const r=n.length-1;let o,i;if(r===0)return 0;if(e===0){i=0;for(let s=0;s<=r;s++)i+=lgr[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return i}else{o=new Array(r);for(let s=0;s<r;s++)o[s]=r*(n[s+1]-n[s]);return vie(e-1,t,o)}};const BQe=(e,t,n)=>{let r=1,o=e/t,i=(e-n(o))/t,s=0;for(;r>.001;){const a=n(o+i),l=Math.abs(e-a)/t;if(l<r)r=l,o+=i;else{const c=n(o-i),u=Math.abs(e-c)/t;u<r?(r=u,o-=i):i/=2}if(s++,s>500)break}return o};var Kd=class Su extends Qt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Su.parsePathData(this.data()),this.pathLength=Su.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let o=0;o<n.length;o++){const i=n[o].command,s=n[o].points;switch(i){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=Su.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=Su.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=Su.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],o=t[1],i=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)||(o=Math.min(o,a),i=Math.max(i,a));return{x:n,y:o,width:r-n,height:i-o}}getLength(){return this.pathLength}getPointAtLength(t){return Su.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,o){return Math.sqrt((r-t)*(r-t)+(o-n)*(o-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,o=0,i=n.length;if(!i)return null;for(;o<i&&t>n[o].pathLength;)t-=n[o].pathLength,++o;if(o===i)return r=n[o-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[o].command==="M"?(r=n[o].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[o].start.x,y:n[o].start.y};const s=n[o],a=s.points;switch(s.command){case"L":return Su.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Su.getPointOnCubicBezier(BQe(t,Su.getPathLength(n),m=>OQe([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 Su.getPointOnQuadraticBezier(BQe(t,Su.getPathLength(n),m=>FQe([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,Su.getPointOnEllipticalArc(l,c,u,d,p,h)}return null}static getPointOnLine(t,n,r,o,i,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,o,i);if(l<1e-10)return{x:n,y:r};if(o===n)return{x:s,y:a+(i>r?t:-t)};const c=(i-r)/(o-n),u=Math.sqrt(t*t/(1+c*c))*(o<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)*(o-n)+(a-r)*(i-r))/(l*l),h=n+f*(o-n),p=r+f*(i-r),m=this.getLineLength(s,a,h,p),g=Math.sqrt(t*t-m*m),y=Math.sqrt(g*g/(1+c*c))*(o<n?-1:1),b=c*y;return{x:h+y,y:p+b}}static getPointOnCubicBezier(t,n,r,o,i,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)+o*f(t)+n*h(t),y:c*u(t)+a*d(t)+i*f(t)+r*h(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,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)+o*c(t)+n*u(t),y:a*l(t)+i*c(t)+r*u(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),c={x:r*Math.cos(i),y:o*Math.sin(i)};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 o=n.split("|"),i=[],s=[];let a=0,l=0;const c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let u;for(let d=1;d<o.length;d++){let f=o[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 b=s[g];if(b==="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(b)){p.push(parseInt(b[0],10)),p.push(parseInt(b[1],10)),p.push(parseFloat(b.slice(2))),m+=3,m>=7&&(m-=7);continue}if(b==="11"||b==="10"||b==="01"){p.push(parseInt(b[0],10)),p.push(parseInt(b[1],10)),m+=2,m>=7&&(m-=7);continue}if(b==="0"||b==="1"){p.push(parseInt(b,10)),m+=1,m>=7&&(m-=7);continue}}else if(m===4){if(/^[01]\d+(?:\.\d+)?$/.test(b)){p.push(parseInt(b[0],10)),p.push(parseFloat(b.slice(1))),m+=2,m>=7&&(m-=7);continue}if(b==="0"||b==="1"){p.push(parseInt(b,10)),m+=1,m>=7&&(m-=7);continue}}const v=parseFloat(b);isNaN(v)?p.push(0):p.push(v),m+=1,m>=7&&(m-=7)}else{const v=parseFloat(b);isNaN(v)?p.push(0):p.push(v)}}for(;p.length>0&&!isNaN(p[0]);){let g="",y=[];const b=a,v=l;let A,S,w,T,x,C,k,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(),M=p.shift();if(a+=R,l+=M,g="M",i.length>2&&i[i.length-1].command==="z"){for(let O=i.length-2;O>=0;O--)if(i[O].command==="M"){a=i[O].points[0]+R,l=i[O].points[1]+M;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":S=a,w=l,A=i[i.length-1],A.command==="C"&&(S=a+(a-A.points[2]),w=l+(l-A.points[3])),y.push(S,w,p.shift(),p.shift()),a=p.shift(),l=p.shift(),g="C",y.push(a,l);break;case"s":S=a,w=l,A=i[i.length-1],A.command==="C"&&(S=a+(a-A.points[2]),w=l+(l-A.points[3])),y.push(S,w,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":S=a,w=l,A=i[i.length-1],A.command==="Q"&&(S=a+(a-A.points[0]),w=l+(l-A.points[1])),a=p.shift(),l=p.shift(),g="Q",y.push(S,w,a,l);break;case"t":S=a,w=l,A=i[i.length-1],A.command==="Q"&&(S=a+(a-A.points[0]),w=l+(l-A.points[1])),a+=p.shift(),l+=p.shift(),g="Q",y.push(S,w,a,l);break;case"A":T=p.shift(),x=p.shift(),C=p.shift(),k=p.shift(),P=p.shift(),E=a,L=l,a=p.shift(),l=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(E,L,a,l,k,P,T,x,C);break;case"a":T=p.shift(),x=p.shift(),C=p.shift(),k=p.shift(),P=p.shift(),E=a,L=l,a+=p.shift(),l+=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(E,L,a,l,k,P,T,x,C);break}i.push({command:g||h,points:y,start:{x:b,y:v},pathLength:this.calcLength(b,v,g||h,y)})}(h==="z"||h==="Z")&&i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,o){let i,s,a,l;const c=Su;switch(r){case"L":return c.getLineLength(t,n,o[0],o[1]);case"C":return OQe([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return FQe([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const u=o[4],d=o[5],f=o[4]+d;let h=Math.PI/180;if(Math.abs(u-f)<h&&(h=Math.abs(u-f)),s=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],u,0),d<0)for(l=u-h;l>f;l-=h)a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=u+h;l<f;l+=h)a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=c.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],f,0),i+=c.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,c){const u=c*(Math.PI/180),d=Math.cos(u)*(t-r)/2+Math.sin(u)*(n-o)/2,f=-1*Math.sin(u)*(t-r)/2+Math.cos(u)*(n-o)/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)));i===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,b=(n+o)/2+Math.sin(u)*m+Math.cos(u)*g,v=function(k){return Math.sqrt(k[0]*k[0]+k[1]*k[1])},A=function(k,P){return(k[0]*P[0]+k[1]*P[1])/(v(k)*v(P))},S=function(k,P){return(k[0]*P[1]<k[1]*P[0]?-1:1)*Math.acos(A(k,P))},w=S([1,0],[(d-m)/a,(f-g)/l]),T=[(d-m)/a,(f-g)/l],x=[(-1*d-m)/a,(-1*f-g)/l];let C=S(T,x);return A(T,x)<=-1&&(C=Math.PI),A(T,x)>=1&&(C=0),s===0&&C>0&&(C=C-2*Math.PI),s===1&&C<0&&(C=C+2*Math.PI),[y,b,a,l,w,C,u,s]}};Kd.prototype.className="Path",Kd.prototype._attrsAffectingSize=["data"],Is(Kd),$e.addGetterSetter(Kd,"data");var Aw=class extends Xm{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());const i=this.pointerLength(),s=n.length;let a,l;if(o){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=Kd.calcLength(r[r.length-4],r[r.length-3],"C",d),h=Kd.getPointOnQuadraticBezier(Math.min(1,1-i/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(-i,u/2),e.lineTo(-i,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(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(-i,u/2),e.lineTo(-i,-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}}};Aw.prototype.className="Arrow",Is(Aw),$e.addGetterSetter(Aw,"pointerLength",10,ln()),$e.addGetterSetter(Aw,"pointerWidth",10,ln()),$e.addGetterSetter(Aw,"pointerAtBeginning",!1),$e.addGetterSetter(Aw,"pointerAtEnding",!0);var gx=class extends Qt{_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)}};gx.prototype._centroid=!0,gx.prototype.className="Circle",gx.prototype._attrsAffectingSize=["radius"],Is(gx),$e.addGetterSetter(gx,"radius",0,ln());var xy=class extends Qt{_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)}};xy.prototype.className="Ellipse",xy.prototype._centroid=!0,xy.prototype._attrsAffectingSize=["radiusX","radiusY"],Is(xy),$e.addComponentsGetterSetter(xy,"radius",["x","y"]),$e.addGetterSetter(xy,"radiusX",0,ln()),$e.addGetterSetter(xy,"radiusY",0,ln());var Yf=class cnt extends Qt{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(),o=this.cornerRadius(),i=this.attrs.image;let s;if(i){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[i,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[i,0,0,n,r]}(this.hasFill()||this.hasStroke()||o)&&(t.beginPath(),o?mt.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),i&&(o&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),o=this.cornerRadius();t.beginPath(),o?mt.drawRoundedRectPath(t,n,r,o):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 o=mt.createImageElement();o.onload=function(){n(new cnt({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};Yf.prototype.className="Image",Yf.prototype._attrsAffectingSize=["image"],Is(Yf),$e.addGetterSetter(Yf,"cornerRadius",0,n9(4)),$e.addGetterSetter(Yf,"image"),$e.addComponentsGetterSetter(Yf,"crop",["x","y","width","height"]),$e.addGetterSetter(Yf,"cropX",0,ln()),$e.addGetterSetter(Yf,"cropY",0,ln()),$e.addGetterSetter(Yf,"cropWidth",0,ln()),$e.addGetterSetter(Yf,"cropHeight",0,ln());var HQe=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],ugr="Change.konva",dgr="none",wie="up",Aie="right",Sie="down",Tie="left",fgr=HQe.length,Iie=class extends px{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<fgr;n++)e.on(HQe[n]+ugr,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,o,i,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),i=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,o){case wie:s=n/2,a=-1*l;break;case Aie:s=n+i,a=r/2;break;case Sie:s=n/2,a=r+l;break;case Tie:s=-1*i,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};Iie.prototype.className="Label",Is(Iie);var Sw=class extends Qt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),i=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===wie&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+o)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===Aie&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===Sie&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),r===Tie&&(e.lineTo(0,(n+i)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-i)/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(),o=this.pointerDirection(),i=this.width(),s=this.height();return o===wie?(t-=r,s+=r):o===Sie?s+=r:o===Tie?(e-=n*1.5,i+=n):o===Aie&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};Sw.prototype.className="Tag",Is(Sw),$e.addGetterSetter(Sw,"pointerDirection",dgr),$e.addGetterSetter(Sw,"pointerWidth",0,ln()),$e.addGetterSetter(Sw,"pointerHeight",0,ln()),$e.addGetterSetter(Sw,"cornerRadius",0,n9(4));var iP=class extends Qt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?mt.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};iP.prototype.className="Rect",Is(iP),$e.addGetterSetter(iP,"cornerRadius",0,n9(4));var ky=class extends Qt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)mt.drawRoundedPolygonPath(e,t,r,n,o);else{e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].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,o=e[0].y;return e.forEach(i=>{t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y)}),{x:t,y:r,width:n-t,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};ky.prototype.className="RegularPolygon",ky.prototype._centroid=!0,ky.prototype._attrsAffectingSize=["radius"],Is(ky),$e.addGetterSetter(ky,"radius",0,ln()),$e.addGetterSetter(ky,"sides",0,ln()),$e.addGetterSetter(ky,"cornerRadius",0,n9(4));var zQe=Math.PI*2,Tw=class extends Qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,zQe,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),zQe,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)}};Tw.prototype.className="Ring",Tw.prototype._centroid=!0,Tw.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Is(Tw),$e.addGetterSetter(Tw,"innerRadius",0,ln()),$e.addGetterSetter(Tw,"outerRadius",0,ln());var hp=class extends Qt{constructor(e){super(e),this._updated=!0,this.anim=new mx(()=>{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,o=this.animations()[t],i=this.frameOffsets(),s=o[r+0],a=o[r+1],l=o[r+2],c=o[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(i){const d=i[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,o=this.animations()[t],i=this.frameOffsets(),s=o[r+2],a=o[r+3];if(e.beginPath(),i){const l=i[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)}};hp.prototype.className="Sprite",Is(hp),$e.addGetterSetter(hp,"animation"),$e.addGetterSetter(hp,"animations"),$e.addGetterSetter(hp,"frameOffsets"),$e.addGetterSetter(hp,"image"),$e.addGetterSetter(hp,"frameIndex",0,ln()),$e.addGetterSetter(hp,"frameRate",17,ln()),$e.backCompat(hp,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Cy=class extends Qt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let o=1;o<r*2;o++){const i=o%2===0?n:t,s=i*Math.sin(o*Math.PI/r),a=-1*i*Math.cos(o*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)}};Cy.prototype.className="Star",Cy.prototype._centroid=!0,Cy.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Is(Cy),$e.addGetterSetter(Cy,"numPoints",5,ln()),$e.addGetterSetter(Cy,"innerRadius",0,ln()),$e.addGetterSetter(Cy,"outerRadius",0,ln());function Ey(e){return[...e].reduce((t,n,r,o)=>{if(/\p{Emoji}/u.test(n)){const i=o[r+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(n+i),o[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(o[r+1]||""))?t.push(n+o[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 yx="auto",hgr="center",UQe="inherit",sP="justify",pgr="Change.konva",VQe="2d",GQe="-",WQe="left",mgr="text",ggr="Text",ygr="top",bgr="bottom",jQe="middle",qQe="normal",vgr="px ",d9=" ",wgr="right",KQe="rtl",Agr="word",Sgr="char",YQe="none",xie="…",XQe=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Tgr=XQe.length,aP=null;function Igr(){if(aP!==null)return aP;aP=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(VQe);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){aP=!0;break}}}catch{}return aP}function xgr(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 f9;function kie(){return f9||(f9=mt.createCanvasElement().getContext(VQe),f9)}function kgr(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Cgr(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Egr(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Xi=class extends Qt{constructor(e){super(Egr(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<Tgr;t++)this.on(XQe[t]+pgr,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,o=r.length;if(!this.text())return;let i=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(),b=g.indexOf("underline")!==-1,v=g.indexOf("line-through")!==-1,A;c=c===UQe?e.direction:c;let S=a/2,w=jQe;if(!fn.legacyTextRendering){const T=this.measureSize("M");w="alphabetic",S=(((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===KQe&&e.setAttr("direction",c),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",w),e.setAttr("textAlign",WQe),l===jQe?u=(this.getHeight()-o*a-i*2)/2:l===bgr&&(u=this.getHeight()-o*a-i*2),e.translate(i,u+i),A=0;A<o;A++){let T=0,x=0;const C=r[A],k=C.text,P=C.width,E=C.lastInParagraph;if(e.save(),d===wgr?T+=f-P-i*2:d===hgr&&(T+=(f-P-i*2)/2),b){e.save(),e.beginPath();const R=y??(fn.legacyTextRendering?Math.round(s/2):Math.round(s/4)),M=T,O=S+x+R;e.moveTo(M,O);const H=d===sP&&!E?f-i*2:P;e.lineTo(M+Math.round(H),O),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}const L=T;if(c!==KQe&&(h!==0||d===sP||p)){const R=k.split(" ").length-1,M=Ey(k);for(let O=0;O<M.length;O++){const H=M[O];if(H===" "&&!E&&d===sP&&(T+=(f-i*2-P)/R),this._partialTextX=T,this._partialTextY=S+x,this._partialText=H,p){e.save();const W=r.slice(0,A).reduce((G,U)=>G+Ey(U.text).length,0);p({char:H,index:O+W,x:T,y:S+x,lineIndex:A,column:O,isLastInLine:E,width:this.measureSize(H).width,context:e})}e.fillStrokeShape(this),p&&e.restore(),T+=this.measureSize(H).width+h}}else h!==0&&e.setAttr("letterSpacing",`${h}px`),this._partialTextX=T,this._partialTextY=S+x,this._partialText=k,e.fillStrokeShape(this);if(v){e.save(),e.beginPath();const R=fn.legacyTextRendering?0:-Math.round(s/4),M=L;e.moveTo(M,S+x+R);const O=d===sP&&!E?f-i*2:P;e.lineTo(M+Math.round(O),S+x+R),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}e.restore(),o>1&&(S+=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=mt._isString(e)?e:e==null?"":e+"";return this._setAttr(mgr,t),this}getWidth(){return this.attrs.width===yx||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===yx||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return mt.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,o,i,s,a,l,c,u,d;let f=kie(),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:(o=p.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*m,alphabeticBaseline:(i=p.alphabeticBaseline)!==null&&i!==void 0?i: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()+d9+this.fontVariant()+d9+(this.fontSize()+vgr)+xgr(this.fontFamily())}_addTextLine(e){this.align()===sP&&(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 kie().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
2139
- `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==yx&&o!==void 0,a=i!==yx&&i!==void 0,l=this.padding(),c=o-l*2,u=i-l*2,d=0,f=this.wrap(),h=f!==Sgr&&f!==YQe,p=this.ellipsis();this.textArr=[],kie().font=this._getContextFont();const m=p?this._getTextWidth(xie):0;for(let g=0,y=e.length;g<y;++g){let b=e[g],v=this._getTextWidth(b);if(s&&v>c)for(;b.length>0;){let A=0,S=Ey(b).length,w="",T=0;for(;A<S;){const x=A+S>>>1,C=Ey(b).slice(0,x+1).join(""),k=this._getTextWidth(C);(p&&a&&d+r>u?k+m:k)<=c?(A=x+1,w=C,T=k):S=x}if(w){if(h){const x=Ey(b),C=Ey(w),k=x[C.length],P=k===d9||k===GQe;let E;if(P&&T<=c)E=C.length;else{const L=C.lastIndexOf(d9),R=C.lastIndexOf(GQe);E=Math.max(L,R)+1}E>0&&(A=E,w=x.slice(0,A).join(""),T=this._getTextWidth(w))}if(w=w.trimRight(),this._addTextLine(w),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(b=Ey(b).slice(A).join("").trimLeft(),b.length>0&&(v=this._getTextWidth(b),v<=c)){this._addTextLine(b),d+=r,n=Math.max(n,v);break}}else break}else this._addTextLine(b),d+=r,n=Math.max(n,v),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,o=r!==yx&&r!==void 0,i=r-this.padding()*2;return this.wrap()===YQe||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==yx&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+xie)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+xie))}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&&Igr()?!0:super._useBufferCanvas()}};Xi.prototype._fillFunc=kgr,Xi.prototype._strokeFunc=Cgr,Xi.prototype.className=ggr,Xi.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Is(Xi),$e.overWriteSetter(Xi,"width",aie()),$e.overWriteSetter(Xi,"height",aie()),$e.addGetterSetter(Xi,"direction",UQe),$e.addGetterSetter(Xi,"fontFamily","Arial"),$e.addGetterSetter(Xi,"fontSize",12,ln()),$e.addGetterSetter(Xi,"fontStyle",qQe),$e.addGetterSetter(Xi,"fontVariant",qQe),$e.addGetterSetter(Xi,"padding",0,ln()),$e.addGetterSetter(Xi,"align",WQe),$e.addGetterSetter(Xi,"verticalAlign",ygr),$e.addGetterSetter(Xi,"lineHeight",1,ln()),$e.addGetterSetter(Xi,"wrap",Agr),$e.addGetterSetter(Xi,"ellipsis",!1,Kf()),$e.addGetterSetter(Xi,"letterSpacing",0,ln()),$e.addGetterSetter(Xi,"text","",bw()),$e.addGetterSetter(Xi,"textDecoration",""),$e.addGetterSetter(Xi,"underlineOffset",void 0,ln()),$e.addGetterSetter(Xi,"charRenderFunc",void 0);var _gr="",JQe="normal";function ZQe(e){e.fillText(this.partialText,0,0)}function QQe(e){e.strokeText(this.partialText,0,0)}var Pa=class extends Qt{constructor(e){super(e),this.dummyCanvas=mt.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 Kd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Kd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Kd.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(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[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 mt.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Xi.prototype.setText.call(this,e)}_getContextFont(){return Xi.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=Ey(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:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,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+i;if(p===" "&&s==="justify"){const w=this.text().split(" ").length-1;m+=(this.pathLength-c)/w}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const b=Kd.getLineLength(h.x,h.y,y.x,y.y);let v=0;if(a)try{v=a(t[f-1].char,p)*this.fontSize()}catch{v=0}h.x+=v,y.x+=v,this.textWidth+=v;const A=Kd.getPointOnLine(v+b/2,h.x,h.y,y.x,y.y),S=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:A.x,transposeY:A.y,text:e[f],rotation:S,p0:h,p1:y,width:b}),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,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return mt.releaseCanvas(this.dummyCanvas),super.destroy()}};Pa.prototype._fillFunc=ZQe,Pa.prototype._strokeFunc=QQe,Pa.prototype._fillFuncHit=ZQe,Pa.prototype._strokeFuncHit=QQe,Pa.prototype.className="TextPath",Pa.prototype._attrsAffectingSize=["text","fontSize","data"],Is(Pa),$e.addGetterSetter(Pa,"data"),$e.addGetterSetter(Pa,"fontFamily","Arial"),$e.addGetterSetter(Pa,"fontSize",12,ln()),$e.addGetterSetter(Pa,"fontStyle",JQe),$e.addGetterSetter(Pa,"align","left"),$e.addGetterSetter(Pa,"letterSpacing",0,ln()),$e.addGetterSetter(Pa,"textBaseline","middle"),$e.addGetterSetter(Pa,"fontVariant",JQe),$e.addGetterSetter(Pa,"text",_gr),$e.addGetterSetter(Pa,"textDecoration",""),$e.addGetterSetter(Pa,"kerningFunc",void 0);var $Qe="tr-konva",Rgr=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${$Qe}`).join(" "),e$e="nodesRect",Pgr=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],Ngr={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Lgr="ontouchstart"in fn._global;function Mgr(e,t,n){if(e==="rotater")return n;t+=mt.degToRad(Ngr[e]||0);const r=(mt.radToDeg(t)%360+360)%360;return mt._inRange(r,337.5,360)||mt._inRange(r,0,22.5)?"ns-resize":mt._inRange(r,22.5,67.5)?"nesw-resize":mt._inRange(r,67.5,112.5)?"ew-resize":mt._inRange(r,112.5,157.5)?"nwse-resize":mt._inRange(r,157.5,202.5)?"ns-resize":mt._inRange(r,202.5,247.5)?"nesw-resize":mt._inRange(r,247.5,292.5)?"ew-resize":mt._inRange(r,292.5,337.5)?"nwse-resize":(mt.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var h9=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],t$e=1e8;function Dgr(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 n$e(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=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:o}}function Ogr(e,t){return n$e(e,t,Dgr(e))}function Fgr(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=fn.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var Cie=0,Po=class extends px{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(Rgr,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return mt.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 $Qe+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(mt.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(o=>o+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(Pgr.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(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),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(e$e),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(e$e,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(fn.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return n$e({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-fn.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-t$e,y:-t$e,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 qf;t.rotate(-fn.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:fn.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(),h9.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new iP({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Lgr?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=Mgr(e,fn.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 Qt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=mt.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=i/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,(i-f)/u));const m=f+u*p,g=h+d*p,y=mt._sign(s),b=m+u*l*y,v=g+d*l*y;t.moveTo(m,g),t.lineTo(b,v)}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,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),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 i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},Cie++,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 o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const c=o.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=o.x()-y.width/2,n=-o.y()+y.height/2;const b=fn.getAngle(this.rotateAnchorAngle());let v=Math.atan2(-n,t)+Math.PI/2-b;y.height<0&&(v-=Math.PI);const A=fn.getAngle(this.rotation())+v,S=fn.getAngle(this.rotationSnapTolerance()),w=Ogr(y,Fgr(this.rotationSnaps(),A,S)-y.rotation);this._fitNodesInto(w,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-o.x(),2)+Math.pow(y.y-o.y(),2));const b=this.findOne(".top-left").x()>y.x?-1:1,v=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,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(o.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(o.x()-y.x,2)+Math.pow(y.y-o.y(),2));const b=this.findOne(".top-right").x()<y.x?-1:1,v=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=o.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(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.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-o.x(),2)+Math.pow(o.y()-y.y,2));const b=y.x<o.x()?-1:1,v=o.y()<y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,o.x(y.x-t),o.y(y.y+n)}h=o.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(o.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(o.x()-y.x,2)+Math.pow(o.y()-y.y,2));const b=this.findOne(".bottom-right").x()<y.x?-1:1,v=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,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"),b=this.findOne(".bottom-right"),v=y.x(),A=y.y(),S=this.getWidth()-b.x(),w=this.getHeight()-b.y();b.move({x:-v,y:-A}),y.move({x:S,y:w})}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:fn.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();Cie--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(mt._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(mt._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new qf;if(o.rotate(fn.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=o.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=o.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=o.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=o.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:mt.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new qf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new qf,l=e.width/i,c=e.height/i;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 qf;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(mt._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(mt._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(S=>{S.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:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=mt.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,b=m+h*g,v=mt._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*v,y:b+h*u*v-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(S=>S.draggable()),x:0,y:0});const A=this.anchorStyleFunc();A&&l.forEach(S=>{A(S)}),(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=""),px.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(mt.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return pn.prototype.toObject.call(this)}clone(e){return pn.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Po.isTransforming=()=>Cie>0;function Bgr(e){return e instanceof Array||mt.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){h9.indexOf(t)===-1&&mt.warn("Unknown anchor name: "+t+". Available names are: "+h9.join(", "))}),e||[]}Po.prototype.className="Transformer",Is(Po),$e.addGetterSetter(Po,"enabledAnchors",h9,Bgr),$e.addGetterSetter(Po,"flipEnabled",!0,Kf()),$e.addGetterSetter(Po,"resizeEnabled",!0),$e.addGetterSetter(Po,"anchorSize",10,ln()),$e.addGetterSetter(Po,"rotateEnabled",!0),$e.addGetterSetter(Po,"rotateLineVisible",!0),$e.addGetterSetter(Po,"rotationSnaps",[]),$e.addGetterSetter(Po,"rotateAnchorOffset",50,ln()),$e.addGetterSetter(Po,"rotateAnchorAngle",0,ln()),$e.addGetterSetter(Po,"rotateAnchorCursor","crosshair"),$e.addGetterSetter(Po,"rotationSnapTolerance",5,ln()),$e.addGetterSetter(Po,"borderEnabled",!0),$e.addGetterSetter(Po,"anchorStroke","rgb(0, 161, 255)"),$e.addGetterSetter(Po,"anchorStrokeWidth",1,ln()),$e.addGetterSetter(Po,"anchorFill","white"),$e.addGetterSetter(Po,"anchorCornerRadius",0,ln()),$e.addGetterSetter(Po,"borderStroke","rgb(0, 161, 255)"),$e.addGetterSetter(Po,"borderStrokeWidth",1,ln()),$e.addGetterSetter(Po,"borderDash"),$e.addGetterSetter(Po,"keepRatio",!0),$e.addGetterSetter(Po,"shiftBehavior","default"),$e.addGetterSetter(Po,"centeredScaling",!1),$e.addGetterSetter(Po,"ignoreStroke",!1),$e.addGetterSetter(Po,"padding",0,ln()),$e.addGetterSetter(Po,"nodes"),$e.addGetterSetter(Po,"node"),$e.addGetterSetter(Po,"boundBoxFunc"),$e.addGetterSetter(Po,"anchorDragBoundFunc"),$e.addGetterSetter(Po,"anchorStyleFunc"),$e.addGetterSetter(Po,"shouldOverdrawWholeArea",!1),$e.addGetterSetter(Po,"useSingleNodeRotation",!0),$e.backCompat(Po,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Jm=class extends Qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,fn.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)}};Jm.prototype.className="Wedge",Jm.prototype._centroid=!0,Jm.prototype._attrsAffectingSize=["radius"],Is(Jm),$e.addGetterSetter(Jm,"radius",0,ln()),$e.addGetterSetter(Jm,"angle",0,ln()),$e.addGetterSetter(Jm,"clockwise",!1),$e.backCompat(Jm,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function r$e(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Hgr=[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],zgr=[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 Ugr(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,c,u,d,f,h,p,m,g,y,b,v,A,S,w,T,x;const C=t+t+1,k=r-1,P=o-1,E=t+1,L=E*(E+1)/2,R=new r$e,M=Hgr[t],O=zgr[t];let H=null,W=R,G=null,U=null;for(let F=1;F<C;F++)W=W.next=new r$e,F===E&&(H=W);W.next=R,a=s=0;for(let F=0;F<o;F++){g=y=b=v=l=c=u=d=0,f=E*(A=n[s]),h=E*(S=n[s+1]),p=E*(w=n[s+2]),m=E*(T=n[s+3]),l+=L*A,c+=L*S,u+=L*w,d+=L*T,W=R;for(let ne=0;ne<E;ne++)W.r=A,W.g=S,W.b=w,W.a=T,W=W.next;for(let ne=1;ne<E;ne++)i=s+((k<ne?k:ne)<<2),l+=(W.r=A=n[i])*(x=E-ne),c+=(W.g=S=n[i+1])*x,u+=(W.b=w=n[i+2])*x,d+=(W.a=T=n[i+3])*x,g+=A,y+=S,b+=w,v+=T,W=W.next;G=R,U=H;for(let ne=0;ne<r;ne++)n[s+3]=T=d*M>>O,T!==0?(T=255/T,n[s]=(l*M>>O)*T,n[s+1]=(c*M>>O)*T,n[s+2]=(u*M>>O)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=G.r,h-=G.g,p-=G.b,m-=G.a,i=a+((i=ne+t+1)<k?i:k)<<2,g+=G.r=n[i],y+=G.g=n[i+1],b+=G.b=n[i+2],v+=G.a=n[i+3],l+=g,c+=y,u+=b,d+=v,G=G.next,f+=A=U.r,h+=S=U.g,p+=w=U.b,m+=T=U.a,g-=A,y-=S,b-=w,v-=T,U=U.next,s+=4;a+=r}for(let F=0;F<r;F++){y=b=v=g=c=u=d=l=0,s=F<<2,f=E*(A=n[s]),h=E*(S=n[s+1]),p=E*(w=n[s+2]),m=E*(T=n[s+3]),l+=L*A,c+=L*S,u+=L*w,d+=L*T,W=R;for(let Y=0;Y<E;Y++)W.r=A,W.g=S,W.b=w,W.a=T,W=W.next;let ne=r;for(let Y=1;Y<=t;Y++)s=ne+F<<2,l+=(W.r=A=n[s])*(x=E-Y),c+=(W.g=S=n[s+1])*x,u+=(W.b=w=n[s+2])*x,d+=(W.a=T=n[s+3])*x,g+=A,y+=S,b+=w,v+=T,W=W.next,Y<P&&(ne+=r);s=F,G=R,U=H;for(let Y=0;Y<o;Y++)i=s<<2,n[i+3]=T=d*M>>O,T>0?(T=255/T,n[i]=(l*M>>O)*T,n[i+1]=(c*M>>O)*T,n[i+2]=(u*M>>O)*T):n[i]=n[i+1]=n[i+2]=0,l-=f,c-=h,u-=p,d-=m,f-=G.r,h-=G.g,p-=G.b,m-=G.a,i=F+((i=Y+E)<P?i:P)*r<<2,l+=g+=G.r=n[i],c+=y+=G.g=n[i+1],u+=b+=G.b=n[i+2],d+=v+=G.a=n[i+3],G=G.next,f+=A=U.r,h+=S=U.g,p+=w=U.b,m+=T=U.a,g-=A,y-=S,b-=w,v-=T,U=U.next,s+=r}}const Vgr=function(t){const n=Math.round(this.blurRadius());n>0&&Ugr(t,n)};$e.addGetterSetter(pn,"blurRadius",0,ln(),$e.afterSetFilter);const Ggr=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};$e.addGetterSetter(pn,"brightness",0,ln(),$e.afterSetFilter);const Wgr=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},jgr=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};$e.addGetterSetter(pn,"contrast",0,ln(),$e.afterSetFilter);const qgr=function(e){var t,n,r,o,i,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,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.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,b=p*255,v=m*Math.PI/180,A=Math.cos(v),S=Math.sin(v),w=128/1020*y,T=new Uint8ClampedArray(u),x=new Float32Array(d*f);for(let L=0,R=0;R<u.length;R+=4,L++)x[L]=.2126*T[R]+.7152*T[R+1]+.0722*T[R+2];const C=[-1,0,1,-2,0,2,-1,0,1],k=[-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 M=L*d+R;let O=0,H=0;O+=x[M+P[0]]*C[0],H+=x[M+P[0]]*k[0],O+=x[M+P[1]]*C[1],H+=x[M+P[1]]*k[1],O+=x[M+P[2]]*C[2],H+=x[M+P[2]]*k[2],O+=x[M+P[3]]*C[3],H+=x[M+P[3]]*k[3],O+=x[M+P[5]]*C[5],H+=x[M+P[5]]*k[5],O+=x[M+P[6]]*C[6],H+=x[M+P[6]]*k[6],O+=x[M+P[7]]*C[7],H+=x[M+P[7]]*k[7],O+=x[M+P[8]]*C[8],H+=x[M+P[8]]*k[8];const W=E(b+(A*O+S*H)*w),G=M*4;if(g){const U=W-b;u[G]=E(T[G]+U),u[G+1]=E(T[G+1]+U),u[G+2]=E(T[G+2]+U),u[G+3]=T[G+3]}else u[G]=u[G+1]=u[G+2]=W,u[G+3]=T[G+3]}for(let L=0;L<d;L++){let R=L*4,M=((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[M]=T[M],u[M+1]=T[M+1],u[M+2]=T[M+2],u[M+3]=T[M+3]}for(let L=1;L<f-1;L++){let R=L*d*4,M=(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[M]=T[M],u[M+1]=T[M+1],u[M+2]=T[M+2],u[M+3]=T[M+3]}return e};$e.addGetterSetter(pn,"embossStrength",.5,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"embossWhiteLevel",.5,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"embossDirection","top-left",void 0,$e.afterSetFilter),$e.addGetterSetter(pn,"embossBlend",!1,void 0,$e.afterSetFilter);function Eie(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}const Kgr=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let v=0;v<n;v+=4)i=t[v+0],i<r?r=i:i>o&&(o=i),l=t[v+1],l<s?s=l:l>a&&(a=l),d=t[v+2],d<c?c=d:d>u&&(u=d);o===r&&(o=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,b;if(f>0)h=o+f*(255-o),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),b=c-f*(c-0);else{const v=(o+r)*.5;h=o+f*(o-v),p=r+f*(r-v);const A=(a+s)*.5;m=a+f*(a-A),g=s+f*(s-A);const S=(u+c)*.5;y=u+f*(u-S),b=c+f*(c-S)}for(let v=0;v<n;v+=4)t[v+0]=Eie(t[v+0],r,o,p,h),t[v+1]=Eie(t[v+1],s,a,g,m),t[v+2]=Eie(t[v+2],c,u,b,y)};$e.addGetterSetter(pn,"enhance",0,ln(),$e.afterSetFilter);const Ygr=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};$e.addGetterSetter(pn,"hue",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"saturation",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"luminance",0,ln(),$e.afterSetFilter);const Xgr=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*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 b,v,A,S;for(let w=0;w<n;w+=4)b=t[w+0],v=t[w+1],A=t[w+2],S=t[w+3],t[w+0]=c*b+u*v+d*A+s,t[w+1]=f*b+h*v+p*A+s,t[w+2]=m*b+g*v+y*A+s,t[w+3]=S},Jgr=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*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 b=t[y+0],v=t[y+1],A=t[y+2],S=t[y+3];t[y+0]=l*b+c*v+u*A,t[y+1]=d*b+f*v+h*A,t[y+2]=p*b+m*v+g*A,t[y+3]=S}};$e.addGetterSetter(pn,"hue",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"saturation",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"value",0,ln(),$e.afterSetFilter);const Zgr=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 Qgr=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=i,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),b=Math.cos(g*m);for(let v=0;v<h;v+=1){u=Math.floor(a+c*v/h*b),d=Math.floor(l+c*v/h*y);let A=(d*i+u)*4;const S=r[A+0],w=r[A+1],T=r[A+2],x=r[A+3];A=(g+v*i)*4,o[A+0]=S,o[A+1]=w,o[A+2]=T,o[A+3]=x}}},$gr=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=i,m=n.polarRotation||0;let g,y;for(u=0;u<i;u+=1)for(d=0;d<s;d+=1){const b=u-a,v=d-l,A=Math.sqrt(b*b+v*v)*h/c;let S=(Math.atan2(v,b)*180/Math.PI+360+m)%360;S=S*p/360,g=Math.floor(S),y=Math.floor(A);let w=(y*i+g)*4;const T=r[w+0],x=r[w+1],C=r[w+2],k=r[w+3];w=(d*i+u)*4,o[w+0]=T,o[w+1]=x,o[w+2]=C,o[w+3]=k}};const e0r=function(e){const t=e.width,n=e.height;let r,o,i,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=mt.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);mt.releaseCanvas(g),Qgr(e,y,{polarCenterX:t/2,polarCenterY:n/2});let b=t/Math.pow(2,h);for(;b<=8;)b=b*2,h-=1;b=Math.ceil(b);let v=b,A=0,S=v,w=1;for(m+b>t&&(A=v,S=0,w=-1),o=0;o<n;o+=1)for(r=A;r!==S;r+=w)i=Math.round(r+m)%t,d=(t*o+i)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*o+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(o=0;o<n;o+=1)for(v=Math.floor(b),s=0;s<h;s+=1){for(r=0;r<v+1;r+=1)d=(t*o+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*o+v*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;v*=2}$gr(y,e,{polarRotation:0})};$e.addGetterSetter(pn,"kaleidoscopePower",2,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"kaleidoscopeAngle",0,ln(),$e.afterSetFilter);function p9(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function lP(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 t0r(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 n0r(e,t){const n=p9(e,0,0),r=p9(e,e.width-1,0),o=p9(e,0,e.height-1),i=p9(e,e.width-1,e.height-1),s=t||10;if(lP(n,r)<s&&lP(r,i)<s&&lP(i,o)<s&&lP(o,n)<s){const a=t0r([r,n,i,o]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=lP(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function r0r(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function o0r(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function i0r(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function s0r(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u}return s}const a0r=function(e){let t=n0r(e,this.threshold());return t&&(t=o0r(t,e.width,e.height),t=i0r(t,e.width,e.height),t=s0r(t,e.width,e.height),r0r(e,t)),e};$e.addGetterSetter(pn,"threshold",0,ln(),$e.afterSetFilter);const l0r=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};$e.addGetterSetter(pn,"noise",.2,ln(),$e.afterSetFilter);const c0r=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){mt.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;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 b=h;b<p;b+=1)if(!(b>=n))for(let v=m;v<g;v+=1){if(v>=r)continue;const A=(n*v+b)*4;c+=s[A+0],u+=s[A+1],d+=s[A+2],f+=s[A+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let b=h;b<p;b+=1)if(!(b>=n))for(let v=m;v<g;v+=1){if(v>=r)continue;const A=(n*v+b)*4;s[A+0]=c,s[A+1]=u,s[A+2]=d,s[A+3]=f}}};$e.addGetterSetter(pn,"pixelSize",8,ln(),$e.afterSetFilter);const u0r=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};$e.addGetterSetter(pn,"levels",.5,ln(),$e.afterSetFilter);const d0r=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=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*o,t[s+2]=a*i,t[s+3]=t[s+3]}};$e.addGetterSetter(pn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"blue",0,rQe,$e.afterSetFilter);const f0r=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=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]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};$e.addGetterSetter(pn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"blue",0,rQe,$e.afterSetFilter),$e.addGetterSetter(pn,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const h0r=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},p0r=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},m0r=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};$e.addGetterSetter(pn,"threshold",.5,ln(),$e.afterSetFilter);var g0r=MQe.Util._assign(MQe,{Arc:Ym,Arrow:Aw,Circle:gx,Ellipse:xy,Image:Yf,Label:Iie,Tag:Sw,Line:Xm,Path:Kd,Rect:iP,RegularPolygon:ky,Ring:Tw,Sprite:hp,Star:Cy,Text:Xi,TextPath:Pa,Transformer:Po,Wedge:Jm,Filters:{Blur:Vgr,Brightness:Wgr,Brighten:Ggr,Contrast:jgr,Emboss:qgr,Enhance:Kgr,Grayscale:Ygr,HSL:Xgr,HSV:Jgr,Invert:Zgr,Kaleidoscope:e0r,Mask:a0r,Noise:l0r,Pixelate:c0r,Posterize:u0r,RGB:d0r,RGBA:f0r,Sepia:h0r,Solarize:p0r,Threshold:m0r}});tn();var y0r=["dialog","floating"],o$e=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function b0r(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!y0r.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&&!o$e.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${o$e.join(", ")}, got "${e.floating.placement}".`)}var v0r=class{activeDialog=od(null);activeFloating=od(null);#e=!1;#t=1;#o;constructor({getModuleConfig:e}){this.#o=e}open(e){if(this.#e)return this.#u(e);b0r(e);const t=this.#s(e),{component:n,props:r,render:o}=this.#c(t);let i,s=!1;const a=new Promise(h=>{i=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{i({status:"submitted",data:h})&&this.#r(l)},u=h=>{i({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:c,close:u,settle:h=>i(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 o=this.#i(e);o&&this.#n(o,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)}#i(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#s(e){const t=e.id??`surface-${this.#t++}`,n=this.#o()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=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:o,floating:i}}#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.#o()?.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"})}}},w0r="https://docs.superdoc.dev/guides/migration/document-api",i$e=new Set;function A0r(e,t){i$e.has(e)||(i$e.add(e),console.warn(t))}var S0r={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},s$e=Symbol.for("superdoc:rawEditor"),a$e=new WeakMap;function l$e(e){return!e||e[s$e]?e:new Proxy(e,{get(t,n){if(n===s$e)return t;const r=S0r[n];r&&A0r(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${w0r}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=a$e.get(t);return i||(i=new Map,a$e.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var c$e=["review","original","final","off"],T0r=["paired","independent"],u$e=Symbol.for("@superdoc/trackChanges:normalized"),d$e=new Set;function f$e(e,t){d$e.has(e)||(d$e.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function h$e(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function I0r(e,t,n){return typeof e=="string"&&c$e.includes(e)?e:typeof t=="string"&&c$e.includes(t)?t:n}function x0r(e){return typeof e=="string"&&T0r.includes(e)?e:null}function bx(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function k0r(e){const t=e[u$e]===!0;bx(e.modules)||(e.modules={});const n=bx(e.modules.trackChanges),r=bx(e.trackChanges),o=bx(e.layoutEngineOptions?.trackedChanges);t||(r&&f$e("config.trackChanges","config.modules.trackChanges"),o&&f$e("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=h$e(n?.visible,r?.visible,!1),s=h$e(n?.enabled,o?.enabled,!0),a=x0r(n?.replacements)??"paired",l=bx(n?.authorColors)?n.authorColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",u=I0r(n?.mode,o?.mode,c),d={visible:i,mode:u,enabled:s,replacements:a};return l&&(d.authorColors=l),e.modules.trackChanges=d,e.trackChanges={visible:i},bx(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:u,enabled:s},Object.defineProperty(e,u$e,{value:!0,writable:!0,configurable:!0,enumerable:!1}),d}var C0r=class{#e=new Map;#t=new Map;#o=null;#n=new Set;register(e){if(this.#e.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#t.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#e.set(e.id,e),t&&this.#t.set(t,e.id)}unregister(e){const t=this.#e.get(e);return t?(this.#e.delete(e),t.root&&this.#t.delete(t.root),this.#o===e&&(this.#o=null,this.#r({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#e.get(e)??null}getAll(){return Array.from(this.#e.values())}getAllByDocumentId(e){const t=[];for(const n of this.#e.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#o===null?null:this.#e.get(this.#o)}getActiveId(){return this.#o}setActive(e,t){if(e!==null&&!this.#e.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#o)return;const n=this.#o;this.#o=e;let r=null;e!==null&&(r=this.#e.get(e).getLegacyEditorProjection?.()??null),this.#r({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${X8}]`);if(!n)return null;const r=n.getAttribute(X8),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#n.add(e),()=>{this.#n.delete(e)}}clear(){this.#e.clear(),this.#t.clear(),this.#o=null,this.#n.clear()}#r(e){for(const t of Array.from(this.#n))try{t(e)}catch{}}};tn();var m9=Object.freeze({id:null,name:"Default SuperDoc user",email:null}),E0r=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"]);function Zm(e){return e?e.presentationEditor??null:null}function _ie(e){if(!e||typeof e!="object")return!1;const t=e;return!!t.commands&&typeof t.commands=="object"}var g9=class extends s4.default{static{this.allowedTypes=[Kc,_k,$N]}#e=!1;#t=!1;#o=null;#n=null;#r;#i=new C0r;#s=null;#c=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...m9},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},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,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!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.#r=new v0r({getModuleConfig:()=>this.config.modules?.surfaces}),this.#u(e,t)}async#u(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),k0r(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};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 o=this.config.user;if(!o||typeof o!="object"?this.config.user={...m9}:(this.config.user={...m9,...o},this.config.user.name||(this.config.user.name=m9.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.modules.comments=phr(this.config.modules.comments),this.config.colors=Ilt(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.44.2",this.#F("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||hn(),this.colors=this.config.colors??[],this.#a(),await this.#T(this.config.modules),this.#e){this.#ee();return}this.config.cspNonce&&this.#p(),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.#s||(this.#s=this.#i.subscribe(s=>{this.#W(s.nextRuntimeId,s.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const i=document.createElement("div");i.style.display="contents",t.appendChild(i),this.#n=i,this.#S(),this.#f(),this.#H(),this.#d()}#d(){if(this.#b(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#n)}#f(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new qpr({Renderer:g0r,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#x("requiredNumberOfEditors").documents.filter(e=>e.type===Kc).length}get state(){return{documents:this.#x("state").documents,users:this.users}}getPresentationEditorForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getPresentationEditor?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#p(){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}}#a(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}else if(n)this.config.documents=[{id:hn(),type:Kc,url:this.config.document,name:"document.docx"}];else if(r){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}else if(o){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=VR(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||hn()}}))}#b(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=Fpr({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=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&q8(this),this.#de()}#l(e,t){t&&this.on(e,t)}#S(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#T({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:hn(),type:Kc,name:"document.docx"}]),this.#y(n,r),q8(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Fde({url:e.url}));const o=vur(this);if(t&&t.useInternalExternalComments&&!t.suppressInternalExternalComments){const i=bur(this);if(!i)throw new Error("SuperDoc: `modules.comments.useInternalExternalComments` requires `superdocId` to be set in the config.");this.ydoc=li(i.ydoc),this.provider=li(i.provider)}else this.ydoc=li(o[0].ydoc),this.provider=li(o[0].provider);return q8(this),o}#y(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=li(e),this.provider=li(t),this.#v();const n=this.config;this._cleanupAwareness=mur(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#w(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#v(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:E0r,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#L({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#M();await this.#D(t),this.#C(),Gnn(n,e),Upr(e,this.#h("upgradeToCollaboration").commentsList),Vpr(e,{isLocked:this.isLocked??!1,lockedBy:this.lockedBy??null}),this.config.modules.collaboration={ydoc:e,provider:t},this.#y(e,t),this.#I(e,t);const r=this.#k();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(o){throw this.#E(),o}if(await this.#R(r),this.#e)return;q8(this)}finally{this.#o=null,this.#t=!1}}#C(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#x(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#h(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#m(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#I(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=Co(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#k(){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}#E(){this.#w(),this.#I(null,null)}#R(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),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=()=>{i(),r(void 0)};this.#o=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#D(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=cv(e,()=>{i||(a(),n())}),i||(o=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.#o=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#L({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,r=n.documents.filter(o=>o.type===Kc);if(r.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(r.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(n.documents.length!==r.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#M(){const e=this.config.documents.find(n=>n.type===Kc),t=this.#x("upgradeToCollaboration").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.#m("addSharedUser");const t=bA({actor:e});t&&this.users.some(n=>bA({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#m("removeSharedUser");const t=typeof e=="string"?eL(e):"",n=typeof e=="string"?`email:${t}`:bA({actor:e});this.users=this.users.filter(r=>{const o=bA({actor:r});return n?o!==n:t?eL(r.email)!==t:!0})}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.#x("onContentError").documents.find(o=>o.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:l$e(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#_(e),this.emit("editorCreate",{editor:l$e(e)})}#A=new WeakSet;#_(e){if(!e||typeof e.on!="function"||this.#A.has(e))return;this.#A.add(e),e.on("fonts-changed",n=>{this.#G(e)&&this.#O(n)});const t=e.presentationEditor?.getLastFontsChangedPayload?.();t&&this.#G(e)&&this.#O(t)}#G(e){return!this.activeEditor||e===this.activeEditor}#oe=null;#O(e){this.#oe=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#F(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}#V=null;get fonts(){return this.#V||(this.#V={getReport:()=>Zm(this.activeEditor)?.getFontReport()??[],getMissingFonts:()=>Zm(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>Zm(this.activeEditor)?.getDocumentFontOptions()??[],getDocumentFonts:()=>[...new Set((Zm(this.activeEditor)?.getFontReport()??[]).map(e=>e.logicalFamily))],onReport:e=>{const t=this.activeEditor,n=t?Zm(t)?.getLastFontsChangedPayload?.()??null:this.#oe??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.mapFonts(e)},unmap:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmapFonts(e)},add:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.addFonts(Array.isArray(e)?e:[e])},preload:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preloadFonts(e)}}),this.#V}#X(){this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null)}#J(e){this.activeEditor=e,this.toolbar&&(e.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}#W(e,t){this.#c=!0;try{if(e===null){this.#X();return}this.#i.get(e)?.kind==="v1"&&_ie(t)?this.setActiveEditor(t):this.#X()}finally{this.#c=!1}}#le(e){if(!e)return null;for(const n of this.#i.getAll())if(n.kind==="v1"&&n.getLegacyEditorProjection?.()===e)return n.id;const t=e.options?.documentId;if(typeof t=="string"&&t.length>0){const n=this.#i.getAllByDocumentId(t).filter(r=>r.kind==="v1");if(n.length===1)return n[0].id}return null}setActiveEditor(e){if(!_ie(e)){this.#X();return}if(!this.#c){const t=this.#le(e);if(t!==null){const n=this.#i.getActive()?.id===t;if(this.#i.setActive(t,"set-active-editor"),n){const r=this.#i.get(t)?.getLegacyEditorProjection?.()??null;_ie(r)?this.#J(r):this.#X()}return}}this.#J(e)}registerEditorRuntime(e){this.#i.register(e)}unregisterEditorRuntime(e){return this.#i.unregister(e)}getActiveRuntime(){return this.#i.getActive()}setActiveRuntime(e,t){this.#i.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#i.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#i.resolveFromEventTarget(e);return n?(this.#i.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#x("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return mw(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#H(){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 lBe({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups: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.config.onException&&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 ffr(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,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,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 o=n.getEditor?.();o?.setOptions&&o.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)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#m("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#de();const t={viewing:()=>this.#pe(),editing:()=>this.#ue(),suggesting:()=>this.#$()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#Z(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null,r=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;let o=!1;if(n){const s=this.#i.getAllByDocumentId(n);if(s.length>0){for(const a of s)a.setDocumentMode(t);o=!0}}if(r){(!o||t!=="viewing"||this.#te(r,t))&&r.setDocumentMode(t);return}if(o)return;const i=typeof e.getEditor=="function"?e.getEditor():null;i&&i.setDocumentMode(t)}#te(e,t){const n=e.element?.classList;return!n||typeof n.contains!="function"?!1:n.contains("presentation-editor--viewing")!==(t==="viewing")}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)})}#ue(){if(this.config.role!=="editor")return this.#$();const e=this.#x("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"editing")})}#$(){if(!["editor","suggester"].includes(this.config.role??""))return this.#pe();const e=this.#x("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"suggesting")})}#pe(){const e=this.#x("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const t=this.config.comments?.visible===!0,n=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(n?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!t&&!n&&this.commentsStore?.clearEditorCommentPositions?.(),e.documents.forEach(r=>{t||n?r.restoreComments?.():r.removeComments?.(),this.#Z(r,"viewing")})}#de(){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 o=this.superdocStore?.documents;Array.isArray(o)&&o.length>0&&o.forEach(i=>{const s=typeof i.getPresentationEditor=="function"?i.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return n.call(t,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}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}this.superdocStore.zoomMode!==e&&(this.superdocStore.zoomMode=e,this.emit("zoomChange",{zoom:this.getZoom(),mode:e}))}getZoomState(){const e=MJe(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}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.#x("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.isLocked=e,this.lockedBy=t,this.#F("🦋 [superdoc] Locking superdoc:",e,t,`
2139
+ `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==yx&&o!==void 0,a=i!==yx&&i!==void 0,l=this.padding(),c=o-l*2,u=i-l*2,d=0,f=this.wrap(),h=f!==Sgr&&f!==YQe,p=this.ellipsis();this.textArr=[],kie().font=this._getContextFont();const m=p?this._getTextWidth(xie):0;for(let g=0,y=e.length;g<y;++g){let b=e[g],v=this._getTextWidth(b);if(s&&v>c)for(;b.length>0;){let A=0,S=Ey(b).length,w="",T=0;for(;A<S;){const x=A+S>>>1,C=Ey(b).slice(0,x+1).join(""),k=this._getTextWidth(C);(p&&a&&d+r>u?k+m:k)<=c?(A=x+1,w=C,T=k):S=x}if(w){if(h){const x=Ey(b),C=Ey(w),k=x[C.length],P=k===d9||k===GQe;let E;if(P&&T<=c)E=C.length;else{const L=C.lastIndexOf(d9),R=C.lastIndexOf(GQe);E=Math.max(L,R)+1}E>0&&(A=E,w=x.slice(0,A).join(""),T=this._getTextWidth(w))}if(w=w.trimRight(),this._addTextLine(w),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(b=Ey(b).slice(A).join("").trimLeft(),b.length>0&&(v=this._getTextWidth(b),v<=c)){this._addTextLine(b),d+=r,n=Math.max(n,v);break}}else break}else this._addTextLine(b),d+=r,n=Math.max(n,v),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,o=r!==yx&&r!==void 0,i=r-this.padding()*2;return this.wrap()===YQe||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==yx&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+xie)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+xie))}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&&Igr()?!0:super._useBufferCanvas()}};Xi.prototype._fillFunc=kgr,Xi.prototype._strokeFunc=Cgr,Xi.prototype.className=ggr,Xi.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Is(Xi),$e.overWriteSetter(Xi,"width",aie()),$e.overWriteSetter(Xi,"height",aie()),$e.addGetterSetter(Xi,"direction",UQe),$e.addGetterSetter(Xi,"fontFamily","Arial"),$e.addGetterSetter(Xi,"fontSize",12,ln()),$e.addGetterSetter(Xi,"fontStyle",qQe),$e.addGetterSetter(Xi,"fontVariant",qQe),$e.addGetterSetter(Xi,"padding",0,ln()),$e.addGetterSetter(Xi,"align",WQe),$e.addGetterSetter(Xi,"verticalAlign",ygr),$e.addGetterSetter(Xi,"lineHeight",1,ln()),$e.addGetterSetter(Xi,"wrap",Agr),$e.addGetterSetter(Xi,"ellipsis",!1,Kf()),$e.addGetterSetter(Xi,"letterSpacing",0,ln()),$e.addGetterSetter(Xi,"text","",bw()),$e.addGetterSetter(Xi,"textDecoration",""),$e.addGetterSetter(Xi,"underlineOffset",void 0,ln()),$e.addGetterSetter(Xi,"charRenderFunc",void 0);var _gr="",JQe="normal";function ZQe(e){e.fillText(this.partialText,0,0)}function QQe(e){e.strokeText(this.partialText,0,0)}var Pa=class extends Qt{constructor(e){super(e),this.dummyCanvas=mt.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 Kd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Kd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Kd.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(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[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 mt.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Xi.prototype.setText.call(this,e)}_getContextFont(){return Xi.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=Ey(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:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),c=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,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+i;if(p===" "&&s==="justify"){const w=this.text().split(" ").length-1;m+=(this.pathLength-c)/w}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const b=Kd.getLineLength(h.x,h.y,y.x,y.y);let v=0;if(a)try{v=a(t[f-1].char,p)*this.fontSize()}catch{v=0}h.x+=v,y.x+=v,this.textWidth+=v;const A=Kd.getPointOnLine(v+b/2,h.x,h.y,y.x,y.y),S=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:A.x,transposeY:A.y,text:e[f],rotation:S,p0:h,p1:y,width:b}),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,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return mt.releaseCanvas(this.dummyCanvas),super.destroy()}};Pa.prototype._fillFunc=ZQe,Pa.prototype._strokeFunc=QQe,Pa.prototype._fillFuncHit=ZQe,Pa.prototype._strokeFuncHit=QQe,Pa.prototype.className="TextPath",Pa.prototype._attrsAffectingSize=["text","fontSize","data"],Is(Pa),$e.addGetterSetter(Pa,"data"),$e.addGetterSetter(Pa,"fontFamily","Arial"),$e.addGetterSetter(Pa,"fontSize",12,ln()),$e.addGetterSetter(Pa,"fontStyle",JQe),$e.addGetterSetter(Pa,"align","left"),$e.addGetterSetter(Pa,"letterSpacing",0,ln()),$e.addGetterSetter(Pa,"textBaseline","middle"),$e.addGetterSetter(Pa,"fontVariant",JQe),$e.addGetterSetter(Pa,"text",_gr),$e.addGetterSetter(Pa,"textDecoration",""),$e.addGetterSetter(Pa,"kerningFunc",void 0);var $Qe="tr-konva",Rgr=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${$Qe}`).join(" "),e$e="nodesRect",Pgr=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],Ngr={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Lgr="ontouchstart"in fn._global;function Mgr(e,t,n){if(e==="rotater")return n;t+=mt.degToRad(Ngr[e]||0);const r=(mt.radToDeg(t)%360+360)%360;return mt._inRange(r,337.5,360)||mt._inRange(r,0,22.5)?"ns-resize":mt._inRange(r,22.5,67.5)?"nesw-resize":mt._inRange(r,67.5,112.5)?"ew-resize":mt._inRange(r,112.5,157.5)?"nwse-resize":mt._inRange(r,157.5,202.5)?"ns-resize":mt._inRange(r,202.5,247.5)?"nesw-resize":mt._inRange(r,247.5,292.5)?"ew-resize":mt._inRange(r,292.5,337.5)?"nwse-resize":(mt.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var h9=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],t$e=1e8;function Dgr(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 n$e(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=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:o}}function Ogr(e,t){return n$e(e,t,Dgr(e))}function Fgr(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=fn.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var Cie=0,Po=class extends px{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(Rgr,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return mt.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 $Qe+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(mt.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(o=>o+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(Pgr.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(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),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(e$e),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(e$e,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(fn.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return n$e({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-fn.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-t$e,y:-t$e,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 qf;t.rotate(-fn.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:fn.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(),h9.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new iP({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Lgr?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=Mgr(e,fn.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 Qt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),c=mt.degToRad(a),u=Math.sin(c),d=-Math.cos(c),f=i/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,(i-f)/u));const m=f+u*p,g=h+d*p,y=mt._sign(s),b=m+u*l*y,v=g+d*l*y;t.moveTo(m,g),t.lineTo(b,v)}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,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),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 i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},Cie++,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 o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const c=o.getAbsolutePosition();if(l.x===c.x&&l.y===c.y)return;if(this._movingAnchorName==="rotater"){const y=this._getNodeRect();t=o.x()-y.width/2,n=-o.y()+y.height/2;const b=fn.getAngle(this.rotateAnchorAngle());let v=Math.atan2(-n,t)+Math.PI/2-b;y.height<0&&(v-=Math.PI);const A=fn.getAngle(this.rotation())+v,S=fn.getAngle(this.rotationSnapTolerance()),w=Ogr(y,Fgr(this.rotationSnaps(),A,S)-y.rotation);this._fitNodesInto(w,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-o.x(),2)+Math.pow(y.y-o.y(),2));const b=this.findOne(".top-left").x()>y.x?-1:1,v=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,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(o.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(o.x()-y.x,2)+Math.pow(y.y-o.y(),2));const b=this.findOne(".top-right").x()<y.x?-1:1,v=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=o.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(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.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-o.x(),2)+Math.pow(o.y()-y.y,2));const b=y.x<o.x()?-1:1,v=o.y()<y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,o.x(y.x-t),o.y(y.y+n)}h=o.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(o.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(o.x()-y.x,2)+Math.pow(o.y()-y.y,2));const b=this.findOne(".bottom-right").x()<y.x?-1:1,v=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*b,n=r*this.sin*v,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"),b=this.findOne(".bottom-right"),v=y.x(),A=y.y(),S=this.getWidth()-b.x(),w=this.getHeight()-b.y();b.move({x:-v,y:-A}),y.move({x:S,y:w})}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:fn.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();Cie--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(mt._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(mt._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new qf;if(o.rotate(fn.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=o.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=o.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=o.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=o.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:mt.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new qf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new qf,l=e.width/i,c=e.height/i;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 qf;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(mt._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(mt._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(S=>{S.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:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const c=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=mt.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,b=m+h*g,v=mt._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*v,y:b+h*u*v-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(S=>S.draggable()),x:0,y:0});const A=this.anchorStyleFunc();A&&l.forEach(S=>{A(S)}),(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=""),px.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(mt.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return pn.prototype.toObject.call(this)}clone(e){return pn.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Po.isTransforming=()=>Cie>0;function Bgr(e){return e instanceof Array||mt.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){h9.indexOf(t)===-1&&mt.warn("Unknown anchor name: "+t+". Available names are: "+h9.join(", "))}),e||[]}Po.prototype.className="Transformer",Is(Po),$e.addGetterSetter(Po,"enabledAnchors",h9,Bgr),$e.addGetterSetter(Po,"flipEnabled",!0,Kf()),$e.addGetterSetter(Po,"resizeEnabled",!0),$e.addGetterSetter(Po,"anchorSize",10,ln()),$e.addGetterSetter(Po,"rotateEnabled",!0),$e.addGetterSetter(Po,"rotateLineVisible",!0),$e.addGetterSetter(Po,"rotationSnaps",[]),$e.addGetterSetter(Po,"rotateAnchorOffset",50,ln()),$e.addGetterSetter(Po,"rotateAnchorAngle",0,ln()),$e.addGetterSetter(Po,"rotateAnchorCursor","crosshair"),$e.addGetterSetter(Po,"rotationSnapTolerance",5,ln()),$e.addGetterSetter(Po,"borderEnabled",!0),$e.addGetterSetter(Po,"anchorStroke","rgb(0, 161, 255)"),$e.addGetterSetter(Po,"anchorStrokeWidth",1,ln()),$e.addGetterSetter(Po,"anchorFill","white"),$e.addGetterSetter(Po,"anchorCornerRadius",0,ln()),$e.addGetterSetter(Po,"borderStroke","rgb(0, 161, 255)"),$e.addGetterSetter(Po,"borderStrokeWidth",1,ln()),$e.addGetterSetter(Po,"borderDash"),$e.addGetterSetter(Po,"keepRatio",!0),$e.addGetterSetter(Po,"shiftBehavior","default"),$e.addGetterSetter(Po,"centeredScaling",!1),$e.addGetterSetter(Po,"ignoreStroke",!1),$e.addGetterSetter(Po,"padding",0,ln()),$e.addGetterSetter(Po,"nodes"),$e.addGetterSetter(Po,"node"),$e.addGetterSetter(Po,"boundBoxFunc"),$e.addGetterSetter(Po,"anchorDragBoundFunc"),$e.addGetterSetter(Po,"anchorStyleFunc"),$e.addGetterSetter(Po,"shouldOverdrawWholeArea",!1),$e.addGetterSetter(Po,"useSingleNodeRotation",!0),$e.backCompat(Po,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Jm=class extends Qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,fn.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)}};Jm.prototype.className="Wedge",Jm.prototype._centroid=!0,Jm.prototype._attrsAffectingSize=["radius"],Is(Jm),$e.addGetterSetter(Jm,"radius",0,ln()),$e.addGetterSetter(Jm,"angle",0,ln()),$e.addGetterSetter(Jm,"clockwise",!1),$e.backCompat(Jm,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function r$e(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Hgr=[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],zgr=[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 Ugr(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,c,u,d,f,h,p,m,g,y,b,v,A,S,w,T,x;const C=t+t+1,k=r-1,P=o-1,E=t+1,L=E*(E+1)/2,R=new r$e,M=Hgr[t],O=zgr[t];let H=null,W=R,G=null,U=null;for(let F=1;F<C;F++)W=W.next=new r$e,F===E&&(H=W);W.next=R,a=s=0;for(let F=0;F<o;F++){g=y=b=v=l=c=u=d=0,f=E*(A=n[s]),h=E*(S=n[s+1]),p=E*(w=n[s+2]),m=E*(T=n[s+3]),l+=L*A,c+=L*S,u+=L*w,d+=L*T,W=R;for(let ne=0;ne<E;ne++)W.r=A,W.g=S,W.b=w,W.a=T,W=W.next;for(let ne=1;ne<E;ne++)i=s+((k<ne?k:ne)<<2),l+=(W.r=A=n[i])*(x=E-ne),c+=(W.g=S=n[i+1])*x,u+=(W.b=w=n[i+2])*x,d+=(W.a=T=n[i+3])*x,g+=A,y+=S,b+=w,v+=T,W=W.next;G=R,U=H;for(let ne=0;ne<r;ne++)n[s+3]=T=d*M>>O,T!==0?(T=255/T,n[s]=(l*M>>O)*T,n[s+1]=(c*M>>O)*T,n[s+2]=(u*M>>O)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=G.r,h-=G.g,p-=G.b,m-=G.a,i=a+((i=ne+t+1)<k?i:k)<<2,g+=G.r=n[i],y+=G.g=n[i+1],b+=G.b=n[i+2],v+=G.a=n[i+3],l+=g,c+=y,u+=b,d+=v,G=G.next,f+=A=U.r,h+=S=U.g,p+=w=U.b,m+=T=U.a,g-=A,y-=S,b-=w,v-=T,U=U.next,s+=4;a+=r}for(let F=0;F<r;F++){y=b=v=g=c=u=d=l=0,s=F<<2,f=E*(A=n[s]),h=E*(S=n[s+1]),p=E*(w=n[s+2]),m=E*(T=n[s+3]),l+=L*A,c+=L*S,u+=L*w,d+=L*T,W=R;for(let Y=0;Y<E;Y++)W.r=A,W.g=S,W.b=w,W.a=T,W=W.next;let ne=r;for(let Y=1;Y<=t;Y++)s=ne+F<<2,l+=(W.r=A=n[s])*(x=E-Y),c+=(W.g=S=n[s+1])*x,u+=(W.b=w=n[s+2])*x,d+=(W.a=T=n[s+3])*x,g+=A,y+=S,b+=w,v+=T,W=W.next,Y<P&&(ne+=r);s=F,G=R,U=H;for(let Y=0;Y<o;Y++)i=s<<2,n[i+3]=T=d*M>>O,T>0?(T=255/T,n[i]=(l*M>>O)*T,n[i+1]=(c*M>>O)*T,n[i+2]=(u*M>>O)*T):n[i]=n[i+1]=n[i+2]=0,l-=f,c-=h,u-=p,d-=m,f-=G.r,h-=G.g,p-=G.b,m-=G.a,i=F+((i=Y+E)<P?i:P)*r<<2,l+=g+=G.r=n[i],c+=y+=G.g=n[i+1],u+=b+=G.b=n[i+2],d+=v+=G.a=n[i+3],G=G.next,f+=A=U.r,h+=S=U.g,p+=w=U.b,m+=T=U.a,g-=A,y-=S,b-=w,v-=T,U=U.next,s+=r}}const Vgr=function(t){const n=Math.round(this.blurRadius());n>0&&Ugr(t,n)};$e.addGetterSetter(pn,"blurRadius",0,ln(),$e.afterSetFilter);const Ggr=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};$e.addGetterSetter(pn,"brightness",0,ln(),$e.afterSetFilter);const Wgr=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},jgr=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};$e.addGetterSetter(pn,"contrast",0,ln(),$e.afterSetFilter);const qgr=function(e){var t,n,r,o,i,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,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),m=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.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,b=p*255,v=m*Math.PI/180,A=Math.cos(v),S=Math.sin(v),w=128/1020*y,T=new Uint8ClampedArray(u),x=new Float32Array(d*f);for(let L=0,R=0;R<u.length;R+=4,L++)x[L]=.2126*T[R]+.7152*T[R+1]+.0722*T[R+2];const C=[-1,0,1,-2,0,2,-1,0,1],k=[-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 M=L*d+R;let O=0,H=0;O+=x[M+P[0]]*C[0],H+=x[M+P[0]]*k[0],O+=x[M+P[1]]*C[1],H+=x[M+P[1]]*k[1],O+=x[M+P[2]]*C[2],H+=x[M+P[2]]*k[2],O+=x[M+P[3]]*C[3],H+=x[M+P[3]]*k[3],O+=x[M+P[5]]*C[5],H+=x[M+P[5]]*k[5],O+=x[M+P[6]]*C[6],H+=x[M+P[6]]*k[6],O+=x[M+P[7]]*C[7],H+=x[M+P[7]]*k[7],O+=x[M+P[8]]*C[8],H+=x[M+P[8]]*k[8];const W=E(b+(A*O+S*H)*w),G=M*4;if(g){const U=W-b;u[G]=E(T[G]+U),u[G+1]=E(T[G+1]+U),u[G+2]=E(T[G+2]+U),u[G+3]=T[G+3]}else u[G]=u[G+1]=u[G+2]=W,u[G+3]=T[G+3]}for(let L=0;L<d;L++){let R=L*4,M=((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[M]=T[M],u[M+1]=T[M+1],u[M+2]=T[M+2],u[M+3]=T[M+3]}for(let L=1;L<f-1;L++){let R=L*d*4,M=(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[M]=T[M],u[M+1]=T[M+1],u[M+2]=T[M+2],u[M+3]=T[M+3]}return e};$e.addGetterSetter(pn,"embossStrength",.5,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"embossWhiteLevel",.5,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"embossDirection","top-left",void 0,$e.afterSetFilter),$e.addGetterSetter(pn,"embossBlend",!1,void 0,$e.afterSetFilter);function Eie(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}const Kgr=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,c=t[2],u=c,d;const f=this.enhance();if(f===0)return;for(let v=0;v<n;v+=4)i=t[v+0],i<r?r=i:i>o&&(o=i),l=t[v+1],l<s?s=l:l>a&&(a=l),d=t[v+2],d<c?c=d:d>u&&(u=d);o===r&&(o=255,r=0),a===s&&(a=255,s=0),u===c&&(u=255,c=0);let h,p,m,g,y,b;if(f>0)h=o+f*(255-o),p=r-f*(r-0),m=a+f*(255-a),g=s-f*(s-0),y=u+f*(255-u),b=c-f*(c-0);else{const v=(o+r)*.5;h=o+f*(o-v),p=r+f*(r-v);const A=(a+s)*.5;m=a+f*(a-A),g=s+f*(s-A);const S=(u+c)*.5;y=u+f*(u-S),b=c+f*(c-S)}for(let v=0;v<n;v+=4)t[v+0]=Eie(t[v+0],r,o,p,h),t[v+1]=Eie(t[v+1],s,a,g,m),t[v+2]=Eie(t[v+2],c,u,b,y)};$e.addGetterSetter(pn,"enhance",0,ln(),$e.afterSetFilter);const Ygr=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};$e.addGetterSetter(pn,"hue",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"saturation",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"luminance",0,ln(),$e.afterSetFilter);const Xgr=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*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 b,v,A,S;for(let w=0;w<n;w+=4)b=t[w+0],v=t[w+1],A=t[w+2],S=t[w+3],t[w+0]=c*b+u*v+d*A+s,t[w+1]=f*b+h*v+p*A+s,t[w+2]=m*b+g*v+y*A+s,t[w+3]=S},Jgr=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*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 b=t[y+0],v=t[y+1],A=t[y+2],S=t[y+3];t[y+0]=l*b+c*v+u*A,t[y+1]=d*b+f*v+h*A,t[y+2]=p*b+m*v+g*A,t[y+3]=S}};$e.addGetterSetter(pn,"hue",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"saturation",0,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"value",0,ln(),$e.afterSetFilter);const Zgr=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 Qgr=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=i,m=360/p*Math.PI/180;for(let g=0;g<p;g+=1){const y=Math.sin(g*m),b=Math.cos(g*m);for(let v=0;v<h;v+=1){u=Math.floor(a+c*v/h*b),d=Math.floor(l+c*v/h*y);let A=(d*i+u)*4;const S=r[A+0],w=r[A+1],T=r[A+2],x=r[A+3];A=(g+v*i)*4,o[A+0]=S,o[A+1]=w,o[A+2]=T,o[A+3]=x}}},$gr=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let c=Math.sqrt(a*a+l*l),u=i-a,d=s-l;const f=Math.sqrt(u*u+d*d);c=f>c?f:c;const h=s,p=i,m=n.polarRotation||0;let g,y;for(u=0;u<i;u+=1)for(d=0;d<s;d+=1){const b=u-a,v=d-l,A=Math.sqrt(b*b+v*v)*h/c;let S=(Math.atan2(v,b)*180/Math.PI+360+m)%360;S=S*p/360,g=Math.floor(S),y=Math.floor(A);let w=(y*i+g)*4;const T=r[w+0],x=r[w+1],C=r[w+2],k=r[w+3];w=(d*i+u)*4,o[w+0]=T,o[w+1]=x,o[w+2]=C,o[w+3]=k}};const e0r=function(e){const t=e.width,n=e.height;let r,o,i,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=mt.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);mt.releaseCanvas(g),Qgr(e,y,{polarCenterX:t/2,polarCenterY:n/2});let b=t/Math.pow(2,h);for(;b<=8;)b=b*2,h-=1;b=Math.ceil(b);let v=b,A=0,S=v,w=1;for(m+b>t&&(A=v,S=0,w=-1),o=0;o<n;o+=1)for(r=A;r!==S;r+=w)i=Math.round(r+m)%t,d=(t*o+i)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*o+r)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;for(o=0;o<n;o+=1)for(v=Math.floor(b),s=0;s<h;s+=1){for(r=0;r<v+1;r+=1)d=(t*o+r)*4,a=y.data[d+0],l=y.data[d+1],c=y.data[d+2],u=y.data[d+3],f=(t*o+v*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;v*=2}$gr(y,e,{polarRotation:0})};$e.addGetterSetter(pn,"kaleidoscopePower",2,ln(),$e.afterSetFilter),$e.addGetterSetter(pn,"kaleidoscopeAngle",0,ln(),$e.afterSetFilter);function p9(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function lP(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 t0r(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 n0r(e,t){const n=p9(e,0,0),r=p9(e,e.width-1,0),o=p9(e,0,e.height-1),i=p9(e,e.width-1,e.height-1),s=t||10;if(lP(n,r)<s&&lP(r,i)<s&&lP(i,o)<s&&lP(o,n)<s){const a=t0r([r,n,i,o]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=lP(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function r0r(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function o0r(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u===2040?255:0}return s}function i0r(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u>=1020?255:0}return s}function s0r(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/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<o;d++)for(let f=0;f<o;f++){const h=a+d-i,p=l+f-i;if(h>=0&&h<n&&p>=0&&p<t){const m=h*t+p,g=r[d*o+f];u+=e[m]*g}}s[c]=u}return s}const a0r=function(e){let t=n0r(e,this.threshold());return t&&(t=o0r(t,e.width,e.height),t=i0r(t,e.width,e.height),t=s0r(t,e.width,e.height),r0r(e,t)),e};$e.addGetterSetter(pn,"threshold",0,ln(),$e.afterSetFilter);const l0r=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};$e.addGetterSetter(pn,"noise",.2,ln(),$e.afterSetFilter);const c0r=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){mt.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;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 b=h;b<p;b+=1)if(!(b>=n))for(let v=m;v<g;v+=1){if(v>=r)continue;const A=(n*v+b)*4;c+=s[A+0],u+=s[A+1],d+=s[A+2],f+=s[A+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let b=h;b<p;b+=1)if(!(b>=n))for(let v=m;v<g;v+=1){if(v>=r)continue;const A=(n*v+b)*4;s[A+0]=c,s[A+1]=u,s[A+2]=d,s[A+3]=f}}};$e.addGetterSetter(pn,"pixelSize",8,ln(),$e.afterSetFilter);const u0r=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};$e.addGetterSetter(pn,"levels",.5,ln(),$e.afterSetFilter);const d0r=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=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*o,t[s+2]=a*i,t[s+3]=t[s+3]}};$e.addGetterSetter(pn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"blue",0,rQe,$e.afterSetFilter);const f0r=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=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]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};$e.addGetterSetter(pn,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),$e.addGetterSetter(pn,"blue",0,rQe,$e.afterSetFilter),$e.addGetterSetter(pn,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const h0r=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},p0r=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},m0r=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};$e.addGetterSetter(pn,"threshold",.5,ln(),$e.afterSetFilter);var g0r=MQe.Util._assign(MQe,{Arc:Ym,Arrow:Aw,Circle:gx,Ellipse:xy,Image:Yf,Label:Iie,Tag:Sw,Line:Xm,Path:Kd,Rect:iP,RegularPolygon:ky,Ring:Tw,Sprite:hp,Star:Cy,Text:Xi,TextPath:Pa,Transformer:Po,Wedge:Jm,Filters:{Blur:Vgr,Brightness:Wgr,Brighten:Ggr,Contrast:jgr,Emboss:qgr,Enhance:Kgr,Grayscale:Ygr,HSL:Xgr,HSV:Jgr,Invert:Zgr,Kaleidoscope:e0r,Mask:a0r,Noise:l0r,Pixelate:c0r,Posterize:u0r,RGB:d0r,RGBA:f0r,Sepia:h0r,Solarize:p0r,Threshold:m0r}});tn();var y0r=["dialog","floating"],o$e=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function b0r(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!y0r.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&&!o$e.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${o$e.join(", ")}, got "${e.floating.placement}".`)}var v0r=class{activeDialog=od(null);activeFloating=od(null);#e=!1;#t=1;#o;constructor({getModuleConfig:e}){this.#o=e}open(e){if(this.#e)return this.#u(e);b0r(e);const t=this.#s(e),{component:n,props:r,render:o}=this.#c(t);let i,s=!1;const a=new Promise(h=>{i=p=>s?!1:(s=!0,h(p),!0)});let l;const c=h=>{i({status:"submitted",data:h})&&this.#r(l)},u=h=>{i({status:"closed",reason:h})&&this.#r(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:c,close:u,settle:h=>i(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 o=this.#i(e);o&&this.#n(o,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)}#i(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#s(e){const t=e.id??`surface-${this.#t++}`,n=this.#o()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=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:o,floating:i}}#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.#o()?.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"})}}},w0r="https://docs.superdoc.dev/guides/migration/document-api",i$e=new Set;function A0r(e,t){i$e.has(e)||(i$e.add(e),console.warn(t))}var S0r={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},s$e=Symbol.for("superdoc:rawEditor"),a$e=new WeakMap;function l$e(e){return!e||e[s$e]?e:new Proxy(e,{get(t,n){if(n===s$e)return t;const r=S0r[n];r&&A0r(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${w0r}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=a$e.get(t);return i||(i=new Map,a$e.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var c$e=["review","original","final","off"],T0r=["paired","independent"],u$e=Symbol.for("@superdoc/trackChanges:normalized"),d$e=new Set;function f$e(e,t){d$e.has(e)||(d$e.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function h$e(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function I0r(e,t,n){return typeof e=="string"&&c$e.includes(e)?e:typeof t=="string"&&c$e.includes(t)?t:n}function x0r(e){return typeof e=="string"&&T0r.includes(e)?e:null}function bx(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function k0r(e){const t=e[u$e]===!0;bx(e.modules)||(e.modules={});const n=bx(e.modules.trackChanges),r=bx(e.trackChanges),o=bx(e.layoutEngineOptions?.trackedChanges);t||(r&&f$e("config.trackChanges","config.modules.trackChanges"),o&&f$e("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=h$e(n?.visible,r?.visible,!1),s=h$e(n?.enabled,o?.enabled,!0),a=x0r(n?.replacements)??"paired",l=bx(n?.authorColors)?n.authorColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",u=I0r(n?.mode,o?.mode,c),d={visible:i,mode:u,enabled:s,replacements:a};return l&&(d.authorColors=l),e.modules.trackChanges=d,e.trackChanges={visible:i},bx(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:u,enabled:s},Object.defineProperty(e,u$e,{value:!0,writable:!0,configurable:!0,enumerable:!1}),d}var C0r=class{#e=new Map;#t=new Map;#o=null;#n=new Set;register(e){if(this.#e.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#t.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#e.set(e.id,e),t&&this.#t.set(t,e.id)}unregister(e){const t=this.#e.get(e);return t?(this.#e.delete(e),t.root&&this.#t.delete(t.root),this.#o===e&&(this.#o=null,this.#r({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#e.get(e)??null}getAll(){return Array.from(this.#e.values())}getAllByDocumentId(e){const t=[];for(const n of this.#e.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#o===null?null:this.#e.get(this.#o)}getActiveId(){return this.#o}setActive(e,t){if(e!==null&&!this.#e.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#o)return;const n=this.#o;this.#o=e;let r=null;e!==null&&(r=this.#e.get(e).getLegacyEditorProjection?.()??null),this.#r({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${X8}]`);if(!n)return null;const r=n.getAttribute(X8),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#n.add(e),()=>{this.#n.delete(e)}}clear(){this.#e.clear(),this.#t.clear(),this.#o=null,this.#n.clear()}#r(e){for(const t of Array.from(this.#n))try{t(e)}catch{}}};tn();var m9=Object.freeze({id:null,name:"Default SuperDoc user",email:null}),E0r=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"]);function Zm(e){return e?e.presentationEditor??null:null}function _ie(e){if(!e||typeof e!="object")return!1;const t=e;return!!t.commands&&typeof t.commands=="object"}var g9=class extends s4.default{static{this.allowedTypes=[Kc,_k,$N]}#e=!1;#t=!1;#o=null;#n=null;#r;#i=new C0r;#s=null;#c=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...m9},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},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,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!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.#r=new v0r({getModuleConfig:()=>this.config.modules?.surfaces}),this.#u(e,t)}async#u(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),k0r(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};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 o=this.config.user;if(!o||typeof o!="object"?this.config.user={...m9}:(this.config.user={...m9,...o},this.config.user.name||(this.config.user.name=m9.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.modules.comments=phr(this.config.modules.comments),this.config.colors=Ilt(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.45.0",this.#F("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||hn(),this.colors=this.config.colors??[],this.#a(),await this.#T(this.config.modules),this.#e){this.#ee();return}this.config.cspNonce&&this.#p(),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.#s||(this.#s=this.#i.subscribe(s=>{this.#W(s.nextRuntimeId,s.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const i=document.createElement("div");i.style.display="contents",t.appendChild(i),this.#n=i,this.#S(),this.#f(),this.#H(),this.#d()}#d(){if(this.#b(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#n)}#f(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new qpr({Renderer:g0r,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#x("requiredNumberOfEditors").documents.filter(e=>e.type===Kc).length}get state(){return{documents:this.#x("state").documents,users:this.users}}getPresentationEditorForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getPresentationEditor?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#p(){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}}#a(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}else if(n)this.config.documents=[{id:hn(),type:Kc,url:this.config.document,name:"document.docx"}];else if(r){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}else if(o){const s=VR(this.config.document);this.config.documents=[{id:hn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=VR(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||hn()}}))}#b(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=Fpr({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=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&q8(this),this.#de()}#l(e,t){t&&this.on(e,t)}#S(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#T({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:hn(),type:Kc,name:"document.docx"}]),this.#y(n,r),q8(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Fde({url:e.url}));const o=vur(this);if(t&&t.useInternalExternalComments&&!t.suppressInternalExternalComments){const i=bur(this);if(!i)throw new Error("SuperDoc: `modules.comments.useInternalExternalComments` requires `superdocId` to be set in the config.");this.ydoc=li(i.ydoc),this.provider=li(i.provider)}else this.ydoc=li(o[0].ydoc),this.provider=li(o[0].provider);return q8(this),o}#y(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=li(e),this.provider=li(t),this.#v();const n=this.config;this._cleanupAwareness=mur(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#w(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#v(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:E0r,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration({ydoc:e,provider:t}){this.#L({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#M();await this.#D(t),this.#C(),Gnn(n,e),Upr(e,this.#h("upgradeToCollaboration").commentsList),Vpr(e,{isLocked:this.isLocked??!1,lockedBy:this.lockedBy??null}),this.config.modules.collaboration={ydoc:e,provider:t},this.#y(e,t),this.#I(e,t);const r=this.#k();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(o){throw this.#E(),o}if(await this.#R(r),this.#e)return;q8(this)}finally{this.#o=null,this.#t=!1}}#C(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#x(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#h(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#m(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#I(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=Co(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#k(){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}#E(){this.#w(),this.#I(null,null)}#R(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),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=()=>{i(),r(void 0)};this.#o=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#D(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=cv(e,()=>{i||(a(),n())}),i||(o=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.#o=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#L({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,r=n.documents.filter(o=>o.type===Kc);if(r.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(r.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(n.documents.length!==r.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances")}#M(){const e=this.config.documents.find(n=>n.type===Kc),t=this.#x("upgradeToCollaboration").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.#m("addSharedUser");const t=bA({actor:e});t&&this.users.some(n=>bA({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#m("removeSharedUser");const t=typeof e=="string"?eL(e):"",n=typeof e=="string"?`email:${t}`:bA({actor:e});this.users=this.users.filter(r=>{const o=bA({actor:r});return n?o!==n:t?eL(r.email)!==t:!0})}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.#x("onContentError").documents.find(o=>o.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:l$e(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#_(e),this.emit("editorCreate",{editor:l$e(e)})}#A=new WeakSet;#_(e){if(!e||typeof e.on!="function"||this.#A.has(e))return;this.#A.add(e),e.on("fonts-changed",n=>{this.#G(e)&&this.#O(n)});const t=e.presentationEditor?.getLastFontsChangedPayload?.();t&&this.#G(e)&&this.#O(t)}#G(e){return!this.activeEditor||e===this.activeEditor}#oe=null;#O(e){this.#oe=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#F(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}#V=null;get fonts(){return this.#V||(this.#V={getReport:()=>Zm(this.activeEditor)?.getFontReport()??[],getMissingFonts:()=>Zm(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>Zm(this.activeEditor)?.getDocumentFontOptions()??[],getDocumentFonts:()=>[...new Set((Zm(this.activeEditor)?.getFontReport()??[]).map(e=>e.logicalFamily))],onReport:e=>{const t=this.activeEditor,n=t?Zm(t)?.getLastFontsChangedPayload?.()??null:this.#oe??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.mapFonts(e)},unmap:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmapFonts(e)},add:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.addFonts(Array.isArray(e)?e:[e])},preload:e=>{const t=Zm(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preloadFonts(e)}}),this.#V}#X(){this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null)}#J(e){this.activeEditor=e,this.toolbar&&(e.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}#W(e,t){this.#c=!0;try{if(e===null){this.#X();return}this.#i.get(e)?.kind==="v1"&&_ie(t)?this.setActiveEditor(t):this.#X()}finally{this.#c=!1}}#le(e){if(!e)return null;for(const n of this.#i.getAll())if(n.kind==="v1"&&n.getLegacyEditorProjection?.()===e)return n.id;const t=e.options?.documentId;if(typeof t=="string"&&t.length>0){const n=this.#i.getAllByDocumentId(t).filter(r=>r.kind==="v1");if(n.length===1)return n[0].id}return null}setActiveEditor(e){if(!_ie(e)){this.#X();return}if(!this.#c){const t=this.#le(e);if(t!==null){const n=this.#i.getActive()?.id===t;if(this.#i.setActive(t,"set-active-editor"),n){const r=this.#i.get(t)?.getLegacyEditorProjection?.()??null;_ie(r)?this.#J(r):this.#X()}return}}this.#J(e)}registerEditorRuntime(e){this.#i.register(e)}unregisterEditorRuntime(e){return this.#i.unregister(e)}getActiveRuntime(){return this.#i.getActive()}setActiveRuntime(e,t){this.#i.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#i.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#i.resolveFromEventTarget(e);return n?(this.#i.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#x("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers})}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return mw(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#H(){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 lBe({selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups: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.config.onException&&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 ffr(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,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,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 o=n.getEditor?.();o?.setOptions&&o.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)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getPresentationEditor?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#m("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#de();const t={viewing:()=>this.#pe(),editing:()=>this.#ue(),suggesting:()=>this.#$()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#Z(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null,r=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;let o=!1;if(n){const s=this.#i.getAllByDocumentId(n);if(s.length>0){for(const a of s)a.setDocumentMode(t);o=!0}}if(r){(!o||t!=="viewing"||this.#te(r,t))&&r.setDocumentMode(t);return}if(o)return;const i=typeof e.getEditor=="function"?e.getEditor():null;i&&i.setDocumentMode(t)}#te(e,t){const n=e.element?.classList;return!n||typeof n.contains!="function"?!1:n.contains("presentation-editor--viewing")!==(t==="viewing")}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)})}#ue(){if(this.config.role!=="editor")return this.#$();const e=this.#x("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"editing")})}#$(){if(!["editor","suggester"].includes(this.config.role??""))return this.#pe();const e=this.#x("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"suggesting")})}#pe(){const e=this.#x("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const t=this.config.comments?.visible===!0,n=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(n?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!t&&!n&&this.commentsStore?.clearEditorCommentPositions?.(),e.documents.forEach(r=>{t||n?r.restoreComments?.():r.removeComments?.(),this.#Z(r,"viewing")})}#de(){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 o=this.superdocStore?.documents;Array.isArray(o)&&o.length>0&&o.forEach(i=>{const s=typeof i.getPresentationEditor=="function"?i.getPresentationEditor():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return n.call(t,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}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}this.superdocStore.zoomMode!==e&&(this.superdocStore.zoomMode=e,this.emit("zoomChange",{zoom:this.getZoom(),mode:e}))}getZoomState(){const e=MJe(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}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.#x("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.isLocked=e,this.lockedBy=t,this.#F("🦋 [superdoc] Locking superdoc:",e,t,`
2140
2140
 
2141
2141
 
2142
2142
  `),this.emit("locked",{isLocked:e,lockedBy:t})}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:o=[],isFinalDoc:i=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=XZe(n||this.config.title),c=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),u=[...r],d=[...o];if(e.includes("docx")&&c.forEach(h=>{u.push(h),d.push(`${l}.docx`)}),u.length===1)return s?YZe(u[0],l,e[0]):u[0];const f=await qXe(u,d);return s?YZe(f,l,"zip"):f}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){let r;const o=this.config?.modules?.comments!==!1;e==="clean"?r=[]:o&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(r=this.commentsStore.translateCommentsForExport(),Array.isArray(r)||(r=[]));const i=new WeakSet,s=a=>{"editor"in a&&a.error&&typeof a.error=="object"&&i.add(a.error)};this.on("exception",s);try{const a=this.#x("exportEditorsToDOCX").documents.map(async l=>{if(!l||l.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const c=typeof l.getEditor=="function"?l.getEditor():null,u=()=>!l.data||l.data.type&&l.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:l.data;if(!c)return u();try{const d=await c.exportDocx({isFinalDoc:t,comments:r,commentsType:e,fieldsHighlightColor:n});if(d)return d}catch(d){(!d||typeof d!="object"||!i.has(d))&&this.emit("exception",{error:d,document:l})}return u()});return(await Promise.all(a)).filter(l=>l!=null)}finally{this.off("exception",s)}}async#Ae(){this.#F("🦋 [superdoc] Triggering collaboration saves");const e=this.#x("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#F(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#F(`After increment - Doc ${r}: pending = ${this.pendingCollaborationSaves}`);const o=n.ydoc.getMap("meta");o.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&t())}),o.set("immediate-save",!0)}}),this.#F(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#Ae()];this.#F("🦋 [superdoc] Saving superdoc"),await Promise.all(e),this.#F("🦋 [superdoc] Save complete")}#ee(){typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.(),e.documents.forEach(t=>{t.provider?.disconnect?.(),t.provider?.destroy?.(),t.ydoc?.destroy()})}openSurface(e){return this.#r.open(e)}closeSurface(e){this.#r.close(e)}destroy(){this.#e=!0,this.#o&&(this.#o(),this.#o=null),this.#r&&this.#r.destroy(),this.toolbar?.destroy(),this.app&&(this.#F("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#ee(),this.#s?.(),this.#s=null,this.#i.clear(),this.#n&&(this.#n.remove(),this.#n=null)}focus(){const e=this.getActiveRuntime();if(e?.getCapabilities().lifecycle.canFocus){e.focus().catch(t=>{console.warn("[SuperDoc] active editor runtime focus failed",t)});return}this.activeEditor?this.activeEditor.focus?.():this.#x("focus").documents.find(t=>{const n=t.getEditor?.();return n?(n.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};const _0r=async(e={})=>{const{editor:t,extensions:n,mode:r="docx"}=e;if(t)return t.getSchemaSummaryJSON();const o=new Um({extensions:Array.isArray(n)&&n.length?n:r==="docx"?O5():Lv(),mode:r,isHeadless:!0,deferDocumentLoad:!0,telemetry:{enabled:!1}});try{return await o.getSchemaSummaryJSON()}finally{typeof o.destroy=="function"&&o.destroy()}};var R0r={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"},P0r=0;function p$e(e){const{name:t,font:n,radius:r,shadow:o,colors:i,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++P0r}`}`,l=[];if(i)for(const[c,u]of Object.entries(i)){if(u==null)continue;const d=R0r[c];d&&l.push(` ${d}: ${u};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),o!=null&&l.push(` --sd-ui-shadow: ${o};`),s)for(const[c,u]of Object.entries(s))u!=null&&l.push(` ${c}: ${u};`);return{className:a,css:l.length>0?`.${a} {