@inkeep/open-knowledge 0.6.0-beta.3 → 0.6.0-beta.4

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 (31) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +4 -4
  4. package/dist/constants-p-2dR2AN.mjs +2 -0
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-DCHFtME7.mjs +1 -0
  7. package/dist/{init-CXjQX8-1.mjs → init-fd_VtUs7.mjs} +3 -3
  8. package/dist/loader-D2Q78EfO.mjs +1 -0
  9. package/dist/{loader-9fT71FVx.mjs → loader-DpyOxoJc.mjs} +2 -2
  10. package/dist/preview-BTTkTrGz.mjs +1 -0
  11. package/dist/{preview-DdehS5d6.mjs → preview-DRZYfkXb.mjs} +2 -2
  12. package/dist/public/assets/{ActivityModeContent-CbQoJ1SW.js → ActivityModeContent-DNScR_Nz.js} +1 -1
  13. package/dist/public/assets/{DocumentContext-jPQKJEkK.js → DocumentContext-CpQaYjLs.js} +1 -1
  14. package/dist/public/assets/{SettingsDialogBody-Cw_kkFEU.js → SettingsDialogBody-CK1XT5BG.js} +1 -1
  15. package/dist/public/assets/{SourceEditor-uEN9i8aI.js → SourceEditor-Ccg-iggu.js} +1 -1
  16. package/dist/public/assets/{config-validation-events-BP50peuP.js → config-validation-events-A4otVJAb.js} +1 -1
  17. package/dist/public/assets/{index-C42VDZsx.css → index-CXzfIokG.css} +1 -1
  18. package/dist/public/assets/{index-CKRJlK5a.js → index-Cwgd9r-l.js} +5 -5
  19. package/dist/public/assets/{typing-burst-detector-D7T5I1jy.js → typing-burst-detector-Dx7uk1xf.js} +1 -1
  20. package/dist/public/index.html +5 -5
  21. package/dist/{repair-launch-json-PSwvlx07.mjs → repair-launch-json-DfvpbbeN.mjs} +2 -2
  22. package/dist/{repair-mcp-configs-DONl4Wrs.mjs → repair-mcp-configs-58KuFzhZ.mjs} +2 -2
  23. package/dist/{src-B0NgArNO.mjs → src-BTk7vkCB.mjs} +2 -2
  24. package/dist/{start-BWgaTNGv.mjs → start-DVb7oD_J.mjs} +2 -2
  25. package/dist/start-s_YNUCK2.mjs +1 -0
  26. package/package.json +1 -1
  27. package/dist/constants-DNaw7K30.mjs +0 -2
  28. package/dist/init-6hVPbbKh.mjs +0 -1
  29. package/dist/loader-DsfL6g1c.mjs +0 -1
  30. package/dist/preview-mSapG-Vl.mjs +0 -1
  31. package/dist/start-Bbl6xJiP.mjs +0 -1
@@ -3,7 +3,7 @@ import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2e
3
3
  `)}},Sf=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Md]?Nd(e,t):Gl(e)?Hl(e,e=>Ul(t,t=>Sf(e,t))):Pd(e)?Bd(e,(e,n)=>Sf(e,t[n])):!1,Cf=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Sf(t,n)}equals(e){return this.constructor===e.constructor&&qd(this.shape,e.shape)}[bf](){return!0}[Md](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){td()}get nullable(){return np(this,_p)}get optional(){return new Pf(this)}cast(e){return xp(e,this),e}expect(e){return xp(e,this),e}},wf=class extends Cf{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let 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?`Check failed`:`Constructor match failed`),n}},Tf=(e,t=null)=>new wf(e,t);Tf(wf);var Ef=class extends Cf{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Df=e=>new Ef(e);Tf(Ef);var Of=class extends Cf{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},kf=(...e)=>new Of(e),Af=Tf(Of),jf=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Mf=e=>{if(fp.check(e))return[jf(e)];if(Af.check(e))return e.shape.map(e=>e+``);if(dp.check(e))return[`[+-]?\\d+.?\\d*`];if(pp.check(e))return[`.*`];if(rp.check(e))return e.shape.map(Mf).flat(1);nd()};Tf(class extends Cf{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Mf).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Nf=Symbol(`optional`),Pf=class extends Cf{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Nf](){return!0}},Ff=Tf(Pf),If=class extends Cf{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new If,Tf(If);var Lf=class e extends Cf{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Bd(this.shape,(n,r)=>{let i=this._isPartial&&!Vd(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Rf=e=>new Lf(e),zf=Tf(Lf),Bf=Df(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Vf=class extends Cf{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Bd(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Hf=(e,t)=>new Vf(e,t),Uf=Tf(Vf),Wf=class extends Cf{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Bd(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Gf=(...e)=>new Wf(e);Tf(Wf);var Kf=class extends Cf{constructor(e){super(),this.shape=e.length===1?e[0]:new tp(e)}check(e,t){let n=Gl(e)&&Hl(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},qf=(...e)=>new Kf(e),Jf=Tf(Kf),Yf=Df(e=>Gl(e)),Xf=class extends Cf{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},Zf=(e,t=null)=>new Xf(e,t);Tf(Xf);var Qf=Zf(Cf),$f=Tf(class extends Cf{constructor(e){super(),this.len=e.length-1,this.args=Gf(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),ep=Df(e=>typeof e==`function`);Tf(class extends Cf{constructor(e){super(),this.shape=e}check(e,t){let n=Hl(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var tp=class extends Cf{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Ul(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},np=(...e)=>e.findIndex(e=>rp.check(e))>=0?np(...e.map(e=>bp(e)).map(e=>rp.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new tp(e),rp=Tf(tp),ip=()=>!0,ap=Df(ip),op=Tf(Ef,e=>e.shape===ip),sp=Df(e=>typeof e==`bigint`),cp=Df(e=>e===sp),lp=Df(e=>typeof e==`symbol`);Df(e=>e===lp);var up=Df(e=>typeof e==`number`),dp=Df(e=>e===up),fp=Df(e=>typeof e==`string`),pp=Df(e=>e===fp),mp=Df(e=>typeof e==`boolean`),hp=Df(e=>e===mp),gp=kf(void 0);Tf(Of,e=>e.shape.length===1&&e.shape[0]===void 0),kf(void 0);var _p=kf(null),vp=Tf(Of,e=>e.shape.length===1&&e.shape[0]===null);Tf(Uint8Array),Tf(wf,e=>e.shape===Uint8Array);var yp=np(up,fp,_p,gp,sp,mp,lp);(()=>{let e=qf(ap),t=Hf(fp,ap),n=np(up,fp,_p,mp,e,t);return e.shape=n,t.shape.values=n,n})();var bp=e=>{if(Qf.check(e))return e;if(Bf.check(e)){let t={};for(let n in e)t[n]=bp(e[n]);return Rf(t)}else if(Yf.check(e))return np(...e.map(bp));else if(yp.check(e))return kf(e);else if(ep.check(e))return Tf(e);nd()},xp=rf?()=>{}:(e,t)=>{let n=new xf;if(!t.check(e,n))throw ed(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Sp=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:bp(e),h:t}),this}else(e){return this.if(ap,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw ed(`Unhandled pattern`)}}},Cp=(e=>new Sp(e))(ap).if(dp,(e,t)=>mf(t,pu,fu)).if(pp,(e,t)=>vf(t)).if(hp,(e,t)=>pf(t)).if(cp,(e,t)=>BigInt(mf(t,pu,fu))).if(rp,(e,t)=>wp(t,yf(t,e.shape))).if(zf,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Ff.check(i)){if(pf(t))continue;i=i.shape}n[r]=Cp(i,t)}return n}).if(Jf,(e,t)=>{let n=[],r=hf(t,0,42);for(let i=0;i<r;i++)n.push(wp(t,e.shape));return n}).if(Af,(e,t)=>yf(t,e.shape)).if(vp,(e,t)=>null).if($f,(e,t)=>{let n=wp(t,e.res);return()=>n}).if(op,(e,t)=>wp(t,yf(t,[up,fp,_p,gp,sp,mp,qf(up),Hf(np(`a`,`b`,`c`),up)]))).if(Uf,(e,t)=>{let n={},r=mf(t,0,3);for(let i=0;i<r;i++){let r=wp(t,e.shape.keys);n[r]=wp(t,e.shape.values)}return n}).done(),wp=(e,t)=>Cp(bp(t),e),Tp=typeof document<`u`?document:{},Ep=e=>Tp.createElement(e),Dp=()=>Tp.createDocumentFragment();Df(e=>e.nodeType===zp);var Op=e=>Tp.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var kp=(e,t)=>(ff(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Ap=e=>{let t=Dp();for(let n=0;n<e.length;n++)Fp(t,e[n]);return t},jp=(e,t)=>(Fp(e,Ap(t)),e),Mp=(e,t=[],n=[])=>jp(kp(Ep(e),t),n);Df(e=>e.nodeType===Ip);var Np=Op;Df(e=>e.nodeType===Lp);var Pp=e=>Il(e,(e,t)=>`${t}:${e};`).join(``),Fp=(e,t)=>e.appendChild(t),Ip=Tp.ELEMENT_NODE,Lp=Tp.TEXT_NODE;Tp.CDATA_SECTION_NODE,Tp.COMMENT_NODE;var Rp=Tp.DOCUMENT_NODE;Tp.DOCUMENT_TYPE_NODE;var zp=Tp.DOCUMENT_FRAGMENT_NODE;Df(e=>e.nodeType===Rp);var Bp=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Vp=(e,t)=>new Bp(setTimeout(t,e)),Hp=Symbol,Up=Hp(),Wp=Hp(),Gp=Hp(),Kp=Hp(),qp=Hp(),Jp=Hp(),Yp=Hp(),Xp=Hp(),Zp=Hp(),Qp=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Dd();var $p={[Up]:df(`font-weight`,`bold`),[Wp]:df(`font-weight`,`normal`),[Gp]:df(`color`,`blue`),[qp]:df(`color`,`green`),[Kp]:df(`color`,`grey`),[Jp]:df(`color`,`red`),[Yp]:df(`color`,`purple`),[Xp]:df(`color`,`orange`),[Zp]:df(`color`,`black`)},em=af?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Nl(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=$p[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Pp(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:Qp,tm=(...e)=>{console.log(...em(e)),rm.forEach(t=>t.print(e))},nm=(...e)=>{console.warn(...em(e)),e.unshift(Xp),rm.forEach(t=>t.print(e))},rm=Rl(),im=e=>({[Symbol.iterator](){return this},next:e}),am=(e,t)=>im(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),om=(e,t)=>im(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),sm=class{constructor(e,t){this.clock=e,this.len=t}},cm=class{constructor(){this.clients=new Map}},lm=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Oh(e,i,o.clock,o.len,n)}}),um=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Jl((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},dm=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&um(n,t.clock)!==null},fm=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new sm(r.clock,Zl(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},pm=e=>{let t=new cm;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Bl(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return fm(t),t},mm=(e,t,n,r)=>{Fl(e.clients,t,()=>[]).push(new sm(n,r))},hm=()=>new cm,gm=e=>{let t=hm();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new sm(i,a))}}r.length>0&&t.clients.set(n,r)}),t},_m=(e,t)=>{Pu(e.restEncoder,t.clients.size),Vl(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Pu(e.restEncoder,t);let r=n.length;Pu(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},vm=e=>{let t=new cm,n=dd(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=dd(e.restDecoder),r=dd(e.restDecoder);if(r>0){let i=Fl(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new sm(e.readDsClock(),e.readDsLen()))}}return t},ym=(e,t,n)=>{let r=new cm,i=dd(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=dd(e.restDecoder),a=dd(e.restDecoder),o=n.clients.get(i)||[],s=bh(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&mm(r,i,s,a-s);let e=Sh(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,G_(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,G_(t,c,a-c.id.clock)),c.delete(t))}else mm(r,i,n,a-n)}}if(r.clients.size>0){let e=new km;return Pu(e.restEncoder,0),_m(e,r),e.toUint8Array()}return null},bm=Cd,xm=class e extends Kl{constructor({guid:e=Ed(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=bm(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new vh,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Od(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Od(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Ih(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Vl(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Ih(this,e,t)}get(e,t=fg){let n=Fl(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==fg&&r!==t)if(r===fg){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,Ng)}getText(e=``){return this.get(e,e_)}getMap(e=``){return this.get(e,Ig)}getXmlElement(e=``){return this.get(e,a_)}getXmlFragment(e=``){return this.get(e,r_)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Vl(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Ih(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Sm=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return dd(this.restDecoder)}readDsLen(){return dd(this.restDecoder)}},Cm=class extends Sm{readLeftID(){return eh(dd(this.restDecoder),dd(this.restDecoder))}readRightID(){return eh(dd(this.restDecoder),dd(this.restDecoder))}readClient(){return dd(this.restDecoder)}readInfo(){return ud(this.restDecoder)}readString(){return pd(this.restDecoder)}readParentInfo(){return dd(this.restDecoder)===1}readTypeRef(){return dd(this.restDecoder)}readLen(){return dd(this.restDecoder)}readAny(){return gd(this.restDecoder)}readBuf(){return cf(ld(this.restDecoder))}readJSON(){return JSON.parse(pd(this.restDecoder))}readKey(){return pd(this.restDecoder)}},wm=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=dd(this.restDecoder),this.dsCurrVal}readDsLen(){let e=dd(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Tm=class extends wm{constructor(e){super(e),this.keys=[],dd(e),this.keyClockDecoder=new yd(ld(e)),this.clientDecoder=new vd(ld(e)),this.leftClockDecoder=new yd(ld(e)),this.rightClockDecoder=new yd(ld(e)),this.infoDecoder=new _d(ld(e),ud),this.stringDecoder=new bd(ld(e)),this.parentInfoDecoder=new _d(ld(e),ud),this.typeRefDecoder=new vd(ld(e)),this.lenDecoder=new vd(ld(e))}readLeftID(){return new Qm(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Qm(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 gd(this.restDecoder)}readBuf(){return ld(this.restDecoder)}readJSON(){return gd(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Em=class{constructor(){this.restEncoder=Du()}toUint8Array(){return Au(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Pu(this.restEncoder,e)}writeDsLen(e){Pu(this.restEncoder,e)}},Dm=class extends Em{writeLeftID(e){Pu(this.restEncoder,e.client),Pu(this.restEncoder,e.clock)}writeRightID(e){Pu(this.restEncoder,e.client),Pu(this.restEncoder,e.clock)}writeClient(e){Pu(this.restEncoder,e)}writeInfo(e){Nu(this.restEncoder,e)}writeString(e){Ru(this.restEncoder,e)}writeParentInfo(e){Pu(this.restEncoder,+!!e)}writeTypeRef(e){Pu(this.restEncoder,e)}writeLen(e){Pu(this.restEncoder,e)}writeAny(e){qu(this.restEncoder,e)}writeBuf(e){Bu(this.restEncoder,e)}writeJSON(e){Ru(this.restEncoder,JSON.stringify(e))}writeKey(e){Ru(this.restEncoder,e)}},Om=class{constructor(){this.restEncoder=Du(),this.dsCurrVal=0}toUint8Array(){return Au(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Pu(this.restEncoder,t)}writeDsLen(e){e===0&&nd(),Pu(this.restEncoder,e-1),this.dsCurrVal+=e}},km=class extends Om{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Qu,this.clientEncoder=new Xu,this.leftClockEncoder=new Qu,this.rightClockEncoder=new Qu,this.infoEncoder=new Ju(Nu),this.stringEncoder=new $u,this.parentInfoEncoder=new Ju(Nu),this.typeRefEncoder=new Xu,this.lenEncoder=new Xu}toUint8Array(){let e=Du();return Pu(e,0),Bu(e,this.keyClockEncoder.toUint8Array()),Bu(e,this.clientEncoder.toUint8Array()),Bu(e,this.leftClockEncoder.toUint8Array()),Bu(e,this.rightClockEncoder.toUint8Array()),Bu(e,Au(this.infoEncoder)),Bu(e,this.stringEncoder.toUint8Array()),Bu(e,Au(this.parentInfoEncoder)),Bu(e,this.typeRefEncoder.toUint8Array()),Bu(e,this.lenEncoder.toUint8Array()),zu(e,Au(this.restEncoder)),Au(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){qu(this.restEncoder,e)}writeBuf(e){Bu(this.restEncoder,e)}writeJSON(e){qu(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Am=(e,t,n,r)=>{r=Zl(r,t[0].id.clock);let i=Sh(t,r);Pu(e.restEncoder,t.length-i),e.writeClient(n),Pu(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},jm=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{bh(t,n)>e&&r.set(n,e)}),yh(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Pu(e.restEncoder,r.size),Vl(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Am(e,t.clients.get(n),n,r)})},Mm=(e,t)=>{let n=Nl(),r=dd(e.restDecoder);for(let i=0;i<r;i++){let r=dd(e.restDecoder),i=Array(r),a=e.readClient(),o=dd(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new m_(eh(a,o),t),o+=t;break}case 10:{let t=dd(e.restDecoder);i[n]=new Q_(eh(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J_(eh(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Y_(e,r));i[n]=c,o+=c.length}}}}return n},Nm=(e,t,n)=>{let r=[],i=Vl(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new vh,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Q_){let i=Fl(d,u.id.client,()=>bh(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,bh(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new km;return jm(e,s,new Map),Pu(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Pm=(e,t)=>jm(e,t.doc.store,t.beforeState),Fm=(e,t,n,r=new Tm(e))=>Ih(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Nm(e,i,Mm(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<bh(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Kh([o.update,a.update])}}else i.pendingStructs=a;let s=ym(r,e,i);if(i.pendingDs){let t=new Tm(od(i.pendingDs));dd(t.restDecoder);let n=ym(t,e,i);s&&n?i.pendingDs=Kh([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Im(e.doc,t)}},n,!1),Im=(e,t,n,r=Tm)=>{let i=od(t);Fm(i,e,n,new r(i))},Lm=(e,t,n)=>Im(e,t,n,Cm),Rm=(e,t,n=new Map)=>{jm(e,t.store,n),_m(e,gm(t.store))},zm=(e,t=new Uint8Array([0]),n=new km)=>{Rm(n,e,Hm(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(qh(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Dm)return Wh(r.map((e,t)=>t===0?e:Qh(e)));if(n.constructor===km)return Kh(r)}return r[0]},Bm=(e,t)=>zm(e,t,new Dm),Vm=e=>{let t=new Map,n=dd(e.restDecoder);for(let r=0;r<n;r++){let n=dd(e.restDecoder),r=dd(e.restDecoder);t.set(n,r)}return t},Hm=e=>Vm(new Sm(od(e))),Um=(e,t)=>(Pu(e.restEncoder,t.size),Vl(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Pu(e.restEncoder,t),Pu(e.restEncoder,n)}),e),Wm=(e,t)=>Um(e,yh(t.store)),Gm=(e,t=new Om)=>(e instanceof Map?Um(t,e):Wm(t,e),t.toUint8Array()),Km=e=>Gm(e,new Em),qm=class{constructor(){this.l=[]}},Jm=()=>new qm,Ym=(e,t)=>e.l.push(t),Xm=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Zm=(e,t,n)=>Gd(e.l,[t,n]),Qm=class{constructor(e,t){this.client=e,this.clock=t}},$m=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,eh=(e,t)=>new Qm(e,t),th=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw nd()},nh=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},rh=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ih=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},ah=e=>new rh(e.type==null?null:eh(e.type.client,e.type.clock),e.tname??null,e.item==null?null:eh(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),oh=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},sh=(e,t,n=0)=>new oh(e,t,n),ch=(e,t,n)=>{let r=null,i=null;return e._item===null?i=th(e):r=eh(e._item.id.client,e._item.id.clock),new rh(r,i,t,n)},lh=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ch(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ch(e,eh(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ch(e,r.lastId,n);r=r.right}return ch(e,null,n)},uh=(e,t)=>{let n=Ch(e,t);return{item:n,diff:t.clock-n.id.clock}},dh=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(bh(r,i.client)<=i.clock)return null;let e=n?U_(r,i):uh(r,i),t=e.item;if(!(t instanceof J_))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(bh(r,a.client)<=a.clock)return null;let{item:e}=n?U_(r,a):{item:Ch(r,a)};if(e instanceof J_&&e.content instanceof V_)c=e.content.type;else return null}else throw nd();l=s>=0?c._length:0}return sh(c,l,e.assoc)},fh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&$m(e.item,t.item)&&$m(e.type,t.type)&&e.assoc===t.assoc,ph=class{constructor(e,t){this.ds=e,this.sv=t}},mh=(e,t)=>new ph(e,t);mh(hm(),new Map);var hh=e=>mh(gm(e.store),yh(e.store)),gh=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!dm(t.ds,e.id),_h=(e,t)=>{let n=Fl(e.meta,_h,Rl),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<bh(r,n)&&Th(e,eh(n,t))}),lm(e,t.ds,e=>{}),n.add(t))},vh=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},yh=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},bh=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},xh=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw nd()}n.push(t)},Sh=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Jl(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=Jl((n+r)/2)}throw nd()},Ch=(e,t)=>{let n=e.clients.get(t.client);return n[Sh(n,t.clock)]},wh=(e,t,n)=>{let r=Sh(t,n),i=t[r];return i.id.clock<n&&i instanceof J_?(t.splice(r+1,0,G_(e,i,n-i.id.clock)),r+1):r},Th=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[wh(e,n,t.clock)]},Eh=(e,t,n)=>{let r=t.clients.get(n.client),i=Sh(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==m_&&r.splice(i+1,0,G_(e,a,n.clock-a.id.clock+1)),a},Dh=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Sh(r,t.id.clock)]=n},Oh=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=wh(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&wh(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},kh=class{constructor(e,t,n){this.doc=e,this.deleteSet=new cm,this.beforeState=yh(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}},Ah=(e,t)=>t.deleteSet.clients.size===0&&!Ll(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(fm(t.deleteSet),Pm(e,t),_m(e,t.deleteSet),!0),jh=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Fl(e.changed,t,Rl).add(n)},Mh=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J_&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Nh=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Sh(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J_&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ph=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=Xl(r.length-1,1+Sh(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Mh(r,e)}})},Fh=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{fm(a),n.afterState=yh(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Zm(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Zg(n)})}),Gd(e,[])}finally{r.gc&&Nh(a,i,r.gcFilter),Ph(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Zl(Sh(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Mh(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Sh(r,n);a+1<r.length&&Mh(r,a+1)>1||a>0&&Mh(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(tm(Xp,Up,`[yjs] `,Wp,Jp,`Changed the client-id because another client seems to be using it.`),r.clientID=bm()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Dm;Ah(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new km;Ah(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Fh(e,t+1)}}},Ih=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new kh(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Fh(i,0)}}return o},Lh=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Rh=(e,t,n)=>{lm(e,n.deletions,n=>{n instanceof J_&&t.scope.some(t=>t===e.doc||nh(t,n))&&W_(n,!1)})},zh=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Ih(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;lm(n,o.insertions,e=>{if(e instanceof J_){if(e.redone!==null){let{item:t,diff:i}=U_(r,e.id);i>0&&(t=Th(n,eh(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||nh(t,e))&&c.push(e)}}),lm(n,o.deletions,e=>{e instanceof J_&&a.some(t=>t===n.doc||nh(t,e))&&!dm(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=q_(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Bh=class extends Kl{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Gl(e)?e[0].doc:e instanceof xm?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new cm;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&mm(i,n,r,a)});let a=Dd(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=pm([t.deletions,e.deleteSet]),t.insertions=pm([t.insertions,i])}else r.push(new Lh(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),lm(e,e.deleteSet,t=>{t instanceof J_&&this.scope.some(n=>n===e.doc||nh(n,t))&&W_(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=Gl(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof fg?e.doc!==this.doc:e!==this.doc)&&nm(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}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(e=>Rh(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Rh(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=zh(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=zh(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*Vh(e){let t=dd(e.restDecoder);for(let n=0;n<t;n++){let t=dd(e.restDecoder),n=e.readClient(),r=dd(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=dd(e.restDecoder);yield new Q_(eh(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J_(eh(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Y_(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new m_(eh(n,r),t),r+=t}}}}var Hh=class{constructor(e,t){this.gen=Vh(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===Q_);return this.curr}},Uh=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Wh=e=>Kh(e,Cm,Dm),Gh=(e,t)=>{if(e.constructor===m_){let{client:n,clock:r}=e.id;return new m_(eh(n,r+t),e.length-t)}else if(e.constructor===Q_){let{client:n,clock:r}=e.id;return new Q_(eh(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J_(eh(r,i+t),null,eh(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Kh=(e,t=Tm,n=km)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(od(e))),i=r.map(e=>new Hh(e,!0)),a=null,o=new n,s=new Uh(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Q_?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Yh(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Q_)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Yh(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Q_(eh(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Q_?a.struct.length-=t:n=Gh(n,t)),a.struct.mergeWith(n)||(Yh(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Q_;n=e.next())Yh(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Yh(s,a.struct,a.offset),a=null),Xh(s),_m(o,pm(r.map(e=>vm(e)))),o.toUint8Array()},qh=(e,t,n=Tm,r=km)=>{let i=Hm(t),a=new r,o=new Uh(a),s=new n(od(e)),c=new Hh(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Q_){c.next();continue}if(e.id.clock+e.length>n)for(Yh(o,e,Zl(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Yh(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Xh(o),_m(a,vm(s)),a.toUint8Array()},Jh=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Au(e.encoder.restEncoder)}),e.encoder.restEncoder=Du(),e.written=0)},Yh=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Jh(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Pu(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Xh=e=>{Jh(e);let t=e.encoder.restEncoder;Pu(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Pu(t,r.written),zu(t,r.restEncoder)}},Zh=(e,t,n,r)=>{let i=new n(od(e)),a=new Hh(i,!1),o=new r,s=new Uh(o);for(let e=a.curr;e!==null;e=a.next())Yh(s,t(e),0);return Xh(s),_m(o,vm(i)),o.toUint8Array()},Qh=e=>Zh(e,Kd,Tm,Dm),$h=`You must not compute changes after the event-handler fired.`,eg=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||=tg(this.currentTarget,this.target)}deletes(e){return dm(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ed($h);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=zl(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=zl(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=zl(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),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 ed($h);let t=this.target,n=Rl(),r=Rl(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},tg=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},ng=()=>{nm(`Invalid access: Add Yjs type to a document before reading data.`)},rg=80,ig=0,ag=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ig++}},og=e=>{e.timestamp=ig++},sg=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ig++},cg=(e,t,n)=>{if(e.length>=rg){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return sg(r,t,n),r}else{let r=new ag(t,n);return e.push(r),r}},lg=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>Yl(t-e.index)<Yl(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,og(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Yl(n.index-i)<r.parent.length/rg?(sg(n,r,i),n):cg(e._searchMarker,r,i)},ug=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Zl(t,i.index+n))}},dg=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Fl(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Zm(r._eH,n,t)},fg=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Jm(),this._dEH=Jm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw td()}clone(){throw td()}_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){Ym(this._eH,e)}observeDeep(e){Ym(this._dEH,e)}unobserve(e){Xm(this._eH,e)}unobserveDeep(e){Xm(this._dEH,e)}toJSON(){}},pg=(e,t,n)=>{e.doc??ng(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},mg=e=>{e.doc??ng();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},hg=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&gh(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},gg=(e,t)=>{let n=0,r=e._start;for(e.doc??ng();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},_g=(e,t)=>{let n=[];return gg(e,(r,i)=>{n.push(t(r,i,e))}),n},vg=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}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},yg=(e,t)=>{e.doc??ng();let n=lg(e,t),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}},bg=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J_(eh(o,bh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new k_(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J_(eh(o,bh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new h_(new Uint8Array(n))),i.integrate(e,0);break;case xm:i=new J_(eh(o,bh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new b_(n)),i.integrate(e,0);break;default:if(n instanceof fg)i=new J_(eh(o,bh(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new V_(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},xg=()=>ed(`Length exceeded!`),Sg=(e,t,n,r)=>{if(n>t._length)throw xg();if(n===0)return t._searchMarker&&ug(t._searchMarker,n,r.length),bg(e,t,null,r);let i=n,a=lg(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Th(e,eh(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&ug(t._searchMarker,i,r.length),bg(e,t,o,r)},Cg=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return bg(e,t,r,n)},wg=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=lg(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Th(e,eh(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Th(e,eh(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw xg();t._searchMarker&&ug(t._searchMarker,i,-a+r)},Tg=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Eg=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new k_([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new k_([r]);break;case Uint8Array:s=new h_(r);break;case xm:s=new b_(r);break;default:if(r instanceof fg)s=new V_(r);else throw Error(`Unexpected content type`)}new J_(eh(o,bh(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Dg=(e,t)=>{e.doc??ng();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Og=e=>{let t={};return e.doc??ng(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},kg=(e,t)=>{e.doc??ng();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ag=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&gh(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},jg=e=>(e.doc??ng(),am(e._map.entries(),e=>!e[1].deleted)),Mg=class extends eg{},Ng=class e extends fg{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof fg?e.clone():e)),t}get length(){return this.doc??ng(),this._length}_callObserver(e,t){super._callObserver(e,t),dg(this,e,new Mg(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ih(this.doc,n=>{Sg(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Ih(this.doc,t=>{Cg(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ih(this.doc,n=>{wg(n,this,e,t)})}get(e){return yg(this,e)}toArray(){return mg(this)}slice(e=0,t=this.length){return pg(this,e,t)}toJSON(){return this.map(e=>e instanceof fg?e.toJSON():e)}map(e){return _g(this,e)}forEach(e){gg(this,e)}[Symbol.iterator](){return vg(this)}_write(e){e.writeTypeRef(P_)}},Pg=e=>new Ng,Fg=class extends eg{constructor(e,t,n){super(e,t),this.keysChanged=n}},Ig=class e extends fg{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof fg?e.clone():e)}),t}_callObserver(e,t){dg(this,e,new Fg(this,e,t))}toJSON(){this.doc??ng();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof fg?r.toJSON():r}}),e}get size(){return[...jg(this)].length}keys(){return om(jg(this),e=>e[0])}values(){return om(jg(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return om(jg(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ng(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Ih(this.doc,t=>{Tg(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Ih(this.doc,n=>{Eg(n,this,e,t)}),t}get(e){return Dg(this,e)}has(e){return kg(this,e)}clear(){this.doc===null?this._prelimContent.clear():Ih(this.doc,e=>{this.forEach(function(t,n,r){Tg(e,r,n)})})}_write(e){e.writeTypeRef(F_)}},Lg=e=>new Ig,Rg=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Hd(e,t),zg=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&nd(),this.right.content.constructor){case w_:this.right.deleted||Ug(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},Bg=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case w_:t.right.deleted||Ug(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Th(e,eh(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Vg=(e,t,n,r)=>{let i=new Map,a=r?lg(t,n):null;return a?Bg(e,new zg(a.p.left,a.p,a.index,i),n-a.index):Bg(e,new zg(null,t._start,0,i),n)},Hg=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===w_&&Rg(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J_(eh(a,bh(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new w_(o,r));l.integrate(e,0),n.right=l,n.forward()})},Ug=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Wg=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===w_&&Rg(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Gg=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Rg(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J_(eh(a,bh(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new w_(s,c)),n.right.integrate(e,0),n.forward()}}return o},Kg=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Wg(n,i);let s=Gg(e,t,n,i),c=r.constructor===String?new j_(r):r instanceof fg?new V_(r):new S_(r),{left:l,right:u,index:d}=n;t._searchMarker&&ug(t._searchMarker,n.index,c.getLength()),u=new J_(eh(o,bh(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Hg(e,t,n,s)},qg=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Wg(n,i);let s=Gg(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===w_));){if(!n.right.deleted)switch(n.right.content.constructor){case w_:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Rg(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Th(e,eh(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
4
4
  `;n.right=new J_(eh(o,bh(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new j_(i)),n.right.integrate(e,0),n.forward()}Hg(e,t,n,s)},Jg=(e,t,n,r,i)=>{let a=t,o=Nl();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===w_){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case w_:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Ug(i,n);break}}}t=t.right}return s},Yg=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===w_){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Xg=e=>{let t=0;return Ih(e.doc,n=>{let r=e._start,i=e._start,a=Nl(),o=Pl(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case w_:Ug(o,i.content);break;default:t+=Jg(n,r,i,a,o),a=Pl(o),r=i;break}i=i.right}}),t},Zg=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Oh(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===w_&&e.constructor!==m_&&t.add(e.parent)})}Ih(n,n=>{lm(e,e.deleteSet,e=>{if(e instanceof m_||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===w_?t.add(r):Yg(n,e)});for(let e of t)Xg(e)})},Qg=(e,t,n)=>{let r=n,i=Pl(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case V_:case S_:case j_:n<t.right.length&&Th(e,eh(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Jg(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&ug(o._searchMarker,t.index,-r+n),t},$g=class extends eg{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}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){let e=this.target.doc,t=[];Ih(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},zd(o)||(e.attributes=Fd({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case V_:case S_:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case j_:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case w_:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Rg(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Rg(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Rg(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Rg(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Ug(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},e_=class e extends fg{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ng(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new $g(this,e,t);dg(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ng();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===j_&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Ih(this.doc,n=>{let r=new zg(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
5
5
  `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Kg(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Qg(n,r,a.delete):qg(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??ng();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(gh(s,e)||t!==void 0&&gh(s,t))switch(s.content.constructor){case j_:{let r=i.get(`ychange`);e!==void 0&&!gh(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!gh(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case V_:case S_:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case w_:gh(s,e)&&(c(),Ug(i,s.content));break}s=s.right}c()};return e||t?Ih(a,n=>{e&&_h(n,e),t&&_h(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Ih(r,r=>{let i=Vg(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Kg(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Ih(r,r=>{let i=Vg(r,this,e,!n);Kg(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Ih(n,n=>{Qg(n,Vg(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Ih(r,r=>{let i=Vg(r,this,e,!1);i.right!==null&&qg(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Ih(this.doc,t=>{Tg(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Ih(this.doc,n=>{Eg(n,this,e,t)})}getAttribute(e){return Dg(this,e)}getAttributes(){return Og(this)}_write(e){e.writeTypeRef(I_)}},t_=e=>new e_,n_=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ng()}[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===a_||t.constructor===r_)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},r_=class e extends fg{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof fg?e.clone():e)),t}get length(){return this.doc??ng(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new n_(this,e)}querySelector(e){e=e.toUpperCase();let t=new n_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Vl(new n_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){dg(this,e,new s_(this,t,e))}toString(){return _g(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),gg(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ih(this.doc,n=>{Sg(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Ih(this.doc,n=>{let r=e&&e instanceof fg?e._item:e;bg(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw ed(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ih(this.doc,n=>{wg(n,this,e,t)})}toArray(){return mg(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yg(this,e)}slice(e=0,t=this.length){return pg(this,e,t)}forEach(e){gg(this,e)}_write(e){e.writeTypeRef(R_)}},i_=e=>new r_,a_=class e extends r_{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Ld(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof fg?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Ih(this.doc,t=>{Tg(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Ih(this.doc,n=>{Eg(n,this,e,t)})}getAttribute(e){return Dg(this,e)}hasAttribute(e){return kg(this,e)}getAttributes(e){return e?Ag(this,e):Og(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return gg(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(L_),e.writeKey(this.nodeName)}},o_=e=>new a_(e.readKey()),s_=class extends eg{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},c_=class e extends Ig{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(z_),e.writeKey(this.hookName)}},l_=e=>new c_(e.readKey()),u_=class e extends e_{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(B_)}},d_=e=>new u_,f_=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw td()}mergeWith(e){return!1}write(e,t,n){throw td()}integrate(e,t){throw td()}},p_=0,m_=class extends f_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),xh(e.doc.store,this)}write(e,t){e.writeInfo(p_),e.writeLen(this.length-t)}getMissing(e,t){return null}},h_=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw td()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},g_=e=>new h_(e.readBuf()),__=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){mm(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},v_=e=>new __(e.readLen()),y_=(e,t)=>new xm({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),b_=class e{constructor(e){e._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=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(y_(this.doc.guid,this.opts))}splice(e){throw td()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},x_=e=>new b_(y_(e.readString(),e.readAny())),S_=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw td()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},C_=e=>new S_(e.readJSON()),w_=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw td()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},T_=e=>new w_(e.readKey(),e.readJSON()),E_=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},D_=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new E_(n)},O_=tf(`node_env`)===`development`,k_=class e{constructor(e){this.arr=e,O_&&Wd(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},A_=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new k_(n)},j_=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let 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(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},M_=e=>new j_(e.readString()),N_=[Pg,Lg,t_,o_,i_,l_,d_],P_=0,F_=1,I_=2,L_=3,R_=4,z_=5,B_=6,V_=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw td()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},H_=e=>new V_(N_[e.readTypeRef()](e)),U_=(e,t)=>{let n=t,r=0,i;do r>0&&(n=eh(n.client,n.clock+r)),i=Ch(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J_);return{item:i,diff:r}},W_=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},G_=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J_(eh(r,i+n),t,eh(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=eh(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},K_=(e,t)=>Ul(e,e=>dm(e.deletions,t)),q_=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Th(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||q_(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Th(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Th(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Th(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||dm(r,d.right.id)||K_(a.undoStack,d.right.id)||K_(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Th(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=eh(c,bh(s,c)),h=new J_(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,W_(h,!0),h.integrate(e,0),h},J_=class e extends f_{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bh(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bh(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Qm&&this.id.client!==this.parent.client&&this.parent.clock>=bh(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Eh(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Th(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===m_||this.right&&this.right.constructor===m_)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Qm){let e=Ch(n,this.parent);e.constructor===m_?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Eh(e,e.doc.store,eh(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),$m(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if($m(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ch(e.doc.store,n.origin)))r.has(Ch(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),xh(e.doc.store,this),this.content.integrate(e,this),jh(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new m_(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:eh(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&$m(e.origin,this.lastId)&&this.right===e&&$m(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),mm(e.deleteSet,this.id.client,this.id.clock,this.length),jh(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw nd();this.content.gc(e),t?Dh(e,this,new m_(this.id,this.length)):this.content=new __(this.length)}write(e,t){let n=t>0?eh(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=th(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===Qm?(e.writeParentInfo(!1),e.writeLeftID(t)):nd();i!==null&&e.writeString(i)}this.content.write(e,t)}},Y_=(e,t)=>X_[t&31](e),X_=[()=>{nd()},v_,D_,g_,M_,C_,T_,H_,A_,x_,()=>{nd()}],Z_=10,Q_=class extends f_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){nd()}write(e,t){e.writeInfo(Z_),Pu(e.restEncoder,this.length-t)}getMissing(e,t){return null}},$_=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},ev=`__ $YJS$ __`;$_[ev]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),$_[ev]=!0;var tv=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},nv=/[\uD800-\uDBFF]/,rv=/[\uDC00-\uDFFF]/,iv=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&nv.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&rv.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},av=(e,t)=>e>>>t|e<<32-t,ov=e=>av(e,2)^av(e,13)^av(e,22),sv=e=>av(e,6)^av(e,11)^av(e,25),cv=e=>av(e,7)^av(e,18)^e>>>3,lv=e=>av(e,17)^av(e,19)^e>>>10,uv=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),dv=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fv=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(dv),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=lv(t[e-2])+t[e-7]+cv(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+sv(o)+(o&s^~o&c)+uv[e]+t[e]>>>0,d=ov(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/du,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},pv=e=>new fv().digest(e),mv=new W(`y-sync`),hv=new W(`y-undo`),gv=new W(`yjs-cursor`),_v=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},vv=e=>sf(_v(pv(lf(e)))),yv=()=>({mapping:new Map,isOMark:new Map}),bv=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!dm(t.ds,e.id),xv=[{light:`#ecd44433`,dark:`#ecd444`}],Sv=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=Rl();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,wd(t))}return e.get(n)},Cv=(e,{colors:t=xv,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Dv(e,a),c=new Oe({props:{editable:e=>{let t=mv.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:mv,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(mv);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&Vp(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=hv.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},mv)})}},destroy:()=>{s.destroy()}})});return c},wv=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new Pt(e.doc));else if(t.type===`node`){let r=ny(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Tv(e,r))}else{let r=ny(n.doc,n.type,t.anchor,n.mapping),i=ny(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(s.between(e.doc.resolve(r),e.doc.resolve(i)))}},Tv=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?j.create(e.doc,t):s.near(n)},Ev=(e,t)=>({type:t.selection.jsonID,anchor:ey(t.selection.anchor,e.type,e.mapping),head:ey(t.selection.head,e.type,e.mapping)}),Dv=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=tv(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Ev(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Xd&&this._domSelectionInView===null&&(Vp(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=Tp.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=mh(hm(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(mv,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>kv(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new rt(St.from(e),0,0));t.setMeta(mv,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>kv(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new rt(St.from(t),0,0));if(e){let t=Xl(Zl(e.anchor,0),n.doc.content.size),r=Xl(Zl(e.head,0),n.doc.content.size);n.setSelection(s.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(mv,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=hh(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&nd(),r=new xm({gc:!1}),Im(r,t),t=hh(r),Im(r,e),e=hh(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[Sh(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{lm(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:Sv(n.colorMapping,n.colors,r)}},s=hg(i,new ph(t.ds,e.sv)).map(n=>!n._item.deleted||bv(n._item,e)||bv(n._item,t)?kv(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new rt(St.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(mv,{isChangeOrigin:!0}))},mv)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=mv.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);lm(t,t.deleteSet,e=>{if(e.constructor===J_){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Ov(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new rt(St.from(n),0,0));wv(r,this.beforeTransactionSelection,this),r=r.setMeta(mv,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Bh}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{qv(this.doc,this.type,e,this),this.beforeTransactionSelection=Ev(this,this.prosemirrorView.state)},mv)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Ov=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof a_)return kv(e,t,n,r,i,a);throw td()}return o},kv=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof a_){let s=Ov(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof e_&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=Av(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):hg(e,new ph(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(bv(e._item,r)?bv(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},Av=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,Gv(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},jv=(e,t)=>{let n=new u_,r=e.map(e=>({insert:e.text,attributes:Kv(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Mv=(e,t)=>{let n=new a_(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,Iv(e).map(e=>Nv(e,t))),t.mapping.set(n,e),n},Nv=(e,t)=>e instanceof Array?jv(e,t):Mv(e,t),Pv=e=>typeof e==`object`&&!!e,Fv=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||Pv(o)&&Pv(s)&&Fv(o,s)}return r},Iv=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},Lv=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Id(e.attributes||{}).length===t[n].marks.length&&Bd(e.attributes,(e,r)=>{let i=Wv(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Fv(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Rv=(e,t)=>{if(e instanceof a_&&!(t instanceof Array)&&Jv(e,t)){let n=Iv(t);return e._length===n.length&&Fv(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>Rv(e,n[t]))}return e instanceof u_&&t instanceof Array&&Lv(e,t)},zv=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Bv=(e,t,n)=>{let r=e.toArray(),i=Iv(t),a=i.length,o=r.length,s=Xl(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(zv(n.mapping.get(e),t))u=!0;else if(!Rv(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(zv(n.mapping.get(e),t))u=!0;else if(!Rv(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Vv=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof j_?t+=n.content.str:n.content instanceof w_&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},Hv=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Vv(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Kv(e.marks,n))})),{insert:o,remove:s,index:c}=iv(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},Uv=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Wv=e=>Uv.exec(e)?.[1]??e,Gv=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Wv(r),e[r]));return n},Kv=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Fl(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${vv(e.toJSON())}`:e.type.name]=e.attrs}}),n},qv=(e,t,n,r)=>{if(t instanceof a_&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof a_){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=Iv(n),a=i.length,o=t.toArray(),s=o.length,c=Xl(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!zv(r.mapping.get(e),t))if(Rv(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!zv(r.mapping.get(e),t))if(Rv(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof u_&&c instanceof Array)Lv(n,c)||Hv(n,c,r),l+=1;else{let i=n instanceof a_&&Jv(n,c),a=d instanceof a_&&Jv(d,f);if(i&&a){let e=Bv(n,c,r),t=Bv(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(qv(e,n,c,r),l+=1):a?(qv(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Nv(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof u_?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(Nv(i[t],r));t.insert(l,e)}},mv)},Jv=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,Yv=null,Xv=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=mv.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},Zv=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=Yv;Yv=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new Xv(t,r,e))})}),new e(n)}},Qv=(e=Zv.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||Vp(0,()=>Qv(e,!0));return}throw r}n=!1,e.dequeueFirst()}},$v=(e,t,n)=>{Yv||(Yv=new Map,Vp(0,Qv)),Fl(Yv,e,Nl).set(t,n)},ey=(e,t,n)=>{if(e===0)return lh(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof u_){if(r._length>=e)return lh(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new rh(r._item===null?null:r._item.id,r._item===null?th(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new rh(r._item===null?null:r._item.id,r._item===null?th(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw nd();if(e===0&&r.constructor!==u_&&r!==t)return ty(r._item.parent,r._item)}return lh(t,t._length,-1)},ty=(e,t)=>{let n=null,r=null;return e._item===null?r=th(e):n=eh(e._item.id.client,e._item.id.clock),new rh(n,r,t.id)},ny=(e,t,n,r)=>{let i=dh(n,e);if(i===null||i.type!==t&&!nh(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===u_)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof u_?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof u_?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},ry=(e,t)=>{let n=yv(),r=e.toArray().map(e=>kv(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,St.fromArray(r)),meta:n,mapping:n.mapping}},iy=(e,t,n)=>e!==t,ay=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},oy=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),sy=/^#[0-9a-fA-F]{6}$/,cy=(e,t,n,r,i)=>{let a=mv.getState(e);if(a==null||a.doc==null||a.binding==null)return C.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?C.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:sy.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=ny(o,a.type,ah(t.cursor.anchor),a.binding.mapping),u=ny(o,a.type,ah(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Zl(e.doc.content.size-1,0);l=Xl(l,t),u=Xl(u,t),s.push(we.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=Xl(l,u),o=Zl(l,u);s.push(we.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),C.create(e.doc,s))},ly=(e,{awarenessStateFilter:t=iy,cursorBuilder:n=ay,selectionBuilder:r=oy,getSelection:i=e=>e.selection}={},a=`cursor`)=>new Oe({key:gv,state:{init(i,a){return cy(a,e,t,n,r)},apply(i,a,o,s){let c=mv.getState(s),l=i.getMeta(gv);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?cy(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>gv.getState(e)},view:t=>{let n=()=>{t.docView&&$v(t,gv,{awarenessUpdated:!0})},r=()=>{let n=mv.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=ey(o.anchor,n.type,n.binding.mapping),c=ey(o.head,n.type,n.binding.mapping);(r.cursor==null||!fh(ah(r.cursor.anchor),s)||!fh(ah(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&ny(n.doc,n.type,ah(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),uy=e=>{let t=hv.getState(e).undoManager;if(t!=null)return t.undo(),!0},dy=e=>{let t=hv.getState(e).undoManager;if(t!=null)return t.redo(),!0},fy=new Set([`paragraph`]),py=(e,t)=>!(e instanceof J_)||!(e.content instanceof V_)||!(e.content.type instanceof e_||e.content.type instanceof a_&&t.has(e.content.type.nodeName))||e.content.type._length===0,my=({protectedNodes:e=fy,trackedOrigins:t=[],undoManager:n=null}={})=>new Oe({key:hv,state:{init:(r,i)=>{let a=mv.getState(i),o=n||new Bh(a.type,{trackedOrigins:new Set([mv].concat(t)),deleteFilter:t=>py(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=mv.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Ev(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=mv.getState(e.state),n=hv.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,hv.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});function hy(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=ct(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function gy(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
6
- `);return/\s/.test(n)}):!1}var _y=new W(`suggestion`);function vy({pluginKey:e=_y,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=hy,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,w=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!gy(i);function T(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let E=new Oe({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!w({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=E.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=E.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),T(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=E.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),C.create(e.doc,[we.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return E}var yy=vy;function by(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function xy(e){if(e.kind===`create`)return`Create new tag #${e.value}`;let t=e.count===1?`1 use`:`${e.count} uses`;return`Tag #${e.value}, ${t}`}function Sy(e){let t=(0,J.c)(32),{items:n,query:r,selectedIndex:i,onSelect:a,onHover:o,loading:s,error:c}=e,l=s===void 0?!1:s,u=c===void 0?null:c,d=(0,Y.useRef)(null),f=(0,Y.useId)(),p=i>=0&&i<n.length?`${f}-option-${i}`:void 0,m,h;t[0]===i?(m=t[1],h=t[2]):(m=()=>{let e=d.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},h=[i],t[0]=i,t[1]=m,t[2]=h),(0,Y.useEffect)(m,h);let g=Cy;if(l){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{ref:d,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:g,children:`Loading tags`}),t[3]=e):e=t[3],e}if(n.length===0){let e;t[4]===r?e=t[5]:(e=r.trim(),t[4]=r,t[5]=e);let n=e,i=u??(n?`No tags match "${n}". Continue typing to create one.`:`No tags yet. Continue typing to create one.`),a;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(a={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[6]=a):a=t[6];let o;return t[7]===i?o=t[8]:(o=(0,X.jsx)(`div`,{ref:d,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:a,onMouseDown:g,children:i}),t[7]=i,t[8]=o),o}let _=i>=0&&i<n.length?n[i]:null,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=v):v=t[9];let y;t[10]===_?y=t[11]:(y=_?xy(_):``,t[10]=_,t[11]=y);let b;t[12]===y?b=t[13]:(b=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),t[12]=y,t[13]=b);let x;t[14]===u?x=t[15]:(x=u&&(0,X.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:u}),t[14]=u,t[15]=x);let S;if(t[16]!==n||t[17]!==f||t[18]!==o||t[19]!==a||t[20]!==i){let e;t[22]!==f||t[23]!==o||t[24]!==a||t[25]!==i?(e=(e,t)=>{let n=t===i,r=by(e),s=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${f}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":s?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},onPointerMove:o?()=>o(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),s?(0,X.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:`New`}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[22]=f,t[23]=o,t[24]=a,t[25]=i,t[26]=e):e=t[26],S=n.map(e),t[16]=n,t[17]=f,t[18]=o,t[19]=a,t[20]=i,t[21]=S}else S=t[21];let C;return t[27]!==p||t[28]!==b||t[29]!==x||t[30]!==S?(C=(0,X.jsxs)(`div`,{ref:d,role:`listbox`,"aria-label":`Tag suggestions`,"aria-activedescendant":p,tabIndex:-1,onMouseDown:g,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:v,children:[b,x,S]}),t[27]=p,t[28]=b,t[29]=x,t[30]=S,t[31]=C):C=t[31],C}function Cy(e){return e.preventDefault()}var wy=new WeakMap;function Ty(e,t){wy.set(e,t)}function Ey(e){return wy.get(e)??!1}function Dy(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),en(r,n,{placement:`bottom-start`,middleware:[ge(4),f(),Se({padding:8}),x({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>ue(r,n,o),reveal:()=>{a||(i=!0,o())}}}function Oy(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var ky=new W(`tagSuggestion`),Ay=8,jy=/^[a-zA-Z][\w/-]*$/;async function My(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function Ny(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function Py(e,t){let n=Ny(e,t).slice(0,Ay).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&jy.test(r)&&!e.some(e=>e.name===r)&&n.unshift({kind:`create`,value:r}),n}function Fy(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function Iy(e){let t=[],n=!1,r=null,i=null;return yy({editor:e,pluginKey:ky,char:`#`,allowedPrefixes:null,findSuggestionMatch:Fy,allow:({editor:e})=>!Ey(e),items:async({query:e})=>{if(!n){r||=My();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return Py(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!jy.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Dy(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new El(Sy,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&jy.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){Oy(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var Ly=1,Ry=.9,zy=.8,By=.17,Vy=.1,Hy=.999,Uy=.9999,Wy=.99,Gy=/[\\\/_+.#"@\[\(\{&]/,Ky=/[\\\/_+.#"@\[\(\{&]/g,qy=/[\s-]/,Jy=/[\s-]/g;function Yy(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ly:Wy;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Yy(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ly:Gy.test(e.charAt(l-1))?(d*=zy,p=e.slice(i,l-1).match(Ky),p&&i>0&&(d*=Hy**+p.length)):qy.test(e.charAt(l-1))?(d*=Ry,m=e.slice(i,l-1).match(Jy),m&&i>0&&(d*=Hy**+m.length)):(d*=By,i>0&&(d*=Hy**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Uy)),(d<Vy&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Yy(e,t,n,r,l+1,a+2,o),f*Vy>d&&(d=f*Vy)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Xy(e){return e.toLowerCase().replace(Jy,` `)}function Zy(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Yy(e,t,Xy(e),Xy(t),0,0,{})}var Qy=`[cmdk-group=""]`,$y=`[cmdk-group-items=""]`,eb=`[cmdk-group-heading=""]`,tb=`[cmdk-item=""]`,nb=`${tb}:not([aria-disabled="true"])`,rb=`cmdk-item-select`,ib=`data-value`,ab=(e,t,n)=>Zy(e,t,n),ob=Y.createContext(void 0),sb=()=>Y.useContext(ob),cb=Y.createContext(void 0),lb=()=>Y.useContext(cb),ub=Y.createContext(void 0),db=Y.forwardRef((e,t)=>{let n=Tb(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Tb(()=>new Set),i=Tb(()=>new Map),a=Tb(()=>new Map),o=Tb(()=>new Set),s=Cb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=gn(),y=gn(),b=gn(),x=Y.useRef(null),S=Ob();wb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),wb(()=>{S(6,k)},[]);let C=Y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ab;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest($y);t?t.appendChild(e.parentElement===t?e:e.closest(`${$y} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${$y} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Qy}[${ib}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(ib);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Qy)?.querySelector(eb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${tb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(nb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(ib))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(ib))}function P(e){let t=A()?.closest(Qy),n;for(;t&&!n;)t=e>0?xb(t,Qy):Sb(t,Qy),n=t?.querySelector(nb);n?C.setState(`value`,n.getAttribute(ib)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Y.createElement(fn.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(rb);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:jb},c),Ab(e,e=>Y.createElement(cb.Provider,{value:C},Y.createElement(ob.Provider,{value:w},e))))}),fb=Y.forwardRef((e,t)=>{let n=gn(),r=Y.useRef(null),i=Y.useContext(ub),a=sb(),o=Cb(e),s=o.current?.forceMount??i?.forceMount;wb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Db(n,r,[e.value,e.children,r],e.keywords),l=lb(),u=Eb(e=>e.value&&e.value===c.current),d=Eb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(rb,f),()=>t.removeEventListener(rb,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Y.createElement(fn.div,{ref:xn(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),pb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=gn(),s=Y.useRef(null),c=Y.useRef(null),l=gn(),u=sb(),d=Eb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);wb(()=>u.group(o),[]),Db(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(fn.div,{ref:xn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Ab(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(ub.Provider,{value:f},e))))}),mb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=Eb(e=>!e.search);return!n&&!a?null:Y.createElement(fn.div,{ref:xn(i,t),...r,"cmdk-separator":``,role:`separator`})}),hb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=lb(),o=Eb(e=>e.search),s=Eb(e=>e.selectedItemId),c=sb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(fn.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),gb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Eb(e=>e.selectedItemId),c=sb();return Y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Y.createElement(fn.div,{ref:xn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Ab(e,e=>Y.createElement(`div`,{ref:xn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),_b=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(jn,{open:n,onOpenChange:r},Y.createElement(Pn,{container:o},Y.createElement(Dn,{"cmdk-overlay":``,className:i}),Y.createElement(En,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(db,{ref:t,...s}))))}),vb=Y.forwardRef((e,t)=>Eb(e=>e.filtered.count===0)?Y.createElement(fn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),yb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(fn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ab(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),bb=Object.assign(db,{List:gb,Item:fb,Input:hb,Group:pb,Separator:mb,Dialog:_b,Empty:vb,Loading:yb});function xb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Sb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Cb(e){let t=Y.useRef(e);return wb(()=>{t.current=e}),t}var wb=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function Tb(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function Eb(e){let t=lb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function Db(e,t,n,r=[]){let i=Y.useRef(),a=sb();return wb(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(ib,s),i.current=s}),i}var Ob=()=>{let[e,t]=Y.useState(),n=Tb(()=>new Map);return wb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function kb(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Ab({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(kb(t),{ref:t.ref},n(t.props.children)):n(t)}var jb={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Mb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nb(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=nn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Tn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(wn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=nn(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(Mb,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(kn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)(Ln,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function Pb(e){let t=(0,J.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(ca,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=nn(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)(bb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Fb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ib(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(bb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Lb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Rb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function Bb(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:_(n)??t}}function Vb(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var Hb=new Map,Ub=null;function Wb(){return Zs(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Gb(){if(Ub!==null)return;let e=Math.max(50,Math.floor(Wb()/2));Ub=setTimeout(()=>{Ub=null,Kb(Date.now()),Hb.size>0&&Gb()},e)}function Kb(e){let t=Wb();for(let[n,r]of Hb)e-r.emittedAt>=t&&(Hb.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function qb(e,t,n=Date.now()){Hb.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),Hb.set(e,{poolEventId:t,emittedAt:n}),Gb()}function Jb(e,t,n=Date.now()){let r=Hb.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Wb()?!1:(Hb.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}pt({event:ze(`ok-branch-switched-clear-failed`),branch:Kt(),docName:Kt(),reason:Kt()});async function Yb(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function Xb(e){let t=!1;return()=>{t?e():t=!0}}function Zb(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Qb(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ft.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&Yb(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Zb(n)}catch{}e.observeDiskAckBatch(t)}}async function $b(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function ex(e){return cx(e,Fe)}function tx(e){return cx(e,Ut)}function nx(e){return cx(e,Tt)}function rx(e){return cx(e,ot)}function ix(e){return cx(e,Bt)}function ax(e){let t=cx(e,kt);if(!t)return null;try{return{docName:t.docName,sv:ox(t.sv)}}catch{return null}}function ox(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function sx(e,t){let n=tx(e);if(n){t.onServerInfo?.(n);return}let r=nx(e);if(r){t.onBranchSwitched?.(r);return}let i=ax(e);if(i){t.onDiskAck?.(i);return}let a=ex(e);if(a){t.onDerivedView?.(a);return}let o=rx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=ix(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function cx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function lx(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function ux(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function dx(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var fx=2e3,px=15e3;function mx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??fx,r=e.maxDelayMs??px,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function hx(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=ux(window);if(t){r(dx(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(dx(t))});return()=>{n()}}let n=mx({fetchConfig:$b,fallbackUrl:lx,now:Date.now,setTimeout:yx,clearTimeout:vx,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(_x),s(gx)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function gx(e){return e+1}function _x(e){return{...e,terminal:!1,lastError:null}}function vx(e){return globalThis.clearTimeout(e)}function yx(e,t){return globalThis.setTimeout(e,t)}var bx=new Map,xx=new Set;function Sx(){for(let e of xx)e()}function Cx(e,t){bx.set(e,t),Sx()}function wx(e,t){bx.get(e)===t&&(bx.delete(e),Sx())}function Tx(e){return bx.get(e)??null}function Ex(e){return xx.add(e),()=>xx.delete(e)}var Dx=new Map;function Ox(e){return Dx.get(e)}function kx(e,t){Dx.set(e,t)}function Ax(e){Dx.delete(e)}var jx=`open-knowledge-app`,Mx=new Map,Nx=new Set,Px=1024,Fx=1024;function Ix(){return Kn.getTracer(jx)}function Lx(e,t,n){if(Nx.has(e))return null;let r=Mx.get(e);if(r)return r;if(Mx.size>=Fx){let e=Mx.keys().next().value;if(e!==void 0){let t=Mx.get(e);Mx.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Ix().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Mx.set(e,i),i}function Rx(e,t,n,r,i){try{let a=Lx(e,n,r),o=a?Kn.setSpan(qn.active(),a.span):qn.active();Ix().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function zx(e,t){try{let n=Mx.get(e);if(n&&(Mx.delete(e),n.span.end(t??Date.now())),!Nx.has(e)){if(Nx.size>=Px){let e=Nx.values().next().value;e!==void 0&&Nx.delete(e)}Nx.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Bx=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function Vx(){return Zs(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function Hx(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Ux(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var Wx=new Map,Gx=new Set;function Kx(e){Gx.add(e);for(let[t,n]of Wx)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Gx.delete(e)}}function qx(e,t){for(let n of Gx)try{n(e,t.mountId)}catch{}}var Jx=!1;function Yx(){typeof document>`u`||document.visibilityState===`visible`&&Qx(Date.now())}function Xx(){Jx||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,Yx),Jx=!0)}function Zx(){Jx&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,Yx),Jx=!1))}function Qx(e){let t=Vx();for(let[n,r]of Wx)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Ux(r,n,e),qx(n,r))}function $x(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=Wx.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Ux(d,t,Date.now()),qx(t,d))},Vx()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,Hx(d),d.preMountEditor&&=(rS(t,d.preMountEditor,`aborted`),null),Wx.delete(t),Wx.size===0&&Zx(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new Bx(t)),zx(d.mountId))}),Wx.set(t,d),Xx(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),iS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(rS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,Hx(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),zx(d.mountId)}),u}function eS(e){return Wx.get(e)?.resolved===!0}function tS(e){return Wx.get(e)?.controller??null}function nS(e){let t=Wx.get(e);t&&(t.settled=!0,Hx(t),t.preMountEditor&&=(rS(e,t.preMountEditor,`aborted`),null),Wx.delete(e),Wx.size===0&&Zx(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),zx(t.mountId),t.controller.abort())}function rS(e,t,n){let r=aS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function iS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(zS(t)!==void 0){let e=CS({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,Hx(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),zx(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){rS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),zx(i.mountId);return}let l;try{l=CS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){rS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),zx(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,Hx(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Rx(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),zx(i.mountId,d)}function aS(e){try{let t=e.state;return hv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var oS=Zs(`MAX_CACHE`,10),sS=Zs(`VIEW_COUNT_CACHE_THRESHOLD`,50),cS=Zs(`BYTES_CACHE_THRESHOLD`,8e6);function lS(e){return!(e.viewCount>0&&e.viewCount>=sS||e.bytes>cS)}var uS=new Map,dS=new Map,fS=new Map;function pS(e,t){if(fS.size>=oS){let e=fS.keys().next().value;e!==void 0&&fS.delete(e)}fS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function mS(e){return fS.get(e)??null}function hS(e){if(!fS.has(e))return;let t=fS.get(e)??null;fS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function gS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function _S(e){try{let t=e.state.selection;return t instanceof s?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof j?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function vS(e){for(let t of e)try{let e=zS(t.fromDocName);e&&!e.editor.isDestroyed?pS(t.toDocName,{html:e.editor.getHTML(),scrollTop:gS(),selection:_S(e.editor)}):Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var yS=[],bS=[],xS=new Set;function SS(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function CS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!lS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=uS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:Ox(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),jS(a,n),a.activeMountKey=t,NS(yS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:Ox(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:Ox(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;uS.size>=oS;){let e=PS(yS,t);if(!e)break;TS(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return uS.set(t,s),NS(yS,t),Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function wS(e){let t=e.activeMountKey;if(e.__uncached){t&&nS(t);let n=aS(e.editor);try{e.editor.destroy()}catch(e){Z(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=kS(e.editor);if(n){e.hadFocus=AS(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=SS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function TS(e){nS(e);let t=uS.get(e);if(!t)return!1;let n=aS(t.editor);try{t.editor.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}uS.delete(e);let r=yS.indexOf(e);return r!==-1&&yS.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function ES(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!lS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=dS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:Ox(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),MS(a,n),a.activeMountKey=t,NS(bS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:Ox(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:Ox(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;dS.size>=oS;){let e=PS(bS,t);if(!e)break;OS(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return dS.set(t,s),NS(bS,t),Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function DS(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=AS(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=SS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function OS(e){let t=dS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}dS.delete(e);let n=bS.indexOf(e);return n!==-1&&bS.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function kS(e){return e.editorView??null}function AS(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function jS(e,t){let n=kS(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function MS(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function NS(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function PS(e,t){for(let n of e)if(n!==t&&!xS.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:xS.size});for(let n of e)if(n!==t)return n;return null}function FS(e){let t=xS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=LS(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=LS(e);if(!n)continue;let r=t=>{Z(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}xS=n}var IS=null;function LS(e){let t=uS.get(e);if(t)return t.provider;let n=dS.get(e);if(n)return n.provider;if(IS){let t=IS.entries.get(e);if(t)return t.provider}return null}function RS(e){IS=e;let t=e.onEvict(e=>{TS(e),OS(e)});return()=>{t(),IS===e&&(IS=null)}}function zS(e){return uS.get(e)}var BS=`ok-editor-tabs-v1:`,VS=`\0folder:`,HS=`\0asset:`,US=`\0doc-tab:`;function WS(e){let t=e.lastIndexOf(US);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function GS(e){return WS(e).baseTabId}function KS(e){if(typeof e!=`string`||e.length===0)return!1;let t=GS(e);return t.startsWith(VS)?t.length>8:t.startsWith(HS)?t.length>7:!0}function qS(e){return e}function JS(e,t){return`${GS(e)}${US}${t}`}function YS(e,t){return XS(e,qS(t))}function XS(e,t){let n=aC(e,2**53-1),r=GS(t);if(!n.includes(r))return r;let i=1,a;do a=JS(r,i),i++;while(n.includes(a));return a}function ZS(e,t){let n=GS(t);return aC(e,2**53-1).find(e=>GS(e)===n)??null}function QS(e,t){return GS(e)===GS(t)}function $S(e){return`${VS}${e}`}function eC(e){return`${HS}${e}`}function tC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function nC(e){switch(e.kind){case`doc`:case`folder-index`:return qS(e.docName);case`folder`:return $S(e.folderPath);case`missing`:return qS(e.target);case`asset`:return eC(e.assetPath)}}function rC(e){let t=GS(e);return t.startsWith(VS)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(HS)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function iC(e){let t=rC(e);return t.kind===`doc`?t.docName:null}function aC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(KS(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function oC(e,t){let n=new Set(aC(t,2**53-1));return aC(e,2**53-1).filter(e=>n.has(e))}function sC(e,t,n){if(t<=0)return[];let r=new Set(aC(n,2**53-1)),i=aC(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function cC(e,t,n){let r=oC(e,n);return!aC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function lC(e,t){return aC(e,2**53-1).filter(e=>e!==t)}function uC(e,t){let n=new Set(aC(t,2**53-1));return aC(e,2**53-1).filter(e=>!n.has(e))}function dC(e,t,n){let r=aC(e,2**53-1),i=oC(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?cC(i,n,r):lC(i,n)}function fC(e,t,n,r=[]){let i=sC(e,n,r);return!KS(t)||i.includes(t)?i:sC([...i,t],n,r)}function pC(e,t,n,r,i=[]){let a=sC(e,r,i);if(!KS(n))return a;if(!t||t===n)return fC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return fC(o,n,r,i);let c=[...o];return c[s]=n,sC(c,r,i)}function mC(e,t,n){return hC(e,qS(t),n)}function hC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=sC(e,i,a),s=GS(t);if(r&&o.includes(r)&&GS(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:fC(o,s,i,a),activeTabId:s};let c=ZS(o,s);if(c)return{tabs:o,activeTabId:c};let l=XS(o,s);return{tabs:pC(o,r,l,i,a),activeTabId:l}}function gC(e,t){return e.filter(e=>e!==t)}function _C(e,t,n){let r=aC(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function vC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return aC(e,2**53-1).filter(e=>{let a=rC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function yC(e,t,n,r=[],i=[]){if(t.length===0&&r.length===0)return aC(e,n);let a=new Map(t.map(e=>[e.fromDocName,e.toDocName])),o=[],s=new Set;for(let t of e){let{instanceSuffix:e}=WS(t),c=rC(t),l=`${c.kind===`doc`?a.get(c.docName)??GS(t):c.kind===`folder`?$S(xC(c.folderPath,r)):eC(xC(c.assetPath,r))}${e}`;if(!s.has(l)&&(s.add(l),o.push(l),i.length===0&&o.length>=n))break}return i.length===0?o:sC(o,n,i.map(e=>{let t=rC(e);return t.kind===`doc`?a.get(t.docName)??e:t.kind===`folder`?$S(xC(t.folderPath,r)):eC(xC(t.assetPath,r))}))}function bC(e,t,n=[]){return yC(e,t,2**53-1,n)}function xC(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function SC(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function CC(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function wC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=aC(n.openTabs,2**53-1),i=oC(n.pinnedTabIds,r),a=i.length===0?aC(n.openTabs,t):sC(r,t,i),o=oC(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?rC(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function TC(e,t,n=[],r=()=>new Date){let i=aC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?rC(a):null;return{openTabs:i,pinnedTabIds:oC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function EC(e){return`${BS}${e}`}function DC(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?wC(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function OC(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var kC=Math.floor,AC=(e,t)=>e<t?e:t,jC=(e,t)=>e>t?e:t;Number.isNaN;var MC=128,NC=1<<17,PC=1<<18,FC=1<<19,IC=1<<20,LC=1<<21,RC=1<<22,zC=1<<23,BC=1<<24,VC=1<<25,HC=1<<26,UC=1<<27,WC=1<<28,GC=1<<29,KC=1<<30,qC=127;NC-1,PC-1,FC-1,IC-1,LC-1,RC-1,zC-1,BC-1,VC-1,HC-1,UC-1,WC-1,GC-1,KC-1;var JC=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var YC=String.fromCharCode;String.fromCodePoint,YC(65535);var XC=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},ZC=typeof TextEncoder<`u`?new TextEncoder:null,QC=ZC?e=>ZC.encode(e):XC,$C=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});$C&&$C.decode(new Uint8Array).length===1&&($C=null);var ew=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},tw=(e,t)=>{for(;t>qC;)ew(e,MC|qC&t),t=kC(t/128);ew(e,qC&t)},nw=new Uint8Array(3e4),rw=nw.length/3,iw=ZC&&ZC.encodeInto?(e,t)=>{if(t.length<rw){let n=ZC.encodeInto(t,nw).written||0;tw(e,n);for(let t=0;t<n;t++)ew(e,nw[t])}else ow(e,QC(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;tw(e,r);for(let t=0;t<r;t++)ew(e,n.codePointAt(t))},aw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=AC(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(jC(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},ow=(e,t)=>{tw(e,t.byteLength),aw(e,t)},sw=e=>Error(e),cw=sw(`Unexpected end of array`),lw=sw(`Integer out of Range`),uw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},dw=e=>uw(e,pw(e)),fw=e=>e.arr[e.pos++],pw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&qC)*n,n*=128,r<MC)return t;if(t>JC)throw lw}throw cw},mw=$C?e=>$C.decode(dw(e)):e=>{let t=pw(e);if(t===0)return``;{let n=String.fromCodePoint(fw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(fw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},hw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),gw=(e,t)=>{tw(e,hw.Token),iw(e,t)},_w=(e,t,n,r)=>{switch(pw(e)){case hw.Token:t();break;case hw.PermissionDenied:n(mw(e));break;case hw.Authenticated:r(mw(e));break;default:}},vw=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),yw=`\0`;function bw(e,t){return e+yw+t}function xw(e){let t=e.indexOf(yw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Sw=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Cw(e){return 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 ww(e){return new Promise(t=>setTimeout(t,e))}function Tw(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Ew(e,t){let n=Cw(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Tw;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await ww(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await ww(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await ww(e)}return a()}var Dw=Math.floor,Ow=(e,t)=>e<t?e:t,kw=(e,t)=>e>t?e:t;Number.isNaN;var Aw=64,jw=128,Mw=1<<17,Nw=1<<18,Pw=1<<19,Fw=1<<20,Iw=1<<21,Lw=1<<22,Rw=1<<23,zw=1<<24,Bw=1<<25,Vw=1<<26,Hw=1<<27,Uw=1<<28,Ww=1<<29,Gw=1<<30,Kw=63,qw=127;Mw-1,Nw-1,Pw-1,Fw-1,Iw-1,Lw-1,Rw-1,zw-1,Bw-1,Vw-1,Hw-1,Uw-1,Ww-1,Gw-1;var Jw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Yw=()=>new Set,Xw=Array.from;Array.isArray;var Zw=String.fromCharCode;String.fromCodePoint,Zw(65535);var Qw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},$w=typeof TextEncoder<`u`?new TextEncoder:null,eT=$w?e=>$w.encode(e):Qw,tT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});tT&&tT.decode(new Uint8Array).length===1&&(tT=null);var nT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},rT=()=>new nT,iT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},aT=e=>{let t=new Uint8Array(iT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},oT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},sT=(e,t)=>{for(;t>qw;)oT(e,jw|qw&t),t=Dw(t/128);oT(e,qw&t)},cT=new Uint8Array(3e4),lT=cT.length/3,uT=$w&&$w.encodeInto?(e,t)=>{if(t.length<lT){let n=$w.encodeInto(t,cT).written||0;sT(e,n);for(let t=0;t<n;t++)oT(e,cT[t])}else fT(e,eT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;sT(e,r);for(let t=0;t<r;t++)oT(e,n.codePointAt(t))},dT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Ow(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(kw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},fT=(e,t)=>{sT(e,t.byteLength),dT(e,t)},pT=e=>Error(e),mT=pT(`Unexpected end of array`),hT=pT(`Integer out of Range`),gT=class{constructor(e){this.arr=e,this.pos=0}},_T=e=>new gT(e),vT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},yT=e=>vT(e,xT(e)),bT=e=>e.arr[e.pos++],xT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&qw)*n,n*=128,r<jw)return t;if(t>Jw)throw hT}throw mT},ST=e=>{let t=e.arr[e.pos++],n=t&Kw,r=64,i=(t&Aw)>0?-1:1;if((t&jw)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&qw)*r,r*=128,t<jw)return i*n;if(n>Jw)throw hT}throw mT},CT=tT?e=>tT.decode(yT(e)):e=>{let t=xT(e);if(t===0)return``;{let n=String.fromCodePoint(bT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(bT(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},wT=e=>{let t=e.pos,n=CT(e);return e.pos=t,n},TT=Date.now,ET=()=>new Map,DT=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},OT=class{constructor(){this._observers=ET()}on(e,t){DT(this._observers,e,Yw).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Xw((this._observers.get(e)||ET()).values()).forEach(e=>e(...t))}destroy(){this._observers=ET()}},kT=Symbol(`Equality`),AT=Object.keys,jT=e=>AT(e).length,MT=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),NT=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[kT]!=null)return e[kT](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!NT(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(jT(e)!==jT(t))return!1;for(let n in e)if(!MT(e,n)||!NT(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!NT(e[n],t[n]))return!1;break;default:return!1}return!0},PT=3e4,FT=class extends OT{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=TT();this.getLocalState()!==null&&PT/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&PT<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&IT(this,t,`timeout`)},Dw(PT/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:TT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),NT(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},IT=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:TT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},LT=(e,t,n=e.states)=>{let r=t.length,i=rT();sT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;sT(i,r),sT(i,s),uT(i,JSON.stringify(o))}return aT(i)},RT=(e,t,n)=>{let r=_T(t),i=TT(),a=[],o=[],s=[],c=[],l=xT(r);for(let t=0;t<l;t++){let t=xT(r),n=xT(r),l=JSON.parse(CT(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(NT(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},zT=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},BT=class{constructor(e){this.data=e,this.encoder=rT(),this.decoder=_T(new Uint8Array(this.data))}peekVarString(){return wT(this.decoder)}readVarUint(){return xT(this.decoder)}readVarString(){return CT(this.decoder)}readVarUint8Array(){return yT(this.decoder)}writeVarUint(e){return sT(this.encoder,e)}writeVarString(e){return uT(this.encoder,e)}writeVarUint8Array(e){return fT(this.encoder,e)}length(){return iT(this.encoder)}},VT=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[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),HT=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),UT=class{constructor(){this.encoder=rT()}get(e){return e.encoder}toUint8Array(){return aT(this.encoder)}},WT=class extends UT{constructor(...e){super(...e),this.type=VT.CLOSE,this.description=`Ask the server to close the connection`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),this.encoder}},GT=class e extends zT{static{this.DEDUPLICATABLE_TYPES=new Set([VT.Awareness,VT.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,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,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=HT.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,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(`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),this.shouldConnect&&this.connect()}async onOpen(e){this.status=HT.Connected,this.emit(`status`,{status:HT.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===HT.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===HT.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(WT,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===HT.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Ew(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,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{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;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=HT.Connecting,this.emit(`status`,{status:HT.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=TT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===VT.Ping){this.sendPong();return}let n=new BT(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=rT();sT(e,VT.Pong),this.send(aT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=HT.Connected,this.emit(`status`,{status:HT.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===HT.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=TT()-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(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=_T(e);return{documentName:CT(t),messageType:xT(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Sw.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=HT.Disconnected,this.emit(`status`,{status:HT.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},KT=0,qT=1,JT=2,YT=(e,t)=>{sT(e,KT),fT(e,Km(t))},XT=(e,t,n)=>{sT(e,qT),fT(e,Bm(t,n))},ZT=(e,t,n)=>XT(t,n,yT(e)),QT=(e,t,n,r)=>{try{Lm(t,yT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},$T=(e,t)=>{sT(e,JT),fT(e,t)},eE=QT,tE=(e,t,n,r,i)=>{let a=xT(e);switch(a){case KT:ZT(e,t,n);break;case qT:QT(e,n,r,i);break;case JT:eE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},nE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case VT.Sync:this.applySyncMessage(e,t);break;case VT.Awareness:this.applyAwarenessMessage(e);break;case VT.Auth:this.applyAuthMessage(e);break;case VT.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case VT.Stateless:e.receiveStateless(CT(n.decoder));break;case VT.SyncStatus:this.applySyncStatusMessage(e,ST(n.decoder)===1);break;case VT.CLOSE:let i={code:1e3,reason:CT(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(UT,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(VT.Sync);let r=tE(n.decoder,n.encoder,e.document,e);t&&r===qT&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;RT(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;_w(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(VT.Awareness),t.writeVarUint8Array(LT(e.awareness,Array.from(e.awareness.getStates().keys())))}},rE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return aT(this.encoder)}send(e){e?.send(this.create())}},iE=`4.0.0-rc.1`,aE=class extends UT{constructor(...e){super(...e),this.type=VT.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return uT(this.encoder,e.documentName),sT(this.encoder,this.type),gw(this.encoder,e.token),uT(this.encoder,iE),this.encoder}},oE=class extends UT{constructor(...e){super(...e),this.type=VT.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);uT(this.encoder,e.documentName),sT(this.encoder,this.type);let t;return t=e.states===void 0?LT(e.awareness,e.clients):LT(e.awareness,e.clients,e.states),fT(this.encoder,t),this.encoder}},sE=class extends UT{constructor(...e){super(...e),this.type=VT.Stateless,this.description=`A stateless message`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),uT(this.encoder,e.payload??``),this.encoder}},cE=class extends UT{constructor(...e){super(...e),this.type=VT.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return uT(this.encoder,e.documentName),sT(this.encoder,this.type),YT(this.encoder,e.document),this.encoder}},lE=class extends UT{constructor(...e){super(...e),this.type=VT.Sync,this.description=`A document update`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),$T(this.encoder,e.update),this.encoder}},uE=class extends Error{constructor(...e){super(...e),this.code=1001}},dE=class extends zT{get effectiveName(){return this.configuration.sessionAwareness?bw(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new xm,this.configuration.awareness=e.awareness===void 0?new FT(this.document):e.awareness,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(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:vw(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:vw(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.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new GT(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(cE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&IT(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(sE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(aE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(lE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(oE,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(cE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(oE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new rE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new BT(e.data),{documentName:n}=xw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new BT(e.data)}),new nE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&IT(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(IT(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.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new uE(`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)}},fE=e=>Od((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),pE=(e,t)=>Od((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(ed(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),mE=e=>fE(indexedDB.deleteDatabase(e)),hE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),gE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>DE(r,e))},_E=(e,t)=>fE(e.count(t)),vE=(e,t)=>fE(e.get(t)),yE=(e,t)=>fE(e.delete(t)),bE=(e,t,n)=>fE(e.put(t,n)),xE=(e,t)=>fE(e.add(t)),SE=(e,t,n)=>fE(e.getAll(t,n)),CE=(e,t,n)=>{let r=null;return EE(e,t,e=>(r=e,!1),n).then(()=>r)},wE=(e,t=null)=>CE(e,t,`prev`),TE=(e,t)=>Od((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),EE=(e,t,n,r=`next`)=>TE(e.openKeyCursor(t,r),e=>n(e.key)),DE=(e,t)=>e.objectStore(t),OE=(e,t)=>IDBKeyRange.upperBound(e,t),kE=(e,t)=>IDBKeyRange.lowerBound(e,t),AE=`custom`,jE=`updates`,ME=(e,t=()=>{},n=()=>{})=>{let[r]=gE(e.db,[jE]);return SE(r,kE(e._dbref,!1)).then(i=>{e._destroyed||(t(r),Ih(e.doc,()=>{i.forEach(t=>Lm(e.doc,t))},e,!1),n(r))}).then(()=>wE(r).then(t=>{e._dbref=t+1})).then(()=>_E(r).then(t=>{e._dbsize=t})).then(()=>r)},NE=(e,t=!0)=>ME(e).then(n=>{(t||e._dbsize>=500)&&xE(n,Bm(e.doc)).then(()=>yE(n,OE(e._dbref,!0))).then(()=>_E(n).then(t=>{e._dbsize=t}))}),PE=class extends ql{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=pE(e,e=>hE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Od(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,ME(this,async e=>{await _E(e)>0&&xE(e,Bm(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=gE(this.db,[jE]);xE(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{NE(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{mE(this.name)})}get(e){return this._db.then(t=>{let[n]=gE(t,[AE],`readonly`);return vE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=gE(n,[AE]);return bE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=gE(t,[AE]);return yE(n,e)})}};function FE(){return!0}var IE=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=FE()?0:performance.now();this._idb=new PE(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!FE()){let e=performance.now();Z(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=FE()?0:performance.now();try{await this._idb.destroy()}finally{if(!FE()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=FE()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!FE()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function LE(e){return new IE(e)}function RE(e){return Km(e)}function zE(e,t){return t===null?Bm(e):Bm(e,t)}function BE(e,t){if(e===null)return t;if(t===null)return e;let n=Hm(e),r=Hm(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Km(i)}function VE(e){let t={};if(Jn.inject(qn.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var HE=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new Oe({key:e||new W(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),UE=g.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[HE({key:new W(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function WE(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!j.isSelectable(o))return!1;try{let t=j.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}var GE=g.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof j){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=s.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof s?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(WE(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof j))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=j.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(WE(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof j))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=j.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>WE(e,`left`),ArrowRight:({editor:e})=>WE(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof s)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let c=t.tr,l=n.before(n.depth),u=n.after(n.depth);c.delete(l,u);let d=o-(u-l),f=t.schema.nodes.paragraph.create();c.insert(d,f);let p=d+1;return c.setSelection(s.create(c.doc,p)),e.view.dispatch(c.scrollIntoView()),!0}}}}),KE={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},qE=/[A-Za-z0-9_]/;function JE(e){return e!==void 0&&qE.test(e)}function YE(e,t,n){return!JE(e[t-1])&&!JE(e[n])}function XE(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||YE(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function ZE(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of XE(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var QE=new W(`findReplace`);function $E(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function eD(e,t,n,r){let i=ZE(e.doc,t,n);return{query:t,options:n,activeIndex:$E(r,i.length),matches:i}}function tD(e,t,n){return t<=0?0:($E(e,t)+n+t)%t}function nD(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function rD(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=ZE(r.doc,t.query,t.options),a=$E(0,i.length),o=i[a];return r.setMeta(QE,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(s.create(r.doc,o.from,o.to)),r.scrollIntoView()}function iD(e,t){let n=QE.getState(e)?.matches[t];return n?e.tr.setMeta(QE,{type:`setActiveIndex`,activeIndex:t}).setSelection(s.create(e.doc,n.from,n.to)).scrollIntoView():null}function aD(e){return QE.getState(e)??KE}function oD(){return new Oe({key:QE,state:{init:()=>KE,apply(e,t,n,r){let i=e.getMeta(QE);if(i?.type===`clear`)return KE;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:eD(r,a,o,s)}},props:{decorations(e){let t=QE.getState(e);return!t||t.matches.length===0?null:C.create(e.doc,t.matches.map((e,n)=>we.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var sD=g.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(QE,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(QE,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(QE,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=aD(e),r=iD(e,tD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=aD(e),r=iD(e,tD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=aD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=ZE(a.doc,r.query,r.options),c=nD(o,i.from,e.length),l=o[c];return a.setMeta(QE,{type:`setActiveIndex`,activeIndex:c}),l&&a.setSelection(s.create(a.doc,l.from,l.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=aD(t);if(!n)return!1;let i=rD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(QE,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[oD()]}}),cD=new WeakMap;function lD(e,t){if(t===null){cD.delete(e);return}cD.set(e,t)}function uD(e){return cD.get(e)??null}function dD(e){return`pagesBySlug`in e}function fD(e){return dD(e)?e.pages:e}function pD(e,t){return dD(e)?e.assetPaths??new Set:t??new Set}function mD(e,t){let n=Le(e);if(n){if(dD(t))return t.pagesBySlug.get(n);for(let e of t)if(Le(e)===n)return e}}function hD(e){let t=e.trim();if(!t)return null;let n=Le(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function gD(e){let t=e.trim();if(!t)return[];let n=Le(t);return n.length>0&&n!==t?[n]:[]}function _D(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function vD(e,t){let n=_D(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function yD(e,t,n){let r=e.trim();if(!r)return!1;if(vD(r,pD(t,n)))return!0;let i=fD(t);return i.has(r)||gD(r).some(e=>i.has(e))?!0:mD(r,t)!==void 0}var bD=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},xD=new W(`imageUpload`);function SD(e){let t=document.createElement(`div`);return t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-label`,e?.name?`Uploading ${e.name}`:`Uploading file`),t}var CD=new Oe({key:xD,state:{init(){return{decorations:C.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(xD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=we.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return xD.getState(e)?.decorations??C.empty}}});function wD(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function TD(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function ED(e){return e.split(`/`).filter(e=>e!==``)}function DD(e,t){let n=wD(e),r=wD(t),i=TD(e);if(n===r)return i;let a=ED(r),o=ED(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function OD(e){return uD(e)}function kD(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function AD(e){let t=ut(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:d.has(t)?{kind:`jsx-img`,ext:t}:Gt.has(t)?{kind:`jsx-video`,ext:t}:se.has(t)?{kind:`jsx-audio`,ext:t}:m.has(t)?{kind:`jsx-file`,ext:t}:Ct.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function jD(e,t,n){let r=OD(t),i=r?`${r}.md`:``;if(!i){zn.error(`Cannot upload: no document is open`);return}let a=crypto.randomUUID(),o=SD(e);t.view.dispatch(t.state.tr.setMeta(xD,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),MD(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),MD(t,a);return}if(!c.ok){let e=xe.safeParse(l);if(!e.success){let n=new bD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),MD(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),MD(t,a,e.data.title);return}let u=qe.safeParse(l);if(!u.success){let e=new bD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),MD(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=wD(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&zn.info(`Already at ${h} — reusing.`);let g=AD(e.name),{state:_}=t,v=xD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(xD,{type:`remove`,id:a}),b=DD(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),MD(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:ee(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(xD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(j.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),MD(t,a);return}let e=kD(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(xD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(j.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),MD(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),MD(t,a);return}let r=hD(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function MD(e,t,n){e.view.dispatch(e.state.tr.setMeta(xD,{type:`remove`,id:t})),zn.error(n??`Upload failed`)}var ND={AppWindow:fi,ChevronRight:Vn,CopyPlus:Ti,FileText:ji,Film:Pi,GitBranch:Li,Image:Hi,LayoutPanelTop:Wi,MessageSquareWarning:$i,PanelTop:ra,Paperclip:ia,Sigma:ua,SquarePlay:da,Volume2:ya,Workflow:ba,ZoomIn:Sa};function PD(e){return e&&Object.hasOwn(ND,e)?ND[e]:gi}var FD={ChevronRight:Vn};function ID(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(FD,t)?FD[t]:null}function LD(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=ID(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Vn,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,X.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,X.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,X.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,X.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,X.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,X.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function RD(e){return e!==!1}function zD(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:$t(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=RD(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,X.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var BD={note:Ui,tip:Gi,important:$i,warning:Ue,caution:ta,abstract:Ci,info:hi,todo:Xi,success:At,question:xi,failure:Si,danger:xa,bug:_i,example:Fi,quote:sa},VD={Info:Ui,Lightbulb:Gi,MessageSquareWarning:$i,AlertTriangle:Ue,AlertOctagon:ta,ClipboardList:Ci,BookOpen:hi,ListTodo:Xi,CircleCheck:At,CircleHelp:xi,CircleX:Si,Zap:xa,Bug:_i,FlaskConical:Fi,Quote:sa};function HD(e,t){if(!e||!e.startsWith(`lucide:`))return BD[t];let n=e.slice(7);return Object.hasOwn(VD,n)?VD[n]:BD[t]}var UD=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function WD(e){return typeof e==`string`&&UD.has(e)?e:`note`}function GD(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=WD(e.type),n=HD(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let o=a,s;t[6]!==i||t[7]!==e.title?(s=e.title||i?(0,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=s):s=t[8];let c=s;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===c?i=t[10]:(i=c??(0,X.jsx)(`span`,{className:`callout-title`,children:`Details`}),t[9]=c,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(vi,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let s;t[12]===i?s=t[13]:(s=(0,X.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=s);let l;t[14]===e.children?l=t[15]:(l=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=l);let u;return t[16]!==n||t[17]!==o||t[18]!==s||t[19]!==l||t[20]!==r?(u=(0,X.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:o,children:[s,l]}),t[16]=n,t[17]=o,t[18]=s,t[19]=l,t[20]=r,t[21]=u):u=t[21],u}let l;t[22]===e.children?l=t[23]:(l=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=l);let u;return t[24]!==c||t[25]!==o||t[26]!==l||t[27]!==r?(u=(0,X.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:o,children:[c,l]}),t[24]=c,t[25]=o,t[26]=l,t[27]=r,t[28]=u):u=t[28],u}var KD=(0,Y.createContext)(null);function qD(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(KD.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function JD(){return(0,Y.use)(KD)}var YD=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function XD(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,o=(0,Y.useRef)(null),s;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(s=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=s):s=t[4];let c=s,l=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let s=a.getBoundingClientRect();o.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:s.width,startHeight:s.height,latestWidth:s.width,latestHeight:s.height,hasMoved:!1},document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=o.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:c(t.startWidth+n,`w`),s=t.handle.dy===0?t.startHeight:c(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=s,t.hasMoved=!0,r({width:a,height:s})};function u(){let e=o.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;o.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},u=YD.map(e=>(0,X.jsx)(`button`,{type:`button`,className:nn(e.className),"aria-label":`Resize ${e.key}`,tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>l(t,e)},e.key)),d;return t[5]===u?d=t[6]:(d=(0,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:u}),t[5]=u,t[6]=d),d}var ZD=`26rem`,QD=`Embedded content`,$D=/^https?:\/\//i;function eO(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function tO(e){return!(typeof e!=`string`||!$D.test(e)||!eO(e))}function nO(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=JD(),c=i||void 0,l=a||ZD,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||ZD)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!tO(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=$D.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g=r||QD,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(XD,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function rO(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function iO(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||rO(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?$t(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Mi,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,X.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:aO,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function aO(e){return e.stopPropagation()}function oO(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function sO(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function cO(e){return typeof Element>`u`?!1:e instanceof Element}var lO=(e,t)=>cO(t)&&t.tagName.toUpperCase()===e,uO=e=>lO(`DIV`,e)||lO(`SPAN`,e),dO=e=>lO(`IMG`,e),fO=e=>e.complete&&e.naturalHeight!==0,pO=e=>lO(`SVG`,e),mO=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),hO=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=mO({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},gO=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?hO({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):mO({height:e,offset:r,width:t}),_O=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,vO=e=>{if(e!==null){if(dO(e))return e.currentSrc===``?void 0:e.currentSrc;if(uO(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return _O.exec(t)?.[1]}}},yO=e=>{if(e!==null)return dO(e)?e.alt:e.getAttribute(`aria-label`)??void 0},bO=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=gO({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},xO=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},SO=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=xO({position:p,relativeNum:r-l*f}),g=xO({position:m,relativeNum:e-c*f}),_=gO({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=xO({position:a,relativeNum:r-l}),f=xO({position:u,relativeNum:e-c}),p=gO({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=gO({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},CO=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=xO({position:p,relativeNum:a-l*f}),g=xO({position:m,relativeNum:n-c*f}),_=gO({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=xO({position:t,relativeNum:a-l}),f=xO({position:u,relativeNum:n-c}),p=gO({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=xO({position:u,relativeNum:a}),p=xO({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=xO({position:_,relativeNum:a-l*g}),b=xO({position:v,relativeNum:n-c*g}),x=gO({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},wO=/\.svg$/i,TO=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&wO.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&uO(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=bO({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?SO({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?CO({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},EO=e=>{if(e==null)return{};if(pO(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},DO=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},OO=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),kO={overflow:``,width:``};function AO(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function jO(e){e.preventDefault()}function MO(e){return Y.createElement(NO,{...e})}var NO=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=kO,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(OO),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:EO(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:EO(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=vO(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(dO(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:EO(this.imgEl)})};t.decode().then(r).catch(()=>{if(fO(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||pO(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=kO},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(fO(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(pO(e)){let r=e.cloneNode(!0);DO(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=uO(a),j=dO(a),M=pO(a),N=yO(a),P=vO(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),te=N!==void 0&&N!==``?`${s}: ${N}`:s,ne=T===`LOADING`||T===`LOADED`,re=R?`found`:`not-found`,z=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,B={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?TO({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&ne,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let ie=null;if(R){let t=j||A?Y.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));ie=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":re,ref:_,style:B},c),R&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":te,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),R&&Da.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:jO,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":z}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},ie)),AO()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};NO.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:oO,IconZoom:sO,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function PO({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(MO,{...t,isZoomed:n,onZoomChange:i})}function FO(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function IO(e,t,n){return FO(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function LO(e){let t=(0,J.c)(51),n,r,i,a,o,s,c,l,u,d,f,p;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12]):({width:p,height:r,loadingTestId:u,slotTestId:d,slotClassName:s,className:n,onLoad:o,onError:a,src:c,style:l,alt:f,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p);let m=u===void 0?`image-loading-skeleton`:u,h=d===void 0?`image-slot`:d,g=f===void 0?``:f,_=(0,Y.useRef)(null),[v,y]=(0,Y.useState)(!1),b;t[13]!==r||t[14]!==p?(b=FO(p,r),t[13]=r,t[14]=p,t[15]=b):b=t[15];let x=b,S;t[16]!==r||t[17]!==l||t[18]!==p?(S=IO(p,r,l),t[16]=r,t[17]=l,t[18]=p,t[19]=S):S=t[19];let C=S,w;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{_.current?.complete?y(!0):y(!1)},t[20]=w):w=t[20];let T;t[21]===c?T=t[22]:(T=[c],t[21]=c,t[22]=T),(0,Y.useLayoutEffect)(w,T);let E=!x&&!v&&`aspect-[16/9] w-full max-w-full`,D;t[23]!==s||t[24]!==E?(D=nn(`relative inline-block overflow-hidden`,E,s),t[23]=s,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==v||t[27]!==m?(O=!v&&(0,X.jsx)(`span`,{"data-testid":m,role:`status`,"aria-busy":`true`,"aria-label":`Loading image`,className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=m,t[28]=O):O=t[28];let k=v?`opacity-100`:`opacity-0`,A;t[29]!==n||t[30]!==k?(A=nn(`block max-w-full transition-opacity motion-reduce:transition-none`,k,n),t[29]=n,t[30]=k,t[31]=A):A=t[31];let j;t[32]===o?j=t[33]:(j=e=>{y(!0),o?.(e)},t[32]=o,t[33]=j);let M;t[34]===a?M=t[35]:(M=e=>{y(!0),a?.(e)},t[34]=a,t[35]=M);let N;t[36]!==g||t[37]!==r||t[38]!==i||t[39]!==c||t[40]!==A||t[41]!==j||t[42]!==M||t[43]!==p?(N=(0,X.jsx)(`img`,{...i,ref:_,src:c,alt:g,width:p,height:r,className:A,onLoad:j,onError:M}),t[36]=g,t[37]=r,t[38]=i,t[39]=c,t[40]=A,t[41]=j,t[42]=M,t[43]=p,t[44]=N):N=t[44];let P;return t[45]!==C||t[46]!==h||t[47]!==O||t[48]!==N||t[49]!==D?(P=(0,X.jsxs)(`span`,{"data-testid":h,className:D,style:C,children:[O,N]}),t[45]=C,t[46]=h,t[47]=O,t[48]=N,t[49]=D,t[50]=P):P=t[50],P}function RO(e){return e??`lazy`}function zO(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function BO(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:$t(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=zO(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=zO(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=RO(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,X.jsx)(LO,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function VO(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(PO,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(BO,{...e})}),t[1]=e,t[2]=r),r}var HO=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-qwlL5fSd.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,X.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function UO(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function WO(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(UO,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(UO,{formula:n,id:e.id}),children:(0,X.jsx)(HO,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var GO=null;function KO(){return GO||=n(()=>import(`./mermaid.core-DKgSmEOt.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw GO=null,e}),GO}function qO(e){let t=(0,J.c)(22),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={status:`idle`,svg:``,error:``},t[3]=o):o=t[3];let[s,c]=(0,Y.useState)(o),l,u;if(t[4]!==n||t[5]!==a?(l=()=>{if(!n.trim()){c({status:`idle`,svg:``,error:``});return}let e=!1;return c(JO),KO().then(async t=>{try{let r=await t.render(a,n);e||c({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||c({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||c({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},u=[n,a],t[4]=n,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),(0,Y.useEffect)(l,u),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(s.status===`error`){let e;t[9]===n?e=t[10]:(e=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[9]=n,t[10]=e);let r;t[11]===s.error?r=t[12]:(r=(0,X.jsx)(`p`,{className:`mermaid-error-message`,children:s.error}),t[11]=s.error,t[12]=r);let i;return t[13]!==s.error||t[14]!==e||t[15]!==r?(i=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:s.error,children:[e,r]}),t[13]=s.error,t[14]=e,t[15]=r,t[16]=i):i=t[16],i}let d=`mermaid mermaid-${s.status}`,f;t[17]===s.svg?f=t[18]:(f={__html:s.svg},t[17]=s.svg,t[18]=f);let p;return t[19]!==d||t[20]!==f?(p=(0,X.jsx)(`div`,{className:d,"data-component-type":`mermaid`,dangerouslySetInnerHTML:f}),t[19]=d,t[20]=f,t[21]=p):p=t[21],p}function JO(e){return{...e,status:`rendering`}}var YO=null;function XO(){return YO||=new oe({extensions:Me}),YO}function ZO(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=ZO(e,t);if(n)return n}return null}function QO(e){return at({type:`root`,children:e.children??[]})}var $O=new Map,ek=30,tk=150,nk=1e4;function rk(e,t){let n=`${e}|${t}`,r=$O.get(n);if(r)return r.refcount+=1,r;let i=new xm,a=new dE({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),$O.set(n,s),$O.size>ek&&console.warn(`[Mirror] provider pool exceeded ${ek} entries (current=${$O.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function ik(e,t){let n=`${e}|${t}`,r=$O.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}$O.delete(n)}}function ak(e,t){let n=(0,J.c)(8),{collabUrl:r}=hx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=rk(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=XO().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=ZO(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=QO(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},tk)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},nk);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,ik(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Y.useEffect)(d,f),a}function ok(e){let t=(0,J.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,X.jsx)(Ki,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(Ji,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sk(e){let t=(0,J.c)(29),n=e.src??``,r=e.anchor??``,i=ak(n,r);if(i.kind===`empty-props`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror — pick a source.`}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`code`,{children:`src`}),t[1]=n):n=t[1];let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`code`,{children:`anchor`}),t[2]=r):r=t[2];let i;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsxs)(ok,{tone:`placeholder`,children:[e,` Set `,n,` +`,` `,r,` via the property panel to point at a `,(0,X.jsx)(`code`,{children:`<MirrorSource>`}),` `,`elsewhere.`]}),t[3]=i):i=t[3],i}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;return t[4]===e?i=t[5]:(i=(0,X.jsxs)(ok,{tone:`placeholder`,children:[`Mirror loading `,(0,X.jsx)(`code`,{children:e})]}),t[4]=e,t[5]=i),i}if(i.kind===`source-removed`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror source removed.`}),t[6]=e):e=t[6];let r;return t[7]===n?r=t[8]:(r=(0,X.jsxs)(ok,{tone:`error`,children:[e,` The doc `,(0,X.jsx)(`code`,{children:n}),` is no longer available.`]}),t[7]=n,t[8]=r),r}if(i.kind===`anchor-not-found`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror anchor not found.`}),t[9]=e):e=t[9];let i;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`code`,{children:`<MirrorSource id="`}),t[10]=i):i=t[10];let a;t[11]===r?a=t[12]:(a=(0,X.jsx)(`code`,{children:r}),t[11]=r,t[12]=a);let o;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`code`,{children:`">`}),t[13]=o):o=t[13];let s;t[14]===n?s=t[15]:(s=(0,X.jsx)(`code`,{children:n}),t[14]=n,t[15]=s);let c;return t[16]!==a||t[17]!==s?(c=(0,X.jsxs)(ok,{tone:`error`,children:[e,` No`,` `,i,a,o,` exists in `,s,`.`]}),t[16]=a,t[17]=s,t[18]=c):c=t[18],c}let a;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Ei,{className:`size-3`,"aria-hidden":`true`}),t[19]=a):a=t[19];let o;t[20]===n?o=t[21]:(o=(0,X.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,X.jsxs)(`span`,{children:[`Mirror of `,(0,X.jsx)(`code`,{className:`font-mono`,children:n})]})]}),t[20]=n,t[21]=o);let s;t[22]===i.html?s=t[23]:(s=(0,X.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[22]=i.html,t[23]=s);let c;return t[24]!==r||t[25]!==n||t[26]!==o||t[27]!==s?(c=(0,X.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[o,s]}),t[24]=r,t[25]=n,t[26]=o,t[27]=s,t[28]=c):c=t[28],c}function ck(e){let t=(0,J.c)(9),n=e.id??``,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(Ti,{className:`size-3`,"aria-hidden":`true`}),t[0]=r):r=t[0];let i=n||`(no id)`,a;t[1]===i?a=t[2]:(a=(0,X.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[r,(0,X.jsxs)(`span`,{children:[`Mirror source `,(0,X.jsx)(`code`,{className:`font-mono`,children:i})]})]}),t[1]=i,t[2]=a);let o;t[3]===e.children?o=t[4]:(o=(0,X.jsx)(`div`,{children:e.children}),t[3]=e.children,t[4]=o);let s;return t[5]!==n||t[6]!==a||t[7]!==o?(s=(0,X.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":n,children:[a,o]}),t[5]=n,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}var lk=24,uk=24,dk=12,fk=.1;function pk(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(fk,(n-lk)/t.naturalWidth);case`fit-height`:return Math.max(fk,(r-uk)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(fk,((n-lk)/2-dk)/t.naturalWidth)}}var mk=600,hk=.5,gk=3,_k=.25,vk=null;function yk(){return vk||(vk=(async()=>{let e=await n(()=>import(`./pdf-wFLJduM2.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-CP44mBOj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),vk.catch(()=>{vk=null})),vk}function bk(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function xk(e){let t=(0,J.c)(85),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=qt(e.anchor);n=i===null?e.fillContainer?`100%`:`${mk}px`:`${i}px`,r=Dk(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,a=(0,Y.useRef)(null),o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[4]=o):o=t[4];let s=(0,Y.useRef)(o),c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[5]=c):c=t[5];let l=(0,Y.useRef)(c),u=(0,Y.useRef)(null),d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[6]=d):d=t[6];let[f,p]=(0,Y.useState)(d),[m,h]=(0,Y.useState)(!0),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(i??1),[b,x]=(0,Y.useState)(String(i??1)),[S,C]=(0,Y.useState)(1),[w,T]=(0,Y.useState)(`fit-width`),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(0),[M,N]=(0,Y.useState)(0),P=f.length,F,I;t[7]===e.src?(F=t[8],I=t[9]):(F=()=>{if(!e.src){h(!1);return}let t=$t(e.src),n=!1,r=null;return h(!0),_(null),(async()=>{try{let e=await(await yk()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,u.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;p(i)}catch(e){let t=e;if(n)return;_(t instanceof Error?t.message:`Failed to load PDF`),h(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),u.current=null}},I=[e.src],t[7]=e.src,t[8]=F,t[9]=I),(0,Y.useEffect)(F,I);let L,ee;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=a.current;if(!e)return;let t=()=>{j(e.clientWidth),N(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ee=[],t[10]=L,t[11]=ee):(L=t[10],ee=t[11]),(0,Y.useEffect)(L,ee);let R,te;t[12]!==M||t[13]!==A||t[14]!==w||t[15]!==f||t[16]!==S?(R=()=>{let e=u.current;if(!e||f.length===0||A===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of f){if(t)return;let a=s.current[i.pageNumber-1];if(!a)continue;let o=pk(w,i,A,M)*S,c=await e.getPage(i.pageNumber);if(t)return;let l=c.getViewport({scale:o});a.width=Math.floor(l.width*r),a.height=Math.floor(l.height*r),a.style.width=`${l.width}px`,a.style.height=`${l.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=c.render({canvas:a,canvasContext:u,viewport:l}),await n.promise,n=null)}t||h(!1)}catch(e){let n=e;if(t||bk(n))return;console.warn(`[Pdf] page render failed:`,n),_(n instanceof Error?n.message:`Failed to render PDF`),h(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},te=[f,w,S,A,M],t[12]=M,t[13]=A,t[14]=w,t[15]=f,t[16]=S,t[17]=R,t[18]=te):(R=t[17],te=t[18]),(0,Y.useEffect)(R,te);let ne,re;t[19]!==f||t[20]!==E?(ne=()=>{if(!E)return;let e=u.current;if(!e||f.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of f){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;bk(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},re=[E,f],t[19]=f,t[20]=E,t[21]=ne,t[22]=re):(ne=t[21],re=t[22]),(0,Y.useEffect)(ne,re);let z,B;t[23]!==m||t[24]!==i?(z=()=>{if(m||!i)return;let e=a.current,t=s.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},B=[m,i],t[23]=m,t[24]=i,t[25]=z,t[26]=B):(z=t[25],B=t[26]),(0,Y.useEffect)(z,B);let ie,V;t[27]===f?(ie=t[28],V=t[29]):(ie=()=>{let e=a.current;if(!e||f.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of f){let i=s.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}y(r),x(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},V=[f],t[27]=f,t[28]=ie,t[29]=V),(0,Y.useEffect)(ie,V);let H,U;t[30]===O?(H=t[31],U=t[32]):(H=()=>{if(!O)return;let e=e=>{let t=e.target,n=a.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){k(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&k(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},U=[O],t[30]=O,t[31]=H,t[32]=U),(0,Y.useEffect)(H,U);let ae;t[33]===P?ae=t[34]:(ae=e=>{let t=Math.max(1,Math.min(P||1,e));y(t),x(String(t));let n=a.current,r=s.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[33]=P,t[34]=ae);let oe=ae,se;t[35]!==v||t[36]!==oe||t[37]!==b?(se=()=>{let e=Number.parseInt(b,10);if(Number.isNaN(e)){x(String(v));return}oe(e)},t[35]=v,t[36]=oe,t[37]=b,t[38]=se):se=t[38];let ce=se,le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>C(Tk),t[39]=le):le=t[39];let ue=le,de;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>C(wk),t[40]=de):de=t[40];let fe=de,pe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{T(e),k(!1),C(1)},t[41]=pe):pe=t[41];let me=pe,he;t[42]===n?he=t[43]:(he={height:n},t[42]=n,t[43]=he);let ge;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>D(Ck),t[44]=ge):ge=t[44];let _e=E?`Hide thumbnails`:`Show thumbnails`,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(na,{size:14,"aria-hidden":`true`}),t[45]=ve):ve=t[45];let ye;t[46]!==E||t[47]!==_e?(ye=(0,X.jsx)(`button`,{type:`button`,onClick:ge,"aria-label":_e,"aria-pressed":E,className:`ok-pdf-btn`,title:`Toggle thumbnails`,children:ve}),t[46]=E,t[47]=_e,t[48]=ye):ye=t[48];let be=e.title??`PDF`,xe;t[49]===be?xe=t[50]:(xe=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:be}),t[49]=be,t[50]=xe);let Se;t[51]!==O||t[52]!==w||t[53]!==b||t[54]!==ce||t[55]!==P||t[56]!==S?(Se=P>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),ce()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:b,onChange:e=>x(e.target.value.replace(/[^0-9]/g,``)),onBlur:ce,"aria-label":`Page number`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-page-of`,children:[`of `,P]}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:fe,disabled:S<=hk,"aria-label":`Zoom out`,className:`ok-pdf-btn`,title:`Zoom out`,children:(0,X.jsx)(Ca,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(S*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:S>=gk,"aria-label":`Zoom in`,className:`ok-pdf-btn`,title:`Zoom in`,children:(0,X.jsx)(Sa,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>k(Sk),"aria-label":`Layout options`,"aria-haspopup":`menu`,"aria-expanded":O,className:`ok-pdf-btn`,title:`Layout`,children:(0,X.jsx)(vi,{size:14,"aria-hidden":`true`})}),O&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(Ek,{label:`Fit width`,active:w===`fit-width`,onSelect:()=>me(`fit-width`)}),(0,X.jsx)(Ek,{label:`Fit height`,active:w===`fit-height`,onSelect:()=>me(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(Ek,{label:`Single page`,active:w===`single`,onSelect:()=>me(`single`)}),(0,X.jsx)(Ek,{label:`Two-page (odd)`,active:w===`two-odd`,onSelect:()=>me(`two-odd`)}),(0,X.jsx)(Ek,{label:`Two-page (even)`,active:w===`two-even`,onSelect:()=>me(`two-even`)})]})]})]}),t[51]=O,t[52]=w,t[53]=b,t[54]=ce,t[55]=P,t[56]=S,t[57]=Se):Se=t[57];let Ce;t[58]!==ye||t[59]!==xe||t[60]!==Se?(Ce=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ye,xe,Se]}),t[58]=ye,t[59]=xe,t[60]=Se,t[61]=Ce):Ce=t[61];let we;t[62]!==v||t[63]!==oe||t[64]!==f||t[65]!==E?(we=E&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":`Page thumbnails`,children:f.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":v===e.pageNumber||void 0,onClick:()=>oe(e.pageNumber),"aria-label":`Jump to page ${e.pageNumber}`,children:[(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:e.pageNumber})]},e.pageNumber))}),t[62]=v,t[63]=oe,t[64]=f,t[65]=E,t[66]=we):we=t[66];let Te;t[67]===m?Te=t[68]:(Te=m&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:`Loading PDF`}),t[67]=m,t[68]=Te);let Ee;t[69]===g?Ee=t[70]:(Ee=g&&(0,X.jsxs)(`div`,{className:`ok-pdf-error`,children:[`Failed to load PDF: `,g]}),t[69]=g,t[70]=Ee);let W;t[71]===P?W=t[72]:(W=Array.from({length:P},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{s.current[t]=e},className:`ok-pdf-page`,"aria-label":`Page ${n}`},n)}),t[71]=P,t[72]=W);let De;t[73]!==w||t[74]!==Te||t[75]!==Ee||t[76]!==W?(De=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:a,"data-layout":w,children:[Te,Ee,W]}),t[73]=w,t[74]=Te,t[75]=Ee,t[76]=W,t[77]=De):De=t[77];let Oe;t[78]!==we||t[79]!==De?(Oe=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[we,De]}),t[78]=we,t[79]=De,t[80]=Oe):Oe=t[80];let ke;return t[81]!==he||t[82]!==Ce||t[83]!==Oe?(ke=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:he,children:[Ce,Oe]}),t[81]=he,t[82]=Ce,t[83]=Oe,t[84]=ke):ke=t[84],ke}function Sk(e){return!e}function Ck(e){return!e}function wk(e){return Math.max(hk,+(e-_k).toFixed(2))}function Tk(e){return Math.min(gk,+(e+_k).toFixed(2))}function Ek(e){let t=(0,J.c)(8),n=e.active||void 0,r=e.active?`✓`:``,i;t[0]===r?i=t[1]:(i=(0,X.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==e.active||t[3]!==e.label||t[4]!==e.onSelect||t[5]!==n||t[6]!==i?(a=(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[2]=e.active,t[3]=e.label,t[4]=e.onSelect,t[5]=n,t[6]=i,t[7]=a):a=t[7],a}function Dk(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function Ok(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,X.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var kk=`[data-component-type="tabs"]`,Ak=`[data-node-view-content-react] > .react-renderer`;function jk(e){let t=e.closest(kk);return t?Array.from(e.querySelectorAll(Ak)).filter(e=>e.parentElement?.closest(kk)===t).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}}):[]}function Mk(e){let t=(0,J.c)(26),{id:n,children:r}=e,[i,a]=(0,Y.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[s,c]=(0,Y.useState)(o),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(0),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=l.current;if(!e)return;let t=jk(e);c(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=f):f=t[1],(0,Y.useLayoutEffect)(f);let p,m;t[2]===s.length?(p=t[3],m=t[4]):(p=()=>{s.length>d.current&&s.length>0&&a(s.length-1),d.current=s.length},m=[s.length],t[2]=s.length,t[3]=p,t[4]=m),(0,Y.useLayoutEffect)(p,m);let h;t[5]===n?h=t[6]:(h=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=l.current;if(!t)return;let r=jk(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=h),(0,Y.useLayoutEffect)(h);let g=s.length===0?0:Math.min(Math.max(i,0),s.length-1),_;t[7]!==s.length||t[8]!==g?(_=e=>{if(s.length===0)return;let t=null;e.key===`ArrowRight`?t=(g+1)%s.length:e.key===`ArrowLeft`?t=(g-1+s.length)%s.length:e.key===`Home`?t=0:e.key===`End`&&(t=s.length-1),t!==null&&(e.preventDefault(),a(t),(u.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=s.length,t[8]=g,t[9]=_):_=t[9];let v=_,y=n?`Tabs: ${n}`:`Tabs`,b;if(t[10]!==s||t[11]!==g){let e;t[13]===g?e=t[14]:(e=e=>(0,X.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===g,"aria-selected":e.index===g,"aria-controls":e.panelId??void 0,tabIndex:e.index===g?0:-1,onMouseDown:Nk,onClick:()=>a(e.index),children:e.label},e.index),t[13]=g,t[14]=e),b=s.map(e),t[10]=s,t[11]=g,t[12]=b}else b=t[12];let x;t[15]!==v||t[16]!==y||t[17]!==b?(x=(0,X.jsx)(`div`,{ref:u,role:`tablist`,"aria-label":y,className:`tabs-strip`,contentEditable:!1,onKeyDown:v,children:b}),t[15]=v,t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==g?(S=(0,X.jsx)(`div`,{ref:l,className:`tabs-content`,"data-active-index":g,children:r}),t[19]=r,t[20]=g,t[21]=S):S=t[21];let C;return t[22]!==n||t[23]!==S||t[24]!==x?(C=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[x,S]}),t[22]=n,t[23]=S,t[24]=x,t[25]=C):C=t[25],C}function Nk(e){return e.preventDefault()}var Pk={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Fk=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Pk[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function Ik(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Lk(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Y.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Fk(e.id,_,g,l):null,y=Y.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Y.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:Ik(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var Rk=Y.forwardRef(Lk);function zk(e){return e!==!1}function Bk(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Vk(e){if(e.width!==void 0)return{width:e.width}}function Hk(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Uk(e){let t=(0,J.c)(25),n;if(t[0]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:We(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Vk(e),s;t[2]===e.poster?s=t[3]:(s=e.poster===void 0?void 0:$t(e.poster),t[2]=e.poster,t[3]=s);let c=(0,X.jsx)(Rk,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Bk(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Hk(e)}),l;t[4]!==o||t[5]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[4]=o,t[5]=c,t[6]=l):l=t[6],n=l;break bb0}}t[0]=e,t[1]=n}else n=t[1];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[7]===e.src?r=t[8]:(r=e.src===void 0?void 0:$t(e.src),t[7]=e.src,t[8]=r);let i=e.title,a;t[9]===e.controls?a=t[10]:(a=zk(e.controls),t[9]=e.controls,t[10]=a);let o;t[11]===e.poster?o=t[12]:(o=e.poster===void 0?void 0:$t(e.poster),t[11]=e.poster,t[12]=o);let s;return t[13]!==e.autoplay||t[14]!==e.height||t[15]!==e.loop||t[16]!==e.muted||t[17]!==e.playsinline||t[18]!==e.preload||t[19]!==e.title||t[20]!==e.width||t[21]!==r||t[22]!==a||t[23]!==o?(s=(0,X.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[13]=e.autoplay,t[14]=e.height,t[15]=e.loop,t[16]=e.muted,t[17]=e.playsinline,t[18]=e.preload,t[19]=e.title,t[20]=e.width,t[21]=r,t[22]=a,t[23]=o,t[24]=s):s=t[24],s}function Wk(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Gk={Callout:GD,img:VO,video:Uk,audio:zD,Pdf:xk,File:iO,Embed:nO,Accordion:LD,Tabs:Mk,Tab:Ok,Math:WO,MermaidFence:qO,Mirror:sk,MirrorSource:ck,"*":Wk};function Kk(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var qk=Yt(),Jk=new Map;function Yk(e){if(e.surface===`compat`){let t=Gk[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Kk(e.props)}}let t=Gk[e.name];return t?{Component:t,reactNodePropNames:Kk(e.props)}:null}for(let[e,t]of qk.entries()){let n=Yk(t);n&&Jk.set(e,n)}function Xk(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Zk(e){let t=qk.getOrWildcard(e),n=Jk.get(t.name)??Jk.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Xk(t,n)}function Qk(){let e=[];for(let[t,n]of qk.entries()){if(t===`*`)continue;let r=Jk.get(t);r&&e.push(Xk(n,r))}return e}var $k=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,eA=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,tA={Callout:{description:`Highlight tips, warnings, and notes.`,props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:`Collapsible section with a clickable summary.`,props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:`Embed an image with optional alt text.`,props:{src:$k,alt:`Sample image`}},video:{description:`Embed a video with native player controls.`,props:{controls:!0,poster:eA}},audio:{description:`Embed an audio file with native player controls.`,props:{controls:!0}},Math:{description:`Block math equation rendered with KaTeX from a LaTeX source string.`,props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:`Embed an external page in an inline iframe (docs, demos, Figma, CodeSandbox).`,render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:`Multi-page PDF viewer with toolbar controls (thumbnails, page nav, zoom).`,render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:`Diagram from Mermaid source — flowchart, sequence, class, state, ER, gantt, pie.`,render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:`Horizontal pill strip + active panel below; click a pill to switch panels.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Active panel content for the selected tab shows here.`})]})},Mirror:{description:`Read-only copy of a MirrorSource block from another doc. Edit at the source — every Mirror reflects the change live.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Di,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Mirror of `,(0,X.jsx)(`code`,{className:`font-mono`,children:`api-spec`})]})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:`Edits at the source land here — no copy-paste drift.`})]})},MirrorSource:{description:`Mark a block as the source of truth. Mirror references elsewhere render this content read-only and update live as you edit here.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Ti,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Mirror source `,(0,X.jsx)(`code`,{className:`font-mono`,children:`api-spec`})]})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:`Authoritative content; mirrored verbatim everywhere it's referenced.`})]})}};function nA(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function rA(e){let t=Zk(e),n=nA(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var iA=new Set;function aA(e){iA.add(e)}function oA(e){if(typeof e==`number`)return iA.delete(e);let t=iA.values().next();return t.done?!1:(iA.delete(t.value),!0)}function sA(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(aA(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function cA(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=rA(e.name);if(e.name===`Tabs`){let e=rA(`Tab`),t=rA(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&sA(t,i,e)}}var lA=new Set([`File`,`Tab`]);function uA(){return[{name:`component-File`,label:`File`,icon:Mi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:fA,preview:{description:`Notion-style inline row for a downloadable file. Drag-drop also works.`,render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(Mi,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function dA(){return[...Qk().filter(e=>e.surface===`canonical`&&!lA.has(e.name)).map(e=>{let t=tA[e.name],n=e.Component,r=t?{description:t.description,render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:PD(e.icon),category:e.category??`content`,command:cA(e),aliases:e.searchTerms,description:e.description,preview:r}}),...uA()]}function fA(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;jD(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function pA(){return[{name:`component-Tag`,label:`Tag`,icon:Ri,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:`Inline hashtag for cross-doc grouping.`,render:()=>(0,X.jsxs)(`p`,{className:`text-sm leading-7`,children:[`See`,` `,(0,X.jsx)(`a`,{className:`tag pointer-events-none`,children:`#design-docs`}),` for the latest specs.`]})},command:e=>{e.chain().insertTag(``).run()}}]}var mA=[{name:`heading1`,label:`Heading 1`,icon:zi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:`Big section heading.`,render:()=>(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Heading 1`})}},{name:`heading2`,label:`Heading 2`,icon:Bi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:`Medium section heading.`,render:()=>(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Heading 2`})}},{name:`heading3`,label:`Heading 3`,icon:Vi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:`Small section heading.`,render:()=>(0,X.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:`Heading 3`})}},{name:`bulletList`,label:`Bullet List`,icon:Zi,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:`Unordered list of items.`,render:()=>(0,X.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:`First item`}),(0,X.jsx)(`li`,{children:`Second item`})]})}},{name:`orderedList`,label:`Ordered List`,icon:Yi,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:`Numbered list of items.`,render:()=>(0,X.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:`First item`}),(0,X.jsx)(`li`,{children:`Second item`})]})}},{name:`taskList`,label:`Task List`,icon:Xi,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:`Checklist with checkboxes.`,render:()=>(0,X.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:`Done`})]}),(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{children:`To do`})]})]})}},{name:`blockquote`,label:`Quote`,icon:sa,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:`Indented blockquote for citations.`,render:()=>(0,X.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:`A pull quote stands out from the surrounding text.`})}},{name:`codeBlock`,label:`Code Block`,icon:wi,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`],preview:{description:`Fenced code block with monospace text.`,render:()=>(0,X.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,X.jsx)(`code`,{children:`const greeting = "Hello";
6
+ `);return/\s/.test(n)}):!1}var _y=new W(`suggestion`);function vy({pluginKey:e=_y,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=hy,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,w=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!gy(i);function T(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let E=new Oe({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!w({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=E.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=E.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),T(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=E.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),C.create(e.doc,[we.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return E}var yy=vy;function by(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function xy(e){if(e.kind===`create`)return`Create new tag #${e.value}`;let t=e.count===1?`1 use`:`${e.count} uses`;return`Tag #${e.value}, ${t}`}function Sy(e){let t=(0,J.c)(32),{items:n,query:r,selectedIndex:i,onSelect:a,onHover:o,loading:s,error:c}=e,l=s===void 0?!1:s,u=c===void 0?null:c,d=(0,Y.useRef)(null),f=(0,Y.useId)(),p=i>=0&&i<n.length?`${f}-option-${i}`:void 0,m,h;t[0]===i?(m=t[1],h=t[2]):(m=()=>{let e=d.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},h=[i],t[0]=i,t[1]=m,t[2]=h),(0,Y.useEffect)(m,h);let g=Cy;if(l){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{ref:d,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:g,children:`Loading tags`}),t[3]=e):e=t[3],e}if(n.length===0){let e;t[4]===r?e=t[5]:(e=r.trim(),t[4]=r,t[5]=e);let n=e,i=u??(n?`No tags match "${n}". Continue typing to create one.`:`No tags yet. Continue typing to create one.`),a;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(a={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[6]=a):a=t[6];let o;return t[7]===i?o=t[8]:(o=(0,X.jsx)(`div`,{ref:d,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:a,onMouseDown:g,children:i}),t[7]=i,t[8]=o),o}let _=i>=0&&i<n.length?n[i]:null,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=v):v=t[9];let y;t[10]===_?y=t[11]:(y=_?xy(_):``,t[10]=_,t[11]=y);let b;t[12]===y?b=t[13]:(b=(0,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:y}),t[12]=y,t[13]=b);let x;t[14]===u?x=t[15]:(x=u&&(0,X.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:u}),t[14]=u,t[15]=x);let S;if(t[16]!==n||t[17]!==f||t[18]!==o||t[19]!==a||t[20]!==i){let e;t[22]!==f||t[23]!==o||t[24]!==a||t[25]!==i?(e=(e,t)=>{let n=t===i,r=by(e),s=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${f}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":s?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},onPointerMove:o?()=>o(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),s?(0,X.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:`New`}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[22]=f,t[23]=o,t[24]=a,t[25]=i,t[26]=e):e=t[26],S=n.map(e),t[16]=n,t[17]=f,t[18]=o,t[19]=a,t[20]=i,t[21]=S}else S=t[21];let C;return t[27]!==p||t[28]!==b||t[29]!==x||t[30]!==S?(C=(0,X.jsxs)(`div`,{ref:d,role:`listbox`,"aria-label":`Tag suggestions`,"aria-activedescendant":p,tabIndex:-1,onMouseDown:g,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:v,children:[b,x,S]}),t[27]=p,t[28]=b,t[29]=x,t[30]=S,t[31]=C):C=t[31],C}function Cy(e){return e.preventDefault()}var wy=new WeakMap;function Ty(e,t){wy.set(e,t)}function Ey(e){return wy.get(e)??!1}function Dy(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),en(r,n,{placement:`bottom-start`,middleware:[ge(4),f(),Se({padding:8}),x({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>ue(r,n,o),reveal:()=>{a||(i=!0,o())}}}function Oy(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var ky=new W(`tagSuggestion`),Ay=8,jy=/^[a-zA-Z][\w/-]*$/;async function My(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function Ny(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function Py(e,t){let n=Ny(e,t).slice(0,Ay).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&jy.test(r)&&!e.some(e=>e.name===r)&&n.unshift({kind:`create`,value:r}),n}function Fy(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function Iy(e){let t=[],n=!1,r=null,i=null;return yy({editor:e,pluginKey:ky,char:`#`,allowedPrefixes:null,findSuggestionMatch:Fy,allow:({editor:e})=>!Ey(e),items:async({query:e})=>{if(!n){r||=My();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return Py(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!jy.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Dy(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new El(Sy,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&jy.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){Oy(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var Ly=1,Ry=.9,zy=.8,By=.17,Vy=.1,Hy=.999,Uy=.9999,Wy=.99,Gy=/[\\\/_+.#"@\[\(\{&]/,Ky=/[\\\/_+.#"@\[\(\{&]/g,qy=/[\s-]/,Jy=/[\s-]/g;function Yy(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ly:Wy;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Yy(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ly:Gy.test(e.charAt(l-1))?(d*=zy,p=e.slice(i,l-1).match(Ky),p&&i>0&&(d*=Hy**+p.length)):qy.test(e.charAt(l-1))?(d*=Ry,m=e.slice(i,l-1).match(Jy),m&&i>0&&(d*=Hy**+m.length)):(d*=By,i>0&&(d*=Hy**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Uy)),(d<Vy&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Yy(e,t,n,r,l+1,a+2,o),f*Vy>d&&(d=f*Vy)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Xy(e){return e.toLowerCase().replace(Jy,` `)}function Zy(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Yy(e,t,Xy(e),Xy(t),0,0,{})}var Qy=`[cmdk-group=""]`,$y=`[cmdk-group-items=""]`,eb=`[cmdk-group-heading=""]`,tb=`[cmdk-item=""]`,nb=`${tb}:not([aria-disabled="true"])`,rb=`cmdk-item-select`,ib=`data-value`,ab=(e,t,n)=>Zy(e,t,n),ob=Y.createContext(void 0),sb=()=>Y.useContext(ob),cb=Y.createContext(void 0),lb=()=>Y.useContext(cb),ub=Y.createContext(void 0),db=Y.forwardRef((e,t)=>{let n=Tb(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Tb(()=>new Set),i=Tb(()=>new Map),a=Tb(()=>new Map),o=Tb(()=>new Set),s=Cb(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=gn(),y=gn(),b=gn(),x=Y.useRef(null),S=Ob();wb(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),wb(()=>{S(6,k)},[]);let C=Y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ab;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest($y);t?t.appendChild(e.parentElement===t?e:e.closest(`${$y} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${$y} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Qy}[${ib}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(ib);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Qy)?.querySelector(eb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${tb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(nb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(ib))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(ib))}function P(e){let t=A()?.closest(Qy),n;for(;t&&!n;)t=e>0?xb(t,Qy):Sb(t,Qy),n=t?.querySelector(nb);n?C.setState(`value`,n.getAttribute(ib)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Y.createElement(fn.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(rb);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:jb},c),Ab(e,e=>Y.createElement(cb.Provider,{value:C},Y.createElement(ob.Provider,{value:w},e))))}),fb=Y.forwardRef((e,t)=>{let n=gn(),r=Y.useRef(null),i=Y.useContext(ub),a=sb(),o=Cb(e),s=o.current?.forceMount??i?.forceMount;wb(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Db(n,r,[e.value,e.children,r],e.keywords),l=lb(),u=Eb(e=>e.value&&e.value===c.current),d=Eb(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(rb,f),()=>t.removeEventListener(rb,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Y.createElement(fn.div,{ref:xn(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),pb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=gn(),s=Y.useRef(null),c=Y.useRef(null),l=gn(),u=sb(),d=Eb(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);wb(()=>u.group(o),[]),Db(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(fn.div,{ref:xn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Ab(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(ub.Provider,{value:f},e))))}),mb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=Eb(e=>!e.search);return!n&&!a?null:Y.createElement(fn.div,{ref:xn(i,t),...r,"cmdk-separator":``,role:`separator`})}),hb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=lb(),o=Eb(e=>e.search),s=Eb(e=>e.selectedItemId),c=sb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(fn.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),gb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Eb(e=>e.selectedItemId),c=sb();return Y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Y.createElement(fn.div,{ref:xn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Ab(e,e=>Y.createElement(`div`,{ref:xn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),_b=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(jn,{open:n,onOpenChange:r},Y.createElement(Pn,{container:o},Y.createElement(Dn,{"cmdk-overlay":``,className:i}),Y.createElement(En,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(db,{ref:t,...s}))))}),vb=Y.forwardRef((e,t)=>Eb(e=>e.filtered.count===0)?Y.createElement(fn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),yb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(fn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ab(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),bb=Object.assign(db,{List:gb,Item:fb,Input:hb,Group:pb,Separator:mb,Dialog:_b,Empty:vb,Loading:yb});function xb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Sb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Cb(e){let t=Y.useRef(e);return wb(()=>{t.current=e}),t}var wb=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function Tb(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function Eb(e){let t=lb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function Db(e,t,n,r=[]){let i=Y.useRef(),a=sb();return wb(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(ib,s),i.current=s}),i}var Ob=()=>{let[e,t]=Y.useState(),n=Tb(()=>new Map);return wb(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function kb(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Ab({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(kb(t),{ref:t.ref},n(t.props.children)):n(t)}var jb={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Mb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nb(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=nn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Tn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(wn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=nn(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(Mb,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(kn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)(Ln,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function Pb(e){let t=(0,J.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(ca,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=nn(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)(bb.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Fb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ib(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(bb.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Lb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Rb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(bb.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zb(e){let t=(0,J.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=nn(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function Bb(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:_(n)??t}}function Vb(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var Hb=new Map,Ub=null;function Wb(){return Zs(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Gb(){if(Ub!==null)return;let e=Math.max(50,Math.floor(Wb()/2));Ub=setTimeout(()=>{Ub=null,Kb(Date.now()),Hb.size>0&&Gb()},e)}function Kb(e){let t=Wb();for(let[n,r]of Hb)e-r.emittedAt>=t&&(Hb.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function qb(e,t,n=Date.now()){Hb.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),Hb.set(e,{poolEventId:t,emittedAt:n}),Gb()}function Jb(e,t,n=Date.now()){let r=Hb.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Wb()?!1:(Hb.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}pt({event:ze(`ok-branch-switched-clear-failed`),branch:Kt(),docName:Kt(),reason:Kt()});async function Yb(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function Xb(e){let t=!1;return()=>{t?e():t=!0}}function Zb(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Qb(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ft.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&Yb(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Zb(n)}catch{}e.observeDiskAckBatch(t)}}async function $b(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function ex(e){return cx(e,Fe)}function tx(e){return cx(e,Ut)}function nx(e){return cx(e,Tt)}function rx(e){return cx(e,ot)}function ix(e){return cx(e,Bt)}function ax(e){let t=cx(e,kt);if(!t)return null;try{return{docName:t.docName,sv:ox(t.sv)}}catch{return null}}function ox(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function sx(e,t){let n=tx(e);if(n){t.onServerInfo?.(n);return}let r=nx(e);if(r){t.onBranchSwitched?.(r);return}let i=ax(e);if(i){t.onDiskAck?.(i);return}let a=ex(e);if(a){t.onDerivedView?.(a);return}let o=rx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=ix(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function cx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function lx(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function ux(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function dx(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var fx=2e3,px=15e3;function mx(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??fx,r=e.maxDelayMs??px,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function hx(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=ux(window);if(t){r(dx(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(dx(t))});return()=>{n()}}let n=mx({fetchConfig:$b,fallbackUrl:lx,now:Date.now,setTimeout:yx,clearTimeout:vx,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(_x),s(gx)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function gx(e){return e+1}function _x(e){return{...e,terminal:!1,lastError:null}}function vx(e){return globalThis.clearTimeout(e)}function yx(e,t){return globalThis.setTimeout(e,t)}var bx=new Map,xx=new Set;function Sx(){for(let e of xx)e()}function Cx(e,t){bx.set(e,t),Sx()}function wx(e,t){bx.get(e)===t&&(bx.delete(e),Sx())}function Tx(e){return bx.get(e)??null}function Ex(e){return xx.add(e),()=>xx.delete(e)}var Dx=new Map;function Ox(e){return Dx.get(e)}function kx(e,t){Dx.set(e,t)}function Ax(e){Dx.delete(e)}var jx=`open-knowledge-app`,Mx=new Map,Nx=new Set,Px=1024,Fx=1024;function Ix(){return Kn.getTracer(jx)}function Lx(e,t,n){if(Nx.has(e))return null;let r=Mx.get(e);if(r)return r;if(Mx.size>=Fx){let e=Mx.keys().next().value;if(e!==void 0){let t=Mx.get(e);Mx.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Ix().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Mx.set(e,i),i}function Rx(e,t,n,r,i){try{let a=Lx(e,n,r),o=a?Kn.setSpan(qn.active(),a.span):qn.active();Ix().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function zx(e,t){try{let n=Mx.get(e);if(n&&(Mx.delete(e),n.span.end(t??Date.now())),!Nx.has(e)){if(Nx.size>=Px){let e=Nx.values().next().value;e!==void 0&&Nx.delete(e)}Nx.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Bx=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function Vx(){return Zs(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function Hx(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Ux(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var Wx=new Map,Gx=new Set;function Kx(e){Gx.add(e);for(let[t,n]of Wx)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Gx.delete(e)}}function qx(e,t){for(let n of Gx)try{n(e,t.mountId)}catch{}}var Jx=!1;function Yx(){typeof document>`u`||document.visibilityState===`visible`&&Qx(Date.now())}function Xx(){Jx||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,Yx),Jx=!0)}function Zx(){Jx&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,Yx),Jx=!1))}function Qx(e){let t=Vx();for(let[n,r]of Wx)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Ux(r,n,e),qx(n,r))}function $x(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=Wx.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Ux(d,t,Date.now()),qx(t,d))},Vx()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,Hx(d),d.preMountEditor&&=(rS(t,d.preMountEditor,`aborted`),null),Wx.delete(t),Wx.size===0&&Zx(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new Bx(t)),zx(d.mountId))}),Wx.set(t,d),Xx(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),iS({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(rS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,Hx(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),zx(d.mountId)}),u}function eS(e){return Wx.get(e)?.resolved===!0}function tS(e){return Wx.get(e)?.controller??null}function nS(e){let t=Wx.get(e);t&&(t.settled=!0,Hx(t),t.preMountEditor&&=(rS(e,t.preMountEditor,`aborted`),null),Wx.delete(e),Wx.size===0&&Zx(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),zx(t.mountId),t.controller.abort())}function rS(e,t,n){let r=aS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function iS(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(zS(t)!==void 0){let e=CS({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,Hx(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),zx(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){rS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),zx(i.mountId);return}let l;try{l=CS({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){rS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,Hx(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),zx(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,Hx(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Rx(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),zx(i.mountId,d)}function aS(e){try{let t=e.state;return hv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var oS=Zs(`MAX_CACHE`,10),sS=Zs(`VIEW_COUNT_CACHE_THRESHOLD`,50),cS=Zs(`BYTES_CACHE_THRESHOLD`,8e6);function lS(e){return!(e.viewCount>0&&e.viewCount>=sS||e.bytes>cS)}var uS=new Map,dS=new Map,fS=new Map;function pS(e,t){if(fS.size>=oS){let e=fS.keys().next().value;e!==void 0&&fS.delete(e)}fS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function mS(e){return fS.get(e)??null}function hS(e){if(!fS.has(e))return;let t=fS.get(e)??null;fS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function gS(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function _S(e){try{let t=e.state.selection;return t instanceof s?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof j?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function vS(e){for(let t of e)try{let e=zS(t.fromDocName);e&&!e.editor.isDestroyed?pS(t.toDocName,{html:e.editor.getHTML(),scrollTop:gS(),selection:_S(e.editor)}):Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var yS=[],bS=[],xS=new Set;function SS(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function CS(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!lS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=uS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:Ox(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),jS(a,n),a.activeMountKey=t,NS(yS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:Ox(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:Ox(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;uS.size>=oS;){let e=PS(yS,t);if(!e)break;TS(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return uS.set(t,s),NS(yS,t),Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function wS(e){let t=e.activeMountKey;if(e.__uncached){t&&nS(t);let n=aS(e.editor);try{e.editor.destroy()}catch(e){Z(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=kS(e.editor);if(n){e.hadFocus=AS(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=SS(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function TS(e){nS(e);let t=uS.get(e);if(!t)return!1;let n=aS(t.editor);try{t.editor.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}uS.delete(e);let r=yS.indexOf(e);return r!==-1&&yS.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function ES(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!lS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=dS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:Ox(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),MS(a,n),a.activeMountKey=t,NS(bS,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:Ox(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:Ox(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;dS.size>=oS;){let e=PS(bS,t);if(!e)break;OS(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return dS.set(t,s),NS(bS,t),Z(`ok/cache/miss`,{docName:t,mountId:Ox(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:Ox(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function DS(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=AS(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=SS(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function OS(e){let t=dS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}dS.delete(e);let n=bS.indexOf(e);return n!==-1&&bS.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function kS(e){return e.editorView??null}function AS(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function jS(e,t){let n=kS(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function MS(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function NS(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function PS(e,t){for(let n of e)if(n!==t&&!xS.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:xS.size});for(let n of e)if(n!==t)return n;return null}function FS(e){let t=xS,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=LS(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=LS(e);if(!n)continue;let r=t=>{Z(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}xS=n}var IS=null;function LS(e){let t=uS.get(e);if(t)return t.provider;let n=dS.get(e);if(n)return n.provider;if(IS){let t=IS.entries.get(e);if(t)return t.provider}return null}function RS(e){IS=e;let t=e.onEvict(e=>{TS(e),OS(e)});return()=>{t(),IS===e&&(IS=null)}}function zS(e){return uS.get(e)}var BS=`ok-editor-tabs-v1:`,VS=`\0folder:`,HS=`\0asset:`,US=`\0doc-tab:`;function WS(e){let t=e.lastIndexOf(US);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function GS(e){return WS(e).baseTabId}function KS(e){if(typeof e!=`string`||e.length===0)return!1;let t=GS(e);return t.startsWith(VS)?t.length>8:t.startsWith(HS)?t.length>7:!0}function qS(e){return e}function JS(e,t){return`${GS(e)}${US}${t}`}function YS(e,t){return XS(e,qS(t))}function XS(e,t){let n=aC(e,2**53-1),r=GS(t);if(!n.includes(r))return r;let i=1,a;do a=JS(r,i),i++;while(n.includes(a));return a}function ZS(e,t){let n=GS(t);return aC(e,2**53-1).find(e=>GS(e)===n)??null}function QS(e,t){return GS(e)===GS(t)}function $S(e){return`${VS}${e}`}function eC(e){return`${HS}${e}`}function tC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function nC(e){switch(e.kind){case`doc`:case`folder-index`:return qS(e.docName);case`folder`:return $S(e.folderPath);case`missing`:return qS(e.target);case`asset`:return eC(e.assetPath)}}function rC(e){let t=GS(e);return t.startsWith(VS)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(HS)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function iC(e){let t=rC(e);return t.kind===`doc`?t.docName:null}function aC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(KS(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function oC(e,t){let n=new Set(aC(t,2**53-1));return aC(e,2**53-1).filter(e=>n.has(e))}function sC(e,t,n){if(t<=0)return[];let r=new Set(aC(n,2**53-1)),i=aC(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function cC(e,t,n){let r=oC(e,n);return!aC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function lC(e,t){return aC(e,2**53-1).filter(e=>e!==t)}function uC(e,t){let n=new Set(aC(t,2**53-1));return aC(e,2**53-1).filter(e=>!n.has(e))}function dC(e,t,n){let r=aC(e,2**53-1),i=oC(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?cC(i,n,r):lC(i,n)}function fC(e,t,n,r=[]){let i=sC(e,n,r);return!KS(t)||i.includes(t)?i:sC([...i,t],n,r)}function pC(e,t,n,r,i=[]){let a=sC(e,r,i);if(!KS(n))return a;if(!t||t===n)return fC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return fC(o,n,r,i);let c=[...o];return c[s]=n,sC(c,r,i)}function mC(e,t,n){return hC(e,qS(t),n)}function hC(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=sC(e,i,a),s=GS(t);if(r&&o.includes(r)&&GS(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:fC(o,s,i,a),activeTabId:s};let c=ZS(o,s);if(c)return{tabs:o,activeTabId:c};let l=XS(o,s);return{tabs:pC(o,r,l,i,a),activeTabId:l}}function gC(e,t){return e.filter(e=>e!==t)}function _C(e,t,n){let r=aC(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function vC(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return aC(e,2**53-1).filter(e=>{let a=rC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function yC(e,t,n,r=[],i=[]){if(t.length===0&&r.length===0)return aC(e,n);let a=new Map(t.map(e=>[e.fromDocName,e.toDocName])),o=[],s=new Set;for(let t of e){let{instanceSuffix:e}=WS(t),c=rC(t),l=`${c.kind===`doc`?a.get(c.docName)??GS(t):c.kind===`folder`?$S(xC(c.folderPath,r)):eC(xC(c.assetPath,r))}${e}`;if(!s.has(l)&&(s.add(l),o.push(l),i.length===0&&o.length>=n))break}return i.length===0?o:sC(o,n,i.map(e=>{let t=rC(e);return t.kind===`doc`?a.get(t.docName)??e:t.kind===`folder`?$S(xC(t.folderPath,r)):eC(xC(t.assetPath,r))}))}function bC(e,t,n=[]){return yC(e,t,2**53-1,n)}function xC(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function SC(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function CC(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function wC(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=aC(n.openTabs,2**53-1),i=oC(n.pinnedTabIds,r),a=i.length===0?aC(n.openTabs,t):sC(r,t,i),o=oC(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?rC(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function TC(e,t,n=[],r=()=>new Date){let i=aC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?rC(a):null;return{openTabs:i,pinnedTabIds:oC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function EC(e){return`${BS}${e}`}function DC(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?wC(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function OC(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var kC=Math.floor,AC=(e,t)=>e<t?e:t,jC=(e,t)=>e>t?e:t;Number.isNaN;var MC=128,NC=1<<17,PC=1<<18,FC=1<<19,IC=1<<20,LC=1<<21,RC=1<<22,zC=1<<23,BC=1<<24,VC=1<<25,HC=1<<26,UC=1<<27,WC=1<<28,GC=1<<29,KC=1<<30,qC=127;NC-1,PC-1,FC-1,IC-1,LC-1,RC-1,zC-1,BC-1,VC-1,HC-1,UC-1,WC-1,GC-1,KC-1;var JC=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var YC=String.fromCharCode;String.fromCodePoint,YC(65535);var XC=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},ZC=typeof TextEncoder<`u`?new TextEncoder:null,QC=ZC?e=>ZC.encode(e):XC,$C=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});$C&&$C.decode(new Uint8Array).length===1&&($C=null);var ew=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},tw=(e,t)=>{for(;t>qC;)ew(e,MC|qC&t),t=kC(t/128);ew(e,qC&t)},nw=new Uint8Array(3e4),rw=nw.length/3,iw=ZC&&ZC.encodeInto?(e,t)=>{if(t.length<rw){let n=ZC.encodeInto(t,nw).written||0;tw(e,n);for(let t=0;t<n;t++)ew(e,nw[t])}else ow(e,QC(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;tw(e,r);for(let t=0;t<r;t++)ew(e,n.codePointAt(t))},aw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=AC(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(jC(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},ow=(e,t)=>{tw(e,t.byteLength),aw(e,t)},sw=e=>Error(e),cw=sw(`Unexpected end of array`),lw=sw(`Integer out of Range`),uw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},dw=e=>uw(e,pw(e)),fw=e=>e.arr[e.pos++],pw=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&qC)*n,n*=128,r<MC)return t;if(t>JC)throw lw}throw cw},mw=$C?e=>$C.decode(dw(e)):e=>{let t=pw(e);if(t===0)return``;{let n=String.fromCodePoint(fw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(fw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},hw=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),gw=(e,t)=>{tw(e,hw.Token),iw(e,t)},_w=(e,t,n,r)=>{switch(pw(e)){case hw.Token:t();break;case hw.PermissionDenied:n(mw(e));break;case hw.Authenticated:r(mw(e));break;default:}},vw=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),yw=`\0`;function bw(e,t){return e+yw+t}function xw(e){let t=e.indexOf(yw);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Sw=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Cw(e){return 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 ww(e){return new Promise(t=>setTimeout(t,e))}function Tw(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Ew(e,t){let n=Cw(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Tw;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await ww(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await ww(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await ww(e)}return a()}var Dw=Math.floor,Ow=(e,t)=>e<t?e:t,kw=(e,t)=>e>t?e:t;Number.isNaN;var Aw=64,jw=128,Mw=1<<17,Nw=1<<18,Pw=1<<19,Fw=1<<20,Iw=1<<21,Lw=1<<22,Rw=1<<23,zw=1<<24,Bw=1<<25,Vw=1<<26,Hw=1<<27,Uw=1<<28,Ww=1<<29,Gw=1<<30,Kw=63,qw=127;Mw-1,Nw-1,Pw-1,Fw-1,Iw-1,Lw-1,Rw-1,zw-1,Bw-1,Vw-1,Hw-1,Uw-1,Ww-1,Gw-1;var Jw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Yw=()=>new Set,Xw=Array.from;Array.isArray;var Zw=String.fromCharCode;String.fromCodePoint,Zw(65535);var Qw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},$w=typeof TextEncoder<`u`?new TextEncoder:null,eT=$w?e=>$w.encode(e):Qw,tT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});tT&&tT.decode(new Uint8Array).length===1&&(tT=null);var nT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},rT=()=>new nT,iT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},aT=e=>{let t=new Uint8Array(iT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},oT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},sT=(e,t)=>{for(;t>qw;)oT(e,jw|qw&t),t=Dw(t/128);oT(e,qw&t)},cT=new Uint8Array(3e4),lT=cT.length/3,uT=$w&&$w.encodeInto?(e,t)=>{if(t.length<lT){let n=$w.encodeInto(t,cT).written||0;sT(e,n);for(let t=0;t<n;t++)oT(e,cT[t])}else fT(e,eT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;sT(e,r);for(let t=0;t<r;t++)oT(e,n.codePointAt(t))},dT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Ow(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(kw(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},fT=(e,t)=>{sT(e,t.byteLength),dT(e,t)},pT=e=>Error(e),mT=pT(`Unexpected end of array`),hT=pT(`Integer out of Range`),gT=class{constructor(e){this.arr=e,this.pos=0}},_T=e=>new gT(e),vT=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},yT=e=>vT(e,xT(e)),bT=e=>e.arr[e.pos++],xT=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&qw)*n,n*=128,r<jw)return t;if(t>Jw)throw hT}throw mT},ST=e=>{let t=e.arr[e.pos++],n=t&Kw,r=64,i=(t&Aw)>0?-1:1;if((t&jw)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&qw)*r,r*=128,t<jw)return i*n;if(n>Jw)throw hT}throw mT},CT=tT?e=>tT.decode(yT(e)):e=>{let t=xT(e);if(t===0)return``;{let n=String.fromCodePoint(bT(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(bT(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},wT=e=>{let t=e.pos,n=CT(e);return e.pos=t,n},TT=Date.now,ET=()=>new Map,DT=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},OT=class{constructor(){this._observers=ET()}on(e,t){DT(this._observers,e,Yw).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Xw((this._observers.get(e)||ET()).values()).forEach(e=>e(...t))}destroy(){this._observers=ET()}},kT=Symbol(`Equality`),AT=Object.keys,jT=e=>AT(e).length,MT=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),NT=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[kT]!=null)return e[kT](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!NT(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(jT(e)!==jT(t))return!1;for(let n in e)if(!MT(e,n)||!NT(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!NT(e[n],t[n]))return!1;break;default:return!1}return!0},PT=3e4,FT=class extends OT{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=TT();this.getLocalState()!==null&&PT/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&PT<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&IT(this,t,`timeout`)},Dw(PT/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:TT()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),NT(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},IT=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:TT()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},LT=(e,t,n=e.states)=>{let r=t.length,i=rT();sT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;sT(i,r),sT(i,s),uT(i,JSON.stringify(o))}return aT(i)},RT=(e,t,n)=>{let r=_T(t),i=TT(),a=[],o=[],s=[],c=[],l=xT(r);for(let t=0;t<l;t++){let t=xT(r),n=xT(r),l=JSON.parse(CT(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(NT(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},zT=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},BT=class{constructor(e){this.data=e,this.encoder=rT(),this.decoder=_T(new Uint8Array(this.data))}peekVarString(){return wT(this.decoder)}readVarUint(){return xT(this.decoder)}readVarString(){return CT(this.decoder)}readVarUint8Array(){return yT(this.decoder)}writeVarUint(e){return sT(this.encoder,e)}writeVarString(e){return uT(this.encoder,e)}writeVarUint8Array(e){return fT(this.encoder,e)}length(){return iT(this.encoder)}},VT=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[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),HT=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),UT=class{constructor(){this.encoder=rT()}get(e){return e.encoder}toUint8Array(){return aT(this.encoder)}},WT=class extends UT{constructor(...e){super(...e),this.type=VT.CLOSE,this.description=`Ask the server to close the connection`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),this.encoder}},GT=class e extends zT{static{this.DEDUPLICATABLE_TYPES=new Set([VT.Awareness,VT.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,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,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=HT.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,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(`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),this.shouldConnect&&this.connect()}async onOpen(e){this.status=HT.Connected,this.emit(`status`,{status:HT.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===HT.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===HT.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(WT,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===HT.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Ew(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,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{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;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=HT.Connecting,this.emit(`status`,{status:HT.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=TT();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===VT.Ping){this.sendPong();return}let n=new BT(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=rT();sT(e,VT.Pong),this.send(aT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=HT.Connected,this.emit(`status`,{status:HT.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===HT.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=TT()-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(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=_T(e);return{documentName:CT(t),messageType:xT(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Sw.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=HT.Disconnected,this.emit(`status`,{status:HT.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},KT=0,qT=1,JT=2,YT=(e,t)=>{sT(e,KT),fT(e,Km(t))},XT=(e,t,n)=>{sT(e,qT),fT(e,Bm(t,n))},ZT=(e,t,n)=>XT(t,n,yT(e)),QT=(e,t,n,r)=>{try{Lm(t,yT(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},$T=(e,t)=>{sT(e,JT),fT(e,t)},eE=QT,tE=(e,t,n,r,i)=>{let a=xT(e);switch(a){case KT:ZT(e,t,n);break;case qT:QT(e,n,r,i);break;case JT:eE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},nE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case VT.Sync:this.applySyncMessage(e,t);break;case VT.Awareness:this.applyAwarenessMessage(e);break;case VT.Auth:this.applyAuthMessage(e);break;case VT.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case VT.Stateless:e.receiveStateless(CT(n.decoder));break;case VT.SyncStatus:this.applySyncStatusMessage(e,ST(n.decoder)===1);break;case VT.CLOSE:let i={code:1e3,reason:CT(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(UT,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(VT.Sync);let r=tE(n.decoder,n.encoder,e.document,e);t&&r===qT&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;RT(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;_w(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(VT.Awareness),t.writeVarUint8Array(LT(e.awareness,Array.from(e.awareness.getStates().keys())))}},rE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return aT(this.encoder)}send(e){e?.send(this.create())}},iE=`4.0.0-rc.1`,aE=class extends UT{constructor(...e){super(...e),this.type=VT.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return uT(this.encoder,e.documentName),sT(this.encoder,this.type),gw(this.encoder,e.token),uT(this.encoder,iE),this.encoder}},oE=class extends UT{constructor(...e){super(...e),this.type=VT.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);uT(this.encoder,e.documentName),sT(this.encoder,this.type);let t;return t=e.states===void 0?LT(e.awareness,e.clients):LT(e.awareness,e.clients,e.states),fT(this.encoder,t),this.encoder}},sE=class extends UT{constructor(...e){super(...e),this.type=VT.Stateless,this.description=`A stateless message`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),uT(this.encoder,e.payload??``),this.encoder}},cE=class extends UT{constructor(...e){super(...e),this.type=VT.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return uT(this.encoder,e.documentName),sT(this.encoder,this.type),YT(this.encoder,e.document),this.encoder}},lE=class extends UT{constructor(...e){super(...e),this.type=VT.Sync,this.description=`A document update`}get(e){return uT(this.encoder,e.documentName),sT(this.encoder,this.type),$T(this.encoder,e.update),this.encoder}},uE=class extends Error{constructor(...e){super(...e),this.code=1001}},dE=class extends zT{get effectiveName(){return this.configuration.sessionAwareness?bw(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new xm,this.configuration.awareness=e.awareness===void 0?new FT(this.document):e.awareness,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(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:vw(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:vw(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.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new GT(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(cE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&IT(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(sE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(aE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(lE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(oE,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(cE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(oE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new rE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new BT(e.data),{documentName:n}=xw(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new BT(e.data)}),new nE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&IT(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(IT(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.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),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(`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.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new uE(`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)}},fE=e=>Od((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),pE=(e,t)=>Od((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(ed(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),mE=e=>fE(indexedDB.deleteDatabase(e)),hE=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),gE=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>DE(r,e))},_E=(e,t)=>fE(e.count(t)),vE=(e,t)=>fE(e.get(t)),yE=(e,t)=>fE(e.delete(t)),bE=(e,t,n)=>fE(e.put(t,n)),xE=(e,t)=>fE(e.add(t)),SE=(e,t,n)=>fE(e.getAll(t,n)),CE=(e,t,n)=>{let r=null;return EE(e,t,e=>(r=e,!1),n).then(()=>r)},wE=(e,t=null)=>CE(e,t,`prev`),TE=(e,t)=>Od((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),EE=(e,t,n,r=`next`)=>TE(e.openKeyCursor(t,r),e=>n(e.key)),DE=(e,t)=>e.objectStore(t),OE=(e,t)=>IDBKeyRange.upperBound(e,t),kE=(e,t)=>IDBKeyRange.lowerBound(e,t),AE=`custom`,jE=`updates`,ME=(e,t=()=>{},n=()=>{})=>{let[r]=gE(e.db,[jE]);return SE(r,kE(e._dbref,!1)).then(i=>{e._destroyed||(t(r),Ih(e.doc,()=>{i.forEach(t=>Lm(e.doc,t))},e,!1),n(r))}).then(()=>wE(r).then(t=>{e._dbref=t+1})).then(()=>_E(r).then(t=>{e._dbsize=t})).then(()=>r)},NE=(e,t=!0)=>ME(e).then(n=>{(t||e._dbsize>=500)&&xE(n,Bm(e.doc)).then(()=>yE(n,OE(e._dbref,!0))).then(()=>_E(n).then(t=>{e._dbsize=t}))}),PE=class extends ql{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=pE(e,e=>hE(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Od(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,ME(this,async e=>{await _E(e)>0&&xE(e,Bm(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=gE(this.db,[jE]);xE(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{NE(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{mE(this.name)})}get(e){return this._db.then(t=>{let[n]=gE(t,[AE],`readonly`);return vE(n,e)})}set(e,t){return this._db.then(n=>{let[r]=gE(n,[AE]);return bE(r,t,e)})}del(e){return this._db.then(t=>{let[n]=gE(t,[AE]);return yE(n,e)})}};function FE(){return!0}var IE=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=FE()?0:performance.now();this._idb=new PE(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!FE()){let e=performance.now();Z(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=FE()?0:performance.now();try{await this._idb.destroy()}finally{if(!FE()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=FE()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!FE()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function LE(e){return new IE(e)}function RE(e){return Km(e)}function zE(e,t){return t===null?Bm(e):Bm(e,t)}function BE(e,t){if(e===null)return t;if(t===null)return e;let n=Hm(e),r=Hm(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Km(i)}function VE(e){let t={};if(Jn.inject(qn.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var HE=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new Oe({key:e||new W(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),UE=g.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[HE({key:new W(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function WE(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!j.isSelectable(o))return!1;try{let t=j.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}var GE=g.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof j){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=s.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof s?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(WE(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof j))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=j.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(WE(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof j))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=j.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return T(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>WE(e,`left`),ArrowRight:({editor:e})=>WE(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof s)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let c=t.tr,l=n.before(n.depth),u=n.after(n.depth);c.delete(l,u);let d=o-(u-l),f=t.schema.nodes.paragraph.create();c.insert(d,f);let p=d+1;return c.setSelection(s.create(c.doc,p)),e.view.dispatch(c.scrollIntoView()),!0}}}}),KE={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},qE=/[A-Za-z0-9_]/;function JE(e){return e!==void 0&&qE.test(e)}function YE(e,t,n){return!JE(e[t-1])&&!JE(e[n])}function XE(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||YE(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function ZE(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of XE(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var QE=new W(`findReplace`);function $E(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function eD(e,t,n,r){let i=ZE(e.doc,t,n);return{query:t,options:n,activeIndex:$E(r,i.length),matches:i}}function tD(e,t,n){return t<=0?0:($E(e,t)+n+t)%t}function nD(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function rD(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=ZE(r.doc,t.query,t.options),a=$E(0,i.length),o=i[a];return r.setMeta(QE,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(s.create(r.doc,o.from,o.to)),r.scrollIntoView()}function iD(e,t){let n=QE.getState(e)?.matches[t];return n?e.tr.setMeta(QE,{type:`setActiveIndex`,activeIndex:t}).setSelection(s.create(e.doc,n.from,n.to)).scrollIntoView():null}function aD(e){return QE.getState(e)??KE}function oD(){return new Oe({key:QE,state:{init:()=>KE,apply(e,t,n,r){let i=e.getMeta(QE);if(i?.type===`clear`)return KE;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:eD(r,a,o,s)}},props:{decorations(e){let t=QE.getState(e);return!t||t.matches.length===0?null:C.create(e.doc,t.matches.map((e,n)=>we.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var sD=g.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(QE,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(QE,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(QE,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=aD(e),r=iD(e,tD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=aD(e),r=iD(e,tD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=aD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=ZE(a.doc,r.query,r.options),c=nD(o,i.from,e.length),l=o[c];return a.setMeta(QE,{type:`setActiveIndex`,activeIndex:c}),l&&a.setSelection(s.create(a.doc,l.from,l.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=aD(t);if(!n)return!1;let i=rD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(QE,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[oD()]}}),cD=new WeakMap;function lD(e,t){if(t===null){cD.delete(e);return}cD.set(e,t)}function uD(e){return cD.get(e)??null}function dD(e){return`pagesBySlug`in e}function fD(e){return dD(e)?e.pages:e}function pD(e,t){return dD(e)?e.assetPaths??new Set:t??new Set}function mD(e,t){let n=Le(e);if(n){if(dD(t))return t.pagesBySlug.get(n);for(let e of t)if(Le(e)===n)return e}}function hD(e){let t=e.trim();if(!t)return null;let n=Le(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function gD(e){let t=e.trim();if(!t)return[];let n=Le(t);return n.length>0&&n!==t?[n]:[]}function _D(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function vD(e,t){let n=_D(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function yD(e,t,n){let r=e.trim();if(!r)return!1;if(vD(r,pD(t,n)))return!0;let i=fD(t);return i.has(r)||gD(r).some(e=>i.has(e))?!0:mD(r,t)!==void 0}var bD=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},xD=new W(`imageUpload`);function SD(e){let t=document.createElement(`div`);return t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-label`,e?.name?`Uploading ${e.name}`:`Uploading file`),t}var CD=new Oe({key:xD,state:{init(){return{decorations:C.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(xD);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=we.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return xD.getState(e)?.decorations??C.empty}}});function wD(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function TD(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function ED(e){return e.split(`/`).filter(e=>e!==``)}function DD(e,t){let n=wD(e),r=wD(t),i=TD(e);if(n===r)return i;let a=ED(r),o=ED(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function OD(e){return uD(e)}function kD(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function AD(e){let t=ut(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:d.has(t)?{kind:`jsx-img`,ext:t}:Gt.has(t)?{kind:`jsx-video`,ext:t}:se.has(t)?{kind:`jsx-audio`,ext:t}:m.has(t)?{kind:`jsx-file`,ext:t}:Ct.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function jD(e,t,n){let r=OD(t),i=r?`${r}.md`:``;if(!i){zn.error(`Cannot upload: no document is open`);return}let a=crypto.randomUUID(),o=SD(e);t.view.dispatch(t.state.tr.setMeta(xD,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),MD(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),MD(t,a);return}if(!c.ok){let e=xe.safeParse(l);if(!e.success){let n=new bD(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),MD(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),MD(t,a,e.data.title);return}let u=qe.safeParse(l);if(!u.success){let e=new bD(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),MD(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=wD(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&zn.info(`Already at ${h} — reusing.`);let g=AD(e.name),{state:_}=t,v=xD.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(xD,{type:`remove`,id:a}),b=DD(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),MD(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:ee(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(xD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(j.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),MD(t,a);return}let e=kD(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(xD,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(j.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),MD(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),MD(t,a);return}let r=hD(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function MD(e,t,n){e.view.dispatch(e.state.tr.setMeta(xD,{type:`remove`,id:t})),zn.error(n??`Upload failed`)}var ND={AppWindow:fi,ChevronRight:Vn,CopyPlus:Ti,FileText:ji,Film:Pi,GitBranch:Li,Image:Hi,LayoutPanelTop:Wi,MessageSquareWarning:$i,PanelTop:ra,Paperclip:ia,Sigma:ua,SquarePlay:da,Volume2:ya,Workflow:ba,ZoomIn:Sa};function PD(e){return e&&Object.hasOwn(ND,e)?ND[e]:gi}var FD={ChevronRight:Vn};function ID(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(FD,t)?FD[t]:null}function LD(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=ID(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Vn,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,X.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,X.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,X.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,X.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,X.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,X.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function RD(e){return e!==!1}function zD(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:$t(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=RD(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,X.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var BD={note:Ui,tip:Gi,important:$i,warning:Ue,caution:ta,abstract:Ci,info:hi,todo:Xi,success:At,question:xi,failure:Si,danger:xa,bug:_i,example:Fi,quote:sa},VD={Info:Ui,Lightbulb:Gi,MessageSquareWarning:$i,AlertTriangle:Ue,AlertOctagon:ta,ClipboardList:Ci,BookOpen:hi,ListTodo:Xi,CircleCheck:At,CircleHelp:xi,CircleX:Si,Zap:xa,Bug:_i,FlaskConical:Fi,Quote:sa};function HD(e,t){if(!e||!e.startsWith(`lucide:`))return BD[t];let n=e.slice(7);return Object.hasOwn(VD,n)?VD[n]:BD[t]}var UD=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function WD(e){return typeof e==`string`&&UD.has(e)?e:`note`}function GD(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=WD(e.type),n=HD(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let o=a,s;t[6]!==i||t[7]!==e.title?(s=e.title||i?(0,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=s):s=t[8];let c=s;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===c?i=t[10]:(i=c??(0,X.jsx)(`span`,{className:`callout-title`,children:`Details`}),t[9]=c,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(vi,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let s;t[12]===i?s=t[13]:(s=(0,X.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=s);let l;t[14]===e.children?l=t[15]:(l=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=l);let u;return t[16]!==n||t[17]!==o||t[18]!==s||t[19]!==l||t[20]!==r?(u=(0,X.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:o,children:[s,l]}),t[16]=n,t[17]=o,t[18]=s,t[19]=l,t[20]=r,t[21]=u):u=t[21],u}let l;t[22]===e.children?l=t[23]:(l=(0,X.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=l);let u;return t[24]!==c||t[25]!==o||t[26]!==l||t[27]!==r?(u=(0,X.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:o,children:[c,l]}),t[24]=c,t[25]=o,t[26]=l,t[27]=r,t[28]=u):u=t[28],u}var KD=(0,Y.createContext)(null);function qD(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(KD.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function JD(){return(0,Y.use)(KD)}var YD=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function XD(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,o=(0,Y.useRef)(null),s;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(s=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=s):s=t[4];let c=s,l=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let s=a.getBoundingClientRect();o.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:s.width,startHeight:s.height,latestWidth:s.width,latestHeight:s.height,hasMoved:!1},document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=o.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:c(t.startWidth+n,`w`),s=t.handle.dy===0?t.startHeight:c(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=s,t.hasMoved=!0,r({width:a,height:s})};function u(){let e=o.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;o.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},u=YD.map(e=>(0,X.jsx)(`button`,{type:`button`,className:nn(e.className),"aria-label":`Resize ${e.key}`,tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>l(t,e)},e.key)),d;return t[5]===u?d=t[6]:(d=(0,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:u}),t[5]=u,t[6]=d),d}var ZD=`26rem`,QD=`Embedded content`,$D=/^https?:\/\//i;function eO(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function tO(e){return!(typeof e!=`string`||!$D.test(e)||!eO(e))}function nO(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=JD(),c=i||void 0,l=a||ZD,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||ZD)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!tO(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=$D.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g=r||QD,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(XD,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function rO(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function iO(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||rO(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?$t(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Mi,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,X.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:aO,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function aO(e){return e.stopPropagation()}function oO(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function sO(){return Y.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Y.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function cO(e){return typeof Element>`u`?!1:e instanceof Element}var lO=(e,t)=>cO(t)&&t.tagName.toUpperCase()===e,uO=e=>lO(`DIV`,e)||lO(`SPAN`,e),dO=e=>lO(`IMG`,e),fO=e=>e.complete&&e.naturalHeight!==0,pO=e=>lO(`SVG`,e),mO=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),hO=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=mO({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},gO=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?hO({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):mO({height:e,offset:r,width:t}),_O=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,vO=e=>{if(e!==null){if(dO(e))return e.currentSrc===``?void 0:e.currentSrc;if(uO(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return _O.exec(t)?.[1]}}},yO=e=>{if(e!==null)return dO(e)?e.alt:e.getAttribute(`aria-label`)??void 0},bO=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=gO({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},xO=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},SO=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=xO({position:p,relativeNum:r-l*f}),g=xO({position:m,relativeNum:e-c*f}),_=gO({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=xO({position:a,relativeNum:r-l}),f=xO({position:u,relativeNum:e-c}),p=gO({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=gO({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},CO=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=xO({position:p,relativeNum:a-l*f}),g=xO({position:m,relativeNum:n-c*f}),_=gO({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=xO({position:t,relativeNum:a-l}),f=xO({position:u,relativeNum:n-c}),p=gO({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=xO({position:u,relativeNum:a}),p=xO({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=xO({position:_,relativeNum:a-l*g}),b=xO({position:v,relativeNum:n-c*g}),x=gO({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},wO=/\.svg$/i,TO=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&wO.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&uO(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=bO({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?SO({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?CO({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},EO=e=>{if(e==null)return{};if(pO(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},DO=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},OO=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),kO={overflow:``,width:``};function AO(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function jO(e){e.preventDefault()}function MO(e){return Y.createElement(NO,{...e})}var NO=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=kO,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(OO),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:EO(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:EO(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=vO(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(dO(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:EO(this.imgEl)})};t.decode().then(r).catch(()=>{if(fO(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||pO(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=kO},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(fO(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(pO(e)){let r=e.cloneNode(!0);DO(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=uO(a),j=dO(a),M=pO(a),N=yO(a),P=vO(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),te=N!==void 0&&N!==``?`${s}: ${N}`:s,ne=T===`LOADING`||T===`LOADED`,re=R?`found`:`not-found`,z=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,B={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?TO({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&ne,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let ie=null;if(R){let t=j||A?Y.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));ie=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":re,ref:_,style:B},c),R&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":te,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),R&&Da.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:jO,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":z}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},ie)),AO()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};NO.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:oO,IconZoom:sO,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function PO({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(MO,{...t,isZoomed:n,onZoomChange:i})}function FO(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function IO(e,t,n){return FO(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function LO(e){let t=(0,J.c)(51),n,r,i,a,o,s,c,l,u,d,f,p;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12]):({width:p,height:r,loadingTestId:u,slotTestId:d,slotClassName:s,className:n,onLoad:o,onError:a,src:c,style:l,alt:f,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p);let m=u===void 0?`image-loading-skeleton`:u,h=d===void 0?`image-slot`:d,g=f===void 0?``:f,_=(0,Y.useRef)(null),[v,y]=(0,Y.useState)(!1),b;t[13]!==r||t[14]!==p?(b=FO(p,r),t[13]=r,t[14]=p,t[15]=b):b=t[15];let x=b,S;t[16]!==r||t[17]!==l||t[18]!==p?(S=IO(p,r,l),t[16]=r,t[17]=l,t[18]=p,t[19]=S):S=t[19];let C=S,w;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{_.current?.complete?y(!0):y(!1)},t[20]=w):w=t[20];let T;t[21]===c?T=t[22]:(T=[c],t[21]=c,t[22]=T),(0,Y.useLayoutEffect)(w,T);let E=!x&&!v&&`aspect-[16/9] w-full max-w-full`,D;t[23]!==s||t[24]!==E?(D=nn(`relative inline-block overflow-hidden`,E,s),t[23]=s,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==v||t[27]!==m?(O=!v&&(0,X.jsx)(`span`,{"data-testid":m,role:`status`,"aria-busy":`true`,"aria-label":`Loading image`,className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=m,t[28]=O):O=t[28];let k=v?`opacity-100`:`opacity-0`,A;t[29]!==n||t[30]!==k?(A=nn(`block max-w-full transition-opacity motion-reduce:transition-none`,k,n),t[29]=n,t[30]=k,t[31]=A):A=t[31];let j;t[32]===o?j=t[33]:(j=e=>{y(!0),o?.(e)},t[32]=o,t[33]=j);let M;t[34]===a?M=t[35]:(M=e=>{y(!0),a?.(e)},t[34]=a,t[35]=M);let N;t[36]!==g||t[37]!==r||t[38]!==i||t[39]!==c||t[40]!==A||t[41]!==j||t[42]!==M||t[43]!==p?(N=(0,X.jsx)(`img`,{...i,ref:_,src:c,alt:g,width:p,height:r,className:A,onLoad:j,onError:M}),t[36]=g,t[37]=r,t[38]=i,t[39]=c,t[40]=A,t[41]=j,t[42]=M,t[43]=p,t[44]=N):N=t[44];let P;return t[45]!==C||t[46]!==h||t[47]!==O||t[48]!==N||t[49]!==D?(P=(0,X.jsxs)(`span`,{"data-testid":h,className:D,style:C,children:[O,N]}),t[45]=C,t[46]=h,t[47]=O,t[48]=N,t[49]=D,t[50]=P):P=t[50],P}function RO(e){return e??`lazy`}function zO(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function BO(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:$t(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=zO(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=zO(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=RO(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,X.jsx)(LO,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function VO(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(PO,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)(BO,{...e})}),t[1]=e,t[2]=r),r}var HO=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-qwlL5fSd.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,X.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function UO(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function WO(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(UO,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(UO,{formula:n,id:e.id}),children:(0,X.jsx)(HO,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var GO=null;function KO(){return GO||=n(()=>import(`./mermaid.core-DKgSmEOt.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw GO=null,e}),GO}function qO(e){let t=(0,J.c)(22),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={status:`idle`,svg:``,error:``},t[3]=o):o=t[3];let[s,c]=(0,Y.useState)(o),l,u;if(t[4]!==n||t[5]!==a?(l=()=>{if(!n.trim()){c({status:`idle`,svg:``,error:``});return}let e=!1;return c(JO),KO().then(async t=>{try{let r=await t.render(a,n);e||c({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||c({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||c({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},u=[n,a],t[4]=n,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),(0,Y.useEffect)(l,u),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(s.status===`error`){let e;t[9]===n?e=t[10]:(e=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[9]=n,t[10]=e);let r;t[11]===s.error?r=t[12]:(r=(0,X.jsx)(`p`,{className:`mermaid-error-message`,children:s.error}),t[11]=s.error,t[12]=r);let i;return t[13]!==s.error||t[14]!==e||t[15]!==r?(i=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:s.error,children:[e,r]}),t[13]=s.error,t[14]=e,t[15]=r,t[16]=i):i=t[16],i}let d=`mermaid mermaid-${s.status}`,f;t[17]===s.svg?f=t[18]:(f={__html:s.svg},t[17]=s.svg,t[18]=f);let p;return t[19]!==d||t[20]!==f?(p=(0,X.jsx)(`div`,{className:d,"data-component-type":`mermaid`,dangerouslySetInnerHTML:f}),t[19]=d,t[20]=f,t[21]=p):p=t[21],p}function JO(e){return{...e,status:`rendering`}}var YO=null;function XO(){return YO||=new oe({extensions:Me}),YO}function ZO(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=ZO(e,t);if(n)return n}return null}function QO(e){return at({type:`root`,children:e.children??[]})}var $O=new Map,ek=30,tk=150,nk=1e4;function rk(e,t){let n=`${e}|${t}`,r=$O.get(n);if(r)return r.refcount+=1,r;let i=new xm,a=new dE({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),$O.set(n,s),$O.size>ek&&console.warn(`[Mirror] provider pool exceeded ${ek} entries (current=${$O.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function ik(e,t){let n=`${e}|${t}`,r=$O.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}$O.delete(n)}}function ak(e,t){let n=(0,J.c)(8),{collabUrl:r}=hx(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=rk(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=XO().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=ZO(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=QO(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},tk)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},nk);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,ik(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Y.useEffect)(d,f),a}function ok(e){let t=(0,J.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,X.jsx)(Ki,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(Ji,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sk(e){let t=(0,J.c)(29),n=e.src??``,r=e.anchor??``,i=ak(n,r);if(i.kind===`empty-props`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror — pick a source.`}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`code`,{children:`src`}),t[1]=n):n=t[1];let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`code`,{children:`anchor`}),t[2]=r):r=t[2];let i;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsxs)(ok,{tone:`placeholder`,children:[e,` Set `,n,` +`,` `,r,` via the property panel to point at a `,(0,X.jsx)(`code`,{children:`<MirrorSource>`}),` `,`elsewhere.`]}),t[3]=i):i=t[3],i}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;return t[4]===e?i=t[5]:(i=(0,X.jsxs)(ok,{tone:`placeholder`,children:[`Mirror loading `,(0,X.jsx)(`code`,{children:e})]}),t[4]=e,t[5]=i),i}if(i.kind===`source-removed`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror source removed.`}),t[6]=e):e=t[6];let r;return t[7]===n?r=t[8]:(r=(0,X.jsxs)(ok,{tone:`error`,children:[e,` The doc `,(0,X.jsx)(`code`,{children:n}),` is no longer available.`]}),t[7]=n,t[8]=r),r}if(i.kind===`anchor-not-found`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`span`,{className:`font-medium`,children:`Mirror anchor not found.`}),t[9]=e):e=t[9];let i;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`code`,{children:`<MirrorSource id="`}),t[10]=i):i=t[10];let a;t[11]===r?a=t[12]:(a=(0,X.jsx)(`code`,{children:r}),t[11]=r,t[12]=a);let o;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`code`,{children:`">`}),t[13]=o):o=t[13];let s;t[14]===n?s=t[15]:(s=(0,X.jsx)(`code`,{children:n}),t[14]=n,t[15]=s);let c;return t[16]!==a||t[17]!==s?(c=(0,X.jsxs)(ok,{tone:`error`,children:[e,` No`,` `,i,a,o,` exists in `,s,`.`]}),t[16]=a,t[17]=s,t[18]=c):c=t[18],c}let a;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Ei,{className:`size-3`,"aria-hidden":`true`}),t[19]=a):a=t[19];let o;t[20]===n?o=t[21]:(o=(0,X.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,X.jsxs)(`span`,{children:[`Mirror of `,(0,X.jsx)(`code`,{className:`font-mono`,children:n})]})]}),t[20]=n,t[21]=o);let s;t[22]===i.html?s=t[23]:(s=(0,X.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[22]=i.html,t[23]=s);let c;return t[24]!==r||t[25]!==n||t[26]!==o||t[27]!==s?(c=(0,X.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[o,s]}),t[24]=r,t[25]=n,t[26]=o,t[27]=s,t[28]=c):c=t[28],c}function ck(e){let t=(0,J.c)(9),n=e.id??``,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(Ti,{className:`size-3`,"aria-hidden":`true`}),t[0]=r):r=t[0];let i=n||`(no id)`,a;t[1]===i?a=t[2]:(a=(0,X.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[r,(0,X.jsxs)(`span`,{children:[`Mirror source `,(0,X.jsx)(`code`,{className:`font-mono`,children:i})]})]}),t[1]=i,t[2]=a);let o;t[3]===e.children?o=t[4]:(o=(0,X.jsx)(`div`,{children:e.children}),t[3]=e.children,t[4]=o);let s;return t[5]!==n||t[6]!==a||t[7]!==o?(s=(0,X.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":n,children:[a,o]}),t[5]=n,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}var lk=24,uk=24,dk=12,fk=.1;function pk(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(fk,(n-lk)/t.naturalWidth);case`fit-height`:return Math.max(fk,(r-uk)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(fk,((n-lk)/2-dk)/t.naturalWidth)}}var mk=600,hk=.5,gk=3,_k=.25,vk=null;function yk(){return vk||(vk=(async()=>{let e=await n(()=>import(`./pdf-wFLJduM2.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-CP44mBOj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),vk.catch(()=>{vk=null})),vk}function bk(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function xk(e){let t=(0,J.c)(85),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=qt(e.anchor);n=i===null?e.fillContainer?`100%`:`${mk}px`:`${i}px`,r=Dk(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,a=(0,Y.useRef)(null),o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[4]=o):o=t[4];let s=(0,Y.useRef)(o),c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[5]=c):c=t[5];let l=(0,Y.useRef)(c),u=(0,Y.useRef)(null),d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[6]=d):d=t[6];let[f,p]=(0,Y.useState)(d),[m,h]=(0,Y.useState)(!0),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(i??1),[b,x]=(0,Y.useState)(String(i??1)),[S,C]=(0,Y.useState)(1),[w,T]=(0,Y.useState)(`fit-width`),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(0),[M,N]=(0,Y.useState)(0),P=f.length,F,I;t[7]===e.src?(F=t[8],I=t[9]):(F=()=>{if(!e.src){h(!1);return}let t=$t(e.src),n=!1,r=null;return h(!0),_(null),(async()=>{try{let e=await(await yk()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,u.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;p(i)}catch(e){let t=e;if(n)return;_(t instanceof Error?t.message:`Failed to load PDF`),h(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),u.current=null}},I=[e.src],t[7]=e.src,t[8]=F,t[9]=I),(0,Y.useEffect)(F,I);let L,ee;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=a.current;if(!e)return;let t=()=>{j(e.clientWidth),N(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ee=[],t[10]=L,t[11]=ee):(L=t[10],ee=t[11]),(0,Y.useEffect)(L,ee);let R,te;t[12]!==M||t[13]!==A||t[14]!==w||t[15]!==f||t[16]!==S?(R=()=>{let e=u.current;if(!e||f.length===0||A===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of f){if(t)return;let a=s.current[i.pageNumber-1];if(!a)continue;let o=pk(w,i,A,M)*S,c=await e.getPage(i.pageNumber);if(t)return;let l=c.getViewport({scale:o});a.width=Math.floor(l.width*r),a.height=Math.floor(l.height*r),a.style.width=`${l.width}px`,a.style.height=`${l.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=c.render({canvas:a,canvasContext:u,viewport:l}),await n.promise,n=null)}t||h(!1)}catch(e){let n=e;if(t||bk(n))return;console.warn(`[Pdf] page render failed:`,n),_(n instanceof Error?n.message:`Failed to render PDF`),h(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},te=[f,w,S,A,M],t[12]=M,t[13]=A,t[14]=w,t[15]=f,t[16]=S,t[17]=R,t[18]=te):(R=t[17],te=t[18]),(0,Y.useEffect)(R,te);let ne,re;t[19]!==f||t[20]!==E?(ne=()=>{if(!E)return;let e=u.current;if(!e||f.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of f){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;bk(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},re=[E,f],t[19]=f,t[20]=E,t[21]=ne,t[22]=re):(ne=t[21],re=t[22]),(0,Y.useEffect)(ne,re);let z,B;t[23]!==m||t[24]!==i?(z=()=>{if(m||!i)return;let e=a.current,t=s.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},B=[m,i],t[23]=m,t[24]=i,t[25]=z,t[26]=B):(z=t[25],B=t[26]),(0,Y.useEffect)(z,B);let ie,V;t[27]===f?(ie=t[28],V=t[29]):(ie=()=>{let e=a.current;if(!e||f.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of f){let i=s.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}y(r),x(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},V=[f],t[27]=f,t[28]=ie,t[29]=V),(0,Y.useEffect)(ie,V);let H,U;t[30]===O?(H=t[31],U=t[32]):(H=()=>{if(!O)return;let e=e=>{let t=e.target,n=a.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){k(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&k(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},U=[O],t[30]=O,t[31]=H,t[32]=U),(0,Y.useEffect)(H,U);let ae;t[33]===P?ae=t[34]:(ae=e=>{let t=Math.max(1,Math.min(P||1,e));y(t),x(String(t));let n=a.current,r=s.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[33]=P,t[34]=ae);let oe=ae,se;t[35]!==v||t[36]!==oe||t[37]!==b?(se=()=>{let e=Number.parseInt(b,10);if(Number.isNaN(e)){x(String(v));return}oe(e)},t[35]=v,t[36]=oe,t[37]=b,t[38]=se):se=t[38];let ce=se,le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>C(Tk),t[39]=le):le=t[39];let ue=le,de;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>C(wk),t[40]=de):de=t[40];let fe=de,pe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{T(e),k(!1),C(1)},t[41]=pe):pe=t[41];let me=pe,he;t[42]===n?he=t[43]:(he={height:n},t[42]=n,t[43]=he);let ge;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>D(Ck),t[44]=ge):ge=t[44];let _e=E?`Hide thumbnails`:`Show thumbnails`,ve;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,X.jsx)(na,{size:14,"aria-hidden":`true`}),t[45]=ve):ve=t[45];let ye;t[46]!==E||t[47]!==_e?(ye=(0,X.jsx)(`button`,{type:`button`,onClick:ge,"aria-label":_e,"aria-pressed":E,className:`ok-pdf-btn`,title:`Toggle thumbnails`,children:ve}),t[46]=E,t[47]=_e,t[48]=ye):ye=t[48];let be=e.title??`PDF`,xe;t[49]===be?xe=t[50]:(xe=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:be}),t[49]=be,t[50]=xe);let Se;t[51]!==O||t[52]!==w||t[53]!==b||t[54]!==ce||t[55]!==P||t[56]!==S?(Se=P>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),ce()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:b,onChange:e=>x(e.target.value.replace(/[^0-9]/g,``)),onBlur:ce,"aria-label":`Page number`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-page-of`,children:[`of `,P]}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:fe,disabled:S<=hk,"aria-label":`Zoom out`,className:`ok-pdf-btn`,title:`Zoom out`,children:(0,X.jsx)(Ca,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(S*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:S>=gk,"aria-label":`Zoom in`,className:`ok-pdf-btn`,title:`Zoom in`,children:(0,X.jsx)(Sa,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>k(Sk),"aria-label":`Layout options`,"aria-haspopup":`menu`,"aria-expanded":O,className:`ok-pdf-btn`,title:`Layout`,children:(0,X.jsx)(vi,{size:14,"aria-hidden":`true`})}),O&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(Ek,{label:`Fit width`,active:w===`fit-width`,onSelect:()=>me(`fit-width`)}),(0,X.jsx)(Ek,{label:`Fit height`,active:w===`fit-height`,onSelect:()=>me(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(Ek,{label:`Single page`,active:w===`single`,onSelect:()=>me(`single`)}),(0,X.jsx)(Ek,{label:`Two-page (odd)`,active:w===`two-odd`,onSelect:()=>me(`two-odd`)}),(0,X.jsx)(Ek,{label:`Two-page (even)`,active:w===`two-even`,onSelect:()=>me(`two-even`)})]})]})]}),t[51]=O,t[52]=w,t[53]=b,t[54]=ce,t[55]=P,t[56]=S,t[57]=Se):Se=t[57];let Ce;t[58]!==ye||t[59]!==xe||t[60]!==Se?(Ce=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ye,xe,Se]}),t[58]=ye,t[59]=xe,t[60]=Se,t[61]=Ce):Ce=t[61];let we;t[62]!==v||t[63]!==oe||t[64]!==f||t[65]!==E?(we=E&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":`Page thumbnails`,children:f.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":v===e.pageNumber||void 0,onClick:()=>oe(e.pageNumber),"aria-label":`Jump to page ${e.pageNumber}`,children:[(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:e.pageNumber})]},e.pageNumber))}),t[62]=v,t[63]=oe,t[64]=f,t[65]=E,t[66]=we):we=t[66];let Te;t[67]===m?Te=t[68]:(Te=m&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:`Loading PDF`}),t[67]=m,t[68]=Te);let Ee;t[69]===g?Ee=t[70]:(Ee=g&&(0,X.jsxs)(`div`,{className:`ok-pdf-error`,children:[`Failed to load PDF: `,g]}),t[69]=g,t[70]=Ee);let W;t[71]===P?W=t[72]:(W=Array.from({length:P},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{s.current[t]=e},className:`ok-pdf-page`,"aria-label":`Page ${n}`},n)}),t[71]=P,t[72]=W);let De;t[73]!==w||t[74]!==Te||t[75]!==Ee||t[76]!==W?(De=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:a,"data-layout":w,children:[Te,Ee,W]}),t[73]=w,t[74]=Te,t[75]=Ee,t[76]=W,t[77]=De):De=t[77];let Oe;t[78]!==we||t[79]!==De?(Oe=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[we,De]}),t[78]=we,t[79]=De,t[80]=Oe):Oe=t[80];let ke;return t[81]!==he||t[82]!==Ce||t[83]!==Oe?(ke=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:he,children:[Ce,Oe]}),t[81]=he,t[82]=Ce,t[83]=Oe,t[84]=ke):ke=t[84],ke}function Sk(e){return!e}function Ck(e){return!e}function wk(e){return Math.max(hk,+(e-_k).toFixed(2))}function Tk(e){return Math.min(gk,+(e+_k).toFixed(2))}function Ek(e){let t=(0,J.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(Sn,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function Dk(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function Ok(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,X.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var kk=`[data-component-type="tabs"]`,Ak=`[data-node-view-content-react] > .react-renderer`;function jk(e){let t=e.closest(kk);return t?Array.from(e.querySelectorAll(Ak)).filter(e=>e.parentElement?.closest(kk)===t).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}}):[]}function Mk(e){let t=(0,J.c)(26),{id:n,children:r}=e,[i,a]=(0,Y.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[s,c]=(0,Y.useState)(o),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(0),f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=l.current;if(!e)return;let t=jk(e);c(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=f):f=t[1],(0,Y.useLayoutEffect)(f);let p,m;t[2]===s.length?(p=t[3],m=t[4]):(p=()=>{s.length>d.current&&s.length>0&&a(s.length-1),d.current=s.length},m=[s.length],t[2]=s.length,t[3]=p,t[4]=m),(0,Y.useLayoutEffect)(p,m);let h;t[5]===n?h=t[6]:(h=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=l.current;if(!t)return;let r=jk(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=h),(0,Y.useLayoutEffect)(h);let g=s.length===0?0:Math.min(Math.max(i,0),s.length-1),_;t[7]!==s.length||t[8]!==g?(_=e=>{if(s.length===0)return;let t=null;e.key===`ArrowRight`?t=(g+1)%s.length:e.key===`ArrowLeft`?t=(g-1+s.length)%s.length:e.key===`Home`?t=0:e.key===`End`&&(t=s.length-1),t!==null&&(e.preventDefault(),a(t),(u.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=s.length,t[8]=g,t[9]=_):_=t[9];let v=_,y=n?`Tabs: ${n}`:`Tabs`,b;if(t[10]!==s||t[11]!==g){let e;t[13]===g?e=t[14]:(e=e=>(0,X.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===g,"aria-selected":e.index===g,"aria-controls":e.panelId??void 0,tabIndex:e.index===g?0:-1,onMouseDown:Nk,onClick:()=>a(e.index),children:e.label},e.index),t[13]=g,t[14]=e),b=s.map(e),t[10]=s,t[11]=g,t[12]=b}else b=t[12];let x;t[15]!==v||t[16]!==y||t[17]!==b?(x=(0,X.jsx)(`div`,{ref:u,role:`tablist`,"aria-label":y,className:`tabs-strip`,contentEditable:!1,onKeyDown:v,children:b}),t[15]=v,t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==g?(S=(0,X.jsx)(`div`,{ref:l,className:`tabs-content`,"data-active-index":g,children:r}),t[19]=r,t[20]=g,t[21]=S):S=t[21];let C;return t[22]!==n||t[23]!==S||t[24]!==x?(C=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[x,S]}),t[22]=n,t[23]=S,t[24]=x,t[25]=C):C=t[25],C}function Nk(e){return e.preventDefault()}var Pk={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Fk=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Pk[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function Ik(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Lk(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Y.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?Fk(e.id,_,g,l):null,y=Y.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Y.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:Ik(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var Rk=Y.forwardRef(Lk);function zk(e){return e!==!1}function Bk(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Vk(e){if(e.width!==void 0)return{width:e.width}}function Hk(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Uk(e){let t=(0,J.c)(25),n;if(t[0]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:We(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Vk(e),s;t[2]===e.poster?s=t[3]:(s=e.poster===void 0?void 0:$t(e.poster),t[2]=e.poster,t[3]=s);let c=(0,X.jsx)(Rk,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Bk(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Hk(e)}),l;t[4]!==o||t[5]!==c?(l=(0,X.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[4]=o,t[5]=c,t[6]=l):l=t[6],n=l;break bb0}}t[0]=e,t[1]=n}else n=t[1];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[7]===e.src?r=t[8]:(r=e.src===void 0?void 0:$t(e.src),t[7]=e.src,t[8]=r);let i=e.title,a;t[9]===e.controls?a=t[10]:(a=zk(e.controls),t[9]=e.controls,t[10]=a);let o;t[11]===e.poster?o=t[12]:(o=e.poster===void 0?void 0:$t(e.poster),t[11]=e.poster,t[12]=o);let s;return t[13]!==e.autoplay||t[14]!==e.height||t[15]!==e.loop||t[16]!==e.muted||t[17]!==e.playsinline||t[18]!==e.preload||t[19]!==e.title||t[20]!==e.width||t[21]!==r||t[22]!==a||t[23]!==o?(s=(0,X.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[13]=e.autoplay,t[14]=e.height,t[15]=e.loop,t[16]=e.muted,t[17]=e.playsinline,t[18]=e.preload,t[19]=e.title,t[20]=e.width,t[21]=r,t[22]=a,t[23]=o,t[24]=s):s=t[24],s}function Wk(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Gk={Callout:GD,img:VO,video:Uk,audio:zD,Pdf:xk,File:iO,Embed:nO,Accordion:LD,Tabs:Mk,Tab:Ok,Math:WO,MermaidFence:qO,Mirror:sk,MirrorSource:ck,"*":Wk};function Kk(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var qk=Yt(),Jk=new Map;function Yk(e){if(e.surface===`compat`){let t=Gk[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Kk(e.props)}}let t=Gk[e.name];return t?{Component:t,reactNodePropNames:Kk(e.props)}:null}for(let[e,t]of qk.entries()){let n=Yk(t);n&&Jk.set(e,n)}function Xk(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Zk(e){let t=qk.getOrWildcard(e),n=Jk.get(t.name)??Jk.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Xk(t,n)}function Qk(){let e=[];for(let[t,n]of qk.entries()){if(t===`*`)continue;let r=Jk.get(t);r&&e.push(Xk(n,r))}return e}var $k=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,eA=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,tA={Callout:{description:`Highlight tips, warnings, and notes.`,props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:`Collapsible section with a clickable summary.`,props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:`Embed an image with optional alt text.`,props:{src:$k,alt:`Sample image`}},video:{description:`Embed a video with native player controls.`,props:{controls:!0,poster:eA}},audio:{description:`Embed an audio file with native player controls.`,props:{controls:!0}},Math:{description:`Block math equation rendered with KaTeX from a LaTeX source string.`,props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:`Embed an external page in an inline iframe (docs, demos, Figma, CodeSandbox).`,render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:`Multi-page PDF viewer with toolbar controls (thumbnails, page nav, zoom).`,render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:`Diagram from Mermaid source — flowchart, sequence, class, state, ER, gantt, pie.`,render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:`Horizontal pill strip + active panel below; click a pill to switch panels.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Active panel content for the selected tab shows here.`})]})},Mirror:{description:`Read-only copy of a MirrorSource block from another doc. Edit at the source — every Mirror reflects the change live.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Di,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Mirror of `,(0,X.jsx)(`code`,{className:`font-mono`,children:`api-spec`})]})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:`Edits at the source land here — no copy-paste drift.`})]})},MirrorSource:{description:`Mark a block as the source of truth. Mirror references elsewhere render this content read-only and update live as you edit here.`,render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(Ti,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Mirror source `,(0,X.jsx)(`code`,{className:`font-mono`,children:`api-spec`})]})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:`Authoritative content; mirrored verbatim everywhere it's referenced.`})]})}};function nA(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function rA(e){let t=Zk(e),n=nA(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var iA=new Set;function aA(e){iA.add(e)}function oA(e){if(typeof e==`number`)return iA.delete(e);let t=iA.values().next();return t.done?!1:(iA.delete(t.value),!0)}function sA(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(aA(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function cA(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=rA(e.name);if(e.name===`Tabs`){let e=rA(`Tab`),t=rA(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&sA(t,i,e)}}var lA=new Set([`File`,`Tab`]);function uA(){return[{name:`component-File`,label:`File`,icon:Mi,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:fA,preview:{description:`Notion-style inline row for a downloadable file. Drag-drop also works.`,render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(Mi,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function dA(){return[...Qk().filter(e=>e.surface===`canonical`&&!lA.has(e.name)).map(e=>{let t=tA[e.name],n=e.Component,r=t?{description:t.description,render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:PD(e.icon),category:e.category??`content`,command:cA(e),aliases:e.searchTerms,description:e.description,preview:r}}),...uA()]}function fA(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;jD(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function pA(){return[{name:`component-Tag`,label:`Tag`,icon:Ri,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:`Inline hashtag for cross-doc grouping.`,render:()=>(0,X.jsxs)(`p`,{className:`text-sm leading-7`,children:[`See`,` `,(0,X.jsx)(`a`,{className:`tag pointer-events-none`,children:`#design-docs`}),` for the latest specs.`]})},command:e=>{e.chain().insertTag(``).run()}}]}var mA=[{name:`heading1`,label:`Heading 1`,icon:zi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:`Big section heading.`,render:()=>(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Heading 1`})}},{name:`heading2`,label:`Heading 2`,icon:Bi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:`Medium section heading.`,render:()=>(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Heading 2`})}},{name:`heading3`,label:`Heading 3`,icon:Vi,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:`Small section heading.`,render:()=>(0,X.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:`Heading 3`})}},{name:`bulletList`,label:`Bullet List`,icon:Zi,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:`Unordered list of items.`,render:()=>(0,X.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:`First item`}),(0,X.jsx)(`li`,{children:`Second item`})]})}},{name:`orderedList`,label:`Ordered List`,icon:Yi,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:`Numbered list of items.`,render:()=>(0,X.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:`First item`}),(0,X.jsx)(`li`,{children:`Second item`})]})}},{name:`taskList`,label:`Task List`,icon:Xi,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:`Checklist with checkboxes.`,render:()=>(0,X.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:`Done`})]}),(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{children:`To do`})]})]})}},{name:`blockquote`,label:`Quote`,icon:sa,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:`Indented blockquote for citations.`,render:()=>(0,X.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:`A pull quote stands out from the surrounding text.`})}},{name:`codeBlock`,label:`Code Block`,icon:wi,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`],preview:{description:`Fenced code block with monospace text.`,render:()=>(0,X.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,X.jsx)(`code`,{children:`const greeting = "Hello";
7
7
  console.log(greeting);`})})}},{name:`table`,label:`Table`,icon:pa,category:`insert`,command:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),aliases:[`grid`],preview:{description:`Grid of rows and columns with a header row.`,render:()=>(0,X.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`border border-border bg-muted/50 px-2 py-1 text-left font-semibold`,children:`Name`}),(0,X.jsx)(`th`,{className:`border border-border bg-muted/50 px-2 py-1 text-left font-semibold`,children:`Role`})]})}),(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`td`,{className:`border border-border px-2 py-1`,children:`Ada`}),(0,X.jsx)(`td`,{className:`border border-border px-2 py-1`,children:`Engineer`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`td`,{className:`border border-border px-2 py-1`,children:`Grace`}),(0,X.jsx)(`td`,{className:`border border-border px-2 py-1`,children:`Admiral`})]})]})]})}},{name:`separator`,label:`Separator`,icon:ea,category:`insert`,command:e=>e.chain().focus().setHorizontalRule().run(),aliases:[`hr`,`divider`,`rule`],preview:{description:`Horizontal rule that divides sections.`,render:()=>(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:`Above`}),(0,X.jsx)(`hr`,{className:`border-border`}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Below`})]})}},{name:`footnote`,label:`Footnote`,icon:fa,category:`insert`,command:e=>{let t=0;e.state.doc.descendants(e=>{if(e.type.name===`footnoteDefinition`){let n=String(e.attrs.identifier??``),r=Number.parseInt(n,10);!Number.isNaN(r)&&r>t&&(t=r)}return!0});let n=String(t+1),r=e.state.doc.content.size;e.chain().focus().insertFootnoteReference(n).insertContentAt(r+1,{type:`footnoteDefinition`,attrs:{identifier:n,label:n},content:[{type:`paragraph`}]}).run()},aliases:[`fn`,`ref`,`[^`],preview:{description:`Insert a footnote reference + matching definition stub.`,render:()=>(0,X.jsxs)(`p`,{className:`text-sm leading-6`,children:[`A line with a footnote`,(0,X.jsx)(`sup`,{className:`footnote-ref`,children:(0,X.jsx)(`a`,{className:`footnote-ref-link`,href:`#fn-1`,children:`[1]`})}),` `,`and a definition shown below.`]})}},{name:`inlineMath`,label:`Inline Math`,icon:ua,category:`insert`,command:e=>{let t=e.state.selection.from;e.chain().focus().insertMathInline(``).run(),aA(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})},aliases:[`math`,`latex`,`equation`,`formula`,`katex`,`inlinemath`],preview:{description:`Inline LaTeX math rendered with KaTeX.`,render:()=>(0,X.jsxs)(`p`,{className:`text-sm leading-7`,children:[`The formula`,` `,(0,X.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-serif italic`,children:`c = √(a² + b²)`}),` `,`renders inline.`]})}}];function hA(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)||e.aliases?.some(e=>e.toLowerCase().includes(n)))}function gA(e){let{$from:t}=e.selection;return t.depth===0?null:{from:t.before(1),to:t.after(1)}}function _A(e,t){let n=gA(e);if(!n)return!1;let{from:r,to:i}=n;if(r===0)return!1;let a=e.doc.resolve(r-1);if(a.depth===0)return!1;let o=a.before(1),c=e.doc.slice(r,i).content,l=e.doc.slice(o,r).content;if(!t)return!0;let u=e.tr;u.replaceWith(o,i,c.append(l));let d=o+1,f=o+c.size,p=e.selection.from-r,m=Math.min(d+p,f);return u.setSelection(s.near(u.doc.resolve(m))),u.scrollIntoView(),t(u),!0}function vA(e,t){let n=gA(e);if(!n)return!1;let{from:r,to:i}=n;if(i>=e.doc.content.size)return!1;let a=e.doc.resolve(i+1);if(a.depth===0)return!1;let o=a.after(1),c=e.doc.slice(r,i).content,l=e.doc.slice(i,o).content;if(!t)return!0;let u=e.tr;u.replaceWith(r,o,l.append(c));let d=r+l.size+1,f=r+l.size+c.size,p=e.selection.from-r,m=Math.min(d+p,f);return u.setSelection(s.near(u.doc.resolve(m))),u.scrollIntoView(),t(u),!0}var yA=g.create({name:`blockMover`,addKeyboardShortcuts(){return{"Mod-Shift-ArrowUp":({editor:e})=>_A(e.state,e.view.dispatch),"Mod-Shift-ArrowDown":({editor:e})=>vA(e.state,e.view.dispatch)}}}),bA=new W(`bridgeId`);function xA(e){let t=mv.getState(e);return t?.binding?.mapping?t.binding.mapping:null}function SA(e){let t=xA(e);if(!t)return null;let n=new Map;for(let[e,r]of t)r&&`nodeName`in e&&typeof e.getAttribute==`function`&&n.set(r,e);return n}function CA(e,t){return e?e.get(t)??null:null}var wA=g.create({name:`bridgeIdPlugin`,priority:1e3,addProseMirrorPlugins(){return[new Oe({key:bA,state:{init(e,t){let n={yElementToId:new WeakMap,posToId:new Map,counter:0},r=SA(t);return t.doc.descendants((e,t)=>{if(e.type.name!==`jsxComponent`)return;let i=CA(r,e);if(i){let e=`b${++n.counter}`;n.yElementToId.set(i,e),n.posToId.set(t,e)}else{let e=`b${++n.counter}`;n.posToId.set(t,e)}}),n},apply(e,t,n,r){if(!e.docChanged){let n=new Map;for(let[i,a]of t.posToId){let t=e.mapping.map(i);r.doc.nodeAt(t)?.type.name===`jsxComponent`&&n.set(t,a)}return{...t,posToId:n}}let i=new Map,{counter:a}=t,{yElementToId:o}=t,s=SA(r);return r.doc.descendants((n,r)=>{if(n.type.name!==`jsxComponent`)return;let c=CA(s,n);if(c){let e=o.get(c);if(e)i.set(r,e);else{let e=`b${++a}`;o.set(c,e),i.set(r,e)}}else{let n=!1;for(let[a,o]of t.posToId)if(e.mapping.map(a)===r){i.set(r,o),n=!0;break}if(!n){let e=`b${++a}`;i.set(r,e)}}}),{yElementToId:o,posToId:i,counter:a}}}})]}}),TA=new W(`chunkWrapperDecoration`),EA=`ok-chunk-wrapper`,DA=!1;function OA(){return globalThis.CSS===void 0||typeof globalThis.CSS.supports!=`function`?!0:globalThis.CSS.supports(`content-visibility`,`auto`)}var kA=OA();function AA(){return kA?new Oe({key:TA,props:{decorations(e){let t=[];return e.doc.forEach((e,n)=>{e.isInline||e.type.name!==`jsxComponent`&&e.type.name!==`heading`&&t.push(we.node(n,n+e.nodeSize,{class:EA}))}),t.length===0?null:(DA||(DA=!0,Z(`ok/render/cv-auto-skip`,{chunkCount:t.length},{startTime:performance.now(),duration:0})),C.create(e.doc,t))}}}):new Oe({key:TA})}function jA(e){let t=e.regex,n=e.COMMENT(`//`,`$`,{contains:[{begin:/\\\n/}]}),r=`decltype\\(auto\\)`,i=`[a-zA-Z_]\\w*::`,a=`(?!struct)(`+r+`|`+t.optional(i)+`[a-zA-Z_]\\w*`+t.optional(`<[^<>]+>`)+`)`,o={className:`type`,begin:`\\b[a-z\\d_]*_t\\b`},s={className:`string`,variants:[{begin:`(u8?|U|L)?"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]},{begin:`(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)`,end:`'`,illegal:`.`},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:`number`,variants:[{begin:`[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)`},{begin:`[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)`}],relevance:0},l={className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(s,{className:`string`}),{className:`string`,begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},u={className:`title`,begin:t.optional(i)+e.IDENT_RE,relevance:0},d=t.optional(i)+e.IDENT_RE+`\\s*\\(`,f=`alignas.alignof.and.and_eq.asm.atomic_cancel.atomic_commit.atomic_noexcept.auto.bitand.bitor.break.case.catch.class.co_await.co_return.co_yield.compl.concept.const_cast|10.consteval.constexpr.constinit.continue.decltype.default.delete.do.dynamic_cast|10.else.enum.explicit.export.extern.false.final.for.friend.goto.if.import.inline.module.mutable.namespace.new.noexcept.not.not_eq.nullptr.operator.or.or_eq.override.private.protected.public.reflexpr.register.reinterpret_cast|10.requires.return.sizeof.static_assert.static_cast|10.struct.switch.synchronized.template.this.thread_local.throw.transaction_safe.transaction_safe_dynamic.true.try.typedef.typeid.typename.union.using.virtual.volatile.while.xor.xor_eq`.split(`.`),p=[`bool`,`char`,`char16_t`,`char32_t`,`char8_t`,`double`,`float`,`int`,`long`,`short`,`void`,`wchar_t`,`unsigned`,`signed`,`const`,`static`],m=`any.auto_ptr.barrier.binary_semaphore.bitset.complex.condition_variable.condition_variable_any.counting_semaphore.deque.false_type.flat_map.flat_set.future.imaginary.initializer_list.istringstream.jthread.latch.lock_guard.multimap.multiset.mutex.optional.ostringstream.packaged_task.pair.promise.priority_queue.queue.recursive_mutex.recursive_timed_mutex.scoped_lock.set.shared_future.shared_lock.shared_mutex.shared_timed_mutex.shared_ptr.stack.string_view.stringstream.timed_mutex.thread.true_type.tuple.unique_lock.unique_ptr.unordered_map.unordered_multimap.unordered_multiset.unordered_set.variant.vector.weak_ptr.wstring.wstring_view`.split(`.`),h=`abort.abs.acos.apply.as_const.asin.atan.atan2.calloc.ceil.cerr.cin.clog.cos.cosh.cout.declval.endl.exchange.exit.exp.fabs.floor.fmod.forward.fprintf.fputs.free.frexp.fscanf.future.invoke.isalnum.isalpha.iscntrl.isdigit.isgraph.islower.isprint.ispunct.isspace.isupper.isxdigit.labs.launder.ldexp.log.log10.make_pair.make_shared.make_shared_for_overwrite.make_tuple.make_unique.malloc.memchr.memcmp.memcpy.memset.modf.move.pow.printf.putchar.puts.realloc.scanf.sin.sinh.snprintf.sprintf.sqrt.sscanf.std.stderr.stdin.stdout.strcat.strchr.strcmp.strcpy.strcspn.strlen.strncat.strncmp.strncpy.strpbrk.strrchr.strspn.strstr.swap.tan.tanh.terminate.to_underlying.tolower.toupper.vfprintf.visit.vprintf.vsprintf`.split(`.`),g={type:p,keyword:f,literal:[`NULL`,`false`,`nullopt`,`nullptr`,`true`],built_in:[`_Pragma`],_type_hints:m},_={className:`function.dispatch`,relevance:0,keywords:{_hint:h},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},v=[_,l,o,n,e.C_BLOCK_COMMENT_MODE,c,s],y={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:`new throw return else`,end:/;/}],keywords:g,contains:v.concat([{begin:/\(/,end:/\)/,keywords:g,contains:v.concat([`self`]),relevance:0}]),relevance:0},b={className:`function`,begin:`(`+a+`[\\*&\\s]+)+`+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:g,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:g,relevance:0},{begin:d,returnBegin:!0,contains:[u],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[s,c]},{relevance:0,match:/,/},{className:`params`,begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,s,c,o,{begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[`self`,n,e.C_BLOCK_COMMENT_MODE,s,c,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,l]};return{name:`C++`,aliases:[`cc`,`c++`,`h++`,`hpp`,`hh`,`hxx`,`cxx`],keywords:g,illegal:`</`,classNameAliases:{"function.dispatch":`built_in`},contains:[].concat(y,b,_,v,[l,{begin:`\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)`,end:`>`,keywords:g,contains:[`self`,o]},{begin:e.IDENT_RE+`::`,keywords:g},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:`keyword`,3:`title.class`}}])}}function MA(e){let t={type:[`boolean`,`byte`,`word`,`String`],built_in:`KeyboardController.MouseController.SoftwareSerial.EthernetServer.EthernetClient.LiquidCrystal.RobotControl.GSMVoiceCall.EthernetUDP.EsploraTFT.HttpClient.RobotMotor.WiFiClient.GSMScanner.FileSystem.Scheduler.GSMServer.YunClient.YunServer.IPAddress.GSMClient.GSMModem.Keyboard.Ethernet.Console.GSMBand.Esplora.Stepper.Process.WiFiUDP.GSM_SMS.Mailbox.USBHost.Firmata.PImage.Client.Server.GSMPIN.FileIO.Bridge.Serial.EEPROM.Stream.Mouse.Audio.Servo.File.Task.GPRS.WiFi.Wire.TFT.GSM.SPI.SD`.split(`.`),_hints:`setup.loop.runShellCommandAsynchronously.analogWriteResolution.retrieveCallingNumber.printFirmwareVersion.analogReadResolution.sendDigitalPortPair.noListenOnLocalhost.readJoystickButton.setFirmwareVersion.readJoystickSwitch.scrollDisplayRight.getVoiceCallStatus.scrollDisplayLeft.writeMicroseconds.delayMicroseconds.beginTransmission.getSignalStrength.runAsynchronously.getAsynchronously.listenOnLocalhost.getCurrentCarrier.readAccelerometer.messageAvailable.sendDigitalPorts.lineFollowConfig.countryNameWrite.runShellCommand.readStringUntil.rewindDirectory.readTemperature.setClockDivider.readLightSensor.endTransmission.analogReference.detachInterrupt.countryNameRead.attachInterrupt.encryptionType.readBytesUntil.robotNameWrite.readMicrophone.robotNameRead.cityNameWrite.userNameWrite.readJoystickY.readJoystickX.mouseReleased.openNextFile.scanNetworks.noInterrupts.digitalWrite.beginSpeaker.mousePressed.isActionDone.mouseDragged.displayLogos.noAutoscroll.addParameter.remoteNumber.getModifiers.keyboardRead.userNameRead.waitContinue.processInput.parseCommand.printVersion.readNetworks.writeMessage.blinkVersion.cityNameRead.readMessage.setDataMode.parsePacket.isListening.setBitOrder.beginPacket.isDirectory.motorsWrite.drawCompass.digitalRead.clearScreen.serialEvent.rightToLeft.setTextSize.leftToRight.requestFrom.keyReleased.compassRead.analogWrite.interrupts.WiFiServer.disconnect.playMelody.parseFloat.autoscroll.getPINUsed.setPINUsed.setTimeout.sendAnalog.readSlider.analogRead.beginWrite.createChar.motorsStop.keyPressed.tempoWrite.readButton.subnetMask.debugPrint.macAddress.writeGreen.randomSeed.attachGPRS.readString.sendString.remotePort.releaseAll.mouseMoved.background.getXChange.getYChange.answerCall.getResult.voiceCall.endPacket.constrain.getSocket.writeJSON.getButton.available.connected.findUntil.readBytes.exitValue.readGreen.writeBlue.startLoop.IPAddress.isPressed.sendSysex.pauseMode.gatewayIP.setCursor.getOemKey.tuneWrite.noDisplay.loadImage.switchPIN.onRequest.onReceive.changePIN.playFile.noBuffer.parseInt.overflow.checkPIN.knobRead.beginTFT.bitClear.updateIR.bitWrite.position.writeRGB.highByte.writeRed.setSpeed.readBlue.noStroke.remoteIP.transfer.shutdown.hangCall.beginSMS.endWrite.attached.maintain.noCursor.checkReg.checkPUK.shiftOut.isValid.shiftIn.pulseIn.connect.println.localIP.pinMode.getIMEI.display.noBlink.process.getBand.running.beginSD.drawBMP.lowByte.setBand.release.bitRead.prepare.pointTo.readRed.setMode.noFill.remove.listen.stroke.detach.attach.noTone.exists.buffer.height.bitSet.circle.config.cursor.random.IRread.setDNS.endSMS.getKey.micros.millis.begin.print.write.ready.flush.width.isPIN.blink.clear.press.mkdir.rmdir.close.point.yield.image.BSSID.click.delay.read.text.move.peek.beep.rect.line.open.seek.fill.size.turn.stop.home.find.step.tone.sqrt.RSSI.SSID.end.bit.tan.cos.sin.pow.map.abs.max.min.get.run.put`.split(`.`),literal:[`DIGITAL_MESSAGE`,`FIRMATA_STRING`,`ANALOG_MESSAGE`,`REPORT_DIGITAL`,`REPORT_ANALOG`,`INPUT_PULLUP`,`SET_PIN_MODE`,`INTERNAL2V56`,`SYSTEM_RESET`,`LED_BUILTIN`,`INTERNAL1V1`,`SYSEX_START`,`INTERNAL`,`EXTERNAL`,`DEFAULT`,`OUTPUT`,`INPUT`,`HIGH`,`LOW`]},n=jA(e),r=n.keywords;return r.type=[...r.type,...t.type],r.literal=[...r.literal,...t.literal],r.built_in=[...r.built_in,...t.built_in],r._hints=t._hints,n.name=`Arduino`,n.aliases=[`ino`],n.supersetOf=`cpp`,n}function NA(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}function PA(e){let t=e.regex,n=e.COMMENT(`//`,`$`,{contains:[{begin:/\\\n/}]}),r=`decltype\\(auto\\)`,i=`[a-zA-Z_]\\w*::`,a=`(`+r+`|`+t.optional(i)+`[a-zA-Z_]\\w*`+t.optional(`<[^<>]+>`)+`)`,o={className:`type`,variants:[{begin:`\\b[a-z\\d_]*_t\\b`},{match:/\batomic_[a-z]{3,6}\b/}]},s={className:`string`,variants:[{begin:`(u8?|U|L)?"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]},{begin:`(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)`,end:`'`,illegal:`.`},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:`number`,variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},l={className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(s,{className:`string`}),{className:`string`,begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},u={className:`title`,begin:t.optional(i)+e.IDENT_RE,relevance:0},d=t.optional(i)+e.IDENT_RE+`\\s*\\(`,f={keyword:`asm.auto.break.case.continue.default.do.else.enum.extern.for.fortran.goto.if.inline.register.restrict.return.sizeof.typeof.typeof_unqual.struct.switch.typedef.union.volatile.while._Alignas._Alignof._Atomic._Generic._Noreturn._Static_assert._Thread_local.alignas.alignof.noreturn.static_assert.thread_local._Pragma`.split(`.`),type:`float.double.signed.unsigned.int.short.long.char.void._Bool._BitInt._Complex._Imaginary._Decimal32._Decimal64._Decimal96._Decimal128._Decimal64x._Decimal128x._Float16._Float32._Float64._Float128._Float32x._Float64x._Float128x.const.static.constexpr.complex.bool.imaginary`.split(`.`),literal:`true false NULL`,built_in:`std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr`},p=[l,o,n,e.C_BLOCK_COMMENT_MODE,c,s],m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:`new throw return else`,end:/;/}],keywords:f,contains:p.concat([{begin:/\(/,end:/\)/,keywords:f,contains:p.concat([`self`]),relevance:0}]),relevance:0},h={begin:`(`+a+`[\\*&\\s]+)+`+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:f,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:f,relevance:0},{begin:d,returnBegin:!0,contains:[e.inherit(u,{className:`title.function`})],relevance:0},{relevance:0,match:/,/},{className:`params`,begin:/\(/,end:/\)/,keywords:f,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,s,c,o,{begin:/\(/,end:/\)/,keywords:f,relevance:0,contains:[`self`,n,e.C_BLOCK_COMMENT_MODE,s,c,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,l]};return{name:`C`,aliases:[`h`],keywords:f,disableAutodetect:!0,illegal:`</`,contains:[].concat(m,h,p,[l,{begin:e.IDENT_RE+`::`,keywords:f},{className:`class`,beginKeywords:`enum class struct union`,end:/[{;:<>=]/,contains:[{beginKeywords:`final class struct`},e.TITLE_MODE]}]),exports:{preprocessor:l,strings:s,keywords:f}}}function FA(e){let t=e.regex,n=e.COMMENT(`//`,`$`,{contains:[{begin:/\\\n/}]}),r=`decltype\\(auto\\)`,i=`[a-zA-Z_]\\w*::`,a=`(?!struct)(`+r+`|`+t.optional(i)+`[a-zA-Z_]\\w*`+t.optional(`<[^<>]+>`)+`)`,o={className:`type`,begin:`\\b[a-z\\d_]*_t\\b`},s={className:`string`,variants:[{begin:`(u8?|U|L)?"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]},{begin:`(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)`,end:`'`,illegal:`.`},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},c={className:`number`,variants:[{begin:`[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)`},{begin:`[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)`}],relevance:0},l={className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(s,{className:`string`}),{className:`string`,begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},u={className:`title`,begin:t.optional(i)+e.IDENT_RE,relevance:0},d=t.optional(i)+e.IDENT_RE+`\\s*\\(`,f=`alignas.alignof.and.and_eq.asm.atomic_cancel.atomic_commit.atomic_noexcept.auto.bitand.bitor.break.case.catch.class.co_await.co_return.co_yield.compl.concept.const_cast|10.consteval.constexpr.constinit.continue.decltype.default.delete.do.dynamic_cast|10.else.enum.explicit.export.extern.false.final.for.friend.goto.if.import.inline.module.mutable.namespace.new.noexcept.not.not_eq.nullptr.operator.or.or_eq.override.private.protected.public.reflexpr.register.reinterpret_cast|10.requires.return.sizeof.static_assert.static_cast|10.struct.switch.synchronized.template.this.thread_local.throw.transaction_safe.transaction_safe_dynamic.true.try.typedef.typeid.typename.union.using.virtual.volatile.while.xor.xor_eq`.split(`.`),p=[`bool`,`char`,`char16_t`,`char32_t`,`char8_t`,`double`,`float`,`int`,`long`,`short`,`void`,`wchar_t`,`unsigned`,`signed`,`const`,`static`],m=`any.auto_ptr.barrier.binary_semaphore.bitset.complex.condition_variable.condition_variable_any.counting_semaphore.deque.false_type.flat_map.flat_set.future.imaginary.initializer_list.istringstream.jthread.latch.lock_guard.multimap.multiset.mutex.optional.ostringstream.packaged_task.pair.promise.priority_queue.queue.recursive_mutex.recursive_timed_mutex.scoped_lock.set.shared_future.shared_lock.shared_mutex.shared_timed_mutex.shared_ptr.stack.string_view.stringstream.timed_mutex.thread.true_type.tuple.unique_lock.unique_ptr.unordered_map.unordered_multimap.unordered_multiset.unordered_set.variant.vector.weak_ptr.wstring.wstring_view`.split(`.`),h=`abort.abs.acos.apply.as_const.asin.atan.atan2.calloc.ceil.cerr.cin.clog.cos.cosh.cout.declval.endl.exchange.exit.exp.fabs.floor.fmod.forward.fprintf.fputs.free.frexp.fscanf.future.invoke.isalnum.isalpha.iscntrl.isdigit.isgraph.islower.isprint.ispunct.isspace.isupper.isxdigit.labs.launder.ldexp.log.log10.make_pair.make_shared.make_shared_for_overwrite.make_tuple.make_unique.malloc.memchr.memcmp.memcpy.memset.modf.move.pow.printf.putchar.puts.realloc.scanf.sin.sinh.snprintf.sprintf.sqrt.sscanf.std.stderr.stdin.stdout.strcat.strchr.strcmp.strcpy.strcspn.strlen.strncat.strncmp.strncpy.strpbrk.strrchr.strspn.strstr.swap.tan.tanh.terminate.to_underlying.tolower.toupper.vfprintf.visit.vprintf.vsprintf`.split(`.`),g={type:p,keyword:f,literal:[`NULL`,`false`,`nullopt`,`nullptr`,`true`],built_in:[`_Pragma`],_type_hints:m},_={className:`function.dispatch`,relevance:0,keywords:{_hint:h},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},v=[_,l,o,n,e.C_BLOCK_COMMENT_MODE,c,s],y={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:`new throw return else`,end:/;/}],keywords:g,contains:v.concat([{begin:/\(/,end:/\)/,keywords:g,contains:v.concat([`self`]),relevance:0}]),relevance:0},b={className:`function`,begin:`(`+a+`[\\*&\\s]+)+`+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:g,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:g,relevance:0},{begin:d,returnBegin:!0,contains:[u],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[s,c]},{relevance:0,match:/,/},{className:`params`,begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,s,c,o,{begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[`self`,n,e.C_BLOCK_COMMENT_MODE,s,c,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,l]};return{name:`C++`,aliases:[`cc`,`c++`,`h++`,`hpp`,`hh`,`hxx`,`cxx`],keywords:g,illegal:`</`,classNameAliases:{"function.dispatch":`built_in`},contains:[].concat(y,b,_,v,[l,{begin:`\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)`,end:`>`,keywords:g,contains:[`self`,o]},{begin:e.IDENT_RE+`::`,keywords:g},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:`keyword`,3:`title.class`}}])}}function IA(e){let t=[`bool`,`byte`,`char`,`decimal`,`delegate`,`double`,`dynamic`,`enum`,`float`,`int`,`long`,`nint`,`nuint`,`object`,`sbyte`,`short`,`string`,`ulong`,`uint`,`ushort`],n=[`public`,`private`,`protected`,`static`,`internal`,`protected`,`abstract`,`async`,`extern`,`override`,`unsafe`,`virtual`,`new`,`sealed`,`partial`],r={keyword:`abstract.as.base.break.case.catch.class.const.continue.do.else.event.explicit.extern.finally.fixed.for.foreach.goto.if.implicit.in.interface.internal.is.lock.namespace.new.operator.out.override.params.private.protected.public.readonly.record.ref.return.scoped.sealed.sizeof.stackalloc.static.struct.switch.this.throw.try.typeof.unchecked.unsafe.using.virtual.void.volatile.while`.split(`.`).concat(`add.alias.and.ascending.args.async.await.by.descending.dynamic.equals.file.from.get.global.group.init.into.join.let.nameof.not.notnull.on.or.orderby.partial.record.remove.required.scoped.select.set.unmanaged.value|0.var.when.where.with.yield`.split(`.`)),built_in:t,literal:[`default`,`false`,`null`,`true`]},i=e.inherit(e.TITLE_MODE,{begin:`[a-zA-Z](\\.?\\w)*`}),a={className:`number`,variants:[{begin:`\\b(0b[01']+)`},{begin:`(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)`},{begin:`(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)`}],relevance:0},o={className:`string`,begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},s={className:`string`,begin:`@"`,end:`"`,contains:[{begin:`""`}]},c=e.inherit(s,{illegal:/\n/}),l={className:`subst`,begin:/\{/,end:/\}/,keywords:r},u=e.inherit(l,{illegal:/\n/}),d={className:`string`,begin:/\$"/,end:`"`,illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,u]},f={className:`string`,begin:/\$@"/,end:`"`,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:`""`},l]},p=e.inherit(f,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:`""`},u]});l.contains=[f,d,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],u.contains=[p,d,c,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let m={variants:[o,f,d,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h={begin:`<`,end:`>`,contains:[{beginKeywords:`in out`},i]},g=e.IDENT_RE+`(<`+e.IDENT_RE+`(\\s*,\\s*`+e.IDENT_RE+`)*>)?(\\[\\])?`,_={begin:`@`+e.IDENT_RE,relevance:0};return{name:`C#`,aliases:[`cs`,`c#`],keywords:r,illegal:/::/,contains:[e.COMMENT(`///`,`$`,{returnBegin:!0,contains:[{className:`doctag`,variants:[{begin:`///`,relevance:0},{begin:`<!--|-->`},{begin:`</?`,end:`>`}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:`meta`,begin:`#`,end:`$`,keywords:{keyword:`if else elif endif define undef warning error line region endregion pragma checksum`}},m,a,{beginKeywords:`class interface`,relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:`where class`},i,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`namespace`,relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[i,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`record`,relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[i,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:`meta`,begin:`^\\s*\\[(?=[\\w])`,excludeBegin:!0,end:`\\]`,excludeEnd:!0,contains:[{className:`string`,begin:/"/,end:/"/}]},{beginKeywords:`new return throw await else`,relevance:0},{className:`function`,begin:`(`+g+`\\s+)+`+e.IDENT_RE+`\\s*(<[^=]+>\\s*)?\\(`,returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:r,contains:[{beginKeywords:n.join(` `),relevance:0},{begin:e.IDENT_RE+`\\s*(<[^=]+>\\s*)?\\(`,returnBegin:!0,contains:[e.TITLE_MODE,h],relevance:0},{match:/\(\)/},{className:`params`,begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:r,relevance:0,contains:[m,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},_]}}var LA=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),RA=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),zA=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),BA=[...RA,...zA],VA=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),HA=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),UA=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),WA=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function GA(e){let t=e.regex,n=LA(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+HA.join(`|`)+`)`},{begin:`:(:)?(`+UA.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+WA.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:VA.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+BA.join(`|`)+`)\\b`}]}}function KA(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}function qA(e){let t={keyword:[`break`,`case`,`chan`,`const`,`continue`,`default`,`defer`,`else`,`fallthrough`,`for`,`func`,`go`,`goto`,`if`,`import`,`interface`,`map`,`package`,`range`,`return`,`select`,`struct`,`switch`,`type`,`var`],type:[`bool`,`byte`,`complex64`,`complex128`,`error`,`float32`,`float64`,`int8`,`int16`,`int32`,`int64`,`string`,`uint8`,`uint16`,`uint32`,`uint64`,`int`,`uint`,`uintptr`,`rune`],literal:[`true`,`false`,`iota`,`nil`],built_in:[`append`,`cap`,`close`,`complex`,`copy`,`imag`,`len`,`make`,`new`,`panic`,`print`,`println`,`real`,`recover`,`delete`]};return{name:`Go`,aliases:[`golang`],keywords:t,illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:`string`,variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:`number`,variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:`function`,beginKeywords:`func`,end:`\\s*(\\{|$)`,excludeEnd:!0,contains:[e.TITLE_MODE,{className:`params`,begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}function JA(e){let t=e.regex;return{name:`GraphQL`,aliases:[`gql`],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:[`query`,`mutation`,`subscription`,`type`,`input`,`schema`,`directive`,`interface`,`union`,`scalar`,`fragment`,`enum`,`on`],literal:[`true`,`false`,`null`]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:`punctuation`,match:/[.]{3}/,relevance:0},{scope:`punctuation`,begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:`variable`,begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:`meta`,match:/@\w+/,excludeEnd:!0},{scope:`symbol`,begin:t.concat(/[_A-Za-z][_0-9A-Za-z]*/,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function YA(e){let t=e.regex,n={className:`number`,relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:`variable`,variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:`literal`,begin:/\bon|off|true|false|yes|no\b/},o={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:`'''`,end:`'''`,relevance:10},{begin:`"""`,end:`"""`,relevance:10},{begin:`"`,end:`"`},{begin:`'`,end:`'`}]},s={begin:/\[/,end:/\]/,contains:[r,a,i,o,n,`self`],relevance:0},c=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:`TOML, also INI`,aliases:[`toml`],case_insensitive:!0,illegal:/\S/,contains:[r,{className:`section`,begin:/\[+/,end:/\]+/},{begin:t.concat(c,`(\\s*\\.\\s*`,c,`)*`,t.lookahead(/\s*=\s*[^#\s]/)),className:`attr`,starts:{end:/$/,contains:[r,s,a,i,o,n]}}]}}var XA=`[0-9](_*[0-9])*`,ZA=`\\.(${XA})`,QA=`[0-9a-fA-F](_*[0-9a-fA-F])*`,$A={className:`number`,variants:[{begin:`(\\b(${XA})((${ZA})|\\.)?|(${ZA}))[eE][+-]?(${XA})[fFdD]?\\b`},{begin:`\\b(${XA})((${ZA})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${ZA})[fFdD]?\\b`},{begin:`\\b(${XA})[fFdD]\\b`},{begin:`\\b0[xX]((${QA})\\.?|(${QA})?\\.(${QA}))[pP][+-]?(${XA})[fFdD]?\\b`},{begin:`\\b(0|[1-9](_*[0-9])*)[lL]?\\b`},{begin:`\\b0[xX](${QA})[lL]?\\b`},{begin:`\\b0(_*[0-7])*[lL]?\\b`},{begin:`\\b0[bB][01](_*[01])*[lL]?\\b`}],relevance:0};function ej(e,t,n){return n===-1?``:e.replace(t,r=>ej(e,t,n-1))}function tj(e){let t=e.regex,n=`[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*`,r=n+ej(`(?:<`+n+`~~~(?:\\s*,\\s*[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*~~~)*>)?`,/~~~/g,2),i={keyword:`synchronized.abstract.private.var.static.if.const .for.while.strictfp.finally.protected.import.native.final.void.enum.else.break.transient.catch.instanceof.volatile.case.assert.package.default.public.try.switch.continue.throws.protected.public.private.module.requires.exports.do.sealed.yield.permits.goto.when`.split(`.`),literal:[`false`,`true`,`null`],type:[`char`,`boolean`,`long`,`float`,`int`,`byte`,`short`,`double`],built_in:[`super`,`this`]},a={className:`meta`,begin:`@`+n,contains:[{begin:/\(/,end:/\)/,contains:[`self`]}]},o={className:`params`,begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:`Java`,aliases:[`jsp`],keywords:i,illegal:/<\/|#/,contains:[e.COMMENT(`/\\*\\*`,`\\*/`,{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:`doctag`,begin:`@[A-Za-z]+`}]}),{begin:/import java\.[a-z]+\./,keywords:`import`,relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:`string`,contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:`keyword`,3:`title.class`}},{match:/non-sealed/,scope:`keyword`},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:`type`,3:`variable`,5:`operator`}},{begin:[/record/,/\s+/,n],className:{1:`keyword`,3:`title.class`},contains:[o,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`new throw return else`,relevance:0},{begin:[`(?:`+r+`\\s+)`,e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:`title.function`},keywords:i,contains:[{className:`params`,begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,$A,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},$A,a]}}var nj=`[A-Za-z$_][0-9A-Za-z$_]*`,rj=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),ij=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],aj=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),oj=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],sj=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],cj=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],lj=[].concat(sj,aj,oj);function uj(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=nj,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:nj,keyword:rj,literal:ij,built_in:lj,"variable.language":cj},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...aj,...oj]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...sj,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function dj(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}var fj=`[0-9](_*[0-9])*`,pj=`\\.(${fj})`,mj=`[0-9a-fA-F](_*[0-9a-fA-F])*`,hj={className:`number`,variants:[{begin:`(\\b(${fj})((${pj})|\\.)?|(${pj}))[eE][+-]?(${fj})[fFdD]?\\b`},{begin:`\\b(${fj})((${pj})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${pj})[fFdD]?\\b`},{begin:`\\b(${fj})[fFdD]\\b`},{begin:`\\b0[xX]((${mj})\\.?|(${mj})?\\.(${mj}))[pP][+-]?(${fj})[fFdD]?\\b`},{begin:`\\b(0|[1-9](_*[0-9])*)[lL]?\\b`},{begin:`\\b0[xX](${mj})[lL]?\\b`},{begin:`\\b0(_*[0-7])*[lL]?\\b`},{begin:`\\b0[bB][01](_*[01])*[lL]?\\b`}],relevance:0};function gj(e){let t={keyword:`abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual`,built_in:`Byte Short Char Int Long Boolean Float Double Void Unit Nothing`,literal:`true false null`},n={className:`keyword`,begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:`symbol`,begin:/@\w+/}]}},r={className:`symbol`,begin:e.UNDERSCORE_IDENT_RE+`@`},i={className:`subst`,begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},a={className:`variable`,begin:`\\$`+e.UNDERSCORE_IDENT_RE},o={className:`string`,variants:[{begin:`"""`,end:`"""(?=[^"])`,contains:[a,i]},{begin:`'`,end:`'`,illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:`"`,end:`"`,illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,a,i]}]};i.contains.push(o);let s={className:`meta`,begin:`@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*`+e.UNDERSCORE_IDENT_RE+`)?`},c={className:`meta`,begin:`@`+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(o,{className:`string`}),`self`]}]},l=hj,u=e.COMMENT(`/\\*`,`\\*/`,{contains:[e.C_BLOCK_COMMENT_MODE]}),d={variants:[{className:`type`,begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},f=d;return f.variants[1].contains=[d],d.variants[1].contains=[f],{name:`Kotlin`,aliases:[`kt`,`kts`],keywords:t,contains:[e.COMMENT(`/\\*\\*`,`\\*/`,{relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`}]}),e.C_LINE_COMMENT_MODE,u,n,r,s,c,{className:`function`,beginKeywords:`fun`,end:`[(]|$`,returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+`\\s*\\(`,returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:`type`,begin:/</,end:/>/,keywords:`reified`,relevance:0},{className:`params`,begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[d,e.C_LINE_COMMENT_MODE,u],relevance:0},e.C_LINE_COMMENT_MODE,u,s,c,o,e.C_NUMBER_MODE]},u]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:`title.class`},keywords:`class interface trait`,end:/[:\{(]|$/,excludeEnd:!0,illegal:`extends implements`,contains:[{beginKeywords:`public protected internal private constructor`},e.UNDERSCORE_TITLE_MODE,{className:`type`,begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},s,c]},o,{className:`meta`,begin:`^#!/usr/bin/env`,end:`$`,illegal:`
8
8
  `},l]}}var _j=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),vj=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),yj=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),bj=[...vj,...yj],xj=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),Sj=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),Cj=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),wj=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse(),Tj=Sj.concat(Cj).sort().reverse();function Ej(e){let t=_j(e),n=Tj,r=`[\\w-]+`,i=`(`+r+`|@\\{[\\w-]+\\})`,a=[],o=[],s=function(e){return{className:`string`,begin:`~?`+e+`.*?`+e}},c=function(e,t,n){return{className:e,begin:t,relevance:n}},l={$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:xj.join(` `)},u={begin:`\\(`,end:`\\)`,contains:o,keywords:l,relevance:0};o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s(`'`),s(`"`),t.CSS_NUMBER_MODE,{begin:`(url|data-uri)\\(`,starts:{className:`string`,end:`[\\)\\n]`,excludeEnd:!0}},t.HEXCOLOR,u,c(`variable`,`@@?`+r,10),c(`variable`,`@\\{`+r+`\\}`),c(`built_in`,"~?`[^`]*?`"),{className:`attribute`,begin:r+`\\s*:`,end:`:`,returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:`and not`},t.FUNCTION_DISPATCH);let d=o.concat({begin:/\{/,end:/\}/,contains:a}),f={beginKeywords:`when`,endsWithParent:!0,contains:[{beginKeywords:`and not`}].concat(o)},p={begin:i+`\\s*:`,returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+wj.join(`|`)+`)\\b`,end:/(?=:)/,starts:{endsWithParent:!0,illegal:`[<=$]`,relevance:0,contains:o}}]},m={className:`keyword`,begin:`@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b`,starts:{end:`[;{}]`,keywords:l,returnEnd:!0,contains:o,relevance:0}},h={className:`variable`,variants:[{begin:`@`+r+`\\s*:`,relevance:15},{begin:`@`+r}],starts:{end:`[;}]`,returnEnd:!0,contains:d}},g={variants:[{begin:`[\\.#:&\\[>]`,end:`[;{}]`},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,f,c(`keyword`,`all\\b`),c(`variable`,`@\\{`+r+`\\}`),{begin:`\\b(`+bj.join(`|`)+`)\\b`,className:`selector-tag`},t.CSS_NUMBER_MODE,c(`selector-tag`,i,0),c(`selector-id`,`#`+i),c(`selector-class`,`\\.`+i,0),c(`selector-tag`,`&`,0),t.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,begin:`:(`+Sj.join(`|`)+`)`},{className:`selector-pseudo`,begin:`:(:)?(`+Cj.join(`|`)+`)`},{begin:/\(/,end:/\)/,relevance:0,contains:d},{begin:`!important`},t.FUNCTION_DISPATCH]},_={begin:`[\\w-]+:(:)?(${n.join(`|`)})`,returnBegin:!0,contains:[g]};return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m,h,_,p,g,f,t.FUNCTION_DISPATCH),{name:`Less`,case_insensitive:!0,illegal:`[=>'/<($"]`,contains:a}}function Dj(e){let t=`\\[=*\\[`,n=`\\]=*\\]`,r={begin:t,end:n,contains:[`self`]},i=[e.COMMENT(`--(?!`+t+`)`,`$`),e.COMMENT(`--`+t,n,{contains:[r],relevance:10})];return{name:`Lua`,aliases:[`pluto`],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:`true false nil`,keyword:`and break do else elseif end for goto if in local not or repeat return then until while`,built_in:`_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove`},contains:i.concat([{className:`function`,beginKeywords:`function`,end:`\\)`,contains:[e.inherit(e.TITLE_MODE,{begin:`([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*`}),{className:`params`,begin:`\\(`,endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:`string`,begin:t,end:n,contains:[r],relevance:5}])}}function Oj(e){let t={className:`variable`,variants:[{begin:`\\$\\(`+e.UNDERSCORE_IDENT_RE+`\\)`,contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:`variable`,begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:`subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value`},contains:[t,n]},i={begin:`^`+e.UNDERSCORE_IDENT_RE+`\\s*(?=[:+?]?=)`},a={className:`meta`,begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:`.PHONY`}},o={className:`section`,begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:`Makefile`,aliases:[`mk`,`mak`,`make`],keywords:{$pattern:/[\w-]+/,keyword:`define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath`},contains:[e.HASH_COMMENT_MODE,t,n,r,i,a,o]}}function kj(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Aj(e){let t={className:`built_in`,begin:`\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+`},n=/[a-zA-Z@][a-zA-Z0-9_]*/,r={"variable.language":[`this`,`super`],$pattern:n,keyword:`while.export.sizeof.typedef.const.struct.for.union.volatile.static.mutable.if.do.return.goto.enum.else.break.extern.asm.case.default.register.explicit.typename.switch.continue.inline.readonly.assign.readwrite.self.@synchronized.id.typeof.nonatomic.IBOutlet.IBAction.strong.weak.copy.in.out.inout.bycopy.byref.oneway.__strong.__weak.__block.__autoreleasing.@private.@protected.@public.@try.@property.@end.@throw.@catch.@finally.@autoreleasepool.@synthesize.@dynamic.@selector.@optional.@required.@encode.@package.@import.@defs.@compatibility_alias.__bridge.__bridge_transfer.__bridge_retained.__bridge_retain.__covariant.__contravariant.__kindof._Nonnull._Nullable._Null_unspecified.__FUNCTION__.__PRETTY_FUNCTION__.__attribute__.getter.setter.retain.unsafe_unretained.nonnull.nullable.null_unspecified.null_resettable.class.instancetype.NS_DESIGNATED_INITIALIZER.NS_UNAVAILABLE.NS_REQUIRES_SUPER.NS_RETURNS_INNER_POINTER.NS_INLINE.NS_AVAILABLE.NS_DEPRECATED.NS_ENUM.NS_OPTIONS.NS_SWIFT_UNAVAILABLE.NS_ASSUME_NONNULL_BEGIN.NS_ASSUME_NONNULL_END.NS_REFINED_FOR_SWIFT.NS_SWIFT_NAME.NS_SWIFT_NOTHROW.NS_DURING.NS_HANDLER.NS_ENDHANDLER.NS_VALUERETURN.NS_VOIDRETURN`.split(`.`),literal:[`false`,`true`,`FALSE`,`TRUE`,`nil`,`YES`,`NO`,`NULL`],built_in:[`dispatch_once_t`,`dispatch_queue_t`,`dispatch_sync`,`dispatch_async`,`dispatch_once`],type:[`int`,`float`,`char`,`unsigned`,`signed`,`short`,`long`,`double`,`wchar_t`,`unichar`,`void`,`bool`,`BOOL`,`id|0`,`_Bool`]},i={$pattern:n,keyword:[`@interface`,`@class`,`@protocol`,`@implementation`]};return{name:`Objective-C`,aliases:[`mm`,`objc`,`obj-c`,`obj-c++`,`objective-c++`],keywords:r,illegal:`</`,contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:`string`,variants:[{begin:`@"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]}]},{className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma ifdef ifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),{className:`string`,begin:/<.*?>/,end:/$/,illegal:`\\n`},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:`class`,begin:`(`+i.keyword.join(`|`)+`)\\b`,end:/(\{|$)/,excludeEnd:!0,keywords:i,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:`\\.`+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function jj(e){let t=e.regex,n=`abs.accept.alarm.and.atan2.bind.binmode.bless.break.caller.chdir.chmod.chomp.chop.chown.chr.chroot.class.close.closedir.connect.continue.cos.crypt.dbmclose.dbmopen.defined.delete.die.do.dump.each.else.elsif.endgrent.endhostent.endnetent.endprotoent.endpwent.endservent.eof.eval.exec.exists.exit.exp.fcntl.field.fileno.flock.for.foreach.fork.format.formline.getc.getgrent.getgrgid.getgrnam.gethostbyaddr.gethostbyname.gethostent.getlogin.getnetbyaddr.getnetbyname.getnetent.getpeername.getpgrp.getpriority.getprotobyname.getprotobynumber.getprotoent.getpwent.getpwnam.getpwuid.getservbyname.getservbyport.getservent.getsockname.getsockopt.given.glob.gmtime.goto.grep.gt.hex.if.index.int.ioctl.join.keys.kill.last.lc.lcfirst.length.link.listen.local.localtime.log.lstat.lt.ma.map.method.mkdir.msgctl.msgget.msgrcv.msgsnd.my.ne.next.no.not.oct.open.opendir.or.ord.our.pack.package.pipe.pop.pos.print.printf.prototype.push.q|0.qq.quotemeta.qw.qx.rand.read.readdir.readline.readlink.readpipe.recv.redo.ref.rename.require.reset.return.reverse.rewinddir.rindex.rmdir.say.scalar.seek.seekdir.select.semctl.semget.semop.send.setgrent.sethostent.setnetent.setpgrp.setpriority.setprotoent.setpwent.setservent.setsockopt.shift.shmctl.shmget.shmread.shmwrite.shutdown.sin.sleep.socket.socketpair.sort.splice.split.sprintf.sqrt.srand.stat.state.study.sub.substr.symlink.syscall.sysopen.sysread.sysseek.system.syswrite.tell.telldir.tie.tied.time.times.tr.truncate.uc.ucfirst.umask.undef.unless.unlink.unpack.unshift.untie.until.use.utime.values.vec.wait.waitpid.wantarray.warn.when.while.write.x|0.xor.y|0`.split(`.`),r=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(` `)},a={className:`subst`,begin:`[$@]\\{`,end:`\\}`,keywords:i},o={begin:/->\{/,end:/\}/},s={scope:`attr`,match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:`variable`,variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,`(?![A-Za-z])(?![@$%])`)},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[s]},l={className:`number`,variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},u=[e.BACKSLASH_ESCAPE,a,c],d=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],f=(e,n,i=`\\1`)=>{let a=i===`\\1`?i:t.concat(i,n);return t.concat(t.concat(`(?:`,e,`)`),n,/(?:\\.|[^\\\/])*?/,a,/(?:\\.|[^\\\/])*?/,i,r)},p=(e,n,i)=>t.concat(t.concat(`(?:`,e,`)`),n,/(?:\\.|[^\\\/])*?/,i,r),m=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:`string`,contains:u,variants:[{begin:`q[qwxr]?\\s*\\(`,end:`\\)`,relevance:5},{begin:`q[qwxr]?\\s*\\[`,end:`\\]`,relevance:5},{begin:`q[qwxr]?\\s*\\{`,end:`\\}`,relevance:5},{begin:`q[qwxr]?\\s*\\|`,end:`\\|`,relevance:5},{begin:`q[qwxr]?\\s*<`,end:`>`,relevance:5},{begin:`qw\\s+q`,end:`q`,relevance:5},{begin:`'`,end:`'`,contains:[e.BACKSLASH_ESCAPE]},{begin:`"`,end:`"`},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:`-?\\w+\\s*=>`,relevance:0}]},l,{begin:`(\\/\\/|`+e.RE_STARTERS_RE+`|\\b(split|return|print|reverse|grep)\\b)\\s*`,keywords:`split return print reverse grep`,relevance:0,contains:[e.HASH_COMMENT_MODE,{className:`regexp`,variants:[{begin:f(`s|tr|y`,t.either(...d,{capture:!0}))},{begin:f(`s|tr|y`,`\\(`,`\\)`)},{begin:f(`s|tr|y`,`\\[`,`\\]`)},{begin:f(`s|tr|y`,`\\{`,`\\}`)}],relevance:2},{className:`regexp`,variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:p(`(?:m|qr)?`,/\//,/\//)},{begin:p(`m|qr`,t.either(...d,{capture:!0}),/\1/)},{begin:p(`m|qr`,/\(/,/\)/)},{begin:p(`m|qr`,/\[/,/\]/)},{begin:p(`m|qr`,/\{/,/\}/)}]}]},{className:`function`,beginKeywords:`sub method`,end:`(\\s*\\(.*?\\))?[;{]`,excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s]},{className:`class`,beginKeywords:`class`,end:`[;{]`,excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s,l]},{begin:`-\\w\\b`,relevance:0},{begin:`^__DATA__$`,end:`^__END__$`,subLanguage:`mojolicious`,contains:[{begin:`^@@.*`,end:`$`,className:`comment`}]}];return a.contains=m,o.contains=m,{name:`Perl`,aliases:[`pl`,`pm`],keywords:i,contains:m}}function Mj(e){let t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),a=t.concat(/[A-Z]+/,n),o={scope:`variable`,match:`\\$+`+r},s={scope:`meta`,variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},c={scope:`subst`,variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},l=e.inherit(e.APOS_STRING_MODE,{illegal:null}),u=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)}),d={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(c),"on:begin":(e,t)=>{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},f=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p=`[
9
9
  ]`,m={scope:`string`,variants:[u,l,d,f]},h={scope:`number`,variants:[{begin:`\\b0[bB][01]+(?:_[01]+)*\\b`},{begin:`\\b0[oO][0-7]+(?:_[0-7]+)*\\b`},{begin:`\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b`},{begin:`(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?`}],relevance:0},g=[`false`,`null`,`true`],_=`__CLASS__.__DIR__.__FILE__.__FUNCTION__.__COMPILER_HALT_OFFSET__.__LINE__.__METHOD__.__NAMESPACE__.__TRAIT__.die.echo.exit.include.include_once.print.require.require_once.array.abstract.and.as.binary.bool.boolean.break.callable.case.catch.class.clone.const.continue.declare.default.do.double.else.elseif.empty.enddeclare.endfor.endforeach.endif.endswitch.endwhile.enum.eval.extends.final.finally.float.for.foreach.from.global.goto.if.implements.instanceof.insteadof.int.integer.interface.isset.iterable.list.match|0.mixed.new.never.object.or.private.protected.public.readonly.real.return.string.switch.throw.trait.try.unset.use.var.void.while.xor.yield`.split(`.`),v=`Error|0.AppendIterator.ArgumentCountError.ArithmeticError.ArrayIterator.ArrayObject.AssertionError.BadFunctionCallException.BadMethodCallException.CachingIterator.CallbackFilterIterator.CompileError.Countable.DirectoryIterator.DivisionByZeroError.DomainException.EmptyIterator.ErrorException.Exception.FilesystemIterator.FilterIterator.GlobIterator.InfiniteIterator.InvalidArgumentException.IteratorIterator.LengthException.LimitIterator.LogicException.MultipleIterator.NoRewindIterator.OutOfBoundsException.OutOfRangeException.OuterIterator.OverflowException.ParentIterator.ParseError.RangeException.RecursiveArrayIterator.RecursiveCachingIterator.RecursiveCallbackFilterIterator.RecursiveDirectoryIterator.RecursiveFilterIterator.RecursiveIterator.RecursiveIteratorIterator.RecursiveRegexIterator.RecursiveTreeIterator.RegexIterator.RuntimeException.SeekableIterator.SplDoublyLinkedList.SplFileInfo.SplFileObject.SplFixedArray.SplHeap.SplMaxHeap.SplMinHeap.SplObjectStorage.SplObserver.SplPriorityQueue.SplQueue.SplStack.SplSubject.SplTempFileObject.TypeError.UnderflowException.UnexpectedValueException.UnhandledMatchError.ArrayAccess.BackedEnum.Closure.Fiber.Generator.Iterator.IteratorAggregate.Serializable.Stringable.Throwable.Traversable.UnitEnum.WeakReference.WeakMap.Directory.__PHP_Incomplete_Class.parent.php_user_filter.self.static.stdClass`.split(`.`),y={keyword:_,literal:(e=>{let t=[];return e.forEach(e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())}),t})(g),built_in:v},b=e=>e.map(e=>e.replace(/\|\d+$/,``)),x={variants:[{match:[/new/,t.concat(p,`+`),t.concat(`(?!`,b(v).join(`\\b|`),`\\b)`),i],scope:{1:`keyword`,4:`title.class`}}]},S=t.concat(r,`\\b(?!\\()`),C={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),S],scope:{2:`variable.constant`}},{match:[/::/,/class/],scope:{2:`variable.language`}},{match:[i,t.concat(/::/,t.lookahead(/(?!class\b)/)),S],scope:{1:`title.class`,3:`variable.constant`}},{match:[i,t.concat(`::`,t.lookahead(/(?!class\b)/))],scope:{1:`title.class`}},{match:[i,/::/,/class/],scope:{1:`title.class`,3:`variable.language`}}]},w={scope:`attr`,match:t.concat(r,t.lookahead(`:`),t.lookahead(/(?!::)/))},T={relevance:0,begin:/\(/,end:/\)/,keywords:y,contains:[w,o,C,e.C_BLOCK_COMMENT_MODE,m,h,x]},E={relevance:0,match:[/\b/,t.concat(`(?!fn\\b|function\\b|`,b(_).join(`\\b|`),`|`,b(v).join(`\\b|`),`\\b)`),r,t.concat(p,`*`),t.lookahead(/(?=\()/)],scope:{3:`title.function.invoke`},contains:[T]};T.contains.push(E);let D=[w,C,e.C_BLOCK_COMMENT_MODE,m,h,x],O={begin:t.concat(/#\[\s*\\?/,t.either(i,a)),beginScope:`meta`,end:/]/,endScope:`meta`,keywords:{literal:g,keyword:[`new`,`array`]},contains:[{begin:/\[/,end:/]/,keywords:{literal:g,keyword:[`new`,`array`]},contains:[`self`,...D]},...D,{scope:`meta`,variants:[{match:i},{match:a}]}]};return{case_insensitive:!1,keywords:y,contains:[O,e.HASH_COMMENT_MODE,e.COMMENT(`//`,`$`),e.COMMENT(`/\\*`,`\\*/`,{contains:[{scope:`doctag`,match:`@[A-Za-z]+`}]}),{match:/__halt_compiler\(\);/,keywords:`__halt_compiler`,starts:{scope:`comment`,end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:`meta`,endsParent:!0}]}},s,{scope:`variable.language`,match:/\$this\b/},o,E,C,{match:[/const/,/\s/,r],scope:{1:`keyword`,3:`variable.constant`}},x,{scope:`function`,relevance:0,beginKeywords:`fn function`,end:/[;{]/,excludeEnd:!0,illegal:`[$%\\[]`,contains:[{beginKeywords:`use`},e.UNDERSCORE_TITLE_MODE,{begin:`=>`,endsParent:!0},{scope:`params`,begin:`\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0,keywords:y,contains:[`self`,O,o,C,e.C_BLOCK_COMMENT_MODE,m,h]}]},{scope:`class`,variants:[{beginKeywords:`enum`,illegal:/[($"]/},{beginKeywords:`class interface trait`,illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:`extends implements`},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:`namespace`,relevance:0,end:`;`,illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:`title.class`})]},{beginKeywords:`use`,relevance:0,end:`;`,contains:[{match:/\b(as|const|function)\b/,scope:`keyword`},e.UNDERSCORE_TITLE_MODE]},m,h]}}function Nj(e){return{name:`PHP template`,subLanguage:`xml`,contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:`php`,contains:[{begin:`/\\*`,end:`\\*/`,skip:!0},{begin:`b"`,end:`"`,skip:!0},{begin:`b'`,end:`'`,skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function Pj(e){return{name:`Plain text`,aliases:[`text`,`txt`],disableAutodetect:!0}}function Fj(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.all.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function Ij(e){return{aliases:[`pycon`],contains:[{className:`meta.prompt`,starts:{end:/ |$/,starts:{end:`$`,subLanguage:`python`}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Lj(e){let t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,a=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:`R`,keywords:{$pattern:n,keyword:`function if in break next repeat else for while`,literal:`NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10`,built_in:`LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm`},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:`doctag`,match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:`doctag`,begin:`@param`,end:/$/,contains:[{scope:`variable`,variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:`doctag`,match:/@[a-zA-Z]+/},{scope:`keyword`,match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:`"`,end:`"`,relevance:0},{begin:`'`,end:`'`,relevance:0}]},{relevance:0,variants:[{scope:{1:`operator`,2:`number`},match:[i,r]},{scope:{1:`operator`,2:`number`},match:[/%[^%]*%/,r]},{scope:{1:`punctuation`,2:`number`},match:[a,r]},{scope:{2:`number`},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:`operator`},match:[n,/\s+/,/<-/,/\s+/]},{scope:`operator`,relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:`punctuation`,relevance:0,match:a},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Rj(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),a={"variable.constant":[`__FILE__`,`__LINE__`,`__ENCODING__`],"variable.language":[`self`,`super`],keyword:[`alias`,`and`,`begin`,`BEGIN`,`break`,`case`,`class`,`defined`,`do`,`else`,`elsif`,`end`,`END`,`ensure`,`for`,`if`,`in`,`module`,`next`,`not`,`or`,`redo`,`require`,`rescue`,`retry`,`return`,`then`,`undef`,`unless`,`until`,`when`,`while`,`yield`,...[`include`,`extend`,`prepend`,`public`,`private`,`protected`,`raise`,`throw`]],built_in:[`proc`,`lambda`,`attr_accessor`,`attr_reader`,`attr_writer`,`define_method`,`private_constant`,`module_function`],literal:[`true`,`false`,`nil`]},o={className:`doctag`,begin:`@[A-Za-z]+`},s={begin:`#<`,end:`>`},c=[e.COMMENT(`#`,`$`,{contains:[o]}),e.COMMENT(`^=begin`,`^=end`,{contains:[o],relevance:10}),e.COMMENT(`^__END__`,e.MATCH_NOTHING_RE)],l={className:`subst`,begin:/#\{/,end:/\}/,keywords:a},u={className:`string`,contains:[e.BACKSLASH_ESCAPE,l],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,l]})]}]},d=`[0-9](_?[0-9])*`,f={className:`number`,relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${d}))?([eE][+-]?(${d})|r)?i?\\b`},{begin:`\\b0[dD][0-9](_?[0-9])*r?i?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*r?i?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*r?i?\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b`},{begin:`\\b0(_?[0-7])+r?i?\\b`}]},p={variants:[{match:/\(\)/},{className:`params`,begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:a}]},m=[u,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:`title.class`,4:`title.class.inherited`},keywords:a},{match:[/(include|extend)\s+/,i],scope:{2:`title.class`},keywords:a},{relevance:0,match:[i,/\.new[. (]/],scope:{1:`title.class`}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`},{relevance:0,match:r,scope:`title.class`},{match:[/def/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[p]},{begin:e.IDENT_RE+`::`},{className:`symbol`,begin:e.UNDERSCORE_IDENT_RE+`(!|\\?)?:`,relevance:0},{className:`symbol`,begin:`:(?!\\s)`,contains:[u,{begin:n}],relevance:0},f,{className:`variable`,begin:`(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])`},{className:`params`,begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:a},{begin:`(`+e.RE_STARTERS_RE+`|unless)\\s*`,keywords:`unless`,contains:[{className:`regexp`,contains:[e.BACKSLASH_ESCAPE,l],illegal:/\n/,variants:[{begin:`/`,end:`/[a-z]*`},{begin:/%r\{/,end:/\}[a-z]*/},{begin:`%r\\(`,end:`\\)[a-z]*`},{begin:`%r!`,end:`![a-z]*`},{begin:`%r\\[`,end:`\\][a-z]*`}]}].concat(s,c),relevance:0}].concat(s,c);l.contains=m,p.contains=m;let h=[{begin:/^\s*=>/,starts:{end:`$`,contains:m}},{className:`meta.prompt`,begin:`^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])`,starts:{end:`$`,keywords:a,contains:m}}];return c.unshift(s),{name:`Ruby`,aliases:[`rb`,`gemspec`,`podspec`,`thor`,`irb`],keywords:a,illegal:/\/\*/,contains:[e.SHEBANG({binary:`ruby`})].concat(h,c,m)}}function zj(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={className:`title.function.invoke`,relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},o=`([ui](8|16|32|64|128|size)|f(32|64))?`,s=`abstract.as.async.await.become.box.break.const.continue.crate.do.dyn.else.enum.extern.false.final.fn.for.if.impl.in.let.loop.macro.match.mod.move.mut.override.priv.pub.ref.return.self.Self.static.struct.super.trait.true.try.type.typeof.union.unsafe.unsized.use.virtual.where.while.yield`.split(`.`),c=[`true`,`false`,`Some`,`None`,`Ok`,`Err`],l=`drop .Copy.Send.Sized.Sync.Drop.Fn.FnMut.FnOnce.ToOwned.Clone.Debug.PartialEq.PartialOrd.Eq.Ord.AsRef.AsMut.Into.From.Default.Iterator.Extend.IntoIterator.DoubleEndedIterator.ExactSizeIterator.SliceConcatExt.ToString.assert!.assert_eq!.bitflags!.bytes!.cfg!.col!.concat!.concat_idents!.debug_assert!.debug_assert_eq!.env!.eprintln!.panic!.file!.format!.format_args!.include_bytes!.include_str!.line!.local_data_key!.module_path!.option_env!.print!.println!.select!.stringify!.try!.unimplemented!.unreachable!.vec!.write!.writeln!.macro_rules!.assert_ne!.debug_assert_ne!`.split(`.`),u=[`i8`,`i16`,`i32`,`i64`,`i128`,`isize`,`u8`,`u16`,`u32`,`u64`,`u128`,`usize`,`f32`,`f64`,`str`,`char`,`bool`,`Box`,`Option`,`Result`,`String`,`Vec`];return{name:`Rust`,aliases:[`rs`],keywords:{$pattern:e.IDENT_RE+`!?`,type:u,keyword:s,literal:c,built_in:l},illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.COMMENT(`/\\*`,`\\*/`,{contains:[`self`]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:`symbol`,begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:`string`,variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:`char.escape`,match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:`number`,variants:[{begin:`\\b0b([01_]+)`+o},{begin:`\\b0o([0-7_]+)`+o},{begin:`\\b0x([A-Fa-f0-9_]+)`+o},{begin:`\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)`+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:`keyword`,3:`title.function`}},{className:`meta`,begin:`#!?\\[`,end:`\\]`,contains:[{className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:`keyword`,3:`keyword`,4:`variable`}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:`keyword`,3:`variable`,5:`keyword`}},{begin:[/type/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:e.IDENT_RE+`::`,keywords:{keyword:`Self`,built_in:l,type:u}},{className:`punctuation`,begin:`->`},a]}}var Bj=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Vj=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),Hj=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),Uj=[...Vj,...Hj],Wj=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),Gj=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),Kj=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),qj=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function Jj(e){let t=Bj(e),n=Kj,r=Gj,i=`@[a-z-]+`,a={className:`variable`,begin:`(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b`,relevance:0};return{name:`SCSS`,case_insensitive:!0,illegal:`[=/|']`,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:`selector-id`,begin:`#[A-Za-z0-9_-]+`,relevance:0},{className:`selector-class`,begin:`\\.[A-Za-z0-9_-]+`,relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:`selector-tag`,begin:`\\b(`+Uj.join(`|`)+`)\\b`,relevance:0},{className:`selector-pseudo`,begin:`:(`+r.join(`|`)+`)`},{className:`selector-pseudo`,begin:`:(:)?(`+n.join(`|`)+`)`},a,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+qj.join(`|`)+`)\\b`},{begin:`\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b`},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,a,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:`@(page|font-face)`,keywords:{$pattern:i,keyword:`@page @font-face`}},{begin:`@`,end:`[{;]`,returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:Wj.join(` `)},contains:[{begin:i,className:`keyword`},{begin:/[a-z-]+(?=:)/,className:`attribute`},a,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function Yj(e){return{name:`Shell Session`,aliases:[`console`,`shellsession`],contains:[{className:`meta.prompt`,begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:`bash`}}]}}function Xj(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}function Zj(e){return e?typeof e==`string`?e:e.source:null}function Qj(e){return $j(`(?=`,e,`)`)}function $j(...e){return e.map(e=>Zj(e)).join(``)}function eM(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function tM(...e){return`(`+(eM(e).capture?``:`?:`)+e.map(e=>Zj(e)).join(`|`)+`)`}var nM=e=>$j(/\b/,e,/\w$/.test(e)?/\b/:/\B/),rM=[`Protocol`,`Type`].map(nM),iM=[`init`,`self`].map(nM),aM=[`Any`,`Self`],oM=[`actor`,`any`,`associatedtype`,`async`,`await`,/as\?/,/as!/,`as`,`borrowing`,`break`,`case`,`catch`,`class`,`consume`,`consuming`,`continue`,`convenience`,`copy`,`default`,`defer`,`deinit`,`didSet`,`distributed`,`do`,`dynamic`,`each`,`else`,`enum`,`extension`,`fallthrough`,/fileprivate\(set\)/,`fileprivate`,`final`,`for`,`func`,`get`,`guard`,`if`,`import`,`indirect`,`infix`,/init\?/,/init!/,`inout`,/internal\(set\)/,`internal`,`in`,`is`,`isolated`,`nonisolated`,`lazy`,`let`,`macro`,`mutating`,`nonmutating`,/open\(set\)/,`open`,`operator`,`optional`,`override`,`package`,`postfix`,`precedencegroup`,`prefix`,/private\(set\)/,`private`,`protocol`,/public\(set\)/,`public`,`repeat`,`required`,`rethrows`,`return`,`set`,`some`,`static`,`struct`,`subscript`,`super`,`switch`,`throws`,`throw`,/try\?/,/try!/,`try`,`typealias`,/unowned\(safe\)/,/unowned\(unsafe\)/,`unowned`,`var`,`weak`,`where`,`while`,`willSet`],sM=[`false`,`nil`,`true`],cM=[`assignment`,`associativity`,`higherThan`,`left`,`lowerThan`,`none`,`right`],lM=[`#colorLiteral`,`#column`,`#dsohandle`,`#else`,`#elseif`,`#endif`,`#error`,`#file`,`#fileID`,`#fileLiteral`,`#filePath`,`#function`,`#if`,`#imageLiteral`,`#keyPath`,`#line`,`#selector`,`#sourceLocation`,`#warning`],uM=`abs.all.any.assert.assertionFailure.debugPrint.dump.fatalError.getVaList.isKnownUniquelyReferenced.max.min.numericCast.pointwiseMax.pointwiseMin.precondition.preconditionFailure.print.readLine.repeatElement.sequence.stride.swap.swift_unboxFromSwiftValueWithType.transcode.type.unsafeBitCast.unsafeDowncast.withExtendedLifetime.withUnsafeMutablePointer.withUnsafePointer.withVaList.withoutActuallyEscaping.zip`.split(`.`),dM=tM(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),fM=tM(dM,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),pM=$j(dM,fM,`*`),mM=tM(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),hM=tM(mM,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),gM=$j(mM,hM,`*`),_M=$j(/[A-Z]/,hM,`*`),vM=[`attached`,`autoclosure`,$j(/convention\(/,tM(`swift`,`block`,`c`),/\)/),`discardableResult`,`dynamicCallable`,`dynamicMemberLookup`,`escaping`,`freestanding`,`frozen`,`GKInspectable`,`IBAction`,`IBDesignable`,`IBInspectable`,`IBOutlet`,`IBSegueAction`,`inlinable`,`main`,`nonobjc`,`NSApplicationMain`,`NSCopying`,`NSManaged`,$j(/objc\(/,gM,/\)/),`objc`,`objcMembers`,`propertyWrapper`,`requires_stored_property_inits`,`resultBuilder`,`Sendable`,`testable`,`UIApplicationMain`,`unchecked`,`unknown`,`usableFromInline`,`warn_unqualified_access`],yM=[`iOS`,`iOSApplicationExtension`,`macOS`,`macOSApplicationExtension`,`macCatalyst`,`macCatalystApplicationExtension`,`watchOS`,`watchOSApplicationExtension`,`tvOS`,`tvOSApplicationExtension`,`swift`];function bM(e){let t={match:/\s+/,relevance:0},n=e.COMMENT(`/\\*`,`\\*/`,{contains:[`self`]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,tM(...rM,...iM)],className:{2:`keyword`}},a={match:$j(/\./,tM(...oM)),relevance:0},o=oM.filter(e=>typeof e==`string`).concat([`_|0`]),s={variants:[{className:`keyword`,match:tM(...oM.filter(e=>typeof e!=`string`).concat(aM).map(nM),...iM)}]},c={$pattern:tM(/\b\w+/,/#\w+/),keyword:o.concat(lM),literal:sM},l=[i,a,s],u=[{match:$j(/\./,tM(...uM)),relevance:0},{className:`built_in`,match:$j(/\b/,tM(...uM),/(?=\()/)}],d={match:/->/,relevance:0},f=[d,{className:`operator`,relevance:0,variants:[{match:pM},{match:`\\.(\\.|${fM})+`}]}],p=`([0-9]_*)+`,m=`([0-9a-fA-F]_*)+`,h={className:`number`,relevance:0,variants:[{match:`\\b(${p})(\\.(${p}))?([eE][+-]?(${p}))?\\b`},{match:`\\b0x(${m})(\\.(${m}))?([pP][+-]?(${p}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},g=(e=``)=>({className:`subst`,variants:[{match:$j(/\\/,e,/[0\\tnr"']/)},{match:$j(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),_=(e=``)=>({className:`subst`,match:$j(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}),v=(e=``)=>({className:`subst`,label:`interpol`,begin:$j(/\\/,e,/\(/),end:/\)/}),y=(e=``)=>({begin:$j(e,/"""/),end:$j(/"""/,e),contains:[g(e),_(e),v(e)]}),b=(e=``)=>({begin:$j(e,/"/),end:$j(/"/,e),contains:[g(e),v(e)]}),x={className:`string`,variants:[y(),y(`#`),y(`##`),y(`###`),b(),b(`#`),b(`##`),b(`###`)]},S=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],C={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:S},w=e=>{let t=$j(e,/\//),n=$j(/\//,e);return{begin:t,end:n,contains:[...S,{scope:`comment`,begin:`#(?!.*${n})`,end:/$/}]}},T={scope:`regexp`,variants:[w(`###`),w(`##`),w(`#`),C]},E={match:$j(/`/,gM,/`/)},D=[E,{className:`variable`,match:/\$\d+/},{className:`variable`,match:`\\$${hM}+`}],O=[{match:/(@|#(un)?)available/,scope:`keyword`,starts:{contains:[{begin:/\(/,end:/\)/,keywords:yM,contains:[...f,h,x]}]}},{scope:`keyword`,match:$j(/@/,tM(...vM),Qj(tM(/\(/,/\s+/)))},{scope:`meta`,match:$j(/@/,gM)}],k={match:Qj(/\b[A-Z]/),relevance:0,contains:[{className:`type`,match:$j(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,hM,`+`)},{className:`type`,match:_M,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:$j(/\s+&\s+/,Qj(_M)),relevance:0}]},A={begin:/</,end:/>/,keywords:c,contains:[...r,...l,...O,d,k]};k.contains.push(A);let j={begin:/\(/,end:/\)/,relevance:0,keywords:c,contains:[`self`,{match:$j(gM,/\s*:/),keywords:`_|0`,relevance:0},...r,T,...l,...u,...f,h,x,...D,...O,k]},M={begin:/</,end:/>/,keywords:`repeat each`,contains:[...r,k]},N={begin:/\(/,end:/\)/,keywords:c,contains:[{begin:tM(Qj($j(gM,/\s*:/)),Qj($j(gM,/\s+/,gM,/\s*:/))),end:/:/,relevance:0,contains:[{className:`keyword`,match:/\b_\b/},{className:`params`,match:gM}]},...r,...l,...f,h,x,...O,k,j],endsParent:!0,illegal:/["']/},P={match:[/(func|macro)/,/\s+/,tM(E.match,gM,pM)],className:{1:`keyword`,3:`title.function`},contains:[M,N,t],illegal:[/\[/,/%/]},F={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:`keyword`},contains:[M,N,t],illegal:/\[|%/},I={match:[/operator/,/\s+/,pM],className:{1:`keyword`,3:`title`}},L={begin:[/precedencegroup/,/\s+/,_M],className:{1:`keyword`,3:`title`},contains:[k],keywords:[...cM,...sM],end:/}/},ee={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:`keyword`,3:`keyword`,5:`title.function`}},R={match:[/class\b/,/\s+/,/var\b/],scope:{1:`keyword`,3:`keyword`}},te={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,gM,/\s*/],beginScope:{1:`keyword`,3:`title.class`},keywords:c,contains:[M,...l,{begin:/:/,end:/\{/,keywords:c,contains:[{scope:`title.class.inherited`,match:_M},...l],relevance:0}]};for(let e of x.variants){let t=e.contains.find(e=>e.label===`interpol`);t.keywords=c;let n=[...l,...u,...f,h,x,...D];t.contains=[...n,{begin:/\(/,end:/\)/,contains:[`self`,...n]}]}return{name:`Swift`,keywords:c,contains:[...r,P,F,ee,R,te,I,L,{beginKeywords:`import`,end:/$/,contains:[...r],relevance:0},T,...l,...u,...f,h,x,...D,...O,k,j]}}var xM=`[A-Za-z$_][0-9A-Za-z$_]*`,SM=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),CM=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],wM=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),TM=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],EM=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],DM=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],OM=[].concat(EM,wM,TM);function kM(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=xM,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:xM,keyword:SM,literal:CM,built_in:OM,"variable.language":DM},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...wM,...TM]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...EM,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function AM(e){let t=e.regex,n=kM(e),r=xM,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:xM,keyword:SM.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:CM,built_in:OM.concat(i),"variable.language":DM},l={className:`meta`,begin:`@`+r},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function jM(e){let t=e.regex,n={className:`string`,begin:/"(""|[^/n])"C\b/},r={className:`string`,begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,a=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,s=/\d{1,2}(:\d{1,2}){1,2}/,c={className:`literal`,variants:[{begin:t.concat(/# */,t.either(a,i),/ *#/)},{begin:t.concat(/# */,s,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(a,i),/ +/,t.either(o,s),/ *#/)}]},l={className:`number`,relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},u={className:`label`,begin:/^\w+:/},d=e.COMMENT(/'''/,/$/,{contains:[{className:`doctag`,begin:/<\/?/,end:/>/}]}),f=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:`Visual Basic .NET`,aliases:[`vb`],case_insensitive:!0,classNameAliases:{label:`symbol`},keywords:{keyword:`addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield`,built_in:`addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort`,type:`boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort`,literal:`true false nothing`},illegal:`//|\\{|\\}|endif|gosub|variant|wend|^\\$ `,contains:[n,r,c,l,u,d,f,{className:`meta`,begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:`const disable else elseif enable end externalsource if region then`},contains:[f]}]}}function MM(e){e.regex;let t=e.COMMENT(/\(;/,/;\)/);return t.contains.push(`self`),{name:`WebAssembly`,keywords:{$pattern:/[\w.]+/,keyword:`anyfunc,block,br,br_if,br_table,call,call_indirect,data,drop,elem,else,end,export,func,global.get,global.set,local.get,local.set,local.tee,get_global,get_local,global,if,import,local,loop,memory,memory.grow,memory.size,module,mut,nop,offset,param,result,return,select,set_global,set_local,start,table,tee_local,then,type,unreachable`.split(`,`)},contains:[e.COMMENT(/;;/,/$/),t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:`keyword`,3:`operator`}},{className:`variable`,begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:`punctuation`,relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:`keyword`,3:`title.function`}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:`type`},{className:`keyword`,match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:`number`,relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}}function NM(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function PM(e){let t=`true false yes no null`,n=`[\\w#;/?:@&=+$,.~*'()[\\]]+`,r={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},o={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},s=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),c={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},l={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},u={begin:/\{/,end:/\}/,contains:[l],illegal:`\\n`,relevance:0},d={begin:`\\[`,end:`\\]`,contains:[l],illegal:`\\n`,relevance:0},f=[r,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+!`+n},{className:`type`,begin:`!<`+n+`>`},{className:`type`,begin:`!`+n},{className:`type`,begin:`!!`+n},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},c,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},u,d,a,o],p=[...f];return p.pop(),p.push(s),l.contains=p,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:f}}var FM={arduino:MA,bash:NA,c:PA,cpp:FA,csharp:IA,css:GA,diff:KA,go:qA,graphql:JA,ini:YA,java:tj,javascript:uj,json:dj,kotlin:gj,less:Ej,lua:Dj,makefile:Oj,markdown:kj,objectivec:Aj,perl:jj,php:Mj,"php-template":Nj,plaintext:Pj,python:Fj,"python-repl":Ij,r:Lj,ruby:Rj,rust:zj,scss:Jj,shell:Yj,sql:Xj,swift:bM,typescript:AM,vbnet:jM,wasm:MM,xml:NM,yaml:PM},IM=e(t(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},N={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},P={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},I=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},L=I(`//`,`$`),ee=I(`/\\*`,`\\*/`),R=I(`#`,`$`),te={scope:`number`,begin:D,relevance:0},ne={scope:`number`,begin:O,relevance:0},re={scope:`number`,begin:k,relevance:0},z={scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},B={scope:`title`,begin:T,relevance:0},ie={scope:`title`,begin:E,relevance:0},V={begin:`\\.\\s*`+E,relevance:0},H=Object.freeze({__proto__:null,APOS_STRING_MODE:N,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:re,BINARY_NUMBER_RE:k,COMMENT:I,C_BLOCK_COMMENT_MODE:ee,C_LINE_COMMENT_MODE:L,C_NUMBER_MODE:ne,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:V,NUMBER_MODE:te,NUMBER_RE:D,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:P,REGEXP_MODE:z,RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:B,UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:ie});function U(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ae(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function oe(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=U,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function se(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function ce(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function le(e,t){e.relevance===void 0&&(e.relevance=1)}var ue=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},de=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],fe=`keyword`;function pe(e,t,n=fe){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,pe(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,me(n[0],n[1])]})}}function me(e,t){return t?Number(t):+!he(e)}function he(e){return de.includes(e.toLowerCase())}var ge={},_e=e=>{console.error(e)},ve=(e,...t)=>{console.log(`WARN: ${e}`,...t)},ye=(e,t)=>{ge[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ge[`${e}/${t}`]=!0)},be=Error();function xe(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function Se(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw _e(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),be;if(typeof e.beginScope!=`object`||e.beginScope===null)throw _e(`beginScope must be object`),be;xe(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function Ce(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw _e(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),be;if(typeof e.endScope!=`object`||e.endScope===null)throw _e(`endScope must be object`),be;xe(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function we(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Te(e){we(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),Se(e),Ce(e)}function Ee(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null),this.matcherRe=t(C(this.regexes.map(e=>e[1]),{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[ae,ce,Te,ue].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[oe,se,le].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=pe(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return De(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function W(e){return e?e.endsWithParent||W(e.starts):!1}function De(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:W(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Oe=`11.11.1`,ke=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},Ae=i,je=a,Me=Symbol(`nomatch`),Ne=7,Pe=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(ve(s.replace(`{}`,n[1])),ve(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||N(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(ye(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),ye(`10.7.0`,`Please use highlight(code, options) instead.