@harbour-enterprises/superdoc 1.37.0-next.2 → 1.37.0-next.3

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-CULDM68i.cjs → SuperConverter-CTVXn3xu.cjs} +1 -1
  2. package/dist/chunks/{SuperConverter-wuBlC2O6.es.js → SuperConverter-Dt8r9AxW.es.js} +1 -1
  3. package/dist/chunks/{create-headless-toolbar-QMlAOGA1.cjs → create-headless-toolbar-BNXtrEIy.cjs} +1 -1
  4. package/dist/chunks/{create-headless-toolbar-Bsc3zsJe.es.js → create-headless-toolbar-C-jN8cp_.es.js} +1 -1
  5. package/dist/chunks/{create-super-doc-ui-CWw9AaiX.es.js → create-super-doc-ui-BKxUaZQJ.es.js} +2 -2
  6. package/dist/chunks/{create-super-doc-ui--t9EUsbh.cjs → create-super-doc-ui-nEjgUWtm.cjs} +2 -2
  7. package/dist/chunks/{create-theme-BA_c5ED9.es.js → create-theme-CInFDZOa.es.js} +5 -5
  8. package/dist/chunks/{create-theme-CiV-x5T1.cjs → create-theme-n6TZSI3F.cjs} +5 -5
  9. package/dist/chunks/{react-B7PIE9ou.es.js → react-BA_72rFO.es.js} +1 -1
  10. package/dist/chunks/{react-DdgQ6Kv9.cjs → react-BO8Fa7p8.cjs} +1 -1
  11. package/dist/chunks/{react-DHyoZ7nl.cjs → react-Cb7hbB2a.cjs} +1 -1
  12. package/dist/chunks/{react-B0XH6MSw.es.js → react-D1F2OKGD.es.js} +1 -1
  13. package/dist/chunks/{src-BJwOlwPE.es.js → src-BD6zOi1Z.es.js} +5 -5
  14. package/dist/chunks/{src-CKtDV1o-.cjs → src-CG1ZKRzP.cjs} +5 -5
  15. package/dist/chunks/{vue-ZV1Wark8.es.js → vue-BcOx51wv.es.js} +1 -1
  16. package/dist/chunks/{vue-CjT3wY_F.cjs → vue-Drb1inqY.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 +1 -1
@@ -2,7 +2,7 @@ var SuperDoc=(function(){var XKe=Object.create,dR=Object.defineProperty,JKe=Obje
2
2
  `)}},J9=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[sx]?Zie(e,t):yy(e)?_9(e,n=>R9(t,r=>J9(n,r))):BJe(e)?dw(e,(n,r)=>J9(n,t[r])):!1,Xl=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),J9(t,n)}equals(e){return this.constructor===e.constructor&&fw(this.shape,e.shape)}[bZe](){return!0}[sx](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ju()}get nullable(){return hw(this,cP)}get optional(){return new hse(this)}cast(e){return Cse(e,this),e}expect(e){return Cse(e,this),e}},Z9=class extends Xl{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 $s=(e,t=null)=>new Z9(e,t),Iir=$s(Z9);var Q9=class extends Xl{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 Ea=e=>new Q9(e),Sir=$s(Q9);var oP=class extends Xl{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 iP=(...e)=>new oP(e),dse=$s(oP);var wZe=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),fse=e=>{if(mw.check(e))return[wZe(e)];if(dse.check(e))return e.shape.map(t=>t+"");if(Tse.check(e))return["[+-]?\\d+.?\\d*"];if(xse.check(e))return[".*"];if(sP.check(e))return e.shape.map(fse).flat(1);Kl()},AZe=class extends Xl{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(fse).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 Tir=$s(AZe);var IZe=Symbol("optional"),hse=class extends Xl{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[IZe](){return!0}};const SZe=$s(hse);var pse=class extends Xl{check(e,t){return t?.extend(null,"never",typeof e),!1}};const xir=new pse,kir=$s(pse);var mse=class Kqe extends Xl{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new Kqe(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):dw(this.shape,(r,o)=>{const i=this._isPartial&&!U9(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 TZe=e=>new mse(e),xZe=$s(mse),kZe=Ea(e=>e!=null&&(e.constructor===Object||e.constructor==null));var gse=class extends Xl{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&dw(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 yse=(e,t)=>new gse(e,t),CZe=$s(gse);var bse=class extends Xl{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&dw(this.shape,(n,r)=>{const o=n.check(e[r],t);return!o&&t?.extend(r.toString(),"Tuple",typeof n),o})}};const EZe=(...e)=>new bse(e),Cir=$s(bse);var vse=class extends Xl{constructor(e){super(),this.shape=e.length===1?e[0]:new $9(e)}check(e,t){const n=yy(e)&&_9(e,r=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}};const wse=(...e)=>new vse(e),_Ze=$s(vse),RZe=Ea(e=>yy(e));var Ase=class extends Xl{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 PZe=(e,t=null)=>new Ase(e,t),Eir=$s(Ase),LZe=PZe(Xl);var NZe=class extends Xl{constructor(e){super(),this.len=e.length-1,this.args=EZe(...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 MZe=$s(NZe),DZe=Ea(e=>typeof e=="function");var OZe=class extends Xl{constructor(e){super(),this.shape=e}check(e,t){const n=_9(this.shape,r=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}};const _ir=$s(OZe,e=>e.shape.length>0);var $9=class extends Xl{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=R9(this.shape,r=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}};const hw=(...e)=>e.findIndex(t=>sP.check(t))>=0?hw(...e.map(t=>ax(t)).map(t=>sP.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new $9(e),sP=$s($9);var Ise=()=>!0;const aP=Ea(Ise),FZe=$s(Q9,e=>e.shape===Ise),e4=Ea(e=>typeof e=="bigint"),BZe=Ea(e=>e===e4),Sse=Ea(e=>typeof e=="symbol"),Rir=Ea(e=>e===Sse),pw=Ea(e=>typeof e=="number"),Tse=Ea(e=>e===pw),mw=Ea(e=>typeof e=="string"),xse=Ea(e=>e===mw),lP=Ea(e=>typeof e=="boolean"),HZe=Ea(e=>e===lP),kse=iP(void 0),Pir=$s(oP,e=>e.shape.length===1&&e.shape[0]===void 0),Lir=iP(void 0),cP=iP(null),zZe=$s(oP,e=>e.shape.length===1&&e.shape[0]===null),Nir=$s(Uint8Array),Mir=$s(Z9,e=>e.shape===Uint8Array),UZe=hw(pw,mw,cP,kse,e4,lP,Sse),Dir=(()=>{const e=wse(aP),t=yse(mw,aP),n=hw(pw,mw,cP,lP,e,t);return e.shape=n,t.shape.values=n,n})(),ax=e=>{if(LZe.check(e))return e;if(kZe.check(e)){const t={};for(const n in e)t[n]=ax(e[n]);return TZe(t)}else{if(RZe.check(e))return hw(...e.map(ax));if(UZe.check(e))return iP(e);if(DZe.check(e))return $s(e)}Kl()},Cse=XJe?()=>{}:(e,t)=>{const n=new vZe;if(!t.check(e,n))throw Jf(`Expected value to be of type ${t.constructor.name}.
3
3
  ${n.toString()}`)};var VZe=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:ax(e),h:t}),this}else(e){return this.if(aP,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 Jf("Unhandled pattern")}}},Ese=(e=>new VZe(e))(aP).if(Tse,(e,t)=>K9(t,Fie,YR)).if(xse,(e,t)=>yZe(t)).if(HZe,(e,t)=>cse(t)).if(BZe,(e,t)=>BigInt(K9(t,Fie,YR))).if(sP,(e,t)=>gw(t,X9(t,e.shape))).if(xZe,(e,t)=>{const n={};for(const r in e.shape){let o=e.shape[r];if(SZe.check(o)){if(cse(t))continue;o=o.shape}n[r]=Ese(o,t)}return n}).if(_Ze,(e,t)=>{const n=[],r=use(t,0,42);for(let o=0;o<r;o++)n.push(gw(t,e.shape));return n}).if(dse,(e,t)=>X9(t,e.shape)).if(zZe,(e,t)=>null).if(MZe,(e,t)=>{const n=gw(t,e.res);return()=>n}).if(FZe,(e,t)=>gw(t,X9(t,[pw,mw,cP,kse,e4,lP,wse(pw),yse(hw("a","b","c"),pw)]))).if(CZe,(e,t)=>{const n={},r=K9(t,0,3);for(let o=0;o<r;o++){const i=gw(t,e.shape.keys);n[i]=gw(t,e.shape.values)}return n}).done();const gw=(e,t)=>Ese(ax(t),e),Km=typeof document<"u"?document:{},Fir=Ea(e=>e.nodeType===KZe),Bir=typeof DOMParser<"u"?new DOMParser:null,Hir=Ea(e=>e.nodeType===WZe),zir=Ea(e=>e.nodeType===jZe),GZe=e=>NJe(e,(t,n)=>`${n}:${t};`).join(""),WZe=Km.ELEMENT_NODE,jZe=Km.TEXT_NODE,Uir=Km.CDATA_SECTION_NODE,Vir=Km.COMMENT_NODE,qZe=Km.DOCUMENT_NODE,Gir=Km.DOCUMENT_TYPE_NODE,KZe=Km.DOCUMENT_FRAGMENT_NODE,Wir=Ea(e=>e.nodeType===qZe);var uP=e=>class{constructor(n){this._=n}destroy(){e(this._)}},YZe=uP(clearTimeout);const t4=(e,t)=>new YZe(setTimeout(t,e));var jir=uP(clearInterval);const qir=uP(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var Kir=uP(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));const yp=Symbol,_se=yp(),Rse=yp(),XZe=yp(),JZe=yp(),ZZe=yp(),Pse=yp(),QZe=yp(),n4=yp(),$Ze=yp(),eQe=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 Yir=Kd(),tQe={[_se]:gp("font-weight","bold"),[Rse]:gp("font-weight","normal"),[XZe]:gp("color","blue"),[ZZe]:gp("color","green"),[JZe]:gp("color","grey"),[Pse]:gp("color","red"),[QZe]:gp("color","purple"),[n4]:gp("color","orange"),[$Ze]:gp("color","black")},nQe=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=Yl();let o=[],i=0;for(;i<e.length;i++){const s=e[i],a=tQe[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=GZe(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},Lse=ZJe?nQe:eQe;const rQe=(...e)=>{console.log(...Lse(e)),Mse.forEach(t=>t.print(e))},Nse=(...e)=>{console.warn(...Lse(e)),e.unshift(n4),Mse.forEach(t=>t.print(e))},Mse=hp(),Dse=e=>({[Symbol.iterator](){return this},next:e}),oQe=(e,t)=>Dse(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),r4=(e,t)=>Dse(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var dP=class{constructor(e,t){this.clock=e,this.len=t}},yw=class{constructor(){this.clients=new Map}},Ym=(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])eae(e,i,c.clock,c.len,n)}}),iQe=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const o=Xu((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},bw=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&iQe(n,t.clock)!==null},o4=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 dP(o.clock,qd(o.len,i.clock+i.len-o.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},i4=e=>{const t=new yw;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++)oJe(i,e[s].clients.get(o)||[]);t.clients.set(o,i)}});return o4(t),t},lx=(e,t,n,r)=>{Zu(e.clients,t,()=>[]).push(new dP(n,r))},s4=()=>new yw,Ose=e=>{const t=s4();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 dP(a,l))}}o.length>0&&t.clients.set(r,o)}),t},vw=(e,t)=>{En(e.restEncoder,t.clients.size),pp(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),En(e.restEncoder,n);const o=r.length;En(e.restEncoder,o);for(let i=0;i<o;i++){const s=r[i];e.writeDsClock(s.clock),e.writeDsLen(s.len)}})},a4=e=>{const t=new yw,n=Dr(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const o=Dr(e.restDecoder),i=Dr(e.restDecoder);if(i>0){const s=Zu(t.clients,o,()=>[]);for(let a=0;a<i;a++)s.push(new dP(e.readDsClock(),e.readDsLen()))}}return t},Fse=(e,t,n)=>{const r=new yw,o=Dr(e.restDecoder);for(let i=0;i<o;i++){e.resetDsCurVal();const s=Dr(e.restDecoder),a=Dr(e.restDecoder),l=n.clients.get(s)||[],c=Ds(n,s);for(let u=0;u<a;u++){const d=e.readDsClock(),f=d+e.readDsLen();if(d<c){c<f&&lx(r,s,c,f-c);let h=Yd(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,xP(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,xP(t,p,f-p.id.clock)),p.delete(t))}else lx(r,s,d,f-d)}}if(r.clients.size>0){const i=new vy;return En(i.restEncoder,0),vw(i,r),i.toUint8Array()}return null},Bse=ase,bp=class Yqe extends q9{constructor({guid:t=pZe(),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=Bse(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Zse,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=lse(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>lse(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(pp(this.subdocs).map(t=>t.guid))}transact(t,n=null){return Ri(this,t,n)}get(t,n=_a){const r=Zu(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),o=r.constructor;if(n!==_a&&o!==n)if(o===_a){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,IP)}getText(t=""){return this.get(t,gx)}getMap(t=""){return this.get(t,Qa)}getXmlElement(t=""){return this.get(t,wl)}getXmlFragment(t=""){return this.get(t,xw)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,pp(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new Yqe({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()}},Hse=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Dr(this.restDecoder)}readDsLen(){return Dr(this.restDecoder)}},zse=class extends Hse{readLeftID(){return jr(Dr(this.restDecoder),Dr(this.restDecoder))}readRightID(){return jr(Dr(this.restDecoder),Dr(this.restDecoder))}readClient(){return Dr(this.restDecoder)}readInfo(){return uw(this.restDecoder)}readString(){return uu(this.restDecoder)}readParentInfo(){return Dr(this.restDecoder)===1}readTypeRef(){return Dr(this.restDecoder)}readLen(){return Dr(this.restDecoder)}readAny(){return ix(this.restDecoder)}readBuf(){return iZe(Za(this.restDecoder))}readJSON(){return JSON.parse(uu(this.restDecoder))}readKey(){return uu(this.restDecoder)}},sQe=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dr(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Dr(this.restDecoder)+1;return this.dsCurrVal+=e,e}},ww=class extends sQe{constructor(e){super(e),this.keys=[],Dr(e),this.keyClockDecoder=new B9(Za(e)),this.clientDecoder=new eP(Za(e)),this.leftClockDecoder=new B9(Za(e)),this.rightClockDecoder=new B9(Za(e)),this.infoDecoder=new jie(Za(e),uw),this.stringDecoder=new CJe(Za(e)),this.parentInfoDecoder=new jie(Za(e),uw),this.typeRefDecoder=new eP(Za(e)),this.lenDecoder=new eP(Za(e))}readLeftID(){return new Aw(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Aw(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 ix(this.restDecoder)}readBuf(){return Za(this.restDecoder)}readJSON(){return ix(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}}},Use=class{constructor(){this.restEncoder=da()}toUint8Array(){return Wi(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){En(this.restEncoder,e)}writeDsLen(e){En(this.restEncoder,e)}},cx=class extends Use{writeLeftID(e){En(this.restEncoder,e.client),En(this.restEncoder,e.clock)}writeRightID(e){En(this.restEncoder,e.client),En(this.restEncoder,e.clock)}writeClient(e){En(this.restEncoder,e)}writeInfo(e){L9(this.restEncoder,e)}writeString(e){Ca(this.restEncoder,e)}writeParentInfo(e){En(this.restEncoder,e?1:0)}writeTypeRef(e){En(this.restEncoder,e)}writeLen(e){En(this.restEncoder,e)}writeAny(e){cw(this.restEncoder,e)}writeBuf(e){hs(this.restEncoder,e)}writeJSON(e){Ca(this.restEncoder,JSON.stringify(e))}writeKey(e){Ca(this.restEncoder,e)}},Vse=class{constructor(){this.restEncoder=da(),this.dsCurrVal=0}toUint8Array(){return Wi(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,En(this.restEncoder,t)}writeDsLen(e){e===0&&Kl(),En(this.restEncoder,e-1),this.dsCurrVal+=e}},vy=class extends Vse{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new O9,this.clientEncoder=new ZR,this.leftClockEncoder=new O9,this.rightClockEncoder=new O9,this.infoEncoder=new zie(L9),this.stringEncoder=new IJe,this.parentInfoEncoder=new zie(L9),this.typeRefEncoder=new ZR,this.lenEncoder=new ZR}toUint8Array(){const e=da();return En(e,0),hs(e,this.keyClockEncoder.toUint8Array()),hs(e,this.clientEncoder.toUint8Array()),hs(e,this.leftClockEncoder.toUint8Array()),hs(e,this.rightClockEncoder.toUint8Array()),hs(e,Wi(this.infoEncoder)),hs(e,this.stringEncoder.toUint8Array()),hs(e,Wi(this.parentInfoEncoder)),hs(e,this.typeRefEncoder.toUint8Array()),hs(e,this.lenEncoder.toUint8Array()),JR(e,Wi(this.restEncoder)),Wi(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){cw(this.restEncoder,e)}writeBuf(e){hs(this.restEncoder,e)}writeJSON(e){cw(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)}},aQe=(e,t,n,r)=>{r=qd(r,t[0].id.clock);const o=Yd(t,r);En(e.restEncoder,t.length-o),e.writeClient(n),En(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)},l4=(e,t,n)=>{const r=new Map;n.forEach((o,i)=>{Ds(t,i)>o&&r.set(i,o)}),hx(t).forEach((o,i)=>{n.has(i)||r.set(i,0)}),En(e.restEncoder,r.size),pp(r.entries()).sort((o,i)=>i[0]-o[0]).forEach(([o,i])=>{aQe(e,t.clients.get(o),o,i)})},lQe=(e,t)=>{const n=Yl(),r=Dr(e.restDecoder);for(let o=0;o<r;o++){const i=Dr(e.restDecoder),s=new Array(i),a=e.readClient();let l=Dr(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 Qu(jr(a,l),d),l+=d;break}case 10:{const d=Dr(e.restDecoder);s[c]=new $u(jr(a,l),d),l+=d;break}default:{const d=(u&192)===0,f=new ji(jr(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,Lae(e,u));s[c]=f,l+=f.length}}}}return n},cQe=(e,t,n)=>{const r=[];let o=pp(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 Zse,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!==$u){const h=Zu(d,u.id.client,()=>Ds(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,Ds(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 vy;return l4(h,a,new Map),En(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},uQe=(e,t)=>l4(e,t.doc.store,t.beforeState),dQe=(e,t,n,r=new ww(e))=>Ri(t,o=>{o.local=!1;let i=!1;const s=o.doc,a=s.store,l=cQe(o,a,lQe(r,s)),c=a.pendingStructs;if(c){for(const[d,f]of c.missing)if(f<Ds(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=mP([c.update,l.update])}}else a.pendingStructs=l;const u=Fse(r,o,a);if(a.pendingDs){const d=new ww(mp(a.pendingDs));Dr(d.restDecoder);const f=Fse(d,o,a);u&&f?a.pendingDs=mP([u,f]):a.pendingDs=u||f}else a.pendingDs=u;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,fP(o.doc,d)}},n,!1),fP=(e,t,n,r=ww)=>{const o=mp(t);dQe(o,e,n,new r(o))},Gse=(e,t,n)=>fP(e,t,n,zse),fQe=(e,t,n=new Map)=>{l4(e,t.store,n),vw(e,Ose(t.store))},hQe=(e,t=new Uint8Array([0]),n=new vy)=>{fQe(n,e,Wse(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(LQe(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===cx)return RQe(r.map((o,i)=>i===0?o:MQe(o)));if(n.constructor===vy)return mP(r)}return r[0]},c4=(e,t)=>hQe(e,t,new cx),pQe=e=>{const t=new Map,n=Dr(e.restDecoder);for(let r=0;r<n;r++){const o=Dr(e.restDecoder),i=Dr(e.restDecoder);t.set(o,i)}return t},Wse=e=>pQe(new Hse(mp(e))),jse=(e,t)=>(En(e.restEncoder,t.size),pp(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{En(e.restEncoder,n),En(e.restEncoder,r)}),e),mQe=(e,t)=>jse(e,hx(t.store)),gQe=(e,t=new Vse)=>(e instanceof Map?jse(t,e):mQe(t,e),t.toUint8Array()),yQe=e=>gQe(e,new Use),bQe=class{constructor(){this.l=[]}},qse=()=>new bQe,Kse=(e,t)=>e.l.push(t),Yse=(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.")},Xse=(e,t,n)=>V9(e.l,[t,n]),Aw=class{constructor(e,t){this.client=e,this.clock=t}},Iw=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,jr=(e,t)=>new Aw(e,t),ux=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw Kl()},dx=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},fx=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},wy=e=>new fx(e.type==null?null:jr(e.type.client,e.type.clock),e.tname??null,e.item==null?null:jr(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),vQe=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},wQe=(e,t,n=0)=>new vQe(e,t,n),hP=(e,t,n)=>{let r=null,o=null;return e._item===null?o=ux(e):r=jr(e._item.id.client,e._item.id.clock),new fx(r,o,t,n)},u4=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return hP(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return hP(e,jr(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return hP(e,r.lastId,n);r=r.right}return hP(e,null,n)},AQe=(e,t)=>{const n=Sw(e,t);return{item:n,diff:t.clock-n.id.clock}},IQe=(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(Ds(r,o.client)<=o.clock)return null;const u=n?E4(r,o):AQe(r,o),d=u.item;if(!(d instanceof ji))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(Ds(r,i.client)<=i.clock)return null;const{item:u}=n?E4(r,i):{item:Sw(r,i)};if(u instanceof ji&&u.content instanceof vp)l=u.content.type;else return null}else throw Kl();a>=0?c=l._length:c=0}return wQe(l,c,e.assoc)},Jse=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Iw(e.item,t.item)&&Iw(e.type,t.type)&&e.assoc===t.assoc,d4=class{constructor(e,t){this.ds=e,this.sv=t}},f4=(e,t)=>new d4(e,t),Xir=f4(s4(),new Map),h4=e=>f4(Ose(e.store),hx(e.store)),Ay=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!bw(t.ds,e.id),p4=(e,t)=>{const n=Zu(e.meta,p4,hp),r=e.doc.store;n.has(t)||(t.sv.forEach((o,i)=>{o<Ds(r,i)&&Pc(e,jr(i,o))}),Ym(e,t.ds,o=>{}),n.add(t))},Zse=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},hx=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},Ds=(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},Qse=(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 Kl()}n.push(t)},Yd=(e,t)=>{let n=0,r=e.length-1,o=e[r],i=o.id.clock;if(i===t)return r;let s=Xu(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=Xu((n+r)/2)}throw Kl()},SQe=(e,t)=>{const n=e.clients.get(t.client);return n[Yd(n,t.clock)]},Sw=SQe,m4=(e,t,n)=>{const r=Yd(t,n),o=t[r];return o.id.clock<n&&o instanceof ji?(t.splice(r+1,0,xP(e,o,n-o.id.clock)),r+1):r},Pc=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[m4(e,n,t.clock)]},$se=(e,t,n)=>{const r=t.clients.get(n.client),o=Yd(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Qu&&r.splice(o+1,0,xP(e,i,n.clock-i.id.clock+1)),i},TQe=(e,t,n)=>{const r=e.clients.get(t.id.client);r[Yd(r,t.id.clock)]=n},eae=(e,t,n,r,o)=>{if(r===0)return;const i=n+r;let s=m4(e,t,n),a;do a=t[s++],i<a.id.clock+a.length&&m4(e,t,i),o(a);while(s<t.length&&t[s].id.clock<i)},xQe=class{constructor(e,t,n){this.doc=e,this.deleteSet=new yw,this.beforeState=hx(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}},tae=(e,t)=>t.deleteSet.clients.size===0&&!MJe(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(o4(t.deleteSet),uQe(e,t),vw(e,t.deleteSet),!0),nae=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Zu(e.changed,t,hp).add(n)},pP=(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 ji&&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},kQe=(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=Yd(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 ji&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},CQe=(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=Xf(o.length-1,1+Yd(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+pP(o,l)}})},rae=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{o4(i),n.afterState=hx(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(()=>{Xse(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&YQe(n)})}),V9(a,[])}finally{r.gc&&kQe(i,o,r.gcFilter),CQe(i,o),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=o.clients.get(d),p=qd(Yd(h,f),1);for(let m=h.length-1;m>=p;)m-=1+pP(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=Yd(h,f);p+1<h.length&&pP(h,p+1)>1||p>0&&pP(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(rQe(n4,_se,"[yjs] ",Rse,Pse,"Changed the client-id because another client seems to be using it."),r.clientID=Bse()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new cx;tae(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new vy;tae(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])):rae(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 xQe(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&&rae(o,0)}}return s},EQe=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},oae=(e,t,n)=>{Ym(e,n.deletions,r=>{r instanceof ji&&t.scope.some(o=>o===e.doc||dx(o,r))&&_4(r,!1)})},iae=(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;Ym(a,c.insertions,h=>{if(h instanceof ji){if(h.redone!==null){let{item:p,diff:m}=E4(l,h.id);m>0&&(p=Pc(a,jr(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>p===a.doc||dx(p,h))&&d.push(h)}}),Ym(a,c.deletions,h=>{h instanceof ji&&i.some(p=>p===a.doc||dx(p,h))&&!bw(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=Pae(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},sae=class extends q9{constructor(e,{captureTimeout:t=500,captureTransaction:n=a=>!0,deleteFilter:r=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:s=yy(e)?e[0].doc:e instanceof bp?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 yw;a.afterState.forEach((m,g)=>{const y=a.beforeState.get(g)||0,v=m-y;v>0&&lx(d,g,y,v)});const f=Kd();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=i4([m.deletions,a.deleteSet]),m.insertions=i4([m.insertions,d])}else u.push(new EQe(a.deleteSet,d)),h=!0;!l&&!c&&(this.lastChange=f),Ym(a,a.deleteSet,m=>{m instanceof ji&&this.scope.some(g=>g===a.doc||dx(g,m))&&_4(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=yy(e)?e:[e],e.forEach(n=>{t.has(n)||(t.add(n),(n instanceof _a?n.doc!==this.doc:n!==this.doc)&&Nse("[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=>oae(n,this,r)),this.undoStack=[]),t&&(this.redoStack.forEach(r=>oae(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=iae(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=iae(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*_Qe(e){const t=Dr(e.restDecoder);for(let n=0;n<t;n++){const r=Dr(e.restDecoder),o=e.readClient();let i=Dr(e.restDecoder);for(let s=0;s<r;s++){const a=e.readInfo();if(a===10){const l=Dr(e.restDecoder);yield new $u(jr(o,i),l),i+=l}else if((31&a)!==0){const l=(a&192)===0,c=new ji(jr(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,Lae(e,a));yield c,i+=c.length}else{const l=e.readLen();yield new Qu(jr(o,i),l),i+=l}}}}var g4=class{constructor(e,t){this.gen=_Qe(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===$u);return this.curr}},y4=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},RQe=e=>mP(e,zse,cx),PQe=(e,t)=>{if(e.constructor===Qu){const{client:n,clock:r}=e.id;return new Qu(jr(n,r+t),e.length-t)}else if(e.constructor===$u){const{client:n,clock:r}=e.id;return new $u(jr(n,r+t),e.length-t)}else{const n=e,{client:r,clock:o}=n.id;return new ji(jr(r,o+t),null,jr(r,o+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},mP=(e,t=ww,n=vy)=>{if(e.length===1)return e[0];const r=e.map(l=>new t(mp(l)));let o=r.map(l=>new g4(l,!0)),i=null;const s=new n,a=new y4(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===$u?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)Xm(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===$u)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{Xm(a,i.struct,i.offset);const f=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new $u(jr(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===$u?i.struct.length-=f:u=PQe(u,f)),i.struct.mergeWith(u)||(Xm(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!==$u;u=l.next())Xm(a,i.struct,i.offset),i={struct:u,offset:0}}return i!==null&&(Xm(a,i.struct,i.offset),i=null),b4(a),vw(s,i4(r.map(l=>a4(l)))),s.toUint8Array()},LQe=(e,t,n=ww,r=vy)=>{const o=Wse(t),i=new r,s=new y4(i),a=new n(mp(e)),l=new g4(a,!1);for(;l.curr;){const c=l.curr,u=c.id.client,d=o.get(u)||0;if(l.curr.constructor===$u){l.next();continue}if(c.id.clock+c.length>d)for(Xm(s,c,qd(d-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)Xm(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 b4(s),vw(i,a4(a)),i.toUint8Array()},aae=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Wi(e.encoder.restEncoder)}),e.encoder.restEncoder=da(),e.written=0)},Xm=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&aae(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),En(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},b4=e=>{aae(e);const t=e.encoder.restEncoder;En(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];En(t,r.written),JR(t,r.restEncoder)}},NQe=(e,t,n,r)=>{const o=new n(mp(e)),i=new g4(o,!1),s=new r,a=new y4(s);for(let l=i.curr;l!==null;l=i.next())Xm(a,t(l),0);return b4(a),vw(s,a4(o)),s.toUint8Array()},MQe=e=>NQe(e,jJe,ww,cx),lae="You must not compute changes after the event-handler fired.",gP=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=DQe(this.currentTarget,this.target))}deletes(e){return bw(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Jf(lae);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=E9(s.content.getContent());else return;else s!==null&&this.deletes(s)?(o="update",i=E9(s.content.getContent())):(o="add",i=void 0)}else if(this.deletes(r))o="delete",i=E9(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 Jf(lae);const t=this.target,n=hp(),r=hp(),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}},DQe=(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},vl=()=>{Nse("Invalid access: Add Yjs type to a document before reading data.")},cae=80,v4=0,OQe=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=v4++}},FQe=e=>{e.timestamp=v4++},uae=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=v4++},BQe=(e,t,n)=>{if(e.length>=cae){const r=e.reduce((o,i)=>o.timestamp<i.timestamp?o:i);return uae(r,t,n),r}else{const r=new OQe(t,n);return e.push(r),r}},yP=(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)=>KR(t-i.index)<KR(t-s.index)?i:s);let r=e._start,o=0;for(n!==null&&(r=n.p,o=n.index,FQe(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&&KR(n.index-o)<r.parent.length/cae?(uae(n,r,o),n):BQe(e._searchMarker,r,o)},px=(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=qd(t,o.index+n))}},bP=(e,t,n)=>{const r=e,o=t.changedParentTypes;for(;Zu(o,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Xse(r._eH,n,t)},_a=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=qse(),this._dEH=qse(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ju()}clone(){throw Ju()}_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){Kse(this._eH,e)}observeDeep(e){Kse(this._dEH,e)}unobserve(e){Yse(this._eH,e)}unobserveDeep(e){Yse(this._dEH,e)}toJSON(){}},dae=(e,t,n)=>{e.doc??vl(),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},fae=e=>{e.doc??vl();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},hae=(e,t)=>{const n=[];let r=e._start;for(;r!==null;){if(r.countable&&Ay(r,t)){const o=r.content.getContent();for(let i=0;i<o.length;i++)n.push(o[i])}r=r.right}return n},mx=(e,t)=>{let n=0,r=e._start;for(e.doc??vl();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}},pae=(e,t)=>{const n=[];return mx(e,(r,o)=>{n.push(t(r,o,e))}),n},HQe=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}}}},mae=(e,t)=>{e.doc??vl();const n=yP(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}},vP=(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 ji(jr(s,Ds(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new TP(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 ji(jr(s,Ds(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new k4(new Uint8Array(d))),o.integrate(e,0);break;case bp:o=new ji(jr(s,Ds(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new C4(d)),o.integrate(e,0);break;default:if(d instanceof _a)o=new ji(jr(s,Ds(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new vp(d)),o.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},gae=()=>Jf("Length exceeded!"),yae=(e,t,n,r)=>{if(n>t._length)throw gae();if(n===0)return t._searchMarker&&px(t._searchMarker,n,r.length),vP(e,t,null,r);const o=n,i=yP(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&&Pc(e,jr(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&px(t._searchMarker,o,r.length),vP(e,t,s,r)},zQe=(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 vP(e,t,r,n)},bae=(e,t,n,r)=>{if(r===0)return;const o=n,i=r,s=yP(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&&Pc(e,jr(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Pc(e,jr(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw gae();t._searchMarker&&px(t._searchMarker,o,-i+r)},wP=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},w4=(e,t,n,r)=>{const o=t._map.get(n)||null,i=e.doc,s=i.clientID;let a;if(r==null)a=new TP([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new TP([r]);break;case Uint8Array:a=new k4(r);break;case bp:a=new C4(r);break;default:if(r instanceof _a)a=new vp(r);else throw new Error("Unexpected content type")}new ji(jr(s,Ds(i.store,s)),o,o&&o.lastId,null,null,t,n,a).integrate(e,0)},A4=(e,t)=>{e.doc??vl();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},vae=e=>{const t={};return e.doc??vl(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},wae=(e,t)=>{e.doc??vl();const n=e._map.get(t);return n!==void 0&&!n.deleted},UQe=(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&&Ay(i,t)&&(n[o]=i.content.getContent()[i.length-1])}),n},AP=e=>(e.doc??vl(),oQe(e._map.entries(),t=>!t[1].deleted)),VQe=class extends gP{},IP=class jB extends _a{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new jB;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new jB}clone(){const t=new jB;return t.insert(0,this.toArray().map(n=>n instanceof _a?n.clone():n)),t}get length(){return this.doc??vl(),this._length}_callObserver(t,n){super._callObserver(t,n),bP(this,t,new VQe(this,t))}insert(t,n){this.doc!==null?Ri(this.doc,r=>{yae(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?Ri(this.doc,n=>{zQe(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{bae(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return mae(this,t)}toArray(){return fae(this)}slice(t=0,n=this.length){return dae(this,t,n)}toJSON(){return this.map(t=>t instanceof _a?t.toJSON():t)}map(t){return pae(this,t)}forEach(t){mx(this,t)}[Symbol.iterator](){return HQe(this)}_write(t){t.writeTypeRef(m$e)}},GQe=e=>new IP,WQe=class extends gP{constructor(e,t,n){super(e,t),this.keysChanged=n}},Qa=class Mne extends _a{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 Mne}clone(){const t=new Mne;return this.forEach((n,r)=>{t.set(r,n instanceof _a?n.clone():n)}),t}_callObserver(t,n){bP(this,t,new WQe(this,t,n))}toJSON(){this.doc??vl();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];t[r]=o instanceof _a?o.toJSON():o}}),t}get size(){return[...AP(this)].length}keys(){return r4(AP(this),t=>t[0])}values(){return r4(AP(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return r4(AP(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??vl(),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=>{wP(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?Ri(this.doc,r=>{w4(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return A4(this,t)}has(t){return wae(this,t)}clear(){this.doc!==null?Ri(this.doc,t=>{this.forEach(function(n,r,o){wP(t,o,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(g$e)}},jQe=e=>new Qa,Jm=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&GJe(e,t),I4=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){this.right===null&&Kl(),this.right.content.constructor===Ra?this.right.deleted||Tw(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Aae=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===Ra?t.right.deleted||Tw(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&Pc(e,jr(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},SP=(e,t,n,r)=>{const o=new Map,i=r?yP(t,n):null;return i?Aae(e,new I4(i.p.left,i.p,i.index,o),n-i.index):Aae(e,new I4(null,t._start,0,o),n)},Iae=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ra&&Jm(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 ji(jr(i,Ds(o.store,i)),l,l&&l.lastId,c,c&&c.id,t,null,new Ra(a,s));u.integrate(e,0),n.right=u,n.forward()})},Tw=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Sae=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===Ra&&Jm(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Tae=(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(!Jm(c,l)){s.set(a,c);const{left:u,right:d}=n;n.right=new ji(jr(i,Ds(o.store,i)),u,u&&u.lastId,d,d&&d.id,t,null,new Ra(a,l)),n.right.integrate(e,0),n.forward()}}return s},S4=(e,t,n,r,o)=>{n.currentAttributes.forEach((f,h)=>{o[h]===void 0&&(o[h]=null)});const i=e.doc,s=i.clientID;Sae(n,o);const a=Tae(e,t,n,o),l=r.constructor===String?new Zm(r):r instanceof _a?new vp(r):new yx(r);let{left:c,right:u,index:d}=n;t._searchMarker&&px(t._searchMarker,n.index,l.getLength()),u=new ji(jr(s,Ds(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(),Iae(e,t,n,a)},xae=(e,t,n,r,o)=>{const i=e.doc,s=i.clientID;Sae(n,o);const a=Tae(e,t,n,o);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Ra));){if(!n.right.deleted)switch(n.right.content.constructor){case Ra:{const{key:l,value:c}=n.right.content,u=o[l];if(u!==void 0){if(Jm(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&&Pc(e,jr(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 ji(jr(s,Ds(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Zm(l)),n.right.integrate(e,0),n.forward()}Iae(e,t,n,a)},kae=(e,t,n,r,o)=>{let i=t;const s=Yl();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Ra){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===Ra){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&&Tw(o,c)}}t=t.right}return a},qQe=(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===Ra){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},KQe=e=>{let t=0;return Ri(e.doc,n=>{let r=e._start,o=e._start,i=Yl();const s=H9(i);for(;o;)o.deleted===!1&&(o.content.constructor===Ra?Tw(s,o.content):(t+=kae(n,r,o,i,s),i=H9(s),r=o)),o=o.right}),t},YQe=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&&eae(e,n.store.clients.get(r),i,o,s=>{!s.deleted&&s.content.constructor===Ra&&s.constructor!==Qu&&t.add(s.parent)})}Ri(n,r=>{Ym(e,e.deleteSet,o=>{if(o instanceof Qu||!o.parent._hasFormatting||t.has(o.parent))return;const i=o.parent;o.content.constructor===Ra?t.add(i):qQe(r,o)});for(const o of t)KQe(o)})},Cae=(e,t,n)=>{const r=n,o=H9(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case vp:case yx:case Zm:n<t.right.length&&Pc(e,jr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&kae(e,i,t.right,o,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&px(s._searchMarker,t.index,-r+n),t},XQe=class extends gP{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},VJe(a)||(f.attributes=HJe({},a))),c=0;break}f&&t.push(f),s=null}};for(;i!==null;){switch(i.content.constructor){case vp:case yx: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 Zm: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 Ra:{const{key:f,value:h}=i.content;if(this.adds(i))this.deletes(i)||(Jm(r.get(f)??null,h)?h!==null&&i.delete(n):(s==="retain"&&d(),Jm(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;Jm(p,h)||(s==="retain"&&d(),a[f]=p)}else if(!i.deleted){o.set(f,h);const p=a[f];p!==void 0&&(Jm(p,h)?p!==null&&i.delete(n):(s==="retain"&&d(),h===null?delete a[f]:a[f]=h))}i.deleted||(s==="insert"&&d(),Tw(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}},gx=class Dne extends _a{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??vl(),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 Dne}clone(){const t=new Dne;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new XQe(this,t,n);bP(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??vl();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Zm&&(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 I4(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)&&S4(r,this,o,a,s.attributes||{})}else s.retain!==void 0?xae(r,this,o,s.retain,s.attributes||{}):s.delete!==void 0&&Cae(r,o,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??vl();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(Ay(l,t)||n!==void 0&&Ay(l,n))switch(l.content.constructor){case Zm:{const d=i.get("ychange");t!==void 0&&!Ay(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&&!Ay(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 vp:case yx:{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 Ra:Ay(l,t)&&(c(),Tw(i,l.content));break}l=l.right}c()};return t||n?Ri(s,d=>{t&&p4(d,t),n&&p4(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=SP(i,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),S4(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=SP(i,this,t,!r);S4(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=>{Cae(o,SP(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=SP(i,this,t,!1);s.right!==null&&xae(i,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{wP(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{w4(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return A4(this,t)}getAttributes(){return vae(this)}_write(t){t.writeTypeRef(y$e)}},JQe=e=>new gx,T4=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??vl()}[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===wl||t.constructor===xw)&&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})}},xw=class One extends _a{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 One}clone(){const t=new One;return t.insert(0,this.toArray().map(n=>n instanceof _a?n.clone():n)),t}get length(){return this.doc??vl(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new T4(this,t)}querySelector(t){t=t.toUpperCase();const n=new T4(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),pp(new T4(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){bP(this,t,new $Qe(this,n,t))}toString(){return pae(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),mx(this,i=>{o.insertBefore(i.toDOM(t,n,r),null)}),o}insert(t,n){this.doc!==null?Ri(this.doc,r=>{yae(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 _a?t._item:t;vP(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 Jf("Reference item not found");r.splice(o,0,...n)}}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{bae(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return fae(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return mae(this,t)}slice(t=0,n=this.length){return dae(this,t,n)}forEach(t){mx(this,t)}_write(t){t.writeTypeRef(v$e)}},ZQe=e=>new xw,wl=class Fne extends xw{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 Fne(this.nodeName)}clone(){const t=new Fne(this.nodeName),n=this.getAttributes();return zJe(n,(r,o)=>{t.setAttribute(o,r)}),t.insert(0,this.toArray().map(r=>r instanceof _a?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=>{wP(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{w4(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return A4(this,t)}hasAttribute(t){return wae(this,t)}getAttributes(t){return t?UQe(this,t):vae(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 mx(this,s=>{o.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(b$e),t.writeKey(this.nodeName)}},QQe=e=>new wl(e.readKey()),$Qe=class extends gP{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)})}},e$e=class Bne extends Qa{constructor(t){super(),this.hookName=t}_copy(){return new Bne(this.hookName)}clone(){const t=new Bne(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(w$e),t.writeKey(this.hookName)}},t$e=e=>new e$e(e.readKey()),Xd=class Hne extends gx{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 Hne}clone(){const t=new Hne;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(A$e)}},n$e=e=>new Xd,x4=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ju()}mergeWith(e){return!1}write(e,t,n){throw Ju()}integrate(e,t){throw Ju()}},r$e=0,Qu=class extends x4{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),Qse(e.doc.store,this)}write(e,t){e.writeInfo(r$e),e.writeLen(this.length-t)}getMissing(e,t){return null}},k4=class Xqe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Xqe(this.content)}splice(t){throw Ju()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},o$e=e=>new k4(e.readBuf()),Eae=class zne{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new zne(this.len)}splice(t){const n=new zne(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){lx(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}},i$e=e=>new Eae(e.readLen()),_ae=(e,t)=>new bp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),C4=class Jqe{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 Jqe(_ae(this.doc.guid,this.opts))}splice(t){throw Ju()}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}},s$e=e=>new C4(_ae(e.readString(),e.readAny())),yx=class Zqe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Zqe(this.embed)}splice(t){throw Ju()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},a$e=e=>new yx(e.readJSON()),Ra=class Qqe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Qqe(this.key,this.value)}splice(t){throw Ju()}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}},l$e=e=>new Ra(e.readKey(),e.readJSON()),c$e=class Une{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Une(this.arr)}splice(t){const n=new Une(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}},u$e=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 c$e(n)},d$e=rP("node_env")==="development",TP=class Vne{constructor(t){this.arr=t,d$e&&$ie(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Vne(this.arr)}splice(t){const n=new Vne(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}},f$e=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new TP(n)},Zm=class Gne{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Gne(this.str)}splice(t){const n=new Gne(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}},h$e=e=>new Zm(e.readString()),p$e=[GQe,jQe,JQe,QQe,ZQe,t$e,n$e],m$e=0,g$e=1,y$e=2,b$e=3,v$e=4,w$e=5,A$e=6,vp=class $qe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new $qe(this.type._copy())}splice(t){throw Ju()}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}},I$e=e=>new vp(p$e[e.readTypeRef()](e)),E4=(e,t)=>{let n=t,r=0,o;do r>0&&(n=jr(n.client,n.clock+r)),o=Sw(e,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof ji);return{item:o,diff:r}},_4=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},xP=(e,t,n)=>{const{client:r,clock:o}=t.id,i=new ji(jr(r,o+n),t,jr(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=jr(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},Rae=(e,t)=>R9(e,n=>bw(n.deletions,t)),Pae=(e,t,n,r,o,i)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return Pc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Pae(e,u,n,r,o,i)===null))return null;for(;u.redone!==null;)u=Pc(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:Pc(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:Pc(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||bw(r,d.right.id)||Rae(i.undoStack,d.right.id)||Rae(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Pc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=jr(l,Ds(a,l)),m=new ji(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,_4(m,!0),m.integrate(e,0),m},ji=class Wne extends x4{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>=Ds(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ds(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Aw&&this.id.client!==this.parent.client&&this.parent.clock>=Ds(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=$se(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Pc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Qu||this.right&&this.right.constructor===Qu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Wne?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Wne&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Aw){const r=Sw(n,this.parent);r.constructor===Qu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=$se(t,t.doc.store,jr(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),Iw(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,i.clear();else if(Iw(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&s.has(Sw(t.doc.store,o.origin)))i.has(Sw(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),Qse(t.doc.store,this),this.content.integrate(t,this),nae(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Qu(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:jr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Iw(t.origin,this.lastId)&&this.right===t&&Iw(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(),lx(t.deleteSet,this.id.client,this.id.clock,this.length),nae(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Kl();this.content.gc(t),n?TQe(t,this,new Qu(this.id,this.length)):this.content=new Eae(this.length)}write(t,n){const r=n>0?jr(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=ux(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===Aw?(t.writeParentInfo(!1),t.writeLeftID(a)):Kl();i!==null&&t.writeString(i)}this.content.write(t,n)}},Lae=(e,t)=>S$e[t&31](e),S$e=[()=>{Kl()},i$e,u$e,o$e,h$e,a$e,l$e,I$e,f$e,s$e,()=>{Kl()}],T$e=10,$u=class extends x4{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Kl()}write(e,t){e.writeInfo(T$e),En(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Nae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Mae="__ $YJS$ __";Nae[Mae]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Nae[Mae]=!0;const x$e=3e4;var Dae=class extends cZe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Kd();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&&kw(this,n,"timeout")},Xu(x$e/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:Kd()});const i=[],s=[],a=[],l=[];e===null?l.push(t):o==null?e!=null&&i.push(t):(s.push(t),fw(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 kw=(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:Kd()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Qm=(e,t,n=e.states)=>{const r=t.length,o=da();En(o,r);for(let i=0;i<r;i++){const s=t[i],a=n.get(s)||null,l=e.meta.get(s).clock;En(o,s),En(o,l),Ca(o,JSON.stringify(a))}return Wi(o)},Oae=(e,t,n)=>{const r=mp(t),o=Kd(),i=[],s=[],a=[],l=[],c=Dr(r);for(let u=0;u<c;u++){const d=Dr(r);let f=Dr(r);const h=JSON.parse(uu(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&&(fw(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 Fae=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 k$e(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 R4(e){return new Promise(t=>setTimeout(t,e))}function C$e(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 E$e(e,t){const n=k$e(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||C$e;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 R4(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 R4(s),r.attemptNum<1&&n.initialJitter){const a=o(r,n);a&&await R4(a)}return i()}const Bae=e=>UJe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let Al=(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})({}),Il=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var kP=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=da(),this.decoder=mp(new Uint8Array(this.data))}peekVarString(){return xJe(this.decoder)}readVarUint(){return Dr(this.decoder)}readVarString(){return uu(this.decoder)}readVarUint8Array(){return Za(this.decoder)}writeVarUint(e){return En(this.encoder,e)}writeVarString(e){return Ca(this.encoder,e)}writeVarUint8Array(e){return hs(this.encoder,e)}length(){return XR(this.encoder)}},Hae=class extends Fae{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=Il.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===Il.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===Il.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:E$e(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=Il.Connecting,this.emit("status",{status:Il.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Kd();const t=new kP(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Il.Connected,this.emit("status",{status:Il.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===Il.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Kd()-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=Bae(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===LJe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===Il.Connected&&(this.status=Il.Disconnected,this.emit("status",{status:Il.Disconnected}),this.emit("disconnect",{event:e})),e.code===qie.code&&(e.reason===qie.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===PJe.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===RJe.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!==Il.Disconnected&&(this.status=Il.Disconnected,this.emit("status",{status:Il.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 Jir=0,Zir=1,Qir=2,CP=(e,t)=>{En(e,0);const n=yQe(t);hs(e,n)},P4=(e,t,n)=>{En(e,1),hs(e,c4(t,n))},_$e=(e,t,n)=>P4(t,n,Za(e)),zae=(e,t,n,r)=>{try{Gse(t,Za(e),n)}catch(o){r?.(o),console.error("Caught error while handling a Yjs update",o)}},Uae=(e,t)=>{En(e,2),hs(e,t)},R$e=zae,Vae=(e,t,n,r,o)=>{const i=Dr(e);switch(i){case 0:_$e(e,t,n);break;case 1:zae(e,n,r,o);break;case 2:R$e(e,n,r,o);break;default:throw new Error("Unknown message type")}return i};var Qf=class{encoder;type;constructor(){this.encoder=da()}get(e){return e.encoder}toUint8Array(){return Wi(this.encoder)}},Gae=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 Al.Sync:this.applySyncMessage(e,t);break;case Al.Awareness:this.applyAwarenessMessage(e);break;case Al.Auth:this.applyAuthMessage(e);break;case Al.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Al.Stateless:e.receiveStateless(uu(n.decoder));break;case Al.SyncStatus:this.applySyncStatusMessage(e,$R(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>o+1&&(this.broadcasted?e.broadcast(Qf,{encoder:n.encoder}):e.send(Qf,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(Al.Sync);const r=Vae(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;Oae(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;_Je(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(Al.Awareness),t.writeVarUint8Array(Qm(e.awareness,Array.from(e.awareness.getStates().keys())))}},Wae=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Wi(this.encoder)}send(e){e?.send(this.create())}broadcast(e){by(e,this.create())}},P$e=class extends Qf{type=Al.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ca(this.encoder,e.documentName),En(this.encoder,this.type),EJe(this.encoder,e.token),this.encoder}},EP=class extends Qf{type=Al.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");Ca(this.encoder,e.documentName),En(this.encoder,this.type);let t;return e.states===void 0?t=Qm(e.awareness,e.clients):t=Qm(e.awareness,e.clients,e.states),hs(this.encoder,t),this.encoder}},L$e=class extends Qf{type=Al.CLOSE;description="Ask the server to close the connection";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},N$e=class extends Qf{type=Al.QueryAwareness;description="Queries awareness states";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},M$e=class extends Qf{type=Al.Stateless;description="A stateless message";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),Ca(this.encoder,e.payload??""),this.encoder}},L4=class extends Qf{type=Al.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 Ca(this.encoder,e.documentName),En(this.encoder,this.type),CP(this.encoder,e.document),this.encoder}},D$e=class extends Qf{type=Al.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 Ca(this.encoder,e.documentName),En(this.encoder,this.type),P4(this.encoder,e.document),this.encoder}},O$e=class extends Qf{type=Al.Sync;description="A document update";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),Uae(this.encoder,e.update),this.encoder}},F$e=class extends Error{code=1001},B$e=class extends Fae{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=Il.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=sse();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new bp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new Dae(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:Kie(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:Kie(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 Hae({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(L4,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&kw(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(M$e,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(O$e,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const o=e.concat(t).concat(n);this.send(EP,{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(P$e,{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(L4,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(EP,{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 Wae(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new kP(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new kP(e.data)}),new Gae(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&kw(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&&(kw(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(L$e,{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=Il.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 kP(e),n=t.readVarString();t.writeVarString(n),new Gae(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(ose(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(L4,{document:this.document,documentName:this.configuration.name}),this.broadcast(D$e,{document:this.document,documentName:this.configuration.name}),this.broadcast(N$e,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(EP,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(EP,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(ise(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new Wae(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new F$e(`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 Lc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",bx="application/pdf",_P="text/html",H$e={docx:Lc,pdf:bx,html:_P},N4=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Os={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"},vx=e=>typeof e!="string"?"":e.trim(),RP=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},M4=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},wx=e=>{const t=e??{},n=vx(t.id),r=RP(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},jae=({current:e,other:t})=>{const n=wx(e),r=wx(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},Cw=({actor:e,fallbackKey:t=""})=>{const n=wx(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 z$e=(e,t)=>wp(e,t,D4),qae=(e,t)=>wp(e,t,Q$e),U$e=(e,t)=>{const n=qae(e,t);return n?n.toLowerCase():null},Kae=(e,t)=>wp(e,t,$$e),V$e=(e,t)=>{const n=Kae(e,t);return n?n.toLowerCase():null},G$e=(e,t)=>wp(e,t,X$e),W$e=(e,t,n)=>Z$e(e,t,n),j$e=(e,t)=>wp(e,t,eet),q$e=(e,t)=>wp(e,t,J$e),K$e={decimal:z$e,decimalZero:q$e,lowerRoman:U$e,upperRoman:qae,lowerLetter:V$e,upperLetter:Kae,ordinal:G$e,custom:W$e,japaneseCounting:j$e};const Yae=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const o=K$e[n];return o?o(e,t,r):null};var Y$e=(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),wp=(e,t,n)=>Y$e(e.map((r,o)=>n(r,o)),t),X$e=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},J$e=(e,t)=>e>=10||t===0?String(e):`0${e}`,Z$e=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return wp(e,t,D4);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const o=r[1].length;return wp(e,t,i=>String(i).padStart(o,"0"))},D4=e=>String(e),Q$e=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},$$e=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const eet=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 tet=new Set(["","","○","o","■","□"]);const O4=e=>!e||!tet.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Xae=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 F4=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Xae(e[e.length-1]);return t!=null&&t>0?t:void 0},PP=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(Xae).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 net(e){return typeof e.captureStackTrace=="function"}var LP=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",net(Error)&&Error.captureStackTrace(this,this.constructor)}},ret=class extends LP{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},oet=class extends LP{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const NP=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new ret(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 oet(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 LP?r:new LP("Failed to create file object",r)}};function iet(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 B4={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 set(e){return e[1].user!==void 0}const aet=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(set).filter(([r,o])=>{const i=Cw({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=Cw({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}})},cet=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 uet="https://ingest.superdoc.dev/v1/collect";const $ir="community-and-eval-agplv3";function det(){try{return"1.37.0-next.2"}catch{return"unknown"}}var fet=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||uet,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=det()}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 het(e,t){return e.type.name===t}function pet(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function met(e,t){return e.type.name===t}function $n(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 Xn=class eKe{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($n(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi($n(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new eKe(t)}};function get(e){return Xn.create(e)}var Sl=class tKe{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($n(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi($n(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new tKe(t)}};function yet(e){return Sl.create(e)}var H4=$o(((e,t)=>{t.exports={}})),bet=$o((e=>{(function(t){t.parser=function(q,D){return new r(q,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(q,D){if(!(this instanceof r))return new r(q,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=!!q,N.noscript=!!(q||N.opt.noscript),N.state=E.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=!q),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),k(N,"onready")}Object.create||(Object.create=function(q){function D(){}return D.prototype=q,new D}),Object.keys||(Object.keys=function(q){var D=[];for(var N in q)q.hasOwnProperty(N)&&D.push(N);return D});function o(q){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,j=0,ie=n.length;j<ie;j++){var J=q[n[j]].length;if(J>D)switch(n[j]){case"textNode":U(q);break;case"cdata":H(q,"oncdata",q.cdata),q.cdata="";break;case"script":H(q,"onscript",q.script),q.script="";break;default:z(q,"Max buffer length exceeded: "+n[j])}N=Math.max(N,J)}q.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+q.position}function i(q){for(var D=0,N=n.length;D<N;D++)q[n[D]]=""}function s(q){U(q),q.cdata!==""&&(H(q,"oncdata",q.cdata),q.cdata=""),q.script!==""&&(H(q,"onscript",q.script),q.script="")}r.prototype={end:function(){Z(this)},write:_e,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=H4().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(q){return q!=="error"&&q!=="end"});function c(q,D){return new d(q,D)}function u(q,D){if(q.length>=2){if(q[0]===255&&q[1]===254)return"utf-16le";if(q[0]===254&&q[1]===255)return"utf-16be"}return q.length>=3&&q[0]===239&&q[1]===187&&q[2]===191?"utf8":q.length>=4?q[0]===60&&q[1]===0&&q[2]===63&&q[3]===0?"utf-16le":q[0]===0&&q[1]===60&&q[2]===0&&q[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(q,D){if(!(this instanceof d))return new d(q,D);a.apply(this),this._parser=new r(q,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(j){N.emit("error",j),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(j){Object.defineProperty(N,"on"+j,{get:function(){return N._parser["on"+j]},set:function(ie){if(!ie)return N.removeAllListeners(j),N._parser["on"+j]=ie,ie;N.on(j,ie)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(q,D){if(this._decoderBuffer&&(q=Buffer.concat([this._decoderBuffer,q]),this._decoderBuffer=null),!this._decoder){var N=u(q,D);if(!N)return this._decoderBuffer=q,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(q,{stream:!D})},d.prototype.write=function(q){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(q))q=this._decodeBuffer(q,!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(q.toString()),this.emit("data",q),!0},d.prototype.end=function(q){if(q&&q.length&&this.write(q),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(q,D){var N=this;return!N._parser["on"+q]&&l.indexOf(q)!==-1&&(N._parser["on"+q]=function(){var j=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);j.splice(0,0,q),N.emit.apply(N,j)}),a.prototype.on.call(N,q,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,I=/[#:_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 w(q){return q===" "||q===`
5
+ `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&S4(r,this,o,a,s.attributes||{})}else s.retain!==void 0?xae(r,this,o,s.retain,s.attributes||{}):s.delete!==void 0&&Cae(r,o,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??vl();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(Ay(l,t)||n!==void 0&&Ay(l,n))switch(l.content.constructor){case Zm:{const d=i.get("ychange");t!==void 0&&!Ay(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&&!Ay(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 vp:case yx:{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 Ra:Ay(l,t)&&(c(),Tw(i,l.content));break}l=l.right}c()};return t||n?Ri(s,d=>{t&&p4(d,t),n&&p4(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=SP(i,this,t,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),S4(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=SP(i,this,t,!r);S4(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=>{Cae(o,SP(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=SP(i,this,t,!1);s.right!==null&&xae(i,this,s,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?Ri(this.doc,n=>{wP(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{w4(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return A4(this,t)}getAttributes(){return vae(this)}_write(t){t.writeTypeRef(y$e)}},JQe=e=>new gx,T4=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??vl()}[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===wl||t.constructor===xw)&&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})}},xw=class One extends _a{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 One}clone(){const t=new One;return t.insert(0,this.toArray().map(n=>n instanceof _a?n.clone():n)),t}get length(){return this.doc??vl(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new T4(this,t)}querySelector(t){t=t.toUpperCase();const n=new T4(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),pp(new T4(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){bP(this,t,new $Qe(this,n,t))}toString(){return pae(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),mx(this,i=>{o.insertBefore(i.toDOM(t,n,r),null)}),o}insert(t,n){this.doc!==null?Ri(this.doc,r=>{yae(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 _a?t._item:t;vP(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 Jf("Reference item not found");r.splice(o,0,...n)}}delete(t,n=1){this.doc!==null?Ri(this.doc,r=>{bae(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return fae(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return mae(this,t)}slice(t=0,n=this.length){return dae(this,t,n)}forEach(t){mx(this,t)}_write(t){t.writeTypeRef(v$e)}},ZQe=e=>new xw,wl=class Fne extends xw{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 Fne(this.nodeName)}clone(){const t=new Fne(this.nodeName),n=this.getAttributes();return zJe(n,(r,o)=>{t.setAttribute(o,r)}),t.insert(0,this.toArray().map(r=>r instanceof _a?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=>{wP(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?Ri(this.doc,r=>{w4(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return A4(this,t)}hasAttribute(t){return wae(this,t)}getAttributes(t){return t?UQe(this,t):vae(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 mx(this,s=>{o.appendChild(s.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(t){t.writeTypeRef(b$e),t.writeKey(this.nodeName)}},QQe=e=>new wl(e.readKey()),$Qe=class extends gP{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)})}},e$e=class Bne extends Qa{constructor(t){super(),this.hookName=t}_copy(){return new Bne(this.hookName)}clone(){const t=new Bne(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(w$e),t.writeKey(this.hookName)}},t$e=e=>new e$e(e.readKey()),Xd=class Hne extends gx{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 Hne}clone(){const t=new Hne;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(A$e)}},n$e=e=>new Xd,x4=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ju()}mergeWith(e){return!1}write(e,t,n){throw Ju()}integrate(e,t){throw Ju()}},r$e=0,Qu=class extends x4{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),Qse(e.doc.store,this)}write(e,t){e.writeInfo(r$e),e.writeLen(this.length-t)}getMissing(e,t){return null}},k4=class Xqe{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Xqe(this.content)}splice(t){throw Ju()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},o$e=e=>new k4(e.readBuf()),Eae=class zne{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new zne(this.len)}splice(t){const n=new zne(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){lx(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}},i$e=e=>new Eae(e.readLen()),_ae=(e,t)=>new bp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),C4=class Jqe{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 Jqe(_ae(this.doc.guid,this.opts))}splice(t){throw Ju()}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}},s$e=e=>new C4(_ae(e.readString(),e.readAny())),yx=class Zqe{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Zqe(this.embed)}splice(t){throw Ju()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},a$e=e=>new yx(e.readJSON()),Ra=class Qqe{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Qqe(this.key,this.value)}splice(t){throw Ju()}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}},l$e=e=>new Ra(e.readKey(),e.readJSON()),c$e=class Une{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Une(this.arr)}splice(t){const n=new Une(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}},u$e=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 c$e(n)},d$e=rP("node_env")==="development",TP=class Vne{constructor(t){this.arr=t,d$e&&$ie(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Vne(this.arr)}splice(t){const n=new Vne(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}},f$e=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new TP(n)},Zm=class Gne{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Gne(this.str)}splice(t){const n=new Gne(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}},h$e=e=>new Zm(e.readString()),p$e=[GQe,jQe,JQe,QQe,ZQe,t$e,n$e],m$e=0,g$e=1,y$e=2,b$e=3,v$e=4,w$e=5,A$e=6,vp=class $qe{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new $qe(this.type._copy())}splice(t){throw Ju()}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}},I$e=e=>new vp(p$e[e.readTypeRef()](e)),E4=(e,t)=>{let n=t,r=0,o;do r>0&&(n=jr(n.client,n.clock+r)),o=Sw(e,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof ji);return{item:o,diff:r}},_4=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},xP=(e,t,n)=>{const{client:r,clock:o}=t.id,i=new ji(jr(r,o+n),t,jr(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=jr(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},Rae=(e,t)=>R9(e,n=>bw(n.deletions,t)),Pae=(e,t,n,r,o,i)=>{const s=e.doc,a=s.store,l=s.clientID,c=t.redone;if(c!==null)return Pc(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Pae(e,u,n,r,o,i)===null))return null;for(;u.redone!==null;)u=Pc(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:Pc(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:Pc(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||bw(r,d.right.id)||Rae(i.undoStack,d.right.id)||Rae(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Pc(e,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;const p=jr(l,Ds(a,l)),m=new ji(p,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=p,_4(m,!0),m.integrate(e,0),m},ji=class Wne extends x4{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>=Ds(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ds(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Aw&&this.id.client!==this.parent.client&&this.parent.clock>=Ds(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=$se(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Pc(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Qu||this.right&&this.right.constructor===Qu)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Wne?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Wne&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Aw){const r=Sw(n,this.parent);r.constructor===Qu?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=$se(t,t.doc.store,jr(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),Iw(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,i.clear();else if(Iw(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&s.has(Sw(t.doc.store,o.origin)))i.has(Sw(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),Qse(t.doc.store,this),this.content.integrate(t,this),nae(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new Qu(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:jr(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Iw(t.origin,this.lastId)&&this.right===t&&Iw(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(),lx(t.deleteSet,this.id.client,this.id.clock,this.length),nae(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Kl();this.content.gc(t),n?TQe(t,this,new Qu(this.id,this.length)):this.content=new Eae(this.length)}write(t,n){const r=n>0?jr(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=ux(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===Aw?(t.writeParentInfo(!1),t.writeLeftID(a)):Kl();i!==null&&t.writeString(i)}this.content.write(t,n)}},Lae=(e,t)=>S$e[t&31](e),S$e=[()=>{Kl()},i$e,u$e,o$e,h$e,a$e,l$e,I$e,f$e,s$e,()=>{Kl()}],T$e=10,$u=class extends x4{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Kl()}write(e,t){e.writeInfo(T$e),En(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Nae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Mae="__ $YJS$ __";Nae[Mae]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Nae[Mae]=!0;const x$e=3e4;var Dae=class extends cZe{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Kd();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&&kw(this,n,"timeout")},Xu(x$e/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:Kd()});const i=[],s=[],a=[],l=[];e===null?l.push(t):o==null?e!=null&&i.push(t):(s.push(t),fw(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 kw=(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:Kd()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},Qm=(e,t,n=e.states)=>{const r=t.length,o=da();En(o,r);for(let i=0;i<r;i++){const s=t[i],a=n.get(s)||null,l=e.meta.get(s).clock;En(o,s),En(o,l),Ca(o,JSON.stringify(a))}return Wi(o)},Oae=(e,t,n)=>{const r=mp(t),o=Kd(),i=[],s=[],a=[],l=[],c=Dr(r);for(let u=0;u<c;u++){const d=Dr(r);let f=Dr(r);const h=JSON.parse(uu(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&&(fw(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 Fae=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 k$e(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 R4(e){return new Promise(t=>setTimeout(t,e))}function C$e(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 E$e(e,t){const n=k$e(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||C$e;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 R4(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 R4(s),r.attemptNum<1&&n.initialJitter){const a=o(r,n);a&&await R4(a)}return i()}const Bae=e=>UJe(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");let Al=(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})({}),Il=(function(e){return e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e})({});var kP=class{data;encoder;decoder;constructor(e){this.data=e,this.encoder=da(),this.decoder=mp(new Uint8Array(this.data))}peekVarString(){return xJe(this.decoder)}readVarUint(){return Dr(this.decoder)}readVarString(){return uu(this.decoder)}readVarUint8Array(){return Za(this.decoder)}writeVarUint(e){return En(this.encoder,e)}writeVarString(e){return Ca(this.encoder,e)}writeVarUint8Array(e){return hs(this.encoder,e)}length(){return XR(this.encoder)}},Hae=class extends Fae{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=Il.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===Il.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===Il.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:E$e(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=Il.Connecting,this.emit("status",{status:Il.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Kd();const t=new kP(e.data).peekVarString();this.configuration.providerMap.get(t)?.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Il.Connected,this.emit("status",{status:Il.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===Il.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Kd()-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=Bae(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===LJe.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){if(this.closeTries=0,this.cleanupWebSocket(),this.status===Il.Connected&&(this.status=Il.Disconnected,this.emit("status",{status:Il.Disconnected}),this.emit("disconnect",{event:e})),e.code===qie.code&&(e.reason===qie.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===PJe.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===RJe.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!==Il.Disconnected&&(this.status=Il.Disconnected,this.emit("status",{status:Il.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 Jir=0,Zir=1,Qir=2,CP=(e,t)=>{En(e,0);const n=yQe(t);hs(e,n)},P4=(e,t,n)=>{En(e,1),hs(e,c4(t,n))},_$e=(e,t,n)=>P4(t,n,Za(e)),zae=(e,t,n,r)=>{try{Gse(t,Za(e),n)}catch(o){r?.(o),console.error("Caught error while handling a Yjs update",o)}},Uae=(e,t)=>{En(e,2),hs(e,t)},R$e=zae,Vae=(e,t,n,r,o)=>{const i=Dr(e);switch(i){case 0:_$e(e,t,n);break;case 1:zae(e,n,r,o);break;case 2:R$e(e,n,r,o);break;default:throw new Error("Unknown message type")}return i};var Qf=class{encoder;type;constructor(){this.encoder=da()}get(e){return e.encoder}toUint8Array(){return Wi(this.encoder)}},Gae=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 Al.Sync:this.applySyncMessage(e,t);break;case Al.Awareness:this.applyAwarenessMessage(e);break;case Al.Auth:this.applyAuthMessage(e);break;case Al.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Al.Stateless:e.receiveStateless(uu(n.decoder));break;case Al.SyncStatus:this.applySyncStatusMessage(e,$R(n.decoder)===1);break;default:throw new Error(`Can’t apply message of unknown type: ${r}`)}n.length()>o+1&&(this.broadcasted?e.broadcast(Qf,{encoder:n.encoder}):e.send(Qf,{encoder:n.encoder}))}applySyncMessage(e,t){const{message:n}=this;n.writeVarUint(Al.Sync);const r=Vae(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;Oae(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;_Je(t.decoder,e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(Al.Awareness),t.writeVarUint8Array(Qm(e.awareness,Array.from(e.awareness.getStates().keys())))}},Wae=class{encoder;message;constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Wi(this.encoder)}send(e){e?.send(this.create())}broadcast(e){by(e,this.create())}},P$e=class extends Qf{type=Al.Auth;description="Authentication";get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return Ca(this.encoder,e.documentName),En(this.encoder,this.type),EJe(this.encoder,e.token),this.encoder}},EP=class extends Qf{type=Al.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");Ca(this.encoder,e.documentName),En(this.encoder,this.type);let t;return e.states===void 0?t=Qm(e.awareness,e.clients):t=Qm(e.awareness,e.clients,e.states),hs(this.encoder,t),this.encoder}},L$e=class extends Qf{type=Al.CLOSE;description="Ask the server to close the connection";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},N$e=class extends Qf{type=Al.QueryAwareness;description="Queries awareness states";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),this.encoder}},M$e=class extends Qf{type=Al.Stateless;description="A stateless message";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),Ca(this.encoder,e.payload??""),this.encoder}},L4=class extends Qf{type=Al.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 Ca(this.encoder,e.documentName),En(this.encoder,this.type),CP(this.encoder,e.document),this.encoder}},D$e=class extends Qf{type=Al.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 Ca(this.encoder,e.documentName),En(this.encoder,this.type),P4(this.encoder,e.document),this.encoder}},O$e=class extends Qf{type=Al.Sync;description="A document update";get(e){return Ca(this.encoder,e.documentName),En(this.encoder,this.type),Uae(this.encoder,e.update),this.encoder}},F$e=class extends Error{code=1001},B$e=class extends Fae{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=Il.Disconnected;isAuthenticated=!1;authorizedScope=void 0;mux=sse();intervals={forceSync:null};isConnected=!0;constructor(e){super(),this.setConfiguration(e),this.configuration.document=e.document?e.document:new bp,this.configuration.awareness=e.awareness!==void 0?e.awareness:new Dae(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:Kie(this.awareness.getStates())})}),this.awareness?.on("change",()=>{this.emit("awarenessChange",{states:Kie(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 Hae({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(L4,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&kw(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(M$e,{documentName:this.configuration.name,payload:e})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(O$e,{update:e,documentName:this.configuration.name},!0))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){const o=e.concat(t).concat(n);this.send(EP,{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(P$e,{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(L4,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(EP,{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 Wae(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new kP(e.data),n=t.readVarString();t.writeVarString(n),this.emit("message",{event:e,message:new kP(e.data)}),new Gae(t).apply(this,!0)}onClose(e){this.isAuthenticated=!1,this.synced=!1,this.awareness&&kw(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&&(kw(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(L$e,{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=Il.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 kP(e),n=t.readVarString();t.writeVarString(n),new Gae(t).setBroadcasted(!0).apply(this,!1)})}subscribeToBroadcastChannel(){this.subscribedToBroadcastChannel||(ose(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!0),this.mux(()=>{this.broadcast(L4,{document:this.document,documentName:this.configuration.name}),this.broadcast(D$e,{document:this.document,documentName:this.configuration.name}),this.broadcast(N$e,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.broadcast(EP,{awareness:this.awareness,clients:[this.document.clientID],document:this.document,documentName:this.configuration.name})})}disconnectBroadcastChannel(){this.awareness&&this.send(EP,{awareness:this.awareness,clients:[this.document.clientID],states:new Map,documentName:this.configuration.name},!0),this.subscribedToBroadcastChannel&&(ise(this.broadcastChannel,this.boundBroadcastChannelSubscriber),this.subscribedToBroadcastChannel=!1)}broadcast(e,t){this.configuration.broadcast&&this.subscribedToBroadcastChannel&&new Wae(e,t).broadcast(this.broadcastChannel)}setAwarenessField(e,t){if(!this.awareness)throw new F$e(`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 Lc="application/vnd.openxmlformats-officedocument.wordprocessingml.document",bx="application/pdf",_P="text/html",H$e={docx:Lc,pdf:bx,html:_P},N4=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Os={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"},vx=e=>typeof e!="string"?"":e.trim(),RP=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},M4=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},wx=e=>{const t=e??{},n=vx(t.id),r=RP(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},jae=({current:e,other:t})=>{const n=wx(e),r=wx(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},Cw=({actor:e,fallbackKey:t=""})=>{const n=wx(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 z$e=(e,t)=>wp(e,t,D4),qae=(e,t)=>wp(e,t,Q$e),U$e=(e,t)=>{const n=qae(e,t);return n?n.toLowerCase():null},Kae=(e,t)=>wp(e,t,$$e),V$e=(e,t)=>{const n=Kae(e,t);return n?n.toLowerCase():null},G$e=(e,t)=>wp(e,t,X$e),W$e=(e,t,n)=>Z$e(e,t,n),j$e=(e,t)=>wp(e,t,eet),q$e=(e,t)=>wp(e,t,J$e),K$e={decimal:z$e,decimalZero:q$e,lowerRoman:U$e,upperRoman:qae,lowerLetter:V$e,upperLetter:Kae,ordinal:G$e,custom:W$e,japaneseCounting:j$e};const Yae=({listLevel:e,lvlText:t,listNumberingType:n,customFormat:r})=>{if(typeof t!="string")return null;const o=K$e[n];return o?o(e,t,r):null};var Y$e=(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),wp=(e,t,n)=>Y$e(e.map((r,o)=>n(r,o)),t),X$e=e=>{const t=["th","st","nd","rd"],n=e%100;return`${e}${t[(n-20)%10]||t[n]||t[0]}`},J$e=(e,t)=>e>=10||t===0?String(e):`0${e}`,Z$e=(e,t,n)=>{if(typeof n!="string"||n.match(/(?:[0]+\d,\s){3}\.{3}/)==null)return wp(e,t,D4);const r=n.match(/(\d+)/);if(!r)throw new Error("Invalid format string: no numeric pattern found");const o=r[1].length;return wp(e,t,i=>String(i).padStart(o,"0"))},D4=e=>String(e),Q$e=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},$$e=e=>{if(e<1)return"";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(e-1)%26],n=Math.floor((e-1)/26)+1;return t.repeat(n)};const eet=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 tet=new Set(["","","○","o","■","□"]);const O4=e=>!e||!tet.has(e)?e:e===""?"•":e==="○"||e==="o"?"◦":e==="■"||e===""?"▪":e==="□"?"◯":e;var Xae=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 F4=e=>{if(!Array.isArray(e)||e.length===0)return;const t=Xae(e[e.length-1]);return t!=null&&t>0?t:void 0},PP=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(Xae).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 net(e){return typeof e.captureStackTrace=="function"}var LP=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",net(Error)&&Error.captureStackTrace(this,this.constructor)}},ret=class extends LP{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},oet=class extends LP{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}};const NP=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new ret(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 oet(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 LP?r:new LP("Failed to create file object",r)}};function iet(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 B4={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 set(e){return e[1].user!==void 0}const aet=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(set).filter(([r,o])=>{const i=Cw({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=Cw({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}})},cet=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 uet="https://ingest.superdoc.dev/v1/collect";const $ir="community-and-eval-agplv3";function det(){try{return"1.37.0-next.3"}catch{return"unknown"}}var fet=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||uet,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=det()}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 het(e,t){return e.type.name===t}function pet(e,t){if(e.type.name!==t)throw new Error(`Expected node type "${t}", got "${e.type.name}"`)}function met(e,t){return e.type.name===t}function $n(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 Xn=class eKe{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($n(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi($n(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new eKe(t)}};function get(e){return Xn.create(e)}var Sl=class tKe{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($n(this,"addOptions",{name:this.name}))||{}:this.options={},this.storage=Pi($n(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t){return new tKe(t)}};function yet(e){return Sl.create(e)}var H4=$o(((e,t)=>{t.exports={}})),bet=$o((e=>{(function(t){t.parser=function(q,D){return new r(q,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(q,D){if(!(this instanceof r))return new r(q,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=!!q,N.noscript=!!(q||N.opt.noscript),N.state=E.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=!q),N.trackPosition=N.opt.position!==!1,N.trackPosition&&(N.position=N.line=N.column=0),k(N,"onready")}Object.create||(Object.create=function(q){function D(){}return D.prototype=q,new D}),Object.keys||(Object.keys=function(q){var D=[];for(var N in q)q.hasOwnProperty(N)&&D.push(N);return D});function o(q){for(var D=Math.max(t.MAX_BUFFER_LENGTH,10),N=0,j=0,ie=n.length;j<ie;j++){var J=q[n[j]].length;if(J>D)switch(n[j]){case"textNode":U(q);break;case"cdata":H(q,"oncdata",q.cdata),q.cdata="";break;case"script":H(q,"onscript",q.script),q.script="";break;default:z(q,"Max buffer length exceeded: "+n[j])}N=Math.max(N,J)}q.bufferCheckPosition=t.MAX_BUFFER_LENGTH-N+q.position}function i(q){for(var D=0,N=n.length;D<N;D++)q[n[D]]=""}function s(q){U(q),q.cdata!==""&&(H(q,"oncdata",q.cdata),q.cdata=""),q.script!==""&&(H(q,"onscript",q.script),q.script="")}r.prototype={end:function(){Z(this)},write:_e,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a;try{a=H4().Stream}catch{a=function(){}}a||(a=function(){});var l=t.EVENTS.filter(function(q){return q!=="error"&&q!=="end"});function c(q,D){return new d(q,D)}function u(q,D){if(q.length>=2){if(q[0]===255&&q[1]===254)return"utf-16le";if(q[0]===254&&q[1]===255)return"utf-16be"}return q.length>=3&&q[0]===239&&q[1]===187&&q[2]===191?"utf8":q.length>=4?q[0]===60&&q[1]===0&&q[2]===63&&q[3]===0?"utf-16le":q[0]===0&&q[1]===60&&q[2]===0&&q[3]===63?"utf-16be":"utf8":D?"utf8":null}function d(q,D){if(!(this instanceof d))return new d(q,D);a.apply(this),this._parser=new r(q,D),this.writable=!0,this.readable=!0;var N=this;this._parser.onend=function(){N.emit("end")},this._parser.onerror=function(j){N.emit("error",j),N._parser.error=null},this._decoder=null,this._decoderBuffer=null,l.forEach(function(j){Object.defineProperty(N,"on"+j,{get:function(){return N._parser["on"+j]},set:function(ie){if(!ie)return N.removeAllListeners(j),N._parser["on"+j]=ie,ie;N.on(j,ie)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(a.prototype,{constructor:{value:d}}),d.prototype._decodeBuffer=function(q,D){if(this._decoderBuffer&&(q=Buffer.concat([this._decoderBuffer,q]),this._decoderBuffer=null),!this._decoder){var N=u(q,D);if(!N)return this._decoderBuffer=q,"";this._parser.encoding=N,this._decoder=new TextDecoder(N)}return this._decoder.decode(q,{stream:!D})},d.prototype.write=function(q){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(q))q=this._decodeBuffer(q,!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(q.toString()),this.emit("data",q),!0},d.prototype.end=function(q){if(q&&q.length&&this.write(q),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(q,D){var N=this;return!N._parser["on"+q]&&l.indexOf(q)!==-1&&(N._parser["on"+q]=function(){var j=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);j.splice(0,0,q),N.emit.apply(N,j)}),a.prototype.on.call(N,q,D)};var f="[CDATA[",h="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,I=/[#:_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 w(q){return q===" "||q===`
6
6
  `||q==="\r"||q===" "}function A(q){return q==='"'||q==="'"}function T(q){return q===">"||w(q)}function x(q,D){return q.test(D)}function _(q,D){return!x(q,D)}var E=0;t.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},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(q){var D=t.ENTITIES[q],N=typeof D=="number"?String.fromCharCode(D):D;t.ENTITIES[q]=N});for(var P in t.STATE)t.STATE[t.STATE[P]]=P;E=t.STATE;function k(q,D,N){q[D]&&q[D](N)}function L(q){var D=q&&q.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return D?D[2]:null}function R(q){return q?q.toLowerCase().replace(/[^a-z0-9]/g,""):null}function O(q,D){const N=R(q),j=R(D);return!N||!j?!0:j==="utf16"?N==="utf16le"||N==="utf16be":N===j}function F(q,D){if(!(!q.strict||!q.encoding||!D||D.name!=="xml")){var N=L(D.body);N&&!O(q.encoding,N)&&$(q,"XML declaration encoding "+N+" does not match detected stream encoding "+q.encoding.toUpperCase())}}function H(q,D,N){q.textNode&&U(q),k(q,D,N)}function U(q){q.textNode=M(q.opt,q.textNode),q.textNode&&k(q,"ontext",q.textNode),q.textNode=""}function M(q,D){return q.trim&&(D=D.trim()),q.normalize&&(D=D.replace(/\s+/g," ")),D}function z(q,D){return U(q),q.trackPosition&&(D+=`
7
7
  Line: `+q.line+`
8
8
  Column: `+q.column+`
@@ -80,7 +80,7 @@ Actual: `+q.attribValue);else{var ie=q.tag,J=q.tags[q.tags.length-1]||q;ie.ns===
80
80
  `,`
81
81
  `);as({editor:e,partId:o.partId,operation:"mutate",source:`story-runtime:commit:${n.storyType}`,mutate({part:c}){HTe(c,o,n.noteId,l)}})}function j8t(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)?vb({type:"doc",content:o.content.length>0?o.content:[{type:"paragraph"}]}):o.doc&&typeof o.doc=="object"?vb(o.doc):o.type==="doc"||o.type==="footnoteBody"||o.type==="endnoteBody"?vb(o):null:null}function q8t(e,t,n,r){const o=BM(e,t.childElementName).find(s=>s.attributes?.["w:id"]===n);if(!o)return!1;const i=r;return WW(i,t.childElementName),o.elements=i,!0}var jW=new WeakMap;function K8t(e){const t=jW.get(e);if(t)return t;const n={counters:new Map};return jW.set(e,n),n}function Y8t(e){return jW.get(e)}function X8t(e,t){const n=e.counters.get(t)??0;return String(n)}function J8t(e,t){const n=(e.counters.get(t)??0)+1;return e.counters.set(t,n),String(n)}var OA=new WeakMap;function Z8t(e){let t=OA.get(e);return t||(t=new Map,OA.set(e,t)),t}function KTe(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 Q8t(e,t,n){const r=Z8t(e),o=t.storyKey;return r.set(o,{storyKey:o,editor:n,runtime:t}),()=>{e9t(e,o,n)}}function qW(e,t){const n=OA.get(e)?.get(t);return n?KTe(n):null}function $8t(e){const t=OA.get(e);if(!t||t.size===0)return 0;let n=0;for(const r of[...t.values()])KTe(r).commit?.(e),n+=1;return n}function e9t(e,t,n){const r=OA.get(e);if(!r)return;const o=r.get(t);o&&(n&&o.editor!==n||(r.delete(t),r.size===0&&OA.delete(e)))}var TC=new WeakMap,KW=new WeakMap;function t9t(e,t){return KW.get(e)?.has(t)??!1}function n9t(e,t){let n=KW.get(e);n||(n=new Set,KW.set(e,n)),n.add(t)}function YTe(e){let t=TC.get(e);return t||(t=new q6t,TC.set(e,t),r9t(e)),t}function r9t(e){typeof e.on=="function"&&(e.on("notes-part-changed",()=>{const t=TC.get(e);t&&(t.invalidateByPrefix("fn:"),t.invalidateByPrefix("en:"))}),e.on("partChanged",t=>{const n=TC.get(e);n&&t.parts.some(r=>bb(r.partId))&&n.invalidateByPrefix("hf:")}))}var o9t={kind:"story",storyType:"body"};function i9t(e){return{locator:o9t,storyKey:bh,editor:e,kind:"body"}}function il(e,t,n={}){if(t===void 0||t.storyType==="body")return s9t(e);const r=Si(t),o=qW(e,r);if(o)return o;const i=YTe(e),s=i.get(r);if(s)return s;let a;switch(t.storyType){case"headerFooterSlot":a=k8t(e,t,n);break;case"headerFooterPart":a=C8t(e,t);break;case"footnote":case"endnote":a=W8t(e,t);break;default:{const c=t;throw new De("INVALID_INPUT",`Unknown story type on locator: ${JSON.stringify(c)}`)}}UU(a.editor);const l=Y8t(e);if(l){const c=X8t(l,r);aye(a.editor,c)}return VU(a.editor),l&&!t9t(a.editor,r)&&(n9t(a.editor,r),a.editor.on("transaction",({transaction:c})=>{c.docChanged&&J8t(l,r)})),a.cacheable!==!1&&i.set(r,a),a}function s9t(e){const t=YTe(e),n=t.get(bh);if(n)return n;const r=i9t(e);return t.set(bh,r),r}function a9t(e){return TC.get(e)}function YW(e,t){const n=il(e,t.in).editor.state.doc;return bM(n,0,n.content.size,`
82
82
  `,`
83
- `)}var l9t=xs({findChildren:()=>ZTe,findInlineNodes:()=>XW,findMarkPosition:()=>XTe,flatten:()=>JTe},1);const XTe=(e,t,n)=>{const r=e.resolve(t),o=r.parent,i=o.childAfter(r.parentOffset);if(!i.node)return null;const s=i.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+i.offset;for(;a>0&&s.isInSet(o.child(a-1).marks);)l-=o.child(--a).nodeSize;let c=r.index()+1,u=r.start()+i.offset+i.node.nodeSize;for(;c<o.childCount&&s.isInSet(o.child(c).marks);)u+=o.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},JTe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,o)=>{if(n.push({node:r,pos:o}),!t)return!1}),n},ZTe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return JTe(e,n).filter(r=>t(r.node))},XW=(e,t)=>ZTe(e,n=>n.isInline,t),jc=(e,t=null)=>{const n=[];if(!e?.doc)return n;const r=XW(e.doc);return r.length?(r.forEach(({node:o,pos:i})=>{const{marks:s}=o,a=[ss,gi,ta];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,node:o,from:i,to:i+o.nodeSize})})}),t?n.filter(({mark:o})=>o.attrs.id===t):n):n};function c9t(e){try{const t=jc(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function u9t(e){return e.rawId}function xC(e){return e.hasFormat?"format":e.hasInsert&&e.hasDelete?"replacement":e.hasDelete?"delete":"insert"}var QTe=new WeakMap;function d9t(e){return e?.options?.trackedChanges?.replacements==="independent"?"independent":"paired"}function $Te(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function f9t(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function exe(e,t,n){const r=Sr(e.sourceId);return r?`word:${t}:${r}`:n}function txe(e){return e==="trackInsert"||e==="trackDelete"||e==="trackFormat"}function h9t(e){const t=[e.rawId,e.commandRawId,e.id,Sr(e.attrs.id),Sr(e.attrs.replacementGroupId),Sr(e.attrs.sourceId)];return Array.from(new Set(t.filter(n=>!!n)))}function p9t(e){if(e.hasInsert===e.hasDelete)return null;const t=Sr(e.attrs.replacementGroupId);return t?`group:${t}`:e.commandRawId?`command:${e.commandRawId}`:null}function m9t(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=p9t(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 nxe(e,t){return{id:e.id,rawId:e.rawId,commandRawId:e.commandRawId,type:xC(e),relationship:t}}function g9t(e,t){const n=xC(e),r=xC(t);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 y9t(e){if(e.length<2)return;const t=new Map;for(const r of e)for(const o of h9t(r))t.has(o)||t.set(o,r);const n=new Map;for(const r of e){const o=Sr(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(g9t),s=[nxe(r,"parent"),...i.map(l=>nxe(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 rxe(e){const t=e.type.name;if(!txe(t))return null;const n=e.attrs??{},r=Sr(n.id);return r?exe(n,t,r):null}function b9t(e,t){return t?(Array.isArray(e.node?.marks)?e.node.marks:[]).some(n=>{const r=n?.type?.name;return txe(r)?Sr(n?.attrs?.overlapParentId)===t:!1}):!1}function v9t(e,t){const n=t.node?.text;return typeof n=="string"?n:e.state.doc.textBetween(t.from,t.to," ","")}function FA(e){const t=e.state.doc,n=QTe.get(e);if(n&&n.doc===t)return n.grouped;const r=c9t(e),o=new Map;for(const s of r){const a=s.mark?.attrs??{},l=Sr(a.id);if(!l)continue;const c=s.mark.type.name,u=exe(a,c,l),d=o.get(u),f=c===ss,h=c===gi,p=c===ta,m=Sr(a.sourceId),g=f9t(c),y=!m||!b9t(s,l)?v9t(e,s):"";if(!d){o.set(u,{rawId:u,commandRawId:l,from:s.from,to:s.to,hasInsert:f,hasDelete:h,hasFormat:p,attrs:{...a},excerptParts:y?[y]:[],wordRevisionIds:g?$Te(void 0,g,m??void 0):void 0});continue}d.from=Math.min(d.from,s.from),d.to=Math.max(d.to,s.to),d.hasInsert=d.hasInsert||f,d.hasDelete=d.hasDelete||h,d.hasFormat=d.hasFormat||p,Object.keys(d.attrs).length===0&&Object.keys(a).length>0&&(d.attrs={...a}),y&&d.excerptParts.push(y),g&&(d.wordRevisionIds=$Te(d.wordRevisionIds,g,m??void 0))}const i=Array.from(o.values()).map(({excerptParts:s,...a})=>{const l=!!Sr(a.attrs.sourceId),c=s.join(""),u={...a,excerpt:s.length>0?c:l?"":void 0};return{...u,id:u9t(u)}}).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return y9t(i),QTe.set(e,{doc:t,grouped:i}),i}function oxe(e,t){const{baseId:n}=JW(t);return FA(e).find(r=>r.id===n)??null}function ixe(e){const t=FA(e),n=m9t(t,d9t(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=Sr(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 JW(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 w9t(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function wb(e,t){const n=w9t(t),r=n.entityId,o=n.story??{kind:"story",storyType:"body"};if((n.story?Si(n.story):"body")==="body"){const a=sxe(e,r);return a?{editor:e,story:o,runtimeRef:{storyKey:bh,rawId:a.rawId},change:a}:null}let i;try{i=il(e,o)}catch{return null}const s=sxe(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 sxe(e,t){const{baseId:n}=JW(t);return FA(e).find(r=>r.id===n||r.rawId===n||r.commandRawId===n)??null}const axe=["structuredContent","structuredContentBlock"],kC="structuredContentBlock",A9t="structuredContent";function CC(e){return axe.includes(e.type.name)}function Ab(e){const t=[];return e.descendants((n,r)=>(CC(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function Tn(e,t){const n=t.nodeId,r=Ab(e).filter(o=>String(o.node.attrs.id)===n);if(r.length===0)throw new De("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new De("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function ba(e,t){return e?.elements?.find(n=>n.name===t)}function lxe(e,t){return ba(e,t)?.attributes}function HM(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 cxe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var I9t=new Set(axe);function Ib(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((i,s)=>r!==null?!1:I9t.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 gf(e,t,n,r){const o=Tn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},i=r(ba(o,n));let s;return i===null?s=cxe(o,n):s=HM(o,n,i),Ib(e,t.nodeId,{sdtPr:s})}function ZW(e,t,n,r,o,i){return gf(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 S9t(e,t,n,r){return gf(e,t,n,o=>({name:n,type:"element",...o,elements:r}))}var T9t=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],x9t=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],k9t=["boundingBox","tags","hidden"];function Gp(e){const t=e.controlType??e.type;return typeof t=="string"&&T9t.includes(t)?t:"unknown"}function zM(e){const t=e.lockMode;return typeof t=="string"&&x9t.includes(t)?t:"unlocked"}function uxe(e){const t=e.appearance;if(typeof t=="string"&&k9t.includes(t))return t}function dxe(e){const t=e.sdtPr;if(!t)return;const n=lxe(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 Uo(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function QW(e){const t=(ba(e,"w14:checkbox")??ba(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 $W(e,t){const n=ba(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 C9t(e,t){if(!t)return{};switch(e){case"text":{const n=lxe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=ba(t,"w:date");if(!n)return{};const r=ba(n,"w:dateFormat"),o=ba(n,"w:lid"),i=ba(n,"w:storeMappedDataAs"),s=ba(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=ba(t,"w14:checkbox")??ba(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:QW(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 $W(t,e);case"repeatingSection":{const n=ba(t,"w15:repeatingSection")??ba(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 Gg(e){const t=e.node.attrs,n=String(t.id??""),r=Gp(t),o=zM(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=C9t(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:uxe(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:dxe(t),raw:i,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function E9t(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:Gp(n),lockMode:zM(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:uxe(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 sl(e,t){const n=zM(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Ah(e,t){const n=zM(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function va(e,t,n){const r=Gp(e.node.attrs),o=Array.isArray(t)?t:[t];if(!o.includes(r))throw new De("TYPE_MISMATCH",`Operation "${n}" requires control type ${o.join(" or ")}, but found "${r}".`,{expected:o,actual:r,operation:n})}function fxe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function Ih(e,t){return{success:!1,failure:{code:e,message:t}}}function EC(e,t){const n=e.length,r=t?.offset??0,o=t?.limit??n;return{items:e.slice(r,r+o),total:n}}function _C(e,t){const n=Un(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new De("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new De("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function hxe(e,t,n){const r=_C(e,t),o=_C(e,n);if(r.pos>o.pos)throw new De("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return Un(e).candidates.filter(i=>(i.nodeType==="paragraph"||i.nodeType==="listItem")&&i.pos>=r.pos&&i.pos<=o.pos)}function gd(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 BA(e){return Un(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>UM(e,t))}function al(e,t){if(t.numId==null)return[t];const n=BA(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 pxe(e,t){const n=al(e,t),r=n.findIndex(o=>o.address.nodeId===t.address.nodeId);return n.slice(r)}function mxe(e,t){const n=al(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function _9t(e,t){if(t.numId==null)return"";const n=al(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function gxe(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 HA(e,t,n){if(t.numId==null)return null;const r=BA(e),o=al(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:al(e,l),numId:l.numId,abstractNumId:gd(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:al(e,l),numId:l.numId,abstractNumId:gd(e,l.numId)}}}return null}function R9t(e,t){if(t.numId==null)return null;const n=gd(e,t.numId);if(n==null)return null;const r=BA(e),o=al(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&&gd(e,a.numId)===n&&a.numId!==t.numId)return{sequence:al(e,a),numId:a.numId}}return null}function yxe(e,t,n){const r=HA(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?gd(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 bxe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=gd(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=BA(e),o=al(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,gd(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=al(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 P9t(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:gM(n?.numId??r?.numId),level:gM(n?.ilvl??r?.ilvl)}}function L9t(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=jn.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 N9t(e,t,n,r){const o=(t.node.attrs??{}).listRendering?.numberingType;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":L9t(e,n,r)}function M9t(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function UM(e,t){const n=t.node.attrs??{},{numId:r,level:o}=P9t(t.node),i=PP(n.listRendering),s=i?.path,a=F4(s),l=i?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:o,kind:N9t(e,t,r,o),marker:l,path:s,ordinal:a,text:M9t(t)}}function vxe(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 D9t(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 O9t(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 De("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new De("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function F9t(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function B9t(e,t){if(t?.within&&t.within.kind!=="block")throw new De("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});Bg(t?.offset,t?.limit);const n=Un(e),r=O9t(n,t?.within),o=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>UM(e,f)),i=o.filter(f=>F9t(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=Zn(e),c=gxe(o);let u=0;const d=[];for(const f of i){if(!D9t(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=vxe(f,p),g=Ni(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:I,level:w,kind:A,text:T}=m;d.push(rs(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:I,level:w,kind:A,text:T}))}return qi({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function ts(e,t){const n=Un(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new De("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return UM(e,n[0])}var H9t=new Set(["text","date","checkbox","comboBox","dropDownList"]),wxe=new WeakMap;function z9t(e){const t=e.state.doc,n=wxe.get(e),r=Txe(e);if(n&&n.doc===t)return Axe(n.counts,r);const o=U9t(e);return wxe.set(e,{doc:t,counts:o}),Axe(o,r)}function U9t(e){const t=YW(e,{}),n=Un(e),r=Fg(e),o=V9t(n),i=G9t(r);return{words:Ixe(t),characters:t.length,paragraphs:o.paragraphs,headings:o.headings,tables:o.tables,images:o.blockImages+i,comments:W9t(r),trackedChanges:j9t(e),sdtFields:q9t(e),lists:K9t(e,n)}}function Axe(e,t){return t!=null?{...e,pages:t}:{...e}}function Ixe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function V9t(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 G9t(e){return e.byType.get("image")?.length??0}function W9t(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const o=yM(r.attrs??{});o&&n.add(o)}return n.size}function j9t(e){return FA(e).length}function q9t(e){return Ab(e.state.doc).filter(t=>H9t.has(Gp(t.node.attrs??{}))).length}function K9t(e,t){const n=Y9t(e,t);if(n.length===0)return 0;const r=gxe(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||X9t(s,a))&&(o+=1),s=a}return o}function Y9t(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>UM(e,n))}function X9t(e,t){return J9t(e,t)?!0:Z9t(e,t)}function J9t(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function Z9t(e,t){const n=Sxe(e),r=Sxe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Sxe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Txe(e){return e.currentTotalPages}function zA(e){const t=YW(e,{});return{words:Ixe(t),characters:Q9t(t),charactersWithSpaces:$9t(t),pages:Txe(e)}}function VM(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 Sb(e){return e.options?.parentEditor??e}function Q9t(e){return e.replace(/\s/g,"").length}function $9t(e){return e.replace(/\n/g,"").length}function xxe(e){const t=new Map,n=zA(Sb(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const o=VM(r,n);o!=null&&t.set(r,o)}return t}const ej="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",e4t="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",t4t="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var kxe="/APA.XSL",Cxe="APA",Exe="6",_xe=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"}),n4t=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"}),tj=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"}),r4t=Object.freeze(Object.fromEntries(Object.entries(tj).map(([e,t])=>[t,e])));function Wg(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function GM(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function UA(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function WM(e,t){const n=t??nW;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Rxe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(Wg(n.name)==="Person"){t.push(n);continue}Rxe(n,t)}}}function o4t(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=Wg(n.name),o=GM(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 nj(e,t){const n=(e?.elements??[]).find(o=>o?.type==="element"&&Wg(o.name)===t);if(!n)return[];const r=[];return Rxe(n,r),r.map(o4t).filter(Boolean)}function i4t(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(UA("b:Last",n)),r&&t.push(UA("b:First",r)),o&&t.push(UA("b:Middle",o)),{type:"element",name:"b:Person",elements:t}}function s4t(e){const t=(e??[]).map(i4t).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function rj(e,t){const n=s4t(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 a4t(e){return _xe[typeof e=="string"?e.trim():""]??_xe.misc}function l4t(e){return n4t[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function oj(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(tj)){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 c4t(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=Wg(a.name);if(l==="Tag"){n=GM(a);continue}if(l==="SourceType"){r=l4t(GM(a));continue}const c=r4t[l];if(!c)continue;const u=GM(a);u&&(t[c]=u)}const o=nj(e,"Author");o.length>0&&(t.authors=o);const i=nj(e,"Editor");i.length>0&&(t.editor=i);const s=nj(e,"Translator");return s.length>0&&(t.translator=s),oj({tag:n,type:r,fields:t})}function u4t(e){const t=oj(e);if(!t)return null;const n=[UA("b:Tag",t.tag),UA("b:SourceType",a4t(t.type))];for(const[s,a]of Object.entries(tj)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(UA(`b:${a}`,l))}const r=rj("Author",t.fields?.authors);r&&n.push(r);const o=rj("Editor",t.fields?.editor);o&&n.push(o);const i=rj("Translator",t.fields?.translator);return i&&n.push(i),{type:"element",name:"b:Source",elements:n}}function d4t(e){if(!e||e.type!=="element"||Wg(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 Pxe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function f4t(e){return e.startsWith("customXml/")?`../${e}`:e}function h4t(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>Wg(n.name)==="Relationships")||null}function p4t(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=WM({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=>Wg(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 m4t(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 g4t(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 y4t(e,t){const n=e.map(u4t).filter(Boolean),r=t.selectedStyle||kxe,o=t.styleName||Cxe,i=t.version||Exe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":ej,xmlns:ej,SelectedStyle:r,StyleName:o,Version:i},elements:n}}function b4t(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function v4t(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":ej}}]}]}}function w4t(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:t4t,Target:e}}]}}function Lxe(e){const t=new Map;for(const n of e){const r=oj(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function ij(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Nxe(e){const t=ij(),n=h4t(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=Ap(i,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(d4t(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=Pxe(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"||Wg(l.name)!=="Source")continue;const c=c4t(l);c&&r.push(c)}}}return t.sources=Lxe(r),t}function A4t(e,t){const n=Nxe(e),r=Lxe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...ij(),sources:[]};const o=t?.partPath||n.partPath,i=Pxe(o),s=i??g4t(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??kxe,d=t?.styleName??n.styleName??Cxe,f=t?.version??n.version??Exe,h=e[a]?.declaration;e[a]=WM(y4t(r,{selectedStyle:u,styleName:d,version:f}),h);const p=p4t(e),m=f4t(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:Ap(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:m4t(p),Type:e4t,Target:m}});const g=e[l],y=g?.declaration;e[l]=WM(v4t(b4t(g)||`{${dn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=WM(w4t(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function I4t(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var S4t=au($m(),1),T4t=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"}),Mxe="sans-serif",x4t=10,k4t="1.37.0-next.2",C4t="SuperdocDocumentOrigin",E4t=new Set(["word","google-docs","unknown","superdoc"]),Dxe=(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"])},ku=class _i{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=_i.getFontTableEntry(t,n)?.elements?.find(o=>o.name==="w:family")?.attributes?.["w:val"];return r?T4t[r.toLowerCase()]||Mxe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=_i.getFallbackFromFontTable(n,t)||Mxe;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=ij(),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 dOt}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]=JIe(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"]=JIe(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(S4t.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 _i,i=r.content,s=o.parseXmlToJson(i)?.elements?.find(l=>_i._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>_i._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]=_4t());const s=t[i].elements?.find(d=>_i._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=_i._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>_i._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)_i._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 _i.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=k4t){return _i.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"||_i._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||_i._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"||_i._matchesElementName(i.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let o=r.elements.find(i=>i.name==="dcterms:created"||_i._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 _i().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 _i.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?_i.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=_i.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(_i.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Lle(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${dn().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-${dn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Lle(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${dn().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=dn()),n||this.setDocumentCreatedTimestamp(_i.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||dn(),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");Dxe(i?.elements?.find(l=>l.name==="w:rPr")??i,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),Dxe(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=x4t);const s=o.typeface?_i.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(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=gtt(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";o.includes(s.fontFamily)||o.push(s.fontFamily),i+=`
83
+ `)}var l9t=xs({findChildren:()=>ZTe,findInlineNodes:()=>XW,findMarkPosition:()=>XTe,flatten:()=>JTe},1);const XTe=(e,t,n)=>{const r=e.resolve(t),o=r.parent,i=o.childAfter(r.parentOffset);if(!i.node)return null;const s=i.node.marks.find(d=>d.type.name===n);if(!s)return null;let a=r.index(),l=r.start()+i.offset;for(;a>0&&s.isInSet(o.child(a-1).marks);)l-=o.child(--a).nodeSize;let c=r.index()+1,u=r.start()+i.offset+i.node.nodeSize;for(;c<o.childCount&&s.isInSet(o.child(c).marks);)u+=o.child(c++).nodeSize;return{from:l,to:u,attrs:s.attrs}},JTe=(e,t=!0)=>{if(!e)throw new Error('Invalid "node" parameter');const n=[];return e.descendants((r,o)=>{if(n.push({node:r,pos:o}),!t)return!1}),n},ZTe=(e,t,n)=>{if(e){if(!t)throw new Error('Invalid "predicate" parameter')}else throw new Error('Invalid "node" parameter');return JTe(e,n).filter(r=>t(r.node))},XW=(e,t)=>ZTe(e,n=>n.isInline,t),jc=(e,t=null)=>{const n=[];if(!e?.doc)return n;const r=XW(e.doc);return r.length?(r.forEach(({node:o,pos:i})=>{const{marks:s}=o,a=[ss,gi,ta];s.length>0&&s.forEach(l=>{a.includes(l.type.name)&&n.push({mark:l,node:o,from:i,to:i+o.nodeSize})})}),t?n.filter(({mark:o})=>o.attrs.id===t):n):n};function c9t(e){try{const t=jc(e.state);return Array.isArray(t)?t:[]}catch{return[]}}function u9t(e){return e.rawId}function xC(e){return e.hasFormat?"format":e.hasInsert&&e.hasDelete?"replacement":e.hasDelete?"delete":"insert"}var QTe=new WeakMap;function d9t(e){return e?.options?.trackedChanges?.replacements==="independent"?"independent":"paired"}function $Te(e,t,n){return n?e?(e[t]||(e[t]=n),e):{[t]:n}:e}function f9t(e){return e==="trackInsert"?"insert":e==="trackDelete"?"delete":e==="trackFormat"?"format":null}function exe(e,t,n){const r=Sr(e.sourceId);return r?`word:${t}:${r}`:n}function txe(e){return e==="trackInsert"||e==="trackDelete"||e==="trackFormat"}function h9t(e){const t=[e.rawId,e.commandRawId,e.id,Sr(e.attrs.id),Sr(e.attrs.replacementGroupId),Sr(e.attrs.sourceId)];return Array.from(new Set(t.filter(n=>!!n)))}function p9t(e){if(e.hasInsert===e.hasDelete)return null;const t=Sr(e.attrs.replacementGroupId);return t?`group:${t}`:e.commandRawId?`command:${e.commandRawId}`:null}function m9t(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=p9t(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 nxe(e,t){return{id:e.id,rawId:e.rawId,commandRawId:e.commandRawId,type:xC(e),relationship:t}}function g9t(e,t){const n=xC(e),r=xC(t);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 y9t(e){if(e.length<2)return;const t=new Map;for(const r of e)for(const o of h9t(r))t.has(o)||t.set(o,r);const n=new Map;for(const r of e){const o=Sr(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(g9t),s=[nxe(r,"parent"),...i.map(l=>nxe(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 rxe(e){const t=e.type.name;if(!txe(t))return null;const n=e.attrs??{},r=Sr(n.id);return r?exe(n,t,r):null}function b9t(e,t){return t?(Array.isArray(e.node?.marks)?e.node.marks:[]).some(n=>{const r=n?.type?.name;return txe(r)?Sr(n?.attrs?.overlapParentId)===t:!1}):!1}function v9t(e,t){const n=t.node?.text;return typeof n=="string"?n:e.state.doc.textBetween(t.from,t.to," ","")}function FA(e){const t=e.state.doc,n=QTe.get(e);if(n&&n.doc===t)return n.grouped;const r=c9t(e),o=new Map;for(const s of r){const a=s.mark?.attrs??{},l=Sr(a.id);if(!l)continue;const c=s.mark.type.name,u=exe(a,c,l),d=o.get(u),f=c===ss,h=c===gi,p=c===ta,m=Sr(a.sourceId),g=f9t(c),y=!m||!b9t(s,l)?v9t(e,s):"";if(!d){o.set(u,{rawId:u,commandRawId:l,from:s.from,to:s.to,hasInsert:f,hasDelete:h,hasFormat:p,attrs:{...a},excerptParts:y?[y]:[],wordRevisionIds:g?$Te(void 0,g,m??void 0):void 0});continue}d.from=Math.min(d.from,s.from),d.to=Math.max(d.to,s.to),d.hasInsert=d.hasInsert||f,d.hasDelete=d.hasDelete||h,d.hasFormat=d.hasFormat||p,Object.keys(d.attrs).length===0&&Object.keys(a).length>0&&(d.attrs={...a}),y&&d.excerptParts.push(y),g&&(d.wordRevisionIds=$Te(d.wordRevisionIds,g,m??void 0))}const i=Array.from(o.values()).map(({excerptParts:s,...a})=>{const l=!!Sr(a.attrs.sourceId),c=s.join(""),u={...a,excerpt:s.length>0?c:l?"":void 0};return{...u,id:u9t(u)}}).sort((s,a)=>s.from!==a.from?s.from-a.from:s.id.localeCompare(a.id));return y9t(i),QTe.set(e,{doc:t,grouped:i}),i}function oxe(e,t){const{baseId:n}=JW(t);return FA(e).find(r=>r.id===n)??null}function ixe(e){const t=FA(e),n=m9t(t,d9t(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=Sr(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 JW(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 w9t(e){return typeof e=="string"?{kind:"entity",entityType:"trackedChange",entityId:e}:e}function wb(e,t){const n=w9t(t),r=n.entityId,o=n.story??{kind:"story",storyType:"body"};if((n.story?Si(n.story):"body")==="body"){const a=sxe(e,r);return a?{editor:e,story:o,runtimeRef:{storyKey:bh,rawId:a.rawId},change:a}:null}let i;try{i=il(e,o)}catch{return null}const s=sxe(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 sxe(e,t){const{baseId:n}=JW(t);return FA(e).find(r=>r.id===n||r.rawId===n||r.commandRawId===n)??null}const axe=["structuredContent","structuredContentBlock"],kC="structuredContentBlock",A9t="structuredContent";function CC(e){return axe.includes(e.type.name)}function Ab(e){const t=[];return e.descendants((n,r)=>(CC(n)&&t.push({node:n,pos:r,kind:n.type.name==="structuredContentBlock"?"block":"inline"}),!0)),t}function Tn(e,t){const n=t.nodeId,r=Ab(e).filter(o=>String(o.node.attrs.id)===n);if(r.length===0)throw new De("TARGET_NOT_FOUND",`Content control with id "${n}" not found.`,{target:t});if(r.length>1)throw new De("AMBIGUOUS_TARGET",`Multiple content controls found with id "${n}".`,{target:t,count:r.length});return r[0]}function ba(e,t){return e?.elements?.find(n=>n.name===t)}function lxe(e,t){return ba(e,t)?.attributes}function HM(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 cxe(e,t){return e.elements?{...e,elements:e.elements.filter(n=>n.name!==t)}:e}var I9t=new Set(axe);function Ib(e,t,n){if(!e?.state)return!1;let r=null;if(e.state.doc.descendants((i,s)=>r!==null?!1:I9t.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 gf(e,t,n,r){const o=Tn(e.state.doc,t).node.attrs.sdtPr??{name:"w:sdtPr",elements:[]},i=r(ba(o,n));let s;return i===null?s=cxe(o,n):s=HM(o,n,i),Ib(e,t.nodeId,{sdtPr:s})}function ZW(e,t,n,r,o,i){return gf(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 S9t(e,t,n,r){return gf(e,t,n,o=>({name:n,type:"element",...o,elements:r}))}var T9t=["text","richText","date","checkbox","comboBox","dropDownList","repeatingSection","repeatingSectionItem","group"],x9t=["unlocked","sdtLocked","contentLocked","sdtContentLocked"],k9t=["boundingBox","tags","hidden"];function Gp(e){const t=e.controlType??e.type;return typeof t=="string"&&T9t.includes(t)?t:"unknown"}function zM(e){const t=e.lockMode;return typeof t=="string"&&x9t.includes(t)?t:"unlocked"}function uxe(e){const t=e.appearance;if(typeof t=="string"&&k9t.includes(t))return t}function dxe(e){const t=e.sdtPr;if(!t)return;const n=lxe(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 Uo(e){return{kind:e.kind,nodeType:"sdt",nodeId:String(e.node.attrs.id??"")}}function QW(e){const t=(ba(e,"w14:checkbox")??ba(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 $W(e,t){const n=ba(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 C9t(e,t){if(!t)return{};switch(e){case"text":{const n=lxe(t,"w:text");if(!n)return{};const r=n["w:multiLine"];return{multiline:r==="1"||r==="true"||r===!0}}case"date":{const n=ba(t,"w:date");if(!n)return{};const r=ba(n,"w:dateFormat"),o=ba(n,"w:lid"),i=ba(n,"w:storeMappedDataAs"),s=ba(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=ba(t,"w14:checkbox")??ba(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:QW(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 $W(t,e);case"repeatingSection":{const n=ba(t,"w15:repeatingSection")??ba(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 Gg(e){const t=e.node.attrs,n=String(t.id??""),r=Gp(t),o=zM(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=C9t(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:uxe(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:dxe(t),raw:i,target:{kind:e.kind,nodeType:"sdt",nodeId:n},text:s}}function E9t(e,t){const n=e??{},r=String(n.id??"");return{nodeType:"sdt",kind:t,id:r,controlType:Gp(n),lockMode:zM(n),properties:{tag:typeof n.tag=="string"?n.tag:void 0,alias:typeof n.alias=="string"?n.alias:void 0,appearance:uxe(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 sl(e,t){const n=zM(e.node.attrs);if(n==="sdtLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function Ah(e,t){const n=zM(e.node.attrs);if(n==="contentLocked"||n==="sdtContentLocked")throw new De("LOCK_VIOLATION",`Content control "${e.node.attrs.id}" has lock mode "${n}" which prevents ${t}.`,{lockMode:n,operation:t})}function va(e,t,n){const r=Gp(e.node.attrs),o=Array.isArray(t)?t:[t];if(!o.includes(r))throw new De("TYPE_MISMATCH",`Operation "${n}" requires control type ${o.join(" or ")}, but found "${r}".`,{expected:o,actual:r,operation:n})}function fxe(e,t){const n={success:!0,contentControl:e};return t&&(n.updatedRef=t),n}function Ih(e,t){return{success:!1,failure:{code:e,message:t}}}function EC(e,t){const n=e.length,r=t?.offset??0,o=t?.limit??n;return{items:e.slice(r,r+o),total:n}}function _C(e,t){const n=Un(e).candidates.filter(r=>r.nodeId===t&&(r.nodeType==="paragraph"||r.nodeType==="listItem"));if(n.length===0)throw new De("TARGET_NOT_FOUND","Block target was not found.",{nodeId:t});if(n.length>1)throw new De("INVALID_TARGET","Block target id is ambiguous.",{nodeId:t,count:n.length});return n[0]}function hxe(e,t,n){const r=_C(e,t),o=_C(e,n);if(r.pos>o.pos)throw new De("INVALID_TARGET",'Block range "from" must precede "to" in document order.',{from:t,to:n});return Un(e).candidates.filter(i=>(i.nodeType==="paragraph"||i.nodeType==="listItem")&&i.pos>=r.pos&&i.pos<=o.pos)}function gd(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 BA(e){return Un(e).candidates.filter(t=>t.nodeType==="listItem").map(t=>UM(e,t))}function al(e,t){if(t.numId==null)return[t];const n=BA(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 pxe(e,t){const n=al(e,t),r=n.findIndex(o=>o.address.nodeId===t.address.nodeId);return n.slice(r)}function mxe(e,t){const n=al(e,t);return n.length>0&&n[0].address.nodeId===t.address.nodeId}function _9t(e,t){if(t.numId==null)return"";const n=al(e,t)[0]?.address.nodeId??t.address.nodeId;return`${t.numId}:${n}`}function gxe(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 HA(e,t,n){if(t.numId==null)return null;const r=BA(e),o=al(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:al(e,l),numId:l.numId,abstractNumId:gd(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:al(e,l),numId:l.numId,abstractNumId:gd(e,l.numId)}}}return null}function R9t(e,t){if(t.numId==null)return null;const n=gd(e,t.numId);if(n==null)return null;const r=BA(e),o=al(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&&gd(e,a.numId)===n&&a.numId!==t.numId)return{sequence:al(e,a),numId:a.numId}}return null}function yxe(e,t,n){const r=HA(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?gd(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 bxe(e,t){if(t.numId==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const n=gd(e,t.numId);if(n==null)return{canContinue:!1,reason:"NO_PREVIOUS_LIST"};const r=BA(e),o=al(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,gd(e,l.numId)!==n))continue;if(l.numId===t.numId)return{canContinue:!1,reason:"ALREADY_CONTINUOUS"};const c=al(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 P9t(e){const t=e.attrs??{},n=t.paragraphProperties?.numberingProperties??void 0,r=t.numberingProperties??void 0;return{numId:gM(n?.numId??r?.numId),level:gM(n?.ilvl??r?.ilvl)}}function L9t(e,t,n){if(!(t==null||n==null||!e.converter))try{const r=jn.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 N9t(e,t,n,r){const o=(t.node.attrs??{}).listRendering?.numberingType;return o==="bullet"?"bullet":typeof o=="string"&&o.length>0?"ordered":L9t(e,n,r)}function M9t(e){const t=e.node.textContent;return typeof t=="string"?t:void 0}function UM(e,t){const n=t.node.attrs??{},{numId:r,level:o}=P9t(t.node),i=PP(n.listRendering),s=i?.path,a=F4(s),l=i?.markerText;return{candidate:t,address:{kind:"block",nodeType:"listItem",nodeId:t.nodeId},numId:r,level:o,kind:N9t(e,t,r,o),marker:l,path:s,ordinal:a,text:M9t(t)}}function vxe(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 D9t(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 O9t(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 De("TARGET_NOT_FOUND","List scope block was not found.",{within:t});if(n.length>1)throw new De("INVALID_TARGET","List scope block id is ambiguous.",{within:t,count:n.length});return{start:n[0].pos,end:n[0].end}}function F9t(e,t){return t?e.pos>=t.start&&e.end<=t.end:!0}function B9t(e,t){if(t?.within&&t.within.kind!=="block")throw new De("INVALID_TARGET","lists.list only supports block within scopes.",{within:t.within});Bg(t?.offset,t?.limit);const n=Un(e),r=O9t(n,t?.within),o=n.candidates.filter(f=>f.nodeType==="listItem").map(f=>UM(e,f)),i=o.filter(f=>F9t(f.candidate,r)),s=t?.offset??0,a=s+(t?.limit??Number.POSITIVE_INFINITY),l=Zn(e),c=gxe(o);let u=0;const d=[];for(const f of i){if(!D9t(f,t))continue;const h=u;if(u+=1,h<s||h>=a)continue;const p=c.get(f.address.nodeId)??"",m=vxe(f,p),g=Ni(m.address.nodeId,"stable","list"),{address:y,marker:v,ordinal:b,path:I,level:w,kind:A,text:T}=m;d.push(rs(m.address.nodeId,g,{address:y,listId:p,marker:v,ordinal:b,path:I,level:w,kind:A,text:T}))}return qi({evaluatedRevision:l,total:u,items:d,page:{limit:t?.limit??u,offset:s,returned:d.length}})}function ts(e,t){const n=Un(e).candidates.filter(r=>r.nodeType==="listItem"&&r.nodeId===t.nodeId);if(n.length===0)throw new De("TARGET_NOT_FOUND","List item target was not found.",{target:t});if(n.length>1)throw new De("INVALID_TARGET","List item target id is ambiguous.",{target:t,count:n.length});return UM(e,n[0])}var H9t=new Set(["text","date","checkbox","comboBox","dropDownList"]),wxe=new WeakMap;function z9t(e){const t=e.state.doc,n=wxe.get(e),r=Txe(e);if(n&&n.doc===t)return Axe(n.counts,r);const o=U9t(e);return wxe.set(e,{doc:t,counts:o}),Axe(o,r)}function U9t(e){const t=YW(e,{}),n=Un(e),r=Fg(e),o=V9t(n),i=G9t(r);return{words:Ixe(t),characters:t.length,paragraphs:o.paragraphs,headings:o.headings,tables:o.tables,images:o.blockImages+i,comments:W9t(r),trackedChanges:j9t(e),sdtFields:q9t(e),lists:K9t(e,n)}}function Axe(e,t){return t!=null?{...e,pages:t}:{...e}}function Ixe(e){const t=e.trim().match(/\S+/g);return t?t.length:0}function V9t(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 G9t(e){return e.byType.get("image")?.length??0}function W9t(e){const t=e.byType.get("comment")??[],n=new Set;for(const r of t){const o=yM(r.attrs??{});o&&n.add(o)}return n.size}function j9t(e){return FA(e).length}function q9t(e){return Ab(e.state.doc).filter(t=>H9t.has(Gp(t.node.attrs??{}))).length}function K9t(e,t){const n=Y9t(e,t);if(n.length===0)return 0;const r=gxe(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||X9t(s,a))&&(o+=1),s=a}return o}function Y9t(e,t){return t.candidates.filter(n=>n.nodeType==="listItem").map(n=>UM(e,n))}function X9t(e,t){return J9t(e,t)?!0:Z9t(e,t)}function J9t(e,t){return e.kind!=null&&t.kind!=null&&e.kind!==t.kind}function Z9t(e,t){const n=Sxe(e),r=Sxe(t);return n==null||r==null||n!==r||e.ordinal==null||t.ordinal==null?!1:t.ordinal<=e.ordinal}function Sxe(e){return e.level!=null?e.level:e.path&&e.path.length>0?e.path.length-1:void 0}function Txe(e){return e.currentTotalPages}function zA(e){const t=YW(e,{});return{words:Ixe(t),characters:Q9t(t),charactersWithSpaces:$9t(t),pages:Txe(e)}}function VM(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 Sb(e){return e.options?.parentEditor??e}function Q9t(e){return e.replace(/\s/g,"").length}function $9t(e){return e.replace(/\n/g,"").length}function xxe(e){const t=new Map,n=zA(Sb(e));for(const r of["NUMWORDS","NUMCHARS","NUMPAGES"]){const o=VM(r,n);o!=null&&t.set(r,o)}return t}const ej="http://schemas.openxmlformats.org/officeDocument/2006/bibliography",e4t="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",t4t="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";var kxe="/APA.XSL",Cxe="APA",Exe="6",_xe=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"}),n4t=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"}),tj=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"}),r4t=Object.freeze(Object.fromEntries(Object.entries(tj).map(([e,t])=>[t,e])));function Wg(e){if(!e||typeof e!="string")return"";const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function GM(e){if(!e?.elements?.length)return"";const t=e.elements.find(n=>n?.type==="text");return typeof t?.text=="string"?t.text.trim():""}function UA(e,t){return{type:"element",name:e,elements:[{type:"text",text:String(t)}]}}function WM(e,t){const n=t??nW;return{declaration:{...n,attributes:{...n.attributes}},elements:[e]}}function Rxe(e,t){if(e?.elements?.length){for(const n of e.elements)if(!(!n||n.type!=="element")){if(Wg(n.name)==="Person"){t.push(n);continue}Rxe(n,t)}}}function o4t(e){const t={};for(const n of e?.elements??[]){if(!n||n.type!=="element")continue;const r=Wg(n.name),o=GM(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 nj(e,t){const n=(e?.elements??[]).find(o=>o?.type==="element"&&Wg(o.name)===t);if(!n)return[];const r=[];return Rxe(n,r),r.map(o4t).filter(Boolean)}function i4t(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(UA("b:Last",n)),r&&t.push(UA("b:First",r)),o&&t.push(UA("b:Middle",o)),{type:"element",name:"b:Person",elements:t}}function s4t(e){const t=(e??[]).map(i4t).filter(Boolean);return t.length===0?null:{type:"element",name:"b:NameList",elements:t}}function rj(e,t){const n=s4t(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 a4t(e){return _xe[typeof e=="string"?e.trim():""]??_xe.misc}function l4t(e){return n4t[typeof e=="string"?e.trim().toLowerCase():""]??"misc"}function oj(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(tj)){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 c4t(e){const t={};let n="",r="misc";for(const a of e?.elements??[]){if(!a||a.type!=="element")continue;const l=Wg(a.name);if(l==="Tag"){n=GM(a);continue}if(l==="SourceType"){r=l4t(GM(a));continue}const c=r4t[l];if(!c)continue;const u=GM(a);u&&(t[c]=u)}const o=nj(e,"Author");o.length>0&&(t.authors=o);const i=nj(e,"Editor");i.length>0&&(t.editor=i);const s=nj(e,"Translator");return s.length>0&&(t.translator=s),oj({tag:n,type:r,fields:t})}function u4t(e){const t=oj(e);if(!t)return null;const n=[UA("b:Tag",t.tag),UA("b:SourceType",a4t(t.type))];for(const[s,a]of Object.entries(tj)){const l=t.fields?.[s];typeof l!="string"||l.length===0||n.push(UA(`b:${a}`,l))}const r=rj("Author",t.fields?.authors);r&&n.push(r);const o=rj("Editor",t.fields?.editor);o&&n.push(o);const i=rj("Translator",t.fields?.translator);return i&&n.push(i),{type:"element",name:"b:Source",elements:n}}function d4t(e){if(!e||e.type!=="element"||Wg(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 Pxe(e){const t=/customXml\/item(\d+)\.xml$/i.exec(e||"");return t?Number.parseInt(t[1],10):null}function f4t(e){return e.startsWith("customXml/")?`../${e}`:e}function h4t(e){const t=e?.["word/_rels/document.xml.rels"];return t?.elements?.length&&t.elements.find(n=>Wg(n.name)==="Relationships")||null}function p4t(e){e["word/_rels/document.xml.rels"]||(e["word/_rels/document.xml.rels"]=WM({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=>Wg(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 m4t(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 g4t(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 y4t(e,t){const n=e.map(u4t).filter(Boolean),r=t.selectedStyle||kxe,o=t.styleName||Cxe,i=t.version||Exe;return{type:"element",name:"b:Sources",attributes:{"xmlns:b":ej,xmlns:ej,SelectedStyle:r,StyleName:o,Version:i},elements:n}}function b4t(e){const t=e?.elements?.[0]?.attributes?.["ds:itemID"];return typeof t=="string"&&t.length>0?t:null}function v4t(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":ej}}]}]}}function w4t(e){return{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[{type:"element",name:"Relationship",attributes:{Id:"rId1",Type:t4t,Target:e}}]}}function Lxe(e){const t=new Map;for(const n of e){const r=oj(n);r&&t.set(r.tag,r)}return Array.from(t.values())}function ij(){return{sources:[],partPath:null,itemPropsPath:null,itemRelsPath:null,selectedStyle:null,styleName:null,version:null}}function Nxe(e){const t=ij(),n=h4t(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=Ap(i,"word");if(!s)continue;const a=e?.[s]?.elements?.[0];if(d4t(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=Pxe(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"||Wg(l.name)!=="Source")continue;const c=c4t(l);c&&r.push(c)}}}return t.sources=Lxe(r),t}function A4t(e,t){const n=Nxe(e),r=Lxe(Array.isArray(t?.sources)?t.sources:[]);if(r.length===0&&!n.partPath)return{...ij(),sources:[]};const o=t?.partPath||n.partPath,i=Pxe(o),s=i??g4t(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??kxe,d=t?.styleName??n.styleName??Cxe,f=t?.version??n.version??Exe,h=e[a]?.declaration;e[a]=WM(y4t(r,{selectedStyle:u,styleName:d,version:f}),h);const p=p4t(e),m=f4t(a);p.elements.some(b=>b?.attributes?.Type!=="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"?!1:Ap(b?.attributes?.Target,"word")===a)||p.elements.push({type:"element",name:"Relationship",attributes:{Id:m4t(p),Type:e4t,Target:m}});const g=e[l],y=g?.declaration;e[l]=WM(v4t(b4t(g)||`{${dn().toUpperCase()}}`),y);const v=e[c]?.declaration;return e[c]=WM(w4t(`itemProps${s}.xml`),v),{sources:r,partPath:a,itemPropsPath:l,itemRelsPath:c,selectedStyle:u,styleName:d,version:f}}function I4t(e){return[e?.partPath,e?.itemPropsPath,e?.itemRelsPath].filter(t=>typeof t=="string"&&t.length>0)}var S4t=au($m(),1),T4t=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"}),Mxe="sans-serif",x4t=10,k4t="1.37.0-next.3",C4t="SuperdocDocumentOrigin",E4t=new Set(["word","google-docs","unknown","superdoc"]),Dxe=(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"])},ku=class _i{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=_i.getFontTableEntry(t,n)?.elements?.find(o=>o.name==="w:family")?.attributes?.["w:val"];return r?T4t[r.toLowerCase()]||Mxe:null}static toCssFontFamily(t,n){if(!t||t.includes(","))return t;const r=_i.getFallbackFromFontTable(n,t)||Mxe;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=ij(),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 dOt}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]=JIe(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"]=JIe(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(S4t.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 _i,i=r.content,s=o.parseXmlToJson(i)?.elements?.find(l=>_i._matchesElementName(l.name,"Properties"));if(!s?.elements)return null;const a=s.elements.find(l=>_i._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]=_4t());const s=t[i].elements?.find(d=>_i._matchesElementName(d.name,"Properties"));if(!s)return null;s.elements||(s.elements=[]);const a=_i._extractNamespacePrefix(s.name),l=a?`${a}:property`:"property";let c=s.elements.find(d=>_i._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)_i._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 _i.getStoredCustomProperty(t,"SuperdocVersion")}static setStoredSuperdocVersion(t=this.convertedXml,n=k4t){return _i.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"||_i._matchesElementName(r.name,"coreProperties"));return n?.elements&&n.elements.find(r=>r.name==="dcterms:created"||_i._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"||_i._matchesElementName(i.name,"coreProperties"));if(!r)return;r.elements||(r.elements=[]);let o=r.elements.find(i=>i.name==="dcterms:created"||_i._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 _i().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 _i.getStoredCustomProperty(t,"DocumentGuid")}getDocumentGuid(){return this.documentGuid}getSuperdocVersion(){return this.docx?_i.getStoredSuperdocVersion(this.docx):null}resolveDocumentGuid(){const t=this.getMicrosoftDocId();if(t)this.documentGuid=t;else{const n=_i.getStoredCustomProperty(this.docx,"DocumentGuid");n&&(this.documentGuid=n)}this.isBlankDoc&&this.setDocumentCreatedTimestamp(_i.generateWordTimestamp())}getMicrosoftDocId(){return this.getDocumentInternalId(),this.documentInternalId?this.documentInternalId.replace(/[{}]/g,""):null}#e(){const t=`${this.documentGuid}|${this.getDocumentCreatedTimestamp()}`;return`HASH-${Lle(new TextEncoder().encode(t)).toUpperCase()}`}async#t(){if(!this.fileSource)return`HASH-${dn().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-${dn().replace(/-/g,"").substring(0,8).toUpperCase()}`;return`HASH-${Lle(t).toUpperCase()}`}catch(t){return console.warn("[super-converter] Could not generate content hash:",t),`HASH-${dn().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=dn()),n||this.setDocumentCreatedTimestamp(_i.generateWordTimestamp()),this.documentModified=!0,this.documentUniqueIdentifier=await this.#t()),this.documentUniqueIdentifier}promoteToGuid(){return this.documentGuid?this.documentGuid:(this.documentGuid=this.getMicrosoftDocId()||dn(),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");Dxe(i?.elements?.find(l=>l.name==="w:rPr")??i,{allowOverrideTypeface:!0,allowOverrideSize:!0,themeResolver:l=>this.getThemeInfo(l),state:o}),Dxe(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=x4t);const s=o.typeface?_i.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(y=>y.attributes.Id===s.attributes["r:id"])?.attributes?.Target;if(!a)return;const l=this.fonts[`word/${a}`]?.buffer;if(!l)return;const c=gtt(l,s.attributes["w:fontKey"]);if(!c)return;const u=new Blob([c],{type:"font/ttf"}),d=URL.createObjectURL(u),f=s.name.includes("Regular"),h=s.name.includes("Bold"),p=s.name.includes("Italic"),m=s.name.includes("Light"),g=f?"normal":h?"bold":m?"200":"normal";o.includes(s.fontFamily)||o.push(s.fontFamily),i+=`
84
84
  @font-face {
85
85
  font-style: ${p?"italic":"normal"};
86
86
  font-weight: ${g};
@@ -399,7 +399,7 @@ function print() { __p += __j.call(arguments, '') }
399
399
  `;$t(),qn();var Yan={class:"search-input-ctn"},Xan={class:"row"},Jan=["onKeydown"],Zan={__name:"SearchInput",props:{searchRef:{type:Object}},emits:["submit"],setup(e,{emit:t}){const n=Le(""),r=t,o=()=>{r("submit",{value:n.value})};return(i,s)=>(Ge(),$e("div",Yan,[ft("div",Xan,[Gd(ft("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:Yf(sr(o,["stop","prevent"]),["enter"])},null,40,Jan),[[fp,n.value]])]),ft("div",{class:"row submit"},[ft("button",{class:"submit-btn",onClick:o},"Apply")])]))}},Qan=Gn(Zan,[["__scopeId","data-v-bfe34b7b"]]);const $an=[{label:"Georgia",key:"Georgia, serif",fontWeight:400,props:{style:{fontFamily:"Georgia, serif"},"data-item":"btn-fontFamily-option"}},{label:"Arial",key:"Arial, sans-serif",fontWeight:400,props:{style:{fontFamily:"Arial, sans-serif"},"data-item":"btn-fontFamily-option"}},{label:"Courier New",key:"Courier New, monospace",fontWeight:400,props:{style:{fontFamily:"Courier New, monospace"},"data-item":"btn-fontFamily-option"}},{label:"Times New Roman",key:"Times New Roman, serif",fontWeight:400,props:{style:{fontFamily:"Times New Roman, serif"},"data-item":"btn-fontFamily-option"}}],eln=[{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"}}],IE={sm:768,md:1024,lg:1280,xl:1410},H3={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"},zLe={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"},ULe=Object.values(zLe),tln=[...new Set([...Object.values(H3),...ULe])];var nln=new Set(["link"]);const VLe=new Set(Object.keys(H3).filter(e=>!nln.has(e)));$t();var Nh=e=>{e.expand.value=!1};const rln=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=xo({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),c=(r??$an).map(Win),u=xo({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:Q})=>{if(!Q)return;Q=Q.split(",")[0],u.label.value=Q;const Oe=c.find(be=>be.label===u.defaultLabel.value),K=c.find(be=>be.label===Q);K?u.selectedValue.value=K.key:Oe?u.selectedValue.value=Oe.key:u.selectedValue.value=""},onDeactivate:()=>{u.label.value=u.defaultLabel.value;const Q=c.find(Oe=>Oe.label===u.defaultLabel.value);Q?u.selectedValue.value=Q.key:u.selectedValue.value=""}}),d=xo({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 Q="";if(e.activeEditor){const{state:K}=e.activeEditor,{from:be,to:Ue,empty:le}=K.selection;Q=le?"":K.doc.textBetween(be,Ue)}return Qs("div",{},[Qs(D3,{handleClose:()=>{Nh(d)},selectedText:Q,editor:e.activeEditor,apiKey:e.config.aiApiKey,endpoint:e.config.aiEndpoint,superToolbar:e})])}}]}),f=eln,h=xo({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:Q},Oe=!1)=>{if(Oe){h.label.value="",h.selectedValue.value="";return}const K=f.find(et=>et.label===String(h.defaultLabel.value));if(!Q){h.label.value=h.defaultLabel.value,K?h.selectedValue.value=K.key:h.selectedValue.value="";return}let be=Vin(Q,12);be<8&&(be=8),be>96&&(be=96);let Ue=String(be);const le=f.find(et=>et.label===Ue||et.key===Ue);le?h.selectedValue.value=le.key:h.selectedValue.value="",h.label.value=Ue},onDeactivate:()=>{h.label.value=h.defaultLabel.value;const Q=f.find(Oe=>Oe.label===String(h.defaultLabel.value));Q?h.selectedValue.value=Q.key:h.selectedValue.value=""}}),p=xo({type:"separator",name:"separator",isNarrow:!0}),m=xo({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),g=xo({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),y=xo({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),v=xo({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:()=>KK(e,v,[],!0)}],onActivate:({color:Q})=>{v.iconColor.value=Q||""},onDeactivate:()=>v.iconColor.value=""}),b=xo({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:()=>KK(e,b)}],onActivate:({color:Q})=>{b.iconColor.value=Q},onDeactivate:()=>b.iconColor.value="#000"}),I=Le(null),w=xo({type:"dropdown",name:"search",active:!1,icon:t.search,tooltip:n.search,group:"right",inputRef:I,attributes:{ariaLabel:"Search"},options:[{type:"render",key:"searchDropdown",render:()=>A()}]}),A=()=>Qs("div",{},[Qs(Qan,{onSubmit:({value:Oe})=>{e.activeEditor.commands.search(Oe,{searchModel:"visible"})},searchRef:I})]),T=xo({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:Q})=>{Q?T.attributes.value={href:Q}:T.attributes.value={}},onDeactivate:()=>{T.attributes.value={},T.expand.value=!1}});function x(Q){return Qs("div",{},[Qs(AE,{editor:e.activeEditor,closePopover:()=>Nh(Q),goToAnchor:()=>{if(Nh(Q),!e.activeEditor||!Q.attributes.value?.href)return;const Oe=Q.attributes.value?.href?.slice(1),K=e.activeEditor.element.querySelector(`a[name='${Oe}']`);K&&qan(K)}})])}const _=xo({type:"options",name:"linkInput",command:"toggleLink",active:!1});T.childItem=_,_.parentItem=T;const E=xo({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),P=xo({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),k=xo({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(k)}]});function L(Q){return Qs("div",{},[Qs(BLe,{onSelect:K=>{e.emitCommand({item:Q,argument:K}),Nh(Q)}})])}const R=xo({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>F(R)}]}),O=[{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 F(Q){return Qs(HLe,{options:O,onSelect:Oe=>{Nh(Q);const{command:K}=Oe;e.emitCommand({item:Q,argument:{command:K}})}})}const H=xo({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:()=>Qs("div",{},[Qs(Ksn,{onSelect:Oe=>{Nh(H);const K={...H,command:"setTextAlign"};K.command="setTextAlign",e.emitCommand({item:K,argument:Oe}),U(H,Oe)}})]),key:"alignment"}],onActivate:({textAlign:Q})=>{U(H,Q)},onDeactivate:()=>{U(H,"left")}}),U=(Q,Oe)=>{let K=Oe==="both"?"justify":Oe,be={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Ue=be[K]??be.left;Q.icon.value=Ue},M=xo({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 Q=Oe=>{Nh(M);const K={...M,command:"toggleBulletListStyle"};e.emitCommand({item:K,argument:Oe})};return Qs(DLe,{buttons:Jsn,iconSize:25,selectedStyle:M.selectedValue.value,onSelect:Q})}}]}),z=xo({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 Q=Oe=>{Nh(z);const K={...z,command:"toggleOrderedListStyle"};e.emitCommand({item:K,argument:Oe})};return Qs(DLe,{buttons:Zsn,iconSize:30,selectedStyle:z.selectedValue.value,onSelect:Q})}}]}),Z=xo({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),$=xo({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),G=xo({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),ye=xo({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:Q})=>{Q&&(ye.label.value=Q)}}),X=xo({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Y=xo({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),ne=xo({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),me=xo({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),Se=xo({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),he=xo({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),_e=(Q,Oe)=>Q==="editor"?Oe:Q==="suggester"?Oe.filter(K=>K.value==="suggesting"):Oe.filter(K=>K.value==="viewing"),q=Q=>Q==="editor"?"Editing":Q==="suggester"?"Suggesting":"Viewing",D=xo({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:q(s),label:q(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>j(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 j(Q){return Qs(ian,{options:_e(s,N),onSelect:Oe=>{Nh(Q);const{label:K,icon:be}=Oe;D.label.value=K,D.icon.value=be,e.emitCommand({item:D,argument:K})}})}const ie=new Map([["separator",20],["zoom",71],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["ai",32],["default",32]]),J=xo({type:"button",name:"ruler",command:"toggleRuler",icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),re=xo({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),ee=Le(null),ae=xo({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Q=Oe=>{Nh(ae);const K={...ae,command:"setLinkedStyle"};e.emitCommand({item:K,argument:Oe}),ee.value=Oe.id};return Qs("div",{},[Qs(can,{editor:e.activeEditor,onSelect:Q,selectedOption:ee.value})])}}],onActivate:({styleId:Q})=>{const Oe=Hq(e.activeEditor)?.find(K=>K.id===Q);ae.label.value=Oe&&Oe.id!=="Normal"?Oe.definition.attrs.name:n.formatText,ae.disabled.value=!1},onDeactivate:()=>{ae.disabled.value=!0,ae.label.value=n.formatText}}),fe=(Q,Oe)=>{if(Oe.value==Q)return Qs("div",{innerHTML:Kan,class:"dropdown-select-icon"})},de=xo({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(Q=>({label:Q.toFixed(2),key:Q,icon:()=>fe(Q,de.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),oe=20,ce=120,xe=32,ve=["linkedStyles","clearFormatting","copyFormat","ruler","formattingMarks","tableOfContents"],ue=["zoom","fontFamily","fontSize","redo"],Ae=i<=IE.lg,Ce=e.config?.showFormattingMarksButton===!0;Ae&&(D.attributes.value={...D.attributes.value,className:`${D.attributes.value.className} toolbar-item--doc-mode-compact`}),Ae&&(ae.attributes.value={...ae.attributes.value,className:`${ae.attributes.value.className} toolbar-item--linked-styles-compact`});let We=[X,Y,ne,me,ye,u,p,h,p,l,m,g,y,b,v,p,T,E,P,k,R,p,H,M,z,Z,$,de,p,ae,p,J,...Ce?[re]:[],he,Se,d,G,D];if(e.config?.superdoc?.config?.modules?.ai||(We=We.filter(Q=>Q.name.value!=="ai")),i<=IE.md&&o&&(We=We.filter(Q=>Q.type!=="separator")),e.config.mode!=="docx"){const Q=We.findIndex(K=>K.name.value==="linkedStyles");We.splice(Q-1,2);const Oe=["ruler","zoom","undo","redo"];We=We.filter(K=>!Oe.includes(K.name.value))}const ot=[];a||(s==="viewer"&&ot.push(ne,me),We=We.filter(Q=>!ot.includes(Q)));const pe=[w,X,G,D].map(Q=>Q.name),Te=Q=>pe.includes(Q.name),Pe=[],we=[];let Ne=xe+ce;return We.forEach(Q=>{const Oe=ie.get(Q.name.value)||ie.get("default");if(i<IE.xl+oe&&ve.includes(Q.name.value)&&o){if(Pe.push(Q),Q.name.value==="linkedStyles"){const K=We.findIndex(be=>be.name.value==="linkedStyles");We.splice(K+1,1)}return}if(i<IE.sm&&ue.includes(Q.name.value)&&o){Pe.push(Q);return}if(Te(Q)){we.push(Q),Ne+=Oe;return}Ne<i||!o?(we.push(Q),Ne+=Oe):Pe.push(Q)}),{defaultItems:we,overflowItems:Pe.filter(Q=>Q.type!=="separator")}};$t(),qn();var oln={class:"toolbar-icon"},iln=["innerHTML"],sln={__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(),$e("div",oln,[ft("div",{class:Mr(["toolbar-icon__icon",[`toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,iln),r.value?(Ge(),$e("div",{key:0,class:"color-bar",style:On(n.value)},null,4)):Bt("",!0)]))}},GLe=Gn(sln,[["__scopeId","data-v-8c30c125"]]);$t(),qn();var aln=["role","aria-label"],lln=["data-item"],cln=["data-item"],uln={key:1,class:"button-label"},dln=["data-item","aria-label"],fln=["innerHTML"],hln={key:1,class:"button-label"},pln={key:2},mln=["onKeydown","id"],gln=["placeholder","onKeydown","id"],yln=["innerHTML"],bln={"aria-live":"polite",class:"visually-hidden"},vln={__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"],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:v}=r.toolbarItem,b=ut(()=>!!d?.value&&!!u?.value),I=Le(a),w=Le(null),{isHighContrastMode:A}=tm(),T=()=>{m&&rr(()=>{w.value?.focus(),w.value?.select()}),n("buttonClick")},x=O=>{f?.value||(O?.stopPropagation(),n("mainClick"))},_=()=>{b.value||T()},E=O=>{if(b.value){x(O);return}T()},P=O=>{r.allowEnterPropagation||O.stopPropagation(),E(O)},k=()=>{const O=I.value,F=O.match(/^\d+(\.5)?$/)?O:Math.floor(parseFloat(O)).toString();n("textSubmit",F),I.value=F},L=ut(()=>y.value?y.value:{minWidth:r.minWidth}),R=ut(()=>h?.value?ls.dropdownCaretUp:ls.dropdownCaretDown);return(O,F)=>(Ge(),$e("div",{class:Mr(["toolbar-item",_t(v).className]),style:On(L.value),role:e.isOverflowItem?"menuitem":"button","aria-label":_t(v).ariaLabel,onClick:_,onKeydown:F[3]||(F[3]=Yf(H=>P(H),["enter"])),tabindex:"0"},[ft("div",{class:Mr(["toolbar-button",{active:_t(i),disabled:_t(f),narrow:e.isNarrow,wide:e.isWide,split:b.value,"has-inline-text-input":_t(m),"high-contrast":_t(A)}]),"data-item":`btn-${_t(o)||""}`},[b.value?(Ge(),$e("div",{key:0,class:"toolbar-button__main","data-item":`btn-${_t(o)||""}-main`,onClick:F[0]||(F[0]=H=>x(H))},[_t(s)?(Ge(),Cr(GLe,{key:0,color:_t(c),class:"toolbar-icon",icon:_t(s),name:_t(o)},null,8,["color","icon","name"])):Bt("",!0),_t(a)&&!_t(l)&&!_t(p)?(Ge(),$e("div",uln,Qn(_t(a)),1)):Bt("",!0)],8,cln)):Bt("",!0),b.value?(Ge(),$e("div",{key:1,class:"toolbar-button__caret","data-item":`btn-${_t(o)||""}-caret`,"aria-label":`${_t(v).ariaLabel} options`,role:"button"},[ft("div",{class:"dropdown-caret",innerHTML:R.value,style:On({opacity:_t(f)?.6:1})},null,12,fln)],8,dln)):(Ge(),$e(Pn,{key:2},[_t(s)?(Ge(),Cr(GLe,{key:0,color:_t(c),class:"toolbar-icon",icon:_t(s),name:_t(o)},null,8,["color","icon","name"])):Bt("",!0),_t(a)&&!_t(l)&&!_t(p)?(Ge(),$e("div",hln,Qn(_t(a)),1)):Bt("",!0),_t(p)?(Ge(),$e("span",pln,[_t(o)==="fontSize"?Gd((Ge(),$e("input",{key:0,"onUpdate:modelValue":F[1]||(F[1]=H=>I.value=H),onKeydown:Yf(sr(k,["prevent"]),["enter"]),type:"text",class:Mr(["button-text-input button-text-input--font-size",{"high-contrast":_t(A)}]),id:"inlineTextInput-"+_t(o),autocomplete:"off",ref_key:"inlineInput",ref:w},null,42,mln)),[[fp,I.value]]):Gd((Ge(),$e("input",{key:1,"onUpdate:modelValue":F[2]||(F[2]=H=>I.value=H),placeholder:_t(a),onKeydown:Yf(sr(k,["prevent"]),["enter"]),type:"text",class:"button-text-input",id:"inlineTextInput-"+_t(o),autocomplete:"off",ref_key:"inlineInput",ref:w},null,40,gln)),[[fp,I.value]])])):Bt("",!0),_t(u)?(Ge(),$e("div",{key:3,class:"dropdown-caret",innerHTML:R.value,style:On({opacity:_t(f)?.6:1})},null,12,yln)):Bt("",!0)],64)),ft("div",bln,Qn(`${_t(v).ariaLabel} ${_t(i)?"selected":"unset"}`),1)],10,lln)],46,aln))}},XK=Gn(vln,[["__scopeId","data-v-dcf6ef0b"]]);$t(),qn();var wln={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},Aln={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=tm(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(Ge(),$e("div",wln,[ft("div",{class:"separator-inner",style:On({backgroundColor:r()})},null,4)]))}},Iln=Gn(Aln,[["__scopeId","data-v-d027f7fc"]]);$t(),qn();var Sln={class:"overflow-menu"},Tln={class:"overflow-menu-trigger"},xln={key:0,class:"overflow-menu_items",role:"group"},kln={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=Rc(),r=t,o=e,i=ut(()=>o.toolbarItem.expand.value),s=Le(!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 Ro(()=>{document.addEventListener("keydown",u,!0)}),wi(()=>{document.removeEventListener("keydown",u,!0)}),(d,f)=>(Ge(),$e("div",Sln,[ft("div",Tln,[Er(XK,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(Ge(),$e("div",xln,[Er(U3,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:c,onDropdownUpdateShow:f[0]||(f[0]=h=>s.value=h)},null,8,["toolbar-items"])])):Bt("",!0)]))}},Cln=Gn(kln,[["__scopeId","data-v-35b48dff"]]);$t(),qn();var Eln={class:"toolbar-dropdown"},_ln=["onClick"],Rln={key:0,class:"toolbar-dropdown-option__icon"},Pln={class:"toolbar-dropdown-option__label"},z3='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',Lln={__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=Le(null),i=Le(null),s=Le({top:"0px",left:"0px"}),a=Le([]),l=Le(-1),c=ut(()=>!!n.show),u=ut(()=>n.options.some(X=>X?.type==="render")),d=ut(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),f=ut(()=>{const{class:X,style:Y,...ne}=d.value;return ne}),h=ut(()=>{const X=d.value.class,Y=n.options.length>0&&n.options.every(ne=>ne&&ne.type==="render");return["toolbar-dropdown-menu",X,{"toolbar-dropdown-menu--render-only":Y}]}),p=ut(()=>{const X=d.value.style||{};return{...n.contentStyle,...X}}),m=ut(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,zIndex:2e3})),g=X=>{r("update:show",X)},y=()=>{c.value&&g(!1)},v=()=>{if(!o.value)return;const X=o.value.getBoundingClientRect(),Y=i.value?.offsetWidth??0,ne=window.innerWidth||document.documentElement.clientWidth||0,me=8;let Se=X.left;n.placement==="bottom-end"&&(Se=X.right-Y);const he=Math.max(me,ne-Y-me);Se=Math.min(Math.max(me,Se),he),s.value={top:`${X.bottom+4}px`,left:`${Se}px`}},b=()=>{n.disabled||g(!c.value)},I=X=>typeof n.nodeProps!="function"?{}:n.nodeProps(X)||{},w=X=>{X?.disabled||X?.type!=="render"&&(r("select",X?.key,X),y())},A=X=>X?.type==="render",T=X=>!X?.disabled&&X?.type!=="render",x=X=>typeof X?.icon=="function"||!!X?.icon,_=X=>typeof X?.icon=="function"?X.icon(X):X?.icon||null,E=X=>X?typeof X=="string"?X.split(/\s+/).includes("selected"):Array.isArray(X)?X.some(E):typeof X=="object"?!!X.selected:!1:!1,P=X=>E(X?.props?.class)||E(X?.class),k=()=>n.options.map((X,Y)=>T(X)?Y:-1).filter(X=>X>=0),L=()=>{const X=n.options.findIndex(Y=>T(Y)&&P(Y));return X>=0?X:k()[0]??-1},R=(X,Y)=>{if(!X){delete a.value[Y];return}a.value[Y]=X},O=()=>{a.value.forEach((Y,ne)=>{Y&&Y.setAttribute("tabindex",ne===l.value?"0":"-1")});const X=a.value[l.value];X&&typeof X.focus=="function"&&X.focus()},F=X=>{const Y=k();if(!Y.length){l.value=-1;return}const ne=Y.indexOf(l.value);if(ne<0){l.value=X>0?Y[0]:Y[Y.length-1];return}l.value=Y[(ne+X+Y.length)%Y.length]},H=()=>{let X=n.options[l.value];if(!T(X)){const Y=k()[0];X=Y===void 0?null:n.options[Y]}X&&w(X)},U=GT({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(X){return()=>typeof X.option.render!="function"?null:X.option.render()}}),M=GT({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(X){return()=>_(X.option)}}),z=X=>{if(!c.value)return;const Y=X.target;if(!(Y instanceof Element))return;const ne=o.value?.contains(Y),me=i.value?.contains(Y);ne||me||y()},Z=Le(null),$=()=>{const X=o.value,Y=document.activeElement;if(X&&Y instanceof HTMLElement&&X.contains(Y)){Z.value=Y;return}Z.value=X?.matches?.(z3)?X:X?.querySelector(z3)},G=()=>{const X=Z.value;if(X instanceof HTMLElement&&document.contains(X)){X.focus();return}const Y=o.value;if(!Y)return;const ne=Y.matches?.(z3)?Y:Y.querySelector(z3);if(ne instanceof HTMLElement){ne.focus();return}Y.setAttribute("tabindex","-1"),Y.focus()},ye=X=>{if(!c.value)return;const{key:Y}=X;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(Y)){if(Y==="Escape"){X.preventDefault(),y(),rr(()=>{requestAnimationFrame(G)});return}if(!u.value){if(X.preventDefault(),Y==="ArrowDown"){F(1),O();return}if(Y==="ArrowUp"){F(-1),O();return}Y==="Enter"&&H()}}};return Bn(c,async X=>{if(!X){l.value=-1,a.value=[];return}$(),await rr(),v(),!u.value&&(l.value=L(),O())},{immediate:!0}),Bn(c,X=>{X?(document.addEventListener("pointerdown",z,!0),document.addEventListener("keydown",ye,!0),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)):(document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",ye,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0))},{immediate:!0}),wi(()=>{document.removeEventListener("pointerdown",z,!0),document.removeEventListener("keydown",ye,!0),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),(X,Y)=>(Ge(),$e("div",Eln,[ft("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger",onClick:b},[jT(X.$slots,"trigger",{},void 0,!0)],512),(Ge(),Cr(Qv,{to:"body"},[Er(g9,{name:"fade-in-scale-up-transition"},{default:Vd(()=>[c.value?(Ge(),$e("div",Um({key:0,ref_key:"menuRef",ref:i,class:h.value,style:m.value},f.value),[(Ge(!0),$e(Pn,null,_o(e.options,(ne,me)=>(Ge(),$e("div",Um({key:ne.key,ref_for:!0,ref:Se=>R(Se,me),class:["toolbar-dropdown-option",[ne.class,ne.props?.class,{disabled:ne.disabled,render:A(ne)}]],tabindex:"-1",onClick:Se=>w(ne)},{ref_for:!0},{...ne.props,...I(ne)}),[A(ne)?(Ge(),Cr(_t(U),{key:0,option:ne},null,8,["option"])):(Ge(),$e(Pn,{key:1},[x(ne)?(Ge(),$e("span",Rln,[Er(_t(M),{option:ne},null,8,["option"])])):Bt("",!0),ft("span",Pln,Qn(ne.label),1)],64))],16,_ln))),128))],16)):Bt("",!0)]),_:1})]))]))}},Nln=Gn(Lln,[["__scopeId","data-v-261e2a66"]]);$t(),qn();var Mln=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=JYe(),r=Le(!1),o=Le(null),i=Le(null),s=Le({top:"0px",left:"0px"});let a=null,l=null;const c=ut(()=>["sd-tooltip-content",n.class]),u=ut(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),d=()=>{a&&(window.clearTimeout(a),a=null)},f=()=>{l&&(window.clearTimeout(l),l=null)},h=()=>{if(!o.value||!i.value)return;const T=o.value.getBoundingClientRect(),x=i.value.offsetWidth,_=i.value.offsetHeight,E=window.innerWidth||document.documentElement.clientWidth||0,P=8;let k=T.left+T.width/2-x/2;k=Math.max(P,Math.min(k,E-x-P)),s.value={top:`${T.top-_-10}px`,left:`${k}px`}},p=async()=>{t.disabled||(d(),f(),!r.value&&(r.value=!0,await rr(),h()))},m=()=>{f(),d(),r.value&&(r.value=!1)},g=()=>{if(d(),f(),!r.value){if(t.delay===0){p();return}l=window.setTimeout(()=>{l=null,p()},t.delay)}},y=()=>{if(f(),d(),!!r.value){if(t.duration===0){m();return}a=window.setTimeout(()=>{a=null,m()},t.duration)}},v=()=>{t.trigger==="hover"&&g()},b=()=>{t.trigger==="hover"&&y()},I=()=>{f(),d()},w=()=>{y()},A=T=>{T.key==="Escape"&&m()};return Bn(()=>t.disabled,T=>{T&&m()}),Bn(r,T=>{T?(window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),document.addEventListener("keydown",A,!0)):(window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",A,!0))}),wi(()=>{f(),d(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",A,!0)}),(T,x)=>(Ge(),$e(Pn,null,[ft("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:v,onMouseleave:b,onFocusin:v,onFocusout:b},[jT(T.$slots,"trigger",{},void 0,!0)],544),(Ge(),Cr(Qv,{to:"body"},[Er(g9,{name:"fade-in-scale-up-transition"},{default:Vd(()=>[r.value&&!e.disabled?(Ge(),$e("div",{key:0,ref_key:"contentRef",ref:i,class:Mr(c.value),style:On(u.value),onMouseenter:I,onMouseleave:w},[x[0]||(x[0]=ft("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),jT(T.$slots,"default",{},void 0,!0)],38)):Bt("",!0)]),_:3})]))],64))}}),WLe=Gn(Mln,[["__scopeId","data-v-d8dd2f5a"]]);$t(),qn();var Dln=["onKeydown","tabindex","data-item-id"],Oln={key:0},Fln={key:0},Bln={key:0},Hln={__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}=Rc(),o=Le([]),i=Le(null),s=e,a=Le(null),{isHighContrastMode:l}=tm(),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=U=>U.type==="button",f=U=>U.type==="dropdown",h=U=>U.type==="separator",p=U=>U.type==="overflow",m=U=>{if(!U)return!1;const M=U.expand;return typeof M=="object"&&M!==null&&"value"in M?!!M.value:!!M},g=(U,M)=>{U?.expand&&(U.expand.value=M)},y=(U,M=null)=>{if(!U.disabled.value){if(p(U)){const z=!m(U);z&&I(),g(U,z),a.value=z?U:null,n("item-clicked");return}f(U)||(a.value&&f(a.value)&&m(a.value)&&I(),n("item-clicked"),n("command",{item:U,argument:M??U.argument?.value??null}))}},v=(U,M)=>{U.disabled.value||(a.value=null,n("command",{item:U,argument:M}))},b=U=>{if(U.disabled.value)return;I();const M=U.splitButtonCommand,z=U.command,Z=M||z;if(!Z)return;const $={...U,command:Z};n("item-clicked"),n("command",{item:$,argument:null})},I=()=>{const U=r?.$toolbar?.toolbarItems||[],M=r?.$toolbar?.overflowItems||[],z=[...U,...M];(z.length?z:s.toolbarItems).forEach(Z=>{const $=p(Z)&&!s.fromOverflow;(f(Z)||$)&&g(Z,!1)}),a.value=null},w=(U,M)=>{I(),n("command",{item:U,argument:U.dropdownValueKey.value?M[U.dropdownValueKey.value]:M.label,option:M}),U.selectedValue.value=M.key},A=U=>U.nestedOptions?.value?.length?U.nestedOptions.value.map(M=>{const z=M?.type!=="render"&&U.selectedValue.value===M.key;return{...M,props:{...M.props,class:z?"selected":""}}}):[],T=(U,M)=>({role:"menuitem",ariaLabel:`${M.attributes.value.ariaLabel} - ${U.label}`}),x=U=>{const M=U.target,z=U.target.closest(".toolbar-item-ctn").nextElementSibling;z&&(M.setAttribute("tabindex","-1"),z.setAttribute("tabindex","0"),z.focus())},_=U=>{const M=U.target,z=U.target.closest(".toolbar-item-ctn").previousElementSibling;z&&(M.setAttribute("tabindex","-1"),z.setAttribute("tabindex","0"),z.focus())},E=U=>{const M=U.target.closest(".button-group").nextElementSibling;if(M)M.setAttribute("tabindex","0"),M.focus();else{const z=document.querySelector(".ProseMirror");z&&z.focus()}},P=U=>{const M=U.target.closest(".button-group").previousElementSibling;M&&(M.setAttribute("tabindex","0"),M.focus())},k=U=>{if(!U.disabled.value){if(f(U)){O(!m(U),U);return}y(U,null,!1)}},L=(U,M)=>{const z=U.target.nodeName==="INPUT"||U.target.nodeName==="TEXTAREA",Z=M.name.value==="fontSize";if(!(z&&Z)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(U.key))switch(U.preventDefault(),U.key){case"Enter":case" ":case"Spacebar":k(M);break;case"Escape":I();break;case"ArrowRight":I(),x(U);break;case"ArrowLeft":I(),_(U);break;case"Tab":U.shiftKey?P(U):E(U);break;default:break}},R=U=>{const M=o.value.find(z=>!z.classList.contains("disabled"));M&&(M.setAttribute("tabindex","0"),M.focus())},O=(U,M)=>{if(n("item-clicked"),!U){I(),n("dropdown-update-show",!1);return}I(),a.value=M,g(M,!0),n("dropdown-update-show",!0)},F=U=>{if(!a.value)return;const M=U.target;M instanceof Element&&(M.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(M)||I())};return Bn(()=>m(a.value),U=>{U?document.addEventListener("pointerdown",F,!0):document.removeEventListener("pointerdown",F,!0)},{immediate:!0}),wi(()=>{document.removeEventListener("pointerdown",F,!0)}),(U,M)=>(Ge(),$e("div",{style:On(u.value),class:"button-group",role:"group",onFocus:R,ref_key:"buttonGroupRef",ref:i},[(Ge(!0),$e(Pn,null,_o(e.toolbarItems,(z,Z)=>(Ge(),$e("div",{key:z.id.value,class:Mr([{narrow:z.isNarrow.value,wide:z.isWide.value,disabled:z.disabled.value},"toolbar-item-ctn"]),onKeydown:$=>L($,z),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:Z===0?0:-1,"data-item-id":z.id.value},[h(z)?(Ge(),Cr(Iln,{key:0,style:{width:"20px"}})):Bt("",!0),f(z)&&z.nestedOptions?.value?.length?(Ge(),Cr(Nln,{key:1,options:A(z),disabled:z.disabled.value,show:m(z),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"toolbar-button sd-editor-toolbar-dropdown",onSelect:($,G)=>w(z,G),"onUpdate:show":$=>O($,z),style:On(z.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":_t(l)}]}),"node-props":$=>T($,z)},{trigger:Vd(()=>[Er(WLe,{trigger:"hover",disabled:!z.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Vd(()=>[Er(XK,{"toolbar-item":z,disabled:z.disabled.value,"allow-enter-propagation":!0,onTextSubmit:$=>v(z,$),onMainClick:$=>b(z)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:Vd(()=>[ft("div",null,[dy(Qn(z.tooltip)+" ",1),z.disabled.value?(Ge(),$e("span",Oln,"(disabled)")):Bt("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(z)?(Ge(),Cr(WLe,{key:2,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:Vd(()=>[Er(XK,{"toolbar-item":z,"is-overflow-item":e.fromOverflow,onTextSubmit:$=>v(z,$),onButtonClick:$=>y(z)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Vd(()=>[z.tooltip?(Ge(),$e("div",Fln,[dy(Qn(z.tooltip)+" ",1),z.disabled.value?(Ge(),$e("span",Bln,"(disabled)")):Bt("",!0)])):Bt("",!0)]),_:2},1032,["content-style"])):Bt("",!0),p(z)&&e.overflowItems.length?(Ge(),Cr(Cln,{key:3,"toolbar-item":z,onButtonClick:$=>y(z),"overflow-items":e.overflowItems,onClose:I},null,8,["toolbar-item","onButtonClick","overflow-items"])):Bt("",!0)],42,Dln))),128))],36))}},U3=Gn(Hln,[["__scopeId","data-v-109576cd"]]);$t(),qn();var zln="Arial, Helvetica, sans-serif",Uln={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=Rc();let r=Le(1);const o=Le(!1);let i=null;const s=ut(()=>{const I=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof I=="string"&&I.trim()?I.trim():zln}),a=n.$toolbar.config?.toolbarGroups?.includes("left"),l=n.$toolbar.config?.toolbarGroups?.includes("right"),c=n.$toolbar.config?.toolbarButtonsExclude||[],u=I=>n.$toolbar.getToolbarItemByGroup(I).filter(w=>!c.includes(w.name.value)),d=()=>{o.value=n.$toolbar.getAvailableWidth()<=IE.lg},f=async I=>{if(I.metaKey&&I.key==="f"){const w=n.$toolbar.getToolbarItemByName("search");w&&(I.preventDefault(),w.expand.value=!0,await rr(),w.inputRef.value&&w.inputRef.value.focus())}},p=Gin(async()=>{await n.$toolbar.onToolbarResize(),d(),r.value+=1},300);function m(){window.removeEventListener("resize",p),window.removeEventListener("keydown",f),i?.disconnect(),i=null}function g(){m(),window.addEventListener("resize",p),window.addEventListener("keydown",f),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(i=new ResizeObserver(()=>{p()}),i.observe(n.$toolbar.toolbarContainer)),d()}Ro(g),loe(g),coe(m),wi(m);const y=({item:I,argument:w,option:A})=>{n.$toolbar.emitCommand({item:I,argument:w,option:A})},v=()=>{const I=n.$toolbar.activeEditor;I&&(I.options?.isHeaderOrFooter||I.commands?.restoreSelection())},b=I=>{I.target.closest('input, textarea, [contenteditable="true"]')||I.preventDefault()};return(I,w)=>(Ge(),$e("div",{class:"superdoc-toolbar",key:_t(r),role:"toolbar","aria-label":"Toolbar","data-editor-ui-surface":"",onMousedown:b},[_t(a)?(Ge(),Cr(U3,{key:0,tabindex:"0","toolbar-items":u("left"),"compact-side-groups":o.value,"ui-font-family":s.value,position:"left",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Bt("",!0),Er(U3,{tabindex:"0","toolbar-items":u("center"),"overflow-items":_t(n).$toolbar.overflowItems,"compact-side-groups":o.value,"ui-font-family":s.value,position:"center",onCommand:y,onItemClicked:v},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),_t(l)?(Ge(),Cr(U3,{key:1,tabindex:"0","toolbar-items":u("right"),"compact-side-groups":o.value,"ui-font-family":s.value,position:"right",onCommand:y,onItemClicked:v,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","compact-side-groups","ui-font-family"])):Bt("",!0)],32))}},jLe=Gn(Uln,[["__scopeId","data-v-bae4cd8a"]]);const qLe={bold:"Bold",fontFamily:"Font",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",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"},Vln=(e,t={})=>{const n=e?.runProperties?.fontFamily;if(!n)return null;const[r]=lg({fontFamily:n},t);return r?.attrs?.fontFamily??null},Gln=e=>{let t=null;return e&&(e.startsWith("#")||e.startsWith(".")?t=document.querySelector(e):t=document.getElementById(e),!t)?null:t};$t();var KLe=class rre extends JB.default{static#e=new Set(["bold","italic","underline","strike","highlight","color","fontSize","fontFamily"]);config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...ls},texts:{...qLe},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,editor:null,aiApiKey:null,aiEndpoint:null,customButtons:[],showFormattingMarksButton:!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={...ls,...t.icons},this.config.texts={...qLe,...t.texts},this.config.hideButtons=t.hideButtons??!0,this.config.responsiveToContainer=t.responsiveToContainer??!1,this.pendingMarkCommands=[],this.stickyStoredMarks=null,this._boundEditorHandlers={transaction:null,selectionUpdate:null,focus:null},this._restoreFocusTimeoutId=null,!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=Gln(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.#n({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=tx(jLe),this.app.directive("click-outside",B4),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?Hin({superdoc:this.superdoc,commands:tln}):null}initHeadlessToolbar(){this.superdoc&&(this.destroyHeadlessToolbar(),this.controller=this.createHeadlessToolbar(),this.snapshot=this.controller.getSnapshot(),this._unsubscribeController=this.controller.subscribe(({snapshot:t})=>{this.snapshot=t,this.updateToolbarState()}))}destroyHeadlessToolbar(){this._unsubscribeController?.(),this.controller?.destroy(),this.controller=null,this.snapshot=null,this._unsubscribeController=null}#t(){this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}setActiveEditor(t){this.activeEditor&&this._boundEditorHandlers.transaction&&(this.activeEditor.off("transaction",this._boundEditorHandlers.transaction),this.activeEditor.off("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.off("focus",this._boundEditorHandlers.focus),this._boundEditorHandlers.transaction=null,this._boundEditorHandlers.selectionUpdate=null,this._boundEditorHandlers.focus=null),this.activeEditor=t,t&&(this._boundEditorHandlers.transaction=this.onEditorTransaction.bind(this),this._boundEditorHandlers.selectionUpdate=this.onEditorSelectionUpdate.bind(this),this._boundEditorHandlers.focus=this.onEditorFocus.bind(this),this.activeEditor.on("transaction",this._boundEditorHandlers.transaction),this.activeEditor.on("selectionUpdate",this._boundEditorHandlers.selectionUpdate),this.activeEditor.on("focus",this._boundEditorHandlers.focus))}getToolbarItemByGroup(t){return this.toolbarItems.filter(n=>(n.group?.value||"center")===t)}getToolbarItemByName(t){return this.#o().find(n=>n.name.value===t)}#o(){return[...this.toolbarItems,...this.overflowItems]}getAvailableWidth(){const t=document.documentElement.clientWidth,n=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?n:t}#n({superToolbar:t,icons:n,texts:r,fonts:o,hideButtons:i,isDev:s=!1}={}){const{defaultItems:a,overflowItems:l}=rln({superToolbar:t,toolbarIcons:n,toolbarTexts:r,toolbarFonts:o,hideButtons:i,availableWidth:this.getAvailableWidth(),role:this.role,isDev:s}),c=this.config.customButtons||[];c.length&&a.push(...c.map(d=>xo({...d})));let u=[...a.map(d=>d.name.value),...l.map(d=>d.name.value)];this.config.groups&&(u=Object.values(this.config.groups).flatMap(d=>d)),this.toolbarItems=a.filter(d=>u.includes(d.name.value)).filter(d=>!this.config.excludeItems.includes(d.name.value)),this.overflowItems=l.filter(d=>u.includes(d.name.value))}#r(){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)}#i(){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=Dan(),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(Wn(a)),s},[]),i={key:"color",type:"render",render:()=>KK(this,t,o,!0)};t.nestedOptions.value=[i]}#l(){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)}#c(){if(!this.activeEditor?.state)return null;const{state:t}=this.activeEditor,n=t.selection;if(!n?.empty)return null;const r=_l(o=>o.type.name==="paragraph")(n);return!r||r.node?.content?.size!==0?null:Vln(Ll(this.activeEditor,r.node,t.doc.resolve(r.pos)),this.activeEditor?.converter?.convertedXml??{})||null}#u(t){return!!t?.active&&t?.value==null}#d(t){if(t.name.value==="tableActions"){const a=ULe.map(l=>this.snapshot?.commands?.[l]).some(l=>l&&!l.disabled);return t.setDisabled(!a),!0}const n=H3[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.#l()},link:()=>{t.active.value=!!r?.active,t.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){t.activate({fontFamily:r.value});return}const a=this.#c();if(a){t.activate({fontFamily:a});return}t.deactivate()},fontSize:()=>{if(r?.value!=null){t.activate({fontSize:r.value});return}if(this.#u(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=qye(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}#h(t,n){const r=t?.name?.value==="tableActions",o=r?zLe[n?.command]:H3[t?.name?.value];return!o||!this.controller?.execute?!1:(r?this.controller.execute(o):this.controller.execute(o,n),!0)}updateToolbarState(){this.#l(),this.#r(),this.#i();const t=this.snapshot?.commands?.["document-mode"]?.value||"editing";if(!this.activeEditor||t==="viewing"){this.#s(),this.#o().forEach(r=>{r.allowWithoutEditor?.value&&this.#d(r)});return}const{state:n}=this.activeEditor;if(!n){this.#s();return}this.#o().forEach(r=>{r.resetDisabled(),this.#d(r)})}onToolbarResize=()=>{this.#n({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.#o().forEach(t=>{const{allowWithoutEditor:n}=t;n.value||t.setDisabled(!0)})}onEditorTransaction({transaction:t}){!t.docChanged&&!t.selectionSet||this.updateToolbarState()}#a(){!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.#h(t,n)){this.updateToolbarState();return}if(VLe.has(t?.name?.value)&&this.#h(t,n)){a&&this.#w(),this.updateToolbarState(),l&&this.#a();return}if(s==="insertTableOfContents"&&this.activeEditor)T2e(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.#w(),this.updateToolbarState(),l&&this.#a()}}}onEditorSelectionUpdate(){if(this.activeEditor){if(this.pendingMarkCommands.length){const t=this.pendingMarkCommands;this.pendingMarkCommands=[],t.forEach(({command:n,argument:r,item:o})=>{if(n)try{if(VLe.has(o?.name?.value)&&this.#h(o,r)){this.#y({command:n,argument:r});return}this.activeEditor.commands&&n in this.activeEditor.commands&&this.activeEditor.commands[n](r),this.#y({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.#w(),this.updateToolbarState();return}this.#A()&&this.updateToolbarState()}}onEditorFocus(){if(this.pendingMarkCommands.length){this.onEditorSelectionUpdate();return}this.#A()&&this.updateToolbarState()}isMarkToggle(t){const n=t?.name?.value;return rre.#e.has(n)}#w(){if(!this.activeEditor)return;const{selection:t,storedMarks:n}=this.activeEditor.state||{};t?.empty&&(this.stickyStoredMarks=n?.length?[...n]:null)}#A(){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||ud(this.activeEditor).some(s=>rre.#e.has(s.name)))return!1;const i=t.tr.setStoredMarks(this.stickyStoredMarks);return n.dispatch(i),!0}#y({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]=$f(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.destroyHeadlessToolbar(),this.app?.unmount()}},Wln=class ore{static createSchemaByExtensions(t,n){const r=t.filter(a=>a.type==="node"),o=t.filter(a=>a.type==="mark"),i=r.find(a=>$n(a,"topNode"))?.name,s=an.getAttributesFromExtensions(t);return new Ale({topNode:i,nodes:ore.#e(r,s,n),marks:ore.#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=$n(m,"extendNodeSchema",a);return{...p,...g?g(i):{}}},{}),u=zz({content:Pi($n(i,"content",a)),group:Pi($n(i,"group",a)),marks:Pi($n(i,"marks",a)),inline:Pi($n(i,"inline",a)),atom:Pi($n(i,"atom",a)),selectable:Pi($n(i,"selectable",a)),draggable:Pi($n(i,"draggable",a)),code:Pi($n(i,"code",a)),defining:Pi($n(i,"defining",a)),isolating:Pi($n(i,"isolating",a)),leafText:$n(i,"leafText",a),summary:$n(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($n(i,"parseDOM",a));d&&(u.parseDOM=d.map(p=>an.insertExtensionAttrsToParseRule(p,s)));const f=$n(i,"renderDOM",a);f&&(u.toDOM=p=>f({node:p,htmlAttributes:an.getAttributesToRender(p,s)}));const h=$n(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=zz({group:Pi($n(i,"group",a)),inclusive:Pi($n(i,"inclusive",a)),excludes:Pi($n(i,"excludes",a)),spanning:Pi($n(i,"spanning",a)),code:Pi($n(i,"code",a)),attrs:l}),u=Pi($n(i,"parseDOM",a));u&&(c.parseDOM=u.map(f=>an.insertExtensionAttrsToParseRule(f,s)));const d=$n(i,"renderDOM",a);return d&&(c.toDOM=f=>d({mark:f,htmlAttributes:an.getAttributesToRender(f,s)})),[i.name,c]});return Object.fromEntries(o)}},xI,YLe,XLe,JLe,ZLe,jln=Re((()=>{xI=class extends Error{constructor(e){super(e),this.name="EditorError"}},YLe=class extends xI{constructor(e){super(e),this.name="InvalidStateError"}},XLe=class extends xI{constructor(e){super(e),this.name="NoSourcePathError"}},JLe=class extends xI{constructor(e){super(e),this.name="FileSystemNotAvailableError"}},ZLe=class extends xI{constructor(e,t){super(e),this.name="DocumentLoadError",this.cause=t}}})),wa,cs,SE=Re((()=>{jln(),wa={PASSWORD_REQUIRED:"DOCX_PASSWORD_REQUIRED",PASSWORD_INVALID:"DOCX_PASSWORD_INVALID",ENCRYPTION_UNSUPPORTED:"DOCX_ENCRYPTION_UNSUPPORTED",DECRYPTION_FAILED:"DOCX_DECRYPTION_FAILED"},cs=class extends xI{constructor(e,t,n){super(t),this.name="DocxEncryptionError",this.code=e,this.cause=n}}}));const qln=mo.create({name:"commands",addCommands(){return{...PUt}}});var JK=e=>{const t=e?.state?.tr;t&&e.dispatch?.(ZL(t))};const Kln=e=>{const{view:t}=e;return JK(t),e.commands.first(({commands:n})=>[()=>n.splitRunToParagraph?.()??!1,()=>n.newlineInCode(),()=>n.createParagraphNear(),()=>n.liftEmptyBlock(),()=>n.splitBlock()])},TE=e=>{const{view:t}=e;return JK(t),e.commands.first(({commands:n,tr:r})=>[()=>n.undoInputRule(),()=>(r.setMeta("inputType","deleteContentBackward"),!1),()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.backspaceEmptyRunParagraph(),()=>n.backspaceSkipEmptyRun(),()=>n.backspaceAtomBefore(),()=>n.backspaceNextToRun(),()=>n.backspaceAcrossRuns(),()=>n.mixedBidiBackspace?.()??!1,()=>n.deleteSelection(),()=>n.removeNumberingProperties(),()=>n.joinBackward(),()=>n.selectNodeBackward()])},kI=e=>{const{view:t}=e;return JK(t),e.commands.first(({commands:n})=>[()=>n.deleteBlockSdtAtTextBlockStart(),()=>n.deleteSkipEmptyRun(),()=>n.deleteAtomAfter(),()=>n.deleteNextToRun(),()=>n.deleteSelection(),()=>n.joinForward(),()=>n.selectNodeForward()])},Yln=mo.create({name:"keymap",addShortcuts(){const e={Enter:()=>Kln(this.editor),"Shift-Enter":()=>this.editor.commands.insertLineBreak(),"Mod-Enter":()=>this.editor.commands.insertPageBreak(),Backspace:()=>TE(this.editor),"Mod-Backspace":()=>TE(this.editor),"Shift-Backspace":()=>TE(this.editor),Delete:()=>kI(this.editor),"Mod-Delete":()=>kI(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":()=>TE(this.editor),"Alt-Backspace":()=>TE(this.editor),"Ctrl-d":()=>kI(this.editor),"Ctrl-Alt-Backspace":()=>kI(this.editor),"Alt-Delete":()=>kI(this.editor),"Alt-d":()=>kI(this.editor),"Ctrl-a":()=>this.editor.commands.selectAll(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd(),"Ctrl-t":()=>this.editor.commands.insertTabChar()};return V4()||Tet()?n:t}});var Xln=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},QLe=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"},CI=(e,t,n,r,o={})=>{if(!QLe(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}Xln({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})},Jln=(e,t,n)=>{const r=t?.inputType==="insertText",o=typeof t?.data=="string"&&t.data.length>0,i=t?.isComposing===!0;if(CI(e,t,n,"beforeinput:start",{isInsertTextInput:r,hasTextData:o,isComposing:i}),!r||!o||i)return CI(e,t,n,"beforeinput:skip"),!1;const s=e.state.selection;if(s.empty&&!QLe(n))return CI(e,t,n,"beforeinput:skip-empty-selection"),!1;const a=e.state.tr.insertText(t.data,s.from,s.to),l=Math.max(0,Math.min(s.from+t.data.length,a.doc.content.size));try{a.setSelection(Rt.create(a.doc,l))}catch{a.setSelection(Cn.near(a.doc.resolve(l),1))}return a.setMeta("inputType","insertText"),e.dispatch(a),t.preventDefault(),CI(e,t,n,"beforeinput:handled"),!0},Zln=(e,t)=>{if(!e.composing||t?.isComposing)return!1;const n=t?.inputType??null;return n?!["insertCompositionText","deleteCompositionText"].includes(n):!1},Qln=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);const $ln=mo.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 Pr({key:new ro("editable"),props:{editable:()=>e.options.editable,handleDOMEvents:{beforeinput:(r,o)=>(CI(r,o,e,"dom:beforeinput"),e.options.editable?(Zln(r,o)&&eIt(r),!!Jln(r,o,e)):(o.preventDefault(),!0)),input:(r,o)=>(CI(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&&(Qln.has(o.key)||(o.ctrlKey||o.metaKey)&&["c","a"].includes(o.key.toLowerCase()))),handlePaste:()=>!e.options.editable,handleDrop:()=>!e.options.editable}})]}}),ecn=mo.create({name:"editorFocus",addPmPlugins(){const e=this.editor;return[new Pr({key:new ro("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}}}})]}}),tcn=mo.create({name:"positionTracker",addStorage(){return{tracker:null}},addPmPlugins(){return[ztn()]},onCreate(){const e=this.editor?.positionTracker??this.storage.tracker;if(e){this.storage.tracker=e,this.editor.positionTracker=e;return}const t=new FPe(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}}),ncn=mo.create({name:"selectionHandle",addPmPlugins(){return[M4t()]}});var xE=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 rcn(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}var ocn=class cR{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=cR.getResolvedExtensions([...t,...this.externalExtensions]),this.schema=Wln.createSchemaByExtensions(this.extensions,r),this.#e()}static create(...t){return new cR(...t)}static getResolvedExtensions(t){return cR.sortByPriority(t)}static sortByPriority(t){return t.sort((r,o)=>{const i=$n(r,"priority")||100,s=$n(o,"priority")||100;return i>s?-1:i<s?1:0})}get attributes(){return an.getAttributesFromExtensions(this.extensions)}get commands(){let t={};for(const n of this.extensions){const r=$n(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:sA(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=$n(n,"addHelpers",{name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:sA(n.name,this.schema)});o&&(t[r]=o())}return t}get plugins(){const t=this.editor,n=cR.sortByPriority([...this.extensions].reverse()),r=[],o=n.map(i=>{const s={name:i.name,options:i.options,storage:i.storage,editor:t,type:sA(i.name,this.schema)},a=[],l=$n(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(uIt(c));const u=$n(i,"addInputRules",s);rcn(i,t.options.enableInputRules)&&u&&r.push(...u());const d=$n(i,"addPmPlugins",s);return d&&a.push(...d()),a}).flat();return[Ckt({editor:t,rules:r}),...o]}get nodeViews(){const{editor:t}=this,n=this.extensions.filter(r=>r.type==="node").filter(r=>!!$n(r,"addNodeView")).map(r=>{const o=this.attributes.filter(l=>l.type===r.name),i=$n(r,"addNodeView",{name:r.name,options:r.options,storage:r.storage,editor:t,type:wu(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:an.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:sA(t.name,this.schema)};t.type==="mark"&&(Pi($n(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:sA(t.name,this.schema)},r=$n(t,"onBeforeCreate",n),o=$n(t,"onCreate",n),i=$n(t,"onUpdate",n),s=$n(t,"onSelectionUpdate",n),a=$n(t,"onTransaction",n),l=$n(t,"onFocus",n),c=$n(t,"onBlur",n),u=$n(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)}},icn={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:xy(fa(a.line)),lineSpaceBefore:xy(fa(a.lineSpaceBefore)),lineSpaceAfter:xy(fa(a.lineSpaceAfter))};r.setNodeMarkup(i,void 0,{...s,spacing:{...a,...l}})}}),n(r),!0}};const $Le=e=>{if(e==="initial"||e==="0.4.14")return Object.values(icn)};var eNe=$o(((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,v=l.length,b=v,I=i.getTypeOf(l)!=="string";y<l.length;)b=v-y,d=I?(c=l[y++],u=y<v?l[y++]:0,y<v?l[y++]:0):(c=l.charCodeAt(y++),u=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),f=c>>2,h=(3&c)<<4|u>>4,p=1<b?(15&u)<<2|d>>6:64,m=2<b?63&d:64,g.push(a.charAt(f)+a.charAt(h)+a.charAt(p)+a.charAt(m));return g.join("")},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 v,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=s.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)c=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,u=(15&f)<<4|(h=a.indexOf(l.charAt(m++)))>>2,d=(3&h)<<6|(p=a.indexOf(l.charAt(m++))),v[g++]=c,h!==64&&(v[g++]=u),p!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(n,r,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,v){var b,I,w=h.file,A=h.compression,T=v!==c.utf8encode,x=a.transformTo("string",v(w.name)),_=a.transformTo("string",c.utf8encode(w.name)),E=w.comment,P=a.transformTo("string",v(E)),k=a.transformTo("string",c.utf8encode(E)),L=_.length!==w.name.length,R=k.length!==E.length,O="",F="",H="",U=w.dir,M=w.date,z={crc32:0,compressedSize:0,uncompressedSize:0};p&&!m||(z.crc32=h.crc32,z.compressedSize=h.compressedSize,z.uncompressedSize=h.uncompressedSize);var Z=0;p&&(Z|=8),T||!L&&!R||(Z|=2048);var $=0,G=0;U&&($|=16),y==="UNIX"?(G=798,$|=(function(X,Y){var ne=X;return X||(ne=Y?16893:33204),(65535&ne)<<16})(w.unixPermissions,U)):(G=20,$|=(function(X){return 63&(X||0)})(w.dosPermissions)),b=M.getUTCHours(),b<<=6,b|=M.getUTCMinutes(),b<<=5,b|=M.getUTCSeconds()/2,I=M.getUTCFullYear()-1980,I<<=4,I|=M.getUTCMonth()+1,I<<=5,I|=M.getUTCDate(),L&&(F=i(1,1)+i(u(x),4)+_,O+="up"+i(F.length,2)+F),R&&(H=i(1,1)+i(u(P),4)+k,O+="uc"+i(H.length,2)+H);var ye="";return ye+=`
400
400
  \0`,ye+=i(Z,2),ye+=A.magic,ye+=i(b,2),ye+=i(I,2),ye+=i(z.crc32,4),ye+=i(z.compressedSize,4),ye+=i(z.uncompressedSize,4),ye+=i(x.length,2),ye+=i(O.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ye+x+O,dirRecord:d.CENTRAL_FILE_HEADER+i(G,2)+ye+i(P.length,2)+"\0\0\0\0"+i($,4)+i(g,4)+x+O+P}}var a=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),d=n("../signature");function f(h,p,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:m?(p+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var m=s(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,m=s(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),p)this.push({data:(function(g){return d.DATA_DESCRIPTOR+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,v,b,I,w){var A=a.transformTo("string",w(I));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(v,4)+i(b,4)+i(A.length,2)+A})(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(v,b){var I=v||b,w=i[I];if(!w)throw new Error(I+" is not a valid compression method !");return w})(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 v=0;v<y.length;v++)g.push(d(y[v]));return s.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,v=0;v<y.length;v++){var b=y[v],I=b.fileNameStr,w=i.resolve(b.fileNameStr);p.file(w,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(w).unsafeOriginalName=I)}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(I,w,A){var T,x=a.getTypeOf(w),_=a.extend(A||{},u);_.date=_.date||new Date,_.compression!==null&&(_.compression=_.compression.toUpperCase()),typeof _.unixPermissions=="string"&&(_.unixPermissions=parseInt(_.unixPermissions,8)),_.unixPermissions&&16384&_.unixPermissions&&(_.dir=!0),_.dosPermissions&&16&_.dosPermissions&&(_.dir=!0),_.dir&&(I=y(I)),_.createFolders&&(T=g(I))&&v.call(this,T,!0);var E=x==="string"&&_.binary===!1&&_.base64===!1;A&&A.binary!==void 0||(_.binary=!E),(w instanceof d&&w.uncompressedSize===0||_.dir||!w||w.length===0)&&(_.base64=!1,_.binary=!0,w="",_.compression="STORE",x="string");var P=null;P=w instanceof d||w instanceof l?w:p.isNode&&p.isStream(w)?new m(I,w):a.prepareContent(I,w,_.binary,_.optimizedBinaryString,_.base64);var k=new f(I,P,_);this.files[I]=k}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(I){I.slice(-1)==="/"&&(I=I.substring(0,I.length-1));var w=I.lastIndexOf("/");return 0<w?I.substring(0,w):""},y=function(I){return I.slice(-1)!=="/"&&(I+="/"),I},v=function(I,w){return w=w!==void 0?w:u.createFolders,I=y(I),this.files[I]||i.call(this,I,null,{dir:!0,createFolders:w}),this.files[I]};function b(I){return Object.prototype.toString.call(I)==="[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(I){var w,A,T;for(w in this.files)T=this.files[w],(A=w.slice(this.root.length,w.length))&&w.slice(0,this.root.length)===this.root&&I(A,T)},filter:function(I){var w=[];return this.forEach(function(A,T){I(A,T)&&w.push(T)}),w},file:function(I,w,A){if(arguments.length!==1)return I=this.root+I,i.call(this,I,w,A),this;if(b(I)){var T=I;return this.filter(function(_,E){return!E.dir&&T.test(_)})}var x=this.files[this.root+I];return x&&!x.dir?x:null},folder:function(I){if(!I)return this;if(b(I))return this.filter(function(x,_){return _.dir&&I.test(x)});var w=this.root+I,A=v.call(this,w),T=this.clone();return T.root=A.name,T},remove:function(I){I=this.root+I;var w=this.files[I];if(w||(I.slice(-1)!=="/"&&(I+="/"),w=this.files[I]),w&&!w.dir)delete this.files[I];else for(var A=this.filter(function(x,_){return _.name.slice(0,I.length)===I}),T=0;T<A.length;T++)delete this.files[A[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(I){var w,A={};try{if((A=a.extend(I||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");a.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var T=A.comment||this.comment||"";w=h.generateWorker(this,A,T)}catch(x){(w=new l("error")).error(x)}return new c(w,A.type||"string",A.mimeType)},generateAsync:function(I,w){return this.generateInternalStream(I).accumulate(w)},generateNodeStream:function(I,w){return(I=I||{}).type||(I.type="nodebuffer"),this.generateInternalStream(I).toNodejsStream(w)}}},{"./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 v=[],b=p._internalType,I=p._outputType,w=p._mimeType;p.on("data",function(A,T){v.push(A),m&&m(T)}).on("error",function(A){v=[],y(A)}).on("end",function(){try{g((function(A,T,x){switch(A){case"blob":return i.newBlob(i.transformTo("arraybuffer",T),x);case"base64":return l.encode(T);default:return i.transformTo(A,T)}})(I,(function(A,T){var x,_=0,E=null,P=0;for(x=0;x<T.length;x++)P+=T[x].length;switch(A){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(E=new Uint8Array(P),x=0;x<T.length;x++)E.set(T[x],_),_+=T[x].length;return E;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+A+"'")}})(b,v),w))}catch(A){y(A)}v=[]}).resume()})}function h(p,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,i.checkSupport(y),this._worker=p.pipe(new s(y)),p.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}h.prototype={accumulate:function(p){return f(this,p)},on:function(p,m){var g=this;return p==="data"?this._worker.on(p,function(y){m.call(g,y.data,y.meta)}):this._worker.on(p,function(){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,v,b,I=p.length,w=0;for(v=0;v<I;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<I&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),w+=g<128?1:g<2048?2:g<65536?3:4;for(m=s.uint8array?new Uint8Array(w):new Array(w),v=b=0;b<w;v++)(64512&(g=p.charCodeAt(v)))==55296&&v+1<I&&(64512&(y=p.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(h)},o.utf8decode=function(h){return s.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var m,g,y,v,b=p.length,I=new Array(2*b);for(m=g=0;m<b;)if((y=p[m++])<128)I[g++]=y;else if(4<(v=c[y]))I[g++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&p[m++],v--;1<v?I[g++]=65533:y<65536?I[g++]=y:(y-=65536,I[g++]=55296|y>>10&1023,I[g++]=56320|1023&y)}return I.length!==g&&(I.subarray?I=I.subarray(0,g):I.length=g),i.applyFromCharCode(I)})(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(v,b){var I;for((b=b||v.length)>v.length&&(b=v.length),I=b-1;0<=I&&(192&v[I])==128;)I--;return I<0||I===0?b:I+c[v[I]]>b?I:b})(p),y=p;g!==p.length&&(s.uint8array?(y=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(y=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data: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 v=[],b=0,I=m.length;if(I<=y)return String.fromCharCode.apply(null,m);for(;b<I;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,I)))):v.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,I)))),b+=y;return v.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return 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),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function h(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}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=[],v=0;v<g.length;v++){var b=g[v];b==="."||b===""&&v!==0&&v!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},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,v="";for(y=0;y<(m||"").length;y++)v+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},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,v,b){return l.Promise.resolve(g).then(function(I){return i.blob&&(I instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(I))!==-1)&&typeof FileReader<"u"?new l.Promise(function(w,A){var T=new FileReader;T.onload=function(x){w(x.target.result)},T.onerror=function(x){A(x.target.error)},T.readAsArrayBuffer(I)}):I}).then(function(I){var w=o.getTypeOf(I);return w?(w==="arraybuffer"?I=o.transformTo("uint8array",I):w==="string"&&(b?I=s.decode(I):y&&v!==!0&&(I=(function(A){return u(A,i.uint8array?new Uint8Array(A.length):new Array(A.length))})(I))),I):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 v=!this._dataBinary;v&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new u("error")).error(b)}return new s(m,g,"")},async:function(p,m){return this.internalStream(p).accumulate(m)},nodeStream:function(p,m){return this.internalStream(p||"nodebuffer").toNodejsStream(m)},_compressWorker:function(p,m){if(this._data instanceof c&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,p,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)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,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(y,v,b){i(function(){var I;try{I=v(b)}catch(w){return a.reject(y,w)}I===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,I)})}function p(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function m(y,v){var b=!1;function I(T){b||(b=!0,a.reject(y,T))}function w(T){b||(b=!0,a.resolve(y,T))}var A=g(function(){v(w,I)});A.status==="error"&&I(A.value)}function g(y,v){var b={};try{b.value=y(v),b.status="success"}catch(I){b.status="error",b.value=I}return b}(r.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==u?h(b,this.state===c?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},a.resolve=function(y,v){var b=g(p,v);if(b.status==="error")return a.reject(y,b.value);var I=b.value;if(I)m(y,I);else{y.state=c,y.outcome=v;for(var w=-1,A=y.queue.length;++w<A;)y.queue[w].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var b=-1,I=y.queue.length;++b<I;)y.queue[b].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},d.reject=function(y){var v=new this(s);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,I=!1;if(!b)return this.resolve([]);for(var w=new Array(b),A=0,T=-1,x=new this(s);++T<b;)_(y[T],T);return x;function _(E,P){v.resolve(E).then(function(k){w[P]=k,++A!==b||I||(I=!0,a.resolve(x,w))},function(k){I||(I=!0,a.reject(x,k))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,I=!1;if(!b)return this.resolve([]);for(var w=-1,A=new this(s);++w<b;)T=y[w],v.resolve(T).then(function(x){I||(I=!0,a.resolve(A,x))},function(x){I||(I=!0,a.reject(A,x))});var T;return A}},{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 v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var b=i.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==d)throw new Error(l[b]);if(v.header&&i.deflateSetHeader(this.strm,v.header),v.dictionary){var I;if(I=typeof v.dictionary=="string"?a.string2buf(v.dictionary):u.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=i.deflateSetDictionary(this.strm,I))!==d)throw new Error(l[b]);this._dict_set=!0}}function g(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,v){var b,I,w=this.strm,A=this.options.chunkSize;if(this.ended)return!1;I=v===~~v?v:v===!0?4:0,typeof y=="string"?w.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?w.input=new Uint8Array(y):w.input=y,w.next_in=0,w.avail_in=w.input.length;do{if(w.avail_out===0&&(w.output=new s.Buf8(A),w.next_out=0,w.avail_out=A),(b=i.deflate(w,I))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);w.avail_out!==0&&(w.avail_in!==0||I!==4&&I!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(w.output,w.next_out))):this.onData(s.shrinkBuf(w.output,w.next_out)))}while((0<w.avail_in||w.avail_out===0)&&b!==1);return I===4?(b=i.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):I!==2||(this.onEnd(d),!(w.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,v){return(v=v||{}).raw=!0,g(y,v)},o.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,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,v,b,I,w,A,T=this.strm,x=this.options.chunkSize,_=this.options.dictionary,E=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?T.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?T.input=new Uint8Array(m):T.input=m,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(x),T.next_out=0,T.avail_out=x),(y=i.inflate(T,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&_&&(A=typeof _=="string"?a.string2buf(_):f.call(_)==="[object ArrayBuffer]"?new Uint8Array(_):_,y=i.inflateSetDictionary(this.strm,A)),y===l.Z_BUF_ERROR&&E===!0&&(y=l.Z_OK,E=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==l.Z_STREAM_END&&(T.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(T.output,T.next_out),I=T.next_out-b,w=a.buf2string(T.output,b),T.next_out=I,T.avail_out=x-I,I&&s.arraySet(T.output,T.output,b,I,0),this.onData(w)):this.onData(s.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(E=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(m){this.chunks.push(m)},h.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},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,v=0;for(m=0;m<y;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),v+=h<128?1:h<2048?2:h<65536?3:4;for(f=new i.Buf8(v),m=g=0;g<v;m++)(64512&(h=d.charCodeAt(m)))==55296&&m+1<y&&(64512&(p=d.charCodeAt(m+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),m++),h<128?f[g++]=h:(h<2048?f[g++]=192|h>>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},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,v=new Array(2*y);for(h=p=0;h<y;)if((m=d[h++])<128)v[p++]=m;else if(4<(g=l[m]))v[p++]=65533,h+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&h<y;)m=m<<6|63&d[h++],g--;1<g?v[p++]=65533:m<65536?v[p++]=m:(m-=65536,v[p++]=55296|m>>10&1023,v[p++]=56320|1023&m)}return u(v,p)},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,v=8,b=9,I=286,w=30,A=19,T=2*I+1,x=15,_=3,E=258,P=E+_+1,k=42,L=113,R=1,O=2,F=3,H=4;function U(N,j){return N.msg=u[j],j}function M(N){return(N<<1)-(4<N?9:0)}function z(N){for(var j=N.length;0<=--j;)N[j]=0}function Z(N){var j=N.state,ie=j.pending;ie>N.avail_out&&(ie=N.avail_out),ie!==0&&(s.arraySet(N.output,j.pending_buf,j.pending_out,ie,N.next_out),N.next_out+=ie,j.pending_out+=ie,N.total_out+=ie,N.avail_out-=ie,j.pending-=ie,j.pending===0&&(j.pending_out=0))}function $(N,j){a._tr_flush_block(N,0<=N.block_start?N.block_start:-1,N.strstart-N.block_start,j),N.block_start=N.strstart,Z(N.strm)}function G(N,j){N.pending_buf[N.pending++]=j}function ye(N,j){N.pending_buf[N.pending++]=j>>>8&255,N.pending_buf[N.pending++]=255&j}function X(N,j){var ie,J,re=N.max_chain_length,ee=N.strstart,ae=N.prev_length,fe=N.nice_match,de=N.strstart>N.w_size-P?N.strstart-(N.w_size-P):0,oe=N.window,ce=N.w_mask,xe=N.prev,ve=N.strstart+E,ue=oe[ee+ae-1],Ae=oe[ee+ae];N.prev_length>=N.good_match&&(re>>=2),fe>N.lookahead&&(fe=N.lookahead);do if(oe[(ie=j)+ae]===Ae&&oe[ie+ae-1]===ue&&oe[ie]===oe[ee]&&oe[++ie]===oe[ee+1]){ee+=2,ie++;do;while(oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&oe[++ee]===oe[++ie]&&ee<ve);if(J=E-(ve-ee),ee=ve-E,ae<J){if(N.match_start=j,fe<=(ae=J))break;ue=oe[ee+ae-1],Ae=oe[ee+ae]}}while((j=xe[j&ce])>de&&--re!=0);return ae<=N.lookahead?ae:N.lookahead}function Y(N){var j,ie,J,re,ee,ae,fe,de,oe,ce,xe=N.w_size;do{if(re=N.window_size-N.lookahead-N.strstart,N.strstart>=xe+(xe-P)){for(s.arraySet(N.window,N.window,xe,xe,0),N.match_start-=xe,N.strstart-=xe,N.block_start-=xe,j=ie=N.hash_size;J=N.head[--j],N.head[j]=xe<=J?J-xe:0,--ie;);for(j=ie=xe;J=N.prev[--j],N.prev[j]=xe<=J?J-xe:0,--ie;);re+=xe}if(N.strm.avail_in===0)break;if(ae=N.strm,fe=N.window,de=N.strstart+N.lookahead,oe=re,ce=void 0,ce=ae.avail_in,oe<ce&&(ce=oe),ie=ce===0?0:(ae.avail_in-=ce,s.arraySet(fe,ae.input,ae.next_in,ce,de),ae.state.wrap===1?ae.adler=l(ae.adler,fe,ce,de):ae.state.wrap===2&&(ae.adler=c(ae.adler,fe,ce,de)),ae.next_in+=ce,ae.total_in+=ce,ce),N.lookahead+=ie,N.lookahead+N.insert>=_)for(ee=N.strstart-N.insert,N.ins_h=N.window[ee],N.ins_h=(N.ins_h<<N.hash_shift^N.window[ee+1])&N.hash_mask;N.insert&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[ee+_-1])&N.hash_mask,N.prev[ee&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=ee,ee++,N.insert--,!(N.lookahead+N.insert<_)););}while(N.lookahead<P&&N.strm.avail_in!==0)}function ne(N,j){for(var ie,J;;){if(N.lookahead<P){if(Y(N),N.lookahead<P&&j===d)return R;if(N.lookahead===0)break}if(ie=0,N.lookahead>=_&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+_-1])&N.hash_mask,ie=N.prev[N.strstart&N.w_mask]=N.head[N.ins_h],N.head[N.ins_h]=N.strstart),ie!==0&&N.strstart-ie<=N.w_size-P&&(N.match_length=X(N,ie)),N.match_length>=_)if(J=a._tr_tally(N,N.strstart-N.match_start,N.match_length-_),N.lookahead-=N.match_length,N.match_length<=N.max_lazy_match&&N.lookahead>=_){for(N.match_length--;N.strstart++,N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+_-1])&N.hash_mask,ie=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&&($(N,!1),N.strm.avail_out===0))return R}return N.insert=N.strstart<_-1?N.strstart:_-1,j===f?($(N,!0),N.strm.avail_out===0?F:H):N.last_lit&&($(N,!1),N.strm.avail_out===0)?R:O}function me(N,j){for(var ie,J,re;;){if(N.lookahead<P){if(Y(N),N.lookahead<P&&j===d)return R;if(N.lookahead===0)break}if(ie=0,N.lookahead>=_&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+_-1])&N.hash_mask,ie=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=_-1,ie!==0&&N.prev_length<N.max_lazy_match&&N.strstart-ie<=N.w_size-P&&(N.match_length=X(N,ie),N.match_length<=5&&(N.strategy===1||N.match_length===_&&4096<N.strstart-N.match_start)&&(N.match_length=_-1)),N.prev_length>=_&&N.match_length<=N.prev_length){for(re=N.strstart+N.lookahead-_,J=a._tr_tally(N,N.strstart-1-N.prev_match,N.prev_length-_),N.lookahead-=N.prev_length-1,N.prev_length-=2;++N.strstart<=re&&(N.ins_h=(N.ins_h<<N.hash_shift^N.window[N.strstart+_-1])&N.hash_mask,ie=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=_-1,N.strstart++,J&&($(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]))&&$(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<_-1?N.strstart:_-1,j===f?($(N,!0),N.strm.avail_out===0?F:H):N.last_lit&&($(N,!1),N.strm.avail_out===0)?R:O}function Se(N,j,ie,J,re){this.good_length=N,this.max_lazy=j,this.nice_length=ie,this.max_chain=J,this.func=re}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*T),this.dyn_dtree=new s.Buf16(2*(2*w+1)),this.bl_tree=new s.Buf16(2*(2*A+1)),z(this.dyn_ltree),z(this.dyn_dtree),z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(x+1),this.heap=new s.Buf16(2*I+1),z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*I+1),z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function _e(N){var j;return N&&N.state?(N.total_in=N.total_out=0,N.data_type=y,(j=N.state).pending=0,j.pending_out=0,j.wrap<0&&(j.wrap=-j.wrap),j.status=j.wrap?k:L,N.adler=j.wrap===2?0:1,j.last_flush=d,a._tr_init(j),h):U(N,p)}function q(N){var j=_e(N);return j===h&&(function(ie){ie.window_size=2*ie.w_size,z(ie.head),ie.max_lazy_match=i[ie.level].max_lazy,ie.good_match=i[ie.level].good_length,ie.nice_match=i[ie.level].nice_length,ie.max_chain_length=i[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=_-1,ie.match_available=0,ie.ins_h=0})(N.state),j}function D(N,j,ie,J,re,ee){if(!N)return p;var ae=1;if(j===m&&(j=6),J<0?(ae=0,J=-J):15<J&&(ae=2,J-=16),re<1||b<re||ie!==v||J<8||15<J||j<0||9<j||ee<0||g<ee)return U(N,p);J===8&&(J=9);var fe=new he;return(N.state=fe).strm=N,fe.wrap=ae,fe.gzhead=null,fe.w_bits=J,fe.w_size=1<<fe.w_bits,fe.w_mask=fe.w_size-1,fe.hash_bits=re+7,fe.hash_size=1<<fe.hash_bits,fe.hash_mask=fe.hash_size-1,fe.hash_shift=~~((fe.hash_bits+_-1)/_),fe.window=new s.Buf8(2*fe.w_size),fe.head=new s.Buf16(fe.hash_size),fe.prev=new s.Buf16(fe.w_size),fe.lit_bufsize=1<<re+6,fe.pending_buf_size=4*fe.lit_bufsize,fe.pending_buf=new s.Buf8(fe.pending_buf_size),fe.d_buf=1*fe.lit_bufsize,fe.l_buf=3*fe.lit_bufsize,fe.level=j,fe.strategy=ee,fe.method=ie,q(N)}i=[new Se(0,0,0,0,function(N,j){var ie=65535;for(ie>N.pending_buf_size-5&&(ie=N.pending_buf_size-5);;){if(N.lookahead<=1){if(Y(N),N.lookahead===0&&j===d)return R;if(N.lookahead===0)break}N.strstart+=N.lookahead,N.lookahead=0;var J=N.block_start+ie;if((N.strstart===0||N.strstart>=J)&&(N.lookahead=N.strstart-J,N.strstart=J,$(N,!1),N.strm.avail_out===0)||N.strstart-N.block_start>=N.w_size-P&&($(N,!1),N.strm.avail_out===0))return R}return N.insert=0,j===f?($(N,!0),N.strm.avail_out===0?F:H):(N.strstart>N.block_start&&($(N,!1),N.strm.avail_out),R)}),new Se(4,4,8,4,ne),new Se(4,5,16,8,ne),new Se(4,6,32,32,ne),new Se(4,4,16,16,me),new Se(8,16,32,32,me),new Se(8,16,128,128,me),new Se(8,32,128,256,me),new Se(32,128,258,1024,me),new Se(32,258,258,4096,me)],o.deflateInit=function(N,j){return D(N,j,v,15,8,0)},o.deflateInit2=D,o.deflateReset=q,o.deflateResetKeep=_e,o.deflateSetHeader=function(N,j){return N&&N.state?N.state.wrap!==2?p:(N.state.gzhead=j,h):p},o.deflate=function(N,j){var ie,J,re,ee;if(!N||!N.state||5<j||j<0)return N?U(N,p):p;if(J=N.state,!N.output||!N.input&&N.avail_in!==0||J.status===666&&j!==f)return U(N,N.avail_out===0?-5:p);if(J.strm=N,ie=J.last_flush,J.last_flush=j,J.status===k)if(J.wrap===2)N.adler=0,G(J,31),G(J,139),G(J,8),J.gzhead?(G(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)),G(J,255&J.gzhead.time),G(J,J.gzhead.time>>8&255),G(J,J.gzhead.time>>16&255),G(J,J.gzhead.time>>24&255),G(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),G(J,255&J.gzhead.os),J.gzhead.extra&&J.gzhead.extra.length&&(G(J,255&J.gzhead.extra.length),G(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):(G(J,0),G(J,0),G(J,0),G(J,0),G(J,0),G(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),G(J,3),J.status=L);else{var ae=v+(J.w_bits-8<<4)<<8;ae|=(2<=J.strategy||J.level<2?0:J.level<6?1:J.level===6?2:3)<<6,J.strstart!==0&&(ae|=32),ae+=31-ae%31,J.status=L,ye(J,ae),J.strstart!==0&&(ye(J,N.adler>>>16),ye(J,65535&N.adler)),N.adler=1}if(J.status===69)if(J.gzhead.extra){for(re=J.pending;J.gzindex<(65535&J.gzhead.extra.length)&&(J.pending!==J.pending_buf_size||(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending!==J.pending_buf_size));)G(J,255&J.gzhead.extra[J.gzindex]),J.gzindex++;J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),J.gzindex===J.gzhead.extra.length&&(J.gzindex=0,J.status=73)}else J.status=73;if(J.status===73)if(J.gzhead.name){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){ee=1;break}ee=J.gzindex<J.gzhead.name.length?255&J.gzhead.name.charCodeAt(J.gzindex++):0,G(J,ee)}while(ee!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),ee===0&&(J.gzindex=0,J.status=91)}else J.status=91;if(J.status===91)if(J.gzhead.comment){re=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),Z(N),re=J.pending,J.pending===J.pending_buf_size)){ee=1;break}ee=J.gzindex<J.gzhead.comment.length?255&J.gzhead.comment.charCodeAt(J.gzindex++):0,G(J,ee)}while(ee!==0);J.gzhead.hcrc&&J.pending>re&&(N.adler=c(N.adler,J.pending_buf,J.pending-re,re)),ee===0&&(J.status=103)}else J.status=103;if(J.status===103&&(J.gzhead.hcrc?(J.pending+2>J.pending_buf_size&&Z(N),J.pending+2<=J.pending_buf_size&&(G(J,255&N.adler),G(J,N.adler>>8&255),N.adler=0,J.status=L)):J.status=L),J.pending!==0){if(Z(N),N.avail_out===0)return J.last_flush=-1,h}else if(N.avail_in===0&&M(j)<=M(ie)&&j!==f)return U(N,-5);if(J.status===666&&N.avail_in!==0)return U(N,-5);if(N.avail_in!==0||J.lookahead!==0||j!==d&&J.status!==666){var fe=J.strategy===2?(function(de,oe){for(var ce;;){if(de.lookahead===0&&(Y(de),de.lookahead===0)){if(oe===d)return R;break}if(de.match_length=0,ce=a._tr_tally(de,0,de.window[de.strstart]),de.lookahead--,de.strstart++,ce&&($(de,!1),de.strm.avail_out===0))return R}return de.insert=0,oe===f?($(de,!0),de.strm.avail_out===0?F:H):de.last_lit&&($(de,!1),de.strm.avail_out===0)?R:O})(J,j):J.strategy===3?(function(de,oe){for(var ce,xe,ve,ue,Ae=de.window;;){if(de.lookahead<=E){if(Y(de),de.lookahead<=E&&oe===d)return R;if(de.lookahead===0)break}if(de.match_length=0,de.lookahead>=_&&0<de.strstart&&(xe=Ae[ve=de.strstart-1])===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]){ue=de.strstart+E;do;while(xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&xe===Ae[++ve]&&ve<ue);de.match_length=E-(ue-ve),de.match_length>de.lookahead&&(de.match_length=de.lookahead)}if(de.match_length>=_?(ce=a._tr_tally(de,1,de.match_length-_),de.lookahead-=de.match_length,de.strstart+=de.match_length,de.match_length=0):(ce=a._tr_tally(de,0,de.window[de.strstart]),de.lookahead--,de.strstart++),ce&&($(de,!1),de.strm.avail_out===0))return R}return de.insert=0,oe===f?($(de,!0),de.strm.avail_out===0?F:H):de.last_lit&&($(de,!1),de.strm.avail_out===0)?R:O})(J,j):i[J.level].func(J,j);if(fe!==F&&fe!==H||(J.status=666),fe===R||fe===F)return N.avail_out===0&&(J.last_flush=-1),h;if(fe===O&&(j===1?a._tr_align(J):j!==5&&(a._tr_stored_block(J,0,0,!1),j===3&&(z(J.head),J.lookahead===0&&(J.strstart=0,J.block_start=0,J.insert=0))),Z(N),N.avail_out===0))return J.last_flush=-1,h}return j!==f?h:J.wrap<=0?1:(J.wrap===2?(G(J,255&N.adler),G(J,N.adler>>8&255),G(J,N.adler>>16&255),G(J,N.adler>>24&255),G(J,255&N.total_in),G(J,N.total_in>>8&255),G(J,N.total_in>>16&255),G(J,N.total_in>>24&255)):(ye(J,N.adler>>>16),ye(J,65535&N.adler)),Z(N),0<J.wrap&&(J.wrap=-J.wrap),J.pending!==0?h:1)},o.deflateEnd=function(N){var j;return N&&N.state?(j=N.state.status)!==k&&j!==69&&j!==73&&j!==91&&j!==103&&j!==L&&j!==666?U(N,p):(N.state=null,j===L?U(N,-3):h):p},o.deflateSetDictionary=function(N,j){var ie,J,re,ee,ae,fe,de,oe,ce=j.length;if(!N||!N.state||(ee=(ie=N.state).wrap)===2||ee===1&&ie.status!==k||ie.lookahead)return p;for(ee===1&&(N.adler=l(N.adler,j,ce,0)),ie.wrap=0,ce>=ie.w_size&&(ee===0&&(z(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),oe=new s.Buf8(ie.w_size),s.arraySet(oe,j,ce-ie.w_size,ie.w_size,0),j=oe,ce=ie.w_size),ae=N.avail_in,fe=N.next_in,de=N.input,N.avail_in=ce,N.next_in=0,N.input=j,Y(ie);ie.lookahead>=_;){for(J=ie.strstart,re=ie.lookahead-(_-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[J+_-1])&ie.hash_mask,ie.prev[J&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=J,J++,--re;);ie.strstart=J,ie.lookahead=_-1,Y(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=_-1,ie.match_available=0,N.next_in=fe,N.input=de,N.avail_in=ae,ie.wrap=ee,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,v,b,I,w,A,T,x,_,E,P,k,L,R=i.input,O;c=l+(i.avail_in-5),u=i.next_out,O=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,v=a.hold,b=a.bits,I=a.lencode,w=a.distcode,A=(1<<a.lenbits)-1,T=(1<<a.distbits)-1;e:do{b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),x=I[v&A];t:for(;;){if(v>>>=_=x>>>24,b-=_,(_=x>>>16&255)===0)O[u++]=65535&x;else{if(!(16&_)){if((64&_)==0){x=I[(65535&x)+(v&(1<<_)-1)];continue t}if(32&_){a.mode=12;break e}i.msg="invalid literal/length code",a.mode=30;break e}E=65535&x,(_&=15)&&(b<_&&(v+=R[l++]<<b,b+=8),E+=v&(1<<_)-1,v>>>=_,b-=_),b<15&&(v+=R[l++]<<b,b+=8,v+=R[l++]<<b,b+=8),x=w[v&T];n:for(;;){if(v>>>=_=x>>>24,b-=_,!(16&(_=x>>>16&255))){if((64&_)==0){x=w[(65535&x)+(v&(1<<_)-1)];continue n}i.msg="invalid distance code",a.mode=30;break e}if(P=65535&x,b<(_&=15)&&(v+=R[l++]<<b,(b+=8)<_&&(v+=R[l++]<<b,b+=8)),h<(P+=v&(1<<_)-1)){i.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=_,b-=_,(_=u-d)<P){if(m<(_=P-_)&&a.sane){i.msg="invalid distance too far back",a.mode=30;break e}if(L=y,(k=0)===g){if(k+=p-_,_<E){for(E-=_;O[u++]=y[k++],--_;);k=u-P,L=O}}else if(g<_){if(k+=p+g-_,(_-=g)<E){for(E-=_;O[u++]=y[k++],--_;);if(k=0,g<E){for(E-=_=g;O[u++]=y[k++],--_;);k=u-P,L=O}}}else if(k+=g-_,_<E){for(E-=_;O[u++]=y[k++],--_;);k=u-P,L=O}for(;2<E;)O[u++]=L[k++],O[u++]=L[k++],O[u++]=L[k++],E-=3;E&&(O[u++]=L[k++],1<E&&(O[u++]=L[k++]))}else{for(k=u-P;O[u++]=O[k++],O[u++]=O[k++],O[u++]=O[k++],2<(E-=3););E&&(O[u++]=O[k++],1<E&&(O[u++]=O[k++]))}break}}break}}while(l<c&&u<f);l-=E=b>>3,v&=(1<<(b-=E<<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=v,a.bits=b}},{}],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(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new 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 b(k){var L;return k&&k.state?(L=k.state,k.total_in=k.total_out=L.total=0,k.msg="",L.wrap&&(k.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 I(k){var L;return k&&k.state?((L=k.state).wsize=0,L.whave=0,L.wnext=0,b(k)):h}function w(k,L){var R,O;return k&&k.state?(O=k.state,L<0?(R=0,L=-L):(R=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:(O.window!==null&&O.wbits!==L&&(O.window=null),O.wrap=R,O.wbits=L,I(k))):h}function A(k,L){var R,O;return k?(O=new v,(k.state=O).window=null,(R=w(k,L))!==f&&(k.state=null),R):h}var T,x,_=!0;function E(k){if(_){var L;for(T=new i.Buf32(512),x=new i.Buf32(32),L=0;L<144;)k.lens[L++]=8;for(;L<256;)k.lens[L++]=9;for(;L<280;)k.lens[L++]=7;for(;L<288;)k.lens[L++]=8;for(c(u,k.lens,0,288,T,0,k.work,{bits:9}),L=0;L<32;)k.lens[L++]=5;c(d,k.lens,0,32,x,0,k.work,{bits:5}),_=!1}k.lencode=T,k.lenbits=9,k.distcode=x,k.distbits=5}function P(k,L,R,O){var F,H=k.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new i.Buf8(H.wsize)),O>=H.wsize?(i.arraySet(H.window,L,R-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(O<(F=H.wsize-H.wnext)&&(F=O),i.arraySet(H.window,L,R-O,F,H.wnext),(O-=F)?(i.arraySet(H.window,L,R-O,O,0),H.wnext=O,H.whave=H.wsize):(H.wnext+=F,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=F))),0}o.inflateReset=I,o.inflateReset2=w,o.inflateResetKeep=b,o.inflateInit=function(k){return A(k,15)},o.inflateInit2=A,o.inflate=function(k,L){var R,O,F,H,U,M,z,Z,$,G,ye,X,Y,ne,me,Se,he,_e,q,D,N,j,ie,J,re=0,ee=new i.Buf8(4),ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return h;(R=k.state).mode===12&&(R.mode=13),U=k.next_out,F=k.output,z=k.avail_out,H=k.next_in,O=k.input,M=k.avail_in,Z=R.hold,$=R.bits,G=M,ye=z,j=f;e:for(;;)switch(R.mode){case p:if(R.wrap===0){R.mode=13;break}for(;$<16;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(2&R.wrap&&Z===35615){ee[R.check=0]=255&Z,ee[1]=Z>>>8&255,R.check=a(R.check,ee,2,0),$=Z=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&Z)<<8)+(Z>>8))%31){k.msg="incorrect header check",R.mode=30;break}if((15&Z)!=8){k.msg="unknown compression method",R.mode=30;break}if($-=4,N=8+(15&(Z>>>=4)),R.wbits===0)R.wbits=N;else if(N>R.wbits){k.msg="invalid window size",R.mode=30;break}R.dmax=1<<N,k.adler=R.check=1,R.mode=512&Z?10:12,$=Z=0;break;case 2:for(;$<16;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(R.flags=Z,(255&R.flags)!=8){k.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){k.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=Z>>8&1),512&R.flags&&(ee[0]=255&Z,ee[1]=Z>>>8&255,R.check=a(R.check,ee,2,0)),$=Z=0,R.mode=3;case 3:for(;$<32;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.head&&(R.head.time=Z),512&R.flags&&(ee[0]=255&Z,ee[1]=Z>>>8&255,ee[2]=Z>>>16&255,ee[3]=Z>>>24&255,R.check=a(R.check,ee,4,0)),$=Z=0,R.mode=4;case 4:for(;$<16;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.head&&(R.head.xflags=255&Z,R.head.os=Z>>8),512&R.flags&&(ee[0]=255&Z,ee[1]=Z>>>8&255,R.check=a(R.check,ee,2,0)),$=Z=0,R.mode=5;case 5:if(1024&R.flags){for(;$<16;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.length=Z,R.head&&(R.head.extra_len=Z),512&R.flags&&(ee[0]=255&Z,ee[1]=Z>>>8&255,R.check=a(R.check,ee,2,0)),$=Z=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(M<(X=R.length)&&(X=M),X&&(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,O,H,X,N)),512&R.flags&&(R.check=a(R.check,O,X,H)),M-=X,H+=X,R.length-=X),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(M===0)break e;for(X=0;N=O[H+X++],R.head&&N&&R.length<65536&&(R.head.name+=String.fromCharCode(N)),N&&X<M;);if(512&R.flags&&(R.check=a(R.check,O,X,H)),M-=X,H+=X,N)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(M===0)break e;for(X=0;N=O[H+X++],R.head&&N&&R.length<65536&&(R.head.comment+=String.fromCharCode(N)),N&&X<M;);if(512&R.flags&&(R.check=a(R.check,O,X,H)),M-=X,H+=X,N)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;$<16;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(Z!==(65535&R.check)){k.msg="header crc mismatch",R.mode=30;break}$=Z=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),k.adler=R.check=0,R.mode=12;break;case 10:for(;$<32;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}k.adler=R.check=y(Z),$=Z=0,R.mode=11;case 11:if(R.havedict===0)return k.next_out=U,k.avail_out=z,k.next_in=H,k.avail_in=M,R.hold=Z,R.bits=$,2;k.adler=R.check=1,R.mode=12;case 12:if(L===5||L===6)break e;case 13:if(R.last){Z>>>=7&$,$-=7&$,R.mode=27;break}for(;$<3;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}switch(R.last=1&Z,$-=1,3&(Z>>>=1)){case 0:R.mode=14;break;case 1:if(E(R),R.mode=20,L!==6)break;Z>>>=2,$-=2;break e;case 2:R.mode=17;break;case 3:k.msg="invalid block type",R.mode=30}Z>>>=2,$-=2;break;case 14:for(Z>>>=7&$,$-=7&$;$<32;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if((65535&Z)!=(Z>>>16^65535)){k.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&Z,$=Z=0,R.mode=15,L===6)break e;case 15:R.mode=16;case 16:if(X=R.length){if(M<X&&(X=M),z<X&&(X=z),X===0)break e;i.arraySet(F,O,H,X,U),M-=X,H+=X,z-=X,U+=X,R.length-=X;break}R.mode=12;break;case 17:for(;$<14;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(R.nlen=257+(31&Z),Z>>>=5,$-=5,R.ndist=1+(31&Z),Z>>>=5,$-=5,R.ncode=4+(15&Z),Z>>>=4,$-=4,286<R.nlen||30<R.ndist){k.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(;$<3;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.lens[ae[R.have++]]=7&Z,Z>>>=3,$-=3}for(;R.have<19;)R.lens[ae[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ie={bits:R.lenbits},j=c(0,R.lens,0,19,R.lencode,0,R.work,ie),R.lenbits=ie.bits,j){k.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(;Se=(re=R.lencode[Z&(1<<R.lenbits)-1])>>>16&255,he=65535&re,!((me=re>>>24)<=$);){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(he<16)Z>>>=me,$-=me,R.lens[R.have++]=he;else{if(he===16){for(J=me+2;$<J;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(Z>>>=me,$-=me,R.have===0){k.msg="invalid bit length repeat",R.mode=30;break}N=R.lens[R.have-1],X=3+(3&Z),Z>>>=2,$-=2}else if(he===17){for(J=me+3;$<J;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}$-=me,N=0,X=3+(7&(Z>>>=me)),Z>>>=3,$-=3}else{for(J=me+7;$<J;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}$-=me,N=0,X=11+(127&(Z>>>=me)),Z>>>=7,$-=7}if(R.have+X>R.nlen+R.ndist){k.msg="invalid bit length repeat",R.mode=30;break}for(;X--;)R.lens[R.have++]=N}}if(R.mode===30)break;if(R.lens[256]===0){k.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ie={bits:R.lenbits},j=c(u,R.lens,0,R.nlen,R.lencode,0,R.work,ie),R.lenbits=ie.bits,j){k.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ie={bits:R.distbits},j=c(d,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ie),R.distbits=ie.bits,j){k.msg="invalid distances set",R.mode=30;break}if(R.mode=20,L===6)break e;case 20:R.mode=21;case 21:if(6<=M&&258<=z){k.next_out=U,k.avail_out=z,k.next_in=H,k.avail_in=M,R.hold=Z,R.bits=$,l(k,ye),U=k.next_out,F=k.output,z=k.avail_out,H=k.next_in,O=k.input,M=k.avail_in,Z=R.hold,$=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;Se=(re=R.lencode[Z&(1<<R.lenbits)-1])>>>16&255,he=65535&re,!((me=re>>>24)<=$);){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(Se&&(240&Se)==0){for(_e=me,q=Se,D=he;Se=(re=R.lencode[D+((Z&(1<<_e+q)-1)>>_e)])>>>16&255,he=65535&re,!(_e+(me=re>>>24)<=$);){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}Z>>>=_e,$-=_e,R.back+=_e}if(Z>>>=me,$-=me,R.back+=me,R.length=he,Se===0){R.mode=26;break}if(32&Se){R.back=-1,R.mode=12;break}if(64&Se){k.msg="invalid literal/length code",R.mode=30;break}R.extra=15&Se,R.mode=22;case 22:if(R.extra){for(J=R.extra;$<J;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.length+=Z&(1<<R.extra)-1,Z>>>=R.extra,$-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;Se=(re=R.distcode[Z&(1<<R.distbits)-1])>>>16&255,he=65535&re,!((me=re>>>24)<=$);){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if((240&Se)==0){for(_e=me,q=Se,D=he;Se=(re=R.distcode[D+((Z&(1<<_e+q)-1)>>_e)])>>>16&255,he=65535&re,!(_e+(me=re>>>24)<=$);){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}Z>>>=_e,$-=_e,R.back+=_e}if(Z>>>=me,$-=me,R.back+=me,64&Se){k.msg="invalid distance code",R.mode=30;break}R.offset=he,R.extra=15&Se,R.mode=24;case 24:if(R.extra){for(J=R.extra;$<J;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}R.offset+=Z&(1<<R.extra)-1,Z>>>=R.extra,$-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){k.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(z===0)break e;if(X=ye-z,R.offset>X){if((X=R.offset-X)>R.whave&&R.sane){k.msg="invalid distance too far back",R.mode=30;break}Y=X>R.wnext?(X-=R.wnext,R.wsize-X):R.wnext-X,X>R.length&&(X=R.length),ne=R.window}else ne=F,Y=U-R.offset,X=R.length;for(z<X&&(X=z),z-=X,R.length-=X;F[U++]=ne[Y++],--X;);R.length===0&&(R.mode=21);break;case 26:if(z===0)break e;F[U++]=R.length,z--,R.mode=21;break;case 27:if(R.wrap){for(;$<32;){if(M===0)break e;M--,Z|=O[H++]<<$,$+=8}if(ye-=z,k.total_out+=ye,R.total+=ye,ye&&(k.adler=R.check=R.flags?a(R.check,F,ye,U-ye):s(R.check,F,ye,U-ye)),ye=z,(R.flags?Z:y(Z))!==R.check){k.msg="incorrect data check",R.mode=30;break}$=Z=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;$<32;){if(M===0)break e;M--,Z+=O[H++]<<$,$+=8}if(Z!==(4294967295&R.total)){k.msg="incorrect length check",R.mode=30;break}$=Z=0}R.mode=29;case 29:j=1;break e;case 30:j=-3;break e;case 31:return-4;default:return h}return k.next_out=U,k.avail_out=z,k.next_in=H,k.avail_in=M,R.hold=Z,R.bits=$,(R.wsize||ye!==k.avail_out&&R.mode<30&&(R.mode<27||L!==4))&&P(k,k.output,k.next_out,ye-k.avail_out)?(R.mode=31,-4):(G-=k.avail_in,ye-=k.avail_out,k.total_in+=G,k.total_out+=ye,R.total+=ye,R.wrap&&ye&&(k.adler=R.check=R.flags?a(R.check,F,ye,k.next_out-ye):s(R.check,F,ye,k.next_out-ye)),k.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(G==0&&ye===0||L===4)&&j===f&&(j=-5),j)},o.inflateEnd=function(k){if(!k||!k.state)return h;var L=k.state;return L.window&&(L.window=null),k.state=null,f},o.inflateGetHeader=function(k,L){var R;return k&&k.state?(2&(R=k.state).wrap)==0?h:((R.head=L).done=!1,f):h},o.inflateSetDictionary=function(k,L){var R,O=L.length;return k&&k.state?(R=k.state).wrap!==0&&R.mode!==11?h:R.mode===11&&s(1,L,O,0)!==R.check?-3:P(k,L,O,O)?(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 v,b,I,w,A,T,x,_,E,P=y.bits,k=0,L=0,R=0,O=0,F=0,H=0,U=0,M=0,z=0,Z=0,$=null,G=0,ye=new i.Buf16(16),X=new i.Buf16(16),Y=null,ne=0;for(k=0;k<=15;k++)ye[k]=0;for(L=0;L<h;L++)ye[d[f+L]]++;for(F=P,O=15;1<=O&&ye[O]===0;O--);if(O<F&&(F=O),O===0)return p[m++]=20971520,p[m++]=20971520,y.bits=1,0;for(R=1;R<O&&ye[R]===0;R++);for(F<R&&(F=R),k=M=1;k<=15;k++)if(M<<=1,(M-=ye[k])<0)return-1;if(0<M&&(u===0||O!==1))return-1;for(X[1]=0,k=1;k<15;k++)X[k+1]=X[k]+ye[k];for(L=0;L<h;L++)d[f+L]!==0&&(g[X[d[f+L]]++]=L);if(T=u===0?($=Y=g,19):u===1?($=s,G-=257,Y=a,ne-=257,256):($=l,Y=c,-1),k=R,A=m,U=L=Z=0,I=-1,w=(z=1<<(H=F))-1,u===1&&852<z||u===2&&592<z)return 1;for(;;){for(x=k-U,E=g[L]<T?(_=0,g[L]):g[L]>T?(_=Y[ne+g[L]],$[G+g[L]]):(_=96,0),v=1<<k-U,R=b=1<<H;p[A+(Z>>U)+(b-=v)]=x<<24|_<<16|E|0,b!==0;);for(v=1<<k-1;Z&v;)v>>=1;if(v!==0?(Z&=v-1,Z+=v):Z=0,L++,--ye[k]==0){if(k===O)break;k=d[f+g[L]]}if(F<k&&(Z&w)!==I){for(U===0&&(U=F),A+=R,M=1<<(H=k-U);H+U<O&&!((M-=ye[H+U])<=0);)H++,M<<=1;if(z+=1<<H,u===1&&852<z||u===2&&592<z)return 1;p[I=Z&w]=F<<24|H<<16|A-m|0}}return Z!==0&&(p[A+Z]=k-U<<24|4194304),y.bits=F,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(re){for(var ee=re.length;0<=--ee;)re[ee]=0}var c=0,u=29,d=256,f=d+1+u,h=30,p=19,m=2*f+1,g=15,y=16,v=7,b=256,I=16,w=17,A=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],_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],E=[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 k=new Array(2*h);l(k);var L=new Array(512);l(L);var R=new Array(256);l(R);var O=new Array(u);l(O);var F,H,U,M=new Array(h);function z(re,ee,ae,fe,de){this.static_tree=re,this.extra_bits=ee,this.extra_base=ae,this.elems=fe,this.max_length=de,this.has_stree=re&&re.length}function Z(re,ee){this.dyn_tree=re,this.max_code=0,this.stat_desc=ee}function $(re){return re<256?L[re]:L[256+(re>>>7)]}function G(re,ee){re.pending_buf[re.pending++]=255&ee,re.pending_buf[re.pending++]=ee>>>8&255}function ye(re,ee,ae){re.bi_valid>y-ae?(re.bi_buf|=ee<<re.bi_valid&65535,G(re,re.bi_buf),re.bi_buf=ee>>y-re.bi_valid,re.bi_valid+=ae-y):(re.bi_buf|=ee<<re.bi_valid&65535,re.bi_valid+=ae)}function X(re,ee,ae){ye(re,ae[2*ee],ae[2*ee+1])}function Y(re,ee){for(var ae=0;ae|=1&re,re>>>=1,ae<<=1,0<--ee;);return ae>>>1}function ne(re,ee,ae){var fe,de,oe=new Array(g+1),ce=0;for(fe=1;fe<=g;fe++)oe[fe]=ce=ce+ae[fe-1]<<1;for(de=0;de<=ee;de++){var xe=re[2*de+1];xe!==0&&(re[2*de]=Y(oe[xe]++,xe))}}function me(re){var ee;for(ee=0;ee<f;ee++)re.dyn_ltree[2*ee]=0;for(ee=0;ee<h;ee++)re.dyn_dtree[2*ee]=0;for(ee=0;ee<p;ee++)re.bl_tree[2*ee]=0;re.dyn_ltree[2*b]=1,re.opt_len=re.static_len=0,re.last_lit=re.matches=0}function Se(re){8<re.bi_valid?G(re,re.bi_buf):0<re.bi_valid&&(re.pending_buf[re.pending++]=re.bi_buf),re.bi_buf=0,re.bi_valid=0}function he(re,ee,ae,fe){var de=2*ee,oe=2*ae;return re[de]<re[oe]||re[de]===re[oe]&&fe[ee]<=fe[ae]}function _e(re,ee,ae){for(var fe=re.heap[ae],de=ae<<1;de<=re.heap_len&&(de<re.heap_len&&he(ee,re.heap[de+1],re.heap[de],re.depth)&&de++,!he(ee,fe,re.heap[de],re.depth));)re.heap[ae]=re.heap[de],ae=de,de<<=1;re.heap[ae]=fe}function q(re,ee,ae){var fe,de,oe,ce,xe=0;if(re.last_lit!==0)for(;fe=re.pending_buf[re.d_buf+2*xe]<<8|re.pending_buf[re.d_buf+2*xe+1],de=re.pending_buf[re.l_buf+xe],xe++,fe===0?X(re,de,ee):(X(re,(oe=R[de])+d+1,ee),(ce=T[oe])!==0&&ye(re,de-=O[oe],ce),X(re,oe=$(--fe),ae),(ce=x[oe])!==0&&ye(re,fe-=M[oe],ce)),xe<re.last_lit;);X(re,b,ee)}function D(re,ee){var ae,fe,de,oe=ee.dyn_tree,ce=ee.stat_desc.static_tree,xe=ee.stat_desc.has_stree,ve=ee.stat_desc.elems,ue=-1;for(re.heap_len=0,re.heap_max=m,ae=0;ae<ve;ae++)oe[2*ae]!==0?(re.heap[++re.heap_len]=ue=ae,re.depth[ae]=0):oe[2*ae+1]=0;for(;re.heap_len<2;)oe[2*(de=re.heap[++re.heap_len]=ue<2?++ue:0)]=1,re.depth[de]=0,re.opt_len--,xe&&(re.static_len-=ce[2*de+1]);for(ee.max_code=ue,ae=re.heap_len>>1;1<=ae;ae--)_e(re,oe,ae);for(de=ve;ae=re.heap[1],re.heap[1]=re.heap[re.heap_len--],_e(re,oe,1),fe=re.heap[1],re.heap[--re.heap_max]=ae,re.heap[--re.heap_max]=fe,oe[2*de]=oe[2*ae]+oe[2*fe],re.depth[de]=(re.depth[ae]>=re.depth[fe]?re.depth[ae]:re.depth[fe])+1,oe[2*ae+1]=oe[2*fe+1]=de,re.heap[1]=de++,_e(re,oe,1),2<=re.heap_len;);re.heap[--re.heap_max]=re.heap[1],(function(Ae,Ce){var We,ot,pe,Te,Pe,we,Ne=Ce.dyn_tree,Q=Ce.max_code,Oe=Ce.stat_desc.static_tree,K=Ce.stat_desc.has_stree,be=Ce.stat_desc.extra_bits,Ue=Ce.stat_desc.extra_base,le=Ce.stat_desc.max_length,et=0;for(Te=0;Te<=g;Te++)Ae.bl_count[Te]=0;for(Ne[2*Ae.heap[Ae.heap_max]+1]=0,We=Ae.heap_max+1;We<m;We++)le<(Te=Ne[2*Ne[2*(ot=Ae.heap[We])+1]+1]+1)&&(Te=le,et++),Ne[2*ot+1]=Te,Q<ot||(Ae.bl_count[Te]++,Pe=0,Ue<=ot&&(Pe=be[ot-Ue]),we=Ne[2*ot],Ae.opt_len+=we*(Te+Pe),K&&(Ae.static_len+=we*(Oe[2*ot+1]+Pe)));if(et!==0){do{for(Te=le-1;Ae.bl_count[Te]===0;)Te--;Ae.bl_count[Te]--,Ae.bl_count[Te+1]+=2,Ae.bl_count[le]--,et-=2}while(0<et);for(Te=le;Te!==0;Te--)for(ot=Ae.bl_count[Te];ot!==0;)Q<(pe=Ae.heap[--We])||(Ne[2*pe+1]!==Te&&(Ae.opt_len+=(Te-Ne[2*pe+1])*Ne[2*pe],Ne[2*pe+1]=Te),ot--)}})(re,ee),ne(oe,ue,re.bl_count)}function N(re,ee,ae){var fe,de,oe=-1,ce=ee[1],xe=0,ve=7,ue=4;for(ce===0&&(ve=138,ue=3),ee[2*(ae+1)+1]=65535,fe=0;fe<=ae;fe++)de=ce,ce=ee[2*(fe+1)+1],++xe<ve&&de===ce||(xe<ue?re.bl_tree[2*de]+=xe:de!==0?(de!==oe&&re.bl_tree[2*de]++,re.bl_tree[2*I]++):xe<=10?re.bl_tree[2*w]++:re.bl_tree[2*A]++,oe=de,ue=(xe=0)===ce?(ve=138,3):de===ce?(ve=6,3):(ve=7,4))}function j(re,ee,ae){var fe,de,oe=-1,ce=ee[1],xe=0,ve=7,ue=4;for(ce===0&&(ve=138,ue=3),fe=0;fe<=ae;fe++)if(de=ce,ce=ee[2*(fe+1)+1],!(++xe<ve&&de===ce)){if(xe<ue)for(;X(re,de,re.bl_tree),--xe!=0;);else de!==0?(de!==oe&&(X(re,de,re.bl_tree),xe--),X(re,I,re.bl_tree),ye(re,xe-3,2)):xe<=10?(X(re,w,re.bl_tree),ye(re,xe-3,3)):(X(re,A,re.bl_tree),ye(re,xe-11,7));oe=de,ue=(xe=0)===ce?(ve=138,3):de===ce?(ve=6,3):(ve=7,4)}}l(M);var ie=!1;function J(re,ee,ae,fe){ye(re,(c<<1)+(fe?1:0),3),(function(de,oe,ce,xe){Se(de),xe&&(G(de,ce),G(de,~ce)),i.arraySet(de.pending_buf,de.window,oe,ce,de.pending),de.pending+=ce})(re,ee,ae,!0)}o._tr_init=function(re){ie||((function(){var ee,ae,fe,de,oe,ce=new Array(g+1);for(de=fe=0;de<u-1;de++)for(O[de]=fe,ee=0;ee<1<<T[de];ee++)R[fe++]=de;for(R[fe-1]=de,de=oe=0;de<16;de++)for(M[de]=oe,ee=0;ee<1<<x[de];ee++)L[oe++]=de;for(oe>>=7;de<h;de++)for(M[de]=oe<<7,ee=0;ee<1<<x[de]-7;ee++)L[256+oe++]=de;for(ae=0;ae<=g;ae++)ce[ae]=0;for(ee=0;ee<=143;)P[2*ee+1]=8,ee++,ce[8]++;for(;ee<=255;)P[2*ee+1]=9,ee++,ce[9]++;for(;ee<=279;)P[2*ee+1]=7,ee++,ce[7]++;for(;ee<=287;)P[2*ee+1]=8,ee++,ce[8]++;for(ne(P,f+1,ce),ee=0;ee<h;ee++)k[2*ee+1]=5,k[2*ee]=Y(ee,5);F=new z(P,T,d+1,f,g),H=new z(k,x,0,h,g),U=new z(new Array(0),_,0,p,v)})(),ie=!0),re.l_desc=new Z(re.dyn_ltree,F),re.d_desc=new Z(re.dyn_dtree,H),re.bl_desc=new Z(re.bl_tree,U),re.bi_buf=0,re.bi_valid=0,me(re)},o._tr_stored_block=J,o._tr_flush_block=function(re,ee,ae,fe){var de,oe,ce=0;0<re.level?(re.strm.data_type===2&&(re.strm.data_type=(function(xe){var ve,ue=4093624447;for(ve=0;ve<=31;ve++,ue>>>=1)if(1&ue&&xe.dyn_ltree[2*ve]!==0)return s;if(xe.dyn_ltree[18]!==0||xe.dyn_ltree[20]!==0||xe.dyn_ltree[26]!==0)return a;for(ve=32;ve<d;ve++)if(xe.dyn_ltree[2*ve]!==0)return a;return s})(re)),D(re,re.l_desc),D(re,re.d_desc),ce=(function(xe){var ve;for(N(xe,xe.dyn_ltree,xe.l_desc.max_code),N(xe,xe.dyn_dtree,xe.d_desc.max_code),D(xe,xe.bl_desc),ve=p-1;3<=ve&&xe.bl_tree[2*E[ve]+1]===0;ve--);return xe.opt_len+=3*(ve+1)+5+5+4,ve})(re),de=re.opt_len+3+7>>>3,(oe=re.static_len+3+7>>>3)<=de&&(de=oe)):de=oe=ae+5,ae+4<=de&&ee!==-1?J(re,ee,ae,fe):re.strategy===4||oe===de?(ye(re,2+(fe?1:0),3),q(re,P,k)):(ye(re,4+(fe?1:0),3),(function(xe,ve,ue,Ae){var Ce;for(ye(xe,ve-257,5),ye(xe,ue-1,5),ye(xe,Ae-4,4),Ce=0;Ce<Ae;Ce++)ye(xe,xe.bl_tree[2*E[Ce]+1],3);j(xe,xe.dyn_ltree,ve-1),j(xe,xe.dyn_dtree,ue-1)})(re,re.l_desc.max_code+1,re.d_desc.max_code+1,ce+1),q(re,re.dyn_ltree,re.dyn_dtree)),me(re),fe&&Se(re)},o._tr_tally=function(re,ee,ae){return re.pending_buf[re.d_buf+2*re.last_lit]=ee>>>8&255,re.pending_buf[re.d_buf+2*re.last_lit+1]=255&ee,re.pending_buf[re.l_buf+re.last_lit]=255&ae,re.last_lit++,ee===0?re.dyn_ltree[2*ae]++:(re.matches++,ee--,re.dyn_ltree[2*(R[ae]+d+1)]++,re.dyn_dtree[2*$(ee)]++),re.last_lit===re.lit_bufsize-1},o._tr_align=function(re){ye(re,2,3),X(re,b,P),(function(ee){ee.bi_valid===16?(G(ee,ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0):8<=ee.bi_valid&&(ee.pending_buf[ee.pending++]=255&ee.bi_buf,ee.bi_buf>>=8,ee.bi_valid-=8)})(re)}},{"../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(I){process.nextTick(function(){v(I)})}:(function(){if(s.postMessage&&!s.importScripts){var I=!0,w=s.onmessage;return s.onmessage=function(){I=!1},s.postMessage("","*"),s.onmessage=w,I}})()?(d="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(I){s.postMessage(d+I,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(I){v(I.data)},function(I){u.port2.postMessage(I)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(I){var w=m.createElement("script");w.onreadystatechange=function(){v(I),w.onreadystatechange=null,c.removeChild(w),w=null},c.appendChild(w)}):function(I){setTimeout(v,0,I)},g.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var w=new Array(arguments.length-1),A=0;A<w.length;A++)w[A]=arguments[A+1];return h[f]={callback:I,args:w},l(f),f++},g.clearImmediate=y}function y(I){delete h[I]}function v(I){if(p)setTimeout(v,0,I);else{var w=h[I];if(w){p=!0;try{(function(A){var T=A.callback,x=A.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)}})(w)}finally{y(I),p=!1}}}}function b(I){I.source===s&&typeof I.data=="string"&&I.data.indexOf(d)===0&&v(+I.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)})})),tNe=au(eNe(),1);const nNe=e=>/\.xml$|\.rels$/i.test(e);function scn(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 rNe(e){return e&&e.charCodeAt(0)===65279?e.slice(1):e}function oNe(e){if(typeof e=="string")return rNe(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=scn(t);let r=new TextDecoder(n).decode(t);return r=rNe(r),n!=="utf-8"&&(r=r.replace(/(<\?xml\b[^?]*?)\bencoding\s*=\s*["'][^"']*["']/i,'$1encoding="UTF-8"')),r}const ZK=[{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 acn=au($m(),1),lcn="SD_OPC_QUOT",ccn=/SD_OPC_QUOT/g;function ucn(e){return String(e).replace(/&quot;/g,lcn).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(ccn,"&quot;")}function iNe(e){return acn.js2xml(e,{spaces:0,attributeValueFn:ucn})}var dcn=au($m(),1),fcn="http://schemas.openxmlformats.org/package/2006/relationships";function QK(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 hcn(e,t,n){return QK(e,t,n)!=null}function sNe(e){try{return dcn.xml2js(e,{compact:!1})}catch{return null}}function aNe(e){return iNe(e)}function lNe(e,t){return e?.elements?.find(n=>n.name?(n.name.includes(":")?n.name.split(":").pop():n.name)===t:!1)}function cNe(){return{declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:fcn},elements:[]}]}}function pcn(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 mcn(e,t){e.elements||(e.elements=[]);const n=new Map;for(const i of ZK)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 gcn(e,t){e.elements||(e.elements=[]);const n=new Map;for(const s of ZK)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=pcn(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 uNe({baseFiles:e,updatedDocs:t}){const n=new Set;for(const c of ZK)hcn(c.zipPath,e,t)&&n.add(c.zipPath);const r=QK("[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=sNe(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=lNe(o,"Types");if(!i)throw new Error("syncPackageMetadata: [Content_Types].xml does not contain a <Types> root element.");mcn(i,n);const s=QK("_rels/.rels",e,t);let a;if(s==null)a=cNe();else if(a=sNe(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=lNe(a,"Relationships");return l||(a=cNe(),l=a.elements[0]),gcn(l,n),{contentTypesXml:aNe(o),relsXml:aNe(a)}}var ycn=au($m(),1);const dNe=[{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 bcn(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 vcn(e,t){if(!e)return e;let n;try{n=ycn.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=bcn(r.elements);for(const s of dNe)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?iNe(n):e}var wcn=xs({detectContainerType:()=>$K},1);function fNe(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 $K(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);return fNe(t,hNe)?"zip":fNe(t,pNe)?"cfb":"unknown"}var hNe,pNe,mNe=Re((()=>{hNe=[80,75,3,4],pNe=[208,207,17,224,161,177,26,225]}));function gNe(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 Acn(e,t){return(e+1)*t}function kE(e,t){return e.getUint16(t,!0)}function Ol(e,t){return e.getUint32(t,!0)}function Icn(e,t){const n=BigInt(e.getUint32(t,!0));return BigInt(e.getUint32(t+4,!0))<<32n|n}function Scn(e){return yNe.decode(e).replace(/\u0000+$/g,"")}var eY,Tcn,xcn,kcn,Ccn,Ecn,_cn,tY,Rcn,Pcn,CE,Lcn,Ncn,Mcn,yNe,Dcn=Re((()=>{eY=new Uint8Array([208,207,17,224,161,177,26,225]),Tcn=512,xcn=128,kcn=109,Ccn=512,Ecn=4096,_cn=4294967295,tY=4294967294,Rcn=4294967292,Pcn=4294967295,CE={STORAGE:1,STREAM:2,ROOT:5},Lcn=65534,Ncn=3,Mcn=4,yNe=new TextDecoder("utf-16le")}));function EE(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function bNe(e,t,n,r){if(t<0||n<0||t+n>e.length)throw new Error(`CFB ${r} exceeds available data`)}function Ocn(e){if(e.length<512)throw new Error(`CFB header is truncated (${e.length} bytes)`);for(let c=0;c<eY.length;c++)if(e[c]!==eY[c])throw new Error("Invalid CFB signature");const t=EE(e),n=kE(t,26),r=kE(t,28),o=kE(t,30),i=kE(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=Ol(t,76+c*4);u!==4294967295&&l.push(u)}return{sectorSize:s,miniSectorSize:a,numberOfFatSectors:Ol(t,44),firstDirectorySector:Ol(t,48),miniStreamCutoffSize:Ol(t,56),firstMiniFatSector:Ol(t,60),numberOfMiniFatSectors:Ol(t,64),firstDifatSector:Ol(t,68),numberOfDifatSectors:Ol(t,72),difatEntries:l}}function nY(e,t,n){if(n>=4294967292)throw new Error(`Invalid sector id 0x${n.toString(16)}`);const r=Acn(n,t.sectorSize);return bNe(e,r,t.sectorSize,`sector ${n}`),e.subarray(r,r+t.sectorSize)}function Fcn(e,t){const n=[...t.difatEntries];let r=t.firstDifatSector;for(let o=0;o<t.numberOfDifatSectors&&!(r===4294967294||r===4294967295);o++){const i=EE(nY(e,t,r)),s=t.sectorSize/4-1;for(let a=0;a<s;a++){const l=Ol(i,a*4);l!==4294967295&&n.push(l)}r=Ol(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 Bcn(e,t){const n=Fcn(e,t),r=[];for(const o of n){const i=EE(nY(e,t,o)),s=t.sectorSize/4;for(let a=0;a<s;a++)r.push(Ol(i,a*4))}return r}function V3(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const o=[],i=new Set;let s=r;for(;s!==tY;){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(nY(e,t,s));const a=n[s];if(a==null)throw new Error(`CFB FAT missing next sector for sector ${s}`);s=a}return gNe(o)}function Hcn(e,t){const n=Icn(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 zcn(e){const t=[];for(let n=0;n+128<=e.length;n+=128){const r=e.subarray(n,n+128),o=EE(r),i=kE(o,64),s=r.subarray(0,Math.max(0,Math.min(i,64)-2));t.push({name:Scn(s),objectType:r[66],leftSiblingId:Ol(o,68),rightSiblingId:Ol(o,72),childId:Ol(o,76),startSector:Ol(o,116),streamSize:Hcn(o,120)})}return t}function rY(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!!(rY(e,o.leftSiblingId,n,r)||n(o)===!0||rY(e,o.rightSiblingId,n,r))}function Ucn(e,t){const n=t.split("/").map(o=>o.trim()).filter(Boolean);let r=e[0];for(const o of n){if(r.objectType!==CE.ROOT&&r.objectType!==CE.STORAGE)return null;let i=null;if(rY(e,r.childId,s=>s.name.toLowerCase()===o.toLowerCase()?(i=s,!0):!1),!i)return null;r=i}return r}function Vcn(e,t,n,r){return e.streamSize===0||e.startSector===4294967294?new Uint8Array(0):V3(t,n,r,e.startSector).subarray(0,e.streamSize)}function Gcn(e,t,n){if(t.numberOfMiniFatSectors===0||t.firstMiniFatSector===4294967294)return[];const r=V3(e,t,n,t.firstMiniFatSector),o=EE(r),i=Math.floor(r.length/4),s=[];for(let a=0;a<i;a++)s.push(Ol(o,a*4));return s}function Wcn(e,t,n,r){if(r===4294967294||r===4294967295)return new Uint8Array(0);const o=[],i=new Set;let s=r;for(;s!==tY;){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;bNe(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 gNe(o)}function jcn(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=Ocn(t),r=Bcn(t,n),o=zcn(V3(t,n,r,n.firstDirectorySector));if(o.length===0||o[0].objectType!==CE.ROOT)throw new Error("CFB root directory entry is missing");const i=o[0],s=Gcn(t,n,r),a=Vcn(i,t,n,r);return{getStream(l){const c=Ucn(o,l);return!c||c.objectType!==CE.STREAM?null:c.streamSize<n.miniStreamCutoffSize?Wcn(a,s,n.miniSectorSize,c.startSector).subarray(0,c.streamSize):V3(t,n,r,c.startSector).subarray(0,c.streamSize)}}}var qcn=Re((()=>{Dcn()}));function Kcn(e){const t=e instanceof Uint8Array?e:new Uint8Array(e);let n;try{n=jcn(t)}catch(i){throw new cs(wa.DECRYPTION_FAILED,"Failed to parse OLE/CFB container",i instanceof Error?i:void 0)}const r=n.getStream("/EncryptionInfo");if(!r)throw new cs(wa.DECRYPTION_FAILED,"CFB container missing EncryptionInfo stream");const o=n.getStream("/EncryptedPackage");if(!o)throw new cs(wa.DECRYPTION_FAILED,"CFB container missing EncryptedPackage stream");return{encryptionInfo:r,encryptedPackage:o}}var Ycn=Re((()=>{qcn(),SE()}));function vNe(e,t){return e[t]|e[t+1]<<8}function oY(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 Xcn(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 EI(e,t,n){const r=e?.[t];if(r==null)throw new cs(wa.DECRYPTION_FAILED,`Missing required attribute "${t}" on <${n}>`);return r}function Wb(e,t,n){return Xcn(EI(e,t,n))}function _I(e,t,n){const r=parseInt(EI(e,t,n),10);if(Number.isNaN(r))throw new cs(wa.DECRYPTION_FAILED,`Invalid integer for attribute "${t}" on <${n}>`);return r}function Jcn(e){const t=new TextDecoder("utf-8").decode(e),n=oY(t,"keyData"),r=oY(t,"dataIntegrity"),o=oY(t,"encryptedKey");return{keySalt:Wb(n,"saltValue","keyData"),keyBits:_I(n,"keyBits","keyData"),hashAlgorithm:EI(n,"hashAlgorithm","keyData"),hashSize:_I(n,"hashSize","keyData"),blockSize:_I(n,"blockSize","keyData"),cipherAlgorithm:EI(n,"cipherAlgorithm","keyData"),cipherChaining:EI(n,"cipherChaining","keyData"),spinCount:_I(o,"spinCount","encryptedKey"),passwordSalt:Wb(o,"saltValue","encryptedKey"),passwordHashAlgorithm:EI(o,"hashAlgorithm","encryptedKey"),passwordKeyBits:_I(o,"keyBits","encryptedKey"),passwordBlockSize:_I(o,"blockSize","encryptedKey"),encryptedVerifierHashInput:Wb(o,"encryptedVerifierHashInput","encryptedKey"),encryptedVerifierHashValue:Wb(o,"encryptedVerifierHashValue","encryptedKey"),encryptedKeyValue:Wb(o,"encryptedKeyValue","encryptedKey"),encryptedHmacKey:Wb(r,"encryptedHmacKey","dataIntegrity"),encryptedHmacValue:Wb(r,"encryptedHmacValue","dataIntegrity")}}function Zcn(e){if(e.length<G3)throw new cs(wa.DECRYPTION_FAILED,`EncryptionInfo too short: ${e.length} bytes (minimum ${G3})`);const t=vNe(e,0),n=vNe(e,2);if(t===wNe&&n===ANe)return{type:"agile",params:Jcn(e.subarray(G3))};throw(t===INe||t===SNe)&&n===TNe?new cs(wa.ENCRYPTION_UNSUPPORTED,"Standard Encryption (Office 2007) is not yet supported. Only Agile Encryption (Office 2010+) is supported."):t<=2?new cs(wa.ENCRYPTION_UNSUPPORTED,"Legacy RC4 encryption is not supported. Only Agile Encryption (Office 2010+) is supported."):new cs(wa.ENCRYPTION_UNSUPPORTED,`Unrecognized EncryptionInfo version=${t} reserved=${n}`)}var wNe,ANe,INe,SNe,TNe,G3,Qcn=Re((()=>{SE(),wNe=4,ANe=4,INe=3,SNe=4,TNe=3,G3=8}));function iY(){const e=globalThis.crypto?.subtle;if(!e)throw new cs(wa.DECRYPTION_FAILED,"Web Crypto API (SubtleCrypto) is not available in this environment");return e}function _E(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 cs(wa.DECRYPTION_FAILED,`Unsupported hash algorithm: ${e}`);return t}function $cn(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 RI(...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 xNe(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 PI(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function LI(e,t){const n=await iY().digest(e,PI(t));return new Uint8Array(n)}async function NI(e,t,n){const r=iY(),o=16,i=await r.importKey("raw",PI(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:PI(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:PI(t)},i,c);return new Uint8Array(u).subarray(0,n.length)}async function sY(e,t,n,r,o,i){const s=_E(o);let a=await LI(s,RI(t,$cn(e)));for(let d=0;d<n;d++)a=await LI(s,RI(xNe(d),a));const l=await LI(s,RI(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 aY(e,t,n,r){let o;if(n?o=await LI(_E(e),RI(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 eun(e,t){const{passwordSalt:n,spinCount:r,passwordHashAlgorithm:o,passwordKeyBits:i,passwordBlockSize:s}=t,a=await sY(e,n,r,i,o,CNe),l=await sY(e,n,r,i,o,ENe),c=await sY(e,n,r,i,o,_Ne),u=await aY(o,n,void 0,s),d=await NI(a,u,t.encryptedVerifierHashInput),f=await NI(l,u,t.encryptedVerifierHashValue),h=await LI(_E(o),d);if(!kNe(h,f.subarray(0,h.length)))throw new cs(wa.PASSWORD_INVALID,"The password is incorrect");return NI(c,u,t.encryptedKeyValue)}function kNe(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 tun(e,t,n){const{keySalt:r,hashAlgorithm:o,blockSize:i}=t,s=_E(o);if(n.length<lY)throw new cs(wa.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(lY),c=Math.ceil(l.length/W3),u=[];for(let d=0;d<c;d++){const f=d*W3,h=Math.min(f+W3,l.length),p=l.subarray(f,h),m=await LI(s,RI(r,xNe(d))),g=await NI(e,m.length>=i?m.subarray(0,i):m,p);u.push(g)}return RI(...u).subarray(0,a)}async function nun(e,t,n){const{keySalt:r,hashAlgorithm:o,blockSize:i,hashSize:s}=t,a=_E(o),l=iY(),c=(await NI(e,await aY(o,r,RNe,i),t.encryptedHmacKey)).subarray(0,s),u=await NI(e,await aY(o,r,PNe,i),t.encryptedHmacValue),d=await l.importKey("raw",PI(c),{name:"HMAC",hash:a},!1,["sign"]),f=new Uint8Array(await l.sign("HMAC",d,PI(n)));if(!kNe(f,u.subarray(0,f.length)))throw new cs(wa.DECRYPTION_FAILED,"Data integrity check failed — the encrypted package may be corrupt or tampered with")}async function run(e,t,n){try{const r=await eun(e,t);return await nun(r,t,n),await tun(r,t,n)}catch(r){throw r instanceof cs?r:new cs(wa.DECRYPTION_FAILED,"Decryption failed unexpectedly",r instanceof Error?r:void 0)}}var CNe,ENe,_Ne,RNe,PNe,W3,lY,oun=Re((()=>{SE(),CNe=new Uint8Array([254,167,210,118,59,75,158,121]),ENe=new Uint8Array([215,170,15,109,48,97,52,78]),_Ne=new Uint8Array([20,110,11,231,171,172,208,214]),RNe=new Uint8Array([95,178,173,1,12,185,225,246]),PNe=new Uint8Array([160,103,127,2,178,44,132,51]),W3=4096,lY=8})),iun=xs({decryptDocxIfNeeded:()=>aun},1);function sun(e){if($K(e)!=="zip")throw new cs(wa.DECRYPTION_FAILED,"Decrypted output is not a valid ZIP archive — the file may be corrupt")}async function aun(e,t){const n=e instanceof Uint8Array?e:new Uint8Array(e),r=$K(n);if(r==="zip")return{data:n,wasEncrypted:!1};if(r==="unknown")throw new cs(wa.DECRYPTION_FAILED,"Unrecognized file format — expected a .docx (ZIP) or encrypted .docx (OLE/CFB)");if(!t?.password)throw new cs(wa.PASSWORD_REQUIRED,"This document is password-protected. A password is required to open it.");const o=Kcn(n),{params:i}=Zcn(o.encryptionInfo),s=await run(t.password,i,o.encryptedPackage);return sun(s),{data:s,wasEncrypted:!0}}var lun=Re((()=>{mNe(),Ycn(),Qcn(),oun(),SE()})),LNe=au($m(),1),cY=new Set(["png","jpg","jpeg","gif","bmp","tiff","tif","emf","wmf","svg","webp"]),uY={tif:"tiff",jpg:"jpeg",svg:"svg+xml"},cun="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",NNe={odttf:"application/vnd.openxmlformats-officedocument.obfuscatedFont",ttf:"application/x-font-ttf",otf:"application/vnd.ms-opentype"},uun=class{constructor(e={}){this.debug=e.debug||!1,this.zip=new tNe.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(()=>(mNe(),wcn)),o=r(await this.#e(e,8));let i=e;if(o==="cfb"){const{decryptDocxIfNeeded:l}=await Promise.resolve().then(()=>(lun(),iun)),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(nNe(c)){const u=oNe(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((!cY.has(d)||d==="tmp")&&(f=WP(u),f&&(d=f)),cY.has(d)){const h=uY[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(k=>this.getFileExtension(k)).filter(k=>k&&cY.has(k)),a=Object.entries(t).filter(([k])=>!this.getFileExtension(k)).map(([k,L])=>({name:k,contentType:this.#o(L)})).filter(k=>k.contentType),l="[Content_Types].xml";let c;n?Array.isArray(e.files)?c=e.files.find(k=>k.name===l)?.content||"":c=e.files?.[l]||"":c=await e.file(l).async("string");let u="";const d=ctt(c),f=new Set;for(let k of s){if(d.includes(k)||f.has(k))continue;const L=`<Default Extension="${k}" ContentType="image/${uY[k]||k}"/>`;u+=L,f.add(k)}if(o){const k=new Set(Object.keys(o).map(L=>this.getFileExtension(L)).filter(L=>L&&NNe[L]));for(const L of k)d.includes(L)||f.has(L)||(u+=`<Default Extension="${L}" ContentType="${NNe[L]}"/>`,f.add(L))}const h=JSON.parse(LNe.xml2json(c,null,2)).elements?.find(k=>k.name==="Types")||{},p=k=>h.elements?.some(L=>L.name==="Override"&&L.attributes.PartName===k);for(const{name:k,contentType:L}of a){const R=`/${k}`;p(R)||(u+=`<Override PartName="${R}" ContentType="${L}" />`)}const m=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/comments.xml"),g=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtended.xml"),y=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsIds.xml"),v=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/commentsExtensible.xml"),b=k=>r&&Object.prototype.hasOwnProperty.call(r,k)?r[k]!==null:e?.files?n&&Array.isArray(e.files)?e.files.some(L=>L.name===k):!!e.files[k]:!1;b("word/comments.xml")&&(m||(u+='<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />')),b("word/commentsExtended.xml")&&(g||(u+='<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />')),b("word/commentsIds.xml")&&(y||(u+='<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />')),b("word/commentsExtensible.xml")&&(v||(u+='<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />'));const I=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/footnotes.xml"),w=h.elements?.some(k=>k.name==="Override"&&k.attributes.PartName==="/word/endnotes.xml");b("word/footnotes.xml")&&(I||(u+='<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />')),b("word/endnotes.xml")&&(w||(u+='<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />'));for(const k of dNe)b(k.zipPath)&&!p(`/${k.zipPath}`)&&(u+=`<Override PartName="/${k.zipPath}" ContentType="${k.contentType}" />`);const A=new Set(i);e?.files&&(n&&Array.isArray(e.files)?e.files.forEach(k=>A.add(k.name)):Object.keys(e.files).forEach(k=>A.add(k))),A.forEach(k=>{if(!/^customXml\/itemProps\d+\.xml$/i.test(k)||!b(k))return;const L=`/${k}`;p(L)||(u+=`<Override PartName="${L}" ContentType="${cun}" />`)}),A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer"))return;const L=h.elements?.some(O=>O.name==="Override"&&O.attributes.PartName===`/${k}`),R=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;L||(u+=R)});const T=tW.map(k=>`/word/${k}`).filter(k=>!b(k.slice(1))),x="application/vnd.openxmlformats-officedocument.customXmlProperties+xml";if(h?.elements?.length)for(const k of h.elements){if(k?.name!=="Override"||k?.attributes?.ContentType!==x)continue;const L=k?.attributes?.PartName;typeof L!="string"||!L.startsWith("/")||b(L.slice(1))||T.push(L)}const _='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';let E=c.replace(_,`${_}${u}`);for(const k of T){const L=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=new RegExp(`\\s*<Override[^>]*PartName="${L}"[^>]*/>`,"g");E=E.replace(R,"")}let P=r["word/_rels/document.xml.rels"];if(P||(n?Array.isArray(e.files)?P=e.files.find(k=>k.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{LNe.xml2js(P,{compact:!1}).elements?.find(k=>k.name==="Relationships")?.elements?.forEach(k=>{const L=k.attributes?.Type,R=k.attributes?.Target;if(!L||!R)return;const O=L.includes("/header"),F=L.includes("/footer");if(!O&&!F)return;let H=R.replace(/^\.\//,"");H.startsWith("../")&&(H=H.slice(3)),H.startsWith("/")&&(H=H.slice(1));const U=H.startsWith("word/")?H:`word/${H}`;A.add(U)})}catch(k){console.warn("Failed to parse document relationships while updating content types",k)}if(A.forEach(k=>{if(k.includes(".rels")||!k.includes("header")&&!k.includes("footer")||E.includes(`PartName="/${k}"`))return;const L=`<Override PartName="/${k}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${k.includes("header")?"header":"footer"}+xml"/>`;E=E.replace("</Types>",`${L}</Types>`)}),P){const k=vcn(P,b);k!==P&&(n?r["word/_rels/document.xml.rels"]=k:e.file("word/_rels/document.xml.rels",k))}if(n)return E;e.file(l,E)}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}=uNe({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:Lc,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 tNe.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"?kx(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,nNe(a.name)?oNe(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=WP(new Uint8Array(e)):ArrayBuffer.isView(e)?t=WP(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):typeof e=="string"&&(t=WP(e.startsWith("data:")?e.split(",",2)[1]:e)),t?`image/${uY[t]||t}`:null}},dY=uun;const dun=(e,t)=>{const{doc:n}=e.state,r=n.nodeAt(t);if(r&&r.type.name==="image"){const o=e.state.tr.setSelection(yn.create(n,t));return e.dispatch(o),!0}return!1};function fun(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 RE=(...e)=>{};const hun=e=>{const t=[];if(RE("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=j3(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);RE("NODES TO INSERT",h),a=a.replaceWith(c,u,h)}return a.setMeta("listsv2migration",t),e.options.migrated=!0,o(a),t};function j3(e,t,n=0,r=null){const o=[],i=["orderedList","bulletList"],s=e.type.name,a=pun(e),l=mun(e,t);if(RE("Needs migration?",a),!a)return l?o:gun(e,t);let c=parseInt(e.attrs?.listId);RE("LIST ID",c,"SHARED NUM ID",r),(!c||Number.isNaN(c))&&(c=jn.getNewListId(t)),(!jn.getListDefinitionDetails({numId:c,level:n,editor:t})||!r&&!c)&&(c=jn.getNewListId(t),RE("Genearted new list ID",c,"for list type",s),jn.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=j3(d,t,n+1,r);o.push(...f)}else{const f=jn.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=j3(d,t,n+1,r);o.push(...f)}else if(d.type.name==="paragraph"||d.isTextblock){const f=jn.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=j3(f,t,n+1,r);o.push(...h)}else o.push({node:f})}return o}var pun=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},mun=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:o,level:i}=r||{},{abstract:s}=jn.getListDefinitionDetails({numId:o,level:i,listType:n,editor:t})||{};return!!s},gun=(e,t)=>{const n=e.type.name,{attrs:r}=e.content.firstChild,{numId:o}=r||{};return jn.generateNewListDefinition({numId:o,listType:n,editor:t})};const yun=async(e=[],t)=>{const n=Eu(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},bun=(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:vun,...t,isChildEditor:!0,parentEditor:e});var vun=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 MNe(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=>MNe(e,[...t,a])}}function wun(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=sb(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 Aun({editor:e,logger:t}){const n=(r,o)=>{const i=[wun(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 Iun(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=sb(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 Sun({editor:e,logger:t}){const n=(r,o)=>{const i=[Iun(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 Tun={imageNodeValidator:Aun,linkMarkValidator:Sun};function xun({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 DNe(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 DNe(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&&DNe(r,t)}n.push(r)}e.elements=n}function kun({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}=Cun(o,n);if(!i)return{results:n,modified:r};s&&(r=!0);const{root:a,wasFixed:l}=Eun(o[i],i,n);if(!a)return{results:n,modified:r};l&&(r=!0),_un(a)&&(r=!0);const{filteredIds:c,binMediaTargets:u,wasProcessed:d}=Run(a,o,n);d&&(r=!0),Pun(o,c,n,t)&&(r=!0);const f=o["[Content_Types].xml"];return u.size>0||f?Lun(o,u,n)&&(r=!0):n.push("[Content_Types].xml not found or not parseable. Skipped content types patch."),{results:n,modified:r}}}function Cun(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 Eun(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 _un(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 Run(e,t,n){const r=new Set,o=new Set;let i=!1;const s=v=>{const b=/^rId(\d+)$/.exec(String(v||""));return b?parseInt(b[1],10):null},a=(v,b)=>typeof v=="string"&&new RegExp(`/relationships/${b}$`,"i").test(v),l=v=>a(v,"hyperlink"),c=v=>a(v,"image"),u=v=>/^https?:\/\//i.test(v||"")||/^mailto:/i.test(v||""),d=new Set;let f=0;for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes.Id,I=s(b);Number.isInteger(I)&&(f=Math.max(f,I)),typeof b=="string"&&b&&d.add(b)}let h=f;const p=v=>{if(v&&!d.has(v))return d.add(v),v;let b;do h+=1,b=`rId${h}`;while(d.has(b));return d.add(b),b},m=new Set,g=[];function y(v,b){return typeof v[b]=="string"?v[b].trim():""}for(const v of e.elements){v.attributes=v.attributes||{};const b=v.attributes;let I=y(b,"Id");const w=y(b,"Type");let A=y(b,"Target"),T=y(b,"TargetMode");if(!A){n.push(`Removed relationship "${I}" without Target`),i=!0;continue}if(l(w)&&u(A)&&T.toLowerCase()!=="external"&&(b.TargetMode="External",T="External",n.push(`Set TargetMode="External" for hyperlink ${I}`),i=!0),c(w)){const x=Ap(A,"word");x&&/^media\/.+\.bin$/i.test(A)&&x in t&&r.add(`/${x}`)}if(T.toLowerCase()!=="external"&&!u(A)&&!(Ap(A,"word")in t))if(c(w))n.push(`Warning: image relationship ${I} target not found: ${A}.`);else{n.push(`Removed relationship ${I} with missing target: ${A}`),i=!0;continue}if(!I){const x=p(null);b.Id=x,n.push(`Assigned missing Id "${x}"`),i=!0,I=x}if(m.has(I)){n.push(`Removed duplicate relationship with ID "${I}"`),i=!0;continue}m.add(I),g.push(v)}(e.elements.length!==g.length||e.elements.some((v,b)=>v!==g[b]))&&(e.elements=g,i=!0);for(const v of e.elements){const b=v.attributes?.Id;typeof b=="string"&&b&&o.add(b)}return{filteredIds:o,binMediaTargets:r,wasProcessed:i}}function Pun(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(ONe(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 Lun(e,t,n){const r="[Content_Types].xml",o=e[r];return typeof o=="string"?Nun(o,t,n,e,r):o?.elements?.length?Mun(o,t,n):!1}function Nun(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 Mun(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 ONe(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}"`)),ONe(r,t,n)}}const Dun={numberingValidator:xun,relationshipsValidator:kun};var FNe=class{#e;#t;#o;#n;#r;constructor(e){this.#e=e.editor,this.dryRun=e.dryRun||!1,this.debug=e.debug||!1,this.logger=MNe(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.#l(a,e,t),[o,a]}));return{stateValidators:n(Tun),xmlValidators:n(Dun),nodeTypes:e,markTypes:t}}#l(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)}},q3=null;const MI=()=>{if(q3!==null)return q3;try{const e=typeof globalThis<"u"&&typeof globalThis.window<"u"&&typeof globalThis.document<"u"&&typeof globalThis.document.createElement=="function";return q3=e,e}catch{return q3=!1,!1}};function K3(e){return e.replace(/\r\n?/g,`
401
401
  `).split(`
402
- `).map(t=>({type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}]}]}))}var Oun="1.37.0-next.2",Fun=["group","content","marks","inline","atom","defining","code","tableRole","summary"],Bun=["group","inclusive","excludes","spanning","code"];function BNe(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 HNe(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function Hun(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:BNe(s.attrs),...HNe(s,Fun)})});const o=[];return e.spec.marks.forEach((i,s)=>{o.push({name:i,attrs:BNe(s.attrs),...HNe(s,Bun)})}),{version:Oun,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:o}}const zun=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=Vun(i),a=Gun(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",Uun(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("")},Uun=(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 Vun(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const Gun=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var Wun=/^Heading[1-9]$/i;function jun(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"||!Wun.test(c))return e;const u=i.type.create(i.attrs,e.content,i.marks);return new Dt(kt.from(u),0,0)}var qun=1,Kun=10,Yun=150,Xun=1.2,Jun=1,Zun=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),Qun="span.sd-paragraph-content",zNe="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",$un='<meta name="Generator" content="Microsoft Word">',edn=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function UNe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(zNe))return r}n=n.parentNode}return null}function tdn(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(zNe)}function ndn(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 rdn(e,t){const n=e.cloneContents();if(tdn(n))return n;const r=UNe(e.startContainer,t.dom),o=UNe(e.endContainer,t.dom);if(!r||r!==o)return n;const i=r.cloneNode(!1),s=ndn(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 odn(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 idn(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 sdn(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=odn(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 adn(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 ldn(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 cdn(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 udn(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=edn.get(c)||"decimal",d=o.getAttribute("data-marker-type")||o.getAttribute("data-lvl-text")||"1.",f=ldn(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=adn(o.getAttribute("data-list-level")),y=g[i]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;o.prepend(cdn(v))}),`${$un}<style>${n.join(`
402
+ `).map(t=>({type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}]}]}))}var Oun="1.37.0-next.3",Fun=["group","content","marks","inline","atom","defining","code","tableRole","summary"],Bun=["group","inclusive","excludes","spanning","code"];function BNe(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 HNe(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]).filter(([,n])=>n!==void 0))}function Hun(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:BNe(s.attrs),...HNe(s,Fun)})});const o=[];return e.spec.marks.forEach((i,s)=>{o.push({name:i,attrs:BNe(s.attrs),...HNe(s,Bun)})}),{version:Oun,schemaVersion:n,topNode:e.topNodeType?.name,nodes:r,marks:o}}const zun=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=Vun(i),a=Gun(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",Uun(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("")},Uun=(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 Vun(e){return Array.from(e.childNodes).find(t=>t.nodeType===Node.ELEMENT_NODE)||null}const Gun=e=>{const t=e.getAttribute("data-level");return t?parseInt(t,10):0};var Wun=/^Heading[1-9]$/i;function jun(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"||!Wun.test(c))return e;const u=i.type.create(i.attrs,e.content,i.marks);return new Dt(kt.from(u),0,0)}var qun=1,Kun=10,Yun=150,Xun=1.2,Jun=1,Zun=[".list-marker",".sd-editor-tab",".ProseMirror-trailingBreak"].join(", "),Qun="span.sd-paragraph-content",zNe="p, div, h1, h2, h3, h4, h5, h6, blockquote, table",$un='<meta name="Generator" content="Microsoft Word">',edn=new Map([["decimal","decimal"],["lowerLetter","alpha-lower"],["upperLetter","alpha-upper"],["lowerRoman","roman-lower"],["upperRoman","roman-upper"],["bullet","bullet"]]);function UNe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeType===Node.ELEMENT_NODE){const r=n;if(r.matches(zNe))return r}n=n.parentNode}return null}function tdn(e){const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),!!t.querySelector(zNe)}function ndn(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 rdn(e,t){const n=e.cloneContents();if(tdn(n))return n;const r=UNe(e.startContainer,t.dom),o=UNe(e.endContainer,t.dom);if(!r||r!==o)return n;const i=r.cloneNode(!1),s=ndn(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 odn(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 idn(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 sdn(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=odn(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 adn(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 ldn(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 cdn(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 udn(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=edn.get(c)||"decimal",d=o.getAttribute("data-marker-type")||o.getAttribute("data-lvl-text")||"1.",f=ldn(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=adn(o.getAttribute("data-list-level")),y=g[i]??g[g.length-1]??1,v=c==="bullet"?d:`${d}`.trim()||`${y}.`;o.prepend(cdn(v))}),`${$un}<style>${n.join(`
403
403
  `)}</style>${t.innerHTML}`}function VNe(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 ddn(e,t){const n=VNe(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(rdn(s,e)),o=!0)}return o?(r.querySelectorAll(Zun).forEach(i=>{i.parentNode?.removeChild(i)}),r.querySelectorAll(Qun).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")}),Akt(r,e,t),idn(r),sdn(r,e),udn(r)||r.innerHTML||null):null}var GNe=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 t0e(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(!MI()){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"),w3(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(Jun):String(Xun),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=`${qun}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-Kun;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},Yun)};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||!MI())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=jun(this.view.state.doc.slice(i,s),this.view.state);a=JSON.stringify(g.toJSON()),o.setData("application/x-superdoc-slice",a),l=lbe(a,e),l&&o.setData(abe,l)}const c=ddn(this.view,e),u=this.view.state.doc.attrs?.bodySectPr,d=u&&dbe(u)?JSON.stringify(u):"";if(c){o.setData("text/html",gV(c,a,d,l)),o.setData("text/plain",VNe(this.view.root)?.toString()??"");return}const f=this.view.state.doc.slice(i,s).content,h=document.createElement("div"),p=eh.fromSchema(this.view.state.schema);h.appendChild(p.serializeFragment(f)),yV(h,f,e);const m=zun(h.innerHTML);o.setData("text/html",gV(m,a,d,l)),o.setData("text/plain",this.view.state.doc.textBetween(i,s,`
404
404
  `))}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 fdn="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 PE(e){return LE(e)}function WNe(e){return XNe(e)}function jNe(e,t){const{nodeType:n,anchor:r,attrs:o}=t,i=qNe(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 hdn(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 qNe(e,t){try{const n=e.state.doc;let r="";return n.descendants((o,i)=>{if(hdn(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 pdn(e,t){const n=e.state.doc,r=[];n.forEach(s=>{r.push(LE(s))});const o=mdn(e),i=bdn(e);return{modelVersion:"sdm/1",body:r,...o.length>0&&{sections:o},...i&&{numbering:i}}}function mdn(e){let t;try{t=oa(e)}catch{return[]}return t.map(n=>gdn(n.domain))}function gdn(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 ydn=new Set(["bullet"]);function bdn(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&&ydn.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 LE(e){const t=e.type.name;switch(t){case"paragraph":return vdn(e);case"heading":return wdn(e);case"table":return Idn(e);case"bulletList":case"orderedList":return xdn(e,t==="orderedList");case"listItem":return Cdn(e);case"image":return Edn(e);case"tableOfContents":return _dn(e);case"sdt":case"structuredContentBlock":return Pdn(e);case"sectionBreak":return Ndn(e);case"pageBreak":case"horizontalRule":return Mdn(e);case"drawing":return Ddn(e);default:return Odn(e)}}function vdn(e){const t=e.attrs,n=_A(t?.paragraphProperties?.styleId);return n&&n>=1&&n<=6?KNe(e,t,n):Adn(e,t)}function wdn(e){const t=e.attrs;return KNe(e,t,e.attrs?.level??_A(t?.paragraphProperties?.styleId)??1)}function Adn(e,t){const n=NE(e),r={kind:"paragraph",id:Tf(e),paragraph:{inlines:n}},o=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;o&&(r.paragraph.styleRef=o);const i=QNe(t);return i&&(r.paragraph.props=i),r}function KNe(e,t,n){const r=NE(e),o={kind:"heading",id:Tf(e),heading:{level:n,inlines:r}},i=t?.paragraphProperties?.styleId??e.attrs?.paragraphStyle;i&&(o.heading.styleRef=i);const s=QNe(t);return s&&(o.heading.props=s),o}function Idn(e){const t=e.attrs,n=e.attrs,r=[];e.forEach(l=>{l.type.name==="tableRow"&&r.push(Sdn(l))});const o={kind:"table",id:Tf(e),table:{rows:r}},i=t?.tableProperties?.tableStyleId??n?.tableStyleId;i&&(o.table.styleRef=i);const s=Ydn(t,n);s&&(o.table.props=s);const a=n?.grid??n?.tableGridModel??t?.tableGrid?.colWidths;if(a&&Array.isArray(a)){const l=a.map(c=>typeof c=="number"?c:c?.col??c?.width).filter(c=>typeof c=="number"&&Number.isFinite(c)).map(c=>({width:c}));l.length>0&&(o.table.columns=l)}if(n?.needsTableStyleNormalization===!0){const l=fY(o.ext)?{...o.ext}:{},c=fY(l.superdoc)?{...l.superdoc}:{};c.needsTableStyleNormalization=!0,o.ext={...l,superdoc:c}}return o}function Sdn(e){const t=[];e.forEach(o=>{(o.type.name==="tableCell"||o.type.name==="tableHeader")&&t.push(Tdn(o))});const n={cells:t},r=e.attrs;return(r?.minHeight!==void 0||r?.cantSplit!==void 0)&&(n.props={},r.minHeight!==void 0&&(n.props.minHeight=r.minHeight),r.cantSplit!==void 0&&(n.props.cantSplit=r.cantSplit)),n}function Tdn(e){const t=e.attrs,n=[];e.forEach(i=>{n.push(LE(i))});const r={content:n};t?.colspan&&t.colspan>1&&(r.colSpan=t.colspan),t?.rowspan&&t.rowspan>1&&(r.rowSpan=t.rowspan);const o=t?.tableCellProperties?.vAlign??t?.verticalAlign;return o&&(r.props={verticalAlign:o}),r}function xdn(e,t){const n=[];e.forEach(i=>{i.type.name==="listItem"&&n.push(kdn(i))});const r={kind:"list",id:Tf(e),list:{items:n,levels:[{level:0,kind:t?"ordered":"bullet"}]}},o=e.attrs;return o?.listStyleId&&(r.list.styleRef=o.listStyleId),r}function kdn(e){const t=[];return e.forEach(n=>{t.push(LE(n))}),{level:e.attrs?.level??0,content:t}}function Cdn(e){const t=NE(e);return{kind:"paragraph",id:Tf(e),paragraph:{inlines:t}}}function Edn(e){const t=e.attrs;return{kind:"image",id:Tf(e),image:{src:t?.src??"",...t?.alt?{alt:t.alt}:{},...t?.size?{geometry:{width:t.size.width,height:t.size.height}}:{}}}}function _dn(e){const t=e.attrs?.instruction??"",n=Nb(t);return{kind:"toc",id:Tf(e),toc:{...t?{instruction:t}:{},...n.source?{sourceConfig:n.source}:{},...n.display?{displayConfig:n.display}:{},...n.preserved?{preservedSwitches:n.preserved}:{},entryCount:e.childCount}}}var Rdn={unlocked:"none",sdtLocked:"sdt",contentLocked:"content",sdtContentLocked:"both"};function YNe(e){const t=Rdn[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 Pdn(e){const t=[];return e.forEach(n=>{t.push(LE(n))}),{kind:"sdt",id:ZNe(e),sdt:{...YNe(e.attrs??{}),scope:"block",...t.length>0?{content:t}:{}}}}function Ldn(e){const t=NE(e);return{kind:"sdt",id:ZNe(e),sdt:{...YNe(e.attrs??{}),scope:"inline",...t.length>0?{inlines:t}:{}}}}function Ndn(e){return{kind:"sectionBreak",id:Tf(e),sectionBreak:{targetSectionId:e.attrs?.targetSectionId??""}}}function Mdn(e){const t=e.attrs?.breakType??"page";return{kind:"break",id:Tf(e),break:{type:t==="column"?"column":"page"}}}function Ddn(e){return{kind:"drawing",id:Tf(e),drawing:{source:e.attrs?.source??{type:"unknown"},...e.attrs?.geometry?{geometry:e.attrs.geometry}:{},...e.attrs?.layout?{layout:e.attrs.layout}:{}}}}function Odn(e){const t=NE(e);return{kind:"paragraph",id:Tf(e),paragraph:{inlines:t}}}function NE(e){const t=[];return e.forEach(n=>{const r=XNe(n);t.push(r)}),t}function XNe(e){if(e.isText)return Hdn(e);switch(e.type.name){case"run":return Fdn(e);case"image":return Udn(e);case"tab":return Vdn();case"hardBreak":case"lineBreak":return Gdn();case"footnoteRef":case"footnoteReference":return Wdn(e);case"endnoteRef":case"endnoteReference":return jdn(e);case"field":return qdn(e);case"structuredContent":return Ldn(e);default:return Kdn(e)}}function Fdn(e){const t=(e.attrs??{}).runProperties,n=e.textContent;let r;if(e.forEach(a=>{r||(r=a.marks?.find(l=>l.type.name==="link"))}),r)return Bdn(e,r);const o={kind:"run",run:{text:n}},i=typeof t?.rStyle=="string"?t.rStyle:typeof t?.styleId=="string"?t.styleId:void 0;i&&(o.run.styleRef=i);const s=JNe(t);return s&&(o.run.props=s),o}function Bdn(e,t){const n=t.attrs,r={kind:"run",run:{text:e.textContent}},o=e.attrs?.runProperties,i=JNe(o);return i&&(r.run.props=i),{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 JNe(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 Hdn(e){const t=e.marks,n=t.find(s=>s.type.name==="link");if(n)return zdn(e,n);const r={kind:"run",run:{text:e.text??""}},o=Zdn(t);o&&(r.run.styleRef=o);const i=Qdn(t);return i&&(r.run.props=i),r}function zdn(e,t){const n=t.attrs,r={kind:"run",run:{text:e.text??""}},o=e.marks.filter(a=>a!==t),i=eMe(o);i&&(r.run.props=i);const s=$Ne(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 Udn(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 Vdn(){return{kind:"tab",tab:{}}}function Gdn(){return{kind:"lineBreak",lineBreak:{}}}function Wdn(e){return{kind:"footnoteRef",footnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function jdn(e){return{kind:"endnoteRef",endnoteRef:{...e.attrs?.id?{noteId:e.attrs.id}:{},...e.attrs?.noteId?{noteId:e.attrs.noteId}:{}}}}function qdn(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 Kdn(e){return{kind:"run",run:{text:e.textContent??""}}}function Tf(e){const t=e.attrs?.sdBlockId;return typeof t=="string"&&t.length>0?t:void 0}function ZNe(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 fY(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ydn(e,t){const n=e?.tableProperties,r={};let o=!1;const i=Jdn(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=Xdn(n?.justification??t?.justification);return a&&(r.alignment=a,o=!0),o?r:void 0}function Xdn(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 Jdn(e){if(!fY(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 QNe(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 Zdn(e){return $Ne(e)}function $Ne(e){const t=e.find(n=>n.type.name==="textStyle");if(t)return typeof t.attrs?.rStyle=="string"?t.attrs.rStyle:void 0}function Qdn(e){return eMe(e)}function eMe(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 $dn(e,t){return pdn(e,t.options)}function Y3(e){if(typeof e=="number")return e;if(e&&typeof e=="object"&&typeof e.value=="number")return e.value}function efn(e){switch(e){case"start":return"left";case"end":return"right";case"left":case"center":case"right":return e;default:return}}function hY(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:gM(t.numberingProperties.numId),level:gM(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 tfn(e){const t=PP(e?.listRendering);if(!t)return;const n={};return t.markerText&&(n.marker=t.markerText),Array.isArray(t.path)&&(n.path=t.path),n.ordinal=F4(t.path),Object.keys(n).length?n:void 0}function nfn(e){const t=e.node.attrs;return{nodeType:"paragraph",kind:"block",properties:hY(t)}}function rfn(e){const t=e.node.attrs,n=hY(t),r=_A(t?.paragraphProperties?.styleId)??(n.outlineLevel!=null?n.outlineLevel+1:void 0);if(!r||r<1||r>6)throw new De("INVALID_TARGET",`Node "${e.nodeId}" does not have a valid heading level.`);return{nodeType:"heading",kind:"block",properties:{...n,headingLevel:r}}}function ofn(e){const t=e.node.attrs;return{nodeType:"listItem",kind:"block",properties:{...hY(t),numbering:tfn(t)}}}function ifn(e){const t=e.node.attrs?.tableProperties??void 0;return{nodeType:"table",kind:"block",properties:{layout:t?.tableLayout??void 0,width:Y3(t?.tableWidth??null)??void 0,alignment:efn(t?.justification)}}}function sfn(){return{nodeType:"tableRow",kind:"block",properties:{}}}function afn(e){const t=e.node.attrs,n=t?.tableCellProperties??void 0;return{nodeType:"tableCell",kind:"block",properties:{width:Y3(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:Y3(n?.cellMargins?.top??null)??Y3(t?.cellMargins?.top??null)}}}function lfn(e){const t=e.node,n=t.attrs?.instruction??"",r=Nb(n),o=t.childCount;return{nodeType:"tableOfContents",kind:"block",properties:{instruction:n,sourceConfig:r.source,displayConfig:r.display,preservedSwitches:r.preserved,entryCount:o}}}function cfn(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 ufn(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 dfn(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:cfn(e?.clipPath),lockAspectRatio:e?.lockAspectRatio??!0,decorative:e?.decorative??!1,hyperlink:e?.hyperlink??null,hasCaption:r!=null?ufn(n,r):!1}}}function ffn(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 hfn(e){const t=yM(e.mark?.attrs??e.attrs??{});if(!t)throw new De("INVALID_TARGET","Comment node is missing a commentId attribute.");return{nodeType:"comment",kind:"inline",properties:{commentId:t}}}function pfn(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 mfn(e){const t=e.node?.attrs??e.attrs??{};return{nodeType:"footnoteRef",kind:"inline",properties:{noteId:typeof t.id=="string"?t.id:void 0}}}function gfn(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 DI(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="string")return gfn(e);if(e&&typeof e=="object"){const t=e,n=DI(t.val??t.value??t.type??t["w:val"]??t["w:value"]);return n??!0}}function yfn(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=DI(t);if(n!=null)return n}}function bfn(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 vfn(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 wfn(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 Afn(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 Ifn(e){const t=e.node?.attrs??e.attrs??{},n=t.runProperties&&typeof t.runProperties=="object"?t.runProperties:void 0,r=yfn([n?.underline,n?.u]),o=DI(n?.strike)??DI(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:DI(n?.bold)??void 0,italic:DI(n?.italic)??void 0,underline:r??void 0,strike:o,font:n?wfn(n):void 0,size:n?Afn(n):void 0,color:bfn(n?.color),highlight:vfn(n?.highlight),styleId:typeof n?.rStyle=="string"?n.rStyle:typeof n?.styleId=="string"?n.styleId:void 0,language:s}}}function Sfn(){return{nodeType:"tab",kind:"inline",properties:{}}}function Tfn(){return{nodeType:"lineBreak",kind:"inline",properties:{}}}function OI(e){return"anchor"in e}function tMe(e,t,n){const r=t??e.nodeType,o=OI(e)?"inline":"block";switch(r){case"paragraph":if(o!=="block")throw new De("INVALID_TARGET","Paragraph nodes can only be resolved as blocks.");return nfn(e);case"heading":if(o!=="block")throw new De("INVALID_TARGET","Heading nodes can only be resolved as blocks.");return rfn(e);case"listItem":if(o!=="block")throw new De("INVALID_TARGET","ListItem nodes can only be resolved as blocks.");return ofn(e);case"table":if(o!=="block")throw new De("INVALID_TARGET","Table nodes can only be resolved as blocks.");return ifn(e);case"tableRow":if(o!=="block")throw new De("INVALID_TARGET","TableRow nodes can only be resolved as blocks.");return sfn();case"tableCell":if(o!=="block")throw new De("INVALID_TARGET","TableCell nodes can only be resolved as blocks.");return afn(e);case"image":{const i=e.node?.attrs;return dfn(i,o,n,e.pos)}case"sdt":{const i=e.node?.attrs;return E9t(i,o)}case"tableOfContents":if(o!=="block")throw new De("INVALID_TARGET","TableOfContents nodes can only be resolved as blocks.");return lfn(e);case"hyperlink":if(!OI(e))throw new De("INVALID_TARGET","Hyperlink nodes can only be resolved inline.");return ffn(e);case"comment":if(!OI(e))throw new De("INVALID_TARGET","Comment nodes can only be resolved inline.");return hfn(e);case"run":if(!OI(e))throw new De("INVALID_TARGET","Run nodes can only be resolved inline.");return Ifn(e);case"bookmark":if(!OI(e))throw new De("INVALID_TARGET","Bookmark nodes can only be resolved inline.");return pfn(e);case"footnoteRef":if(!OI(e))throw new De("INVALID_TARGET","Footnote references can only be resolved inline.");return mfn(e);case"tab":return Sfn();case"lineBreak":return Tfn();default:throw new De("INVALID_TARGET",`Node type "${r}" is not implemented yet.`)}}function nMe(e,t,n,r){if(n.kind==="block"){const i=vh(t,n);return i?tMe(i,n.nodeType,e.state.doc):void 0}const o=hC(r??Fg(e),n);if(o)return tMe(o,n.nodeType)}function xfn(e,t,n){const r=[];let o;for(const i of n){if(i.kind==="inline"){o??=Fg(e);const a=nMe(e,t,i,o);a&&r.push(a);continue}const s=nMe(e,t,i);s&&r.push(s)}return r}function kfn(e,t){return{kind:"inline",nodeType:t??e.nodeType,anchor:e.anchor}}function pY(e,t,n,r){const o=bC(t,n,r);if(!o.ok)return{matches:[],total:0};const i=Fg(e),s=n.select;let a,l;if(s.type==="node"){if(s.kind&&s.kind!=="inline")return Bp(r,"Only inline nodes are supported by the current inline adapter."),{matches:[],total:0};if(s.nodeType){if(!HSe(s.nodeType))return Bp(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?mM(i,a):i.candidates;c=AM(c,o.range);const u=Ti(c.map(d=>kfn(d,l)),n.offset,n.limit);return{matches:u.items,total:u.total}}function rMe(e,t,n,r){const o={...n,offset:void 0,limit:void 0},i=FD(t,o,r),s=pY(e,t,o,r),a=Ti(qqt(e,t,[...i.matches,...s.matches]),n.offset,n.limit);return{matches:a.items,total:a.total}}function Cfn(e){const t={};for(const n of e)switch(n.type.name){case"bold":t.bold=!PD(n.attrs.value);break;case"italic":t.italic=!PD(n.attrs.value);break;case"strike":t.strike=!PD(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 Efn(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 _fn(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&&Efn(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 Rfn(e,t){const n=ND(e,"bold"),r=ND(e,"italic"),o=ND(e,"underline"),i=ND(e,"strike"),s={bold:n,italic:r,underline:o,strike:i},a=R1(n),l=R1(r),c=R1(o),u=R1(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=Cfn(e),x=Hc(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 _=x.underline?.["w:val"];d.underline=_!=null&&_!=="none"}}const f={direct:s,effective:d},h=e.find(T=>T.type.name==="runProperties"),p=e.find(T=>T.type.name==="textStyle"),m=o0(h,"color")??o0(p,"color"),g=m!=null?oMe(String(m)):void 0;g&&(f.color=g);const y=o0(h,"highlight")??o0(p,"highlight"),v=y!=null?oMe(String(y)):void 0;v&&(f.highlight=v);const b=o0(h,"fontFamily")??o0(p,"fontFamily");typeof b=="string"&&b.trim().length>0&&(f.fontFamily=b);const I=o0(h,"fontSize"),w=I??o0(p,"fontSize"),A=Lfn((I!=null?"runProperties":"textStyle")=="runProperties"&&typeof w=="number"?w/2:w);return A!==void 0&&(f.fontSizePt=A),f}function o0(e,t){if(!e)return;const n=e.attrs[t];return n??void 0}function Pfn(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 oMe(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=Mfn[t];if(r)return r}function Lfn(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 Nfn(e,t,n){if(e.length===0){if(t.start!==t.end)throw en("INTERNAL_ERROR",`run-tiling: no runs for non-empty block range in block ${n}`);return}if(e[0].range.start!==t.start)throw en("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 en("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 en("INTERNAL_ERROR",`run-tiling: gap or overlap between runs[${r}] and runs[${r+1}] in block ${n}`)}var Mfn={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 Dfn(e){return`text:${btoa(JSON.stringify(e))}`}function X3(e,t,n,r,o,i,s){return rI({v:4,rev:t,storyKey:e,scope:r,matchId:n,segments:o,blockIndex:i,runIndex:s})}function Ofn(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 Ffn(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 Bfn(e,t,n,r,o,i){const s=Un(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(R=>R.nodeId===f);if(!p)continue;const m=Math.min(...h.map(R=>R.range.start)),g=Math.max(...h.map(R=>R.range.end)),y=[...h].sort((R,O)=>R.range.start-O.range.start);for(let R=0;R<y.length-1;R++)if(y[R].range.end<y[R+1].range.start){const O=y[R].range.end,F=y[R+1].range.start,H=Math.min(...y.map(M=>M.range.start)),U=Math.max(...y.map(M=>M.range.end));throw en("INVALID_INPUT",`discontiguous text ranges in block ${f}: gap between ${O} and ${F}. 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 ${H}..${U} — direct mode only, since in tracked mode the untouched middle would be recorded as deleted+reinserted.`,void 0,{blockId:f,gap:{start:O,end:F},coveringRange:{start:H,end:U},rangeCount:y.length,ranges:y.map(M=>({start:M.range.start,end:M.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 ${H}..${U} (direct mode only — pollutes tracked history).`}})}const v=p.pos+1,b=p.end-1,I=a.textBetween(v,b,`
405
405
  `,""),w=I.slice(m,g),A=a.nodeAt(p.pos),T=A?.type.name??"paragraph",x=Hfn(A),_=i?{resolverParams:i,paragraphProperties:A?.attrs?.paragraphProperties??null}:void 0,E=_fn(iI(e,p.pos,m,g).runs),P={start:m,end:g},k=E.map((R,O)=>({range:{start:R.from,end:R.to},text:I.slice(R.from,R.to),styleId:Pfn(R.marks),styles:Rfn(R.marks,_),ref:X3(o,n,r,"run",[{blockId:f,start:R.from,end:R.to}],d,O)}));for(const R of k)R.styleId===void 0&&delete R.styleId;Nfn(k,P,f);const L={blockId:f,nodeType:T,range:P,text:w,ref:X3(o,n,r,"block",[{blockId:f,start:m,end:g}],d),runs:k};x&&(L.paragraphStyle=x),u.push(L)}return u}function Hfn(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 zfn(e,t){if(!e.state?.doc||t.length===0)return;const n=Un(e),r=e.state.doc,o=t.map(m=>m.text).join(`
@@ -414,7 +414,7 @@ function print() { __p += __j.call(arguments, '') }
414
414
  `,t);return r===-1?n:n===-1||n+1===r?r:n<r?n:r}var BCn=Re((()=>{})),HCn=Re((()=>{BCn()})),i6e,zCn=Re((()=>{i6e={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 UCn(e,t){const n=t||{};return VJ({file:n.file||void 0,location:!1,schema:n.space==="svg"?I5:A5,verbose:n.verbose||!1},e)}function VJ(e,t){let n;switch(t.nodeName){case"#comment":{const r=t;return n={type:"comment",value:r.data},S5(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:s6e(e,t.childNodes),data:{quirksMode:o}},e.file&&e.location){const i=String(e.file),s=FCn(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"},S5(e,r,n),n}case"#text":{const r=t;return n={type:"text",value:r.value},S5(e,r,n),n}default:return n=VCn(e,t),n}}function s6e(e,t){let n=-1;const r=[];for(;++n<t.length;){const o=VJ(e,t[n]);r.push(o)}return r}function VCn(e,t){const n=e.schema;e.schema=t.namespaceURI===i6e.svg?I5:A5;let r=-1;const o={};for(;++r<t.attrs.length;){const s=t.attrs[r],a=(s.prefix?s.prefix+":":"")+s.name;GJ.call(l6e,a)||(o[a]=s.value)}const i=(e.schema.space==="svg"?r6e:n6e)(t.tagName,o,s6e(e,t.childNodes));if(S5(e,t,i),i.tagName==="template"){const s=t,a=s.sourceCodeLocation,l=a&&a.startTag&&fS(a.startTag),c=a&&a.endTag&&fS(a.endTag),u=VJ(e,s.content);l&&c&&e.file&&(u.position={start:l.end,end:c.start}),i.content=u}return e.schema=n,i}function S5(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const r=GCn(e,n,t.sourceCodeLocation);r&&(e.location=!0,n.position=r)}}function GCn(e,t,n){const r=fS(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)GJ.call(n.attrs,s)&&(i[Y5e(e.schema,s).property]=fS(n.attrs[s]));n.startTag;const a=fS(n.startTag),l=n.endTag?fS(n.endTag):void 0,c={opening:a};l&&(c.closing=l),c.properties=i,t.data={position:c}}}return r}function fS(e){const t=a6e({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=a6e({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function a6e(e){return e.line&&e.column?e:void 0}var GJ,l6e,WCn=Re((()=>{lb(),OCn(),HJ(),HCn(),zCn(),GJ={}.hasOwnProperty,l6e=Object.prototype})),jCn=Re((()=>{WCn()}));function c6e(e){return e>=55296&&e<=57343}function qCn(e){return e>=56320&&e<=57343}function KCn(e,t){return(e-55296)*1024+9216+t}function u6e(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function d6e(e){return e>=64976&&e<=65007||f6e.has(e)}var f6e,YCn,Me,bc,WJ=Re((()=>{f6e=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]),YCn="�",(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"})(Me||(Me={})),bc={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"}})),At,T5=Re((()=>{(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(At||(At={}))})),h6e,p6e,XCn=Re((()=>{WJ(),T5(),h6e=65536,p6e=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=h6e,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(qCn(t))return this.pos++,this._addGap(),KCn(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Me.EOF;return this._err(At.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let n=0;n<e.length;n++)if((this.html.charCodeAt(this.pos+n)|32)!==e.charCodeAt(n))return!1;return!0}peek(e){const t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Me.EOF;const n=this.html.charCodeAt(t);return n===Me.CARRIAGE_RETURN?Me.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,Me.EOF;let e=this.html.charCodeAt(this.pos);return e===Me.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,Me.LINE_FEED):e===Me.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,c6e(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===Me.LINE_FEED||e===Me.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){u6e(e)?this._err(At.controlCharacterInInputStream):d6e(e)&&this._err(At.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}}));function m6e(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 Go,jJ=Re((()=>{(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"})(Go||(Go={}))})),g6e,JCn=Re((()=>{g6e=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 ZCn(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=y6e.get(e))!==null&&t!==void 0?t:e}var qJ,y6e,QCn,$Cn=Re((()=>{y6e=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]]),QCn=(qJ=String.fromCodePoint)!==null&&qJ!==void 0?qJ: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 KJ(e){return e>=Ua.ZERO&&e<=Ua.NINE}function eEn(e){return e>=Ua.UPPER_A&&e<=Ua.UPPER_F||e>=Ua.LOWER_A&&e<=Ua.LOWER_F}function tEn(e){return e>=Ua.UPPER_A&&e<=Ua.UPPER_Z||e>=Ua.LOWER_A&&e<=Ua.LOWER_Z||KJ(e)}function nEn(e){return e===Ua.EQUALS||tEn(e)}function rEn(e,t,n,r){const o=(t&y0.BRANCH_LENGTH)>>7,i=t&y0.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 Ua,b6e,y0,Va,lm,v6e,oEn=Re((()=>{$Cn(),JCn(),(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"})(Ua||(Ua={})),b6e=32,(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(y0||(y0={})),(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"})(Va||(Va={})),(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(lm||(lm={})),v6e=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=Va.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=lm.Strict}startEntity(e){this.decodeMode=e,this.state=Va.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case Va.EntityStart:return e.charCodeAt(t)===Ua.NUM?(this.state=Va.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=Va.NamedEntity,this.stateNamedEntity(e,t));case Va.NumericStart:return this.stateNumericStart(e,t);case Va.NumericDecimal:return this.stateNumericDecimal(e,t);case Va.NumericHex:return this.stateNumericHex(e,t);case Va.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|b6e)===Ua.LOWER_X?(this.state=Va.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=Va.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(KJ(r)||eEn(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(KJ(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===Ua.SEMI)this.consumed+=1;else if(this.decodeMode===lm.Strict)return 0;return this.emitCodePoint(ZCn(this.result),this.consumed),this.errors&&(e!==Ua.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&y0.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const i=e.charCodeAt(t);if(this.treeIndex=rEn(n,r,this.treeIndex+Math.max(1,o),i),this.treeIndex<0)return this.result===0||this.decodeMode===lm.Attribute&&(o===0||nEn(i))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],o=(r&y0.VALUE_LENGTH)>>14,o!==0){if(i===Ua.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==lm.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]&y0.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]&~y0.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case Va.NamedEntity:return this.result!==0&&(this.decodeMode!==lm.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Va.NumericDecimal:return this.emitNumericEntity(0,2);case Va.NumericHex:return this.emitNumericEntity(0,3);case Va.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Va.EntityStart:return 0}}}}));function x5(e){var t;return(t=w6e.get(e))!==null&&t!==void 0?t:W.UNKNOWN}var Ht,rv,Sd,ht,W,w6e,Wt,A6e,k5,iEn,b0=Re((()=>{(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Ht||(Ht={})),(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(rv||(rv={})),(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Sd||(Sd={})),(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"})(ht||(ht={})),(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(W||(W={})),w6e=new Map([[ht.A,W.A],[ht.ADDRESS,W.ADDRESS],[ht.ANNOTATION_XML,W.ANNOTATION_XML],[ht.APPLET,W.APPLET],[ht.AREA,W.AREA],[ht.ARTICLE,W.ARTICLE],[ht.ASIDE,W.ASIDE],[ht.B,W.B],[ht.BASE,W.BASE],[ht.BASEFONT,W.BASEFONT],[ht.BGSOUND,W.BGSOUND],[ht.BIG,W.BIG],[ht.BLOCKQUOTE,W.BLOCKQUOTE],[ht.BODY,W.BODY],[ht.BR,W.BR],[ht.BUTTON,W.BUTTON],[ht.CAPTION,W.CAPTION],[ht.CENTER,W.CENTER],[ht.CODE,W.CODE],[ht.COL,W.COL],[ht.COLGROUP,W.COLGROUP],[ht.DD,W.DD],[ht.DESC,W.DESC],[ht.DETAILS,W.DETAILS],[ht.DIALOG,W.DIALOG],[ht.DIR,W.DIR],[ht.DIV,W.DIV],[ht.DL,W.DL],[ht.DT,W.DT],[ht.EM,W.EM],[ht.EMBED,W.EMBED],[ht.FIELDSET,W.FIELDSET],[ht.FIGCAPTION,W.FIGCAPTION],[ht.FIGURE,W.FIGURE],[ht.FONT,W.FONT],[ht.FOOTER,W.FOOTER],[ht.FOREIGN_OBJECT,W.FOREIGN_OBJECT],[ht.FORM,W.FORM],[ht.FRAME,W.FRAME],[ht.FRAMESET,W.FRAMESET],[ht.H1,W.H1],[ht.H2,W.H2],[ht.H3,W.H3],[ht.H4,W.H4],[ht.H5,W.H5],[ht.H6,W.H6],[ht.HEAD,W.HEAD],[ht.HEADER,W.HEADER],[ht.HGROUP,W.HGROUP],[ht.HR,W.HR],[ht.HTML,W.HTML],[ht.I,W.I],[ht.IMG,W.IMG],[ht.IMAGE,W.IMAGE],[ht.INPUT,W.INPUT],[ht.IFRAME,W.IFRAME],[ht.KEYGEN,W.KEYGEN],[ht.LABEL,W.LABEL],[ht.LI,W.LI],[ht.LINK,W.LINK],[ht.LISTING,W.LISTING],[ht.MAIN,W.MAIN],[ht.MALIGNMARK,W.MALIGNMARK],[ht.MARQUEE,W.MARQUEE],[ht.MATH,W.MATH],[ht.MENU,W.MENU],[ht.META,W.META],[ht.MGLYPH,W.MGLYPH],[ht.MI,W.MI],[ht.MO,W.MO],[ht.MN,W.MN],[ht.MS,W.MS],[ht.MTEXT,W.MTEXT],[ht.NAV,W.NAV],[ht.NOBR,W.NOBR],[ht.NOFRAMES,W.NOFRAMES],[ht.NOEMBED,W.NOEMBED],[ht.NOSCRIPT,W.NOSCRIPT],[ht.OBJECT,W.OBJECT],[ht.OL,W.OL],[ht.OPTGROUP,W.OPTGROUP],[ht.OPTION,W.OPTION],[ht.P,W.P],[ht.PARAM,W.PARAM],[ht.PLAINTEXT,W.PLAINTEXT],[ht.PRE,W.PRE],[ht.RB,W.RB],[ht.RP,W.RP],[ht.RT,W.RT],[ht.RTC,W.RTC],[ht.RUBY,W.RUBY],[ht.S,W.S],[ht.SCRIPT,W.SCRIPT],[ht.SEARCH,W.SEARCH],[ht.SECTION,W.SECTION],[ht.SELECT,W.SELECT],[ht.SOURCE,W.SOURCE],[ht.SMALL,W.SMALL],[ht.SPAN,W.SPAN],[ht.STRIKE,W.STRIKE],[ht.STRONG,W.STRONG],[ht.STYLE,W.STYLE],[ht.SUB,W.SUB],[ht.SUMMARY,W.SUMMARY],[ht.SUP,W.SUP],[ht.TABLE,W.TABLE],[ht.TBODY,W.TBODY],[ht.TEMPLATE,W.TEMPLATE],[ht.TEXTAREA,W.TEXTAREA],[ht.TFOOT,W.TFOOT],[ht.TD,W.TD],[ht.TH,W.TH],[ht.THEAD,W.THEAD],[ht.TITLE,W.TITLE],[ht.TR,W.TR],[ht.TRACK,W.TRACK],[ht.TT,W.TT],[ht.U,W.U],[ht.UL,W.UL],[ht.SVG,W.SVG],[ht.VAR,W.VAR],[ht.WBR,W.WBR],[ht.XMP,W.XMP]]),Wt=W,A6e={[Ht.HTML]:new Set([Wt.ADDRESS,Wt.APPLET,Wt.AREA,Wt.ARTICLE,Wt.ASIDE,Wt.BASE,Wt.BASEFONT,Wt.BGSOUND,Wt.BLOCKQUOTE,Wt.BODY,Wt.BR,Wt.BUTTON,Wt.CAPTION,Wt.CENTER,Wt.COL,Wt.COLGROUP,Wt.DD,Wt.DETAILS,Wt.DIR,Wt.DIV,Wt.DL,Wt.DT,Wt.EMBED,Wt.FIELDSET,Wt.FIGCAPTION,Wt.FIGURE,Wt.FOOTER,Wt.FORM,Wt.FRAME,Wt.FRAMESET,Wt.H1,Wt.H2,Wt.H3,Wt.H4,Wt.H5,Wt.H6,Wt.HEAD,Wt.HEADER,Wt.HGROUP,Wt.HR,Wt.HTML,Wt.IFRAME,Wt.IMG,Wt.INPUT,Wt.LI,Wt.LINK,Wt.LISTING,Wt.MAIN,Wt.MARQUEE,Wt.MENU,Wt.META,Wt.NAV,Wt.NOEMBED,Wt.NOFRAMES,Wt.NOSCRIPT,Wt.OBJECT,Wt.OL,Wt.P,Wt.PARAM,Wt.PLAINTEXT,Wt.PRE,Wt.SCRIPT,Wt.SECTION,Wt.SELECT,Wt.SOURCE,Wt.STYLE,Wt.SUMMARY,Wt.TABLE,Wt.TBODY,Wt.TD,Wt.TEMPLATE,Wt.TEXTAREA,Wt.TFOOT,Wt.TH,Wt.THEAD,Wt.TITLE,Wt.TR,Wt.TRACK,Wt.UL,Wt.WBR,Wt.XMP]),[Ht.MATHML]:new Set([Wt.MI,Wt.MO,Wt.MN,Wt.MS,Wt.MTEXT,Wt.ANNOTATION_XML]),[Ht.SVG]:new Set([Wt.TITLE,Wt.FOREIGN_OBJECT,Wt.DESC]),[Ht.XLINK]:new Set,[Ht.XML]:new Set,[Ht.XMLNS]:new Set},k5=new Set([Wt.H1,Wt.H2,Wt.H3,Wt.H4,Wt.H5,Wt.H6]),iEn=new Set([ht.STYLE,ht.SCRIPT,ht.XMP,ht.IFRAME,ht.NOEMBED,ht.NOFRAMES,ht.PLAINTEXT])}));function sEn(e){return e>=Me.DIGIT_0&&e<=Me.DIGIT_9}function n_(e){return e>=Me.LATIN_CAPITAL_A&&e<=Me.LATIN_CAPITAL_Z}function aEn(e){return e>=Me.LATIN_SMALL_A&&e<=Me.LATIN_SMALL_Z}function v0(e){return aEn(e)||n_(e)}function I6e(e){return v0(e)||sEn(e)}function C5(e){return e+32}function S6e(e){return e===Me.SPACE||e===Me.LINE_FEED||e===Me.TABULATION||e===Me.FORM_FEED}function T6e(e){return S6e(e)||e===Me.SOLIDUS||e===Me.GREATER_THAN_SIGN}function lEn(e){return e===Me.NULL?At.nullCharacterReference:e>1114111?At.characterReferenceOutsideUnicodeRange:c6e(e)?At.surrogateCharacterReference:d6e(e)?At.noncharacterCharacterReference:u6e(e)||e===Me.CARRIAGE_RETURN?At.controlCharacterReference:null}var ze,vc,x6e,k6e=Re((()=>{XCn(),WJ(),jJ(),oEn(),T5(),b0(),(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"})(ze||(ze={})),vc={DATA:ze.DATA,RCDATA:ze.RCDATA,RAWTEXT:ze.RAWTEXT,SCRIPT_DATA:ze.SCRIPT_DATA,PLAINTEXT:ze.PLAINTEXT,CDATA_SECTION:ze.CDATA_SECTION},x6e=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=ze.DATA,this.returnState=ze.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new p6e(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new v6e(g6e,(n,r)=>{this.preprocessor.pos=this.entityStartPos+r-1,this._flushCodePointConsumedAsCharacterReference(n)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(At.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(At.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const r=lEn(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:Go.START_TAG,tagName:"",tagID:W.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Go.END_TAG,tagName:"",tagID:W.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:Go.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:Go.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(m6e(n,this.currentAttr.name)===null){if(n.attrs.push(this.currentAttr),n.location&&this.currentLocation){const r=(e=(t=n.location).attrs)!==null&&e!==void 0?e:t.attrs=Object.create(null);r[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(At.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const e=this.currentToken;this.prepareToken(e),e.tagID=x5(e.tagName),e.type===Go.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(At.endTagWithAttributes),e.selfClosing&&this._err(At.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case Go.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case Go.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case Go.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:Go.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=S6e(e)?Go.WHITESPACE_CHARACTER:e===Me.NULL?Go.NULL_CHARACTER:Go.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(Go.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=ze.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?lm.Attribute:lm.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ze.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ze.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case ze.DATA:this._stateData(e);break;case ze.RCDATA:this._stateRcdata(e);break;case ze.RAWTEXT:this._stateRawtext(e);break;case ze.SCRIPT_DATA:this._stateScriptData(e);break;case ze.PLAINTEXT:this._statePlaintext(e);break;case ze.TAG_OPEN:this._stateTagOpen(e);break;case ze.END_TAG_OPEN:this._stateEndTagOpen(e);break;case ze.TAG_NAME:this._stateTagName(e);break;case ze.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case ze.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case ze.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case ze.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case ze.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case ze.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case ze.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case ze.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case ze.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case ze.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case ze.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case ze.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case ze.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case ze.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case ze.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case ze.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case ze.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case ze.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case ze.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case ze.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case ze.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case ze.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case ze.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case ze.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case ze.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case ze.BOGUS_COMMENT:this._stateBogusComment(e);break;case ze.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case ze.COMMENT_START:this._stateCommentStart(e);break;case ze.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case ze.COMMENT:this._stateComment(e);break;case ze.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case ze.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case ze.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case ze.COMMENT_END:this._stateCommentEnd(e);break;case ze.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case ze.DOCTYPE:this._stateDoctype(e);break;case ze.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case ze.DOCTYPE_NAME:this._stateDoctypeName(e);break;case ze.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case ze.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case ze.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case ze.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case ze.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case ze.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case ze.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case ze.CDATA_SECTION:this._stateCdataSection(e);break;case ze.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case ze.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case ze.CHARACTER_REFERENCE:this._stateCharacterReference();break;case ze.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw new Error("Unknown state")}}_stateData(e){switch(e){case Me.LESS_THAN_SIGN:this.state=ze.TAG_OPEN;break;case Me.AMPERSAND:this._startCharacterReference();break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitCodePoint(e);break;case Me.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case Me.AMPERSAND:this._startCharacterReference();break;case Me.LESS_THAN_SIGN:this.state=ze.RCDATA_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case Me.LESS_THAN_SIGN:this.state=ze.RAWTEXT_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(v0(e))this._createStartTagToken(),this.state=ze.TAG_NAME,this._stateTagName(e);else switch(e){case Me.EXCLAMATION_MARK:this.state=ze.MARKUP_DECLARATION_OPEN;break;case Me.SOLIDUS:this.state=ze.END_TAG_OPEN;break;case Me.QUESTION_MARK:this._err(At.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e);break;case Me.EOF:this._err(At.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(At.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ze.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(v0(e))this._createEndTagToken(),this.state=ze.TAG_NAME,this._stateTagName(e);else switch(e){case Me.GREATER_THAN_SIGN:this._err(At.missingEndTagName),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break;default:this._err(At.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Me.SOLIDUS:this.state=ze.SELF_CLOSING_START_TAG;break;case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentTagToken();break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.tagName+="�";break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(n_(e)?C5(e):e)}}_stateRcdataLessThanSign(e){e===Me.SOLIDUS?this.state=ze.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=ze.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){v0(e)?(this.state=ze.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=ze.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 Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=ze.BEFORE_ATTRIBUTE_NAME,!1;case Me.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=ze.SELF_CLOSING_START_TAG,!1;case Me.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=ze.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===Me.SOLIDUS?this.state=ze.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){v0(e)?(this.state=ze.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case Me.SOLIDUS:this.state=ze.SCRIPT_DATA_END_TAG_OPEN;break;case Me.EXCLAMATION_MARK:this.state=ze.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break;default:this._emitChars("<"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){v0(e)?(this.state=ze.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===Me.HYPHEN_MINUS?(this.state=ze.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===Me.HYPHEN_MINUS?(this.state=ze.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=ze.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case Me.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case Me.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case Me.HYPHEN_MINUS:this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case Me.GREATER_THAN_SIGN:this.state=ze.SCRIPT_DATA,this._emitChars(">");break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===Me.SOLIDUS?this.state=ze.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:v0(e)?(this._emitChars("<"),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){v0(e)?(this.state=ze.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(bc.SCRIPT,!1)&&T6e(this.preprocessor.peek(bc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<bc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=ze.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case Me.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case Me.HYPHEN_MINUS:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case Me.HYPHEN_MINUS:this._emitChars("-");break;case Me.LESS_THAN_SIGN:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case Me.GREATER_THAN_SIGN:this.state=ze.SCRIPT_DATA,this._emitChars(">");break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case Me.EOF:this._err(At.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===Me.SOLIDUS?(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(bc.SCRIPT,!1)&&T6e(this.preprocessor.peek(bc.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<bc.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=ze.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=ze.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.SOLIDUS:case Me.GREATER_THAN_SIGN:case Me.EOF:this.state=ze.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Me.EQUALS_SIGN:this._err(At.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=ze.ATTRIBUTE_NAME;break;default:this._createAttr(""),this.state=ze.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:case Me.SOLIDUS:case Me.GREATER_THAN_SIGN:case Me.EOF:this._leaveAttrName(),this.state=ze.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case Me.EQUALS_SIGN:this._leaveAttrName(),this.state=ze.BEFORE_ATTRIBUTE_VALUE;break;case Me.QUOTATION_MARK:case Me.APOSTROPHE:case Me.LESS_THAN_SIGN:this._err(At.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.name+="�";break;default:this.currentAttr.name+=String.fromCodePoint(n_(e)?C5(e):e)}}_stateAfterAttributeName(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.SOLIDUS:this.state=ze.SELF_CLOSING_START_TAG;break;case Me.EQUALS_SIGN:this.state=ze.BEFORE_ATTRIBUTE_VALUE;break;case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentTagToken();break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._createAttr(""),this.state=ze.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.QUOTATION_MARK:this.state=ze.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case Me.APOSTROPHE:this.state=ze.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case Me.GREATER_THAN_SIGN:this._err(At.missingAttributeValue),this.state=ze.DATA,this.emitCurrentTagToken();break;default:this.state=ze.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case Me.QUOTATION_MARK:this.state=ze.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Me.AMPERSAND:this._startCharacterReference();break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case Me.APOSTROPHE:this.state=ze.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case Me.AMPERSAND:this._startCharacterReference();break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this._leaveAttrValue(),this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Me.AMPERSAND:this._startCharacterReference();break;case Me.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ze.DATA,this.emitCurrentTagToken();break;case Me.NULL:this._err(At.unexpectedNullCharacter),this.currentAttr.value+="�";break;case Me.QUOTATION_MARK:case Me.APOSTROPHE:case Me.LESS_THAN_SIGN:case Me.EQUALS_SIGN:case Me.GRAVE_ACCENT:this._err(At.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this._leaveAttrValue(),this.state=ze.BEFORE_ATTRIBUTE_NAME;break;case Me.SOLIDUS:this._leaveAttrValue(),this.state=ze.SELF_CLOSING_START_TAG;break;case Me.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ze.DATA,this.emitCurrentTagToken();break;case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._err(At.missingWhitespaceBetweenAttributes),this.state=ze.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case Me.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=ze.DATA,this.emitCurrentTagToken();break}case Me.EOF:this._err(At.eofInTag),this._emitEOFToken();break;default:this._err(At.unexpectedSolidusInTag),this.state=ze.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentComment(t);break;case Me.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.data+="�";break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(bc.DASH_DASH,!0)?(this._createCommentToken(bc.DASH_DASH.length+1),this.state=ze.COMMENT_START):this._consumeSequenceIfMatch(bc.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(bc.DOCTYPE.length+1),this.state=ze.DOCTYPE):this._consumeSequenceIfMatch(bc.CDATA_START,!0)?this.inForeignNode?this.state=ze.CDATA_SECTION:(this._err(At.cdataInHtmlContent),this._createCommentToken(bc.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=ze.BOGUS_COMMENT):this._ensureHibernation()||(this._err(At.incorrectlyOpenedComment),this._createCommentToken(2),this.state=ze.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case Me.HYPHEN_MINUS:this.state=ze.COMMENT_START_DASH;break;case Me.GREATER_THAN_SIGN:{this._err(At.abruptClosingOfEmptyComment),this.state=ze.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case Me.HYPHEN_MINUS:this.state=ze.COMMENT_END;break;case Me.GREATER_THAN_SIGN:this._err(At.abruptClosingOfEmptyComment),this.state=ze.DATA,this.emitCurrentComment(t);break;case Me.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ze.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case Me.HYPHEN_MINUS:this.state=ze.COMMENT_END_DASH;break;case Me.LESS_THAN_SIGN:t.data+="<",this.state=ze.COMMENT_LESS_THAN_SIGN;break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.data+="�";break;case Me.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case Me.EXCLAMATION_MARK:t.data+="!",this.state=ze.COMMENT_LESS_THAN_SIGN_BANG;break;case Me.LESS_THAN_SIGN:t.data+="<";break;default:this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===Me.HYPHEN_MINUS?this.state=ze.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=ze.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===Me.HYPHEN_MINUS?this.state=ze.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=ze.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==Me.GREATER_THAN_SIGN&&e!==Me.EOF&&this._err(At.nestedComment),this.state=ze.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case Me.HYPHEN_MINUS:this.state=ze.COMMENT_END;break;case Me.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentComment(t);break;case Me.EXCLAMATION_MARK:this.state=ze.COMMENT_END_BANG;break;case Me.HYPHEN_MINUS:t.data+="-";break;case Me.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--",this.state=ze.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case Me.HYPHEN_MINUS:t.data+="--!",this.state=ze.COMMENT_END_DASH;break;case Me.GREATER_THAN_SIGN:this._err(At.incorrectlyClosedComment),this.state=ze.DATA,this.emitCurrentComment(t);break;case Me.EOF:this._err(At.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--!",this.state=ze.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_NAME;break;case Me.GREATER_THAN_SIGN:this.state=ze.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case Me.EOF:{this._err(At.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(At.missingWhitespaceBeforeDoctypeName),this.state=ze.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(n_(e))this._createDoctypeToken(String.fromCharCode(C5(e))),this.state=ze.DOCTYPE_NAME;else switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.NULL:this._err(At.unexpectedNullCharacter),this._createDoctypeToken("�"),this.state=ze.DOCTYPE_NAME;break;case Me.GREATER_THAN_SIGN:{this._err(At.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break}case Me.EOF:{this._err(At.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=ze.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.AFTER_DOCTYPE_NAME;break;case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.name+="�";break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(n_(e)?C5(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch(bc.PUBLIC,!1)?this.state=ze.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(bc.SYSTEM,!1)?this.state=ze.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(At.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case Me.QUOTATION_MARK:this._err(At.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:this._err(At.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Me.GREATER_THAN_SIGN:this._err(At.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.QUOTATION_MARK:t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:t.publicId="",this.state=ze.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case Me.GREATER_THAN_SIGN:this._err(At.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Me.QUOTATION_MARK:this.state=ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.publicId+="�";break;case Me.GREATER_THAN_SIGN:this._err(At.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Me.APOSTROPHE:this.state=ze.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.publicId+="�";break;case Me.GREATER_THAN_SIGN:this._err(At.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case Me.GREATER_THAN_SIGN:this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.QUOTATION_MARK:this._err(At.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:this._err(At.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.QUOTATION_MARK:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:this.state=ze.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case Me.QUOTATION_MARK:this._err(At.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:this._err(At.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Me.GREATER_THAN_SIGN:this._err(At.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.QUOTATION_MARK:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case Me.APOSTROPHE:t.systemId="",this.state=ze.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case Me.GREATER_THAN_SIGN:this._err(At.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.DATA,this.emitCurrentDoctype(t);break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case Me.QUOTATION_MARK:this.state=ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.systemId+="�";break;case Me.GREATER_THAN_SIGN:this._err(At.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case Me.APOSTROPHE:this.state=ze.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case Me.NULL:this._err(At.unexpectedNullCharacter),t.systemId+="�";break;case Me.GREATER_THAN_SIGN:this._err(At.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case Me.SPACE:case Me.LINE_FEED:case Me.TABULATION:case Me.FORM_FEED:break;case Me.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.EOF:this._err(At.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(At.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=ze.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case Me.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ze.DATA;break;case Me.NULL:this._err(At.unexpectedNullCharacter);break;case Me.EOF:this.emitCurrentDoctype(t),this._emitEOFToken();break;default:}}_stateCdataSection(e){switch(e){case Me.RIGHT_SQUARE_BRACKET:this.state=ze.CDATA_SECTION_BRACKET;break;case Me.EOF:this._err(At.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===Me.RIGHT_SQUARE_BRACKET?this.state=ze.CDATA_SECTION_END:(this._emitChars("]"),this.state=ze.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case Me.GREATER_THAN_SIGN:this.state=ze.DATA;break;case Me.RIGHT_SQUARE_BRACKET:this._emitChars("]");break;default:this._emitChars("]]"),this.state=ze.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(Me.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&I6e(this.preprocessor.peek(1))?ze.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){I6e(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===Me.SEMICOLON&&this._err(At.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}}})),YJ,XJ,r_,C6e,E6e,JJ,ZJ,_6e,R6e,P6e,L6e,N6e,cEn=Re((()=>{b0(),YJ=new Set([W.DD,W.DT,W.LI,W.OPTGROUP,W.OPTION,W.P,W.RB,W.RP,W.RT,W.RTC]),XJ=new Set([...YJ,W.CAPTION,W.COLGROUP,W.TBODY,W.TD,W.TFOOT,W.TH,W.THEAD,W.TR]),r_=new Set([W.APPLET,W.CAPTION,W.HTML,W.MARQUEE,W.OBJECT,W.TABLE,W.TD,W.TEMPLATE,W.TH]),C6e=new Set([...r_,W.OL,W.UL]),E6e=new Set([...r_,W.BUTTON]),JJ=new Set([W.ANNOTATION_XML,W.MI,W.MN,W.MO,W.MS,W.MTEXT]),ZJ=new Set([W.DESC,W.FOREIGN_OBJECT,W.TITLE]),_6e=new Set([W.TR,W.TEMPLATE,W.HTML]),R6e=new Set([W.TBODY,W.TFOOT,W.THEAD,W.TEMPLATE,W.HTML]),P6e=new Set([W.TABLE,W.TEMPLATE,W.HTML]),L6e=new Set([W.TD,W.TH]),N6e=class{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=W.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===W.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Ht.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){const r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==Ht.HTML);this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){const t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(n,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(k5,Ht.HTML)}popUntilTableCellPopped(){this.popUntilPopped(L6e,Ht.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let n=this.stackTop;n>=0;n--)if(e.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(P6e,Ht.HTML)}clearBackToTableBodyContext(){this.clearBackTo(R6e,Ht.HTML)}clearBackToTableRowContext(){this.clearBackTo(_6e,Ht.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===W.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===W.HTML}hasInDynamicScope(e,t){for(let n=this.stackTop;n>=0;n--){const r=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case Ht.HTML:if(r===e)return!0;if(t.has(r))return!1;break;case Ht.SVG:if(ZJ.has(r))return!1;break;case Ht.MATHML:if(JJ.has(r))return!1;break}}return!0}hasInScope(e){return this.hasInDynamicScope(e,r_)}hasInListItemScope(e){return this.hasInDynamicScope(e,C6e)}hasInButtonScope(e){return this.hasInDynamicScope(e,E6e)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case Ht.HTML:if(k5.has(t))return!0;if(r_.has(t))return!1;break;case Ht.SVG:if(ZJ.has(t))return!1;break;case Ht.MATHML:if(JJ.has(t))return!1;break}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ht.HTML)switch(this.tagIDs[t]){case e:return!0;case W.TABLE:case W.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===Ht.HTML)switch(this.tagIDs[e]){case W.TBODY:case W.THEAD:case W.TFOOT:return!0;case W.TABLE:case W.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Ht.HTML)switch(this.tagIDs[t]){case e:return!0;case W.OPTION:case W.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&YJ.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&XJ.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==void 0&&this.currentTagId!==e&&XJ.has(this.currentTagId);)this.pop()}}})),E5,Fh,QJ,M6e,uEn=Re((()=>{E5=3,(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Fh||(Fh={})),QJ={type:Fh.Marker},M6e=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===Fh.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<E5)return;const t=this.treeAdapter.getAttrList(e),n=this._getNoahArkConditionCandidates(e,t);if(n.length<E5)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>=E5&&this.entries.splice(s.idx,1))}}insertMarker(){this.entries.unshift(QJ)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:Fh.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:Fh.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(QJ);e===-1?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){const t=this.entries.find(n=>n.type===Fh.Marker||this.treeAdapter.getTagName(n.element)===e);return t&&t.type===Fh.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===Fh.Element&&t.element===e)}}})),cm,$J=Re((()=>{b0(),cm={createDocument(){return{nodeName:"#document",mode:Sd.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};cm.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(cm.isTextNode(n)){n.value+=t;return}}cm.appendChild(e,cm.createTextNode(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&cm.isTextNode(r)?r.value+=t:cm.insertBefore(e,cm.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 D6e(e,t){return t.some(n=>e.startsWith(n))}function dEn(e){return e.name===eZ&&e.publicId===null&&(e.systemId===null||e.systemId===O6e)}function fEn(e){if(e.name!==eZ)return Sd.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===F6e)return Sd.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),H6e.has(n))return Sd.QUIRKS;let r=t===null?B6e:tZ;if(D6e(n,r))return Sd.QUIRKS;if(r=t===null?nZ:z6e,D6e(n,r))return Sd.LIMITED_QUIRKS}return Sd.NO_QUIRKS}var eZ,O6e,F6e,tZ,B6e,H6e,nZ,z6e,hEn=Re((()=>{b0(),eZ="html",O6e="about:legacy-compat",F6e="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",tZ=["+//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//"],B6e=[...tZ,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],H6e=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),nZ=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],z6e=[...nZ,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"]}));function pEn(e){const t=e.tagID;return t===W.FONT&&e.attrs.some(({name:n})=>n===rv.COLOR||n===rv.SIZE||n===rv.FACE)||Y6e.has(t)}function U6e(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===G6e){e.attrs[t].name=W6e;break}}function V6e(e){for(let t=0;t<e.attrs.length;t++){const n=j6e.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function rZ(e){for(let t=0;t<e.attrs.length;t++){const n=q6e.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 mEn(e){const t=K6e.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=x5(e.tagName))}function gEn(e,t){return t===Ht.MATHML&&(e===W.MI||e===W.MO||e===W.MN||e===W.MS||e===W.MTEXT)}function yEn(e,t,n){if(t===Ht.MATHML&&e===W.ANNOTATION_XML){for(let r=0;r<n.length;r++)if(n[r].name===rv.ENCODING){const o=n[r].value.toLowerCase();return o===oZ.TEXT_HTML||o===oZ.APPLICATION_XML}}return t===Ht.SVG&&(e===W.FOREIGN_OBJECT||e===W.DESC||e===W.TITLE)}function bEn(e,t,n,r){return(!r||r===Ht.HTML)&&yEn(e,t,n)||(!r||r===Ht.MATHML)&&gEn(e,t)}var oZ,G6e,W6e,j6e,q6e,K6e,Y6e,X6e=Re((()=>{b0(),oZ={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},G6e="definitionurl",W6e="definitionURL",j6e=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])),q6e=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Ht.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Ht.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Ht.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Ht.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Ht.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Ht.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Ht.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Ht.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Ht.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Ht.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Ht.XMLNS}]]),K6e=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])),Y6e=new Set([W.B,W.BIG,W.BLOCKQUOTE,W.BODY,W.BR,W.CENTER,W.CODE,W.DD,W.DIV,W.DL,W.DT,W.EM,W.EMBED,W.H1,W.H2,W.H3,W.H4,W.H5,W.H6,W.HEAD,W.HR,W.I,W.IMG,W.LI,W.LISTING,W.MENU,W.META,W.NOBR,W.OL,W.P,W.PRE,W.RUBY,W.S,W.SMALL,W.SPAN,W.STRONG,W.STRIKE,W.SUB,W.SUP,W.TABLE,W.TT,W.U,W.UL,W.VAR])}));function vEn(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):nFe(e,t),n}function wEn(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 AEn(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>=pFe;!a||l?(l&&e.activeFormattingElements.removeEntry(a),e.openElements.remove(s)):(s=IEn(e,a),r===t&&(e.activeFormattingElements.bookmark=a),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(s,r),r=s)}return r}function IEn(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 SEn(e,t,n){const r=x5(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const o=e.treeAdapter.getNamespaceURI(t);r===W.TEMPLATE&&o===Ht.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function TEn(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 iZ(e,t){for(let n=0;n<hFe;n++){const r=vEn(e,t);if(!r)break;const o=wEn(e,r);if(!o)break;e.activeFormattingElements.bookmark=r;const i=AEn(e,o,r.element),s=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(i),s&&SEn(e,s,i),TEn(e,o,r)}}function sZ(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function xEn(e,t){e._appendCommentNode(t,e.openElements.items[0])}function kEn(e,t){e._appendCommentNode(t,e.document)}function aZ(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 CEn(e,t){e._setDocumentType(t);const n=t.forceQuirks?Sd.QUIRKS:fEn(t);dEn(t)||e._err(t,At.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=Je.BEFORE_HTML}function o_(e,t){e._err(t,At.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Sd.QUIRKS),e.insertionMode=Je.BEFORE_HTML,e._processToken(t)}function EEn(e,t){t.tagID===W.HTML?(e._insertElement(t,Ht.HTML),e.insertionMode=Je.BEFORE_HEAD):i_(e,t)}function _En(e,t){const n=t.tagID;(n===W.HTML||n===W.HEAD||n===W.BODY||n===W.BR)&&i_(e,t)}function i_(e,t){e._insertFakeRootElement(),e.insertionMode=Je.BEFORE_HEAD,e._processToken(t)}function REn(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.HEAD:e._insertElement(t,Ht.HTML),e.headElement=e.openElements.current,e.insertionMode=Je.IN_HEAD;break;default:s_(e,t)}}function PEn(e,t){const n=t.tagID;n===W.HEAD||n===W.BODY||n===W.HTML||n===W.BR?s_(e,t):e._err(t,At.endTagWithoutMatchingOpenElement)}function s_(e,t){e._insertFakeElement(ht.HEAD,W.HEAD),e.headElement=e.openElements.current,e.insertionMode=Je.IN_HEAD,e._processToken(t)}function Cf(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.TITLE:e._switchToTextParsing(t,vc.RCDATA);break;case W.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,vc.RAWTEXT):(e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_HEAD_NO_SCRIPT);break;case W.NOFRAMES:case W.STYLE:e._switchToTextParsing(t,vc.RAWTEXT);break;case W.SCRIPT:e._switchToTextParsing(t,vc.SCRIPT_DATA);break;case W.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Je.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Je.IN_TEMPLATE);break;case W.HEAD:e._err(t,At.misplacedStartTagForHeadElement);break;default:a_(e,t)}}function LEn(e,t){switch(t.tagID){case W.HEAD:e.openElements.pop(),e.insertionMode=Je.AFTER_HEAD;break;case W.BODY:case W.BR:case W.HTML:a_(e,t);break;case W.TEMPLATE:ov(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function ov(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==W.TEMPLATE&&e._err(t,At.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(W.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,At.endTagWithoutMatchingOpenElement)}function a_(e,t){e.openElements.pop(),e.insertionMode=Je.AFTER_HEAD,e._processToken(t)}function NEn(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.BASEFONT:case W.BGSOUND:case W.HEAD:case W.LINK:case W.META:case W.NOFRAMES:case W.STYLE:Cf(e,t);break;case W.NOSCRIPT:e._err(t,At.nestedNoscriptInHead);break;default:l_(e,t)}}function MEn(e,t){switch(t.tagID){case W.NOSCRIPT:e.openElements.pop(),e.insertionMode=Je.IN_HEAD;break;case W.BR:l_(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function l_(e,t){const n=t.type===Go.EOF?At.openElementsLeftAfterEof:At.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=Je.IN_HEAD,e._processToken(t)}function DEn(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.BODY:e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=Je.IN_BODY;break;case W.FRAMESET:e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_FRAMESET;break;case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:case W.NOFRAMES:case W.SCRIPT:case W.STYLE:case W.TEMPLATE:case W.TITLE:e._err(t,At.abandonedHeadElementChild),e.openElements.push(e.headElement,W.HEAD),Cf(e,t),e.openElements.remove(e.headElement);break;case W.HEAD:e._err(t,At.misplacedStartTagForHeadElement);break;default:c_(e,t)}}function OEn(e,t){switch(t.tagID){case W.BODY:case W.HTML:case W.BR:c_(e,t);break;case W.TEMPLATE:ov(e,t);break;default:e._err(t,At.endTagWithoutMatchingOpenElement)}}function c_(e,t){e._insertFakeElement(ht.BODY,W.BODY),e.insertionMode=Je.IN_BODY,_5(e,t)}function _5(e,t){switch(t.type){case Go.CHARACTER:Z6e(e,t);break;case Go.WHITESPACE_CHARACTER:J6e(e,t);break;case Go.COMMENT:sZ(e,t);break;case Go.START_TAG:Fl(e,t);break;case Go.END_TAG:R5(e,t);break;case Go.EOF:rFe(e,t);break;default:}}function J6e(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Z6e(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function FEn(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function BEn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function HEn(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_FRAMESET)}function zEn(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML)}function UEn(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&k5.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Ht.HTML)}function VEn(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function GEn(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),n||(e.formElement=e.openElements.current))}function WEn(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===W.LI&&o===W.LI||(n===W.DD||n===W.DT)&&(o===W.DD||o===W.DT)){e.openElements.generateImpliedEndTagsWithExclusion(o),e.openElements.popUntilTagNamePopped(o);break}if(o!==W.ADDRESS&&o!==W.DIV&&o!==W.P&&e._isSpecialElement(e.openElements.items[r],o))break}e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML)}function jEn(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.tokenizer.state=vc.PLAINTEXT}function qEn(e,t){e.openElements.hasInScope(W.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.framesetOk=!1}function KEn(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(ht.A);n&&(iZ(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function YEn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function XEn(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(W.NOBR)&&(iZ(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Ht.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function JEn(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function ZEn(e,t){e.treeAdapter.getDocumentMode(e.document)!==Sd.QUIRKS&&e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=Je.IN_TABLE}function Q6e(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ht.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function $6e(e){const t=m6e(e,rv.TYPE);return t!=null&&t.toLowerCase()===fFe}function QEn(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ht.HTML),$6e(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function $En(e,t){e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0}function e_n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._appendElement(t,Ht.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function t_n(e,t){t.tagName=ht.IMG,t.tagID=W.IMG,Q6e(e,t)}function n_n(e,t){e._insertElement(t,Ht.HTML),e.skipNextNewLine=!0,e.tokenizer.state=vc.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Je.TEXT}function r_n(e,t){e.openElements.hasInButtonScope(W.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,vc.RAWTEXT)}function o_n(e,t){e.framesetOk=!1,e._switchToTextParsing(t,vc.RAWTEXT)}function eFe(e,t){e._switchToTextParsing(t,vc.RAWTEXT)}function i_n(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Je.IN_TABLE||e.insertionMode===Je.IN_CAPTION||e.insertionMode===Je.IN_TABLE_BODY||e.insertionMode===Je.IN_ROW||e.insertionMode===Je.IN_CELL?Je.IN_SELECT_IN_TABLE:Je.IN_SELECT}function s_n(e,t){e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML)}function a_n(e,t){e.openElements.hasInScope(W.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Ht.HTML)}function l_n(e,t){e.openElements.hasInScope(W.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(W.RTC),e._insertElement(t,Ht.HTML)}function c_n(e,t){e._reconstructActiveFormattingElements(),U6e(t),rZ(t),t.selfClosing?e._appendElement(t,Ht.MATHML):e._insertElement(t,Ht.MATHML),t.ackSelfClosing=!0}function u_n(e,t){e._reconstructActiveFormattingElements(),V6e(t),rZ(t),t.selfClosing?e._appendElement(t,Ht.SVG):e._insertElement(t,Ht.SVG),t.ackSelfClosing=!0}function tFe(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ht.HTML)}function Fl(e,t){switch(t.tagID){case W.I:case W.S:case W.B:case W.U:case W.EM:case W.TT:case W.BIG:case W.CODE:case W.FONT:case W.SMALL:case W.STRIKE:case W.STRONG:YEn(e,t);break;case W.A:KEn(e,t);break;case W.H1:case W.H2:case W.H3:case W.H4:case W.H5:case W.H6:UEn(e,t);break;case W.P:case W.DL:case W.OL:case W.UL:case W.DIV:case W.DIR:case W.NAV:case W.MAIN:case W.MENU:case W.ASIDE:case W.CENTER:case W.FIGURE:case W.FOOTER:case W.HEADER:case W.HGROUP:case W.DIALOG:case W.DETAILS:case W.ADDRESS:case W.ARTICLE:case W.SEARCH:case W.SECTION:case W.SUMMARY:case W.FIELDSET:case W.BLOCKQUOTE:case W.FIGCAPTION:zEn(e,t);break;case W.LI:case W.DD:case W.DT:WEn(e,t);break;case W.BR:case W.IMG:case W.WBR:case W.AREA:case W.EMBED:case W.KEYGEN:Q6e(e,t);break;case W.HR:e_n(e,t);break;case W.RB:case W.RTC:a_n(e,t);break;case W.RT:case W.RP:l_n(e,t);break;case W.PRE:case W.LISTING:VEn(e,t);break;case W.XMP:r_n(e,t);break;case W.SVG:u_n(e,t);break;case W.HTML:FEn(e,t);break;case W.BASE:case W.LINK:case W.META:case W.STYLE:case W.TITLE:case W.SCRIPT:case W.BGSOUND:case W.BASEFONT:case W.TEMPLATE:Cf(e,t);break;case W.BODY:BEn(e,t);break;case W.FORM:GEn(e,t);break;case W.NOBR:XEn(e,t);break;case W.MATH:c_n(e,t);break;case W.TABLE:ZEn(e,t);break;case W.INPUT:QEn(e,t);break;case W.PARAM:case W.TRACK:case W.SOURCE:$En(e,t);break;case W.IMAGE:t_n(e,t);break;case W.BUTTON:qEn(e,t);break;case W.APPLET:case W.OBJECT:case W.MARQUEE:JEn(e,t);break;case W.IFRAME:o_n(e,t);break;case W.SELECT:i_n(e,t);break;case W.OPTION:case W.OPTGROUP:s_n(e,t);break;case W.NOEMBED:case W.NOFRAMES:eFe(e,t);break;case W.FRAMESET:HEn(e,t);break;case W.TEXTAREA:n_n(e,t);break;case W.NOSCRIPT:e.options.scriptingEnabled?eFe(e,t):tFe(e,t);break;case W.PLAINTEXT:jEn(e,t);break;case W.COL:case W.TH:case W.TD:case W.TR:case W.HEAD:case W.FRAME:case W.TBODY:case W.TFOOT:case W.THEAD:case W.CAPTION:case W.COLGROUP:break;default:tFe(e,t)}}function d_n(e,t){if(e.openElements.hasInScope(W.BODY)&&(e.insertionMode=Je.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function f_n(e,t){e.openElements.hasInScope(W.BODY)&&(e.insertionMode=Je.AFTER_BODY,uFe(e,t))}function h_n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function p_n(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(W.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(W.FORM):n&&e.openElements.remove(n))}function m_n(e){e.openElements.hasInButtonScope(W.P)||e._insertFakeElement(ht.P,W.P),e._closePElement()}function g_n(e){e.openElements.hasInListItemScope(W.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(W.LI),e.openElements.popUntilTagNamePopped(W.LI))}function y_n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function b_n(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function v_n(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function w_n(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(ht.BR,W.BR),e.openElements.pop(),e.framesetOk=!1}function nFe(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!==W.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 R5(e,t){switch(t.tagID){case W.A:case W.B:case W.I:case W.S:case W.U:case W.EM:case W.TT:case W.BIG:case W.CODE:case W.FONT:case W.NOBR:case W.SMALL:case W.STRIKE:case W.STRONG:iZ(e,t);break;case W.P:m_n(e);break;case W.DL:case W.UL:case W.OL:case W.DIR:case W.DIV:case W.NAV:case W.PRE:case W.MAIN:case W.MENU:case W.ASIDE:case W.BUTTON:case W.CENTER:case W.FIGURE:case W.FOOTER:case W.HEADER:case W.HGROUP:case W.DIALOG:case W.ADDRESS:case W.ARTICLE:case W.DETAILS:case W.SEARCH:case W.SECTION:case W.SUMMARY:case W.LISTING:case W.FIELDSET:case W.BLOCKQUOTE:case W.FIGCAPTION:h_n(e,t);break;case W.LI:g_n(e);break;case W.DD:case W.DT:y_n(e,t);break;case W.H1:case W.H2:case W.H3:case W.H4:case W.H5:case W.H6:b_n(e);break;case W.BR:w_n(e);break;case W.BODY:d_n(e,t);break;case W.HTML:f_n(e,t);break;case W.FORM:p_n(e);break;case W.APPLET:case W.OBJECT:case W.MARQUEE:v_n(e,t);break;case W.TEMPLATE:ov(e,t);break;default:nFe(e,t)}}function rFe(e,t){e.tmplInsertionModeStack.length>0?cFe(e,t):aZ(e,t)}function A_n(e,t){var n;t.tagID===W.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function I_n(e,t){e._err(t,At.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function lZ(e,t){if(e.openElements.currentTagId!==void 0&&dZ.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Je.IN_TABLE_TEXT,t.type){case Go.CHARACTER:iFe(e,t);break;case Go.WHITESPACE_CHARACTER:oFe(e,t);break}else d_(e,t)}function S_n(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_CAPTION}function T_n(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_COLUMN_GROUP}function x_n(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ht.COLGROUP,W.COLGROUP),e.insertionMode=Je.IN_COLUMN_GROUP,cZ(e,t)}function k_n(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_TABLE_BODY}function C_n(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ht.TBODY,W.TBODY),e.insertionMode=Je.IN_TABLE_BODY,L5(e,t)}function E_n(e,t){e.openElements.hasInTableScope(W.TABLE)&&(e.openElements.popUntilTagNamePopped(W.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function __n(e,t){$6e(t)?e._appendElement(t,Ht.HTML):d_(e,t),t.ackSelfClosing=!0}function R_n(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Ht.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function hS(e,t){switch(t.tagID){case W.TD:case W.TH:case W.TR:C_n(e,t);break;case W.STYLE:case W.SCRIPT:case W.TEMPLATE:Cf(e,t);break;case W.COL:x_n(e,t);break;case W.FORM:R_n(e,t);break;case W.TABLE:E_n(e,t);break;case W.TBODY:case W.TFOOT:case W.THEAD:k_n(e,t);break;case W.INPUT:__n(e,t);break;case W.CAPTION:S_n(e,t);break;case W.COLGROUP:T_n(e,t);break;default:d_(e,t)}}function u_(e,t){switch(t.tagID){case W.TABLE:e.openElements.hasInTableScope(W.TABLE)&&(e.openElements.popUntilTagNamePopped(W.TABLE),e._resetInsertionMode());break;case W.TEMPLATE:ov(e,t);break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TBODY:case W.TD:case W.TFOOT:case W.TH:case W.THEAD:case W.TR:break;default:d_(e,t)}}function d_(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,_5(e,t),e.fosterParentingEnabled=n}function oFe(e,t){e.pendingCharacterTokens.push(t)}function iFe(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function f_(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)d_(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}function P_n(e,t){const n=t.tagID;pZ.has(n)?e.openElements.hasInTableScope(W.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Je.IN_TABLE,hS(e,t)):Fl(e,t)}function L_n(e,t){const n=t.tagID;switch(n){case W.CAPTION:case W.TABLE:e.openElements.hasInTableScope(W.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(W.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Je.IN_TABLE,n===W.TABLE&&u_(e,t));break;case W.BODY:case W.COL:case W.COLGROUP:case W.HTML:case W.TBODY:case W.TD:case W.TFOOT:case W.TH:case W.THEAD:case W.TR:break;default:R5(e,t)}}function cZ(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.COL:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.TEMPLATE:Cf(e,t);break;default:P5(e,t)}}function N_n(e,t){switch(t.tagID){case W.COLGROUP:e.openElements.currentTagId===W.COLGROUP&&(e.openElements.pop(),e.insertionMode=Je.IN_TABLE);break;case W.TEMPLATE:ov(e,t);break;case W.COL:break;default:P5(e,t)}}function P5(e,t){e.openElements.currentTagId===W.COLGROUP&&(e.openElements.pop(),e.insertionMode=Je.IN_TABLE,e._processToken(t))}function L5(e,t){switch(t.tagID){case W.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_ROW;break;case W.TH:case W.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(ht.TR,W.TR),e.insertionMode=Je.IN_ROW,N5(e,t);break;case W.CAPTION:case W.COL:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE,hS(e,t));break;default:hS(e,t)}}function uZ(e,t){const n=t.tagID;switch(t.tagID){case W.TBODY:case W.TFOOT:case W.THEAD:e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE);break;case W.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE,u_(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TD:case W.TH:case W.TR:break;default:u_(e,t)}}function N5(e,t){switch(t.tagID){case W.TH:case W.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,Ht.HTML),e.insertionMode=Je.IN_CELL,e.activeFormattingElements.insertMarker();break;case W.CAPTION:case W.COL:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:case W.TR:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE_BODY,L5(e,t));break;default:hS(e,t)}}function sFe(e,t){switch(t.tagID){case W.TR:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE_BODY);break;case W.TABLE:e.openElements.hasInTableScope(W.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE_BODY,uZ(e,t));break;case W.TBODY:case W.TFOOT:case W.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(W.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=Je.IN_TABLE_BODY,uZ(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:case W.TD:case W.TH:break;default:u_(e,t)}}function M_n(e,t){const n=t.tagID;pZ.has(n)?(e.openElements.hasInTableScope(W.TD)||e.openElements.hasInTableScope(W.TH))&&(e._closeTableCell(),N5(e,t)):Fl(e,t)}function D_n(e,t){const n=t.tagID;switch(n){case W.TD:case W.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Je.IN_ROW);break;case W.TABLE:case W.TBODY:case W.TFOOT:case W.THEAD:case W.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),sFe(e,t));break;case W.BODY:case W.CAPTION:case W.COL:case W.COLGROUP:case W.HTML:break;default:R5(e,t)}}function aFe(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.OPTION:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e._insertElement(t,Ht.HTML);break;case W.OPTGROUP:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Ht.HTML);break;case W.HR:e.openElements.currentTagId===W.OPTION&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.INPUT:case W.KEYGEN:case W.TEXTAREA:case W.SELECT:e.openElements.hasInSelectScope(W.SELECT)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),t.tagID!==W.SELECT&&e._processStartTag(t));break;case W.SCRIPT:case W.TEMPLATE:Cf(e,t);break;default:}}function lFe(e,t){switch(t.tagID){case W.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===W.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===W.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===W.OPTGROUP&&e.openElements.pop();break;case W.OPTION:e.openElements.currentTagId===W.OPTION&&e.openElements.pop();break;case W.SELECT:e.openElements.hasInSelectScope(W.SELECT)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode());break;case W.TEMPLATE:ov(e,t);break;default:}}function O_n(e,t){const n=t.tagID;n===W.CAPTION||n===W.TABLE||n===W.TBODY||n===W.TFOOT||n===W.THEAD||n===W.TR||n===W.TD||n===W.TH?(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),e._processStartTag(t)):aFe(e,t)}function F_n(e,t){const n=t.tagID;n===W.CAPTION||n===W.TABLE||n===W.TBODY||n===W.TFOOT||n===W.THEAD||n===W.TR||n===W.TD||n===W.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(W.SELECT),e._resetInsertionMode(),e.onEndTag(t)):lFe(e,t)}function B_n(e,t){switch(t.tagID){case W.BASE:case W.BASEFONT:case W.BGSOUND:case W.LINK:case W.META:case W.NOFRAMES:case W.SCRIPT:case W.STYLE:case W.TEMPLATE:case W.TITLE:Cf(e,t);break;case W.CAPTION:case W.COLGROUP:case W.TBODY:case W.TFOOT:case W.THEAD:e.tmplInsertionModeStack[0]=Je.IN_TABLE,e.insertionMode=Je.IN_TABLE,hS(e,t);break;case W.COL:e.tmplInsertionModeStack[0]=Je.IN_COLUMN_GROUP,e.insertionMode=Je.IN_COLUMN_GROUP,cZ(e,t);break;case W.TR:e.tmplInsertionModeStack[0]=Je.IN_TABLE_BODY,e.insertionMode=Je.IN_TABLE_BODY,L5(e,t);break;case W.TD:case W.TH:e.tmplInsertionModeStack[0]=Je.IN_ROW,e.insertionMode=Je.IN_ROW,N5(e,t);break;default:e.tmplInsertionModeStack[0]=Je.IN_BODY,e.insertionMode=Je.IN_BODY,Fl(e,t)}}function H_n(e,t){t.tagID===W.TEMPLATE&&ov(e,t)}function cFe(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(W.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):aZ(e,t)}function z_n(e,t){t.tagID===W.HTML?Fl(e,t):M5(e,t)}function uFe(e,t){var n;if(t.tagID===W.HTML){if(e.fragmentContext||(e.insertionMode=Je.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===W.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(r))===null||n===void 0)&&n.endTag)&&e._setEndLocation(r,t)}}else M5(e,t)}function M5(e,t){e.insertionMode=Je.IN_BODY,_5(e,t)}function U_n(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.FRAMESET:e._insertElement(t,Ht.HTML);break;case W.FRAME:e._appendElement(t,Ht.HTML),t.ackSelfClosing=!0;break;case W.NOFRAMES:Cf(e,t);break;default:}}function V_n(e,t){t.tagID===W.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==W.FRAMESET&&(e.insertionMode=Je.AFTER_FRAMESET))}function G_n(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.NOFRAMES:Cf(e,t);break;default:}}function W_n(e,t){t.tagID===W.HTML&&(e.insertionMode=Je.AFTER_AFTER_FRAMESET)}function j_n(e,t){t.tagID===W.HTML?Fl(e,t):D5(e,t)}function D5(e,t){e.insertionMode=Je.IN_BODY,_5(e,t)}function q_n(e,t){switch(t.tagID){case W.HTML:Fl(e,t);break;case W.NOFRAMES:Cf(e,t);break;default:}}function K_n(e,t){t.chars="�",e._insertCharacters(t)}function Y_n(e,t){e._insertCharacters(t),e.framesetOk=!1}function dFe(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Ht.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function X_n(e,t){if(pEn(t))dFe(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===Ht.MATHML?U6e(t):r===Ht.SVG&&(mEn(t),V6e(t)),rZ(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}function J_n(e,t){if(t.tagID===W.P||t.tagID===W.BR){dFe(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===Ht.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(r);if(o.toLowerCase()===t.tagName){t.tagName=o,e.openElements.shortenToLength(n);break}}}var fFe,hFe,pFe,Je,mFe,dZ,fZ,hZ,pZ,Z_n=Re((()=>{k6e(),cEn(),uEn(),$J(),hEn(),X6e(),T5(),WJ(),b0(),jJ(),fFe="hidden",hFe=8,pFe=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"})(Je||(Je={})),mFe={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},dZ=new Set([W.TABLE,W.TBODY,W.TFOOT,W.THEAD,W.TR]),fZ={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:cm,onParseError:null},hZ=class{constructor(e,t,n=null,r=null){this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=Je.INITIAL,this.originalInsertionMode=Je.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={...fZ,...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 x6e(this.options,this),this.activeFormattingElements=new M6e(this.treeAdapter),this.fragmentContextID=n?x5(this.treeAdapter.getTagName(n)):W.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new N6e(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={...fZ,...t};e!=null||(e=n.treeAdapter.createElement(ht.TEMPLATE,Ht.HTML,[]));const r=n.treeAdapter.createElement("documentmock",Ht.HTML,[]),o=new this(n,r,e);return o.fragmentContextID===W.TEMPLATE&&o.tmplInsertionModeStack.unshift(Je.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:mFe,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)===Ht.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&e!==void 0&&t!==void 0&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,Ht.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=Je.TEXT}switchToPlaintextParsing(){this.insertionMode=Je.TEXT,this.originalInsertionMode=Je.IN_BODY,this.tokenizer.state=vc.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)===ht.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Ht.HTML))switch(this.fragmentContextID){case W.TITLE:case W.TEXTAREA:this.tokenizer.state=vc.RCDATA;break;case W.STYLE:case W.XMP:case W.IFRAME:case W.NOEMBED:case W.NOFRAMES:case W.NOSCRIPT:this.tokenizer.state=vc.RAWTEXT;break;case W.SCRIPT:this.tokenizer.state=vc.SCRIPT_DATA;break;case W.PLAINTEXT:this.tokenizer.state=vc.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,Ht.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,Ht.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(ht.HTML,Ht.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,W.HTML)}_appendCommentNode(e,t){const n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const r=this.treeAdapter.getChildNodes(t),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===Go.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===W.SVG&&this.treeAdapter.getTagName(t)===ht.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===Ht.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===W.MGLYPH||e.tagID===W.MALIGNMARK)&&n!==void 0&&!this._isIntegrationPoint(n,t,Ht.HTML)}_processToken(e){switch(e.type){case Go.CHARACTER:this.onCharacter(e);break;case Go.NULL_CHARACTER:this.onNullCharacter(e);break;case Go.COMMENT:this.onComment(e);break;case Go.DOCTYPE:this.onDoctype(e);break;case Go.START_TAG:this._processStartTag(e);break;case Go.END_TAG:this.onEndTag(e);break;case Go.EOF:this.onEof(e);break;case Go.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e);break}}_isIntegrationPoint(e,t,n){const r=this.treeAdapter.getNamespaceURI(t),o=this.treeAdapter.getAttrList(t);return bEn(e,r,o,n)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(r=>r.type===Fh.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=Je.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(W.P),this.openElements.popUntilTagNamePopped(W.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case W.TR:this.insertionMode=Je.IN_ROW;return;case W.TBODY:case W.THEAD:case W.TFOOT:this.insertionMode=Je.IN_TABLE_BODY;return;case W.CAPTION:this.insertionMode=Je.IN_CAPTION;return;case W.COLGROUP:this.insertionMode=Je.IN_COLUMN_GROUP;return;case W.TABLE:this.insertionMode=Je.IN_TABLE;return;case W.BODY:this.insertionMode=Je.IN_BODY;return;case W.FRAMESET:this.insertionMode=Je.IN_FRAMESET;return;case W.SELECT:this._resetInsertionModeForSelect(e);return;case W.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case W.HTML:this.insertionMode=this.headElement?Je.AFTER_HEAD:Je.BEFORE_HEAD;return;case W.TD:case W.TH:if(e>0){this.insertionMode=Je.IN_CELL;return}break;case W.HEAD:if(e>0){this.insertionMode=Je.IN_HEAD;return}break}this.insertionMode=Je.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const n=this.openElements.tagIDs[t];if(n===W.TEMPLATE)break;if(n===W.TABLE){this.insertionMode=Je.IN_SELECT_IN_TABLE;return}}this.insertionMode=Je.IN_SELECT}_isElementCausesFosterParenting(e){return dZ.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case W.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===Ht.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case W.TABLE:{const n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}default:}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return A6e[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Y_n(this,e);return}switch(this.insertionMode){case Je.INITIAL:o_(this,e);break;case Je.BEFORE_HTML:i_(this,e);break;case Je.BEFORE_HEAD:s_(this,e);break;case Je.IN_HEAD:a_(this,e);break;case Je.IN_HEAD_NO_SCRIPT:l_(this,e);break;case Je.AFTER_HEAD:c_(this,e);break;case Je.IN_BODY:case Je.IN_CAPTION:case Je.IN_CELL:case Je.IN_TEMPLATE:Z6e(this,e);break;case Je.TEXT:case Je.IN_SELECT:case Je.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case Je.IN_TABLE:case Je.IN_TABLE_BODY:case Je.IN_ROW:lZ(this,e);break;case Je.IN_TABLE_TEXT:iFe(this,e);break;case Je.IN_COLUMN_GROUP:P5(this,e);break;case Je.AFTER_BODY:M5(this,e);break;case Je.AFTER_AFTER_BODY:D5(this,e);break;default:}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){K_n(this,e);return}switch(this.insertionMode){case Je.INITIAL:o_(this,e);break;case Je.BEFORE_HTML:i_(this,e);break;case Je.BEFORE_HEAD:s_(this,e);break;case Je.IN_HEAD:a_(this,e);break;case Je.IN_HEAD_NO_SCRIPT:l_(this,e);break;case Je.AFTER_HEAD:c_(this,e);break;case Je.TEXT:this._insertCharacters(e);break;case Je.IN_TABLE:case Je.IN_TABLE_BODY:case Je.IN_ROW:lZ(this,e);break;case Je.IN_COLUMN_GROUP:P5(this,e);break;case Je.AFTER_BODY:M5(this,e);break;case Je.AFTER_AFTER_BODY:D5(this,e);break;default:}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){sZ(this,e);return}switch(this.insertionMode){case Je.INITIAL:case Je.BEFORE_HTML:case Je.BEFORE_HEAD:case Je.IN_HEAD:case Je.IN_HEAD_NO_SCRIPT:case Je.AFTER_HEAD:case Je.IN_BODY:case Je.IN_TABLE:case Je.IN_CAPTION:case Je.IN_COLUMN_GROUP:case Je.IN_TABLE_BODY:case Je.IN_ROW:case Je.IN_CELL:case Je.IN_SELECT:case Je.IN_SELECT_IN_TABLE:case Je.IN_TEMPLATE:case Je.IN_FRAMESET:case Je.AFTER_FRAMESET:sZ(this,e);break;case Je.IN_TABLE_TEXT:f_(this,e);break;case Je.AFTER_BODY:xEn(this,e);break;case Je.AFTER_AFTER_BODY:case Je.AFTER_AFTER_FRAMESET:kEn(this,e);break;default:}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case Je.INITIAL:CEn(this,e);break;case Je.BEFORE_HEAD:case Je.IN_HEAD:case Je.IN_HEAD_NO_SCRIPT:case Je.AFTER_HEAD:this._err(e,At.misplacedDoctype);break;case Je.IN_TABLE_TEXT:f_(this,e);break;default:}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,At.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?X_n(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case Je.INITIAL:o_(this,e);break;case Je.BEFORE_HTML:EEn(this,e);break;case Je.BEFORE_HEAD:REn(this,e);break;case Je.IN_HEAD:Cf(this,e);break;case Je.IN_HEAD_NO_SCRIPT:NEn(this,e);break;case Je.AFTER_HEAD:DEn(this,e);break;case Je.IN_BODY:Fl(this,e);break;case Je.IN_TABLE:hS(this,e);break;case Je.IN_TABLE_TEXT:f_(this,e);break;case Je.IN_CAPTION:P_n(this,e);break;case Je.IN_COLUMN_GROUP:cZ(this,e);break;case Je.IN_TABLE_BODY:L5(this,e);break;case Je.IN_ROW:N5(this,e);break;case Je.IN_CELL:M_n(this,e);break;case Je.IN_SELECT:aFe(this,e);break;case Je.IN_SELECT_IN_TABLE:O_n(this,e);break;case Je.IN_TEMPLATE:B_n(this,e);break;case Je.AFTER_BODY:z_n(this,e);break;case Je.IN_FRAMESET:U_n(this,e);break;case Je.AFTER_FRAMESET:G_n(this,e);break;case Je.AFTER_AFTER_BODY:j_n(this,e);break;case Je.AFTER_AFTER_FRAMESET:q_n(this,e);break;default:}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?J_n(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case Je.INITIAL:o_(this,e);break;case Je.BEFORE_HTML:_En(this,e);break;case Je.BEFORE_HEAD:PEn(this,e);break;case Je.IN_HEAD:LEn(this,e);break;case Je.IN_HEAD_NO_SCRIPT:MEn(this,e);break;case Je.AFTER_HEAD:OEn(this,e);break;case Je.IN_BODY:R5(this,e);break;case Je.TEXT:A_n(this,e);break;case Je.IN_TABLE:u_(this,e);break;case Je.IN_TABLE_TEXT:f_(this,e);break;case Je.IN_CAPTION:L_n(this,e);break;case Je.IN_COLUMN_GROUP:N_n(this,e);break;case Je.IN_TABLE_BODY:uZ(this,e);break;case Je.IN_ROW:sFe(this,e);break;case Je.IN_CELL:D_n(this,e);break;case Je.IN_SELECT:lFe(this,e);break;case Je.IN_SELECT_IN_TABLE:F_n(this,e);break;case Je.IN_TEMPLATE:H_n(this,e);break;case Je.AFTER_BODY:uFe(this,e);break;case Je.IN_FRAMESET:V_n(this,e);break;case Je.AFTER_FRAMESET:W_n(this,e);break;case Je.AFTER_AFTER_BODY:D5(this,e);break;default:}}onEof(e){switch(this.insertionMode){case Je.INITIAL:o_(this,e);break;case Je.BEFORE_HTML:i_(this,e);break;case Je.BEFORE_HEAD:s_(this,e);break;case Je.IN_HEAD:a_(this,e);break;case Je.IN_HEAD_NO_SCRIPT:l_(this,e);break;case Je.AFTER_HEAD:c_(this,e);break;case Je.IN_BODY:case Je.IN_TABLE:case Je.IN_CAPTION:case Je.IN_COLUMN_GROUP:case Je.IN_TABLE_BODY:case Je.IN_ROW:case Je.IN_CELL:case Je.IN_SELECT:case Je.IN_SELECT_IN_TABLE:rFe(this,e);break;case Je.TEXT:I_n(this,e);break;case Je.IN_TABLE_TEXT:f_(this,e);break;case Je.IN_TEMPLATE:cFe(this,e);break;case Je.AFTER_BODY:case Je.IN_FRAMESET:case Je.AFTER_FRAMESET:case Je.AFTER_AFTER_BODY:case Je.AFTER_AFTER_FRAMESET:aZ(this,e);break;default:}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===Me.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 Je.IN_HEAD:case Je.IN_HEAD_NO_SCRIPT:case Je.AFTER_HEAD:case Je.TEXT:case Je.IN_COLUMN_GROUP:case Je.IN_SELECT:case Je.IN_SELECT_IN_TABLE:case Je.IN_FRAMESET:case Je.AFTER_FRAMESET:this._insertCharacters(e);break;case Je.IN_BODY:case Je.IN_CAPTION:case Je.IN_CELL:case Je.IN_TEMPLATE:case Je.AFTER_BODY:case Je.AFTER_AFTER_BODY:case Je.AFTER_AFTER_FRAMESET:J6e(this,e);break;case Je.IN_TABLE:case Je.IN_TABLE_BODY:case Je.IN_ROW:lZ(this,e);break;case Je.IN_TABLE_TEXT:oFe(this,e);break;default:}}},pZ=new Set([W.CAPTION,W.COL,W.COLGROUP,W.TBODY,W.TD,W.TFOOT,W.TH,W.THEAD,W.TR])})),Q_n,$_n=Re((()=>{b0(),$J(),Q_n=new Set([ht.AREA,ht.BASE,ht.BASEFONT,ht.BGSOUND,ht.BR,ht.COL,ht.EMBED,ht.FRAME,ht.HR,ht.IMG,ht.INPUT,ht.KEYGEN,ht.LINK,ht.META,ht.PARAM,ht.SOURCE,ht.TRACK,ht.WBR])}));function e2n(e,t){return hZ.parse(e,t)}function t2n(e,t,n){typeof e=="string"&&(n=t,t=e,e=null);const r=hZ.getFragmentParser(e,n);return r.tokenizer.write(t,!0),r.getFragment()}var n2n=Re((()=>{Z_n(),$J(),$_n(),T5(),X6e(),b0(),jJ(),k6e()})),gFe,r2n=Re((()=>{gFe={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 o2n(e,t){const n=t||IFe,r=n.onerror,o=e instanceof wN?e:new wN(e),i=n.fragment?t2n:e2n,s=String(o);return UCn(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=i2n(c),d=n[u],f=d??!0,h=typeof f=="number"?f:f?1:0;if(h){const m=gFe[u],g=new Nl(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=AFe[h],g.note=p(m.description),g.url=m.url===!1?void 0:yFe+c,r(g)}function p(m){return m.replace(vFe,g).replace(wFe,y);function g(v,b,I){const w=(I?Number.parseInt(I,10):0)*(b==="-"?-1:1);return a2n(s.charAt(l.startOffset+w))}function y(){return l2n(s.charCodeAt(l.startOffset))}}}}function i2n(e){return e.replace(bFe,s2n)}function s2n(e){return e.charAt(1).toUpperCase()}function a2n(e){return e==="`"?"` ` `":e}function l2n(e){return"0x"+e.toString(16).toUpperCase()}var yFe,bFe,vFe,wFe,AFe,IFe,c2n=Re((()=>{lb(),jCn(),n2n(),Lbe(),_be(),r2n(),yFe="https://html.spec.whatwg.org/multipage/parsing.html#parse-error-",bFe=/-[a-z]/g,vFe=/%c(?:([-+])(\d+))?/g,wFe=/%x/g,AFe={2:!0,1:!1,0:null},IFe={}})),u2n=Re((()=>{c2n()}));function d2n(e){const t=this,{emitParseErrors:n,...r}={...t.data("settings"),...e};t.parser=o;function o(i,s){return o2n(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 f2n=Re((()=>{u2n()})),h2n=xs({default:()=>d2n},1),p2n=Re((()=>{f2n()})),m2n,g2n,y2n,b2n,v2n,w2n,A2n,I2n,S2n,T2n,SFe=Re((()=>{m2n=-1,g2n=0,y2n=1,b2n=2,v2n=3,w2n=4,A2n=5,I2n=6,S2n=7,T2n=8})),mZ,TFe,gZ,x2n=Re((()=>{SFe(),mZ=typeof self=="object"?self:globalThis,TFe=(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 mZ[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 mZ[i](s),o)};return r},gZ=e=>TFe(new Map,e)(0)})),iv,xFe,kFe,pS,h_,CFe,yZ,k2n=Re((()=>{SFe(),iv="",{toString:xFe}={},{keys:kFe}=Object,pS=e=>{const t=typeof e;if(t!=="object"||!e)return[0,t];const n=xFe.call(e).slice(8,-1);switch(n){case"Array":return[1,iv];case"Object":return[2,iv];case"Date":return[3,iv];case"RegExp":return[4,iv];case"Map":return[5,iv];case"Set":return[6,iv];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},h_=([e,t])=>e===0&&(t==="function"||t==="symbol"),CFe=(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]=pS(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 kFe(s))(e||!h_(pS(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||!(h_(pS(f))||h_(pS(h))))&&u.push([i(f),i(h)]);return d}case 6:{const u=[],d=o([a,u],s);for(const f of s)(e||!h_(pS(f)))&&u.push(i(f));return d}}const{message:c}=s;return o([a,{name:l,message:c}],s)};return i},yZ=(e,{json:t,lossy:n}={})=>{const r=[];return CFe(!(t||n),!!t,new Map,r)(e),r}})),bZ,EFe=Re((()=>{x2n(),k2n(),bZ=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?gZ(yZ(e,t)):structuredClone(e):(e,t)=>gZ(yZ(e,t))}));function C2n(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Td(e[n]);return vZ(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function E2n(e){return vZ(t);function t(n){return n.tagName===e}}function vZ(e){return t;function t(n,r,o){return!!(_Fe(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function _2n(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function _Fe(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}var O5,Td,R2n=Re((()=>{O5=(function(e,t,n,r,o){const i=Td(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 _Fe(e)?i.call(o,e,n,r):!1}),Td=(function(e){if(e==null)return _2n;if(typeof e=="string")return E2n(e);if(typeof e=="object")return C2n(e);if(typeof e=="function")return vZ(e);throw new Error("Expected function, string, or array as `test`")})})),F5=Re((()=>{R2n()})),wZ,P2n=Re((()=>{F5(),wZ=Td(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"})})),RFe=Re((()=>{P2n()}));function PFe(e){return typeof e=="object"?e.type==="text"?LFe(e.value):!1:LFe(e)}function LFe(e){return e.replace(NFe,"")===""}var NFe,L2n=Re((()=>{NFe=/[ \t\n\f\r]/g})),MFe=Re((()=>{L2n()})),DFe,N2n=Re((()=>{DFe=["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"]})),OFe,M2n=Re((()=>{OFe=["button","input","select","textarea"]})),FFe,D2n=Re((()=>{FFe=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"]}));function O2n(e,t){BFe(e,{collapse:G2n((t||GFe).newlines?U2n:V2n),whitespace:"normal"})}function BFe(e,t){if("children"in e){const n={...t};return(e.type==="root"||UFe(e))&&(n.before=!0,n.after=!0),n.whitespace=W2n(e,t),B2n(e,n)}if(e.type==="text"){if(t.whitespace==="normal")return F2n(e,t);t.whitespace==="nowrap"&&(e.value=t.collapse(e.value))}return{ignore:B5(e),stripAtStart:!1,remove:!1}}function F2n(e,t){const n=t.collapse(e.value),r={ignore:!1,stripAtStart:!1,remove:!1};let o=0,i=n.length;return t.before&&VFe(n.charAt(0))&&o++,o!==i&&VFe(n.charAt(i-1))&&(t.after?i--:r.stripAtStart=!0),o===i?r.remove=!0:e.value=n.slice(o,i),r}function B2n(e,t){let n=t.before;const r=t.after,o=e.children;let i=o.length,s=-1;for(;++s<i;){const a=BFe(o[s],{...t,after:HFe(o,s,r),before:n});a.remove?(o.splice(s,1),s--,i--):a.ignore||(n=a.stripAtStart),zFe(o[s])&&(n=!1)}return{ignore:!1,stripAtStart:!!(n||r),remove:!1}}function HFe(e,t,n){for(;++t<e.length;){const r=e[t];let o=H2n(r);if(o===void 0&&"children"in r&&!z2n(r)&&(o=HFe(r.children,-1)),typeof o=="boolean")return o}return n}function H2n(e){if(e.type==="element"){if(zFe(e))return!1;if(UFe(e))return!0}else if(e.type==="text"){if(!PFe(e))return!1}else if(!B5(e))return!1}function zFe(e){return wZ(e)||O5(e,OFe)}function UFe(e){return O5(e,DFe)}function z2n(e){return!!(e.type==="element"&&e.properties.hidden)||B5(e)||O5(e,FFe)}function VFe(e){return e===" "||e===`
415
415
  `}function U2n(e){const t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function V2n(){return" "}function G2n(e){return t;function t(n){return String(n).replace(/[\t\n\v\f\r ]+/g,e)}}function W2n(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 GFe,B5,j2n=Re((()=>{RFe(),F5(),MFe(),$k(),N2n(),M2n(),D2n(),GFe={},B5=cb(["comment","doctype"])})),q2n=Re((()=>{j2n()}));function K2n(e){return function(t){O2n(t,e)}}var Y2n=Re((()=>{q2n()})),X2n=Re((()=>{Y2n()}));function WFe(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 J2n(e){const t=qFe(e),n=jFe(e);if(t&&n)return{start:t,end:n}}var jFe,qFe,Z2n=Re((()=>{jFe=WFe("end"),qFe=WFe("start")})),Q2n=Re((()=>{Z2n()}));function $2n(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 eRn=Re((()=>{}));function tRn(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)}var nRn=Re((()=>{}));function rRn(e,t){const n={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,n),n}var oRn=Re((()=>{}));function iRn(e,t){const n={type:"break"};return e.patch(t,n),n}var sRn=Re((()=>{})),AZ,aRn=Re((()=>{$k(),AZ=(function(e,t,n){const r=cb(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]})})),lRn=Re((()=>{aRn()}));function p_(e,t){const n=t||{},r="children"in e?e.children:[],o=kZ(e),i=XFe(e,{whitespace:n.whitespace||"normal",breakBefore:!1,breakAfter:!1}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...YFe(e,{whitespace:i,breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<r.length;)s.push(...KFe(r[a],e,{whitespace:i,breakBefore:a?void 0:o,breakAfter:a<r.length-1?H5(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(`
416
416
  `.repeat(c)||" "),c=-1,l.push(u))}return l.join("")}function KFe(e,t,n){return e.type==="element"?cRn(e,t,n):e.type==="text"?n.whitespace==="normal"?YFe(e,n):uRn(e):[]}function cRn(e,t,n){const r=XFe(e,n),o=e.children||[];let i=-1,s=[];if(ZFe(e))return s;let a,l;for(H5(e)||xZ(e)&&AZ(t,e,xZ)?l=`
417
- `:JFe(e)?(a=2,l=2):kZ(e)&&(a=1,l=1);++i<o.length;)s=s.concat(KFe(o[i],e,{whitespace:r,breakBefore:i?void 0:a,breakAfter:i<o.length-1?H5(o[i+1]):l}));return TZ(e)&&AZ(t,e,TZ)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function YFe(e,t){const n=String(e.value),r=[],o=[];let i=0;for(;i<=n.length;){IZ.lastIndex=i;const l=IZ.exec(n),c=l&&"index"in l?l.index:n.length;r.push(dRn(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 uRn(e){return[String(e.value)]}function dRn(e,t,n){const r=[];let o=0,i;for(;o<e.length;){SZ.lastIndex=o;const s=SZ.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 XFe(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 fRn(e){return!!(e.properties||{}).hidden}function hRn(e){return e.tagName==="td"||e.tagName==="th"}function pRn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var IZ,SZ,H5,TZ,JFe,xZ,ZFe,kZ,mRn=Re((()=>{lRn(),F5(),IZ=/\n/g,SZ=/[\t ]+/g,H5=Td("br"),TZ=Td(hRn),JFe=Td("p"),xZ=Td("tr"),ZFe=Td(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",fRn,pRn]),kZ=Td(["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"])})),m_=Re((()=>{mRn()}));function gRn(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 yRn=Re((()=>{}));function z5(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)===QFe){i=String(o[r]).slice(9);break}}const s={type:"code",lang:i||null,meta:null,value:gRn(p_(t))};return e.patch(t,s),s}var QFe,bRn=Re((()=>{m_(),yRn(),QFe="language-"}));function vRn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var wRn=Re((()=>{}));function CZ(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var ARn=Re((()=>{}));function EZ(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var $Fe=Re((()=>{}));function IRn(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=[...eBe(e,r[o].titles),...eBe(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:EZ(s),children:s};return e.patch(t,a),a}}function eBe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,SRn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:EZ(r),children:r}]}function SRn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var TRn=Re((()=>{$Fe()}));function U5(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var xRn=Re((()=>{}));function _Z(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 RZ=Re((()=>{}));function mS(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:_Z(e.all(t))};return e.patch(t,n),n}var kRn=Re((()=>{RZ()}));function CRn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var ERn=Re((()=>{}));function _Rn(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 RRn=Re((()=>{}));function tBe(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 PRn=Re((()=>{}));function g_(e,t){const n={type:"inlineCode",value:p_(t)};return e.patch(t,n),n}var LRn=Re((()=>{m_()}));function nBe(e,t){const n=[],r=[],o=t||e.properties||{},i=rBe(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=p_(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function rBe(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(...rBe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var oBe=Re((()=>{m_()}));function NRn(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||iBe:e.options.unchecked||sBe};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=nBe(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 iBe,sBe,MRn=Re((()=>{oBe(),iBe="[x]",sBe="[ ]"}));function DRn(e,t){const n=e.type==="element"&&aBe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var aBe,ORn=Re((()=>{aBe={}.hasOwnProperty})),FRn=Re((()=>{ORn()}));function BRn(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(!lBe.has(String(t[n])))return!1;return!0}var lBe,HRn=Re((()=>{lBe=new Set(["pingback","prefetch","stylesheet"])})),zRn=Re((()=>{HRn()}));function cBe(e){return!!(e.type==="text"||uBe(e)||wZ(e)||BRn(e)||dBe(e)&&DRn(e,"itemProp"))}var uBe,dBe,URn=Re((()=>{RFe(),FRn(),zRn(),F5(),uBe=Td(["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"]),dBe=Td("meta")})),fBe=Re((()=>{URn()}));function PZ(e,t){const{rest:n,checkbox:r}=pBe(t),o=r?!!r.properties.checked:null,i={type:"listItem",spread:hBe(n),checked:o,children:e.toFlow(e.all(n))};return e.patch(t,i),i}function hBe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(cBe(r))continue;if(r.tagName==="p"||n||hBe(r))return!0;n=!0}}return!1}function pBe(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}=pBe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var VRn=Re((()=>{fBe()}));function LZ(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),GRn);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:EZ(r),children:r};return e.patch(t,i),i}function GRn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var WRn=Re((()=>{$Fe()}));function V5(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!yBe(n)||"children"in n&&V5(n.children))return!0}return!1}function mBe(e){return gBe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?PFe(r.value):!1})?[]:[{type:"paragraph",children:_Z(n)}]}}function jRn(e){return gBe(e.children,t,n);function t(r){const o=NZ(e);return o.children=r,[o]}function n(r){if("children"in r&&"children"in e){const o=NZ(e),i=NZ(r);return o.children=r.children,i.children.push(o),i}return{...r}}}function gBe(e,t,n){const r=qRn(e),o=[];let i=[],s=-1;for(;++s<r.length;){const a=r[s];yBe(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 qRn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&V5(r.children)?t.push(...jRn(r)):t.push(r)}return t}function yBe(e){const t=e.data&&e.data.hName;return t?cBe({type:"element",tagName:t,properties:{},children:[]}):tG(e)}function NZ(e){return bZ({...e,children:[]})}var MZ=Re((()=>{EFe(),fBe(),MFe(),mwe(),RZ()}));function bBe(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(tC({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||V5(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:TN(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 KRn=Re((()=>{xN(),BN(),MZ()}));function vBe(e,t){const n=_Z(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var YRn=Re((()=>{RZ()}));function XRn(e,t){const n=e.options.quotes||wBe;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 wBe,JRn=Re((()=>{wBe=['"']}));function ZRn(e,t){let n=e.all(t);(e.options.document||V5(n))&&(n=mBe(n));const r={type:"root",children:n};return e.patch(t,r),r}var QRn=Re((()=>{MZ()}));function $Rn(e,t){const n=nBe(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 ePn=Re((()=>{oBe()}));function ABe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var tPn=Re((()=>{}));function IBe(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 nPn=Re((()=>{}));function rPn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),oPn)};return e.patch(t,n),n}function oPn(){return{type:"tableCell",children:[]}}var iPn=Re((()=>{}));function sPn(e,t){if(e.inTable){const c={type:"text",value:p_(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=aPn(t),o=e.toSpecificContent(e.all(t),SBe);r&&o.unshift(SBe());let i=-1;for(;++i<o.length;){const c=o[i];c.children=e.toSpecificContent(c.children,lPn)}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 aPn(e){const t={align:[null],headless:!0};let n=0,r=0;return tC(e,function(o){if(o.type==="element"){if(o.tagName==="table"&&e!==o)return zve;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 lPn(){return{type:"tableCell",children:[]}}function SBe(){return{type:"tableRow",children:[]}}var cPn=Re((()=>{m_(),BN()}));function uPn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var dPn=Re((()=>{}));function fPn(e,t){const n={type:"text",value:p_(t)};return e.patch(t,n),n}var hPn=Re((()=>{m_()}));function pPn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var mPn=Re((()=>{}));function go(e,t){return e.all(t)}function sa(e,t){return e.toFlow(e.all(t))}function yo(){}var TBe,xBe,gPn=Re((()=>{eRn(),nRn(),oRn(),sRn(),bRn(),wRn(),ARn(),TRn(),xRn(),kRn(),ERn(),RRn(),PRn(),LRn(),MRn(),VRn(),WRn(),KRn(),YRn(),JRn(),QRn(),ePn(),tPn(),nPn(),iPn(),cPn(),dPn(),hPn(),mPn(),TBe={comment:vRn,doctype:yo,root:ZRn,text:uPn},xBe={applet:yo,area:yo,basefont:yo,bgsound:yo,caption:yo,col:yo,colgroup:yo,command:yo,content:yo,datalist:yo,dialog:yo,element:yo,embed:yo,frame:yo,frameset:yo,isindex:yo,keygen:yo,link:yo,math:yo,menu:yo,menuitem:yo,meta:yo,nextid:yo,noembed:yo,noframes:yo,optgroup:yo,option:yo,param:yo,script:yo,shadow:yo,source:yo,spacer:yo,style:yo,svg:yo,template:yo,title:yo,track:yo,abbr:go,acronym:go,bdi:go,bdo:go,big:go,blink:go,button:go,canvas:go,cite:go,data:go,details:go,dfn:go,font:go,ins:go,label:go,map:go,marquee:go,meter:go,nobr:go,noscript:go,object:go,output:go,progress:go,rb:go,rbc:go,rp:go,rt:go,rtc:go,ruby:go,slot:go,small:go,span:go,sup:go,sub:go,tbody:go,tfoot:go,thead:go,time:go,address:sa,article:sa,aside:sa,body:sa,center:sa,div:sa,fieldset:sa,figcaption:sa,figure:sa,form:sa,footer:sa,header:sa,hgroup:sa,html:sa,legend:sa,main:sa,multicol:sa,nav:sa,picture:sa,section:sa,a:$2n,audio:bBe,b:ABe,base:tRn,blockquote:rRn,br:iRn,code:g_,dir:LZ,dl:IRn,dt:PZ,dd:PZ,del:CZ,em:U5,h1:mS,h2:mS,h3:mS,h4:mS,h5:mS,h6:mS,hr:CRn,i:U5,iframe:_Rn,img:tBe,image:tBe,input:NRn,kbd:g_,li:PZ,listing:z5,mark:U5,ol:LZ,p:vBe,plaintext:z5,pre:z5,q:XRn,s:CZ,samp:g_,select:$Rn,strike:CZ,strong:ABe,summary:vBe,table:sPn,td:IBe,textarea:fPn,th:IBe,tr:rPn,tt:g_,u:U5,ul:LZ,var:g_,video:bBe,wbr:pPn,xmp:z5}}));function yPn(e){return{all:bPn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...xBe,...e.handlers},inTable:!1,nodeHandlers:{...TBe,...e.nodeHandlers},one:vPn,options:e,patch:wPn,qNesting:0,resolve:APn,toFlow:IPn,toSpecificContent:SPn}}function bPn(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 vPn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(DZ.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(DZ.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 wPn(e,t){e.position&&(t.position=J2n(e))}function APn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function IPn(e){return mBe(e)}function SPn(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 DZ,TPn=Re((()=>{Q2n(),gPn(),MZ(),DZ={}.hasOwnProperty}));function kBe(e,t){const n=bZ(e),r=t||CBe,o=K2n({newlines:r.newlines===!0}),i=yPn(r);let s;o(n),tC(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:[]},tC(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 CBe,xPn=Re((()=>{EFe(),X2n(),BN(),TPn(),CBe={}})),kPn=Re((()=>{xPn()}));function CPn(e,t){return e&&"run"in e?async function(n,r){const o=kBe(n,{...OZ,...t});await e.run(o,r)}:function(n){return kBe(n,{...OZ,...e})}}var OZ,EPn=Re((()=>{kPn(),OZ={document:!0}})),_Pn=xs({default:()=>CPn},1),RPn=Re((()=>{EPn()}));function PPn(e){const t=e.modules?.trackChanges,n=e.trackedChanges;if(!t&&!n)return e;const r={...n??{},...t??{}};return{...e,trackedChanges:r}}var LPn="1.37.0-next.2",FZ=96,NPn=50,MPn=20,DPn=new Set([ss,gi,ta]),G5=e=>!!(e?.type?.name&&DPn.has(e.type.name)),OPn=e=>{if(!G5(e))return null;const t=typeof e.attrs?.id=="string"?e.attrs.id:"";return`${e.type?.name??""}:${t}`},W5=e=>{const t=new Set;if(!e)return t;for(const n of e.marks??[]){const r=OPn(n);r&&t.add(r)}return t},EBe=e=>!!(e.isInline&&e.marks?.some(G5)),j5=(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(EBe(l))return a=!0,!1}),a},_Be=(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(G5);if(!f.length){l=!0;return}a=!0,f.every(h=>h.type?.name==="trackInsert")||(c=!0)}),a&&!l&&!c},FPn=(e,t,n)=>{if(!_Be(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===ss),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},RBe=(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},BPn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof po))return null;const r=(t.docs??[])[0]??e.doc,o=n.from!==n.to&&n.slice.content.size===0?FPn(r,n.from,n.to):n.from===n.to&&n.slice.content.size>0?RBe(r,n.from):null;return o?{insertedMark:o,deletionMark:null,formatMark:null,deletionNodes:[],step:n,emitCommentEvent:!0}:null},HPn=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=W5(r.nodeBefore);if(!o.size)return!1;const i=W5(r.nodeAfter);for(const s of o)if(i.has(s))return!0;return!1},zPn=e=>{let t=!1;return e.descendants?.(n=>{if(EBe(n))return t=!0,!1}),t},UPn=(e,t,n)=>{const r=RBe(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(G5);if(a.length&&!a.every(l=>l.type?.name==="trackInsert"&&l.attrs?.id===o))return i=!1,!1}),i},VPn=(e,t,n)=>{if(!n.content||!zPn(n.content))return!1;const r=Math.max(0,Math.min(e.content.size,t)),o=e.resolve(r);return W5(o.nodeBefore).size>0||W5(o.nodeAfter).size>0},GPn=(e,t)=>e instanceof po?e.from!==e.to&&e.slice.content.size===0&&_Be(t,e.from,e.to)||e.from===e.to&&e.slice.content.size>0&&UPn(t,e.from,e.slice)?!1:j5(t,e.from,e.to)?!0:e.from===e.to&&e.slice.content.size>0?HPn(t,e.from)||VPn(t,e.from,e.slice):!1:e instanceof ah||e instanceof zc?j5(t,e.from,e.to):e instanceof rc?j5(t,e.from,e.to)||j5(t,e.gapFrom,e.gapTo):!1,WPn=(e,t)=>{if(!t.docChanged||!t.steps.length)return!1;const n=t.docs??[];return t.steps.some((r,o)=>GPn(r,n[o]??e.doc))},PBe=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 jPn(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 Fm extends xE{#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}}#l=null;#c=!1;#u=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=PPn(t),r=MI(),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.#u=n.fragment??null,this.#g(n),this.setOptions(n),this.#t=n.renderer??(r?new GNe:null),this.#w();const{setHighContrastMode:l}=tm();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#T(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#x(),html:()=>this.#x(),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)}#d(t){this.#t?.initContainerElement?.(t)}#h(){return MI()&&!this.options.isHeadless}#s(){return this.options.document??this.options.mockDocument??(MI()?document:null)}#a(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#A()}#w(){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.#l=new fet({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#A(){this.getDocumentIdentifier().then(t=>{if(!(!this.#l||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()??null;this.#l.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new YLe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#P(t,n,r,o){this.#n=t;try{const i=await o();return this.#n=n,i}catch(i){throw this.#n=r,i}}#T(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?N3():Vb()),this.#S(),this.#O(),this.#U(),this.#m()}#m(){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.#E.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.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#v(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.#u},a=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const c=H4().readFileSync(t),[u,d,f,h,p]=await Fm.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 Fm.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 Fm.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 Fm.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.#z();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.#F(),g5(this),this.#b(),this.#X();const l=this.#h();if(l&&(this.#d(this.options),this.#J()),this.#ee({includePlugins:!l}),!l){const c=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(c)}l&&(this.mount(this.options.element),this.#de()),l||this.#a(),l&&(this.initDefaultStyles(),this.#Q()),(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.#fe(),l&&(this.#K(),this.#R())}catch(r){if(r instanceof cs)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 ZLe(`Failed to load document: ${o.message}`,o)}}#f(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=Up(this);t&&(t.state={...cde},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}#b(){const t=Up(this);t&&(t.state=gb(this.converter?pf(this.converter):null),t.initialized=!0)}#k(){const t=Up(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#S(),this.#O(),this.#U(),this.#F(),g5(this),this.#b(),this.#X(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#h();if(this.#ee({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(n)}t&&(this.#d(this.options),this.#J(),this.mount(this.options.element),this.#de()),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.#E.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.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#Q()),(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.#fe(),t&&(this.#K(),this.#R())}#x(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Vb()),this.#S(),this.#O(),this.#U(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#h();this.#ee({includePlugins:!t}),t&&(this.#d(this.options),this.mount(this.options.element),this.#de()),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.#E.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a()}mount(t){this.#Z(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#A()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#E({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#g(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=Rht(iCn(this))),this.#r}#_(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=M5e(this);return Fxe(this,n,t??this.#_())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=D5e(this);return Fxe(this,n,t??this.#_())}resolveSelectionHandle(t){this.#y("ready","saving");const n=D4t(t);return n?PJ(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),O4t(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),cCn(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),uCn(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=$we(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"));MA(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}#R(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await V7t(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||VA(this.options.collaborationProvider,()=>{this.#I()})}replaceContent(t){this.setOptions({content:t}),this.#F(),this.initDefaultStyles(),this.#F(),g5(this),this.#X();const n=this.#$(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#B(r)}#M(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.#B(s)}#I(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#$(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#B(r);const o=this.options.ydoc;o&&o.getMap("meta").set("bodySectPr",n),this.#M(t.attrs??{}),setTimeout(()=>{this.#fe()},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)}#L(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.#L(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=()=>{mke(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}}#S(){const t=["extension","node","mark"],n=[$ln,qln,ecn,Yln,tcn,ncn],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=>PBe(s)),i=r.map(s=>PBe(s));this.extensionService=ocn.create(o,i,this)}#O(){this.#e=O0e.create({editor:this})}#F(){this.options.converter?this.converter=this.options.converter:this.converter=new ku({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#z(){const t=await Dle(fdn),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 Fm.loadXmlData(o,n);return{content:i,mediaFiles:a,fonts:l,fileSource:o}}async#ne(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#z();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#X(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#J(){this.#t?.initFonts?.(this)}async#Q(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#j(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#j(t){return t.filter(n=>{const r=fun(n),o=this.fontsImported.includes(n);return!r&&!o})}static async loadXmlData(t,n=!1,r){if(!t)return;const o=new dY;return[await o.getDocxData(t,n,{password:r?.password}),o.media,o.mediaFiles,o.fonts,o.decryptedFileData]}static getDocumentVersion(t){return ku.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=ku.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return ku.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),Fm.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=Hun(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}}#U(){this.schema=this.extensionService.schema}#$(){let t;try{const{mode:n,content:r,fragment:o,loadFromSchema:i}=this.options,s=this.#s(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?i&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#N(t)):(t=Ume(this.converter,this.schema,this),t=this.#N(t),this.options.markdown?t=yG(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=jk(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&&(Aj(o),t=gTt(o,this.schema))):(n==="text"||n==="html")&&(i&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=jk(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}#ee({includePlugins:t=!1}={}){if(this._state)return;const n=this.#$(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let o=xL.create(r);t&&(o=o.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=o,this._state=o}#de(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#Z(t){if(this._state||this.#ee(),!this.#t){if(!MI())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new GNe}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#B.bind(this),state:this.state,handleClick:this.#re.bind(this)}),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 v=s.depth;v>0;v--){const b=s.node(v);if(b.type.name==="tableCell"||b.type.name==="tableHeader"){i=jPn(b);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=v=>(l?.[v]??0)*FZ,f=d("top"),h=d("bottom"),p=d("left"),m=d("right"),g=u*FZ-f-h-NPn,y=c*FZ-p-m-MPn;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.#he(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#B(r),this.options.isNewFile||this.#fe()}#fe(){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(ii,{type:"force"});this.#B(r)},50)}#B(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),o=r(),i=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=Vo.getState(i)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=BPn(i,a),y=WPn(i,a);y&&m&&a.setMeta("protectTrackedReviewState",!0);const v=(p||c)&&!m||y;if(!v&&g&&!a.getMeta(Vo)&&a.setMeta(Vo,g),v&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");const b=this.options.user??{};a=v?GRe({tr:a,state:i,user:b,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:I,transactions:w}=i.applyTransaction(a);s=I,l=w.find(A=>A.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});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}))}dispatch(t){this.#B(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return an.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return Gme(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.#s();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=eh.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(o);let i=r.innerHTML;return t&&(i=tbe(i,n)),i}async getMarkdown(){const t=this.#s();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(()=>(PV(),gCt)),Promise.resolve().then(()=>(p2n(),h2n)),Promise.resolve().then(()=>(RPn(),_Pn)),Promise.resolve().then(()=>(cMe(),$fn)),Promise.resolve().then(()=>(fG(),s1t))]),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 bun(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&&!Eb()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#B(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#re(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return dun(t,n)}#N(t){const n=xL.create({schema:this.schema,doc:t}),{tr:r,doc:o}=n;return SVt(o,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:hun(this)}#ge(t=[]){const n=this.state.doc,r=new bz(n);return IVt(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#ge()}#ye(){if(!this.converter)return;const t=JOt(),n=(l,c)=>{const u=l?.sourceId;uC(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}#V(){if(!this.converter)return;const t=this.converter.wordIdAllocator?.getSourceIdMap?.()??{};if(Object.keys(t).length===0&&!this.#ie())return;const n=JSON.stringify({version:1,parts:t});ku.setStoredCustomProperty(this.converter.convertedXml,KIe,n,!1)}#ie(){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{$8t(Sb(this));const c=(i??this.converter.comments??[]).map(X=>{const Y=Array.isArray(X.elements)&&X.elements.length?X.elements:void 0,ne=X.commentJSON??Y??(typeof X.commentText=="string"?K3(X.commentText):void 0);return{...X,commentJSON:ne}}),u=this.#ge(c);this.#ye();const d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#p(),o||r)return d;this.#V();const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],I=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,w=this.converter.convertedXml["word/endnotes.xml"],A=w?.elements?.[0]?this.converter.schemaToXml(w.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],x=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,_=this.converter.convertedXml["word/_rels/settings.xml.rels"],E=_?.elements?.[0]?this.converter.schemaToXml(_.elements[0]):null,P=this.converter.addedMedia,k={};Object.entries(this.converter.convertedXml).forEach(([X,Y])=>{if(X.includes("header")||X.includes("footer")){const ne=Y,me=this.converter.schemaToXml(ne.elements?.[0]);k[X]=String(me.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,H=this.converter.convertedXml["docProps/core.xml"],U=H?.elements?.[0]?this.converter.schemaToXml(H.elements[0]):null,M={...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),...k,...F?{"docProps/app.xml":String(F)}:{},...U?{"docProps/core.xml":String(U)}:{}};if(p){let X=String(m);E?M["word/_rels/settings.xml.rels"]=String(E):/<\w+:attachedTemplate\b/i.test(X)&&(X=X.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=X}v&&(M["word/footnotes.xml"]=String(v)),I&&(M["word/_rels/footnotes.xml.rels"]=String(I)),A&&(M["word/endnotes.xml"]=String(A)),x&&(M["word/_rels/endnotes.xml.rels"]=String(x));const z=tW.map(X=>`word/${X}`);for(const X of z){const Y=this.converter.convertedXml[X];Y?.elements?.[0]?M[X]=String(this.converter.schemaToXml(Y.elements[0])):M[X]=null}const Z=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const X of Z){const Y=this.converter.convertedXml[X];Y?.elements?.[0]&&(M[X]=String(this.converter.schemaToXml(Y.elements[0])))}if(t){const X=vTn(this,this.converter.convertedXml,{finalDoc:!0});for(const[Y,ne]of Object.entries(X))M[Y]=ne}for(const X of Object.keys(this.converter.convertedXml)){if(!X.startsWith("customXml/")||!X.endsWith(".xml")&&!X.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,X))continue;const Y=this.converter.convertedXml[X];Y?.elements?.[0]&&(M[X]=String(this.converter.schemaToXml(Y.elements[0])))}const $=this.converter.removedCustomXmlPaths;if($ instanceof Set)for(const X of $)M[X]=null;const G=new dY;if(s){M["[Content_Types].xml"]=await G.updateContentTypes({files:this.options.content},P,!0,M,this.options.fonts);const X=this.options.content,{contentTypesXml:Y,relsXml:ne}=uNe({baseFiles:Array.isArray(X)||X&&typeof X=="object"?X:null,updatedDocs:M});return M["[Content_Types].xml"]=Y,M["_rels/.rels"]=ne,M}const ye=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#ne():this.options.content;return await G.updateZip({docx:ye,updatedDocs:M,originalDocxFile:this.options.fileSource,media:P,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#q(){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.#P("documentLoading","ready","closed",async()=>{await this.#v(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},v=new Fm({...g,deferDocumentLoad:!0});return await v.open(t,y),v}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#f(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#i)throw new XLe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#P("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#me(this.#i,n)})}async saveTo(t,n){this.#y("ready"),await this.#P("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#me(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#me(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=H4(),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 JLe("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.#q(),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=$Le(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",LPn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=$Le(t)||[],r=this.state.plugins.find(i=>this.#L(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 Fm.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.#F(),g5(this),this.#X(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#I(),QM(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=VA(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.#I();this.options.ydoc||this.#fe(),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}=AG;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=jk(n,this);r.replaceWith(o,i,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=kD.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await yun(t,this)}annotate(t=[],n=[],r=!1){const{state:o,schema:i}=this;let s=o.tr;if(s=kD.processTables({state:this.state,tr:s,annotationValues:t}),s=kD.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)}#he(){this.options.isHeaderOrFooter||this.options.isChildEditor||new FNe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#p(){this.options.isHeaderOrFooter||this.options.isChildEditor||new FNe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#K(){this.#t?.initDevTools?.(this)}},w0=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),A0={EXT:w0("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:w0("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:w0("--sd-comments-highlight-external-faded","#B1124B20"),INT:w0("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:w0("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:w0("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:w0("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:w0("--sd-comments-highlight-internal-nested-border","#07838399")},q5="track-change-focused",LBe=".superdoc-comment-highlight",qPn="[data-track-change-id]";function NBe(e){return e?e.split(",").filter(Boolean):[]}function KPn(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 MBe(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function BZ(e,t){MBe(e,"backgroundColor",t.css,t.fallback)}function YPn(e,t){MBe(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 XPn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#o(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(LBe);for(let r=0;r<t.length;r++){const o=t[r];o.style.backgroundColor="",o.style.boxShadow=""}const n=e.querySelectorAll(`.${q5}`);for(let r=0;r<n.length;r++)n[r].classList.remove(q5)}#o(e){const t=this.#e,n=e.querySelectorAll(LBe);for(let r=0;r<n.length;r++){const o=n[r],i=NBe(o.dataset.commentIds);if(i.length===0)continue;const s=new Set(NBe(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="":BZ(o,a?A0.INT:A0.EXT),o.style.boxShadow="";continue}const c=this.#n(t,i,o.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?o.style.backgroundColor="":BZ(o,u?A0.INT_ACTIVE:A0.EXT_ACTIVE),i.length>1?YPn(o,u?A0.INT_NESTED_BDR:A0.EXT_NESTED_BDR):o.style.boxShadow=""}else l?o.style.backgroundColor="":BZ(o,a?A0.INT_FADED:A0.EXT_FADED),o.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=KPn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(qPn);for(let r=0;r<n.length;r++){const o=n[r];t&&o.dataset.trackChangeId===t?o.classList.add(q5):o.classList.remove(q5)}}},JPn=[Vo,ii,DC,jg,lI,S3],ZPn=new Set([...JPn]),QPn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],HZ=`
417
+ `:JFe(e)?(a=2,l=2):kZ(e)&&(a=1,l=1);++i<o.length;)s=s.concat(KFe(o[i],e,{whitespace:r,breakBefore:i?void 0:a,breakAfter:i<o.length-1?H5(o[i+1]):l}));return TZ(e)&&AZ(t,e,TZ)&&s.push(" "),a&&s.unshift(a),l&&s.push(l),s}function YFe(e,t){const n=String(e.value),r=[],o=[];let i=0;for(;i<=n.length;){IZ.lastIndex=i;const l=IZ.exec(n),c=l&&"index"in l?l.index:n.length;r.push(dRn(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 uRn(e){return[String(e.value)]}function dRn(e,t,n){const r=[];let o=0,i;for(;o<e.length;){SZ.lastIndex=o;const s=SZ.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 XFe(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 fRn(e){return!!(e.properties||{}).hidden}function hRn(e){return e.tagName==="td"||e.tagName==="th"}function pRn(e){return e.tagName==="dialog"&&!(e.properties||{}).open}var IZ,SZ,H5,TZ,JFe,xZ,ZFe,kZ,mRn=Re((()=>{lRn(),F5(),IZ=/\n/g,SZ=/[\t ]+/g,H5=Td("br"),TZ=Td(hRn),JFe=Td("p"),xZ=Td("tr"),ZFe=Td(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",fRn,pRn]),kZ=Td(["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"])})),m_=Re((()=>{mRn()}));function gRn(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 yRn=Re((()=>{}));function z5(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)===QFe){i=String(o[r]).slice(9);break}}const s={type:"code",lang:i||null,meta:null,value:gRn(p_(t))};return e.patch(t,s),s}var QFe,bRn=Re((()=>{m_(),yRn(),QFe="language-"}));function vRn(e,t){const n={type:"html",value:"<!--"+t.value+"-->"};return e.patch(t,n),n}var wRn=Re((()=>{}));function CZ(e,t){const n={type:"delete",children:e.all(t)};return e.patch(t,n),n}var ARn=Re((()=>{}));function EZ(e){let t=-1;if(e.length>1){for(;++t<e.length;)if(e[t].spread)return!0}return!1}var $Fe=Re((()=>{}));function IRn(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=[...eBe(e,r[o].titles),...eBe(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:EZ(s),children:s};return e.patch(t,a),a}}function eBe(e,t){const n=e.all({type:"root",children:t}),r=e.toSpecificContent(n,SRn);return r.length===0?[]:r.length===1?r[0].children:[{type:"list",ordered:!1,start:null,spread:EZ(r),children:r}]}function SRn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var TRn=Re((()=>{$Fe()}));function U5(e,t){const n={type:"emphasis",children:e.all(t)};return e.patch(t,n),n}var xRn=Re((()=>{}));function _Z(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 RZ=Re((()=>{}));function mS(e,t){const n={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:_Z(e.all(t))};return e.patch(t,n),n}var kRn=Re((()=>{RZ()}));function CRn(e,t){const n={type:"thematicBreak"};return e.patch(t,n),n}var ERn=Re((()=>{}));function _Rn(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 RRn=Re((()=>{}));function tBe(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 PRn=Re((()=>{}));function g_(e,t){const n={type:"inlineCode",value:p_(t)};return e.patch(t,n),n}var LRn=Re((()=>{m_()}));function nBe(e,t){const n=[],r=[],o=t||e.properties||{},i=rBe(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=p_(u),h=f||String(d.label||""),p=String(d.value||"")||f;r.push([p,h===p?void 0:h])}return r}function rBe(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(...rBe(r)),r.type==="element"&&r.tagName==="option"&&(!r.properties||!r.properties.disabled)&&t.push(r)}return t}var oBe=Re((()=>{m_()}));function NRn(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||iBe:e.options.unchecked||sBe};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=nBe(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 iBe,sBe,MRn=Re((()=>{oBe(),iBe="[x]",sBe="[ ]"}));function DRn(e,t){const n=e.type==="element"&&aBe.call(e.properties,t)&&e.properties[t];return n!=null&&n!==!1}var aBe,ORn=Re((()=>{aBe={}.hasOwnProperty})),FRn=Re((()=>{ORn()}));function BRn(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(!lBe.has(String(t[n])))return!1;return!0}var lBe,HRn=Re((()=>{lBe=new Set(["pingback","prefetch","stylesheet"])})),zRn=Re((()=>{HRn()}));function cBe(e){return!!(e.type==="text"||uBe(e)||wZ(e)||BRn(e)||dBe(e)&&DRn(e,"itemProp"))}var uBe,dBe,URn=Re((()=>{RFe(),FRn(),zRn(),F5(),uBe=Td(["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"]),dBe=Td("meta")})),fBe=Re((()=>{URn()}));function PZ(e,t){const{rest:n,checkbox:r}=pBe(t),o=r?!!r.properties.checked:null,i={type:"listItem",spread:hBe(n),checked:o,children:e.toFlow(e.all(n))};return e.patch(t,i),i}function hBe(e){let t=-1,n=!1;for(;++t<e.children.length;){const r=e.children[t];if(r.type==="element"){if(cBe(r))continue;if(r.tagName==="p"||n||hBe(r))return!0;n=!0}}return!1}function pBe(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}=pBe(t);if(n)return{checkbox:n,rest:{...e,children:[r,...e.children.slice(1)]}}}return{checkbox:void 0,rest:e}}var VRn=Re((()=>{fBe()}));function LZ(e,t){const n=t.tagName==="ol",r=e.toSpecificContent(e.all(t),GRn);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:EZ(r),children:r};return e.patch(t,i),i}function GRn(){return{type:"listItem",spread:!1,checked:null,children:[]}}var WRn=Re((()=>{$Fe()}));function V5(e){let t=-1;for(;++t<e.length;){const n=e[t];if(!yBe(n)||"children"in n&&V5(n.children))return!0}return!1}function mBe(e){return gBe(e,t,function(n){return n});function t(n){return n.every(function(r){return r.type==="text"?PFe(r.value):!1})?[]:[{type:"paragraph",children:_Z(n)}]}}function jRn(e){return gBe(e.children,t,n);function t(r){const o=NZ(e);return o.children=r,[o]}function n(r){if("children"in r&&"children"in e){const o=NZ(e),i=NZ(r);return o.children=r.children,i.children.push(o),i}return{...r}}}function gBe(e,t,n){const r=qRn(e),o=[];let i=[],s=-1;for(;++s<r.length;){const a=r[s];yBe(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 qRn(e){const t=[];let n=-1;for(;++n<e.length;){const r=e[n];(r.type==="delete"||r.type==="link")&&V5(r.children)?t.push(...jRn(r)):t.push(r)}return t}function yBe(e){const t=e.data&&e.data.hName;return t?cBe({type:"element",tagName:t,properties:{},children:[]}):tG(e)}function NZ(e){return bZ({...e,children:[]})}var MZ=Re((()=>{EFe(),fBe(),MFe(),mwe(),RZ()}));function bBe(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(tC({type:"root",children:a},function(u){if(u.type==="link")return s=!0,!1}),s||V5(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:TN(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 KRn=Re((()=>{xN(),BN(),MZ()}));function vBe(e,t){const n=_Z(e.all(t));if(n.length>0){const r={type:"paragraph",children:n};return e.patch(t,r),r}}var YRn=Re((()=>{RZ()}));function XRn(e,t){const n=e.options.quotes||wBe;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 wBe,JRn=Re((()=>{wBe=['"']}));function ZRn(e,t){let n=e.all(t);(e.options.document||V5(n))&&(n=mBe(n));const r={type:"root",children:n};return e.patch(t,r),r}var QRn=Re((()=>{MZ()}));function $Rn(e,t){const n=nBe(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 ePn=Re((()=>{oBe()}));function ABe(e,t){const n={type:"strong",children:e.all(t)};return e.patch(t,n),n}var tPn=Re((()=>{}));function IBe(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 nPn=Re((()=>{}));function rPn(e,t){const n={type:"tableRow",children:e.toSpecificContent(e.all(t),oPn)};return e.patch(t,n),n}function oPn(){return{type:"tableCell",children:[]}}var iPn=Re((()=>{}));function sPn(e,t){if(e.inTable){const c={type:"text",value:p_(t)};return e.patch(t,c),c}e.inTable=!0;const{align:n,headless:r}=aPn(t),o=e.toSpecificContent(e.all(t),SBe);r&&o.unshift(SBe());let i=-1;for(;++i<o.length;){const c=o[i];c.children=e.toSpecificContent(c.children,lPn)}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 aPn(e){const t={align:[null],headless:!0};let n=0,r=0;return tC(e,function(o){if(o.type==="element"){if(o.tagName==="table"&&e!==o)return zve;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 lPn(){return{type:"tableCell",children:[]}}function SBe(){return{type:"tableRow",children:[]}}var cPn=Re((()=>{m_(),BN()}));function uPn(e,t){const n={type:"text",value:t.value};return e.patch(t,n),n}var dPn=Re((()=>{}));function fPn(e,t){const n={type:"text",value:p_(t)};return e.patch(t,n),n}var hPn=Re((()=>{m_()}));function pPn(e,t){const n={type:"text",value:"​"};return e.patch(t,n),n}var mPn=Re((()=>{}));function go(e,t){return e.all(t)}function sa(e,t){return e.toFlow(e.all(t))}function yo(){}var TBe,xBe,gPn=Re((()=>{eRn(),nRn(),oRn(),sRn(),bRn(),wRn(),ARn(),TRn(),xRn(),kRn(),ERn(),RRn(),PRn(),LRn(),MRn(),VRn(),WRn(),KRn(),YRn(),JRn(),QRn(),ePn(),tPn(),nPn(),iPn(),cPn(),dPn(),hPn(),mPn(),TBe={comment:vRn,doctype:yo,root:ZRn,text:uPn},xBe={applet:yo,area:yo,basefont:yo,bgsound:yo,caption:yo,col:yo,colgroup:yo,command:yo,content:yo,datalist:yo,dialog:yo,element:yo,embed:yo,frame:yo,frameset:yo,isindex:yo,keygen:yo,link:yo,math:yo,menu:yo,menuitem:yo,meta:yo,nextid:yo,noembed:yo,noframes:yo,optgroup:yo,option:yo,param:yo,script:yo,shadow:yo,source:yo,spacer:yo,style:yo,svg:yo,template:yo,title:yo,track:yo,abbr:go,acronym:go,bdi:go,bdo:go,big:go,blink:go,button:go,canvas:go,cite:go,data:go,details:go,dfn:go,font:go,ins:go,label:go,map:go,marquee:go,meter:go,nobr:go,noscript:go,object:go,output:go,progress:go,rb:go,rbc:go,rp:go,rt:go,rtc:go,ruby:go,slot:go,small:go,span:go,sup:go,sub:go,tbody:go,tfoot:go,thead:go,time:go,address:sa,article:sa,aside:sa,body:sa,center:sa,div:sa,fieldset:sa,figcaption:sa,figure:sa,form:sa,footer:sa,header:sa,hgroup:sa,html:sa,legend:sa,main:sa,multicol:sa,nav:sa,picture:sa,section:sa,a:$2n,audio:bBe,b:ABe,base:tRn,blockquote:rRn,br:iRn,code:g_,dir:LZ,dl:IRn,dt:PZ,dd:PZ,del:CZ,em:U5,h1:mS,h2:mS,h3:mS,h4:mS,h5:mS,h6:mS,hr:CRn,i:U5,iframe:_Rn,img:tBe,image:tBe,input:NRn,kbd:g_,li:PZ,listing:z5,mark:U5,ol:LZ,p:vBe,plaintext:z5,pre:z5,q:XRn,s:CZ,samp:g_,select:$Rn,strike:CZ,strong:ABe,summary:vBe,table:sPn,td:IBe,textarea:fPn,th:IBe,tr:rPn,tt:g_,u:U5,ul:LZ,var:g_,video:bBe,wbr:pPn,xmp:z5}}));function yPn(e){return{all:bPn,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...xBe,...e.handlers},inTable:!1,nodeHandlers:{...TBe,...e.nodeHandlers},one:vPn,options:e,patch:wPn,qNesting:0,resolve:APn,toFlow:IPn,toSpecificContent:SPn}}function bPn(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 vPn(e,t){if(e.type==="element"){if(e.properties&&e.properties.dataMdast==="ignore")return;if(DZ.call(this.handlers,e.tagName))return this.handlers[e.tagName](this,e,t)||void 0}else if(DZ.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 wPn(e,t){e.position&&(t.position=J2n(e))}function APn(e){const t=this.frozenBaseUrl;return e==null?"":t?String(new URL(e,t)):e}function IPn(e){return mBe(e)}function SPn(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 DZ,TPn=Re((()=>{Q2n(),gPn(),MZ(),DZ={}.hasOwnProperty}));function kBe(e,t){const n=bZ(e),r=t||CBe,o=K2n({newlines:r.newlines===!0}),i=yPn(r);let s;o(n),tC(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:[]},tC(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 CBe,xPn=Re((()=>{EFe(),X2n(),BN(),TPn(),CBe={}})),kPn=Re((()=>{xPn()}));function CPn(e,t){return e&&"run"in e?async function(n,r){const o=kBe(n,{...OZ,...t});await e.run(o,r)}:function(n){return kBe(n,{...OZ,...e})}}var OZ,EPn=Re((()=>{kPn(),OZ={document:!0}})),_Pn=xs({default:()=>CPn},1),RPn=Re((()=>{EPn()}));function PPn(e){const t=e.modules?.trackChanges,n=e.trackedChanges;if(!t&&!n)return e;const r={...n??{},...t??{}};return{...e,trackedChanges:r}}var LPn="1.37.0-next.3",FZ=96,NPn=50,MPn=20,DPn=new Set([ss,gi,ta]),G5=e=>!!(e?.type?.name&&DPn.has(e.type.name)),OPn=e=>{if(!G5(e))return null;const t=typeof e.attrs?.id=="string"?e.attrs.id:"";return`${e.type?.name??""}:${t}`},W5=e=>{const t=new Set;if(!e)return t;for(const n of e.marks??[]){const r=OPn(n);r&&t.add(r)}return t},EBe=e=>!!(e.isInline&&e.marks?.some(G5)),j5=(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(EBe(l))return a=!0,!1}),a},_Be=(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(G5);if(!f.length){l=!0;return}a=!0,f.every(h=>h.type?.name==="trackInsert")||(c=!0)}),a&&!l&&!c},FPn=(e,t,n)=>{if(!_Be(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===ss),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},RBe=(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},BPn=(e,t)=>{if(!t.docChanged||t.steps.length!==1)return null;const[n]=t.steps;if(!(n instanceof po))return null;const r=(t.docs??[])[0]??e.doc,o=n.from!==n.to&&n.slice.content.size===0?FPn(r,n.from,n.to):n.from===n.to&&n.slice.content.size>0?RBe(r,n.from):null;return o?{insertedMark:o,deletionMark:null,formatMark:null,deletionNodes:[],step:n,emitCommentEvent:!0}:null},HPn=(e,t)=>{const n=Math.max(0,Math.min(e.content.size,t)),r=e.resolve(n),o=W5(r.nodeBefore);if(!o.size)return!1;const i=W5(r.nodeAfter);for(const s of o)if(i.has(s))return!0;return!1},zPn=e=>{let t=!1;return e.descendants?.(n=>{if(EBe(n))return t=!0,!1}),t},UPn=(e,t,n)=>{const r=RBe(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(G5);if(a.length&&!a.every(l=>l.type?.name==="trackInsert"&&l.attrs?.id===o))return i=!1,!1}),i},VPn=(e,t,n)=>{if(!n.content||!zPn(n.content))return!1;const r=Math.max(0,Math.min(e.content.size,t)),o=e.resolve(r);return W5(o.nodeBefore).size>0||W5(o.nodeAfter).size>0},GPn=(e,t)=>e instanceof po?e.from!==e.to&&e.slice.content.size===0&&_Be(t,e.from,e.to)||e.from===e.to&&e.slice.content.size>0&&UPn(t,e.from,e.slice)?!1:j5(t,e.from,e.to)?!0:e.from===e.to&&e.slice.content.size>0?HPn(t,e.from)||VPn(t,e.from,e.slice):!1:e instanceof ah||e instanceof zc?j5(t,e.from,e.to):e instanceof rc?j5(t,e.from,e.to)||j5(t,e.gapFrom,e.gapTo):!1,WPn=(e,t)=>{if(!t.docChanged||!t.steps.length)return!1;const n=t.docs??[];return t.steps.some((r,o)=>GPn(r,n[o]??e.doc))},PBe=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 jPn(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 Fm extends xE{#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}}#l=null;#c=!1;#u=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=PPn(t),r=MI(),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.#u=n.fragment??null,this.#g(n),this.setOptions(n),this.#t=n.renderer??(r?new GNe:null),this.#w();const{setHighContrastMode:l}=tm();if(this.setHighContrastMode=l,n.deferDocumentLoad===!0)this.#T(),this.#n="initialized";else{const c={docx:()=>this.#C(),text:()=>this.#x(),html:()=>this.#x(),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)}#d(t){this.#t?.initContainerElement?.(t)}#h(){return MI()&&!this.options.isHeadless}#s(){return this.options.document??this.options.mockDocument??(MI()?document:null)}#a(){setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#A()}#w(){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.#l=new fet({enabled:!0,endpoint:t.endpoint,licenseKey:r,metadata:t.metadata}),console.debug("[super-editor] Telemetry: enabled")}catch{}}#A(){this.getDocumentIdentifier().then(t=>{if(!(!this.#l||this.#c))try{const n=this.converter?.getDocumentCreatedTimestamp?.()??null;this.#l.trackDocumentOpen(t,n),this.#c=!0}catch{}})}#y(...t){if(!t.includes(this.#n))throw new YLe(`Invalid operation: editor is in '${this.#n}' state, expected one of: ${t.join(", ")}`)}async#P(t,n,r,o){this.#n=t;try{const i=await o();return this.#n=n,i}catch(i){throw this.#n=r,i}}#T(){this.options.extensions?.length||(this.options.extensions=this.options.mode==="docx"?N3():Vb()),this.#S(),this.#O(),this.#U(),this.#m()}#m(){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.#E.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.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick)}async#v(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.#u},a=n?.password?{password:n.password}:void 0;if(typeof t=="string")if(typeof process<"u"&&process.versions?.node){const c=H4().readFileSync(t),[u,d,f,h,p]=await Fm.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 Fm.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 Fm.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 Fm.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.#z();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.#F(),g5(this),this.#b(),this.#X();const l=this.#h();if(l&&(this.#d(this.options),this.#J()),this.#ee({includePlugins:!l}),!l){const c=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(c)}l&&(this.mount(this.options.element),this.#de()),l||this.#a(),l&&(this.initDefaultStyles(),this.#Q()),(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.#fe(),l&&(this.#K(),this.#R())}catch(r){if(r instanceof cs)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 ZLe(`Failed to load document: ${o.message}`,o)}}#f(){this.unmount(),this.destroyHeaderFooterEditors(),this.converter=void 0,this.storage.image&&(this.storage.image.media={});const t=Up(this);t&&(t.state={...cde},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}#b(){const t=Up(this);t&&(t.state=gb(this.converter?pf(this.converter):null),t.initialized=!0)}#k(){const t=Up(this);t?.initialized&&this.emit("protectionChanged",{editor:this,state:t.state,source:"init"})}#C(){this.#S(),this.#O(),this.#U(),this.#F(),g5(this),this.#b(),this.#X(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#h();if(this.#ee({includePlugins:!t}),!t){const n=this.state.tr.setMeta("forcePluginPass",!0).setMeta("addToHistory",!1);this.#B(n)}t&&(this.#d(this.options),this.#J(),this.mount(this.options.element),this.#de()),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.#E.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.on("exception",this.options.onException),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a(),this.initializeCollaborationData(),t&&(this.initDefaultStyles(),this.#Q()),(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.#fe(),t&&(this.#K(),this.#R())}#x(){(!this.options.extensions||!this.options.extensions.length)&&(this.options.extensions=Vb()),this.#S(),this.#O(),this.#U(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError);const t=this.#h();this.#ee({includePlugins:!t}),t&&(this.#d(this.options),this.mount(this.options.element),this.#de()),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.#E.bind(this)),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("commentsLoaded",this.options.onCommentsLoaded),this.on("commentClick",this.options.onCommentClicked),this.on("locked",this.options.onDocumentLocked),this.on("list-definitions-change",this.options.onListDefinitionsChange),this.on("pointerDown",this.options.onPointerDown),this.on("pointerUp",this.options.onPointerUp),this.on("rightClick",this.options.onRightClick),t||this.#a()}mount(t){this.#Z(t),setTimeout(()=>{this.isDestroyed||this.emit("create",{editor:this})},0),this.#A()}unmount(){this.#t?this.#t.destroy():this.view&&this.view.destroy(),this.view=void 0}#E({editor:t,event:n}){this.toolbar?.setActiveEditor?.(t),this.options.onFocus?.({editor:t,event:n})}setToolbar(t){this.toolbar=t}#g(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=Rht(iCn(this))),this.#r}#_(){const t=this.options.headerFooterType;return t==="header"||t==="footer"?t:"body"}captureCurrentSelectionHandle(t){this.#y("ready","saving");const n=M5e(this);return Fxe(this,n,t??this.#_())}captureEffectiveSelectionHandle(t){this.#y("ready","saving");const n=D5e(this);return Fxe(this,n,t??this.#_())}resolveSelectionHandle(t){this.#y("ready","saving");const n=D4t(t);return n?PJ(t._owner,n):null}releaseSelectionHandle(t){this.#y("ready","saving"),O4t(t)}getCurrentSelectionRange(){return this.#y("ready","saving"),cCn(this)}getEffectiveSelectionRange(){return this.#y("ready","saving"),uCn(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=$we(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"));MA(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}#R(){this.#t?.registerCopyHandler?.(this)}async generateCollaborationUpdate(){return await V7t(this)}initializeCollaborationData(){!this.options.isNewFile||!this.options.collaborationProvider||VA(this.options.collaborationProvider,()=>{this.#I()})}replaceContent(t){this.setOptions({content:t}),this.#F(),this.initDefaultStyles(),this.#F(),g5(this),this.#X();const n=this.#$(),r=this.state.tr.replaceWith(0,this.state.doc.content.size,n);r.setMeta("replaceContent",!0),this.#B(r)}#M(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.#B(s)}#I(){if(!this.options.isNewFile)return;this.options.isNewFile=!1;const t=this.#$(),n=JSON.parse(JSON.stringify(t.attrs?.bodySectPr??null)),r=this.state.tr.replaceWith(0,this.state.doc.content.size,t).setMeta("addToHistory",!1);this.#B(r);const o=this.options.ydoc;o&&o.getMap("meta").set("bodySectPr",n),this.#M(t.attrs??{}),setTimeout(()=>{this.#fe()},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)}#L(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.#L(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=()=>{mke(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}}#S(){const t=["extension","node","mark"],n=[$ln,qln,ecn,Yln,tcn,ncn],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=>PBe(s)),i=r.map(s=>PBe(s));this.extensionService=ocn.create(o,i,this)}#O(){this.#e=O0e.create({editor:this})}#F(){this.options.converter?this.converter=this.options.converter:this.converter=new ku({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#z(){const t=await Dle(fdn),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 Fm.loadXmlData(o,n);return{content:i,mediaFiles:a,fonts:l,fileSource:o}}async#ne(){if(Array.isArray(this.options.content))return this.options.content;const t=await this.#z();return this.options.content=t.content,this.options.mediaFiles={...t.mediaFiles,...this.options.mediaFiles??{}},this.options.fonts={...t.fonts,...this.options.fonts??{}},t.content}#X(){if(this.options.isChildEditor)return;if(!this.options.ydoc){this.storage.image.media=this.options.mediaFiles;return}const t=this.options.ydoc.getMap("media");this.options.isNewFile?(Object.entries(this.options.mediaFiles).forEach(([n,r])=>{t.set(n,r)}),this.storage.image.media=this.options.mediaFiles):this.storage.image.media=Object.fromEntries(t.entries())}#J(){this.#t?.initFonts?.(this)}async#Q(){if(!(!this.options.onFontsResolved||typeof this.options.onFontsResolved!="function")&&!this.options.isHeadless)try{const t=this.converter.getDocumentFonts(),n={documentFonts:t,unsupportedFonts:this.#j(t)};this.emit("fonts-resolved",n)}catch{console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts")}}#j(t){return t.filter(n=>{const r=fun(n),o=this.fontsImported.includes(n);return!r&&!o})}static async loadXmlData(t,n=!1,r){if(!t)return;const o=new dY;return[await o.getDocxData(t,n,{password:r?.password}),o.media,o.mediaFiles,o.fonts,o.decryptedFileData]}static getDocumentVersion(t){return ku.getStoredSuperdocVersion(t)}static setDocumentVersion(t,n){const r=ku.setStoredSuperdocVersion(t,n);return typeof r=="string"?r:n}static getDocumentGuid(t){return ku.extractDocumentGuid(t)}static updateDocumentVersion(t,n){return console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead"),Fm.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=Hun(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}}#U(){this.schema=this.extensionService.schema}#$(){let t;try{const{mode:n,content:r,fragment:o,loadFromSchema:i}=this.options,s=this.#s(),a=l=>typeof l=="object"&&l!==null&&!Array.isArray(l);n==="docx"?i&&a(r)?(t=this.schema.nodeFromJSON(r),t=this.#N(t)):(t=Ume(this.converter,this.schema,this),t=this.#N(t),this.options.markdown?t=yG(this.options.markdown,this,{isImport:!0,document:s,onUnsupportedContent:this.options.onUnsupportedContent,warnOnUnsupportedContent:this.options.warnOnUnsupportedContent}):this.options.html?t=jk(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&&(Aj(o),t=gTt(o,this.schema))):(n==="text"||n==="html")&&(i&&a(r)?t=this.schema.nodeFromJSON(r):typeof r=="string"?t=jk(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}#ee({includePlugins:t=!1}={}){if(this._state)return;const n=this.#$(),r={schema:this.schema};this.options.ydoc||(r.doc=n);let o=xL.create(r);t&&(o=o.reconfigure({plugins:[...this.extensionService.plugins]})),this.options.initialState=o,this._state=o}#de(){const t=this.state.reconfigure({plugins:[...this.extensionService.plugins]});this._state=t,this.view?.updateState(t)}#Z(t){if(this._state||this.#ee(),!this.#t){if(!MI())throw new Error("[super-editor] Cannot create an editor view without a renderer.");this.#t=new GNe}this.view=this.#t.attach({element:t,editorProps:this.options.editorProps,dispatchTransaction:this.#B.bind(this),state:this.state,handleClick:this.#re.bind(this)}),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 v=s.depth;v>0;v--){const b=s.node(v);if(b.type.name==="tableCell"||b.type.name==="tableHeader"){i=jPn(b);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=v=>(l?.[v]??0)*FZ,f=d("top"),h=d("bottom"),p=d("left"),m=d("right"),g=u*FZ-f-h-NPn,y=c*FZ-p-m-MPn;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.#he(),this.options.ydoc&&this.migrateListsToV2(),this.options.onCollaborationReady({editor:t,ydoc:n}),this.options.collaborationIsReady=!0,this.options.initialState=this.state;const{tr:r}=this.state;r.setMeta("collaborationReady",!0),this.#B(r),this.options.isNewFile||this.#fe()}#fe(){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(ii,{type:"force"});this.#B(r)},50)}#B(t){if(this.isDestroyed)return;const n=this.view?.dom?.ownerDocument?.defaultView?.performance??globalThis.performance,r=()=>n?.now?n.now():Date.now(),o=r(),i=this.state;let s,a=t,l=t;const c=a.getMeta("forceTrackChanges")===!0;try{const p=Vo.getState(i)?.isTrackChangesActive??!1,m=a.getMeta("skipTrackChanges")===!0,g=BPn(i,a),y=WPn(i,a);y&&m&&a.setMeta("protectTrackedReviewState",!0);const v=(p||c)&&!m||y;if(!v&&g&&!a.getMeta(Vo)&&a.setMeta(Vo,g),v&&c&&!this.options.user)throw new Error("forceTrackChanges requires a user to be configured on the editor instance.");const b=this.options.user??{};a=v?GRe({tr:a,state:i,user:b,replacements:this.options.trackedChanges?.replacements==="independent"?"independent":"paired"}):a;const{state:I,transactions:w}=i.applyTransaction(a);s=I,l=w.find(A=>A.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});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}))}dispatch(t){this.#B(t)}async getDocumentIdentifier(){return await this.converter?.getDocumentIdentifier()||null}getDocumentGuid(){return this.converter?.documentGuid||null}isDocumentModified(){return this.converter?.documentModified||!1}getDocumentId(){return console.warn("getDocumentId is deprecated, use getDocumentGuid instead"),this.getDocumentGuid()}getAttributes(t){return an.getAttributes(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return Gme(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.#s();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=eh.fromSchema(this.schema).serializeFragment(this.state.doc.content,{document:n});r.appendChild(o);let i=r.innerHTML;return t&&(i=tbe(i,n)),i}async getMarkdown(){const t=this.#s();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(()=>(PV(),gCt)),Promise.resolve().then(()=>(p2n(),h2n)),Promise.resolve().then(()=>(RPn(),_Pn)),Promise.resolve().then(()=>(cMe(),$fn)),Promise.resolve().then(()=>(fG(),s1t))]),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 bun(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&&!Eb()){const r=this.view.state.tr;r.setMeta("forceUpdatePagination",!0),this.#B(r),this.emit("pageStyleUpdate",{pageMargins:t,pageStyles:this.converter.pageStyles})}}#re(t,n){if(this.setOptions({lastSelection:null}),this.options.isHeaderOrFooter)return dun(t,n)}#N(t){const n=xL.create({schema:this.schema,doc:t}),{tr:r,doc:o}=n;return SVt(o,r,this.schema,this.converter),n.apply(r).doc}migrateListsToV2(){return this.options.isHeaderOrFooter?[]:hun(this)}#ge(t=[]){const n=this.state.doc,r=new bz(n);return IVt(n,r,this.schema,t),r.doc.toJSON()}getUpdatedJson(){return this.#ge()}#ye(){if(!this.converter)return;const t=JOt(),n=(l,c)=>{const u=l?.sourceId;uC(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}#V(){if(!this.converter)return;const t=this.converter.wordIdAllocator?.getSourceIdMap?.()??{};if(Object.keys(t).length===0&&!this.#ie())return;const n=JSON.stringify({version:1,parts:t});ku.setStoredCustomProperty(this.converter.convertedXml,KIe,n,!1)}#ie(){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{$8t(Sb(this));const c=(i??this.converter.comments??[]).map(X=>{const Y=Array.isArray(X.elements)&&X.elements.length?X.elements:void 0,ne=X.commentJSON??Y??(typeof X.commentText=="string"?K3(X.commentText):void 0);return{...X,commentJSON:ne}}),u=this.#ge(c);this.#ye();const d=await this.converter.exportToDocx(u,this.schema,this.storage.image.media,t,n,c,this,r,a);if(this.#p(),o||r)return d;this.#V();const f=this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]),h=this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]),p=!!this.converter.convertedXml["word/settings.xml"]?.elements?.length,m=p?this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]):null,g=this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]),y=this.converter.convertedXml["word/footnotes.xml"],v=y?.elements?.[0]?this.converter.schemaToXml(y.elements[0]):null,b=this.converter.convertedXml["word/_rels/footnotes.xml.rels"],I=b?.elements?.[0]?this.converter.schemaToXml(b.elements[0]):null,w=this.converter.convertedXml["word/endnotes.xml"],A=w?.elements?.[0]?this.converter.schemaToXml(w.elements[0]):null,T=this.converter.convertedXml["word/_rels/endnotes.xml.rels"],x=T?.elements?.[0]?this.converter.schemaToXml(T.elements[0]):null,_=this.converter.convertedXml["word/_rels/settings.xml.rels"],E=_?.elements?.[0]?this.converter.schemaToXml(_.elements[0]):null,P=this.converter.addedMedia,k={};Object.entries(this.converter.convertedXml).forEach(([X,Y])=>{if(X.includes("header")||X.includes("footer")){const ne=Y,me=this.converter.schemaToXml(ne.elements?.[0]);k[X]=String(me.replace(/\[\[sdspace\]\]/g,""))}});const L=this.converter.convertedXml["word/numbering.xml"],R=L?.elements?.[0]?this.converter.schemaToXml(L.elements[0]):null,O=this.converter.convertedXml["docProps/app.xml"],F=O?.elements?.[0]?this.converter.schemaToXml(O.elements[0]):null,H=this.converter.convertedXml["docProps/core.xml"],U=H?.elements?.[0]?this.converter.schemaToXml(H.elements[0]):null,M={...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),...k,...F?{"docProps/app.xml":String(F)}:{},...U?{"docProps/core.xml":String(U)}:{}};if(p){let X=String(m);E?M["word/_rels/settings.xml.rels"]=String(E):/<\w+:attachedTemplate\b/i.test(X)&&(X=X.replace(/<\w+:attachedTemplate\b[^>]*\/?>/gi,"")),M["word/settings.xml"]=X}v&&(M["word/footnotes.xml"]=String(v)),I&&(M["word/_rels/footnotes.xml.rels"]=String(I)),A&&(M["word/endnotes.xml"]=String(A)),x&&(M["word/_rels/endnotes.xml.rels"]=String(x));const z=tW.map(X=>`word/${X}`);for(const X of z){const Y=this.converter.convertedXml[X];Y?.elements?.[0]?M[X]=String(this.converter.schemaToXml(Y.elements[0])):M[X]=null}const Z=typeof this.converter.getBibliographyPartExportPaths=="function"?this.converter.getBibliographyPartExportPaths():[];for(const X of Z){const Y=this.converter.convertedXml[X];Y?.elements?.[0]&&(M[X]=String(this.converter.schemaToXml(Y.elements[0])))}if(t){const X=vTn(this,this.converter.convertedXml,{finalDoc:!0});for(const[Y,ne]of Object.entries(X))M[Y]=ne}for(const X of Object.keys(this.converter.convertedXml)){if(!X.startsWith("customXml/")||!X.endsWith(".xml")&&!X.endsWith(".rels")||Object.prototype.hasOwnProperty.call(M,X))continue;const Y=this.converter.convertedXml[X];Y?.elements?.[0]&&(M[X]=String(this.converter.schemaToXml(Y.elements[0])))}const $=this.converter.removedCustomXmlPaths;if($ instanceof Set)for(const X of $)M[X]=null;const G=new dY;if(s){M["[Content_Types].xml"]=await G.updateContentTypes({files:this.options.content},P,!0,M,this.options.fonts);const X=this.options.content,{contentTypesXml:Y,relsXml:ne}=uNe({baseFiles:Array.isArray(X)||X&&typeof X=="object"?X:null,updatedDocs:M});return M["[Content_Types].xml"]=Y,M["_rels/.rels"]=ne,M}const ye=!this.options.fileSource&&!Array.isArray(this.options.content)?await this.#ne():this.options.content;return await G.updateZip({docx:ye,updatedDocs:M,originalDocxFile:this.options.fileSource,media:P,fonts:this.options.fonts,isHeadless:this.options.isHeadless,compression:l})}catch(c){const u=c instanceof Error?c:new Error(String(c));this.emit("exception",{error:u,editor:this}),console.error(u)}}#q(){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.#P("documentLoading","ready","closed",async()=>{await this.#v(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},v=new Fm({...g,deferDocumentLoad:!0});return await v.open(t,y),v}close(){this.#n==="closed"||this.#n==="initialized"||this.#n!=="destroyed"&&(this.#y("ready"),this.emit("documentClose",{editor:this}),this.#f(),this.#r=null,this.#n="closed")}async save(t){if(this.#y("ready"),!this.#i)throw new XLe("No source path. Use saveTo(path) or exportDocument() instead.");await this.#P("saving","ready","ready",async()=>{const n=await this.exportDocument(t);await this.#me(this.#i,n)})}async saveTo(t,n){this.#y("ready"),await this.#P("saving","ready","ready",async()=>{const r=await this.exportDocument(n);await this.#me(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#me(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=H4(),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 JLe("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.#q(),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=$Le(t)||[];return console.debug("[checkVersionMigrations] Migrations needed:",t,n.length),n.length>0}processCollaborationMigrations(){if(console.debug("[checkVersionMigrations] Current editor version",LPn),!this.options.ydoc)return;let t=this.options.ydoc.getMap("meta").get("version");t||(t="initial"),console.debug("[checkVersionMigrations] Document version",t);const n=$Le(t)||[],r=this.state.plugins.find(i=>this.#L(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 Fm.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.#F(),g5(this),this.#X(),this.initDefaultStyles(),this.options.ydoc&&this.options.collaborationProvider){const l=this.options.ydoc,c=this.options.collaborationProvider,u=()=>{this.options.fragment=null,this.#I(),QM(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=VA(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.#I();this.options.ydoc||this.#fe(),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}=AG;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=jk(n,this);r.replaceWith(o,i,s),this.dispatch(r)}prepareForAnnotations(t=[]){const{tr:n}=this.state,r=kD.processTables({state:this.state,tr:n,annotationValues:t});this.dispatch(r)}async migrateParagraphFields(t=[]){return!Array.isArray(t)||!t.length?t:await yun(t,this)}annotate(t=[],n=[],r=!1){const{state:o,schema:i}=this;let s=o.tr;if(s=kD.processTables({state:this.state,tr:s,annotationValues:t}),s=kD.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)}#he(){this.options.isHeaderOrFooter||this.options.isChildEditor||new FNe({editor:this,dryRun:!1,debug:!1}).validateActiveDocument()}#p(){this.options.isHeaderOrFooter||this.options.isChildEditor||new FNe({editor:this,dryRun:!1,debug:!1}).validateDocumentExport()}#K(){this.#t?.initDevTools?.(this)}},w0=(e,t)=>({css:`var(${e}, ${t})`,fallback:t}),A0={EXT:w0("--sd-comments-highlight-external","#B1124B40"),EXT_ACTIVE:w0("--sd-comments-highlight-external-active","#B1124B66"),EXT_FADED:w0("--sd-comments-highlight-external-faded","#B1124B20"),INT:w0("--sd-comments-highlight-internal","#07838340"),INT_ACTIVE:w0("--sd-comments-highlight-internal-active","#07838366"),INT_FADED:w0("--sd-comments-highlight-internal-faded","#07838320"),EXT_NESTED_BDR:w0("--sd-comments-highlight-external-nested-border","#B1124B99"),INT_NESTED_BDR:w0("--sd-comments-highlight-internal-nested-border","#07838399")},q5="track-change-focused",LBe=".superdoc-comment-highlight",qPn="[data-track-change-id]";function NBe(e){return e?e.split(",").filter(Boolean):[]}function KPn(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 MBe(e,t,n,r){e.style[t]="",e.style[t]=n,e.style[t]||(e.style[t]=r)}function BZ(e,t){MBe(e,"backgroundColor",t.css,t.fallback)}function YPn(e,t){MBe(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 XPn=class{#e=null;#t=null;setContainer(e){this.#t=e}getActiveCommentId(){return this.#e}setActiveComment(e){return this.#e===e?!1:(this.#e=e,!0)}apply(){const e=this.#t;e&&(this.#o(e),this.#r(e))}destroy(){const e=this.#t;if(!e)return;const t=e.querySelectorAll(LBe);for(let r=0;r<t.length;r++){const o=t[r];o.style.backgroundColor="",o.style.boxShadow=""}const n=e.querySelectorAll(`.${q5}`);for(let r=0;r<n.length;r++)n[r].classList.remove(q5)}#o(e){const t=this.#e,n=e.querySelectorAll(LBe);for(let r=0;r<n.length;r++){const o=n[r],i=NBe(o.dataset.commentIds);if(i.length===0)continue;const s=new Set(NBe(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="":BZ(o,a?A0.INT:A0.EXT),o.style.boxShadow="";continue}const c=this.#n(t,i,o.dataset.commentImportedIds);if(c!=null){const u=s.has(c);l?o.style.backgroundColor="":BZ(o,u?A0.INT_ACTIVE:A0.EXT_ACTIVE),i.length>1?YPn(o,u?A0.INT_NESTED_BDR:A0.EXT_NESTED_BDR):o.style.boxShadow=""}else l?o.style.backgroundColor="":BZ(o,a?A0.INT_FADED:A0.EXT_FADED),o.style.boxShadow=""}}#n(e,t,n){if(t.includes(e))return e;if(n){const r=KPn(n).get(e);if(r&&t.includes(r))return r}return null}#r(e){const t=this.#e,n=e.querySelectorAll(qPn);for(let r=0;r<n.length;r++){const o=n[r];t&&o.dataset.trackChangeId===t?o.classList.add(q5):o.classList.remove(q5)}}},JPn=[Vo,ii,DC,jg,lI,S3],ZPn=new Set([...JPn]),QPn=["placeholder","tabPlugin","dropcapPlugin","ImagePosition","ImageRegistration","search","yjs-cursor"],HZ=`
418
418
  `,zZ=`
419
419
  `;function $Pn(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 DBe(e,t,n){if(!t)return null;const r=e.content.size,o=e.textBetween(0,r,HZ,zZ),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=>$Pn(e,f,HZ,zZ),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 e1n(e,t,n){if(!n.text)return null;const r=DBe(e,n.text,n.from);return!r||r.from<0||r.to<=r.from||r.to>t?null:r}function OBe(e,t,n){const r=[];for(const o of n){const i=e1n(e,t,o);i&&r.push({...o,from:i.from,to:i.to})}return r}function FBe(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 t1n(e,t,n,r){if(e.length===0||!t?.length)return e;const o=OBe(n,r,t);if(o.length===0)return e;const i=FBe(e),s=FBe(o);return!i||!s?e:i.from>=s.from&&i.to<=s.to&&s.to-s.from>i.to-i.from?o:e}var n1n=class ire{#e=new WeakMap;#t=[];#o=[];#n=new Map;#r=!1;#i=new Map;#l=!1;#c=!1;#u=0;#d=new Map;#h=new Map;sync(t,n,r){this.#a(t);const o=t.doc.content.size,i=r?.restoreEmptyDecorations!==!1;i||(this.#l=!0);const s=this.#t.length>0?this.#y(t,n,o,i):new Map;return this.#r=this.#t.length>0,this.#M(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.#x(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.#x(r,t);if(o!==Mn.empty)for(const i of o.find(0,n)){if(!this.#E(i))continue;const s=this.#g(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.#T(o,t,r),a=this.#i.get(o),l=!this.#l&&a&&a.length>0,{effectiveRanges:c,rangesToStore:u}=this.#m(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.#s(),n}#s(){this.#l&&(this.#l=!1)}destroy(){this.#t=[],this.#o=[],this.#n.clear(),this.#i.clear(),this.#h.clear(),this.#r=!1,this.#l=!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.#w(r)||this.#A(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.#h.keys())n.has(r)||this.#h.delete(r);this.#k()}#w(t){const n=t.spec?.key;return n!=null&&ZPn.has(n)}#A(t){const n=t.key??"";return QPn.some(r=>n===r||n.startsWith(`${r}$`))}#y(t,n,r,o){const i=new Map;for(const s of this.#t){const{ranges:a,decorationSet:l}=this.#T(s,t,r),c=this.#i.get(s),{effectiveRanges:u,rangesToStore:d}=this.#m(a,c,t.doc,r,o,this.#c);if(a.length>0||u.length>0){this.#P(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}#P(t,n,r){for(const o of r){const i=n.findEntriesInRange(o.from,o.to);for(const s of i){const a=this.#R(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 ire.#_(o.style))a.styleProps.set(l,c)}}}#T(t,n,r){const o=this.#x(t,n),i=this.#n.get(t),s=this.#C(t,o,i,n.doc,r);if(s)return{ranges:s,decorationSet:o};const a=[];if(o!==Mn.empty){const l=o.find(0,r);for(const c of l){if(!this.#E(c))continue;const u=this.#g(c);if(u.classes.length===0&&u.dataEntries.length===0&&u.styleEntries.length===0||c.from>=c.to)continue;const d={};for(const[p,m]of u.dataEntries)d[p]=m;const f=u.styleEntries.length>0?u.styleEntries.map(([p,m])=>`${p}: ${m}`).join("; "):null,h=typeof n.doc.textBetween=="function"?n.doc.textBetween(c.from,c.to,HZ,zZ):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}}#m(t,n,r,o,i,s){let a=t;a.length===0&&i&&n?.length&&(a=OBe(r,o,n));const l=s&&i&&n?.length?t1n(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.#h.set(t,this.#u),this.#k()}#f(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}#b(t,n,r){let o=t;for(const i of r)o=i.map(o,n);return o}#k(){if(this.#d.size===0)return;let t=this.#u;for(const n of this.#h.values())n<t&&(t=n);for(const n of this.#d.keys())n<=t&&this.#d.delete(n)}#C(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.#h.get(t)??-1;if(a===this.#u)return s;const l=this.#f(a);if(l.length===0)return null;const c=[];for(const u of s){if(u.text){const h=DBe(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.#b(u.from,-1,l),f=this.#b(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}#x(t,n){try{const r=t.props.decorations?.call(t,n);return r instanceof Mn?r:Mn.empty}catch{return Mn.empty}}#E(t){return t.inline===!0}#g(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"?ire.#_(n.style):[]}}static#_(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}#R(t,n){let r=t.get(n);return r||(r={classes:new Set,dataAttrs:new Map,styleProps:new Map},t.set(n,r)),r}#M(t,n,r){let o=!1;for(const[s,a]of t){const l=this.#e.get(s);l?this.#F(s,l,a)&&(o=!0):(this.#I(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.#z(s.el,a),o=!0)}return o}#I(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)}#L(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)}#S(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)}#O(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)}#F(t,n,r){let o=!1;for(const i of r.classes)this.#L(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.#S(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.#O(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}#z(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)}},UZ="interactionEpoch",VZ="displayLabelSource",GZ={CANONICAL:"canonical",DERIVED:"derived"};function r1n(e,t){const n=e.dataset[xi.DISPLAY_LABEL],r=e.dataset[VZ];if(n!==void 0&&r!==GZ.DERIVED)return{source:GZ.CANONICAL,value:n};const o=t?.textContent?.trim()??"";return o.length===0?null:{source:GZ.DERIVED,value:o}}var o1n=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e),n=this.#e.querySelectorAll(x3());for(let r=0;r<n.length;r+=1){const o=n[r];if(o.dataset[UZ]===t)continue;o.dataset[UZ]=t,o.draggable=!0,o.dataset[xi.DRAGGABLE]="true";const i=r1n(o,o.querySelector(`.${on.ANNOTATION_CONTENT}`));i!==null&&(o.dataset[xi.DISPLAY_LABEL]=i.value,o.dataset[VZ]=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(x3());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[UZ],delete n.dataset[VZ],n.querySelector(`.${on.ANNOTATION_CARET_ANCHOR}`)?.remove()}}#t(e){if(e.querySelector(`.${on.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(on.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)}},WZ="imageInteractionEpoch";function BBe(e){return e&&e.trim().length>0?e:null}function HBe(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(`.${on.IMAGE_FRAGMENT}`)))!o.hasAttribute("data-image-metadata")&&o.querySelector?.("[data-image-metadata]")==null||r(o);for(const o of Array.from(e.querySelectorAll(`.${on.INLINE_IMAGE_CLIP_WRAPPER}`)))o.querySelector?.("[data-image-metadata]")!=null&&r(o);for(const o of Array.from(e.querySelectorAll(`.${on.INLINE_IMAGE}`)))o.hasAttribute("data-image-metadata")&&o.closest(`.${on.INLINE_IMAGE_CLIP_WRAPPER}`)==null&&r(o);return t}function i1n(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 s1n(e){return e.classList.contains(on.IMAGE_FRAGMENT)?"block":"inline"}var a1n=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=String(e);for(const n of HBe(this.#e)){if(n.dataset[WZ]===t)continue;const r=BBe(n.dataset.pmStart),o=BBe(n.dataset.pmEnd);!r||!o||(n.dataset[WZ]=t,n.draggable=!0,n.dataset.dragSourceKind="existingImage",n.dataset.imageKind=s1n(n),n.dataset.nodeType="image",n.dataset.displayLabel=i1n(n),n.dataset.pmStart=r,n.dataset.pmEnd=o)}}clear(){if(this.#e)for(const e of HBe(this.#e))e.removeAttribute("draggable"),delete e.dataset.dragSourceKind,delete e.dataset.imageKind,delete e.dataset.nodeType,delete e.dataset.displayLabel,delete e.dataset[WZ]}},zBe=".superdoc-structured-content__label",UBe=`.${on.INLINE_SDT_WRAPPER}__label`,jZ="structuredContentInteractionEpoch",l1n=class{#e=null;setContainer(e){this.#e=e}apply(e){if(!this.#e)return;const t=Array.from(this.#e.querySelectorAll(`${zBe}, ${UBe}`));for(const n of t){if(n.dataset[jZ]===String(e))continue;const r=n.closest(`.${on.BLOCK_SDT}, .${on.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(on.BLOCK_SDT)?"block":"inline"),s=n.textContent?.trim()||"Structured content";n.dataset[jZ]=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(`${zBe}, ${UBe}`));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[jZ]}};const ul={SPELLING:"sd-proofing-spelling",GRAMMAR:"sd-proofing-grammar",STYLE:"sd-proofing-style",DATA_ATTR:"data-sd-proofing",SPLIT_ATTR:"data-sd-proofing-split"};function VBe(e){switch(e){case"spelling":return ul.SPELLING;case"grammar":return ul.GRAMMAR;case"style":return ul.STYLE}}var GBe=new WeakMap;function c1n(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=VBe(p.kind);break}s.push({textStart:u,textEnd:f,pmStart:l,pmEnd:c,proofingClass:h})}return s}function u1n(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(ul.SPLIT_ATTR,""),u.setAttribute(ul.DATA_ATTR,""),u.textContent="",u.appendChild(o.createTextNode(c)),GBe.set(u,e),i.push(u)}e.style.display="none",e.setAttribute(ul.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 d1n(e){const t=Array.from(e.querySelectorAll(`[${ul.SPLIT_ATTR}]`));if(t.length===0)return!1;const n=new Map;for(const i of t){const s=GBe.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){WBe(i);for(const l of s)a.removeChild(l)}}const r=Array.from(e.querySelectorAll(`[${ul.SPLIT_ATTR}]`));for(const i of r)i.parentNode?.removeChild(i);const o=Array.from(e.querySelectorAll(`[${ul.DATA_ATTR}="original"]`));for(const i of o)WBe(i);return!0}function WBe(e){e.style.display="",e.style.cssText||e.removeAttribute("style"),e.removeAttribute(ul.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 f1n(e,t){const n=qZ(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||!h1n(s))continue;const c=p1n(r,a,l);if(c.length===0)continue;const u=s.textContent??"";if(u.length===0)continue;if(m1n(a,l,c)){s.classList.add(VBe(c[0].kind)),s.setAttribute(ul.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),i=!0;continue}const d=c1n(a,l,u,c);if(d.length>1){u1n(s,d,u),i=!0;continue}d.length===1&&d[0].proofingClass&&(s.classList.add(d[0].proofingClass),s.setAttribute(ul.DATA_ATTR,""),s.setAttribute("aria-invalid","spelling"),i=!0)}return i||n}function qZ(e){let t=!1;const n=d1n(e),r=Array.from(e.querySelectorAll(`[${ul.DATA_ATTR}]`));for(const o of r)o.classList.remove(ul.SPELLING,ul.GRAMMAR,ul.STYLE),o.removeAttribute(ul.DATA_ATTR),o.removeAttribute("aria-invalid"),t=!0;return t||n}function h1n(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 p1n(e,t,n){const r=[];for(const o of e){if(o.pmFrom>=n)break;o.pmTo>t&&r.push(o)}return r}function m1n(e,t,n){return n.some(r=>r.pmFrom<=e&&r.pmTo>=t)}var g1n=class{#e=null;setContainer(e){this.#e=e}applyAnnotations(e){const t=this.#e;return t?!e||e.length===0?qZ(t):f1n(t,e):!1}clear(){const e=this.#e;return e?qZ(e):!1}},y1n=class{#e;#t;#o;#n;#r;#i;constructor(e={}){this.#e=e.fieldAnnotationLayer??new o1n,this.#t=e.imageLayer??new a1n,this.#o=e.structuredContentLayer??new l1n,this.#n=e.commentHighlightDecorator??new XPn,this.#r=e.decorationBridge??new n1n,this.#i=e.proofingDecorator??new g1n}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)}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),this.#o.apply(e.layoutEpoch),this.syncInlineStyleLayers(e.editorState,e.domPositionIndex),this.applyProofingAnnotations(e.proofingAnnotations,e.rebuildDomPositionIndex),e.reapplyStructuredContentHover?.()}destroy(){this.#i.clear(),this.#e.clear(),this.#t.clear(),this.#o.clear(),this.#n.destroy(),this.#r.destroy()}},b1n=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"&&(v1n(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 v1n(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 w1n(e,t){const n=A1n(e);if(n)return n;const r=I1n(e);return r||t}function A1n(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 I1n(e){return e.attrs.paragraphProperties?.lang?.val??null}function jBe(e,t,n){const r=[],o=new Map,i=new Map;return S1n(e,(s,a,l)=>{const{text:c,slices:u}=x1n(s,a);if(c.length===0)return;const d=_1n(s,a),f=w1n(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 S1n(e,t){e.descendants((n,r)=>{const o=n.type.name;return o==="header"||o==="footer"?!1:o==="paragraph"?(t(n,r,T1n(e,r)?"table-cell":"body"),!1):!0})}function T1n(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 x1n(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(k1n(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(E1n(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 k1n(e){return e.marks?.some(t=>t.type.name==="trackDelete")??!1}var C1n=new Set(["fieldAnnotation","image","equation","hardBreak","lineBreak","tab","footnoteReference","symbol"]);function E1n(e){return C1n.has(e)}function _1n(e,t){const n=e.attrs.sdBlockId;return n?`blk-${n}`:`pos-${t}`}function R1n(e,t){const n=qBe(e.start,t),r=qBe(e.end,t);return n===null||r===null||n>=r?null:{...e,pmFrom:n,pmTo:r}}function qBe(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 P1n(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 KBe(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 L1n(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 N1n(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 M1n(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 D1n=500,O1n=2e3,F1n=1e4,B1n=2,H1n=20,z1n=5,YBe=class{#e;#t=null;#o=null;#n="disabled";#r=new b1n;#i=new Map;#l=new Map;#c=null;#u=new Set;#d=0;#h=0;#s=!1;#a=[];#w=0;#A=!1;#y=0;#P=null;#T=null;#m=null;#v=null;#f=[];constructor(e={}){this.onResultsChanged=null,this.#e={enabled:e.enabled??!1,debounceMs:e.debounceMs??D1n,maxSuggestions:e.maxSuggestions??z1n,visibleFirst:e.visibleFirst??!0,allowIgnoreWord:e.allowIgnoreWord??!0,defaultLanguage:e.defaultLanguage??null,ignoredWords:e.ignoredWords??[],timeoutMs:e.timeoutMs??F1n,maxConcurrentRequests:e.maxConcurrentRequests??B1n,maxSegmentsPerBatch:e.maxSegmentsPerBatch??H1n,onProofingError:e.onProofingError??null,onStatusChange:e.onStatusChange??null},e.provider&&(this.#t=e.provider),this.#e.enabled&&this.#t&&this.#S("idle")}get status(){return this.#n}get isEnabled(){return this.#e.enabled&&this.#t!==null}get config(){return this.#e}setVisibilitySource(e){this.#P=e}setDocumentId(e){this.#T=e}setPageResolver(e){this.#m=e}setComposing(e){this.#A=e,!e&&this.#f.length>0&&this.isEnabled&&this.#k(this.#f)}getPaintSlices(e){if(!this.isEnabled)return[];const t=N1n(this.#r.getDisplayIssues(this.#e.ignoredWords));return e?t.filter(n=>n.pmTo<=e.from||n.pmFrom>=e.to):t}getIssueAtPosition(e,t){return M1n(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.#L(),this.#r.clear(),this.#l.clear(),this.#i.clear(),this.#S("disabled"),this.onResultsChanged?.();return}if(e.enabled&&!n&&t){this.#S("idle"),this.#b(t);return}}o&&this.isEnabled&&t&&(this.#L(),this.#h++,this.#r.clear(),this.#l.clear(),this.onResultsChanged?.(),this.#b(t))}onDocumentChanged(e,t,n){if(!this.isEnabled)return;this.#h++,this.#v=e;const{segments:r,offsetMaps:o,segmentPositions:i}=jBe(e,this.#e.defaultLanguage,this.#m??void 0);this.#f=r,this.#i=o;const s=P1n(r,i,t);for(const a of s)this.#l.delete(a);if(s.size>0){const a=this.#w++;this.#r.remapIssues(s,n,a),this.#r.removeOrphanedSegments(new Set(r.map(l=>l.id)))}this.#k(r)}runInitialCheck(e){this.isEnabled&&this.#b(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.#s=!0,this.#L(),this.#r.clear(),this.#i.clear(),this.#l.clear(),this.#v=null,this.#f=[],this.#a=[],this.#t?.dispose?.(),this.#t=null,this.#S("disabled")}#b(e){this.#v=e;const{segments:t,offsetMaps:n}=jBe(e,this.#e.defaultLanguage,this.#m??void 0);this.#f=t,this.#i=n,this.#l.clear(),this.#r.clear(),this.#k(t)}#k(e){if(this.#A)return;this.#c!==null&&clearTimeout(this.#c);const t=Date.now()-this.#y;this.#y>0&&t>=O1n?this.#C(e):this.#c=setTimeout(()=>{this.#c=null,this.#C(e)},this.#e.debounceMs)}#C(e){this.#y=Date.now(),this.#x(e)}async#x(e){if(this.#s||!this.#t)return;if(!this.#o&&this.#t.getCapabilities)try{this.#o=await this.#t.getCapabilities()}catch{}const t=e.filter(s=>{const a=KBe(s.text);return this.#l.get(s.id)!==a});if(t.length===0){this.#S("idle");return}const n=this.#r.getActiveRecheckIds(),r=this.#e.visibleFirst&&this.#P?L1n(t,this.#P):t,o=this.#I(r),i=this.#h;this.#a=[];for(let s=0;s<o.length;s++){if(this.#s||i!==this.#h)return;if(this.#d>=this.#e.maxConcurrentRequests){for(let a=s;a<o.length;a++)this.#a.push(...o[a]);break}this.#E(o[s],i,n)}}async#E(e,t,n){if(!this.#t||this.#s)return;const r=new AbortController;this.#u.add(r),this.#d++,this.#S("checking");const o=setTimeout(()=>r.abort(),this.#e.timeoutMs),i={documentId:this.#T,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.#h||this.#s){this.#_();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.#R(u,a,l))continue;const d=this.#i.get(u.segmentId);if(!d)continue;const f=R1n(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.#l.set(u.id,KBe(u.text));this.#S(this.#d>0?"checking":"idle"),this.onResultsChanged?.(),this.#g(t,n)}catch(s){if(clearTimeout(o),!this.#u.delete(r)||(this.#d--,this.#s))return;if(t!==this.#h){this.#_();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.#S(this.#d>0?"checking":"degraded"),this.#g(t,n)}}#g(e,t){if(this.#s||e!==this.#h||this.#a.length===0||this.#d>=this.#e.maxConcurrentRequests)return;const n=this.#a.splice(0,this.#e.maxSegmentsPerBatch);n.length>0&&this.#E(n,e,t)}#_(){this.#s||this.#a.length===0||this.#g(this.#h,this.#r.getActiveRecheckIds())}#R(e,t,n){if(!t.has(e.segmentId))return this.#M(`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.#M(`Invalid offsets [${e.start}, ${e.end}) for segment "${e.segmentId}" (length ${r.text.length})`,[e.segmentId]),!1):!0:!1}#M(e,t){this.#e.onProofingError?.({kind:"validation-error",message:e,segmentIds:t})}#I(e){const t=[];for(let n=0;n<e.length;n+=this.#e.maxSegmentsPerBatch)t.push(e.slice(n,n+this.#e.maxSegmentsPerBatch));return t}#L(){this.#c!==null&&(clearTimeout(this.#c),this.#c=null);for(const e of this.#u)e.abort();this.#u.clear(),this.#d=0,this.#a=[]}#S(e){this.#n!==e&&(this.#n=e,this.#e.onStatusChange?.(e))}},XBe=20,sv=500,I0=5e3,Bl=["#4472C4","#ED7D31","#A5A5A5","#FFC000","#5B9BD5","#70AD47"],S0="#595959",y_="#E0E0E0",b_="#333",K5="#666",Ru="Calibri, Arial, sans-serif",U1n="#f8f9fa",V1n="#dee2e6",JBe="#6c757d",Br="http://www.w3.org/2000/svg",Vn={top:30,right:20,bottom:50,left:60},Pu=5;function G1n(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?Hl(e,r,"No chart data"):t.chartType==="barChart"?oLn(e,r,t,n):t.chartType==="lineChart"||t.chartType==="stockChart"?f8e(e,r,t,n):t.chartType==="areaChart"?eLn(e,r,t,n):t.chartType==="scatterChart"?X1n(e,r,t,n):t.chartType==="bubbleChart"?J1n(e,r,t,n):t.chartType==="radarChart"?Q1n(e,r,t,n):t.chartType==="pieChart"?d8e(e,r,t,n):t.chartType==="doughnutChart"?nLn(e,r,t,n):t.chartType==="ofPieChart"?d8e(e,r,t,n):Hl(e,r,`Chart: ${t.chartType}`)}function Hl(e,t,n){t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.background=U1n,t.style.border=`1px solid ${V1n}`,t.style.borderRadius="4px",t.style.color=JBe,t.style.fontSize="13px",t.style.fontFamily=Ru;const r=e.createElement("span");r.textContent="📊 ",t.appendChild(r);const o=e.createElement("span");return o.textContent=n,t.appendChild(o),t}function Y5(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 gS(e){let t=!1,n=e.series;return n.length>XBe&&(n=n.slice(0,XBe),t=!0),n=n.map(r=>r.values.length<=sv&&r.categories.length<=sv?r:(t=!0,{name:r.name,categories:r.categories.slice(0,sv),values:r.values.slice(0,sv),...r.xValues&&{xValues:r.xValues.slice(0,sv)},...r.bubbleSizes&&{bubbleSizes:r.bubbleSizes.slice(0,sv)}})),{series:n,truncated:t}}function W1n(e,t,n){const r=Math.max(1,e-Vn.left-Vn.right),o=Math.max(1,t-Vn.top-Vn.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:Vn.top+o*(s/l),valueRange:l,minValue:a,maxValue:s}}function j1n(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=Bl[u%Bl.length];for(let h=0;h<d.values.length;h++){const p=d.values[h],m=Math.abs(p/l)*c,g=Vn.left+h*o+i+u*s,y=p>=0?a-m:a,v=e.createElementNS(Br,"rect");v.setAttribute("x",String(g)),v.setAttribute("y",String(y)),v.setAttribute("width",String(s)),v.setAttribute("height",String(Math.max(.5,m))),v.setAttribute("fill",f),t.appendChild(v)}}}function q1n(e,t,n){const{plotWidth:r,plotHeight:o,baselineY:i}=n,s=e.createElementNS(Br,"line");s.setAttribute("x1",String(Vn.left)),s.setAttribute("y1",String(Vn.top)),s.setAttribute("x2",String(Vn.left)),s.setAttribute("y2",String(Vn.top+o)),s.setAttribute("stroke",S0),s.setAttribute("stroke-width","1"),t.appendChild(s);const a=e.createElementNS(Br,"line");a.setAttribute("x1",String(Vn.left)),a.setAttribute("y1",String(i)),a.setAttribute("x2",String(Vn.left+r)),a.setAttribute("y2",String(i)),a.setAttribute("stroke",S0),a.setAttribute("stroke-width","1"),t.appendChild(a)}function K1n(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=Vn.left+c*i+i/2,d=e.createElementNS(Br,"text");d.setAttribute("x",String(u)),d.setAttribute("y",String(Vn.top+s+16)),d.setAttribute("text-anchor","middle"),d.setAttribute("font-size",String(l)),d.setAttribute("fill",b_),d.setAttribute("font-family",Ru),d.textContent=n[c]??"",t.appendChild(d)}}function Y1n(e,t,n,r){const{plotWidth:o,plotHeight:i,valueRange:s,minValue:a}=n,l=s/Pu,c=Math.max(8,Math.min(11,r/30));for(let u=0;u<=Pu;u++){const d=a+l*u,f=Vn.top+i-i*(d-a)/s,h=e.createElementNS(Br,"text");if(h.setAttribute("x",String(Vn.left-6)),h.setAttribute("y",String(f+3)),h.setAttribute("text-anchor","end"),h.setAttribute("font-size",String(c)),h.setAttribute("fill",K5),h.setAttribute("font-family",Ru),h.textContent=Y5(d),t.appendChild(h),u>0&&u<Pu){const p=e.createElementNS(Br,"line");p.setAttribute("x1",String(Vn.left)),p.setAttribute("y1",String(f)),p.setAttribute("x2",String(Vn.left+o)),p.setAttribute("y2",String(f)),p.setAttribute("stroke",y_),p.setAttribute("stroke-width","0.5"),t.appendChild(p)}}}function yS(e,t,n,r){const o=r-12;let i=Vn.left;for(let s=0;s<n.length;s++){const a=n[s],l=Bl[s%Bl.length],c=e.createElementNS(Br,"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(Br,"text");u.setAttribute("x",String(i+14)),u.setAttribute("y",String(o)),u.setAttribute("font-size","10"),u.setAttribute("fill",b_),u.setAttribute("font-family",Ru),u.textContent=a.name,t.appendChild(u),i+=14+a.name.length*6+16}}function T0(e,t,n){const r=e.createElementNS(Br,"text");r.setAttribute("x",String(n-8)),r.setAttribute("y","14"),r.setAttribute("text-anchor","end"),r.setAttribute("font-size","10"),r.setAttribute("fill",JBe),r.setAttribute("font-family",Ru),r.textContent="Data truncated for display",t.appendChild(r)}function ZBe(e,t,n,r=!1){const o=Math.max(1,e-Vn.left-Vn.right),i=Math.max(1,t-Vn.top-Vn.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=Vn.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 bS(e,t){return e.categoryCount<=1?Vn.left+e.plotWidth/2:Vn.left+e.plotWidth*t/(e.categoryCount-1)}function KZ(e,t){return Vn.top+e.plotHeight-(t-e.minValue)/e.valueRange*e.plotHeight}function QBe(e,t,n){const r=e.createElementNS(Br,"line");r.setAttribute("x1",String(Vn.left)),r.setAttribute("y1",String(Vn.top)),r.setAttribute("x2",String(Vn.left)),r.setAttribute("y2",String(Vn.top+n.plotHeight)),r.setAttribute("stroke",S0),r.setAttribute("stroke-width","1"),t.appendChild(r);const o=e.createElementNS(Br,"line");o.setAttribute("x1",String(Vn.left)),o.setAttribute("y1",String(n.baselineY)),o.setAttribute("x2",String(Vn.left+n.plotWidth)),o.setAttribute("y2",String(n.baselineY)),o.setAttribute("stroke",S0),o.setAttribute("stroke-width","1"),t.appendChild(o)}function $Be(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(Br,"text");c.setAttribute("x",String(bS(r,l))),c.setAttribute("y",String(Vn.top+r.plotHeight+16)),c.setAttribute("text-anchor","middle"),c.setAttribute("font-size",String(a)),c.setAttribute("fill",b_),c.setAttribute("font-family",Ru),c.textContent=i[l]??"",t.appendChild(c)}}function e8e(e,t,n,r){const o=n.valueRange/Pu,i=Math.max(8,Math.min(11,r/30));for(let s=0;s<=Pu;s++){const a=n.minValue+o*s,l=Vn.top+n.plotHeight-n.plotHeight*(a-n.minValue)/n.valueRange,c=e.createElementNS(Br,"text");if(c.setAttribute("x",String(Vn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(i)),c.setAttribute("fill",K5),c.setAttribute("font-family",Ru),c.textContent=Y5(a),t.appendChild(c),s>0&&s<Pu){const u=e.createElementNS(Br,"line");u.setAttribute("x1",String(Vn.left)),u.setAttribute("y1",String(l)),u.setAttribute("x2",String(Vn.left+n.plotWidth)),u.setAttribute("y2",String(l)),u.setAttribute("stroke",y_),u.setAttribute("stroke-width","0.5"),t.appendChild(u)}}}function t8e(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 n8e(e,t,n,r=!1){const o=Math.max(1,e-Vn.left-Vn.right),i=Math.max(1,t-Vn.top-Vn.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=Vn.left+o*f,m=Vn.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 r8e(e,t){return Vn.left+(t-e.minX)/e.xRange*e.plotWidth}function o8e(e,t){return Vn.top+e.plotHeight-(t-e.minY)/e.yRange*e.plotHeight}function i8e(e,t,n){const r=e.createElementNS(Br,"line");r.setAttribute("x1",String(n.axisX)),r.setAttribute("y1",String(Vn.top)),r.setAttribute("x2",String(n.axisX)),r.setAttribute("y2",String(Vn.top+n.plotHeight)),r.setAttribute("stroke",S0),r.setAttribute("stroke-width","1"),t.appendChild(r);const o=e.createElementNS(Br,"line");o.setAttribute("x1",String(Vn.left)),o.setAttribute("y1",String(n.axisY)),o.setAttribute("x2",String(Vn.left+n.plotWidth)),o.setAttribute("y2",String(n.axisY)),o.setAttribute("stroke",S0),o.setAttribute("stroke-width","1"),t.appendChild(o)}function s8e(e,t,n,r){const o=Math.max(8,Math.min(11,r/30));for(let i=0;i<=Pu;i++){const s=i/Pu,a=n.minY+n.yRange*s,l=Vn.top+n.plotHeight-n.plotHeight*s,c=e.createElementNS(Br,"text");if(c.setAttribute("x",String(Vn.left-6)),c.setAttribute("y",String(l+3)),c.setAttribute("text-anchor","end"),c.setAttribute("font-size",String(o)),c.setAttribute("fill",K5),c.setAttribute("font-family",Ru),c.textContent=Y5(a),t.appendChild(c),i>0&&i<Pu){const h=e.createElementNS(Br,"line");h.setAttribute("x1",String(Vn.left)),h.setAttribute("y1",String(l)),h.setAttribute("x2",String(Vn.left+n.plotWidth)),h.setAttribute("y2",String(l)),h.setAttribute("stroke",y_),h.setAttribute("stroke-width","0.5"),t.appendChild(h)}const u=n.minX+n.xRange*s,d=Vn.left+n.plotWidth*s,f=e.createElementNS(Br,"text");f.setAttribute("x",String(d)),f.setAttribute("y",String(Vn.top+n.plotHeight+16)),f.setAttribute("text-anchor","middle"),f.setAttribute("font-size",String(o)),f.setAttribute("fill",K5),f.setAttribute("font-family",Ru),f.textContent=Y5(u),t.appendChild(f)}}function a8e(e,t){const n=e.reduce((a,l)=>a+l.length,0),r=2,o=(Pu+1)*2,i=Math.max(0,Pu-1),s=t?e.length*2:0;return n+r+o+i+s}function X1n(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s.map(t8e),c=l.flat();if(c.length===0)return Hl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=a8e(l,u);if(d>I0)return Hl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=n8e(o,i,c,!1),h=e.createElementNS(Br,"svg");h.setAttribute("viewBox",`0 0 ${o} ${i}`),h.setAttribute("width","100%"),h.setAttribute("height","100%"),h.style.display="block",i8e(e,h,f),s8e(e,h,f,i);for(let p=0;p<l.length;p++){const m=l[p],g=Bl[p%Bl.length];for(const y of m){const v=e.createElementNS(Br,"circle");v.setAttribute("cx",String(r8e(f,y.x))),v.setAttribute("cy",String(o8e(f,y.y))),v.setAttribute("r","3"),v.setAttribute("fill",g),v.setAttribute("fill-opacity","0.85"),h.appendChild(v)}}return u&&yS(e,h,s,i),a&&T0(e,h,o),t.appendChild(h),t}function J1n(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s.map(t8e),c=l.flat();if(c.length===0)return Hl(e,t,"No chart data");const u=n.legendPosition!==void 0,d=a8e(l,u);if(d>I0)return Hl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=n8e(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(Br,"svg");m.setAttribute("viewBox",`0 0 ${o} ${i}`),m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.style.display="block",i8e(e,m,f),s8e(e,m,f,i);for(let g=0;g<l.length;g++){const y=l[g],v=Bl[g%Bl.length];for(const b of y){const I=b.size&&b.size>0?b.size:p*.5,w=p>0?4+I/p*10:6,A=e.createElementNS(Br,"circle");A.setAttribute("cx",String(r8e(f,b.x))),A.setAttribute("cy",String(o8e(f,b.y))),A.setAttribute("r",String(Math.max(2,w))),A.setAttribute("fill",v),A.setAttribute("fill-opacity","0.45"),A.setAttribute("stroke",v),A.setAttribute("stroke-width","1"),m.appendChild(A)}}return u&&yS(e,m,s,i),a&&T0(e,m,o),t.appendChild(m),t}function Z1n(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 Q1n(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s[0]?.categories??[],c=Math.max(3,l.length,...s.map(A=>A.values.length)),u=n.legendPosition!==void 0,d=Z1n(s,c,u);if(d>I0)return Hl(e,t,`Chart too complex for inline rendering (${d} elements)`);const f=s.flatMap(A=>A.values).filter(A=>Number.isFinite(A)),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(Br,"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,v=Math.max(10,Math.min(o-60,i-y-60)/2),b=o/2,I=Vn.top+(i-Vn.top-y)/2,w=4;for(let A=1;A<=w;A++){const T=v*A/w,x=[];for(let E=0;E<c;E++){const P=-Math.PI/2+E*Math.PI*2/c;x.push(`${b+T*Math.cos(P)},${I+T*Math.sin(P)}`)}const _=e.createElementNS(Br,"polygon");_.setAttribute("points",x.join(" ")),_.setAttribute("fill","none"),_.setAttribute("stroke",y_),_.setAttribute("stroke-width","0.8"),g.appendChild(_)}for(let A=0;A<c;A++){const T=-Math.PI/2+A*Math.PI*2/c,x=b+v*Math.cos(T),_=I+v*Math.sin(T),E=e.createElementNS(Br,"line");E.setAttribute("x1",String(b)),E.setAttribute("y1",String(I)),E.setAttribute("x2",String(x)),E.setAttribute("y2",String(_)),E.setAttribute("stroke",y_),E.setAttribute("stroke-width","0.8"),g.appendChild(E);const P=v+14,k=b+P*Math.cos(T),L=I+P*Math.sin(T),R=e.createElementNS(Br,"text");R.setAttribute("x",String(k)),R.setAttribute("y",String(L)),R.setAttribute("font-size","10"),R.setAttribute("fill",b_),R.setAttribute("font-family",Ru),R.setAttribute("text-anchor",Math.abs(Math.cos(T))<.2?"middle":Math.cos(T)>0?"start":"end"),R.textContent=l[A]??`Category ${A+1}`,g.appendChild(R)}for(let A=0;A<s.length;A++){const T=s[A],x=Bl[A%Bl.length],_=[],E=[],P=Math.min(c,T.values.length);for(let k=0;k<P;k++){const L=T.values[k]??0,R=Math.max(0,(L-Math.min(0,p))/m)*v,O=-Math.PI/2+k*Math.PI*2/c,F=b+R*Math.cos(O),H=I+R*Math.sin(O);_.push(`${F},${H}`),E.push({x:F,y:H})}if(_.length>0){const k=e.createElementNS(Br,"polygon");k.setAttribute("points",_.join(" ")),k.setAttribute("fill",x),k.setAttribute("fill-opacity","0.18"),k.setAttribute("stroke",x),k.setAttribute("stroke-width","1.8"),g.appendChild(k)}for(const k of E){const L=e.createElementNS(Br,"circle");L.setAttribute("cx",String(k.x)),L.setAttribute("cy",String(k.y)),L.setAttribute("r","2.5"),L.setAttribute("fill",x),g.appendChild(L)}}return u&&yS(e,g,s,i),a&&T0(e,g,o),t.appendChild(g),t}function l8e(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=(Pu+1)*2,c=t.length,u=n?e.length*2:0;return i+s+a+l+c+u}function c8e(e){let t=!1;const n=Math.min(e.values.length,sv);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:Bl[o%Bl.length]})}return{slices:r,truncated:t}}function $1n(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(Br,"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(Br,"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 u8e(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(Br,"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(Br,"text");u.setAttribute("x",String(s+14)),u.setAttribute("y",String(a)),u.setAttribute("font-size","10"),u.setAttribute("fill",b_),u.setAttribute("font-family",Ru),u.textContent=l.label,t.appendChild(u),s+=14+l.label.length*6+16}}function d8e(e,t,n,r){const o=n.series[0];if(!o)return Hl(e,t,"No chart data");const{slices:i,truncated:s}=c8e(o);if(i.reduce((I,w)=>I+w.value,0)<=0)return Hl(e,t,"No chart data");if(i.length*3>I0)return Hl(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,v=Math.max(8,Math.min(p,m)*.45),b=e.createElementNS(Br,"svg");if(b.setAttribute("viewBox",`0 0 ${a} ${l}`),b.setAttribute("width","100%"),b.setAttribute("height","100%"),b.style.display="block",d){const I=e.createElementNS(Br,"text");I.setAttribute("x",String(g)),I.setAttribute("y","24"),I.setAttribute("text-anchor","middle"),I.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),I.setAttribute("fill",S0),I.setAttribute("font-family",Ru),I.textContent=u,b.appendChild(I)}return $1n(e,b,i,g,y,v),c&&u8e(e,b,i,a,l),s&&T0(e,b,a),t.appendChild(b),t}function f8e(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=l8e(s,l,c,!0);if(u>I0)return Hl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=ZBe(o,i,s,!1),f=e.createElementNS(Br,"svg");f.setAttribute("viewBox",`0 0 ${o} ${i}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",QBe(e,f,d),e8e(e,f,d,i),$Be(e,f,l,d,o);for(let h=0;h<s.length;h++){const p=s[h],m=Bl[h%Bl.length],g=[];for(let v=0;v<p.values.length;v++){const b=bS(d,v),I=KZ(d,p.values[v]??0);g.push(`${b},${I}`)}if(g.length===0)continue;const y=e.createElementNS(Br,"polyline");y.setAttribute("points",g.join(" ")),y.setAttribute("fill","none"),y.setAttribute("stroke",m),y.setAttribute("stroke-width","2"),f.appendChild(y);for(let v=0;v<p.values.length;v++){const b=e.createElementNS(Br,"circle");b.setAttribute("cx",String(bS(d,v))),b.setAttribute("cy",String(KZ(d,p.values[v]??0))),b.setAttribute("r","2.5"),b.setAttribute("fill",m),f.appendChild(b)}}return c&&yS(e,f,s,i),a&&T0(e,f,o),t.appendChild(f),t}function eLn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=l8e(s,l,c,!1)+s.length;if(u>I0)return Hl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=ZBe(o,i,s,!0),f=e.createElementNS(Br,"svg");f.setAttribute("viewBox",`0 0 ${o} ${i}`),f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.style.display="block",QBe(e,f,d),e8e(e,f,d,i),$Be(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=Bl[h%Bl.length],g=[`M ${bS(d,0)} ${d.baselineY}`];for(let b=0;b<p.values.length;b++)g.push(`L ${bS(d,b)} ${KZ(d,p.values[b]??0)}`);const y=bS(d,Math.max(0,p.values.length-1));g.push(`L ${y} ${d.baselineY} Z`);const v=e.createElementNS(Br,"path");v.setAttribute("d",g.join(" ")),v.setAttribute("fill",m),v.setAttribute("fill-opacity","0.35"),v.setAttribute("stroke",m),v.setAttribute("stroke-width","1.5"),f.appendChild(v)}return c&&yS(e,f,s,i),a&&T0(e,f,o),t.appendChild(f),t}function tLn(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 A=e.createElementNS(Br,"circle");A.setAttribute("cx",String(r)),A.setAttribute("cy",String(o)),A.setAttribute("r",String((i+s)/2)),A.setAttribute("fill","none"),A.setAttribute("stroke",c.color),A.setAttribute("stroke-width",String(Math.max(1,i-s))),t.appendChild(A);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),v=r+s*Math.cos(d),b=o+s*Math.sin(d),I=u>Math.PI?1:0,w=e.createElementNS(Br,"path");w.setAttribute("d",`M ${f} ${h} A ${i} ${i} 0 ${I} 1 ${p} ${m} L ${v} ${b} A ${s} ${s} 0 ${I} 0 ${g} ${y} Z`),w.setAttribute("fill",c.color),w.setAttribute("stroke","#fff"),w.setAttribute("stroke-width","1"),t.appendChild(w),l=d}}function nLn(e,t,n,r){const o=n.series[0];if(!o)return Hl(e,t,"No chart data");const{slices:i,truncated:s}=c8e(o);if(i.reduce((w,A)=>w+A.value,0)<=0)return Hl(e,t,"No chart data");if(i.length*3>I0)return Hl(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,v=Math.max(8,Math.min(p,m)*.45),b=Math.max(2,v*.58),I=e.createElementNS(Br,"svg");if(I.setAttribute("viewBox",`0 0 ${a} ${l}`),I.setAttribute("width","100%"),I.setAttribute("height","100%"),I.style.display="block",d){const w=e.createElementNS(Br,"text");w.setAttribute("x",String(g)),w.setAttribute("y","24"),w.setAttribute("text-anchor","middle"),w.setAttribute("font-size",String(Math.max(12,Math.min(22,a/18)))),w.setAttribute("fill",S0),w.setAttribute("font-family",Ru),w.textContent=u,I.appendChild(w)}return tLn(e,I,i,g,y,v,b),c&&u8e(e,I,i,a,l),s&&T0(e,I,a),t.appendChild(I),t}function rLn(e,t,n){const r=e.reduce((l,c)=>l+c.values.length,0),o=2,i=t.length,s=(Pu+1)*2,a=n?e.length*2:0;return r+o+i+s+a}function oLn(e,t,n,r){const{width:o,height:i}=r,{series:s,truncated:a}=gS(n),l=s[0]?.categories??[],c=n.legendPosition!==void 0,u=rLn(s,l,c);if(u>I0)return Hl(e,t,`Chart too complex for inline rendering (${u} elements)`);const d=e.createElementNS(Br,"svg");d.setAttribute("viewBox",`0 0 ${o} ${i}`),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.style.display="block";const f=W1n(o,i,s);return j1n(e,d,s,f),q1n(e,d,f),K1n(e,d,l,f,o),Y1n(e,d,f,i),c&&yS(e,d,s,i),a&&T0(e,d,o),t.appendChild(d),t}var X5=96,h8e=25,x0=X5/8;function iLn(e){const t=e.ppi??X5,n=e.heightPx??h8e,{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+=x0;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=x0;if(s.push({size:"half",height:"40%",x:a}),a+=x0,c<=.5)break;for(let u=0;u<3;u++)s.push({size:"eighth",height:"10%",x:a}),a+=x0}return{widthPx:i,heightPx:n,ticks:s,leftMarginPx:o.left*t,rightMarginPx:i-o.right*t,pageWidthInches:r.width}}function sLn(e,t,n,r=X5){return t==="left"?e/r:(n-e)/r}function aLn(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 lLn(e){const t=e.ppi??X5,n=e.heightPx??h8e,{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+=x0;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=x0;if(a.push({size:"half",height:"40%",x:l}),l+=x0,u<=.5)break;for(let d=0;d<3;d++)a.push({size:"eighth",height:"10%",x:l}),l+=x0}return{widthPx:r,heightPx:n,ticks:a,leftMarginPx:o,rightMarginPx:r-i,pageWidthInches:s}}const ws={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 cLn(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=ws.ruler,o.style.cssText=`
420
420
  position: relative;
@@ -1325,7 +1325,7 @@ or
1325
1325
  bash: npm install skia-canvas
1326
1326
  js: import "konva/skia-backend";
1327
1327
  `,DGe=()=>{if(typeof document>"u")throw new Error(AXn)},Nf=class KKe{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 KKe(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=at._getRotation(l.rotation),l}},IXn="[object Array]",SXn="[object Number]",TXn="[object String]",xXn="[object Boolean]",kXn=Math.PI/180,CXn=180/Math.PI,m2="#",EXn="",_Xn="0",RXn="Konva warning: ",OGe="Konva error: ",PXn="rgb(",ate={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]},LXn=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,FF=[],g2=null,NXn=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const at={_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)===IXn},_isNumber(e){return Object.prototype.toString.call(e)===SXn&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===TXn},_isBoolean(e){return Object.prototype.toString.call(e)===xXn},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){FF.push(e),FF.length===1&&NXn(function(){const t=FF;FF=[],t.forEach(function(n){n()})})},createCanvasElement(){DGe();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return DGe(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=at.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(m2,EXn);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=_Xn+e;return m2+e},isCanvasFarblingActive(){if(g2!==null)return g2;if(typeof document>"u")return g2=!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 g2=r,this.releaseCanvas(e),g2},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),m2+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return m2+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 ate?(t=ate[e],{r:t[0],g:t[1],b:t[2]}):e[0]===m2?this._hexToRgb(e.substring(1)):e.substr(0,4)===PXn?(t=LXn.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",at._namedColorToRBA(e)||at._hex3ColorToRGBA(e)||at._hex4ColorToRGBA(e)||at._hex6ColorToRGBA(e)||at._hex8ColorToRGBA(e)||at._rgbColorToRGBA(e)||at._rgbaColorToRGBA(e)||at._hslColorToRGBA(e)},_namedColorToRBA(e){const t=ate[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*kXn},radToDeg(e){return e*CXn},_degToRad(e){return at.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),at.degToRad(e)},_radToDeg(e){return at.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),at.radToDeg(e)},_getRotation(e){return sn.angleDeg?at.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(OGe+e)},error(e){console.error(OGe+e)},warn(e){sn.showWarnings&&console.warn(RXn+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=at.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=at._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=at._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||at._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(at._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){sn.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 MXn(e){const t=[],n=e.length,r=at;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 FGe=",",DXn="(",OXn=")",FXn="([",BXn="])",HXn=";",zXn="()",UXn="=",BGe=["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"],VXn=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],GXn=100,BF=null;function HGe(){if(BF!==null)return BF;try{const e=at.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(BF=!1,!1)}catch{return BF=!1,!1}}var HF=class{constructor(e){this.canvas=e,sn.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+=zXn:at._isArray(l[0])?o+=FXn+l.join(FGe)+BXn:(t&&(l=l.map(c=>typeof c=="number"?Math.floor(c):c)),o+=DXn+l.join(FGe)+OXn)):(o+=s.property,e||(o+=UXn+s.val)),o+=HXn;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=GXn&&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=BGe.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=MXn(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(BGe[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)}};VXn.forEach(function(e){Object.defineProperty(HF.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var WXn=class extends HF{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)}},jXn=class extends HF{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()}}},zF;function qXn(){if(zF)return zF;const e=at.createCanvasElement(),t=e.getContext("2d");return zF=(function(){return(sn._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),at.releaseCanvas(e),zF}var lte=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||sn.pixelRatio||qXn(),this._canvas=at.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 at.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},H0=class extends lte{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new WXn(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},cte=class extends lte{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new jXn(this),this.setSize(e.width,e.height)}};const Wo={get isDragging(){let e=!1;return Wo._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Wo._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Wo._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=at._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=[];Wo._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")&&(Wo.justDragged=!0,sn._mouseListenClick=!1,sn._touchListenClick=!1,sn._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof sn.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Wo._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Wo._dragElements.delete(n)})}};sn.isBrowser&&(window.addEventListener("mouseup",Wo._endDragBefore,!0),window.addEventListener("touchend",Wo._endDragBefore,!0),window.addEventListener("touchcancel",Wo._endDragBefore,!0),window.addEventListener("mousemove",Wo._drag),window.addEventListener("touchmove",Wo._drag),window.addEventListener("mouseup",Wo._endDragAfter,!1),window.addEventListener("touchend",Wo._endDragAfter,!1),window.addEventListener("touchcancel",Wo._endDragAfter,!1));function z0(e){return at._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||at._isBoolean(e)?e:Object.prototype.toString.call(e)}function zGe(e){return e>255?255:e<0?0:Math.round(e)}function Qt(){if(sn.isUnminified)return function(e,t){return at._isNumber(e)||at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function UF(e){if(sn.isUnminified)return function(t,n){let r=at._isNumber(t),o=at._isArray(t)&&t.length==e;return!r&&!o&&at.warn(z0(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function ute(){if(sn.isUnminified)return function(e,t){return at._isNumber(e)||e==="auto"||at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Ev(){if(sn.isUnminified)return function(e,t){return at._isString(e)||at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function UGe(){if(sn.isUnminified)return function(e,t){const n=at._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function KXn(){if(sn.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(at._isArray(e)?e.forEach(function(r){at._isNumber(r)||at.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Mf(){if(sn.isUnminified)return function(e,t){return e===!0||e===!1||at.warn(z0(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function YXn(e){if(sn.isUnminified)return function(t,n){return t==null||at.isObject(t)||at.warn(z0(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var y2="get",b2="set";const qe={addGetterSetter(e,t,n,r,o){qe.addGetter(e,t,n),qe.addSetter(e,t,r,o),qe.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=y2+at._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=b2+at._capitalize(t);e.prototype[o]||qe.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=b2+at._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=at._capitalize,a=y2+s(t),l=b2+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=YXn(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},qe.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=at._capitalize(t),r=b2+n,o=y2+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){at.error("Adding deprecated "+t);const o=y2+at._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){at.error(i);const s=this.attrs[t];return s===void 0?n:s},qe.addSetter(e,t,r,function(){at.error(i)}),qe.addOverloadedGetterSetter(e,t)},backCompat(e,t){at.each(t,function(n,r){const o=e.prototype[r],i=y2+at._capitalize(n),s=b2+at._capitalize(n);function a(){o.apply(this,arguments),at.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 XXn(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=sn.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=sn.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=sn.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=sn.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=sn.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=sn.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:at.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var VF="absoluteOpacity",VGe="allEventListeners",wm="absoluteTransform",GGe="absoluteScale",_v="canvas",JXn="Change",ZXn="children",QXn="konva",dte="listening",$Xn="mouseenter",eJn="mouseleave",tJn="pointerenter",nJn="pointerleave",rJn="touchenter",oJn="touchleave",WGe="set",jGe="Shape",GF=" ",qGe="stage",U0="transform",iJn="Stage",fte="visible",sJn=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(GF),aJn=1,ln=class uR{constructor(t){this._id=aJn++,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===U0||t===wm)&&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===U0||t===wm)&&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(GF);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(_v)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===wm&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(_v)){const{scene:t,filter:n,hit:r}=this._cache.get(_v);at.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(_v)}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){at.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 H0({pixelRatio:s,width:o,height:i}),m=new H0({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),g=new cte({pixelRatio:d,width:o,height:i}),y=p.getContext(),v=g.getContext(),b=new H0({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),I=b.getContext();return g.isCache=!0,p.isCache=!0,this._cache.delete(_v),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),y.save(),v.save(),I.save(),y.translate(-a,-l),v.translate(-a,-l),I.translate(-a,-l),b.x=a,b.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(VF),this._clearSelfAndDescendantCache(GGe),this.drawScene(p,this,b),this.drawHit(g,this),this._isUnderCache=!1,y.restore(),v.restore(),u&&(y.save(),y.beginPath(),y.rect(0,0,o,i),y.closePath(),y.setAttr("strokeStyle","red"),y.setAttr("lineWidth",5),y.stroke(),y.restore()),at.releaseCanvas(b._canvas),this._cache.set(_v,{scene:p,filter:m,hit:g,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(_v)}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"&&HGe(),typeof t[f]!="string"||!HGe()){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=XXn(c)),c.call(this,a),i.putImageData(a,0,0)}catch(f){at.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(VGe),t.length===3)return this._delegate.apply(this,t);const o=n.split(GF);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(GF),o=r.length,i,s,a,l,c,u;if(this._cache&&this._cache.delete(VGe),!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=at.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Wo._dragElements.delete(this._id),Wo._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Wo._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(wm),this._clearSelfAndDescendantCache(VF),this._clearSelfAndDescendantCache(GGe),this._clearSelfAndDescendantCache(qGe),this._clearSelfAndDescendantCache(fte),this._clearSelfAndDescendantCache(dte)}_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"+at._capitalize(t);return at._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!==ZXn&&(r=WGe+at._capitalize(n),at._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(dte,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(fte,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;Wo._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!sn.hitOnDragEnabled&&(o||sn.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!==jGe&&(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!==iJn&&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(U0),this._clearSelfAndDescendantCache(wm)),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 Nf,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(U0);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(U0),this._clearSelfAndDescendantCache(wm),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 at.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 at.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 at.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 at.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 at.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&at.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(VF,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=at.isObject(r)&&!at._isPlainObject(r)&&!at._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 at._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],at.isValidSelector(i)||(at.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),at.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),at.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(qGe,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(wm,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new Nf,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(wm)||new Nf,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(U0,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(U0)||new Nf;r.reset();const o=this.x(),i=this.y(),s=sn.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=at.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(QXn)<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 H0({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 H0({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,at._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():sn.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+JXn,{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[WGe+at._capitalize(t)];return at._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(sn.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!at.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===jGe&&(n.target=this);const o=[$Xn,eJn,tJn,nJn,rJn,oJn];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=uR.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,uR.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;Wo._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){Wo._dragElements.has(this._id)||this._createDragElement(t);const r=Wo._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:at.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=Wo._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Wo._endDragBefore(t),Wo._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Wo._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||sn.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Wo._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=Wo._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Wo._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 at.haveIntersection(r,this.getClientRect())}static create(t,n){return at._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=uR.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),sn[r]||(at.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=sn[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(uR._createNode(o[a]));return i}};ln.protoListenerMap=new Map,ln.prototype.nodeType="Node",ln.prototype._attrsAffectingSize=[],ln.prototype.eventListeners={},ln.prototype.on(sJn,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(U0),this._clearSelfAndDescendantCache(wm)}),ln.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(fte)}),ln.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(dte)}),ln.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(VF)});var Bi=qe.addGetterSetter;Bi(ln,"zIndex"),Bi(ln,"absolutePosition"),Bi(ln,"position"),Bi(ln,"x",0,Qt()),Bi(ln,"y",0,Qt()),Bi(ln,"globalCompositeOperation","source-over",Ev()),Bi(ln,"opacity",1,Qt()),Bi(ln,"name","",Ev()),Bi(ln,"id","",Ev()),Bi(ln,"rotation",0,Qt()),qe.addComponentsGetterSetter(ln,"scale",["x","y"]),Bi(ln,"scaleX",1,Qt()),Bi(ln,"scaleY",1,Qt()),qe.addComponentsGetterSetter(ln,"skew",["x","y"]),Bi(ln,"skewX",0,Qt()),Bi(ln,"skewY",0,Qt()),qe.addComponentsGetterSetter(ln,"offset",["x","y"]),Bi(ln,"offsetX",0,Qt()),Bi(ln,"offsetY",0,Qt()),Bi(ln,"dragDistance",void 0,Qt()),Bi(ln,"width",0,Qt()),Bi(ln,"height",0,Qt()),Bi(ln,"listening",!0,Mf()),Bi(ln,"preventDefault",!0,Mf()),Bi(ln,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Bi(ln,"visible",!0,Mf()),Bi(ln,"transformsEnabled","all",Ev()),Bi(ln,"size"),Bi(ln,"dragBoundFunc"),Bi(ln,"draggable",!1,Mf()),qe.backCompat(ln,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Fu=class extends ln{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=ln.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=ln.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)}};qe.addComponentsGetterSetter(Fu,"clip",["x","y","width","height"]),qe.addGetterSetter(Fu,"clipX",void 0,Qt()),qe.addGetterSetter(Fu,"clipY",void 0,Qt()),qe.addGetterSetter(Fu,"clipWidth",void 0,Qt()),qe.addGetterSetter(Fu,"clipHeight",void 0,Qt()),qe.addGetterSetter(Fu,"clipFunc");var v2=new Map,KGe=sn._global.PointerEvent!==void 0;function hte(e){return v2.get(e)}function pte(e){return{evt:e,pointerId:e.pointerId}}function YGe(e,t){return v2.get(e)===t}function XGe(e,t){w2(e),t.getStage()&&(v2.set(e,t),KGe&&t._fire("gotpointercapture",pte(new PointerEvent("gotpointercapture"))))}function w2(e,t){const n=v2.get(e);if(!n)return;const r=n.getStage();r&&r.content,v2.delete(e),KGe&&n._fire("lostpointercapture",pte(new PointerEvent("lostpointercapture")))}var lJn="Stage",cJn="string",JGe="px",uJn="mouseout",ZGe="mouseleave",QGe="mouseover",$Ge="mouseenter",eWe="mousemove",tWe="mousedown",nWe="mouseup",A2="pointermove",I2="pointerdown",eT="pointerup",S2="pointercancel",dJn="lostpointercapture",WF="pointerout",T2="pointerleave",jF="pointerover",qF="pointerenter",mte="contextmenu",rWe="touchstart",oWe="touchend",iWe="touchmove",sWe="touchcancel",gte="wheel",fJn=5,hJn=[[$Ge,"_pointerenter"],[tWe,"_pointerdown"],[eWe,"_pointermove"],[nWe,"_pointerup"],[ZGe,"_pointerleave"],[rWe,"_pointerdown"],[iWe,"_pointermove"],[oWe,"_pointerup"],[sWe,"_pointercancel"],[QGe,"_pointerover"],[gte,"_wheel"],[mte,"_contextmenu"],[I2,"_pointerdown"],[A2,"_pointermove"],[eT,"_pointerup"],[S2,"_pointercancel"],[T2,"_pointerleave"],[dJn,"_lostpointercapture"]],yte={mouse:{[WF]:uJn,[T2]:ZGe,[jF]:QGe,[qF]:$Ge,[A2]:eWe,[I2]:tWe,[eT]:nWe,[S2]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[WF]:"touchout",[T2]:"touchleave",[jF]:"touchover",[qF]:"touchenter",[A2]:iWe,[I2]:rWe,[eT]:oWe,[S2]:sWe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[WF]:WF,[T2]:T2,[jF]:jF,[qF]:qF,[A2]:A2,[I2]:I2,[eT]:eT,[S2]:S2,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},x2=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",tT=e=>{const t=x2(e);if(t==="pointer")return sn.pointerEventsEnabled&&yte.pointer;if(t==="touch")return yte.touch;if(t==="mouse")return yte.mouse};function aWe(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&at.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var pJn="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 k2=[];var KF=class extends Fu{constructor(e){super(aWe(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),k2.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{aWe(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||at.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===cJn){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Fu.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&at._isInDocument(e)&&this.container().removeChild(e);const t=k2.indexOf(this);return t>-1&&k2.splice(t,1),at.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}:(at.warn(pJn),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 H0({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+JGe,this.content.style.height=t+JGe),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>fJn&&at.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(),sn.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return YGe(e,this)}setPointerCapture(e){XGe(e,this)}releaseCapture(e){w2(e,this)}getLayers(){return this.children}_bindContentEvents(){sn.isBrowser&&hJn.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=tT(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=tT(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=tT(e.type),n=x2(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(sn.isDragging()||sn.isTransforming())||sn.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=tT(e.type),n=x2(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Wo.justDragged=!1,sn["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}sn.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=tT(e.type),n=x2(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(sn.isDragging()&&Wo.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(sn.isDragging()||sn.isTransforming())||sn.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=hte(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=tT(e.type),n=x2(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=hte(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;sn["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Wo.justDragged||(sn["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){sn["_"+n+"InDblClickWindow"]=!1},sn.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...u}),sn["_"+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),sn["_"+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}),sn["_"+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(mte,{evt:e}):this._fire(mte,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(gte,{evt:e}):this._fire(gte,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=hte(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(eT,pte(e)),w2(e.pointerId)}_lostpointercapture(e){w2(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:at._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:at._getFirstPointerId(e)}])}_setPointerPosition(e){at.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 H0({width:this.width(),height:this.height()}),this.bufferHitCanvas=new cte({pixelRatio:1,width:this.width(),height:this.height()}),!sn.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 at.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}};KF.prototype.nodeType=lJn,Ss(KF),qe.addGetterSetter(KF,"container"),sn.isBrowser&&document.addEventListener("visibilitychange",()=>{k2.forEach(e=>{e.batchDraw()})});var lWe="hasShadow",cWe="shadowRGBA",uWe="patternImage",dWe="linearGradient",fWe="radialGradient",YF;function bte(){return YF||(YF=at.createCanvasElement().getContext("2d"),YF)}const C2={};function mJn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function gJn(e){e.stroke()}function yJn(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function bJn(e){e.stroke()}function vJn(){this._clearCache(lWe)}function wJn(){this._clearCache(cWe)}function AJn(){this._clearCache(uWe)}function IJn(){this._clearCache(dWe)}function SJn(){this._clearCache(fWe)}var qt=class extends ln{constructor(e){super(e);let t,n=0;for(;t=at.getHitColor(),!(t&&!(t in C2));)if(n++,n>=1e4){at.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=at.getRandomColor();break}this.colorKey=t,C2[t]=this}getContext(){return at.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return at.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(lWe,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(uWe,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=bte().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Nf;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(sn.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(dWe,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=bte(),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(fWe,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=bte(),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(cWe,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=at.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 ln.prototype.destroy.call(this),delete C2[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){at.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||at.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=at._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){at.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return YGe(e,this)}setPointerCapture(e){XGe(e,this)}releaseCapture(e){w2(e,this)}};qt.prototype._fillFunc=mJn,qt.prototype._strokeFunc=gJn,qt.prototype._fillFuncHit=yJn,qt.prototype._strokeFuncHit=bJn,qt.prototype._centroid=!1,qt.prototype.nodeType="Shape",Ss(qt),qt.prototype.eventListeners={},qt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",vJn),qt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",wJn),qt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",AJn),qt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",IJn),qt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",SJn),qe.addGetterSetter(qt,"stroke",void 0,UGe()),qe.addGetterSetter(qt,"strokeWidth",2,Qt()),qe.addGetterSetter(qt,"fillAfterStrokeEnabled",!1),qe.addGetterSetter(qt,"hitStrokeWidth","auto",ute()),qe.addGetterSetter(qt,"strokeHitEnabled",!0,Mf()),qe.addGetterSetter(qt,"perfectDrawEnabled",!0,Mf()),qe.addGetterSetter(qt,"shadowForStrokeEnabled",!0,Mf()),qe.addGetterSetter(qt,"lineJoin"),qe.addGetterSetter(qt,"lineCap"),qe.addGetterSetter(qt,"miterLimit"),qe.addGetterSetter(qt,"sceneFunc"),qe.addGetterSetter(qt,"hitFunc"),qe.addGetterSetter(qt,"dash"),qe.addGetterSetter(qt,"dashOffset",0,Qt()),qe.addGetterSetter(qt,"shadowColor",void 0,Ev()),qe.addGetterSetter(qt,"shadowBlur",0,Qt()),qe.addGetterSetter(qt,"shadowOpacity",1,Qt()),qe.addComponentsGetterSetter(qt,"shadowOffset",["x","y"]),qe.addGetterSetter(qt,"shadowOffsetX",0,Qt()),qe.addGetterSetter(qt,"shadowOffsetY",0,Qt()),qe.addGetterSetter(qt,"fillPatternImage"),qe.addGetterSetter(qt,"fill",void 0,UGe()),qe.addGetterSetter(qt,"fillPatternX",0,Qt()),qe.addGetterSetter(qt,"fillPatternY",0,Qt()),qe.addGetterSetter(qt,"fillLinearGradientColorStops"),qe.addGetterSetter(qt,"strokeLinearGradientColorStops"),qe.addGetterSetter(qt,"fillRadialGradientStartRadius",0),qe.addGetterSetter(qt,"fillRadialGradientEndRadius",0),qe.addGetterSetter(qt,"fillRadialGradientColorStops"),qe.addGetterSetter(qt,"fillPatternRepeat","repeat"),qe.addGetterSetter(qt,"fillEnabled",!0),qe.addGetterSetter(qt,"strokeEnabled",!0),qe.addGetterSetter(qt,"shadowEnabled",!0),qe.addGetterSetter(qt,"dashEnabled",!0),qe.addGetterSetter(qt,"strokeScaleEnabled",!0),qe.addGetterSetter(qt,"fillPriority","color"),qe.addComponentsGetterSetter(qt,"fillPatternOffset",["x","y"]),qe.addGetterSetter(qt,"fillPatternOffsetX",0,Qt()),qe.addGetterSetter(qt,"fillPatternOffsetY",0,Qt()),qe.addComponentsGetterSetter(qt,"fillPatternScale",["x","y"]),qe.addGetterSetter(qt,"fillPatternScaleX",1,Qt()),qe.addGetterSetter(qt,"fillPatternScaleY",1,Qt()),qe.addComponentsGetterSetter(qt,"fillLinearGradientStartPoint",["x","y"]),qe.addComponentsGetterSetter(qt,"strokeLinearGradientStartPoint",["x","y"]),qe.addGetterSetter(qt,"fillLinearGradientStartPointX",0),qe.addGetterSetter(qt,"strokeLinearGradientStartPointX",0),qe.addGetterSetter(qt,"fillLinearGradientStartPointY",0),qe.addGetterSetter(qt,"strokeLinearGradientStartPointY",0),qe.addComponentsGetterSetter(qt,"fillLinearGradientEndPoint",["x","y"]),qe.addComponentsGetterSetter(qt,"strokeLinearGradientEndPoint",["x","y"]),qe.addGetterSetter(qt,"fillLinearGradientEndPointX",0),qe.addGetterSetter(qt,"strokeLinearGradientEndPointX",0),qe.addGetterSetter(qt,"fillLinearGradientEndPointY",0),qe.addGetterSetter(qt,"strokeLinearGradientEndPointY",0),qe.addComponentsGetterSetter(qt,"fillRadialGradientStartPoint",["x","y"]),qe.addGetterSetter(qt,"fillRadialGradientStartPointX",0),qe.addGetterSetter(qt,"fillRadialGradientStartPointY",0),qe.addComponentsGetterSetter(qt,"fillRadialGradientEndPoint",["x","y"]),qe.addGetterSetter(qt,"fillRadialGradientEndPointX",0),qe.addGetterSetter(qt,"fillRadialGradientEndPointY",0),qe.addGetterSetter(qt,"fillPatternRotation",0),qe.addGetterSetter(qt,"fillRule",void 0,Ev()),qe.backCompat(qt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var TJn="beforeDraw",xJn="draw",hWe=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],kJn=hWe.length,Rv=class extends Fu{constructor(e){super(e),this.canvas=new H0,this.hitCanvas=new cte({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(){ln.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(!ln.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(ln.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(ln.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 ln.prototype.remove.call(this),e&&e.parentNode&&at._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"&&at.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(),ln.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(){at.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){at.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,at.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<kJn;r++){const o=hWe[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=C2[at.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(TJn,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),Fu.prototype.drawScene.call(this,o,t,n),this._fire(xJn,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Fu.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){at.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return at.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 at.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Rv.prototype.nodeType="Layer",Ss(Rv),qe.addGetterSetter(Rv,"imageSmoothingEnabled",!0),qe.addGetterSetter(Rv,"clearBeforeDraw",!0),qe.addGetterSetter(Rv,"hitGraphEnabled",!0,Mf());var vte=class extends Rv{constructor(e){super(e),this.listening(!1),at.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};vte.prototype.nodeType="FastLayer",Ss(vte);var nT=class extends Fu{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&at.throw("You may only add groups and shapes to groups.")}};nT.prototype.nodeType="Group",Ss(nT);var wte=(function(){return Cv.performance&&Cv.performance.now?function(){return Cv.performance.now()}:function(){return new Date().getTime()}})(),rT=class TT{constructor(t,n){this.id=TT.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:wte(),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=TT.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=wte(),TT._addAnimation(this),this}stop(){return TT._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(wte());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=TT;t.animations.length?(t._runFrames(),at.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,at.requestAnimFrame(this._animationLoop))}};rT.animations=[],rT.animIdCounter=0,rT.animRunning=!1;var CJn={node:1,duration:1,easing:1,onFinish:1,yoyo:1},EJn=1,pWe=2,mWe=3,gWe=["fill","stroke","shadowColor"],_Jn=0,RJn=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=pWe,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=mWe,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===pWe?this.setTime(e):this.state===mWe&&this.setTime(this.duration-e)}pause(){this.state=EJn,this.fire("onPause")}getTimer(){return new Date().getTime()}},XF=class Ms{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||E2.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=_Jn++;const c=r.getLayer()||(r instanceof sn.Stage?r.getLayers():null);c||at.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new rT(function(){n.tween.onEnterFrame()},c),this.tween=new RJn(l,function(u){n._tweenFunc(u)},i,0,1,a*1e3,s),this._addListeners(),Ms.attrs[o]||(Ms.attrs[o]={}),Ms.attrs[o][this._id]||(Ms.attrs[o][this._id]={}),Ms.tweens[o]||(Ms.tweens[o]={});for(l in t)CJn[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=Ms.tweens[o][t];u&&delete Ms.attrs[o][u][t];let d=r.getAttr(t);if(at._isArray(n))if(i=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=at._prepareArrayForTween(d,n,r.closed())):(a=n,n=at._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=at.colorToRGBA(d[f]);c=at.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 gWe.indexOf(t)!==-1?(d=at.colorToRGBA(d),c=at.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;Ms.attrs[o][this._id][t]={start:d,diff:i,end:n,trueEnd:a,trueStart:l},Ms.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=Ms.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,at._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 gWe.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=Ms.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=Ms.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=Ms.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete Ms.tweens[t][o];delete Ms.attrs[t][n],Ms.tweens[t]&&(Object.keys(Ms.tweens[t]).length===0&&delete Ms.tweens[t],Object.keys(Ms.attrs[t]).length===0&&delete Ms.attrs[t])}};XF.attrs={},XF.tweens={},ln.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new XF(e).play()};const E2={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-E2.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?E2.BounceEaseIn(e*2,0,n,r)*.5+t:E2.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}},yWe=at._assign(sn,{Util:at,Transform:Nf,Node:ln,Container:Fu,Stage:KF,stages:k2,Layer:Rv,FastLayer:vte,Group:nT,DD:Wo,Shape:qt,shapes:C2,Animation:rT,Tween:XF,Easings:E2,Context:HF,Canvas:lte});var Am=class extends qt{_sceneFunc(e){const t=sn.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=sn.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}}};Am.prototype._centroid=!0,Am.prototype.className="Arc",Am.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Ss(Am),qe.addGetterSetter(Am,"innerRadius",0,Qt()),qe.addGetterSetter(Am,"outerRadius",0,Qt()),qe.addGetterSetter(Am,"angle",0,Qt()),qe.addGetterSetter(Am,"clockwise",!1,Mf());function Ate(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 bWe(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=Ate(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 PJn(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 Im=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():bWe(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=Ate(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=Ate(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=bWe(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],...PJn(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}}};Im.prototype.className="Line",Im.prototype._attrsAffectingSize=["points","bezier","tension"],Ss(Im),qe.addGetterSetter(Im,"closed",!1),qe.addGetterSetter(Im,"bezier",!1),qe.addGetterSetter(Im,"tension",0,Qt()),qe.addGetterSetter(Im,"points",[],KXn());const LJn=[[],[],[-.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]],NJn=[[],[],[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]],MJn=[[1],[1,1],[1,2,1],[1,3,3,1]],vWe=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*LJn[20][a]+s,r+=NJn[20][a]*DJn(e,t,o);return s*r},wWe=(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 DJn(e,t,n){const r=Ite(1,n,e),o=Ite(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var Ite=(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+=MJn[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 Ite(e-1,t,o)}};const AWe=(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 Pd=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(AWe(t,su.getPathLength(n),m=>vWe([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(AWe(t,su.getPathLength(n),m=>wWe([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),v=c*y;return{x:h+y,y:p+v}}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 v=s[g];if(v==="00"){p.push(0,0),m>=0&&(m+=2,m>=7&&(m-=7));continue}if(m>=0){if(m===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),p.push(parseFloat(v.slice(2))),m+=3,m>=7&&(m-=7);continue}if(v==="11"||v==="10"||v==="01"){p.push(parseInt(v[0],10)),p.push(parseInt(v[1],10)),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}else if(m===4){if(/^[01]\d+(?:\.\d+)?$/.test(v)){p.push(parseInt(v[0],10)),p.push(parseFloat(v.slice(1))),m+=2,m>=7&&(m-=7);continue}if(v==="0"||v==="1"){p.push(parseInt(v,10)),m+=1,m>=7&&(m-=7);continue}}const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b),m+=1,m>=7&&(m-=7)}else{const b=parseFloat(v);isNaN(b)?p.push(0):p.push(b)}}for(;p.length>0&&!isNaN(p[0]);){let g="",y=[];const v=a,b=l;let I,w,A,T,x,_,E,P,k,L;switch(h){case"l":a+=p.shift(),l+=p.shift(),g="L",y.push(a,l);break;case"L":a=p.shift(),l=p.shift(),y.push(a,l);break;case"m":const R=p.shift(),O=p.shift();if(a+=R,l+=O,g="M",i.length>2&&i[i.length-1].command==="z"){for(let F=i.length-2;F>=0;F--)if(i[F].command==="M"){a=i[F].points[0]+R,l=i[F].points[1]+O;break}}y.push(a,l),h="l";break;case"M":a=p.shift(),l=p.shift(),g="M",y.push(a,l),h="L";break;case"h":a+=p.shift(),g="L",y.push(a,l);break;case"H":a=p.shift(),g="L",y.push(a,l);break;case"v":l+=p.shift(),g="L",y.push(a,l);break;case"V":l=p.shift(),g="L",y.push(a,l);break;case"C":y.push(p.shift(),p.shift(),p.shift(),p.shift()),a=p.shift(),l=p.shift(),y.push(a,l);break;case"c":y.push(a+p.shift(),l+p.shift(),a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),g="C",y.push(a,l);break;case"S":w=a,A=l,I=i[i.length-1],I.command==="C"&&(w=a+(a-I.points[2]),A=l+(l-I.points[3])),y.push(w,A,p.shift(),p.shift()),a=p.shift(),l=p.shift(),g="C",y.push(a,l);break;case"s":w=a,A=l,I=i[i.length-1],I.command==="C"&&(w=a+(a-I.points[2]),A=l+(l-I.points[3])),y.push(w,A,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":w=a,A=l,I=i[i.length-1],I.command==="Q"&&(w=a+(a-I.points[0]),A=l+(l-I.points[1])),a=p.shift(),l=p.shift(),g="Q",y.push(w,A,a,l);break;case"t":w=a,A=l,I=i[i.length-1],I.command==="Q"&&(w=a+(a-I.points[0]),A=l+(l-I.points[1])),a+=p.shift(),l+=p.shift(),g="Q",y.push(w,A,a,l);break;case"A":T=p.shift(),x=p.shift(),_=p.shift(),E=p.shift(),P=p.shift(),k=a,L=l,a=p.shift(),l=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(k,L,a,l,E,P,T,x,_);break;case"a":T=p.shift(),x=p.shift(),_=p.shift(),E=p.shift(),P=p.shift(),k=a,L=l,a+=p.shift(),l+=p.shift(),g="A",y=this.convertEndpointToCenterParameterization(k,L,a,l,E,P,T,x,_);break}i.push({command:g||h,points:y,start:{x:v,y:b},pathLength:this.calcLength(v,b,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 vWe([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return wWe([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,v=(n+o)/2+Math.sin(u)*m+Math.cos(u)*g,b=function(E){return Math.sqrt(E[0]*E[0]+E[1]*E[1])},I=function(E,P){return(E[0]*P[0]+E[1]*P[1])/(b(E)*b(P))},w=function(E,P){return(E[0]*P[1]<E[1]*P[0]?-1:1)*Math.acos(I(E,P))},A=w([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 _=w(T,x);return I(T,x)<=-1&&(_=Math.PI),I(T,x)>=1&&(_=0),s===0&&_>0&&(_=_-2*Math.PI),s===1&&_<0&&(_=_+2*Math.PI),[y,v,a,l,A,_,u,s]}};Pd.prototype.className="Path",Pd.prototype._attrsAffectingSize=["data"],Ss(Pd),qe.addGetterSetter(Pd,"data");var Pv=class extends Im{_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=Pd.calcLength(r[r.length-4],r[r.length-3],"C",d),h=Pd.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}}};Pv.prototype.className="Arrow",Ss(Pv),qe.addGetterSetter(Pv,"pointerLength",10,Qt()),qe.addGetterSetter(Pv,"pointerWidth",10,Qt()),qe.addGetterSetter(Pv,"pointerAtBeginning",!1),qe.addGetterSetter(Pv,"pointerAtEnding",!0);var oT=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)}};oT.prototype._centroid=!0,oT.prototype.className="Circle",oT.prototype._attrsAffectingSize=["radius"],Ss(oT),qe.addGetterSetter(oT,"radius",0,Qt());var V0=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)}};V0.prototype.className="Ellipse",V0.prototype._centroid=!0,V0.prototype._attrsAffectingSize=["radiusX","radiusY"],Ss(V0),qe.addComponentsGetterSetter(V0,"radius",["x","y"]),qe.addGetterSetter(V0,"radiusX",0,Qt()),qe.addGetterSetter(V0,"radiusY",0,Qt());var Df=class YKe 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?at.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?at.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=at.createImageElement();o.onload=function(){n(new YKe({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};Df.prototype.className="Image",Df.prototype._attrsAffectingSize=["image"],Ss(Df),qe.addGetterSetter(Df,"cornerRadius",0,UF(4)),qe.addGetterSetter(Df,"image"),qe.addComponentsGetterSetter(Df,"crop",["x","y","width","height"]),qe.addGetterSetter(Df,"cropX",0,Qt()),qe.addGetterSetter(Df,"cropY",0,Qt()),qe.addGetterSetter(Df,"cropWidth",0,Qt()),qe.addGetterSetter(Df,"cropHeight",0,Qt());var IWe=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],OJn="Change.konva",FJn="none",Ste="up",Tte="right",xte="down",kte="left",BJn=IWe.length,Cte=class extends nT{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<BJn;n++)e.on(IWe[n]+OJn,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 Ste:s=n/2,a=-1*l;break;case Tte:s=n+i,a=r/2;break;case xte:s=n/2,a=r+l;break;case kte: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})}}};Cte.prototype.className="Label",Ss(Cte);var Lv=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===Ste&&(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===Tte&&(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===xte&&(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===kte&&(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===Ste?(t-=r,s+=r):o===xte?s+=r:o===kte?(e-=n*1.5,i+=n):o===Tte&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};Lv.prototype.className="Tag",Ss(Lv),qe.addGetterSetter(Lv,"pointerDirection",FJn),qe.addGetterSetter(Lv,"pointerWidth",0,Qt()),qe.addGetterSetter(Lv,"pointerHeight",0,Qt()),qe.addGetterSetter(Lv,"cornerRadius",0,UF(4));var _2=class extends qt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?at.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};_2.prototype.className="Rect",Ss(_2),qe.addGetterSetter(_2,"cornerRadius",0,UF(4));var G0=class extends qt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)at.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)}};G0.prototype.className="RegularPolygon",G0.prototype._centroid=!0,G0.prototype._attrsAffectingSize=["radius"],Ss(G0),qe.addGetterSetter(G0,"radius",0,Qt()),qe.addGetterSetter(G0,"sides",0,Qt()),qe.addGetterSetter(G0,"cornerRadius",0,UF(4));var SWe=Math.PI*2,Nv=class extends qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,SWe,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),SWe,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)}};Nv.prototype.className="Ring",Nv.prototype._centroid=!0,Nv.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ss(Nv),qe.addGetterSetter(Nv,"innerRadius",0,Qt()),qe.addGetterSetter(Nv,"outerRadius",0,Qt());var jh=class extends qt{constructor(e){super(e),this._updated=!0,this.anim=new rT(()=>{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)}};jh.prototype.className="Sprite",Ss(jh),qe.addGetterSetter(jh,"animation"),qe.addGetterSetter(jh,"animations"),qe.addGetterSetter(jh,"frameOffsets"),qe.addGetterSetter(jh,"image"),qe.addGetterSetter(jh,"frameIndex",0,Qt()),qe.addGetterSetter(jh,"frameRate",17,Qt()),qe.backCompat(jh,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var W0=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)}};W0.prototype.className="Star",W0.prototype._centroid=!0,W0.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ss(W0),qe.addGetterSetter(W0,"numPoints",5,Qt()),qe.addGetterSetter(W0,"innerRadius",0,Qt()),qe.addGetterSetter(W0,"outerRadius",0,Qt());function j0(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 iT="auto",HJn="center",TWe="inherit",R2="justify",zJn="Change.konva",xWe="2d",kWe="-",CWe="left",UJn="text",VJn="Text",GJn="top",WJn="bottom",EWe="middle",_We="normal",jJn="px ",JF=" ",qJn="right",RWe="rtl",KJn="word",YJn="char",PWe="none",Ete="…",LWe=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],XJn=LWe.length,P2=null;function JJn(){if(P2!==null)return P2;P2=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(xWe);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){P2=!0;break}}}catch{}return P2}function ZJn(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 ZF;function _te(){return ZF||(ZF=at.createCanvasElement().getContext(xWe),ZF)}function QJn(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function $Jn(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function eZn(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Yi=class extends qt{constructor(e){super(eZn(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<XJn;t++)this.on(LWe[t]+zJn,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(),v=g.indexOf("underline")!==-1,b=g.indexOf("line-through")!==-1,I;c=c===TWe?e.direction:c;let w=a/2,A=EWe;if(!sn.legacyTextRendering){const T=this.measureSize("M");A="alphabetic",w=(((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===RWe&&e.setAttr("direction",c),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",A),e.setAttr("textAlign",CWe),l===EWe?u=(this.getHeight()-o*a-i*2)/2:l===WJn&&(u=this.getHeight()-o*a-i*2),e.translate(i,u+i),I=0;I<o;I++){let T=0,x=0;const _=r[I],E=_.text,P=_.width,k=_.lastInParagraph;if(e.save(),d===qJn?T+=f-P-i*2:d===HJn&&(T+=(f-P-i*2)/2),v){e.save(),e.beginPath();const R=y??(sn.legacyTextRendering?Math.round(s/2):Math.round(s/4)),O=T,F=w+x+R;e.moveTo(O,F);const H=d===R2&&!k?f-i*2:P;e.lineTo(O+Math.round(H),F),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}const L=T;if(c!==RWe&&(h!==0||d===R2||p)){const R=E.split(" ").length-1,O=j0(E);for(let F=0;F<O.length;F++){const H=O[F];if(H===" "&&!k&&d===R2&&(T+=(f-i*2-P)/R),this._partialTextX=T,this._partialTextY=w+x,this._partialText=H,p){e.save();const U=r.slice(0,I).reduce((M,z)=>M+j0(z.text).length,0);p({char:H,index:F+U,x:T,y:w+x,lineIndex:I,column:F,isLastInLine:k,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=w+x,this._partialText=E,e.fillStrokeShape(this);if(b){e.save(),e.beginPath();const R=sn.legacyTextRendering?0:-Math.round(s/4),O=L;e.moveTo(O,w+x+R);const F=d===R2&&!k?f-i*2:P;e.lineTo(O+Math.round(F),w+x+R),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||m,e.stroke(),e.restore()}e.restore(),o>1&&(w+=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=at._isString(e)?e:e==null?"":e+"";return this._setAttr(UJn,t),this}getWidth(){return this.attrs.width===iT||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===iT||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return at.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=_te(),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()+JF+this.fontVariant()+JF+(this.fontSize()+jJn)+ZJn(this.fontFamily())}_addTextLine(e){this.align()===R2&&(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 _te().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
1328
- `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==iT&&o!==void 0,a=i!==iT&&i!==void 0,l=this.padding(),c=o-l*2,u=i-l*2,d=0,f=this.wrap(),h=f!==YJn&&f!==PWe,p=this.ellipsis();this.textArr=[],_te().font=this._getContextFont();const m=p?this._getTextWidth(Ete):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let I=0,w=j0(v).length,A="",T=0;for(;I<w;){const x=I+w>>>1,_=j0(v).slice(0,x+1).join(""),E=this._getTextWidth(_);(p&&a&&d+r>u?E+m:E)<=c?(I=x+1,A=_,T=E):w=x}if(A){if(h){const x=j0(v),_=j0(A),E=x[_.length],P=E===JF||E===kWe;let k;if(P&&T<=c)k=_.length;else{const L=_.lastIndexOf(JF),R=_.lastIndexOf(kWe);k=Math.max(L,R)+1}k>0&&(I=k,A=x.slice(0,I).join(""),T=this._getTextWidth(A))}if(A=A.trimRight(),this._addTextLine(A),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=j0(v).slice(I).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==iT&&r!==void 0,i=r-this.padding()*2;return this.wrap()===PWe||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==iT&&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+Ete)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+Ete))}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&&JJn()?!0:super._useBufferCanvas()}};Yi.prototype._fillFunc=QJn,Yi.prototype._strokeFunc=$Jn,Yi.prototype.className=VJn,Yi.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ss(Yi),qe.overWriteSetter(Yi,"width",ute()),qe.overWriteSetter(Yi,"height",ute()),qe.addGetterSetter(Yi,"direction",TWe),qe.addGetterSetter(Yi,"fontFamily","Arial"),qe.addGetterSetter(Yi,"fontSize",12,Qt()),qe.addGetterSetter(Yi,"fontStyle",_We),qe.addGetterSetter(Yi,"fontVariant",_We),qe.addGetterSetter(Yi,"padding",0,Qt()),qe.addGetterSetter(Yi,"align",CWe),qe.addGetterSetter(Yi,"verticalAlign",GJn),qe.addGetterSetter(Yi,"lineHeight",1,Qt()),qe.addGetterSetter(Yi,"wrap",KJn),qe.addGetterSetter(Yi,"ellipsis",!1,Mf()),qe.addGetterSetter(Yi,"letterSpacing",0,Qt()),qe.addGetterSetter(Yi,"text","",Ev()),qe.addGetterSetter(Yi,"textDecoration",""),qe.addGetterSetter(Yi,"underlineOffset",void 0,Qt()),qe.addGetterSetter(Yi,"charRenderFunc",void 0);var tZn="",NWe="normal";function MWe(e){e.fillText(this.partialText,0,0)}function DWe(e){e.strokeText(this.partialText,0,0)}var Aa=class extends qt{constructor(e){super(e),this.dummyCanvas=at.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 Pd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Pd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Pd.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 at.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Yi.prototype.setText.call(this,e)}_getContextFont(){return Yi.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=j0(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 A=this.text().split(" ").length-1;m+=(this.pathLength-c)/A}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=Pd.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const I=Pd.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),w=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:I.x,transposeY:I.y,text:e[f],rotation:w,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,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 at.releaseCanvas(this.dummyCanvas),super.destroy()}};Aa.prototype._fillFunc=MWe,Aa.prototype._strokeFunc=DWe,Aa.prototype._fillFuncHit=MWe,Aa.prototype._strokeFuncHit=DWe,Aa.prototype.className="TextPath",Aa.prototype._attrsAffectingSize=["text","fontSize","data"],Ss(Aa),qe.addGetterSetter(Aa,"data"),qe.addGetterSetter(Aa,"fontFamily","Arial"),qe.addGetterSetter(Aa,"fontSize",12,Qt()),qe.addGetterSetter(Aa,"fontStyle",NWe),qe.addGetterSetter(Aa,"align","left"),qe.addGetterSetter(Aa,"letterSpacing",0,Qt()),qe.addGetterSetter(Aa,"textBaseline","middle"),qe.addGetterSetter(Aa,"fontVariant",NWe),qe.addGetterSetter(Aa,"text",tZn),qe.addGetterSetter(Aa,"textDecoration",""),qe.addGetterSetter(Aa,"kerningFunc",void 0);var OWe="tr-konva",nZn=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${OWe}`).join(" "),FWe="nodesRect",rZn=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],oZn={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},iZn="ontouchstart"in sn._global;function sZn(e,t,n){if(e==="rotater")return n;t+=at.degToRad(oZn[e]||0);const r=(at.radToDeg(t)%360+360)%360;return at._inRange(r,337.5,360)||at._inRange(r,0,22.5)?"ns-resize":at._inRange(r,22.5,67.5)?"nesw-resize":at._inRange(r,67.5,112.5)?"ew-resize":at._inRange(r,112.5,157.5)?"nwse-resize":at._inRange(r,157.5,202.5)?"ns-resize":at._inRange(r,202.5,247.5)?"nesw-resize":at._inRange(r,247.5,292.5)?"ew-resize":at._inRange(r,292.5,337.5)?"nwse-resize":(at.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var QF=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],BWe=1e8;function aZn(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 HWe(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 lZn(e,t){return HWe(e,t,aZn(e))}function cZn(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=sn.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var Rte=0,Co=class extends nT{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(nZn,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return at.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 OWe+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(at.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(rZn.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(FWe),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(FWe,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=(sn.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return HWe({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},-sn.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-BWe,y:-BWe,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 Nf;t.rotate(-sn.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:sn.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(),QF.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new _2({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:iZn?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=sZn(e,sn.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=at.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=at._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,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},Rte++,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 v=sn.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const I=sn.getAngle(this.rotation())+b,w=sn.getAngle(this.rotationSnapTolerance()),A=lZn(y,cZn(this.rotationSnaps(),I,w)-y.rotation);this._fitNodesInto(A,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 v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(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 v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=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 v=y.x<o.x()?-1:1,b=o.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,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 v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),I=y.y(),w=this.getWidth()-v.x(),A=this.getHeight()-v.y();v.move({x:-b,y:-I}),y.move({x:w,y:A})}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:sn.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();Rte--,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(at._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(at._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new Nf;if(o.rotate(sn.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:at.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new Nf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new Nf,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 Nf;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(at._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(at._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(w=>{w.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=at.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=at._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(w=>w.draggable()),x:0,y:0});const I=this.anchorStyleFunc();I&&l.forEach(w=>{I(w)}),(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=""),nT.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(at.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return ln.prototype.toObject.call(this)}clone(e){return ln.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Co.isTransforming=()=>Rte>0;function uZn(e){return e instanceof Array||at.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){QF.indexOf(t)===-1&&at.warn("Unknown anchor name: "+t+". Available names are: "+QF.join(", "))}),e||[]}Co.prototype.className="Transformer",Ss(Co),qe.addGetterSetter(Co,"enabledAnchors",QF,uZn),qe.addGetterSetter(Co,"flipEnabled",!0,Mf()),qe.addGetterSetter(Co,"resizeEnabled",!0),qe.addGetterSetter(Co,"anchorSize",10,Qt()),qe.addGetterSetter(Co,"rotateEnabled",!0),qe.addGetterSetter(Co,"rotateLineVisible",!0),qe.addGetterSetter(Co,"rotationSnaps",[]),qe.addGetterSetter(Co,"rotateAnchorOffset",50,Qt()),qe.addGetterSetter(Co,"rotateAnchorAngle",0,Qt()),qe.addGetterSetter(Co,"rotateAnchorCursor","crosshair"),qe.addGetterSetter(Co,"rotationSnapTolerance",5,Qt()),qe.addGetterSetter(Co,"borderEnabled",!0),qe.addGetterSetter(Co,"anchorStroke","rgb(0, 161, 255)"),qe.addGetterSetter(Co,"anchorStrokeWidth",1,Qt()),qe.addGetterSetter(Co,"anchorFill","white"),qe.addGetterSetter(Co,"anchorCornerRadius",0,Qt()),qe.addGetterSetter(Co,"borderStroke","rgb(0, 161, 255)"),qe.addGetterSetter(Co,"borderStrokeWidth",1,Qt()),qe.addGetterSetter(Co,"borderDash"),qe.addGetterSetter(Co,"keepRatio",!0),qe.addGetterSetter(Co,"shiftBehavior","default"),qe.addGetterSetter(Co,"centeredScaling",!1),qe.addGetterSetter(Co,"ignoreStroke",!1),qe.addGetterSetter(Co,"padding",0,Qt()),qe.addGetterSetter(Co,"nodes"),qe.addGetterSetter(Co,"node"),qe.addGetterSetter(Co,"boundBoxFunc"),qe.addGetterSetter(Co,"anchorDragBoundFunc"),qe.addGetterSetter(Co,"anchorStyleFunc"),qe.addGetterSetter(Co,"shouldOverdrawWholeArea",!1),qe.addGetterSetter(Co,"useSingleNodeRotation",!0),qe.backCompat(Co,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Sm=class extends qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,sn.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)}};Sm.prototype.className="Wedge",Sm.prototype._centroid=!0,Sm.prototype._attrsAffectingSize=["radius"],Ss(Sm),qe.addGetterSetter(Sm,"radius",0,Qt()),qe.addGetterSetter(Sm,"angle",0,Qt()),qe.addGetterSetter(Sm,"clockwise",!1),qe.backCompat(Sm,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function zWe(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var dZn=[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],fZn=[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 hZn(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,v,b,I,w,A,T,x;const _=t+t+1,E=r-1,P=o-1,k=t+1,L=k*(k+1)/2,R=new zWe,O=dZn[t],F=fZn[t];let H=null,U=R,M=null,z=null;for(let Z=1;Z<_;Z++)U=U.next=new zWe,Z===k&&(H=U);U.next=R,a=s=0;for(let Z=0;Z<o;Z++){g=y=v=b=l=c=u=d=0,f=k*(I=n[s]),h=k*(w=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*I,c+=L*w,u+=L*A,d+=L*T,U=R;for(let $=0;$<k;$++)U.r=I,U.g=w,U.b=A,U.a=T,U=U.next;for(let $=1;$<k;$++)i=s+((E<$?E:$)<<2),l+=(U.r=I=n[i])*(x=k-$),c+=(U.g=w=n[i+1])*x,u+=(U.b=A=n[i+2])*x,d+=(U.a=T=n[i+3])*x,g+=I,y+=w,v+=A,b+=T,U=U.next;M=R,z=H;for(let $=0;$<r;$++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,i=a+((i=$+t+1)<E?i:E)<<2,g+=M.r=n[i],y+=M.g=n[i+1],v+=M.b=n[i+2],b+=M.a=n[i+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=I=z.r,h+=w=z.g,p+=A=z.b,m+=T=z.a,g-=I,y-=w,v-=A,b-=T,z=z.next,s+=4;a+=r}for(let Z=0;Z<r;Z++){y=v=b=g=c=u=d=l=0,s=Z<<2,f=k*(I=n[s]),h=k*(w=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*I,c+=L*w,u+=L*A,d+=L*T,U=R;for(let G=0;G<k;G++)U.r=I,U.g=w,U.b=A,U.a=T,U=U.next;let $=r;for(let G=1;G<=t;G++)s=$+Z<<2,l+=(U.r=I=n[s])*(x=k-G),c+=(U.g=w=n[s+1])*x,u+=(U.b=A=n[s+2])*x,d+=(U.a=T=n[s+3])*x,g+=I,y+=w,v+=A,b+=T,U=U.next,G<P&&($+=r);s=Z,M=R,z=H;for(let G=0;G<o;G++)i=s<<2,n[i+3]=T=d*O>>F,T>0?(T=255/T,n[i]=(l*O>>F)*T,n[i+1]=(c*O>>F)*T,n[i+2]=(u*O>>F)*T):n[i]=n[i+1]=n[i+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,i=Z+((i=G+k)<P?i:P)*r<<2,l+=g+=M.r=n[i],c+=y+=M.g=n[i+1],u+=v+=M.b=n[i+2],d+=b+=M.a=n[i+3],M=M.next,f+=I=z.r,h+=w=z.g,p+=A=z.b,m+=T=z.a,g-=I,y-=w,v-=A,b-=T,z=z.next,s+=r}}const pZn=function(t){const n=Math.round(this.blurRadius());n>0&&hZn(t,n)};qe.addGetterSetter(ln,"blurRadius",0,Qt(),qe.afterSetFilter);const mZn=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};qe.addGetterSetter(ln,"brightness",0,Qt(),qe.afterSetFilter);const gZn=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)},yZn=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};qe.addGetterSetter(ln,"contrast",0,Qt(),qe.afterSetFilter);const bZn=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,v=p*255,b=m*Math.PI/180,I=Math.cos(b),w=Math.sin(b),A=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 _=[-1,0,1,-2,0,2,-1,0,1],E=[-1,-2,-1,0,0,0,1,2,1],P=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],k=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let R=1;R<d-1;R++){const O=L*d+R;let F=0,H=0;F+=x[O+P[0]]*_[0],H+=x[O+P[0]]*E[0],F+=x[O+P[1]]*_[1],H+=x[O+P[1]]*E[1],F+=x[O+P[2]]*_[2],H+=x[O+P[2]]*E[2],F+=x[O+P[3]]*_[3],H+=x[O+P[3]]*E[3],F+=x[O+P[5]]*_[5],H+=x[O+P[5]]*E[5],F+=x[O+P[6]]*_[6],H+=x[O+P[6]]*E[6],F+=x[O+P[7]]*_[7],H+=x[O+P[7]]*E[7],F+=x[O+P[8]]*_[8],H+=x[O+P[8]]*E[8];const U=k(v+(I*F+w*H)*A),M=O*4;if(g){const z=U-v;u[M]=k(T[M]+z),u[M+1]=k(T[M+1]+z),u[M+2]=k(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=U,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let R=L*4,O=((f-1)*d+L)*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let R=L*d*4,O=(L*d+(d-1))*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};qe.addGetterSetter(ln,"embossStrength",.5,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"embossWhiteLevel",.5,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"embossDirection","top-left",void 0,qe.afterSetFilter),qe.addGetterSetter(ln,"embossBlend",!1,void 0,qe.afterSetFilter);function Pte(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 vZn=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 b=0;b<n;b+=4)i=t[b+0],i<r?r=i:i>o&&(o=i),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+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,v;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),v=c-f*(c-0);else{const b=(o+r)*.5;h=o+f*(o-b),p=r+f*(r-b);const I=(a+s)*.5;m=a+f*(a-I),g=s+f*(s-I);const w=(u+c)*.5;y=u+f*(u-w),v=c+f*(c-w)}for(let b=0;b<n;b+=4)t[b+0]=Pte(t[b+0],r,o,p,h),t[b+1]=Pte(t[b+1],s,a,g,m),t[b+2]=Pte(t[b+2],c,u,v,y)};qe.addGetterSetter(ln,"enhance",0,Qt(),qe.afterSetFilter);const wZn=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}};qe.addGetterSetter(ln,"hue",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"saturation",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"luminance",0,Qt(),qe.afterSetFilter);const AZn=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 v,b,I,w;for(let A=0;A<n;A+=4)v=t[A+0],b=t[A+1],I=t[A+2],w=t[A+3],t[A+0]=c*v+u*b+d*I+s,t[A+1]=f*v+h*b+p*I+s,t[A+2]=m*v+g*b+y*I+s,t[A+3]=w},IZn=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 v=t[y+0],b=t[y+1],I=t[y+2],w=t[y+3];t[y+0]=l*v+c*b+u*I,t[y+1]=d*v+f*b+h*I,t[y+2]=p*v+m*b+g*I,t[y+3]=w}};qe.addGetterSetter(ln,"hue",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"saturation",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"value",0,Qt(),qe.afterSetFilter);const SZn=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 TZn=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),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let I=(d*i+u)*4;const w=r[I+0],A=r[I+1],T=r[I+2],x=r[I+3];I=(g+b*i)*4,o[I+0]=w,o[I+1]=A,o[I+2]=T,o[I+3]=x}}},xZn=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 v=u-a,b=d-l,I=Math.sqrt(v*v+b*b)*h/c;let w=(Math.atan2(b,v)*180/Math.PI+360+m)%360;w=w*p/360,g=Math.floor(w),y=Math.floor(I);let A=(y*i+g)*4;const T=r[A+0],x=r[A+1],_=r[A+2],E=r[A+3];A=(d*i+u)*4,o[A+0]=T,o[A+1]=x,o[A+2]=_,o[A+3]=E}};const kZn=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=at.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);at.releaseCanvas(g),TZn(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,I=0,w=b,A=1;for(m+v>t&&(I=b,w=0,A=-1),o=0;o<n;o+=1)for(r=I;r!==w;r+=A)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(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+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+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}xZn(y,e,{polarRotation:0})};qe.addGetterSetter(ln,"kaleidoscopePower",2,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"kaleidoscopeAngle",0,Qt(),qe.afterSetFilter);function $F(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 L2(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 CZn(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 EZn(e,t){const n=$F(e,0,0),r=$F(e,e.width-1,0),o=$F(e,0,e.height-1),i=$F(e,e.width-1,e.height-1),s=t||10;if(L2(n,r)<s&&L2(r,i)<s&&L2(i,o)<s&&L2(o,n)<s){const a=CZn([r,n,i,o]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=L2(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function _Zn(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function RZn(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 PZn(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 LZn(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 NZn=function(e){let t=EZn(e,this.threshold());return t&&(t=RZn(t,e.width,e.height),t=PZn(t,e.width,e.height),t=LZn(t,e.width,e.height),_Zn(e,t)),e};qe.addGetterSetter(ln,"threshold",0,Qt(),qe.afterSetFilter);const MZn=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()};qe.addGetterSetter(ln,"noise",.2,Qt(),qe.afterSetFilter);const DZn=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){at.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 v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const I=(n*b+v)*4;c+=s[I+0],u+=s[I+1],d+=s[I+2],f+=s[I+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const I=(n*b+v)*4;s[I+0]=c,s[I+1]=u,s[I+2]=d,s[I+3]=f}}};qe.addGetterSetter(ln,"pixelSize",8,Qt(),qe.afterSetFilter);const OZn=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};qe.addGetterSetter(ln,"levels",.5,Qt(),qe.afterSetFilter);const FZn=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]}};qe.addGetterSetter(ln,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"blue",0,zGe,qe.afterSetFilter);const BZn=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}};qe.addGetterSetter(ln,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"blue",0,zGe,qe.afterSetFilter),qe.addGetterSetter(ln,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const HZn=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)}},zZn=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},UZn=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};qe.addGetterSetter(ln,"threshold",.5,Qt(),qe.afterSetFilter);var VZn=yWe.Util._assign(yWe,{Arc:Am,Arrow:Pv,Circle:oT,Ellipse:V0,Image:Df,Label:Cte,Tag:Lv,Line:Im,Path:Pd,Rect:_2,RegularPolygon:G0,Ring:Nv,Sprite:jh,Star:W0,Text:Yi,TextPath:Aa,Transformer:Co,Wedge:Sm,Filters:{Blur:pZn,Brightness:gZn,Brighten:mZn,Contrast:yZn,Emboss:bZn,Enhance:vZn,Grayscale:wZn,HSL:AZn,HSV:IZn,Invert:SZn,Kaleidoscope:kZn,Mask:NZn,Noise:MZn,Pixelate:DZn,Posterize:OZn,RGB:FZn,RGBA:BZn,Sepia:HZn,Solarize:zZn,Threshold:UZn}});$t();var GZn=["dialog","floating"],UWe=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function WZn(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!GZn.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&&!UWe.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${UWe.join(", ")}, got "${e.floating.placement}".`)}var jZn=class{activeDialog=qu(null);activeFloating=qu(null);#e=!1;#t=1;#o;constructor({getModuleConfig:e}){this.#o=e}open(e){if(this.#e)return this.#u(e);WZn(e);const t=this.#l(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}#l(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"})}}},qZn="https://docs.superdoc.dev/guides/migration/document-api",VWe=new Set;function KZn(e,t){VWe.has(e)||(VWe.add(e),console.warn(t))}var YZn={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},GWe=Symbol.for("superdoc:rawEditor"),WWe=new WeakMap;function jWe(e){return!e||e[GWe]?e:new Proxy(e,{get(t,n){if(n===GWe)return t;const r=YZn[n];r&&KZn(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${qZn}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=WWe.get(t);return i||(i=new Map,WWe.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var qWe=["review","original","final","off"],XZn=["paired","independent"],KWe=Symbol.for("@superdoc/trackChanges:normalized"),YWe=new Set;function XWe(e,t){YWe.has(e)||(YWe.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function JWe(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function JZn(e,t,n){return typeof e=="string"&&qWe.includes(e)?e:typeof t=="string"&&qWe.includes(t)?t:n}function ZZn(e){return typeof e=="string"&&XZn.includes(e)?e:null}function N2(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function QZn(e){const t=e[KWe]===!0;N2(e.modules)||(e.modules={});const n=N2(e.modules.trackChanges),r=N2(e.trackChanges),o=N2(e.layoutEngineOptions?.trackedChanges);t||(r&&XWe("config.trackChanges","config.modules.trackChanges"),o&&XWe("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=JWe(n?.visible,r?.visible,!1),s=JWe(n?.enabled,o?.enabled,!0),a=ZZn(n?.replacements)??"paired",l=e.documentMode==="viewing"?i?"review":"original":"review",c=JZn(n?.mode,o?.mode,l),u={visible:i,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:i},N2(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,KWe,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}$t();var eB=Object.freeze({id:null,name:"Default SuperDoc user",email:null}),$Zn=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"]),tB=class extends JB.default{static{this.allowedTypes=[Lc,bx,_P]}#e=!1;#t=!1;#o=null;#n=null;#r;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:{...eB},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,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 jZn({getModuleConfig:()=>this.config.modules?.surfaces}),this.#i(e,t)}async#i(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),QZn(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={...eB}:(this.config.user={...eB,...o},this.config.user.name||(this.config.user.name=eB.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=jKn(this.config.modules.comments),this.config.colors=cet(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.37.0-next.2",this.#R("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||dn(),this.colors=this.config.colors??[],this.#d(),await this.#w(this.config.modules),this.#e){this.#ne();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const i=document.createElement("div");i.style.display="contents",t.appendChild(i),this.#n=i,this.#a(),this.#c(),this.#M(),this.#l()}#l(){if(this.#h(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#n)}#c(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new bXn({Renderer:VZn,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#m("requiredNumberOfEditors").documents.filter(e=>e.type===Lc).length}get state(){return{documents:this.#m("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}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(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=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}else if(n)this.config.documents=[{id:dn(),type:Lc,url:this.config.document,name:"document.docx"}];else if(r){const s=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}else if(o){const s=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=f2(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||dn()}}))}#h(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=cXn({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&&LF(this),this.#F()}#s(e,t){t&&this.on(e,t)}#a(){this.#s("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#s("editorCreate",this.config.onEditorCreate),this.#s("editorDestroy",this.config.onEditorDestroy),this.#s("ready",this.config.onReady),this.#s("comments-update",this.config.onCommentsUpdate),this.#s("awareness-update",this.config.onAwarenessUpdate),this.#s("locked",this.config.onLocked),this.#s("pdf:document-ready",this.config.onPdfDocumentReady),this.#s("sidebar-toggle",this.config.onSidebarToggle),this.#s("collaboration-ready",this.config.onCollaborationReady),this.#s("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#s("exception",this.config.onException),this.#s("list-definitions-change",this.config.onListDefinitionsChange),this.#s("pagination-update",this.config.onPaginationUpdate),this.#s("fonts-resolved",this.config.onFontsResolved)}async#w({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:dn(),type:Lc,name:"document.docx"}]),this.#A(n,r),LF(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Hae({url:e.url}));const o=djn(this);if(t&&t.useInternalExternalComments&&!t.suppressInternalExternalComments){const i=ujn(this);if(!i)throw new Error("SuperDoc: `modules.comments.useInternalExternalComments` requires `superdocId` to be set in the config.");this.ydoc=fi(i.ydoc),this.provider=fi(i.provider)}else this.ydoc=fi(o[0].ydoc),this.provider=fi(o[0].provider);return LF(this),o}#A(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=fi(e),this.provider=fi(t),this.#P();const n=this.config;this._cleanupAwareness=ajn(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#y(){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})}#P(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:$Zn,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.#g({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#_();await this.#E(t),this.#T(),G7t(n,e),hXn(e,this.#v("upgradeToCollaboration").commentsList),pXn(e,{isLocked:this.isLocked??!1,lockedBy:this.lockedBy??null}),this.config.modules.collaboration={ydoc:e,provider:t},this.#A(e,t),this.#b(e,t);const r=this.#k();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(o){throw this.#C(),o}if(await this.#x(r),this.#e)return;LF(this)}finally{this.#o=null,this.#t=!1}}#T(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#m(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}#v(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}#f(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#b(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=To(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}#C(){this.#y(),this.#b(null,null)}#x(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))})}#E(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=VA(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")))}})}#g({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===Lc);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")}#_(){const e=this.config.documents.find(n=>n.type===Lc),t=this.#m("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.#f("addSharedUser");const t=Cw({actor:e});t&&this.users.some(n=>Cw({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#f("removeSharedUser");const t=typeof e=="string"?RP(e):"",n=typeof e=="string"?`email:${t}`:Cw({actor:e});this.users=this.users.filter(r=>{const o=Cw({actor:r});return n?o!==n:t?RP(r.email)!==t:!0})}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.#m("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:jWe(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:jWe(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#R(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){const e=this.#m("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 Tv(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#M(){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 KLe({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 tKn(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.#f("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#F();const t={viewing:()=>this.#O(),editing:()=>this.#L(),suggesting:()=>this.#S()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#I(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#L(){if(this.config.role!=="editor")return this.#S();const e=this.#m("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.#I(t,"editing")})}#S(){if(!["editor","suggester"].includes(this.config.role??""))return this.#O();const e=this.#m("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.#I(t,"suggesting")})}#O(){const e=this.#m("setDocumentMode");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.#I(r,"viewing")})}#F(){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){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.#m("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.#R("🦋 [superdoc] Locking superdoc:",e,t,`
1328
+ `),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==iT&&o!==void 0,a=i!==iT&&i!==void 0,l=this.padding(),c=o-l*2,u=i-l*2,d=0,f=this.wrap(),h=f!==YJn&&f!==PWe,p=this.ellipsis();this.textArr=[],_te().font=this._getContextFont();const m=p?this._getTextWidth(Ete):0;for(let g=0,y=e.length;g<y;++g){let v=e[g],b=this._getTextWidth(v);if(s&&b>c)for(;v.length>0;){let I=0,w=j0(v).length,A="",T=0;for(;I<w;){const x=I+w>>>1,_=j0(v).slice(0,x+1).join(""),E=this._getTextWidth(_);(p&&a&&d+r>u?E+m:E)<=c?(I=x+1,A=_,T=E):w=x}if(A){if(h){const x=j0(v),_=j0(A),E=x[_.length],P=E===JF||E===kWe;let k;if(P&&T<=c)k=_.length;else{const L=_.lastIndexOf(JF),R=_.lastIndexOf(kWe);k=Math.max(L,R)+1}k>0&&(I=k,A=x.slice(0,I).join(""),T=this._getTextWidth(A))}if(A=A.trimRight(),this._addTextLine(A),n=Math.max(n,T),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(v=j0(v).slice(I).join("").trimLeft(),v.length>0&&(b=this._getTextWidth(v),b<=c)){this._addTextLine(v),d+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(v),d+=r,n=Math.max(n,b),this._shouldHandleEllipsis(d)&&g<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==iT&&r!==void 0,i=r-this.padding()*2;return this.wrap()===PWe||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==iT&&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+Ete)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+Ete))}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&&JJn()?!0:super._useBufferCanvas()}};Yi.prototype._fillFunc=QJn,Yi.prototype._strokeFunc=$Jn,Yi.prototype.className=VJn,Yi.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ss(Yi),qe.overWriteSetter(Yi,"width",ute()),qe.overWriteSetter(Yi,"height",ute()),qe.addGetterSetter(Yi,"direction",TWe),qe.addGetterSetter(Yi,"fontFamily","Arial"),qe.addGetterSetter(Yi,"fontSize",12,Qt()),qe.addGetterSetter(Yi,"fontStyle",_We),qe.addGetterSetter(Yi,"fontVariant",_We),qe.addGetterSetter(Yi,"padding",0,Qt()),qe.addGetterSetter(Yi,"align",CWe),qe.addGetterSetter(Yi,"verticalAlign",GJn),qe.addGetterSetter(Yi,"lineHeight",1,Qt()),qe.addGetterSetter(Yi,"wrap",KJn),qe.addGetterSetter(Yi,"ellipsis",!1,Mf()),qe.addGetterSetter(Yi,"letterSpacing",0,Qt()),qe.addGetterSetter(Yi,"text","",Ev()),qe.addGetterSetter(Yi,"textDecoration",""),qe.addGetterSetter(Yi,"underlineOffset",void 0,Qt()),qe.addGetterSetter(Yi,"charRenderFunc",void 0);var tZn="",NWe="normal";function MWe(e){e.fillText(this.partialText,0,0)}function DWe(e){e.strokeText(this.partialText,0,0)}var Aa=class extends qt{constructor(e){super(e),this.dummyCanvas=at.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 Pd.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Pd.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Pd.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 at.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Yi.prototype.setText.call(this,e)}_getContextFont(){return Yi.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=j0(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 A=this.text().split(" ").length-1;m+=(this.pathLength-c)/A}const g=d+m,y=this._getPointAtLength(g>this.pathLength&&g-this.pathLength<=l?this.pathLength:g);if(!y)return;const v=Pd.getLineLength(h.x,h.y,y.x,y.y);let b=0;if(a)try{b=a(t[f-1].char,p)*this.fontSize()}catch{b=0}h.x+=b,y.x+=b,this.textWidth+=b;const I=Pd.getPointOnLine(b+v/2,h.x,h.y,y.x,y.y),w=Math.atan2(y.y-h.y,y.x-h.x);this.glyphInfo.push({transposeX:I.x,transposeY:I.y,text:e[f],rotation:w,p0:h,p1:y,width:v}),d+=m}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,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 at.releaseCanvas(this.dummyCanvas),super.destroy()}};Aa.prototype._fillFunc=MWe,Aa.prototype._strokeFunc=DWe,Aa.prototype._fillFuncHit=MWe,Aa.prototype._strokeFuncHit=DWe,Aa.prototype.className="TextPath",Aa.prototype._attrsAffectingSize=["text","fontSize","data"],Ss(Aa),qe.addGetterSetter(Aa,"data"),qe.addGetterSetter(Aa,"fontFamily","Arial"),qe.addGetterSetter(Aa,"fontSize",12,Qt()),qe.addGetterSetter(Aa,"fontStyle",NWe),qe.addGetterSetter(Aa,"align","left"),qe.addGetterSetter(Aa,"letterSpacing",0,Qt()),qe.addGetterSetter(Aa,"textBaseline","middle"),qe.addGetterSetter(Aa,"fontVariant",NWe),qe.addGetterSetter(Aa,"text",tZn),qe.addGetterSetter(Aa,"textDecoration",""),qe.addGetterSetter(Aa,"kerningFunc",void 0);var OWe="tr-konva",nZn=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${OWe}`).join(" "),FWe="nodesRect",rZn=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],oZn={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},iZn="ontouchstart"in sn._global;function sZn(e,t,n){if(e==="rotater")return n;t+=at.degToRad(oZn[e]||0);const r=(at.radToDeg(t)%360+360)%360;return at._inRange(r,337.5,360)||at._inRange(r,0,22.5)?"ns-resize":at._inRange(r,22.5,67.5)?"nesw-resize":at._inRange(r,67.5,112.5)?"ew-resize":at._inRange(r,112.5,157.5)?"nwse-resize":at._inRange(r,157.5,202.5)?"ns-resize":at._inRange(r,202.5,247.5)?"nesw-resize":at._inRange(r,247.5,292.5)?"ew-resize":at._inRange(r,292.5,337.5)?"nwse-resize":(at.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var QF=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],BWe=1e8;function aZn(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 HWe(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 lZn(e,t){return HWe(e,t,aZn(e))}function cZn(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=sn.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var Rte=0,Co=class extends nT{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(nZn,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return at.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 OWe+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(at.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(rZn.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(FWe),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(FWe,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=(sn.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return HWe({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},-sn.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-BWe,y:-BWe,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 Nf;t.rotate(-sn.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:sn.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(),QF.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new _2({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:iZn?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=sZn(e,sn.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=at.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=at._sign(s),v=m+u*l*y,b=g+d*l*y;t.moveTo(m,g),t.lineTo(v,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,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},Rte++,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 v=sn.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-v;y.height<0&&(b-=Math.PI);const I=sn.getAngle(this.rotation())+b,w=sn.getAngle(this.rotationSnapTolerance()),A=lZn(y,cZn(this.rotationSnaps(),I,w)-y.rotation);this._fitNodesInto(A,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 v=this.findOne(".top-left").x()>y.x?-1:1,b=this.findOne(".top-left").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-left").x(y.x-t),this.findOne(".top-left").y(y.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(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 v=this.findOne(".top-right").x()<y.x?-1:1,b=this.findOne(".top-right").y()>y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".top-right").x(y.x+t),this.findOne(".top-right").y(y.y-n)}var h=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 v=y.x<o.x()?-1:1,b=o.y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,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 v=this.findOne(".bottom-right").x()<y.x?-1:1,b=this.findOne(".bottom-right").y()<y.y?-1:1;t=r*this.cos*v,n=r*this.sin*b,this.findOne(".bottom-right").x(y.x+t),this.findOne(".bottom-right").y(y.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){const y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),b=y.x(),I=y.y(),w=this.getWidth()-v.x(),A=this.getHeight()-v.y();v.move({x:-b,y:-I}),y.move({x:w,y:A})}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:sn.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();Rte--,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(at._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(at._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new Nf;if(o.rotate(sn.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:at.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new Nf;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new Nf,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 Nf;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(at._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(at._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(w=>{w.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=at.degToRad(c),f=Math.sin(d),h=-Math.cos(d),p=n/2,m=r/2;let g=1/0;h<0?g=Math.min(g,-m/h):h>0&&(g=Math.min(g,(r-m)/h)),f<0?g=Math.min(g,-p/f):f>0&&(g=Math.min(g,(n-p)/f));const y=p+f*g,v=m+h*g,b=at._sign(r);this._batchChangeChild(".rotater",{x:y+f*u*b,y:v+h*u*b-s*h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(w=>w.draggable()),x:0,y:0});const I=this.anchorStyleFunc();I&&l.forEach(w=>{I(w)}),(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=""),nT.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(at.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return ln.prototype.toObject.call(this)}clone(e){return ln.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Co.isTransforming=()=>Rte>0;function uZn(e){return e instanceof Array||at.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){QF.indexOf(t)===-1&&at.warn("Unknown anchor name: "+t+". Available names are: "+QF.join(", "))}),e||[]}Co.prototype.className="Transformer",Ss(Co),qe.addGetterSetter(Co,"enabledAnchors",QF,uZn),qe.addGetterSetter(Co,"flipEnabled",!0,Mf()),qe.addGetterSetter(Co,"resizeEnabled",!0),qe.addGetterSetter(Co,"anchorSize",10,Qt()),qe.addGetterSetter(Co,"rotateEnabled",!0),qe.addGetterSetter(Co,"rotateLineVisible",!0),qe.addGetterSetter(Co,"rotationSnaps",[]),qe.addGetterSetter(Co,"rotateAnchorOffset",50,Qt()),qe.addGetterSetter(Co,"rotateAnchorAngle",0,Qt()),qe.addGetterSetter(Co,"rotateAnchorCursor","crosshair"),qe.addGetterSetter(Co,"rotationSnapTolerance",5,Qt()),qe.addGetterSetter(Co,"borderEnabled",!0),qe.addGetterSetter(Co,"anchorStroke","rgb(0, 161, 255)"),qe.addGetterSetter(Co,"anchorStrokeWidth",1,Qt()),qe.addGetterSetter(Co,"anchorFill","white"),qe.addGetterSetter(Co,"anchorCornerRadius",0,Qt()),qe.addGetterSetter(Co,"borderStroke","rgb(0, 161, 255)"),qe.addGetterSetter(Co,"borderStrokeWidth",1,Qt()),qe.addGetterSetter(Co,"borderDash"),qe.addGetterSetter(Co,"keepRatio",!0),qe.addGetterSetter(Co,"shiftBehavior","default"),qe.addGetterSetter(Co,"centeredScaling",!1),qe.addGetterSetter(Co,"ignoreStroke",!1),qe.addGetterSetter(Co,"padding",0,Qt()),qe.addGetterSetter(Co,"nodes"),qe.addGetterSetter(Co,"node"),qe.addGetterSetter(Co,"boundBoxFunc"),qe.addGetterSetter(Co,"anchorDragBoundFunc"),qe.addGetterSetter(Co,"anchorStyleFunc"),qe.addGetterSetter(Co,"shouldOverdrawWholeArea",!1),qe.addGetterSetter(Co,"useSingleNodeRotation",!0),qe.backCompat(Co,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Sm=class extends qt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,sn.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)}};Sm.prototype.className="Wedge",Sm.prototype._centroid=!0,Sm.prototype._attrsAffectingSize=["radius"],Ss(Sm),qe.addGetterSetter(Sm,"radius",0,Qt()),qe.addGetterSetter(Sm,"angle",0,Qt()),qe.addGetterSetter(Sm,"clockwise",!1),qe.backCompat(Sm,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function zWe(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var dZn=[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],fZn=[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 hZn(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,v,b,I,w,A,T,x;const _=t+t+1,E=r-1,P=o-1,k=t+1,L=k*(k+1)/2,R=new zWe,O=dZn[t],F=fZn[t];let H=null,U=R,M=null,z=null;for(let Z=1;Z<_;Z++)U=U.next=new zWe,Z===k&&(H=U);U.next=R,a=s=0;for(let Z=0;Z<o;Z++){g=y=v=b=l=c=u=d=0,f=k*(I=n[s]),h=k*(w=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*I,c+=L*w,u+=L*A,d+=L*T,U=R;for(let $=0;$<k;$++)U.r=I,U.g=w,U.b=A,U.a=T,U=U.next;for(let $=1;$<k;$++)i=s+((E<$?E:$)<<2),l+=(U.r=I=n[i])*(x=k-$),c+=(U.g=w=n[i+1])*x,u+=(U.b=A=n[i+2])*x,d+=(U.a=T=n[i+3])*x,g+=I,y+=w,v+=A,b+=T,U=U.next;M=R,z=H;for(let $=0;$<r;$++)n[s+3]=T=d*O>>F,T!==0?(T=255/T,n[s]=(l*O>>F)*T,n[s+1]=(c*O>>F)*T,n[s+2]=(u*O>>F)*T):n[s]=n[s+1]=n[s+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,i=a+((i=$+t+1)<E?i:E)<<2,g+=M.r=n[i],y+=M.g=n[i+1],v+=M.b=n[i+2],b+=M.a=n[i+3],l+=g,c+=y,u+=v,d+=b,M=M.next,f+=I=z.r,h+=w=z.g,p+=A=z.b,m+=T=z.a,g-=I,y-=w,v-=A,b-=T,z=z.next,s+=4;a+=r}for(let Z=0;Z<r;Z++){y=v=b=g=c=u=d=l=0,s=Z<<2,f=k*(I=n[s]),h=k*(w=n[s+1]),p=k*(A=n[s+2]),m=k*(T=n[s+3]),l+=L*I,c+=L*w,u+=L*A,d+=L*T,U=R;for(let G=0;G<k;G++)U.r=I,U.g=w,U.b=A,U.a=T,U=U.next;let $=r;for(let G=1;G<=t;G++)s=$+Z<<2,l+=(U.r=I=n[s])*(x=k-G),c+=(U.g=w=n[s+1])*x,u+=(U.b=A=n[s+2])*x,d+=(U.a=T=n[s+3])*x,g+=I,y+=w,v+=A,b+=T,U=U.next,G<P&&($+=r);s=Z,M=R,z=H;for(let G=0;G<o;G++)i=s<<2,n[i+3]=T=d*O>>F,T>0?(T=255/T,n[i]=(l*O>>F)*T,n[i+1]=(c*O>>F)*T,n[i+2]=(u*O>>F)*T):n[i]=n[i+1]=n[i+2]=0,l-=f,c-=h,u-=p,d-=m,f-=M.r,h-=M.g,p-=M.b,m-=M.a,i=Z+((i=G+k)<P?i:P)*r<<2,l+=g+=M.r=n[i],c+=y+=M.g=n[i+1],u+=v+=M.b=n[i+2],d+=b+=M.a=n[i+3],M=M.next,f+=I=z.r,h+=w=z.g,p+=A=z.b,m+=T=z.a,g-=I,y-=w,v-=A,b-=T,z=z.next,s+=r}}const pZn=function(t){const n=Math.round(this.blurRadius());n>0&&hZn(t,n)};qe.addGetterSetter(ln,"blurRadius",0,Qt(),qe.afterSetFilter);const mZn=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};qe.addGetterSetter(ln,"brightness",0,Qt(),qe.afterSetFilter);const gZn=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)},yZn=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};qe.addGetterSetter(ln,"contrast",0,Qt(),qe.afterSetFilter);const bZn=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,v=p*255,b=m*Math.PI/180,I=Math.cos(b),w=Math.sin(b),A=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 _=[-1,0,1,-2,0,2,-1,0,1],E=[-1,-2,-1,0,0,0,1,2,1],P=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],k=L=>L<0?0:L>255?255:L;for(let L=1;L<f-1;L++)for(let R=1;R<d-1;R++){const O=L*d+R;let F=0,H=0;F+=x[O+P[0]]*_[0],H+=x[O+P[0]]*E[0],F+=x[O+P[1]]*_[1],H+=x[O+P[1]]*E[1],F+=x[O+P[2]]*_[2],H+=x[O+P[2]]*E[2],F+=x[O+P[3]]*_[3],H+=x[O+P[3]]*E[3],F+=x[O+P[5]]*_[5],H+=x[O+P[5]]*E[5],F+=x[O+P[6]]*_[6],H+=x[O+P[6]]*E[6],F+=x[O+P[7]]*_[7],H+=x[O+P[7]]*E[7],F+=x[O+P[8]]*_[8],H+=x[O+P[8]]*E[8];const U=k(v+(I*F+w*H)*A),M=O*4;if(g){const z=U-v;u[M]=k(T[M]+z),u[M+1]=k(T[M+1]+z),u[M+2]=k(T[M+2]+z),u[M+3]=T[M+3]}else u[M]=u[M+1]=u[M+2]=U,u[M+3]=T[M+3]}for(let L=0;L<d;L++){let R=L*4,O=((f-1)*d+L)*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}for(let L=1;L<f-1;L++){let R=L*d*4,O=(L*d+(d-1))*4;u[R]=T[R],u[R+1]=T[R+1],u[R+2]=T[R+2],u[R+3]=T[R+3],u[O]=T[O],u[O+1]=T[O+1],u[O+2]=T[O+2],u[O+3]=T[O+3]}return e};qe.addGetterSetter(ln,"embossStrength",.5,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"embossWhiteLevel",.5,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"embossDirection","top-left",void 0,qe.afterSetFilter),qe.addGetterSetter(ln,"embossBlend",!1,void 0,qe.afterSetFilter);function Pte(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 vZn=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 b=0;b<n;b+=4)i=t[b+0],i<r?r=i:i>o&&(o=i),l=t[b+1],l<s?s=l:l>a&&(a=l),d=t[b+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,v;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),v=c-f*(c-0);else{const b=(o+r)*.5;h=o+f*(o-b),p=r+f*(r-b);const I=(a+s)*.5;m=a+f*(a-I),g=s+f*(s-I);const w=(u+c)*.5;y=u+f*(u-w),v=c+f*(c-w)}for(let b=0;b<n;b+=4)t[b+0]=Pte(t[b+0],r,o,p,h),t[b+1]=Pte(t[b+1],s,a,g,m),t[b+2]=Pte(t[b+2],c,u,v,y)};qe.addGetterSetter(ln,"enhance",0,Qt(),qe.afterSetFilter);const wZn=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}};qe.addGetterSetter(ln,"hue",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"saturation",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"luminance",0,Qt(),qe.afterSetFilter);const AZn=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 v,b,I,w;for(let A=0;A<n;A+=4)v=t[A+0],b=t[A+1],I=t[A+2],w=t[A+3],t[A+0]=c*v+u*b+d*I+s,t[A+1]=f*v+h*b+p*I+s,t[A+2]=m*v+g*b+y*I+s,t[A+3]=w},IZn=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 v=t[y+0],b=t[y+1],I=t[y+2],w=t[y+3];t[y+0]=l*v+c*b+u*I,t[y+1]=d*v+f*b+h*I,t[y+2]=p*v+m*b+g*I,t[y+3]=w}};qe.addGetterSetter(ln,"hue",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"saturation",0,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"value",0,Qt(),qe.afterSetFilter);const SZn=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 TZn=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),v=Math.cos(g*m);for(let b=0;b<h;b+=1){u=Math.floor(a+c*b/h*v),d=Math.floor(l+c*b/h*y);let I=(d*i+u)*4;const w=r[I+0],A=r[I+1],T=r[I+2],x=r[I+3];I=(g+b*i)*4,o[I+0]=w,o[I+1]=A,o[I+2]=T,o[I+3]=x}}},xZn=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 v=u-a,b=d-l,I=Math.sqrt(v*v+b*b)*h/c;let w=(Math.atan2(b,v)*180/Math.PI+360+m)%360;w=w*p/360,g=Math.floor(w),y=Math.floor(I);let A=(y*i+g)*4;const T=r[A+0],x=r[A+1],_=r[A+2],E=r[A+3];A=(d*i+u)*4,o[A+0]=T,o[A+1]=x,o[A+2]=_,o[A+3]=E}};const kZn=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=at.createCanvasElement();g.width=t,g.height=n;const y=g.getContext("2d").getImageData(0,0,t,n);at.releaseCanvas(g),TZn(e,y,{polarCenterX:t/2,polarCenterY:n/2});let v=t/Math.pow(2,h);for(;v<=8;)v=v*2,h-=1;v=Math.ceil(v);let b=v,I=0,w=b,A=1;for(m+v>t&&(I=b,w=0,A=-1),o=0;o<n;o+=1)for(r=I;r!==w;r+=A)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(b=Math.floor(v),s=0;s<h;s+=1){for(r=0;r<b+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+b*2-r-1)*4,y.data[f+0]=a,y.data[f+1]=l,y.data[f+2]=c,y.data[f+3]=u;b*=2}xZn(y,e,{polarRotation:0})};qe.addGetterSetter(ln,"kaleidoscopePower",2,Qt(),qe.afterSetFilter),qe.addGetterSetter(ln,"kaleidoscopeAngle",0,Qt(),qe.afterSetFilter);function $F(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 L2(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 CZn(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 EZn(e,t){const n=$F(e,0,0),r=$F(e,e.width-1,0),o=$F(e,0,e.height-1),i=$F(e,e.width-1,e.height-1),s=t||10;if(L2(n,r)<s&&L2(r,i)<s&&L2(i,o)<s&&L2(o,n)<s){const a=CZn([r,n,i,o]),l=[];for(let c=0;c<e.width*e.height;c++)l[c]=L2(a,[e.data[c*4],e.data[c*4+1],e.data[c*4+2]])<s?0:255;return l}}function _Zn(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function RZn(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 PZn(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 LZn(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 NZn=function(e){let t=EZn(e,this.threshold());return t&&(t=RZn(t,e.width,e.height),t=PZn(t,e.width,e.height),t=LZn(t,e.width,e.height),_Zn(e,t)),e};qe.addGetterSetter(ln,"threshold",0,Qt(),qe.afterSetFilter);const MZn=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()};qe.addGetterSetter(ln,"noise",.2,Qt(),qe.afterSetFilter);const DZn=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){at.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 v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const I=(n*b+v)*4;c+=s[I+0],u+=s[I+1],d+=s[I+2],f+=s[I+3],y+=1}c=c/y,u=u/y,d=d/y,f=f/y;for(let v=h;v<p;v+=1)if(!(v>=n))for(let b=m;b<g;b+=1){if(b>=r)continue;const I=(n*b+v)*4;s[I+0]=c,s[I+1]=u,s[I+2]=d,s[I+3]=f}}};qe.addGetterSetter(ln,"pixelSize",8,Qt(),qe.afterSetFilter);const OZn=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};qe.addGetterSetter(ln,"levels",.5,Qt(),qe.afterSetFilter);const FZn=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]}};qe.addGetterSetter(ln,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"blue",0,zGe,qe.afterSetFilter);const BZn=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}};qe.addGetterSetter(ln,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),qe.addGetterSetter(ln,"blue",0,zGe,qe.afterSetFilter),qe.addGetterSetter(ln,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const HZn=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)}},zZn=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},UZn=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};qe.addGetterSetter(ln,"threshold",.5,Qt(),qe.afterSetFilter);var VZn=yWe.Util._assign(yWe,{Arc:Am,Arrow:Pv,Circle:oT,Ellipse:V0,Image:Df,Label:Cte,Tag:Lv,Line:Im,Path:Pd,Rect:_2,RegularPolygon:G0,Ring:Nv,Sprite:jh,Star:W0,Text:Yi,TextPath:Aa,Transformer:Co,Wedge:Sm,Filters:{Blur:pZn,Brightness:gZn,Brighten:mZn,Contrast:yZn,Emboss:bZn,Enhance:vZn,Grayscale:wZn,HSL:AZn,HSV:IZn,Invert:SZn,Kaleidoscope:kZn,Mask:NZn,Noise:MZn,Pixelate:DZn,Posterize:OZn,RGB:FZn,RGBA:BZn,Sepia:HZn,Solarize:zZn,Threshold:UZn}});$t();var GZn=["dialog","floating"],UWe=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function WZn(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!GZn.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&&!UWe.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${UWe.join(", ")}, got "${e.floating.placement}".`)}var jZn=class{activeDialog=qu(null);activeFloating=qu(null);#e=!1;#t=1;#o;constructor({getModuleConfig:e}){this.#o=e}open(e){if(this.#e)return this.#u(e);WZn(e);const t=this.#l(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}#l(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"})}}},qZn="https://docs.superdoc.dev/guides/migration/document-api",VWe=new Set;function KZn(e,t){VWe.has(e)||(VWe.add(e),console.warn(t))}var YZn={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},GWe=Symbol.for("superdoc:rawEditor"),WWe=new WeakMap;function jWe(e){return!e||e[GWe]?e:new Proxy(e,{get(t,n){if(n===GWe)return t;const r=YZn[n];r&&KZn(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${qZn}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=WWe.get(t);return i||(i=new Map,WWe.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var qWe=["review","original","final","off"],XZn=["paired","independent"],KWe=Symbol.for("@superdoc/trackChanges:normalized"),YWe=new Set;function XWe(e,t){YWe.has(e)||(YWe.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function JWe(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function JZn(e,t,n){return typeof e=="string"&&qWe.includes(e)?e:typeof t=="string"&&qWe.includes(t)?t:n}function ZZn(e){return typeof e=="string"&&XZn.includes(e)?e:null}function N2(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function QZn(e){const t=e[KWe]===!0;N2(e.modules)||(e.modules={});const n=N2(e.modules.trackChanges),r=N2(e.trackChanges),o=N2(e.layoutEngineOptions?.trackedChanges);t||(r&&XWe("config.trackChanges","config.modules.trackChanges"),o&&XWe("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=JWe(n?.visible,r?.visible,!1),s=JWe(n?.enabled,o?.enabled,!0),a=ZZn(n?.replacements)??"paired",l=e.documentMode==="viewing"?i?"review":"original":"review",c=JZn(n?.mode,o?.mode,l),u={visible:i,mode:c,enabled:s,replacements:a};return e.modules.trackChanges=u,e.trackChanges={visible:i},N2(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:c,enabled:s},Object.defineProperty(e,KWe,{value:!0,writable:!0,configurable:!0,enumerable:!1}),u}$t();var eB=Object.freeze({id:null,name:"Default SuperDoc user",email:null}),$Zn=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"]),tB=class extends JB.default{static{this.allowedTypes=[Lc,bx,_P]}#e=!1;#t=!1;#o=null;#n=null;#r;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:{...eB},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,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 jZn({getModuleConfig:()=>this.config.modules?.surfaces}),this.#i(e,t)}async#i(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),QZn(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={...eB}:(this.config.user={...eB,...o},this.config.user.name||(this.config.user.name=eB.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=jKn(this.config.modules.comments),this.config.colors=cet(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="1.37.0-next.3",this.#R("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||dn(),this.colors=this.config.colors??[],this.#d(),await this.#w(this.config.modules),this.#e){this.#ne();return}this.config.cspNonce&&this.#u(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const i=document.createElement("div");i.style.display="contents",t.appendChild(i),this.#n=i,this.#a(),this.#c(),this.#M(),this.#l()}#l(){if(this.#h(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#n)}#c(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new bXn({Renderer:VZn,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#m("requiredNumberOfEditors").documents.filter(e=>e.type===Lc).length}get state(){return{documents:this.#m("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}#u(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#d(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(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=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}else if(n)this.config.documents=[{id:dn(),type:Lc,url:this.config.document,name:"document.docx"}];else if(r){const s=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}else if(o){const s=f2(this.config.document);this.config.documents=[{id:dn(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=f2(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||dn()}}))}#h(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=cXn({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&&LF(this),this.#F()}#s(e,t){t&&this.on(e,t)}#a(){this.#s("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#s("editorCreate",this.config.onEditorCreate),this.#s("editorDestroy",this.config.onEditorDestroy),this.#s("ready",this.config.onReady),this.#s("comments-update",this.config.onCommentsUpdate),this.#s("awareness-update",this.config.onAwarenessUpdate),this.#s("locked",this.config.onLocked),this.#s("pdf:document-ready",this.config.onPdfDocumentReady),this.#s("sidebar-toggle",this.config.onSidebarToggle),this.#s("collaboration-ready",this.config.onCollaborationReady),this.#s("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#s("exception",this.config.onException),this.#s("list-definitions-change",this.config.onListDefinitionsChange),this.#s("pagination-update",this.config.onPaginationUpdate),this.#s("fonts-resolved",this.config.onFontsResolved)}async#w({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:dn(),type:Lc,name:"document.docx"}]),this.#A(n,r),LF(this),this.config.documents;this.isCollaborative=!0,e.providerType==="hocuspocus"&&(this.config.socket=new Hae({url:e.url}));const o=djn(this);if(t&&t.useInternalExternalComments&&!t.suppressInternalExternalComments){const i=ujn(this);if(!i)throw new Error("SuperDoc: `modules.comments.useInternalExternalComments` requires `superdocId` to be set in the config.");this.ydoc=fi(i.ydoc),this.provider=fi(i.provider)}else this.ydoc=fi(o[0].ydoc),this.provider=fi(o[0].provider);return LF(this),o}#A(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=fi(e),this.provider=fi(t),this.#P();const n=this.config;this._cleanupAwareness=ajn(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#y(){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})}#P(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:$Zn,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.#g({ydoc:e,provider:t}),this.#t=!0;try{const n=this.#_();await this.#E(t),this.#T(),G7t(n,e),hXn(e,this.#v("upgradeToCollaboration").commentsList),pXn(e,{isLocked:this.isLocked??!1,lockedBy:this.lockedBy??null}),this.config.modules.collaboration={ydoc:e,provider:t},this.#A(e,t),this.#b(e,t);const r=this.#k();try{r.attachCollaboration({ydoc:e,collaborationProvider:t})}catch(o){throw this.#C(),o}if(await this.#x(r),this.#e)return;LF(this)}finally{this.#o=null,this.#t=!1}}#T(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#m(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}#v(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}#f(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#b(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=To(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}#C(){this.#y(),this.#b(null,null)}#x(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))})}#E(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=VA(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")))}})}#g({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===Lc);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")}#_(){const e=this.config.documents.find(n=>n.type===Lc),t=this.#m("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.#f("addSharedUser");const t=Cw({actor:e});t&&this.users.some(n=>Cw({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#f("removeSharedUser");const t=typeof e=="string"?RP(e):"",n=typeof e=="string"?`email:${t}`:Cw({actor:e});this.users=this.users.filter(r=>{const o=Cw({actor:r});return n?o!==n:t?RP(r.email)!==t:!0})}onContentError({error:e,editor:t}){const{documentId:n}=t.options,r=this.#m("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:jWe(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:jWe(e)})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#R(...e){(console.debug?console.debug:console.log)("🦋 🦸‍♀️ [superdoc]",...e)}setActiveEditor(e){this.activeEditor=e,this.toolbar&&(this.activeEditor.toolbar=this.toolbar,this.toolbar.setActiveEditor(e))}toggleRuler(){const e=this.#m("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 Tv(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#M(){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 KLe({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 tKn(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.#f("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#F();const t={viewing:()=>this.#O(),editing:()=>this.#L(),suggesting:()=>this.#S()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#I(e,t){const n=typeof e.getPresentationEditor=="function"?e.getPresentationEditor():null;if(n){n.setDocumentMode(t);return}const r=typeof e.getEditor=="function"?e.getEditor():null;r&&r.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getPresentationEditor=="function"?n.getPresentationEditor():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#L(){if(this.config.role!=="editor")return this.#S();const e=this.#m("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.#I(t,"editing")})}#S(){if(!["editor","suggester"].includes(this.config.role??""))return this.#O();const e=this.#m("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.#I(t,"suggesting")})}#O(){const e=this.#m("setDocumentMode");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.#I(r,"viewing")})}#F(){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){return this.activeEditor?.commands.search(e,{searchModel:"visible"})}goToSearchResult(e){return this.activeEditor?.commands.goToSearchResult(e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}this.superdocStore&&(this.superdocStore.activeZoom=e),this.emit("zoomChange",{zoom:e})}setLocked(e=!0){this.config.documents.forEach(t=>{const n=t.ydoc,r=n.getMap("meta");n.transact(()=>{r.set("locked",e),r.set("lockedBy",this.user)})})}getHTML(e={}){const t=[];return this.#m("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.#R("🦋 [superdoc] Locking superdoc:",e,t,`
1329
1329
 
1330
1330
 
1331
1331
  `),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=LGe(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?PGe(u[0],l,e[0]):u[0];const f=await BUe(u,d);return s?PGe(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=this.#m("exportEditorsToDOCX").documents.map(async s=>{if(!s||s.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const a=typeof s.getEditor=="function"?s.getEditor():null,l=()=>!s.data||s.data.type&&s.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:s.data;if(!a)return l();try{const c=await a.exportDocx({isFinalDoc:t,comments:r,commentsType:e,fieldsHighlightColor:n});if(c)return c}catch(c){this.emit("exception",{error:c,document:s})}return l()});return(await Promise.all(i)).filter(s=>s!=null)}async#z(){this.#R("🦋 [superdoc] Triggering collaboration saves");const e=this.#m("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#R(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#R(`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.#R(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#z()];this.#R("🦋 [superdoc] Saving superdoc"),await Promise.all(e),this.#R("🦋 [superdoc] Save complete")}#ne(){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.#R("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#ne(),this.#n&&(this.#n.remove(),this.#n=null)}focus(){this.activeEditor?this.activeEditor.focus():this.#m("focus").documents.find(e=>{const t=e.getEditor?.();t&&t.focus()})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};const eQn=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"?N3():Vb(),mode:r,isHeadless:!0,deferDocumentLoad:!0,telemetry:{enabled:!1}});try{return await o.getSchemaSummaryJSON()}finally{typeof o.destroy=="function"&&o.destroy()}};var tQn={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"},nQn=0;function ZWe(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-${++nQn}`}`,l=[];if(i)for(const[c,u]of Object.entries(i)){if(u==null)continue;const d=tQn[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} {