@tempots/beatui 0.87.4 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ar-Dn7AkNO5.js → ar-MUKILk4c.js} +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/{auth-divider-BZPM2Xd3.js → auth-divider-DvVmqjnk.js} +7 -7
- package/dist/beatui.css +732 -671
- package/dist/beatui.tailwind.css +714 -662
- package/dist/better-auth/index.es.js +5 -5
- package/dist/{colors-CatA-RXf.js → colors-BY0Ja_bf.js} +3 -3
- package/dist/{de-QYhBiWv7.js → de-CEsW1rVX.js} +1 -1
- package/dist/deep-merge-Dgy9xj6w.cjs +1 -0
- package/dist/{deep-merge-D076XcC5.js → deep-merge-OvVqSLSN.js} +322 -304
- package/dist/{duration-input-6RN16H08.js → duration-input-BCXujp0V.js} +4 -4
- package/dist/{duration-input-CJU-yeKk.cjs → duration-input-MJz6UO6E.cjs} +1 -1
- package/dist/{editor-toolbar-group-DRCbXeQP.js → editor-toolbar-group-Cnta0SOa.js} +2 -2
- package/dist/{es-Ba31pZAd.js → es-ChP-aFwC.js} +1 -1
- package/dist/{fa-DvLjl_Ha.js → fa-CNsrlIqh.js} +1 -1
- package/dist/{fr-D64yBpAp.js → fr-DgEFKpML.js} +1 -1
- package/dist/{he-DHZGEQ7C.js → he-B4TqfISZ.js} +1 -1
- package/dist/{hi-CeAXVCvp.js → hi-TSoDsngT.js} +1 -1
- package/dist/{index-KNk3k6NI.js → index-1JaBwDB-.js} +1 -1
- package/dist/index-B8cqD9ny.js +838 -0
- package/dist/index-CN10Cyqr.cjs +1 -0
- package/dist/{index-yMrXbIdg.cjs → index-CTcbhnPw.cjs} +1 -1
- package/dist/{index-BIGCKfNz.cjs → index-D3QVPAme.cjs} +2 -2
- package/dist/{index-Bso_SkEn.cjs → index-D4ZFV8Rs.cjs} +1 -1
- package/dist/{index-anrXec7K.cjs → index-DF7RFzD9.cjs} +1 -1
- package/dist/{index-DWDC-qRY.js → index-DOc1_-Nm.js} +1 -1
- package/dist/{index-BTITknMc.js → index-D_aTUfqS.js} +6 -6
- package/dist/{index-BFe-x3-z.js → index-DfPkCwdC.js} +2 -2
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +1500 -1472
- package/dist/{input-container-BTyCOubf.js → input-container-BBWCDGTv.js} +1 -1
- package/dist/{it-Im0KgKWL.js → it-BrbebXg4.js} +1 -1
- package/dist/{ja-lliCbC19.js → ja-DcfOktrV.js} +1 -1
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +11 -11
- package/dist/json-schema-display/index.es.js +1 -1
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +6 -6
- package/dist/{ko-B9W4RBBs.js → ko-73e6t369.js} +1 -1
- package/dist/lexical/index.cjs.js +1 -1
- package/dist/lexical/index.es.js +7 -7
- package/dist/lexical.css +24 -23
- package/dist/markdown/index.cjs.js +1 -1
- package/dist/markdown/index.es.js +1 -1
- package/dist/markdown.css +7 -7
- package/dist/{modal-CD3DwAlD.js → modal-BBJWY7NB.js} +3 -3
- package/dist/{nl-ba5SyHsw.js → nl-Bq-1-ulc.js} +1 -1
- package/dist/{notice-Cc26kgiB.js → notice-AUVH8Lho.js} +4 -4
- package/dist/{oneof-branch-detection-DiAtgGQH.js → oneof-branch-detection-BQnRjp9P.js} +1 -1
- package/dist/{pl-DCiJAZWC.js → pl-Du9-VCfW.js} +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror.css +7 -7
- package/dist/{pt-Df5bAGWA.js → pt-B2UqqSAB.js} +1 -1
- package/dist/{ru-Dg-c670Y.js → ru-DiWa2inw.js} +1 -1
- package/dist/styles-url-4g2WnNJ8.js +4 -0
- package/dist/{styles-url-DZhZ-9Bf.js → styles-url-CJYy5nML.js} +1 -1
- package/dist/{styles-url-YAJ6Q1GS.cjs → styles-url-D8nVwSmZ.cjs} +1 -1
- package/dist/{styles-url-BSUFsmMD.cjs → styles-url-evUdl8tK.cjs} +1 -1
- package/dist/{styles-url-BvcVGpBJ.js → styles-url-hKxIOumK.js} +1 -1
- package/dist/styles-url-mlDYoWbF.cjs +1 -0
- package/dist/tailwind/preset.cjs.js +1 -1
- package/dist/tailwind/preset.es.js +2 -2
- package/dist/tailwind/vite-plugin.cjs.js +1 -1
- package/dist/tailwind/vite-plugin.es.js +1 -1
- package/dist/{text-input-Cux5iiUC.js → text-input-6FD7p7hN.js} +1 -1
- package/dist/{toolbar-DYmKrtic.js → toolbar-Cr0JGj5h.js} +1 -1
- package/dist/{tr-Dhpiq0u_.js → tr-Culcm2Zb.js} +1 -1
- package/dist/{translations-COSDzhvR.js → translations-Cttn6w0G.js} +1 -1
- package/dist/{translations-BLlzvZgw.js → translations-uEUkO6gJ.js} +19 -19
- package/dist/types/components/form/input/step-utils.d.ts +5 -0
- package/dist/types/tailwind/preset.d.ts +1 -1
- package/dist/types/tailwind/vite-plugin.d.ts +1 -1
- package/dist/types/tokens/borders.d.ts +104 -0
- package/dist/types/tokens/controls.d.ts +127 -0
- package/dist/types/tokens/index.d.ts +2 -0
- package/dist/types/tokens/radius.d.ts +14 -14
- package/dist/types/tokens/typography.d.ts +33 -33
- package/dist/{ur-Lr1p8f9y.js → ur-Deb-uH6b.js} +1 -1
- package/dist/{use-form-BfzX3bwL.js → use-form-lg6-7Brc.js} +3 -2
- package/dist/{vi-jozfaxSj.js → vi-CUsCVh3n.js} +1 -1
- package/dist/{widget-customization-BZqPoojo.cjs → widget-customization-BLvD4Lqt.cjs} +1 -1
- package/dist/{widget-customization-fMNSVtuP.js → widget-customization-CDD72zYs.js} +5 -5
- package/dist/{zh-BBYKq49d.js → zh-Dil2Jft8.js} +1 -1
- package/package.json +11 -11
- package/dist/deep-merge-BmxkFFi1.cjs +0 -1
- package/dist/index-BywbRDsb.cjs +0 -1
- package/dist/index-rHnH2IGb.js +0 -671
- package/dist/styles-url-CCopc5pG.js +0 -4
- package/dist/styles-url-CEDSZTyZ.cjs +0 -1
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
`)}}const bc=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[ds]?fm(n,e):El(n)?vu(n,t=>lm(e,r=>bc(t,r))):DC(n)?Os(n,(t,r)=>bc(t,e[r])):!1;class rt{static _dilutes=!1;extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),bc(t,r)}equals(e){return this.constructor===e.constructor&&ro(this.shape,e.shape)}[qC](){return!0}[ds](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ft()}get nullable(){return vi(this,Ol)}get optional(){return new ym(this)}cast(e){return bh(e,this),e}expect(e){return bh(e,this),e}}class $u extends rt{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}const Ee=(n,e=null)=>new $u(n,e);Ee($u);class Iu extends rt{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape(e);return!r&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}const Re=n=>new Iu(n);Ee(Iu);class kl extends rt{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape.some(i=>i===e);return!r&&t?.extend(null,this.shape.join(" | "),e.toString()),r}}const Tl=(...n)=>new kl(n),mm=Ee(kl),XC=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),_m=n=>{if(ni.check(n))return[XC(n)];if(mm.check(n))return n.shape.map(e=>e+"");if(Tm.check(n))return["[+-]?\\d+.?\\d*"];if(Nm.check(n))return[".*"];if(Bo.check(n))return n.shape.map(_m).flat(1);pn()};class QC extends rt{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(_m).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}Ee(QC);const ew=Symbol("optional");class ym extends rt{constructor(e){super(),this.shape=e}check(e,t){const r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,"undefined (optional)","()"),r}get[ew](){return!0}}const tw=Ee(ym);class nw extends rt{check(e,t){return t?.extend(null,"never",typeof e),!1}}Ee(nw);class Nl extends rt{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Nl(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,"object","null"),!1):Os(this.shape,(r,i)=>{const s=this._isPartial&&!Au(e,i)||r.check(e[i],t);return!s&&t?.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match"),s})}}const rw=n=>new Nl(n),iw=Ee(Nl),sw=Re(n=>n!=null&&(n.constructor===Object||n.constructor==null));class bm extends rt{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Os(e,(r,i)=>{const s=this.shape.keys.check(i,t);return!s&&t?.extend(i+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(r,t)})}}const xm=(n,e)=>new bm(n,e),ow=Ee(bm);class Sm extends rt{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Os(this.shape,(r,i)=>{const s=r.check(e[i],t);return!s&&t?.extend(i.toString(),"Tuple",typeof r),s})}}const lw=(...n)=>new Sm(n);Ee(Sm);class Cm extends rt{constructor(e){super(),this.shape=e.length===1?e[0]:new Fu(e)}check(e,t){const r=El(e)&&vu(e,i=>this.shape.check(i));return!r&&t?.extend(null,"Array",""),r}}const wm=(...n)=>new Cm(n),aw=Ee(Cm),cw=Re(n=>El(n));class vm extends rt{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}}const uw=(n,e=null)=>new vm(n,e);Ee(vm);const dw=uw(rt);class fw extends rt{constructor(e){super(),this.len=e.length-1,this.args=lw(...e.slice(-1)),this.res=e[this.len]}check(e,t){const r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,"function",typeof e),r}}const hw=Ee(fw),gw=Re(n=>typeof n=="function");class pw extends rt{constructor(e){super(),this.shape=e}check(e,t){const r=vu(this.shape,i=>i.check(e,t));return!r&&t?.extend(null,"Intersectinon",typeof e),r}}Ee(pw,n=>n.shape.length>0);class Fu extends rt{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const r=lm(this.shape,i=>i.check(e,t));return t?.extend(null,"Union",typeof e),r}}const vi=(...n)=>n.findIndex(e=>Bo.check(e))>=0?vi(...n.map(e=>hs(e)).map(e=>Bo.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new Fu(n),Bo=Ee(Fu),Em=()=>!0,zo=Re(Em),mw=Ee(Iu,n=>n.shape===Em),Du=Re(n=>typeof n=="bigint"),_w=Re(n=>n===Du),km=Re(n=>typeof n=="symbol");Re(n=>n===km);const Zr=Re(n=>typeof n=="number"),Tm=Re(n=>n===Zr),ni=Re(n=>typeof n=="string"),Nm=Re(n=>n===ni),Al=Re(n=>typeof n=="boolean"),yw=Re(n=>n===Al),Am=Tl(void 0);Ee(kl,n=>n.shape.length===1&&n.shape[0]===void 0);Tl(void 0);const Ol=Tl(null),bw=Ee(kl,n=>n.shape.length===1&&n.shape[0]===null);Ee(Uint8Array);Ee($u,n=>n.shape===Uint8Array);const xw=vi(Zr,ni,Ol,Am,Du,Al,km);(()=>{const n=wm(zo),e=xm(ni,zo),t=vi(Zr,ni,Ol,Al,n,e);return n.shape=t,e.shape.values=t,t})();const hs=n=>{if(dw.check(n))return n;if(sw.check(n)){const e={};for(const t in n)e[t]=hs(n[t]);return rw(e)}else{if(cw.check(n))return vi(...n.map(hs));if(xw.check(n))return Tl(n);if(gw.check(n))return Ee(n)}pn()},bh=jC?()=>{}:(n,e)=>{const t=new ZC;if(!e.check(n,t))throw Pn(`Expected value to be of type ${e.constructor.name}.
|
|
37
37
|
${t.toString()}`)};class Sw{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:hs(e),h:t}),this}else(e){return this.if(zo,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,t)}throw Pn("Unhandled pattern")}}}const Cw=n=>new Sw(n),Om=Cw(zo).if(Tm,(n,e)=>va(e,uh,ch)).if(Nm,(n,e)=>YC(e)).if(yw,(n,e)=>yh(e)).if(_w,(n,e)=>BigInt(va(e,uh,ch))).if(Bo,(n,e)=>zr(e,Ea(e,n.shape))).if(iw,(n,e)=>{const t={};for(const r in n.shape){let i=n.shape[r];if(tw.check(i)){if(yh(e))continue;i=i.shape}t[r]=Om(i,e)}return t}).if(aw,(n,e)=>{const t=[],r=pm(e,0,42);for(let i=0;i<r;i++)t.push(zr(e,n.shape));return t}).if(mm,(n,e)=>Ea(e,n.shape)).if(bw,(n,e)=>null).if(hw,(n,e)=>{const t=zr(e,n.res);return()=>t}).if(mw,(n,e)=>zr(e,Ea(e,[Zr,ni,Ol,Am,Du,Al,wm(Zr),xm(vi("a","b","c"),Zr)]))).if(ow,(n,e)=>{const t={},r=va(e,0,3);for(let i=0;i<r;i++){const s=zr(e,n.shape.keys),o=zr(e,n.shape.values);t[s]=o}return t}).done(),zr=(n,e)=>Om(hs(e),n),Ml=typeof document<"u"?document:{};Re(n=>n.nodeType===Tw);typeof DOMParser<"u"&&new DOMParser;Re(n=>n.nodeType===vw);Re(n=>n.nodeType===Ew);const ww=n=>tC(n,(e,t)=>`${t}:${e};`).join(""),vw=Ml.ELEMENT_NODE,Ew=Ml.TEXT_NODE,kw=Ml.DOCUMENT_NODE,Tw=Ml.DOCUMENT_FRAGMENT_NODE;Re(n=>n.nodeType===kw);const Cn=Symbol,Mm=Cn(),$m=Cn(),Nw=Cn(),Aw=Cn(),Ow=Cn(),Im=Cn(),Mw=Cn(),Lu=Cn(),$w=Cn(),Iw=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());const e=[],t=[];let r=0;for(;r<n.length;r++){const i=n[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&t.push(e.join(""));r<n.length;r++){const i=n[r];i instanceof Symbol||t.push(i)}return t},Fw={[Mm]:en("font-weight","bold"),[$m]:en("font-weight","normal"),[Nw]:en("color","blue"),[Ow]:en("color","green"),[Aw]:en("color","grey"),[Im]:en("color","red"),[Mw]:en("color","purple"),[Lu]:en("color","orange"),[$w]:en("color","black")},Dw=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());const e=[],t=[],r=Gt();let i=[],s=0;for(;s<n.length;s++){const o=n[s],l=Fw[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=ww(r);s>0||a.length>0?(e.push("%c"+o),t.push(a)):e.push(o)}else break}}for(s>0&&(i=t,i.unshift(e.join("")));s<n.length;s++){const o=n[s];o instanceof Symbol||i.push(o)}return i},Fm=JC?Dw:Iw,Lw=(...n)=>{console.log(...Fm(n)),Dm.forEach(e=>e.print(n))},Rw=(...n)=>{console.warn(...Fm(n)),n.unshift(Lu),Dm.forEach(e=>e.print(n))},Dm=ei(),Lm=n=>({[Symbol.iterator](){return this},next:n}),Pw=(n,e)=>Lm(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),ka=(n,e)=>Lm(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class Bw{constructor(e,t){this.clock=e,this.len=t}}class zw{constructor(){this.clients=new Map}}const Rm=(n,e,t)=>e.clients.forEach((r,i)=>{const s=n.doc.store.clients.get(i);if(s!=null){const o=s[s.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])jm(n,s,c.clock,c.len,t)}}),Uw=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=gn((t+r)/2),s=n[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;t=i+1}else r=i-1}return null},Pm=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&Uw(t,e.clock)!==null},Bm=n=>{n.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){const i=e[r-1],s=e[t];i.clock+i.len>=s.clock?i.len=wi(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++)}e.length=r})},zm=(n,e,t,r)=>{Ci(n.clients,e,()=>[]).push(new Bw(t,r))},Kw=(n,e)=>{ce(n.restEncoder,e.clients.size),ti(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ce(n.restEncoder,t);const i=r.length;ce(n.restEncoder,i);for(let s=0;s<i;s++){const o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Um=um;class Bn extends iC{constructor({guid:e=MC(),collectionid:t=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=Um(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Xw,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=mh(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>mh(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&he(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ti(this.subdocs).map(e=>e.guid))}transact(e,t=null){return he(this,e,t)}get(e,t=Ue){const r=Ci(this.share,e,()=>{const s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==Ue&&i!==t)if(i===Ue){const s=new t;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Yi)}getText(e=""){return this.get(e,ms)}getMap(e=""){return this.get(e,yt)}getXmlElement(e=""){return this.get(e,_n)}getXmlFragment(e=""){return this.get(e,ri)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,ti(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new Bn({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,he(e.parent.doc,r=>{const i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Ww{constructor(){this.restEncoder=Eu()}toUint8Array(){return an(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ce(this.restEncoder,e)}writeDsLen(e){ce(this.restEncoder,e)}}class jw extends Ww{writeLeftID(e){ce(this.restEncoder,e.client),ce(this.restEncoder,e.clock)}writeRightID(e){ce(this.restEncoder,e.client),ce(this.restEncoder,e.clock)}writeClient(e){ce(this.restEncoder,e)}writeInfo(e){mc(this.restEncoder,e)}writeString(e){qr(this.restEncoder,e)}writeParentInfo(e){ce(this.restEncoder,e?1:0)}writeTypeRef(e){ce(this.restEncoder,e)}writeLen(e){ce(this.restEncoder,e)}writeAny(e){us(this.restEncoder,e)}writeBuf(e){ut(this.restEncoder,e)}writeJSON(e){qr(this.restEncoder,JSON.stringify(e))}writeKey(e){qr(this.restEncoder,e)}}class Hw{constructor(){this.restEncoder=Eu(),this.dsCurrVal=0}toUint8Array(){return an(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ce(this.restEncoder,t)}writeDsLen(e){e===0&&pn(),ce(this.restEncoder,e-1),this.dsCurrVal+=e}}class Jw extends Hw{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new wa,this.clientEncoder=new no,this.leftClockEncoder=new wa,this.rightClockEncoder=new wa,this.infoEncoder=new hh(mc),this.stringEncoder=new NC,this.parentInfoEncoder=new hh(mc),this.typeRefEncoder=new no,this.lenEncoder=new no}toUint8Array(){const e=Eu();return ce(e,0),ut(e,this.keyClockEncoder.toUint8Array()),ut(e,this.clientEncoder.toUint8Array()),ut(e,this.leftClockEncoder.toUint8Array()),ut(e,this.rightClockEncoder.toUint8Array()),ut(e,an(this.infoEncoder)),ut(e,this.stringEncoder.toUint8Array()),ut(e,an(this.parentInfoEncoder)),ut(e,this.typeRefEncoder.toUint8Array()),ut(e,this.lenEncoder.toUint8Array()),Tu(e,an(this.restEncoder)),an(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){us(this.restEncoder,e)}writeBuf(e){ut(this.restEncoder,e)}writeJSON(e){us(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Gw=(n,e,t,r)=>{r=wi(r,e[0].id.clock);const i=mn(e,r);ce(n.restEncoder,e.length-i),n.writeClient(t),ce(n.restEncoder,r);const s=e[i];s.write(n,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(n,0)},Vw=(n,e,t)=>{const r=new Map;t.forEach((i,s)=>{it(e,s)>i&&r.set(s,i)}),Ru(e).forEach((i,s)=>{t.has(s)||r.set(s,0)}),ce(n.restEncoder,r.size),ti(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{Gw(n,e.clients.get(i),i,s)})},Yw=(n,e)=>Vw(n,e.doc.store,e.beforeState);class qw{constructor(){this.l=[]}}const xh=()=>new qw,Sh=(n,e)=>n.l.push(e),Ch=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Km=(n,e,t)=>Ou(n.l,[e,t]);class io{constructor(e,t){this.client=e,this.clock=t}}const Js=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,_e=(n,e)=>new io(n,e),Zw=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw pn()},jr=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!Pm(e.ds,n.id),xc=(n,e)=>{const t=Ci(n.meta,xc,ei),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<it(r,s)&&zn(n,_e(s,i))}),Rm(n,e.ds,i=>{}),t.add(e))};class Xw{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ru=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},it=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},Wm=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw pn()}t.push(e)},mn=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=gn(e/(s+i.length-1)*r);for(;t<=r;){if(i=n[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;t=o+1}else r=o-1;o=gn((t+r)/2)}throw pn()},Qw=(n,e)=>{const t=n.clients.get(e.client);return t[mn(t,e.clock)]},Ta=Qw,Sc=(n,e,t)=>{const r=mn(e,t),i=e[r];return i.id.clock<t&&i instanceof Je?(e.splice(r+1,0,a_(n,i,t-i.id.clock)),r+1):r},zn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[Sc(n,t,e.clock)]},wh=(n,e,t)=>{const r=e.clients.get(t.client),i=mn(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==En&&r.splice(i+1,0,a_(n,s,t.clock-s.id.clock+1)),s},ev=(n,e,t)=>{const r=n.clients.get(e.id.client);r[mn(r,e.id.clock)]=t},jm=(n,e,t,r,i)=>{if(r===0)return;const s=t+r;let o=Sc(n,e,t),l;do l=e[o++],s<l.id.clock+l.length&&Sc(n,e,s),i(l);while(o<e.length&&e[o].id.clock<s)};class tv{constructor(e,t,r){this.doc=e,this.deleteSet=new zw,this.beforeState=Ru(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=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const vh=(n,e)=>e.deleteSet.clients.size===0&&!nC(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(Bm(e.deleteSet),Yw(n,e),Kw(n,e.deleteSet),!0),Eh=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Ci(n.changed,e,ei).add(t)},so=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof Je&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const s=e-i;return s&&n.splice(e+1-s,s),s},nv=(n,e,t)=>{for(const[r,i]of n.clients.entries()){const s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){const l=i[o],a=l.clock+l.len;for(let c=mn(s,l.clock),u=s[c];c<s.length&&u.id.clock<a;u=s[++c]){const d=s[c];if(l.clock+l.len<=d.id.clock)break;d instanceof Je&&d.deleted&&!d.keep&&t(d)&&d.gc(e,!1)}}}},rv=(n,e)=>{n.clients.forEach((t,r)=>{const i=e.clients.get(r);for(let s=t.length-1;s>=0;s--){const o=t[s],l=am(i.length-1,1+mn(i,o.clock+o.len-1));for(let a=l,c=i[a];a>0&&c.id.clock>=o.clock;c=i[a])a-=1+so(i,a)}})},Hm=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{Bm(s),t.afterState=Ru(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const l=[];t.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,a)})),l.push(()=>{t.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),l.push(()=>{Km(c._dEH,a,t)}))}),l.push(()=>r.emit("afterTransaction",[t,r])),l.push(()=>{t._needFormattingCleanup&&pv(t)})}),Ou(l,[])}finally{r.gc&&nv(s,i,r.gcFilter),rv(s,i),t.afterState.forEach((u,d)=>{const f=t.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),g=wi(mn(h,f),1);for(let p=h.length-1;p>=g;)p-=1+so(h,p)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:f}=o[u].id,h=i.clients.get(d),g=mn(h,f);g+1<h.length&&so(h,g+1)>1||g>0&&so(h,g)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(Lw(Lu,Mm,"[yjs] ",$m,Im,"Changed the client-id because another client seems to be using it."),r.clientID=Um()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new jw;vh(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new Jw;vh(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=t;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):Hm(n,e+1)}}},he=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new tv(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(s){const l=n._transaction===i[0];n._transaction=null,l&&Hm(i,0)}}return o},kh="You must not compute changes after the event-handler fired.";class $l{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=iv(this.currentTarget,this.target))}deletes(e){return Pm(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Pn(kh);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const s=t._map.get(i);let o,l;if(this.adds(s)){let a=s.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",l=ba(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=ba(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=ba(s.content.getContent());else return;e.set(i,{action:o,oldValue:l})}}),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 Pn(kh);const t=this.target,r=ei(),i=ei(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null;const a=()=>{l&&s.push(l)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,i.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const iv=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;t.unshift(r)}e=e._item.parent}return t},Ve=()=>{Rw("Invalid access: Add Yjs type to a document before reading data.")},Jm=80;let Pu=0;class sv{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Pu++}}const ov=n=>{n.timestamp=Pu++},Gm=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Pu++},lv=(n,e,t)=>{if(n.length>=Jm){const r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return Gm(r,e,t),r}else{const r=new sv(e,t);return n.push(r),r}},Il=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,o)=>to(e-s.index)<to(e-o.index)?s:o);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,ov(t));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)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 t!==null&&to(t.index-i)<r.parent.length/Jm?(Gm(t,r,i),t):lv(n._searchMarker,r,i)},gs=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const i=n[r];if(t>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){n.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=wi(e,i.index+t))}},Fl=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;Ci(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Km(r._eH,t,e)};class Ue{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=xh(),this._dEH=xh(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ft()}clone(){throw Ft()}_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){Sh(this._eH,e)}observeDeep(e){Sh(this._dEH,e)}unobserve(e){Ch(this._eH,e)}unobserveDeep(e){Ch(this._dEH,e)}toJSON(){}}const Vm=(n,e,t)=>{n.doc??Ve(),e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const i=[];let s=n._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)i.push(o[l]),r--;e=0}}s=s.right}return i},Ym=n=>{n.doc??Ve();const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},ps=(n,e)=>{let t=0,r=n._start;for(n.doc??Ve();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let s=0;s<i.length;s++)e(i[s],t++,n)}r=r.right}},qm=(n,e)=>{const t=[];return ps(n,(r,i)=>{t.push(e(r,i,n))}),t},av=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Zm=(n,e)=>{n.doc??Ve();const t=Il(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Uo=(n,e,t,r)=>{let i=t;const s=n.doc,o=s.clientID,l=s.store,a=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(i=new Je(_e(o,it(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new ii(c)),i.integrate(n,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:i=new Je(_e(o,it(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Dl(new Uint8Array(d))),i.integrate(n,0);break;case Bn:i=new Je(_e(o,it(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ll(d)),i.integrate(n,0);break;default:if(d instanceof Ue)i=new Je(_e(o,it(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Jn(d)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Xm=()=>Pn("Length exceeded!"),Qm=(n,e,t,r)=>{if(t>e._length)throw Xm();if(t===0)return e._searchMarker&&gs(e._searchMarker,t,r.length),Uo(n,e,null,r);const i=t,s=Il(e,t);let o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&zn(n,_e(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&gs(e._searchMarker,i,r.length),Uo(n,e,o,r)},cv=(n,e,t)=>{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return Uo(n,e,i,t)},e_=(n,e,t,r)=>{if(r===0)return;const i=t,s=r,o=Il(e,t);let l=e._start;for(o!==null&&(l=o.p,t-=o.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&zn(n,_e(l.id.client,l.id.clock+t)),t-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&zn(n,_e(l.id.client,l.id.clock+r)),l.delete(n),r-=l.length),l=l.right;if(r>0)throw Xm();e._searchMarker&&gs(e._searchMarker,i,-s+r)},Ko=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Bu=(n,e,t,r)=>{const i=e._map.get(t)||null,s=n.doc,o=s.clientID;let l;if(r==null)l=new ii([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new ii([r]);break;case Uint8Array:l=new Dl(r);break;case Bn:l=new Ll(r);break;default:if(r instanceof Ue)l=new Jn(r);else throw new Error("Unexpected content type")}new Je(_e(o,it(s.store,o)),i,i&&i.lastId,null,null,e,t,l).integrate(n,0)},zu=(n,e)=>{n.doc??Ve();const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},t_=n=>{const e={};return n.doc??Ve(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},n_=(n,e)=>{n.doc??Ve();const t=n._map.get(e);return t!==void 0&&!t.deleted},uv=(n,e)=>{const t={};return n._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&jr(s,e)&&(t[i]=s.content.getContent()[s.length-1])}),t},Gs=n=>(n.doc??Ve(),Pw(n._map.entries(),e=>!e[1].deleted));class dv extends $l{}class Yi extends Ue{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Yi;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Yi}clone(){const e=new Yi;return e.insert(0,this.toArray().map(t=>t instanceof Ue?t.clone():t)),e}get length(){return this.doc??Ve(),this._length}_callObserver(e,t){super._callObserver(e,t),Fl(this,e,new dv(this,e))}insert(e,t){this.doc!==null?he(this.doc,r=>{Qm(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?he(this.doc,t=>{cv(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?he(this.doc,r=>{e_(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Zm(this,e)}toArray(){return Ym(this)}slice(e=0,t=this.length){return Vm(this,e,t)}toJSON(){return this.map(e=>e instanceof Ue?e.toJSON():e)}map(e){return qm(this,e)}forEach(e){ps(this,e)}[Symbol.iterator](){return av(this)}_write(e){e.writeTypeRef(Sv)}}class fv extends $l{constructor(e,t,r){super(e,t),this.keysChanged=r}}class yt extends Ue{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((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new yt}clone(){const e=new yt;return this.forEach((t,r)=>{e.set(r,t instanceof Ue?t.clone():t)}),e}_callObserver(e,t){Fl(this,e,new fv(this,e,t))}toJSON(){this.doc??Ve();const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof Ue?i.toJSON():i}}),e}get size(){return[...Gs(this)].length}keys(){return ka(Gs(this),e=>e[0])}values(){return ka(Gs(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ka(Gs(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Ve(),this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?he(this.doc,t=>{Ko(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?he(this.doc,r=>{Bu(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return zu(this,e)}has(e){return n_(this,e)}clear(){this.doc!==null?he(this.doc,e=>{this.forEach(function(t,r,i){Ko(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Cv)}}const Nn=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&zC(n,e);class Cc{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){this.right===null&&pn(),this.right.content.constructor===De?this.right.deleted||Ei(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const Th=(n,e,t)=>{for(;e.right!==null&&t>0;)e.right.content.constructor===De?e.right.deleted||Ei(e.currentAttributes,e.right.content):e.right.deleted||(t<e.right.length&&zn(n,_e(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Vs=(n,e,t,r)=>{const i=new Map,s=r?Il(e,t):null;if(s){const o=new Cc(s.p.left,s.p,s.index,i);return Th(n,o,t-s.index)}else{const o=new Cc(null,e._start,0,i);return Th(n,o,t)}},r_=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===De&&Nn(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const i=n.doc,s=i.clientID;r.forEach((o,l)=>{const a=t.left,c=t.right,u=new Je(_e(s,it(i.store,s)),a,a&&a.lastId,c,c&&c.id,e,null,new De(l,o));u.integrate(n,0),t.right=u,t.forward()})},Ei=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},i_=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===De&&Nn(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},s_=(n,e,t,r)=>{const i=n.doc,s=i.clientID,o=new Map;for(const l in r){const a=r[l],c=t.currentAttributes.get(l)??null;if(!Nn(c,a)){o.set(l,c);const{left:u,right:d}=t;t.right=new Je(_e(s,it(i.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new De(l,a)),t.right.integrate(n,0),t.forward()}}return o},Na=(n,e,t,r,i)=>{t.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const s=n.doc,o=s.clientID;i_(t,i);const l=s_(n,e,t,i),a=r.constructor===String?new yn(r):r instanceof Ue?new Jn(r):new ki(r);let{left:c,right:u,index:d}=t;e._searchMarker&&gs(e._searchMarker,t.index,a.getLength()),u=new Je(_e(o,it(s.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(n,0),t.right=u,t.index=d,t.forward(),r_(n,e,t,l)},Nh=(n,e,t,r,i)=>{const s=n.doc,o=s.clientID;i_(t,i);const l=s_(n,e,t,i);e:for(;t.right!==null&&(r>0||l.size>0&&(t.right.deleted||t.right.content.constructor===De));){if(!t.right.deleted)switch(t.right.content.constructor){case De:{const{key:a,value:c}=t.right.content,u=i[a];if(u!==void 0){if(Nn(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}t.right.delete(n)}else t.currentAttributes.set(a,c);break}default:r<t.right.length&&zn(n,_e(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
38
38
|
`;t.right=new Je(_e(o,it(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new yn(a)),t.right.integrate(n,0),t.forward()}r_(n,e,t,l)},o_=(n,e,t,r,i)=>{let s=e;const o=Gt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===De){const c=s.content;o.set(c.key,c)}s=s.right}let l=0,a=!1;for(;e!==s;){if(t===e&&(a=!0),!e.deleted){const c=e.content;if(c.constructor===De){const{key:u,value:d}=c,f=r.get(u)??null;(o.get(u)!==c||f===d)&&(e.delete(n),l++,!a&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!a&&!e.deleted&&Ei(i,c)}}e=e.right}return l},hv=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===De){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},gv=n=>{let e=0;return he(n.doc,t=>{let r=n._start,i=n._start,s=Gt();const o=pc(s);for(;i;)i.deleted===!1&&(i.content.constructor===De?Ei(o,i.content):(e+=o_(t,r,i,s,o),s=pc(o),r=i)),i=i.right}),e},pv=n=>{const e=new Set,t=n.doc;for(const[r,i]of n.afterState.entries()){const s=n.beforeState.get(r)||0;i!==s&&jm(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===De&&o.constructor!==En&&e.add(o.parent)})}he(t,r=>{Rm(n,n.deleteSet,i=>{if(i instanceof En||!i.parent._hasFormatting||e.has(i.parent))return;const s=i.parent;i.content.constructor===De?e.add(s):hv(r,i)});for(const i of e)gv(i)})},Ah=(n,e,t)=>{const r=t,i=pc(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Jn:case ki:case yn:t<e.right.length&&zn(n,_e(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&o_(n,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&gs(o._searchMarker,e.index,-r+t),e};class mv extends $l{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];he(e,r=>{const i=new Map,s=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const f=()=>{if(l!==null){let h=null;switch(l){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},i.size>0&&(h.attributes={},i.forEach((g,p)=>{g!==null&&(h.attributes[p]=g)}))),c="";break;case"retain":u>0&&(h={retain:u},BC(a)||(h.attributes=LC({},a))),u=0;break}h&&t.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case Jn:case ki:this.adds(o)?this.deletes(o)||(f(),l="insert",c=o.content.getContent()[0],f()):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=1);break;case yn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(f(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=o.length);break;case De:{const{key:h,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const p=i.get(h)??null;Nn(p,g)?g!==null&&o.delete(r):(l==="retain"&&f(),Nn(g,s.get(h)??null)?delete a[h]:a[h]=g)}}else if(this.deletes(o)){s.set(h,g);const p=i.get(h)??null;Nn(p,g)||(l==="retain"&&f(),a[h]=p)}else if(!o.deleted){s.set(h,g);const p=a[h];p!==void 0&&(Nn(p,g)?p!==null&&o.delete(r):(l==="retain"&&f(),g===null?delete a[h]:a[h]=g))}o.deleted||(l==="insert"&&f(),Ei(i,o.content));break}}o=o.right}for(f();t.length>0;){const h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ms extends Ue{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ve(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ms}clone(){const e=new ms;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new mv(this,e,t);Fl(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Ve();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===yn&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?he(this.doc,r=>{const i=new Cc(null,this._start,0,new Map);for(let s=0;s<e.length;s++){const o=e[s];if(o.insert!==void 0){const l=!t&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
|
|
39
|
-
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Na(r,this,i,l,o.attributes||{})}else o.retain!==void 0?Nh(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Ah(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??Ve();const i=[],s=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let f=!1;s.forEach((g,p)=>{f=!0,d[p]=g});const h={insert:l};f&&(h.attributes=d),i.push(h),l=""}}const u=()=>{for(;a!==null;){if(jr(a,e)||t!==void 0&&jr(a,t))switch(a.content.constructor){case yn:{const d=s.get("ychange");e!==void 0&&!jr(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),s.set("ychange",r?r("removed",a.id):{type:"removed"})):t!==void 0&&!jr(a,t)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),s.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),s.delete("ychange")),l+=a.content.str;break}case Jn:case ki:{c();const d={insert:a.content.getContent()[0]};if(s.size>0){const f={};d.attributes=f,s.forEach((h,g)=>{f[g]=h})}i.push(d);break}case De:jr(a,e)&&(c(),Ei(s,a.content));break}a=a.right}c()};return e||t?he(o,d=>{e&&xc(d,e),t&&xc(d,t),u()},"cleanup"):u(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Na(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!r);Na(s,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?he(r,i=>{Ah(i,Vs(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!1);o.right!==null&&Nh(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?he(this.doc,t=>{Ko(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?he(this.doc,r=>{Bu(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return zu(this,e)}getAttributes(){return t_(this)}_write(e){e.writeTypeRef(wv)}}class Aa{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ve()}[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===_n||t.constructor===ri)&&t._start!==null)e=t._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class ri extends Ue{constructor(){super(),this._prelimContent=[]}get firstChild(){const 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 ri}clone(){const e=new ri;return e.insert(0,this.toArray().map(t=>t instanceof Ue?t.clone():t)),e}get length(){return this.doc??Ve(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Aa(this,e)}querySelector(e){e=e.toUpperCase();const r=new Aa(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),ti(new Aa(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Fl(this,e,new _v(this,t,e))}toString(){return qm(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),ps(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?he(this.doc,r=>{Qm(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)he(this.doc,r=>{const i=e&&e instanceof Ue?e._item:e;Uo(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw Pn("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?he(this.doc,r=>{e_(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Ym(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Zm(this,e)}slice(e=0,t=this.length){return Vm(this,e,t)}forEach(e){ps(this,e)}_write(e){e.writeTypeRef(Ev)}}class _n extends ri{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new _n(this.nodeName)}clone(){const e=new _n(this.nodeName),t=this.getAttributes();return PC(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Ue?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const l in e)r.push(l);r.sort();const i=r.length;for(let l=0;l<i;l++){const a=r[l];t.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?he(this.doc,t=>{Ko(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?he(this.doc,r=>{Bu(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return zu(this,e)}hasAttribute(e){return n_(this,e)}getAttributes(e){return e?uv(this,e):t_(this)}toDOM(e=document,t={},r){const i=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&i.setAttribute(o,l)}return ps(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(vv),e.writeKey(this.nodeName)}}class _v extends $l{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class Un extends ms{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Un}clone(){const e=new Un;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const s=[];for(const o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,l)=>o.key<l.key?-1:1),t.push({nodeName:i,attrs:s})}t.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const s=t[i];r+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){const l=s.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let i=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(kv)}}class l_{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ft()}mergeWith(e){return!1}write(e,t,r){throw Ft()}integrate(e,t){throw Ft()}}const yv=0;class En extends l_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Wm(e.doc.store,this)}write(e,t){e.writeInfo(yv),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Dl{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Dl(this.content)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class Wo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Wo(this.len)}splice(e){const t=new Wo(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){zm(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}}const bv=(n,e)=>new Bn({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ll{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;const 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 Ll(bv(this.doc.guid,this.opts))}splice(e){throw Ft()}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}}class ki{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ki(this.embed)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class De{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new De(this.key,this.value)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const xv=Po("node_env")==="development";class ii{constructor(e){this.arr=e,xv&&hm(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ii(this.arr)}splice(e){const t=new ii(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}class yn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new yn(this.str)}splice(e){const t=new yn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}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}}const Sv=0,Cv=1,wv=2,vv=3,Ev=4,kv=6;class Jn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Jn(this.type._copy())}splice(e){throw Ft()}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(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.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(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const a_=(n,e,t)=>{const{client:r,clock:i}=e.id,s=new Je(_e(r,i+t),e,_e(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=_e(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s};class Je extends l_{constructor(e,t,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?lh:0}set marker(e){(this.info&Sa)>0!==e&&(this.info^=Sa)}get marker(){return(this.info&Sa)>0}get keep(){return(this.info&oh)>0}set keep(e){this.keep!==e&&(this.info^=oh)}get countable(){return(this.info&lh)>0}get deleted(){return(this.info&xa)>0}set deleted(e){this.deleted!==e&&(this.info^=xa)}markDeleted(){this.info|=xa}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=it(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=it(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===io&&this.id.client!==this.parent.client&&this.parent.clock>=it(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=wh(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=zn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===En||this.right&&this.right.constructor===En)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Je?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Je&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===io){const r=Ta(t,this.parent);r.constructor===En?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wh(e,e.doc.store,_e(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 r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),Js(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(Js(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Ta(e.doc.store,i.origin)))s.has(Ta(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Wm(e.doc.store,this),this.content.integrate(e,this),Eh(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new En(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:_e(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Js(e.origin,this.lastId)&&this.right===e&&Js(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)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.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){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),zm(e.deleteSet,this.id.client,this.id.clock,this.length),Eh(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw pn();this.content.gc(e),t?ev(e,this,new En(this.id,this.length)):this.content=new Wo(this.length)}write(e,t){const r=t>0?_e(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&lC|(r===null?0:Lo)|(i===null?0:cm)|(s===null?0:oC);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=Zw(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===io?(e.writeParentInfo(!1),e.writeLeftID(l)):pn();s!==null&&e.writeString(s)}this.content.write(e,t)}}const c_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},u_="__ $YJS$ __";c_[u_]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");c_[u_]=!0;function Be(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Tv(n,e,t){const r=n.length,i=e.length;let s=0,o=0;for(;s<r&&s<i&&n[s]===e[s]&&s<t;)s++;for(;o+s<r&&o+s<i&&n[r-o-1]===e[i-o-1];)o++;for(;o+s<r&&o+s<i&&n[s]===e[s];)s++;return{index:s,insert:e.slice(s,i-o),remove:r-s-o}}class er{_xmlElem;_key;_parent;_type;constructor(e,t,r){this._key="",this._xmlElem=e,this._parent=t,this._type=r}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return V(t)?t:null}getNode(){const e=q(this._key);return V(e)?e:null}getSharedType(){return this._xmlElem}getType(){return this._type}getKey(){return this._key}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}syncPropertiesFromLexical(e,t,r){const i=this.getPrevNode(r);Wu(e,this._xmlElem,i,t)}syncPropertiesFromYjs(e,t){const r=this.getNode();r===null&&Be(83),Ku(e,this._xmlElem,r,t)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function d_(n,e,t){const r=new er(n,e,t);return n._collabNode=r,r}class Ui{_map;_key;_parent;_type;constructor(e,t){this._key="",this._map=e,this._parent=t,this._type="linebreak"}getNode(){const e=q(this._key);return ue(e)?e:null}getKey(){return this._key}getSharedType(){return this._map}getType(){return this._type}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function f_(n,e){const t=new Ui(n,e);return n._collabNode=t,t}class xt{_map;_key;_parent;_text;_type;_normalized;constructor(e,t,r,i){this._key="",this._map=e,this._parent=r,this._text=t,this._type=i,this._normalized=!1}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return D(t)?t:null}getNode(){const e=q(this._key);return D(e)?e:null}getSharedType(){return this._map}getType(){return this._type}getKey(){return this._key}getSize(){return this._text.length+(this._normalized?0:1)}getOffset(){return this._parent.getChildOffset(this)}spliceText(e,t,r){const i=this._parent._xmlText,s=this.getOffset()+1+e;t!==0&&i.delete(s,t),r!==""&&i.insert(s,r)}syncPropertiesAndTextFromLexical(e,t,r){const i=this.getPrevNode(r),s=t.__text;if(Wu(e,this._map,i,t),i!==null){const o=i.__text;o!==s&&((function(l,a,c,u){const d=O();let f=u.length;if(N(d)&&d.isCollapsed()){const g=d.anchor;g.key===a&&(f=g.offset)}const h=Tv(c,u,f);l.spliceText(h.index,h.remove,h.insert)})(this,t.__key,o,s),this._text=s)}}syncPropertiesAndTextFromYjs(e,t){const r=this.getNode();r===null&&Be(84),Ku(e,this._map,r,t);const i=this._text;r.__text!==i&&r.setTextContent(i)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function h_(n,e,t,r){const i=new xt(n,e,t,r);return n._collabNode=i,i}class rn{_key;_children;_xmlText;_type;_parent;constructor(e,t,r){this._key="",this._children=[],this._xmlText=e,this._type=r,this._parent=t}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return A(t)?t:null}getNode(){const e=q(this._key);return A(e)?e:null}getSharedType(){return this._xmlText}getType(){return this._type}getKey(){return this._key}isEmpty(){return this._children.length===0}getSize(){return 1}getOffset(){const e=this._parent;return e===null&&Be(90),e.getChildOffset(this)}syncPropertiesFromYjs(e,t){const r=this.getNode();r===null&&Be(91),Ku(e,this._xmlText,r,t)}applyChildrenYjsDelta(e,t){const r=this._children;let i=0,s=null;for(let o=0;o<t.length;o++){const l=t[o],a=l.insert,c=l.delete;if(l.retain!=null)i+=l.retain;else if(typeof c=="number"){let u=c;for(;u>0;){const{node:d,nodeIndex:f,offset:h,length:g}=Oa(this,i,!1);if(d instanceof rn||d instanceof Ui||d instanceof er)r.splice(f,1),u-=1;else{if(!(d instanceof xt))break;{const p=Math.min(u,g),m=f!==0?r[f-1]:null,b=d.getSize();if(h===0&&g===b){r.splice(f,1);const _=Ii(d._text,h,p-1,"");_.length>0&&(m instanceof xt?m._text+=_:this._xmlText.delete(h,_.length))}else d._text=Ii(d._text,h,p,"");u-=p}}}}else{if(a==null)throw new Error("Unexpected delta format");if(typeof a=="string"){const{node:u,offset:d}=Oa(this,i,!0);u instanceof xt?u._text=Ii(u._text,d,0,a):this._xmlText.delete(d,a.length),i+=a.length}else{const u=a,{node:d,nodeIndex:f,length:h}=Oa(this,i,!1),g=p_(e,u,this);if(d instanceof xt&&h>0&&h<d._text.length){const p=d._text,m=p.length-h;d._text=Ii(p,m,h,""),r.splice(f+1,0,g),s=Ii(p,0,m,"")}else r.splice(f,0,g);s!==null&&g instanceof xt&&(g._text=s+g._text,s=null),i+=1}}}}syncChildrenFromYjs(e){const t=this.getNode();t===null&&Be(92);const r=t.__key,i=or(t,null),s=i.length,o=this._children,l=o.length,a=e.collabNodeMap,c=new Set;let u,d,f=0,h=null;l!==s&&(d=t.getWritable());for(let g=0;g<l;g++){const p=i[f],m=o[g],b=m.getNode(),_=m._key;if(b!==null&&p===_){const y=D(b);if(c.add(p),y)if(m._key=p,m instanceof rn){const S=m._xmlText;m.syncPropertiesFromYjs(e,null),m.applyChildrenYjsDelta(e,S.toDelta()),m.syncChildrenFromYjs(e)}else m instanceof xt?m.syncPropertiesAndTextFromYjs(e,null):m instanceof er?m.syncPropertiesFromYjs(e,null):m instanceof Ui||Be(93);h=b,f++}else{if(u===void 0){u=new Set;for(let C=0;C<l;C++){const x=o[C]._key;x!==""&&u.add(x)}}if(b!==null&&p!==void 0&&!u.has(p)){const C=Qn(p);jt(C),g--,f++;continue}d=t.getWritable();const y=Rv(e,m,r),S=y.__key;if(a.set(S,m),h===null){const C=d.getFirstChild();if(d.__first=S,C!==null){const x=C.getWritable();x.__prev=S,y.__next=x.__key}}else{const C=h.getWritable(),x=h.getNextSibling();if(C.__next=S,y.__prev=h.__key,x!==null){const v=x.getWritable();v.__prev=S,y.__next=v.__key}}g===l-1&&(d.__last=S),d.__size++,h=y}}for(let g=0;g<s;g++){const p=i[g];if(!c.has(p)){const m=Qn(p),b=e.collabNodeMap.get(p);b!==void 0&&b.destroy(e),jt(m)}}}syncPropertiesFromLexical(e,t,r){Wu(e,this._xmlText,this.getPrevNode(r),t)}_syncChildFromLexical(e,t,r,i,s,o){const l=this._children[t],a=Qn(r);l instanceof rn&&A(a)?(l.syncPropertiesFromLexical(e,a,i),l.syncChildrenFromLexical(e,a,i,s,o)):l instanceof xt&&D(a)?l.syncPropertiesAndTextFromLexical(e,a,i):l instanceof er&&V(a)&&l.syncPropertiesFromLexical(e,a,i)}syncChildrenFromLexical(e,t,r,i,s){const o=this.getPrevNode(r),l=o===null?[]:or(o,r),a=or(t,null),c=l.length-1,u=a.length-1,d=e.collabNodeMap;let f,h,g=0,p=0;for(;g<=c&&p<=u;){const _=l[g],y=a[p];if(_===y)this._syncChildFromLexical(e,p,y,r,i,s),g++,p++;else{f===void 0&&(f=new Set(l)),h===void 0&&(h=new Set(a));const S=h.has(_),C=f.has(y);if(S){const x=Oh(e,Qn(y),this);d.set(y,x),C?(this.splice(e,p,1,x),g++,p++):(this.splice(e,p,0,x),p++)}else this.splice(e,p,1),g++}}const m=g>c,b=p>u;if(m&&!b)for(;p<=u;++p){const _=a[p],y=Oh(e,Qn(_),this);this.append(y),d.set(_,y)}else if(b&&!m)for(let _=this._children.length-1;_>=p;_--)this.splice(e,_,1)}append(e){const t=this._xmlText,r=this._children,i=r[r.length-1],s=i!==void 0?i.getOffset()+i.getSize():0;if(e instanceof rn)t.insertEmbed(s,e._xmlText);else if(e instanceof xt){const o=e._map;o.parent===null&&t.insertEmbed(s,o),t.insert(s+1,e._text)}else e instanceof Ui?t.insertEmbed(s,e._map):e instanceof er&&t.insertEmbed(s,e._xmlElem);this._children.push(e)}splice(e,t,r,i){const s=this._children,o=s[t];if(o===void 0)return i===void 0&&Be(94),void this.append(i);const l=o.getOffset();l===-1&&Be(95);const a=this._xmlText;if(r!==0&&a.delete(l,o.getSize()),i instanceof rn)a.insertEmbed(l,i._xmlText);else if(i instanceof xt){const c=i._map;c.parent===null&&a.insertEmbed(l,c),a.insert(l+1,i._text)}else i instanceof Ui?a.insertEmbed(l,i._map):i instanceof er&&a.insertEmbed(l,i._xmlElem);if(r!==0){const c=s.slice(t,t+r);for(let u=0;u<c.length;u++)c[u].destroy(e)}i!==void 0?s.splice(t,r,i):s.splice(t,r)}getChildOffset(e){let t=0;const r=this._children;for(let i=0;i<r.length;i++){const s=r[i];if(s===e)return t;t+=s.getSize()}return-1}destroy(e){const t=e.collabNodeMap,r=this._children;for(let i=0;i<r.length;i++)r[i].destroy(e);t.get(this._key)===this&&t.delete(this._key)}}function Uu(n,e,t){const r=new rn(n,e,t);return n._collabNode=r,r}function Nv(n,e,t,r,i){t==null&&Be(81);const s={clientID:t.clientID,cursors:new Map,cursorsContainer:null,doc:t,docMap:r,editor:n,excludedProperties:i||new Map,id:e,nodeProperties:new Map};return(function(o){const{editor:l,nodeProperties:a}=o;l.update(()=>{l._nodes.forEach(c=>{const u=new c.klass,d={};for(const[f,h]of Object.entries(u))g_(f,u,o)||(d[f]=h);a.set(u.__type,Object.freeze(d))})})})(s),s}function Av(n,e,t,r,i,s){r==null&&Be(81);const o=Uu(r.get("root",Un),null,"root");return o._key="root",{...Nv(n,t,r,i,s),collabNodeMap:new Map,root:o}}function Ov(n){return Object.hasOwn(n,"collabNodeMap")}const Mv=new Set(["__key","__parent","__next","__prev","__state"]),$v=new Set(["__first","__last","__size"]),Iv=new Set(["__cachedText"]),Fv=new Set(["__text"]);function g_(n,e,t){if(Mv.has(n)||typeof e[n]=="function")return!0;if(D(e)){if(Fv.has(n))return!0}else if(A(e)&&($v.has(n)||be(e)&&Iv.has(n)))return!0;const r=e.constructor,i=t.excludedProperties.get(r);return i!=null&&i.has(n)}function Dv(n,e){const t=n.__type,{nodeProperties:r}=e,i=r.get(t);return i===void 0&&Be(330,t),i}function Oh(n,e,t){const r=e.__type;let i;if(A(e))i=Uu(new Un,t,r),i.syncPropertiesFromLexical(n,e,null),i.syncChildrenFromLexical(n,e,null,null,null);else if(D(e))i=h_(new yt,e.__text,t,r),i.syncPropertiesAndTextFromLexical(n,e,null);else if(ue(e)){const s=new yt;s.set("__type","linebreak"),i=f_(s,t)}else V(e)?(i=d_(new _n,t,r),i.syncPropertiesFromLexical(n,e,null)):Be(86);return i._key=e.__key,i}function Lv(n){const e=Rl(n,"__type");return typeof e!="string"&&e!==void 0&&Be(87),e}function p_(n,e,t){const r=e._collabNode;if(r===void 0){const i=n.editor._nodes,s=Lv(e);typeof s!="string"&&Be(87),i.get(s)===void 0&&Be(88,s);const o=e.parent,l=t===void 0&&o!==null?p_(n,o):t||null;if(l instanceof rn||Be(89),e instanceof Un)return Uu(e,l,s);if(e instanceof yt)return s==="linebreak"?f_(e,l):h_(e,"",l,s);if(e instanceof _n)return d_(e,l,s)}return r}function Rv(n,e,t){const r=e.getType(),i=n.editor._nodes.get(r);i===void 0&&Be(88,r);const s=new i.klass;if(s.__parent=t,e._key=s.__key,e instanceof rn){const o=e._xmlText;e.syncPropertiesFromYjs(n,null),e.applyChildrenYjsDelta(n,o.toDelta()),e.syncChildrenFromYjs(n)}else e instanceof xt?e.syncPropertiesAndTextFromYjs(n,null):e instanceof er&&e.syncPropertiesFromYjs(n,null);return n.collabNodeMap.set(s.__key,e),s}function Ku(n,e,t,r){const i=r===null?e instanceof yt?Array.from(e.keys()):e instanceof Un||e instanceof _n?Object.keys(e.getAttributes()):Object.keys(e):Array.from(r);let s;for(let o=0;o<i.length;o++){const l=i[o];if(g_(l,t,n)){l==="__state"&&Ov(n)&&(s||(s=t.getWritable()),Pv(e,s));continue}const a=t[l];let c=Rl(e,l);if(a!==c){if(c instanceof Bn){const u=n.docMap;a instanceof Bn&&u.delete(a.guid);const d=gi(),f=c.guid;d._key=f,u.set(f,c),c=d}s===void 0&&(s=t.getWritable()),s[l]=c}}}function Rl(n,e){return n instanceof yt?n.get(e):n instanceof Un||n instanceof _n?n.getAttribute(e):n[e]}function Mh(n,e,t){n instanceof yt?n.set(e,t):n.setAttribute(e,t)}function Pv(n,e){const t=Rl(n,"__state");t instanceof yt&&Jo(e).updateFromJSON(t.toJSON())}function Wu(n,e,t,r){const i=Object.keys(Dv(r,n)),s=n.editor.constructor;(function(o,l,a,c){const u=c.__state,d=Rl(l,"__state");if(!u)return;const[f,h]=u.getInternalState(),g=a&&a.__state,p=d instanceof yt?d:new yt;if(g===u)return;const[m,b]=g&&p.doc?g.getInternalState():[void 0,new Map];if(f)for(const[_,y]of Object.entries(f))m&&y!==m[_]&&p.set(_,y);for(const[_,y]of h)b.get(_)!==y&&p.set(_.key,_.unparse(y));d||Mh(l,"__state",p)})(0,e,t,r);for(let o=0;o<i.length;o++){const l=i[o],a=t===null?void 0:t[l];let c=r[l];if(a!==c){if(c instanceof s){const u=n.docMap;let d;if(a instanceof s){const g=a._key;d=u.get(g),u.delete(g)}const f=d||new Bn,h=f.guid;c._key=h,u.set(h,f),c=f,n.editor.update(()=>{r.markDirty()})}Mh(e,l,c)}}}function Ii(n,e,t,r){return n.slice(0,e)+r+n.slice(e+t)}function Oa(n,e,t){let r=0,i=0;const s=n._children,o=s.length;for(;i<o;i++){const l=s[i],a=r;if(r+=l.getSize(),(t?r>=e:r>e)&&l instanceof xt){let c=e-a-1;return c<0&&(c=0),{length:r-e,node:l,nodeIndex:i,offset:c}}if(r>e)return{length:0,node:l,nodeIndex:i,offset:a};if(i===o-1)return{length:0,node:null,nodeIndex:i+1,offset:a+1}}return{length:0,node:null,nodeIndex:0,offset:0}}Tc("ychange",{isEqual:(n,e)=>n===e,parse:n=>n??null});async function m_(){return hb}async function Pl(n){return ox(n)}async function Bl(n){return mS(n)}async function zl(n,e){const t=qp(),r=e?.delay??300;return Yp(n,t,r)}async function Ul(n){return()=>{}}async function Kl(n){return typeof da=="function"?typeof hf=="function"?pt(da(n),hf(n)):da(n):pt(n.registerCommand(xi,()=>(fa(n,"number"),!0),G),n.registerCommand(bi,()=>(fa(n,"bullet"),!0),G),n.registerCommand(xl,()=>(fa(n,"check"),!0),G),n.registerCommand(pu,()=>(px(n),!0),G))}async function Wl(n){return n.registerCommand(lc,e=>(e===null||typeof e=="string"?ha(e):ha(e.url,e),!0),G)}async function Bv(n,e,t){const r=e?.trigger||"/";let i=!1,s=null,o=0;const l=()=>n.getEditorState().read(()=>{const p=O();if(!N(p)||!p.isCollapsed())return!1;const m=p.anchor,b=m.getNode();if(!D(b))return!1;const _=b.getTextContent(),y=m.offset;if(y===0||_[y-1]!==r)return!1;if(y===1)return!0;const C=_[y-2];return!!/\s/.test(C)}),a=()=>s?n.getEditorState().read(()=>{if(!s)return"";const p=s.getTextContent(),m=p.indexOf(r,o);if(m===-1)return"";const b=O();if(!N(b))return"";const _=b.anchor;if(_.getNode().getKey()!==s.getKey())return"";const S=_.offset;return S<=m?"":p.slice(m+1,S)}):"",c=()=>{n.getEditorState().read(()=>{const p=O();if(N(p)){const m=p.anchor,b=m.getNode();if(D(b)){s=b,o=m.offset-1,i=!0;const _={isActive:!0,filterText:"",anchorNode:s,anchorOffset:o};t?.onTrigger?.(_,d),t?.onUpdate?.(_,d)}}})},u=()=>{i&&(i=!1,s=null,o=0,t?.onDismiss?.())},d=()=>{s&&n.update(()=>{if(!s)return;const p=s.getTextContent(),m=p.indexOf(r,o);if(m===-1)return;const b=O();if(!N(b))return;const _=b.anchor;if(_.getNode().getKey()!==s.getKey())return;const S=_.offset,C=p.slice(0,m),x=p.slice(S);s.setTextContent(C+x);const v=O();N(v)&&(v.anchor.set(s.getKey(),m,"text"),v.focus.set(s.getKey(),m,"text"))})},f=()=>{if(!i)return;const m={isActive:!0,filterText:a(),anchorNode:s,anchorOffset:o};t?.onUpdate?.(m,d)},h=n.registerMutationListener(Ye,p=>{if(!i&&l()){c();return}i&&(s&&!p.has(s.getKey())?f():u())}),g=pt(n.registerUpdateListener(({editorState:p})=>{p.read(()=>{if(!i)return;const m=O();if(!N(m)){u();return}const b=m.anchor,_=b.getNode();if(!s||_.getKey()!==s.getKey()){u();return}const S=s.getTextContent().indexOf(r,o);if(S===-1||b.offset<=S){u();return}})}),n.registerCommand(dr,p=>i?(p.preventDefault(),!0):!1,G),n.registerCommand(dn,p=>i?(p.preventDefault(),!0):!1,G),n.registerCommand(Dn,p=>i?(p?.preventDefault(),!0):!1,G),n.registerCommand(ui,p=>i?(p?.preventDefault(),u(),!0):!1,G));return()=>{u(),h(),g()}}function zv(n,e,t){t(),e.handler(n),n.focus()}const Uv=z("TOGGLE_SLASH_COMMAND_PALETTE"),Ms=z("INSERT_HORIZONTAL_RULE_COMMAND"),Kv=z("INSERT_IMAGE_COMMAND");function jl(n){return n.registerCommand(Ms,()=>{const e=O();if(!N(e))return!1;if(e.focus.getNode()!==null){const r=Ns();e.insertNodes([r]);const i=H();r.insertAfter(i),i.selectStart()}return!0},G)}const __={dependencies:[Ir],export:n=>Vp(n)?"---":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const i=Ns();if(r)n.replace(i);else{n.replace(i);const s=H();i.insertAfter(s),s.selectStart()}},type:"element"},ju=[...wu,__];async function wt(n){let e="";return n.getEditorState().read(()=>{e=qS(ju)}),e}async function Kn(n,e){n.update(()=>{YS(e,ju)})}async function y_(){return ju}const Hu=Object.freeze(Object.defineProperty({__proto__:null,exportToMarkdown:wt,getMarkdownTransformers:y_,importFromMarkdown:Kn},Symbol.toStringTag,{value:"Module"}));async function vt(n){let e="";return n.getEditorState().read(()=>{e=fp(n)}),e}async function Wn(n,e){n.update(()=>{const r=new DOMParser().parseFromString(e,"text/html"),i=dp(n,r);fe().clear(),nl(i)})}const Ju=Object.freeze(Object.defineProperty({__proto__:null,exportToHtml:vt,importFromHtml:Wn},Symbol.toStringTag,{value:"Module"}));async function Wv(n,e,t){let r,i,s;switch(e){case"markdown":r=await wt(n),i="text/markdown",s="md";break;case"html":r=await vt(n),i="text/html",s="html";break;case"json":r=JSON.stringify(n.getEditorState().toJSON(),null,2),i="application/json",s="json";break}const o=new Blob([r],{type:i}),l=URL.createObjectURL(o),a=document.createElement("a");a.href=l,a.download=t??`document.${s}`,a.click(),URL.revokeObjectURL(l)}async function jv(n,e,t){const r=await new Promise((s,o)=>{const l=new FileReader;l.onload=()=>s(l.result),l.onerror=()=>o(l.error),l.readAsText(e)});switch(t??Hv(e.name)){case"markdown":{const{importFromMarkdown:s}=await Promise.resolve().then(()=>Hu);await s(n,r);break}case"html":{const{importFromHtml:s}=await Promise.resolve().then(()=>Ju);await s(n,r);break}case"json":{const s=n.parseEditorState(r);n.setEditorState(s);break}}}function Hv(n){return n.endsWith(".md")||n.endsWith(".markdown")?"markdown":n.endsWith(".html")||n.endsWith(".htm")?"html":"json"}async function Hl(n,e){return typeof vf=="function"?vf(n):()=>{}}async function Jv(n,e=3,t=3){n.dispatchCommand(Ts,{rows:String(e),columns:String(t),includeHeaders:!0})}async function Gv(n,e){return typeof Fo=="function"?Fo(n):()=>{}}async function Vv(n,e){return typeof Fo=="function"?Fo(n):()=>{}}const Yv=/#[\w\u0590-\u05ff]+/;function qv(n){return new Cl(n)}async function Zv(n,e){const t=[],r=rS(n,i=>{const s=Yv.exec(i);return s?{start:s.index,end:s.index+s[0].length}:null},Cl,qv);if(Array.isArray(r)?t.push(...r):typeof r=="function"&&t.push(r),e?.onHashtagClick){const i=n.registerCommand(br,s=>{const o=s.target;if(o.classList.contains("bc-lexical-hashtag")){const l=o.textContent;if(l)return e.onHashtagClick(l.replace("#","")),!0}return!1},G);t.push(i)}return()=>{t.forEach(i=>i())}}const Xv=/((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g,Qv=/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g,e0=[{pattern:Xv,urlTransformer:n=>n.startsWith("http")?n:`https://${n}`},{pattern:Qv,urlTransformer:n=>`mailto:${n}`}];async function t0(n,e){const t=e?.matchers??e0;return n.registerMutationListener(Ye,r=>{n.update(()=>{for(const[i,s]of r){if(s!=="created"&&s!=="updated")continue;const o=q(i);if(!o||!D(o))continue;const l=o.getTextContent();for(const a of t){const c=new RegExp(a.pattern.source,a.pattern.flags);let u;for(;(u=c.exec(l))!==null;)a.urlTransformer(u[0])}}})})}async function n0(n,e){const t=[];return e?.onMarkClick&&t.push(n.registerCommand(br,r=>{const i=r.target;if(i.classList.contains("bc-lexical-mark")){const s=i.dataset.markId;if(s)return e.onMarkClick(s,{id:s,type:i.dataset.markType||"annotation",data:{}}),!0}return!1},G)),()=>t.forEach(r=>r())}async function r0(n,e,t){n.update(()=>{const r=O();N(r)&&oS(r,r.isBackward(),e)})}async function i0(n,e){n.update(()=>{const r=fe().getAllTextNodes().filter(i=>{const s=i.getParent();return as(s)?lS(i,0)?.includes(e)??!1:!1});for(const i of r){const s=i.getParent();as(s)&&sS(s)}})}async function s0(n,e){const{maxLength:t,onOverflow:r}=e;return n.registerUpdateListener(({editorState:i})=>{i.read(()=>{const l=fe().getTextContent().length,a=l>t;r&&r(a,l)})})}async function Jl(n){return typeof ef=="function"?ef(n):()=>{}}async function Gl(n,e){const t=e.docMap??new Map,r=e.id??"lexical",i=e.doc.getText(r),s=Av(n,e.provider,i,e.doc,t),o=n.registerUpdateListener(()=>{});return()=>{o(),s&&typeof s.destroy=="function"&&s.destroy()}}function o0(n){let e={hasSelection:!1,selectedText:"",anchorOffset:0,focusOffset:0};return n.getEditorState().read(()=>{const t=O();N(t)&&(e={hasSelection:!t.isCollapsed(),selectedText:t.getTextContent(),anchorOffset:t.anchor.offset,focusOffset:t.focus.offset})}),e}function Gu(n){let e="";return n.getEditorState().read(()=>{e=fe().getTextContent()}),e}function l0(n){return Gu(n).length}function a0(n){const e=Gu(n).trim();return e?e.split(/\s+/).length:0}async function c0(){return eC}async function $s(n={}){const{nodes:e=[],plugins:t=[],onError:r}=n,s=(await m_()).createEditor({namespace:"BeatUIHeadless",nodes:e,onError:o=>{r?r(o,s):console.error("[BeatUI Headless]",o)},editable:!1});if(t.length>0)for(const o of t)o.register(s);return s}async function u0(n){const e=await $s(),{importFromMarkdown:t}=await Promise.resolve().then(()=>Hu);return await t(e,n),e.getEditorState().toJSON()}async function d0(n){const e=await $s(),{exportToMarkdown:t}=await Promise.resolve().then(()=>Hu),r=e.parseEditorState(JSON.stringify(n));return e.setEditorState(r),await t(e)}async function f0(n){const e=await $s(),{importFromHtml:t}=await Promise.resolve().then(()=>Ju);return await t(e,n),e.getEditorState().toJSON()}async function h0(n){const e=await $s(),{exportToHtml:t}=await Promise.resolve().then(()=>Ju),r=e.parseEditorState(JSON.stringify(n));return e.setEditorState(r),await t(e)}const b_=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="auto",onError:c,onInput:u,onChange:d,onBlur:f,onReady:h}=n;return w.Use(vc.Theme,({appearance:g})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-CEDSZTyZ.cjs")),({default:p})=>wc.LinkPortal({id:"beatui-lexical-css",href:p})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,p=>!p):!0),i!=null?w.attr.class(w.Value.map(i,p=>p?"bc-lexical-editor--readonly":"")):null,w.WithElement(p=>{let m=null;const b=[];return(async()=>{try{const y=r??vl("bare"),S=wl(y),C=w.Value.get(t??"markdown"),x=gi({namespace:l,nodes:S,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:E=>{c?c(E,x):console.error("[BeatUI Lexical]",E)},editable:i?!w.Value.get(i):!0});m=x,x.setRootElement(p);const v=[];if(y.richText?v.push(Pl(x)):y.plainText&&v.push(Bl(x)),y.history){const E=typeof y.history=="object"?y.history:void 0;v.push(zl(x,E))}if(y.clipboard&&v.push(Ul(x)),y.list&&v.push(Kl(x)),y.link&&v.push(Wl(x)),y.yjs&&v.push(Gl(x,y.yjs)),y.dragon&&v.push(Jl(x)),y.table&&v.push(Hl(x)),(await Promise.all(v)).forEach(E=>{E&&b.push(E)}),b.push(jl(x)),e!=null){const E=w.Value.get(e);if(E!=null&&(E!==""||C==="json"&&typeof E=="object")){if(C==="markdown"&&typeof E=="string")await Kn(x,E);else if(C==="html"&&typeof E=="string")await Wn(x,E);else if(C==="json"&&typeof E=="object")try{const T=JSON.stringify(E),I=x.parseEditorState(T);x.setEditorState(I)}catch(T){console.error("[BeatUI] Failed to parse JSON editor state:",T),c&&c(T instanceof Error?T:new Error(String(T)),x)}}}b.push(x.registerUpdateListener(({editorState:E,dirtyElements:M,dirtyLeaves:T})=>{M.size===0&&T.size===0||u&&E.read(async()=>{if(C==="markdown"){const I=await wt(x);u(I,x)}else if(C==="html"){const I=await vt(x);u(I,x)}else C==="json"&&u(E.toJSON(),x)})})),e!=null&&b.push(w.Value.on(e,async E=>{if(E!=null){if(C==="markdown"&&typeof E=="string"){const M=await wt(x);E!==M&&await Kn(x,E)}else if(C==="html"&&typeof E=="string"){const M=await vt(x);E!==M&&await Wn(x,E)}else if(C==="json"&&typeof E=="object"){const M=JSON.stringify(x.getEditorState().toJSON()),T=JSON.stringify(E);if(M!==T){const I=x.parseEditorState(T);x.setEditorState(I)}}}})),i!=null&&b.push(w.Value.on(i,E=>{x.setEditable(!E)})),b.push(x.registerCommand(fi,()=>(f&&f(x),d&&x.getEditorState().read(async()=>{if(C==="markdown"){const E=await wt(x);d(E,x)}else if(C==="html"){const E=await vt(x);d(E,x)}else C==="json"&&d(x.getEditorState().toJSON(),x)}),!1),G)),b.push(g.on(E=>{const M=x.getRootElement();M&&(M.dataset.theme=E)})),h&&h(x)}catch(y){console.error("[BeatUI] Failed to initialize Lexical editor:",y);const S=p;S.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{b.forEach(y=>y())}catch{}try{m?.setRootElement(null)}catch{}})}))))};function x_(n,e,t){const r=(h,g)=>e.map(()=>{const p=n.value;return p?p.getEditorState().read(()=>{const m=O();return N(m)?h(m):g}):g}),i=h=>{const g=h.anchor.getNode();return g.getKey()==="root"?g:g.getTopLevelElementOrThrow()};return{withSelection:r,getAnchorElement:i,textFormatActive:h=>r(g=>g.hasFormat(h),!1),blockTypeActive:h=>r(g=>i(g).getType()===h,!1),listTypeActive:h=>r(g=>{const p=i(g).getParent();return J(p)&&p.getListType()===h},!1),headingActive:h=>e.map(()=>{const g=n.value;return g?g.getEditorState().read(()=>{const p=O();if(N(p)){const m=i(p);if(m.getType()==="heading")return g.getElementByKey(m.getKey())?.tagName===`H${h}`}return!1}):!1}),linkActive:()=>r(h=>{const g=h.anchor.getNode();return g.getParent()?.getType()==="link"||g.getType()==="link"},!1),dispatch:(h,g)=>()=>{const p=n.value;p&&(p.dispatchCommand(h,g),p.focus())},toggleBlock:(h,g)=>()=>{const p=n.value;p&&(p.update(()=>{const m=O();if(N(m)){const b=i(m);et(m,()=>b.getType()===h?H():g())}}),p.focus())},toggleLink:()=>{const h=n.value;h&&(h.getEditorState().read(()=>{const g=O();if(N(g)){const p=g.anchor.getNode();if(p.getParent()?.getType()==="link"||p.getType()==="link")h.dispatchCommand(lc,null);else{const _=prompt(t?.enterUrlMessage?.()??"Enter URL:");_&&h.dispatchCommand(lc,_)}}}),h.focus())}}}function S_(n,e){return t=>r=>ct.EditorToolbarButton({...r,display:t,disabled:n,size:e})}const g0=[{value:"Arial",label:"Arial"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Trebuchet MS",label:"Trebuchet MS"},{value:"Verdana",label:"Verdana"}],p0=[{value:"10px",label:"10"},{value:"12px",label:"12"},{value:"14px",label:"14"},{value:"16px",label:"16"},{value:"18px",label:"18"},{value:"20px",label:"20"},{value:"24px",label:"24"},{value:"30px",label:"30"},{value:"36px",label:"36"}];function C_({editor:n,stateUpdate:e,toolbar:t={},readOnly:r=w.signal(!1),size:i="sm"}){const{visibleGroups:s,hiddenGroups:o,maxHeadingLevel:l=3}=t,a=c=>!(o?.includes(c)||s&&!s.includes(c));return w.Use(nr.BeatUII18n,c=>w.Ensure(n,u=>{const d=u,f=c.$.lexical,h=w.signal(a("text-formatting")),g=w.signal(a("headings")),p=w.signal(a("lists")),m=w.signal(a("blocks")),b=w.signal(a("links")),_=w.signal(a("indent")),y=w.signal(a("tables")),S=w.signal(a("history")),C=w.signal(a("clipboard")),x=w.signal(a("font")),v=w.signal(a("color")),k=w.signal(a("clear-formatting")),{getAnchorElement:E,textFormatActive:M,blockTypeActive:T,listTypeActive:I,headingActive:K,linkActive:$,dispatch:R,toggleBlock:W,toggleLink:Z}=x_(d,e,{enterUrlMessage:()=>c.value.lexical.enterUrl}),Y=S_(r,i),se=()=>{const F=d.value;F&&(F.update(()=>{const U=O();N(U)&&et(U,()=>H())}),F.focus())},Ke=F=>{const U=d.value;U&&(U.update(()=>{const X=O();if(N(X)){const Gn=E(X),Is=`h${F}`,B_=U.getElementByKey(Gn.getKey());Gn.getType()==="heading"&&B_?.tagName===`H${F}`?et(X,()=>H()):et(X,()=>ft(Is))}}),U.focus())},qe=Y(h),j=Y(g),pe=Y(p),oe=Y(m),Ze=Y(b),Se=Y(_),We=Y(y),Xe=Y(k),bt=Y(S),Ce=Y(C),wn=()=>{const F=d.value;if(!F)return;const U=F.getRootElement();U&&(U.focus(),document.execCommand("copy"))},Ti=()=>{const F=d.value;if(!F)return;const U=F.getRootElement();U&&(U.focus(),document.execCommand("cut"))},Zt=()=>{const F=d.value;F&&navigator.clipboard.readText().then(U=>{F.update(()=>{const X=O();N(X)&&X.insertText(U)}),F.focus()}).catch(()=>{})},Ni=()=>{const F=d.value;F&&(F.update(()=>{const U=O();if(N(U))for(const X of U.getNodes())D(X)&&(X.setFormat(0),X.setStyle(""))}),F.focus())},Vl=()=>{const F=d.value;F&&(F.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0}),F.focus())},Vu={value:"",label:c.value.lexical.defaultOption},T_=[Vu,...t.fontFamilies??g0],N_=[Vu,...t.fontSizes??p0],A_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)?zs(U,"font-family",""):""}):""}),O_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)?zs(U,"font-size",""):""}):""}),M_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"font-family":F||null})}),U.focus())},$_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"font-size":F||null})}),U.focus())},I_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)&&zs(U,"color","")||"#000000"}):"#000000"}),F_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)&&zs(U,"background-color","")||"#ffffff"}):"#ffffff"}),D_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();if(N(U)){const X=E(U);return F.getElementByKey(X.getKey())?.style.backgroundColor||"#ffffff"}return"#ffffff"}):"#ffffff"}),L_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{color:F})}),U.focus())},R_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"background-color":F})}),U.focus())},P_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();if(N(X)){const Gn=E(X),Is=U.getElementByKey(Gn.getKey());Is&&(Is.style.backgroundColor=F)}}),U.focus())};return z_.Toolbar(w.attr.class("bc-lexical-toolbar"),w.When(x,()=>ct.EditorToolbarGroup({display:[x]},w.html.select(w.attr.class("bc-lexical-toolbar-select"),w.attr.title(f.map(F=>F.fontFamily)),w.attr.disabled(r),w.on.change(F=>M_(F.target.value)),...T_.map(F=>w.html.option(w.attr.value(F.value),w.attr.selected(A_.map(U=>U===F.value)),F.label))),w.html.select(w.attr.class("bc-lexical-toolbar-select"),w.attr.title(f.map(F=>F.fontSize)),w.attr.disabled(r),w.on.change(F=>$_(F.target.value)),...N_.map(F=>w.html.option(w.attr.value(F.value),w.attr.selected(O_.map(U=>U===F.value)),F.label))))),w.When(v,()=>ct.EditorToolbarGroup({display:[v]},w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.fontColor)),w.html.input(w.attr.type("color"),w.attr.value(I_),w.attr.disabled(r),w.on.input(F=>L_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon"),"A")),w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.highlightColor)),w.html.input(w.attr.type("color"),w.attr.value(F_),w.attr.disabled(r),w.on.input(F=>R_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"),"A")),w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.backgroundColor)),w.html.input(w.attr.type("color"),w.attr.value(D_),w.attr.disabled(r),w.on.input(F=>P_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"),"■")))),ct.EditorToolbarGroup({display:Array(5).fill(h)},qe({active:M("bold"),onClick:R(ve,"bold"),label:f.map(F=>F.bold),icon:"mdi:format-bold"}),qe({active:M("italic"),onClick:R(ve,"italic"),label:f.map(F=>F.italic),icon:"mdi:format-italic"}),qe({active:M("underline"),onClick:R(ve,"underline"),label:f.map(F=>F.underline),icon:"mdi:format-underline"}),qe({active:M("strikethrough"),onClick:R(ve,"strikethrough"),label:f.map(F=>F.strikethrough),icon:"mdi:format-strikethrough"}),qe({active:M("code"),onClick:R(ve,"code"),label:f.map(F=>F.code),icon:"mdi:code-tags"})),ct.EditorToolbarGroup({display:[k]},Xe({active:w.signal(!1),onClick:Ni,label:f.map(F=>F.clearFormatting),icon:"mdi:format-clear"})),ct.EditorToolbarGroup({display:[g,...Array(l).fill(g)]},j({active:T("paragraph"),onClick:se,label:f.map(F=>F.normal),icon:"mdi:format-paragraph"}),...Array.from({length:l},(F,U)=>{const X=U+1;return j({active:K(X),onClick:()=>Ke(X),label:f.map(Gn=>Gn.heading(X)),icon:`mdi:format-header-${X}`})})),ct.EditorToolbarGroup({display:Array(3).fill(p)},pe({active:I("bullet"),onClick:R(bi,void 0),label:f.map(F=>F.bulletList),icon:"mdi:format-list-bulleted"}),pe({active:I("number"),onClick:R(xi,void 0),label:f.map(F=>F.orderedList),icon:"mdi:format-list-numbered"}),pe({active:I("check"),onClick:R(xl,void 0),label:f.map(F=>F.checkList),icon:"mdi:format-list-checks"})),ct.EditorToolbarGroup({display:Array(2).fill(_)},Se({active:w.signal(!1),onClick:R(Ut,void 0),label:f.map(F=>F.indent),icon:"mdi:format-indent-increase"}),Se({active:w.signal(!1),onClick:R(sn,void 0),label:f.map(F=>F.outdent),icon:"mdi:format-indent-decrease"})),ct.EditorToolbarGroup({display:Array(3).fill(m)},oe({active:T("quote"),onClick:W("quote",yi),label:f.map(F=>F.blockquote),icon:"mdi:format-quote-close"}),oe({active:T("code"),onClick:W("code",St),label:f.map(F=>F.codeBlock),icon:"mdi:code-braces"}),oe({active:w.signal(!1),onClick:R(Ms,void 0),label:f.map(F=>F.horizontalRule),icon:"mdi:minus"})),ct.EditorToolbarGroup({display:[y]},We({active:w.signal(!1),onClick:Vl,label:f.map(F=>F.insertTable),icon:"mdi:table-plus"})),ct.EditorToolbarGroup({display:[b]},Ze({active:$(),onClick:Z,label:f.map(F=>F.link),icon:"mdi:link"})),ct.EditorToolbarGroup({display:Array(2).fill(S)},bt({active:w.signal(!1),onClick:R(ai,void 0),label:f.map(F=>F.undo),icon:"mdi:undo"}),bt({active:w.signal(!1),onClick:R(ci,void 0),label:f.map(F=>F.redo),icon:"mdi:redo"})),ct.EditorToolbarGroup({display:Array(3).fill(C)},Ce({active:w.signal(!1),onClick:Ti,label:f.map(F=>F.cut),icon:"mdi:content-cut"}),Ce({active:w.signal(!1),onClick:wn,label:f.map(F=>F.copy),icon:"mdi:content-copy"}),Ce({active:w.signal(!1),onClick:Zt,label:f.map(F=>F.paste),icon:"mdi:content-paste"})))}))}function w_({editor:n,stateUpdate:e,readOnly:t=w.signal(!1)}){const r=w.prop(!1),i=w.prop(0),s=w.prop(0),o=()=>{const p=n.value;if(!p){r.value=!1;return}p.getEditorState().read(()=>{const m=O();if(!N(m)){r.value=!1;return}let _=m.anchor.getNode(),y=null;for(;_;){if(ge(_)){y=_;break}if(_=_.getParent(),!_||_.getKey()==="root")break}if(!y){r.value=!1;return}const S=p.getElementByKey(y.getKey()),C=p.getRootElement();if(S&&C){const x=S.getBoundingClientRect(),v=C.closest(".bc-lexical-editor-container"),k=v?v.getBoundingClientRect():C.getBoundingClientRect();i.value=x.bottom-k.top+4,s.value=x.left-k.left}r.value=!0})};e.onChange(o);const l=()=>{const p=n.value;p&&(p.update(()=>{yf(!1)}),p.focus())},a=()=>{const p=n.value;p&&(p.update(()=>{yf(!0)}),p.focus())},c=()=>{const p=n.value;p&&(p.update(()=>{bf(!1)}),p.focus())},u=()=>{const p=n.value;p&&(p.update(()=>{bf(!0)}),p.focus())},d=()=>{const p=n.value;p&&(p.update(()=>{xx()}),p.focus())},f=()=>{const p=n.value;p&&(p.update(()=>{Sx()}),p.focus())},h=()=>{const p=n.value;p&&(p.update(()=>{const m=O();if(!N(m))return;const b=m.anchor.getNode(),_=bx(b);if(!_)return;Fp(_).remove()}),p.focus())},g=w.html.div(w.attr.class("bc-table-context-menu"),w.attr.role("menu"),w.style.position("absolute"),w.style.top(i.map(p=>`${p}px`)),w.style.left(s.map(p=>`${p}px`)),w.style.zIndex("1000"),w.style.backgroundColor("var(--color-surface)"),w.style.border("1px solid var(--color-border)"),w.style.borderRadius("var(--radius-md)"),w.style.boxShadow("0 2px 8px rgba(0, 0, 0, 0.15)"),w.style.padding("var(--spacing-xs)"),w.style.minWidth("180px"),w.WithElement(p=>{const m=_=>{if(_.key==="Escape"&&r.value){r.value=!1;const y=n.value;y&&y.focus()}},b=_=>{if(r.value&&!p.contains(_.target)){const y=n.value;if(y){const S=y.getRootElement();if(S&&S.contains(_.target))return}r.value=!1}};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b),w.OnDispose(()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b)})}),Yn("Insert row above",l,t),Yn("Insert row below",a,t),Yn("Insert column left",c,t),Yn("Insert column right",u,t),w.html.div(w.attr.class("bc-table-menu-separator"),w.style.height("1px"),w.style.backgroundColor("var(--color-border)"),w.style.margin("var(--spacing-xs) 0")),Yn("Delete row",d,t,"danger"),Yn("Delete column",f,t,"danger"),Yn("Delete table",h,t,"danger"));return w.When(r,()=>g)}function Yn(n,e,t,r="default"){return w.html.button(w.attr.class("bc-table-menu-button"),w.attr.type("button"),w.attr.role("menuitem"),w.attr.disabled(t),w.on.click(e),w.style.display("block"),w.style.width("100%"),w.style.padding("var(--spacing-xs) var(--spacing-sm)"),w.style.border("none"),w.style.backgroundColor("transparent"),w.style.color(r==="danger"?"var(--color-danger-600)":"var(--color-neutral-900)"),w.style.textAlign("left"),w.style.cursor("pointer"),w.style.borderRadius("var(--radius-sm)"),w.style.fontSize("0.875rem"),w.style.transition("background-color 0.15s"),w.html.span(n))}const m0=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="fixed",toolbar:c,onError:u,onInput:d,onChange:f,onBlur:h,onReady:g}=n,p=w.prop(null),m=w.prop(0),b=y=>typeof y=="object"&&y!==null&&"map"in y&&typeof y.map=="function",_=i!=null?b(i)?i:w.prop(w.Value.get(i)):w.prop(!1);return w.Use(vc.Theme,({appearance:y})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-CEDSZTyZ.cjs")),({default:S})=>wc.LinkPortal({id:"beatui-lexical-css",href:S})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),w.When(_.map(S=>!S),()=>C_({editor:p,stateUpdate:m,toolbar:c,readOnly:_,size:"sm"})),w_({editor:p,stateUpdate:m,readOnly:_}),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,S=>!S):!0),i!=null?w.attr.class(w.Value.map(i,S=>S?"bc-lexical-editor--readonly":"")):null,w.WithElement(S=>{let C=null;const x=[];return(async()=>{try{const k=r??vl("docked"),E=wl(k),M=w.Value.get(t??"markdown"),T=gi({namespace:l,nodes:E,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:$=>{u?u($,T):console.error("[BeatUI Lexical]",$)},editable:i?!w.Value.get(i):!0});C=T,p.set(T),T.setRootElement(S);const I=[];if(k.richText?I.push(Pl(T)):k.plainText&&I.push(Bl(T)),k.history){const $=typeof k.history=="object"?k.history:void 0;I.push(zl(T,$))}if(k.clipboard&&I.push(Ul(T)),k.list&&I.push(Kl(T)),k.link&&I.push(Wl(T)),k.yjs&&I.push(Gl(T,k.yjs)),k.dragon&&I.push(Jl(T)),k.table&&I.push(Hl(T)),(await Promise.all(I)).forEach($=>{$&&x.push($)}),x.push(jl(T)),x.push(T.registerCommand(oi,()=>(m.set(m.value+1),!1),G)),x.push(T.registerUpdateListener(({editorState:$,dirtyElements:R,dirtyLeaves:W})=>{(R.size>0||W.size>0)&&m.set(m.value+1),d&&(R.size>0||W.size>0)&&$.read(async()=>{if(M==="markdown"){const Z=await wt(T);d(Z,T)}else if(M==="html"){const Z=await vt(T);d(Z,T)}else M==="json"&&d($.toJSON(),T)})})),e!=null){const $=w.Value.get(e);if($!=null&&($!==""||M==="json"&&typeof $=="object")){if(M==="markdown"&&typeof $=="string")await Kn(T,$);else if(M==="html"&&typeof $=="string")await Wn(T,$);else if(M==="json"&&typeof $=="object")try{const W=JSON.stringify($),Z=T.parseEditorState(W);T.setEditorState(Z)}catch(W){console.error("[BeatUI] Failed to parse JSON editor state:",W),u&&u(W instanceof Error?W:new Error(String(W)),T)}}}e!=null&&x.push(w.Value.on(e,async $=>{if($!=null){if(M==="markdown"&&typeof $=="string"){const R=await wt(T);$!==R&&await Kn(T,$)}else if(M==="html"&&typeof $=="string"){const R=await vt(T);$!==R&&await Wn(T,$)}else if(M==="json"&&typeof $=="object"){const R=JSON.stringify(T.getEditorState().toJSON()),W=JSON.stringify($);if(R!==W){const Z=T.parseEditorState(W);T.setEditorState(Z)}}}})),i!=null&&x.push(w.Value.on(i,$=>{T.setEditable(!$)})),x.push(T.registerCommand(fi,()=>(h&&h(T),f&&T.getEditorState().read(async()=>{if(M==="markdown"){const $=await wt(T);f($,T)}else if(M==="html"){const $=await vt(T);f($,T)}else M==="json"&&f(T.getEditorState().toJSON(),T)}),!1),G)),x.push(y.on($=>{const R=T.getRootElement();R&&(R.dataset.theme=$)})),g&&g(T)}catch(k){console.error("[BeatUI] Failed to initialize Lexical editor:",k);const E=S;E.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{x.forEach(k=>k())}catch{}try{C?.setRootElement(null)}catch{}p.set(null)})}))))};function v_({editor:n,stateUpdate:e,groups:t=["text-formatting"],readOnly:r=w.signal(!1),size:i="sm"}){const s=w.prop(!1),o=w.prop(0),l=w.prop(0);return w.Use(nr.BeatUII18n,a=>w.Ensure(n,c=>{const u=c,d=a.$.lexical,f=v=>t.includes(v),{textFormatActive:h,linkActive:g,dispatch:p,toggleLink:m}=x_(u,e,{enterUrlMessage:()=>a.value.lexical.enterUrl}),_=S_(r,i)(w.signal(!0)),y=()=>{const v=u.value;if(!v){s.value=!1;return}const k=v.getRootElement();if(!k){s.value=!1;return}const E=window.getSelection();if(!E||E.rangeCount===0||E.isCollapsed){s.value=!1;return}const M=E.anchorNode;if(M&&!k.contains(M)){s.value=!1;return}const I=E.getRangeAt(0).getBoundingClientRect();if(I.width===0&&I.height===0){s.value=!1;return}const K=40,$=8;let R=I.top-K-$;const W=I.left+I.width/2;R<0&&(R=I.bottom+$),o.value=R,l.value=W,s.value=!0},S=e.onChange(y),C=()=>{y()};document.addEventListener("selectionchange",C);const x=w.html.div(w.attr.class("bc-floating-toolbar"),w.style.position("fixed"),w.style.top(o.map(v=>`${v}px`)),w.style.left(l.map(v=>`${v}px`)),w.style.transform("translateX(-50%)"),w.WithElement(v=>{const k=M=>{if(M.key==="Escape"&&s.value){s.value=!1;const T=u.value;T&&T.focus()}},E=M=>{if(s.value&&!v.contains(M.target)){const T=u.value;if(T){const I=T.getRootElement();if(I&&I.contains(M.target))return}s.value=!1}};return document.addEventListener("keydown",k),document.addEventListener("mousedown",E),w.OnDispose(()=>{S(),document.removeEventListener("keydown",k),document.removeEventListener("mousedown",E),document.removeEventListener("selectionchange",C)})}),...f("text-formatting")?[_({active:h("bold"),onClick:p(ve,"bold"),label:d.map(v=>v.bold),icon:"mdi:format-bold"}),_({active:h("italic"),onClick:p(ve,"italic"),label:d.map(v=>v.italic),icon:"mdi:format-italic"}),_({active:h("underline"),onClick:p(ve,"underline"),label:d.map(v=>v.underline),icon:"mdi:format-underline"}),_({active:h("strikethrough"),onClick:p(ve,"strikethrough"),label:d.map(v=>v.strikethrough),icon:"mdi:format-strikethrough"}),_({active:h("code"),onClick:p(ve,"code"),label:d.map(v=>v.code),icon:"mdi:code-tags"})]:[],...f("links")?[_({active:g(),onClick:m,label:d.map(v=>v.link),icon:"mdi:link"})]:[],...f("clipboard")?[_({active:w.signal(!1),onClick:()=>{const v=u.value;if(!v)return;const k=v.getRootElement();k&&(k.focus(),document.execCommand("cut"))},label:d.map(v=>v.cut),icon:"mdi:content-cut"}),_({active:w.signal(!1),onClick:()=>{const v=u.value;if(!v)return;const k=v.getRootElement();k&&(k.focus(),document.execCommand("copy"))},label:d.map(v=>v.copy),icon:"mdi:content-copy"}),_({active:w.signal(!1),onClick:()=>{const v=u.value;v&&navigator.clipboard.readText().then(k=>{v.update(()=>{const E=O();N(E)&&E.insertText(k)}),v.focus()}).catch(()=>{})},label:d.map(v=>v.paste),icon:"mdi:content-paste"})]:[]);return w.When(s,()=>x)}))}const _0=[{id:"heading1",label:"Heading 1",description:"Large section heading",icon:"mdi:format-header-1",keywords:["h1","heading","title"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h1"))})}},{id:"heading2",label:"Heading 2",description:"Medium section heading",icon:"mdi:format-header-2",keywords:["h2","heading"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h2"))})}},{id:"heading3",label:"Heading 3",description:"Small section heading",icon:"mdi:format-header-3",keywords:["h3","heading"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h3"))})}},{id:"bullet-list",label:"Bullet List",description:"Create a bulleted list",icon:"mdi:format-list-bulleted",keywords:["ul","unordered","bullets"],category:"Lists",handler:n=>{n.dispatchCommand(bi,void 0)}},{id:"ordered-list",label:"Ordered List",description:"Create a numbered list",icon:"mdi:format-list-numbered",keywords:["ol","numbered","1","2","3"],category:"Lists",handler:n=>{n.dispatchCommand(xi,void 0)}},{id:"quote",label:"Quote",description:"Insert a blockquote",icon:"mdi:format-quote-close",keywords:["blockquote","citation"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>yi())})}},{id:"code-block",label:"Code Block",description:"Insert a code block",icon:"mdi:code-braces",keywords:["code","pre","programming"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>St())})}},{id:"divider",label:"Divider",description:"Insert a horizontal rule",icon:"mdi:minus",keywords:["hr","horizontal","line","separator"],category:"Basic blocks",handler:n=>{n.dispatchCommand(Ms,void 0)}},{id:"table",label:"Table",description:"Insert a table",icon:"mdi:table",keywords:["table","grid","cells","rows","columns"],category:"Advanced",handler:n=>{n.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0})}}];function y0({commands:n,isVisible:e,filterText:t,position:r,onSelect:i,onDismiss:s}){const o=w.prop(0),l=t.map(f=>{const h=f.toLowerCase().trim();return h?n.filter(g=>[g.label.toLowerCase(),g.description?.toLowerCase()||"",...g.keywords?.map(m=>m.toLowerCase())||[]].join(" ").includes(h)):n});l.onChange(()=>{o.value=0});const a=f=>{const h=l.value;if(f>=0&&f<h.length){const g=h[f];i(g)}},c=f=>{if(!e.value)return;const g=l.value.length-1;switch(f.key){case"ArrowDown":f.preventDefault(),o.value=Math.min(o.value+1,g);break;case"ArrowUp":f.preventDefault(),o.value=Math.max(o.value-1,0);break;case"Enter":f.preventDefault(),a(o.value);break;case"Escape":f.preventDefault(),s();break}},u=(f,h)=>{const g=o.map(m=>m===h),p=`slash-cmd-${f.id}`;return w.html.div(w.attr.class("bc-slash-command-palette__item"),w.attr.id(p),w.attr.role("option"),w.aria.selected(g),w.WithElement(m=>{const b=()=>{o.value=h},_=()=>{a(h)};return m.addEventListener("mouseenter",b),m.addEventListener("click",_),w.OnDispose(()=>{m.removeEventListener("mouseenter",b),m.removeEventListener("click",_)})}),typeof f.icon=="string"?w.html.div(w.attr.class("bc-slash-command-palette__icon"),nr.Icon({icon:f.icon,size:"sm"})):f.icon,w.html.div(w.attr.class("bc-slash-command-palette__content"),w.html.div(w.attr.class("bc-slash-command-palette__label"),f.label),f.description?w.html.div(w.attr.class("bc-slash-command-palette__description"),f.description):void 0),f.category?w.html.div(w.attr.class("bc-slash-command-palette__category"),f.category):void 0)},d=w.Use(nr.BeatUII18n,f=>w.html.div(w.attr.class("bc-slash-command-palette"),w.attr.role("listbox"),w.aria.label(f.$.lexical.map(h=>h.slashCommands)),w.style.position("absolute"),w.style.top(r.map(h=>`${h.top}px`)),w.style.left(r.map(h=>`${h.left}px`)),w.WithElement(()=>(document.addEventListener("keydown",c),w.OnDispose(()=>{document.removeEventListener("keydown",c)}))),w.When(l.map(h=>h.length===0),()=>w.html.div(w.attr.class("bc-slash-command-palette__empty"),f.$.lexical.map(h=>h.noCommandsFound))),w.ForEach(l,(h,g)=>{const p=h.value;return u(p,g.index)})));return w.When(e,()=>d)}const E_=[{id:"paragraph",label:"Paragraph",icon:"mdi:format-paragraph",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>H())})}},{id:"heading1",label:"Heading 1",icon:"mdi:format-header-1",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h1"))})}},{id:"heading2",label:"Heading 2",icon:"mdi:format-header-2",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h2"))})}},{id:"heading3",label:"Heading 3",icon:"mdi:format-header-3",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h3"))})}},{id:"bullet-list",label:"Bullet List",icon:"mdi:format-list-bulleted",handler:n=>{n.dispatchCommand(bi,void 0)}},{id:"ordered-list",label:"Ordered List",icon:"mdi:format-list-numbered",handler:n=>{n.dispatchCommand(xi,void 0)}},{id:"quote",label:"Quote",icon:"mdi:format-quote-close",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>yi())})}},{id:"code-block",label:"Code Block",icon:"mdi:code-braces",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>St())})}},{id:"divider",label:"Divider",icon:"mdi:minus",handler:n=>{n.dispatchCommand(Ms,void 0)}},{id:"table",label:"Table",icon:"mdi:table",handler:n=>{n.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0})}}];function k_({editor:n,stateUpdate:e,readOnly:t=w.signal(!1),commands:r=E_}){const i=w.prop(!1),s=w.prop(!1),o=w.prop(0),l=w.prop(0);return w.Use(nr.BeatUII18n,a=>w.Ensure(n,c=>{const u=c;let d=null,f=!1,h=null,g=null;const p=24,m=4,b=200,_=T=>{if(T===d&&i.value)return;d=T;const I=T.getBoundingClientRect();o.value=I.top,l.value=I.left-p-m,i.value=!0},y=()=>{h!=null&&(clearTimeout(h),h=null)},S=()=>{s.value||(y(),h=setTimeout(()=>{h=null,s.value||(i.value=!1,d=null)},b))},C=()=>{const T=u.value;if(!T)return;const I=T.getRootElement();I&&(k(I),T.getEditorState().read(()=>{const K=O();if(N(K))try{const R=K.anchor.getNode().getTopLevelElementOrThrow(),W=T.getElementByKey(R.getKey());W&&_(W)}catch{}}))},x=T=>{if(s.value)return;const I=u.value;if(!I)return;const K=I.getRootElement();if(K)for(const $ of Array.from(K.children)){const R=$.getBoundingClientRect();if(T.clientY>=R.top&&T.clientY<=R.bottom){y(),_($);return}}},v=()=>{S()},k=T=>{f||(f=!0,T.addEventListener("mousemove",x),T.addEventListener("mouseleave",v))},E=e.onChange(C);return[w.OnDispose(()=>{E(),y();const T=u.value;if(T){const I=T.getRootElement();I&&f&&(I.removeEventListener("mousemove",x),I.removeEventListener("mouseleave",v))}}),w.When(i,()=>w.html.div(w.attr.class("bc-block-handle"),w.style.position("fixed"),w.style.top(o.map(T=>`${T}px`)),w.style.left(l.map(T=>`${T}px`)),w.on.mouseenter(y),w.on.mouseleave(()=>S()),w.WithElement(T=>{T.addEventListener("mousedown",I=>{I.preventDefault()})}),w.html.button(w.attr.class("bc-block-handle__button"),w.attr.type("button"),w.attr.title(a.$.lexical.map(T=>T.changeBlockType)),w.attr.disabled(t),nr.Icon({icon:"mdi:drag-horizontal-variant",size:"sm"}),w.WithElement(T=>{const I=new MutationObserver(()=>{const K=T.getAttribute("aria-expanded")==="true";s.value=K});return I.observe(T,{attributes:!0,attributeFilter:["aria-expanded"]}),w.OnDispose(()=>I.disconnect())}),qu.Menu({items:()=>r.map(T=>qu.MenuItem({key:T.id,content:T.label,startContent:nr.Icon({icon:T.icon,size:"sm"}),onClick:()=>{const I=u.value;I&&(T.handler(I),g?.(),I.focus())}})),placement:"bottom-start",showOn:(T,I)=>(g=I,w.on.click(()=>{s.value?I():(T(),s.value=!0)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const T=u.value;T&&T.focus()},ariaLabel:a.value.lexical.blockTypes}))))]}))}const b0=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="auto",floatingToolbarGroups:c,onError:u,onInput:d,onChange:f,onBlur:h,onReady:g}=n,p=w.prop(null),m=w.prop(0),b=y=>typeof y=="object"&&y!==null&&"map"in y&&typeof y.map=="function",_=i!=null?b(i)?i:w.prop(w.Value.get(i)):w.prop(!1);return w.Use(vc.Theme,({appearance:y})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-CEDSZTyZ.cjs")),({default:S})=>wc.LinkPortal({id:"beatui-lexical-css",href:S})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),v_({editor:p,stateUpdate:m,groups:c??["text-formatting","links"],readOnly:_}),k_({editor:p,stateUpdate:m,readOnly:_}),w_({editor:p,stateUpdate:m,readOnly:_}),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,S=>!S):!0),i!=null?w.attr.class(w.Value.map(i,S=>S?"bc-lexical-editor--readonly":"")):null,w.WithElement(S=>{let C=null;const x=[];return(async()=>{try{const k=r??vl("contextual"),E=wl(k),M=w.Value.get(t??"markdown"),T=gi({namespace:l,nodes:E,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:$=>{u?u($,T):console.error("[BeatUI Lexical]",$)},editable:i?!w.Value.get(i):!0});C=T,p.set(T),T.setRootElement(S);const I=[];if(k.richText?I.push(Pl(T)):k.plainText&&I.push(Bl(T)),k.history){const $=typeof k.history=="object"?k.history:void 0;I.push(zl(T,$))}if(k.clipboard&&I.push(Ul(T)),k.list&&I.push(Kl(T)),k.link&&I.push(Wl(T)),k.yjs&&I.push(Gl(T,k.yjs)),k.dragon&&I.push(Jl(T)),k.table&&I.push(Hl(T)),(await Promise.all(I)).forEach($=>{$&&x.push($)}),x.push(jl(T)),x.push(T.registerCommand(oi,()=>(m.set(m.value+1),!1),G)),x.push(T.registerUpdateListener(({editorState:$,dirtyElements:R,dirtyLeaves:W})=>{(R.size>0||W.size>0)&&m.set(m.value+1),d&&(R.size>0||W.size>0)&&$.read(async()=>{if(M==="markdown"){const Z=await wt(T);d(Z,T)}else if(M==="html"){const Z=await vt(T);d(Z,T)}else M==="json"&&d($.toJSON(),T)})})),e!=null){const $=w.Value.get(e);if($!=null&&($!==""||M==="json"&&typeof $=="object")){if(M==="markdown"&&typeof $=="string")await Kn(T,$);else if(M==="html"&&typeof $=="string")await Wn(T,$);else if(M==="json"&&typeof $=="object")try{const W=JSON.stringify($),Z=T.parseEditorState(W);T.setEditorState(Z)}catch(W){console.error("[BeatUI] Failed to parse JSON editor state:",W),u&&u(W instanceof Error?W:new Error(String(W)),T)}}}e!=null&&x.push(w.Value.on(e,async $=>{if($!=null){if(M==="markdown"&&typeof $=="string"){const R=await wt(T);$!==R&&await Kn(T,$)}else if(M==="html"&&typeof $=="string"){const R=await vt(T);$!==R&&await Wn(T,$)}else if(M==="json"&&typeof $=="object"){const R=JSON.stringify(T.getEditorState().toJSON()),W=JSON.stringify($);if(R!==W){const Z=T.parseEditorState(W);T.setEditorState(Z)}}}})),i!=null&&x.push(w.Value.on(i,$=>{T.setEditable(!$)})),x.push(T.registerCommand(fi,()=>(h&&h(T),f&&T.getEditorState().read(async()=>{if(M==="markdown"){const $=await wt(T);f($,T)}else if(M==="html"){const $=await vt(T);f($,T)}else M==="json"&&f(T.getEditorState().toJSON(),T)}),!1),G)),x.push(y.on($=>{const R=T.getRootElement();R&&(R.dataset.theme=$)})),g&&g(T)}catch(k){console.error("[BeatUI] Failed to initialize Lexical editor:",k);const E=S;E.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{x.forEach(k=>k())}catch{}try{C?.setRootElement(null)}catch{}p.set(null)})}))))},x0=n=>{const{value:e,before:t,after:r,onChange:i,onInput:s,onBlur:o,disabled:l,hasError:a,name:c,placeholder:u,id:d,required:f,tabIndex:h,size:g,class:p,namespace:m,format:b,plugins:_,readOnly:y,onError:S,onReady:C,marks:x}=n,v=l!=null&&y!=null?w.computedOf(l,y)((k,E)=>(k??!1)||(E??!1)):l??y;return U_.InputContainer({disabled:l,hasError:a,size:g,baseContainer:!0,growInput:!0,focusableSelector:"[contenteditable]",before:t,after:r,input:w.html.div(w.attr.class("bc-lexical-editor-input"),w.attr.name(c),w.attr.id(d),f!=null?w.aria.required(f):null,h!=null?w.attr.tabindex(h):null,a!=null?w.attr.class(w.Value.map(a,k=>k?"bc-lexical-editor-input--error":"")):null,b_({value:e,format:b??"markdown",plugins:_,readOnly:v,placeholder:u,namespace:m,class:p,onError:S,onReady:C,onInput:s?(k,E)=>{s(k)}:void 0,onChange:i?(k,E)=>{i(k)}:void 0,onBlur:o?k=>{o()}:void 0}))})};exports.$createHorizontalRuleNode=Ns;exports.$isHorizontalRuleNode=Vp;exports.BLUR_COMMAND=fi;exports.BareEditor=b_;exports.BlockHandle=k_;exports.CLEAR_EDITOR_COMMAND=Lc;exports.CLICK_COMMAND=br;exports.COMMAND_PRIORITY_CRITICAL=Wc;exports.COMMAND_PRIORITY_EDITOR=B;exports.COMMAND_PRIORITY_HIGH=wg;exports.COMMAND_PRIORITY_LOW=G;exports.COMMAND_PRIORITY_NORMAL=Cg;exports.COPY_COMMAND=xr;exports.CUT_COMMAND=di;exports.ContextualEditor=b0;exports.DEFAULT_BLOCK_COMMANDS=E_;exports.DEFAULT_SLASH_COMMANDS=_0;exports.DecoratorNode=Ss;exports.DockedEditor=m0;exports.ElementNode=xe;exports.FOCUS_COMMAND=Rc;exports.FORMAT_ELEMENT_COMMAND=Fc;exports.FORMAT_TEXT_COMMAND=ve;exports.FloatingToolbar=v_;exports.HR_TRANSFORMER=__;exports.HorizontalRuleNode=Ir;exports.INDENT_CONTENT_COMMAND=Ut;exports.INSERT_CHECK_LIST_COMMAND=xl;exports.INSERT_HORIZONTAL_RULE_COMMAND=Ms;exports.INSERT_IMAGE_COMMAND=Kv;exports.INSERT_ORDERED_LIST_COMMAND=xi;exports.INSERT_PARAGRAPH_COMMAND=Fn;exports.INSERT_UNORDERED_LIST_COMMAND=bi;exports.KEY_ENTER_COMMAND=Dn;exports.KEY_ESCAPE_COMMAND=ui;exports.KEY_TAB_COMMAND=xs;exports.LexicalEditorInput=x0;exports.LexicalToolbar=C_;exports.OUTDENT_CONTENT_COMMAND=sn;exports.PASTE_COMMAND=li;exports.REDO_COMMAND=ci;exports.REMOVE_LIST_COMMAND=pu;exports.SELECTION_CHANGE_COMMAND=oi;exports.SlashCommandPalette=y0;exports.TOGGLE_SLASH_COMMAND_PALETTE=Uv;exports.TextNode=Ye;exports.UNDO_COMMAND=ai;exports.applyMark=r0;exports.createCommand=z;exports.createDefaultPluginConfig=vl;exports.createHeadlessEditor=$s;exports.executeSlashCommand=zv;exports.exportEditorToFile=Wv;exports.exportToHtml=vt;exports.exportToMarkdown=wt;exports.getCharacterCount=l0;exports.getMarkdownTransformers=y_;exports.getNodesForPlugins=wl;exports.getSelectionInfo=o0;exports.getTextContent=Gu;exports.getWordCount=a0;exports.htmlToLexicalJson=f0;exports.importFileToEditor=jv;exports.importFromHtml=Wn;exports.importFromMarkdown=Kn;exports.insertTable=Jv;exports.lexicalJsonToHtml=h0;exports.lexicalJsonToMarkdown=d0;exports.loadLexicalCore=m_;exports.loadOffsetUtils=c0;exports.markdownToLexicalJson=u0;exports.registerAutoLinkPlugin=t0;exports.registerClipboardPlugin=Ul;exports.registerCodePlugin=Gv;exports.registerCodeShikiPlugin=Vv;exports.registerDragonPlugin=Jl;exports.registerHashtagPlugin=Zv;exports.registerHistoryPlugin=zl;exports.registerHorizontalRulePlugin=jl;exports.registerLinkPlugin=Wl;exports.registerListPlugin=Kl;exports.registerMarkPlugin=n0;exports.registerOverflowPlugin=s0;exports.registerPlainTextPlugin=Bl;exports.registerRichTextPlugin=Pl;exports.registerSlashCommandsPlugin=Bv;exports.registerTablePlugin=Hl;exports.registerYjsPlugin=Gl;exports.removeMark=i0;
|
|
39
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Na(r,this,i,l,o.attributes||{})}else o.retain!==void 0?Nh(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Ah(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??Ve();const i=[],s=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let f=!1;s.forEach((g,p)=>{f=!0,d[p]=g});const h={insert:l};f&&(h.attributes=d),i.push(h),l=""}}const u=()=>{for(;a!==null;){if(jr(a,e)||t!==void 0&&jr(a,t))switch(a.content.constructor){case yn:{const d=s.get("ychange");e!==void 0&&!jr(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),s.set("ychange",r?r("removed",a.id):{type:"removed"})):t!==void 0&&!jr(a,t)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),s.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),s.delete("ychange")),l+=a.content.str;break}case Jn:case ki:{c();const d={insert:a.content.getContent()[0]};if(s.size>0){const f={};d.attributes=f,s.forEach((h,g)=>{f[g]=h})}i.push(d);break}case De:jr(a,e)&&(c(),Ei(s,a.content));break}a=a.right}c()};return e||t?he(o,d=>{e&&xc(d,e),t&&xc(d,t),u()},"cleanup"):u(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Na(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!r);Na(s,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?he(r,i=>{Ah(i,Vs(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?he(i,s=>{const o=Vs(s,this,e,!1);o.right!==null&&Nh(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?he(this.doc,t=>{Ko(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?he(this.doc,r=>{Bu(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return zu(this,e)}getAttributes(){return t_(this)}_write(e){e.writeTypeRef(wv)}}class Aa{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ve()}[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===_n||t.constructor===ri)&&t._start!==null)e=t._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class ri extends Ue{constructor(){super(),this._prelimContent=[]}get firstChild(){const 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 ri}clone(){const e=new ri;return e.insert(0,this.toArray().map(t=>t instanceof Ue?t.clone():t)),e}get length(){return this.doc??Ve(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Aa(this,e)}querySelector(e){e=e.toUpperCase();const r=new Aa(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),ti(new Aa(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Fl(this,e,new _v(this,t,e))}toString(){return qm(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),ps(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?he(this.doc,r=>{Qm(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)he(this.doc,r=>{const i=e&&e instanceof Ue?e._item:e;Uo(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw Pn("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?he(this.doc,r=>{e_(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Ym(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Zm(this,e)}slice(e=0,t=this.length){return Vm(this,e,t)}forEach(e){ps(this,e)}_write(e){e.writeTypeRef(Ev)}}class _n extends ri{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new _n(this.nodeName)}clone(){const e=new _n(this.nodeName),t=this.getAttributes();return PC(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Ue?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const l in e)r.push(l);r.sort();const i=r.length;for(let l=0;l<i;l++){const a=r[l];t.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?he(this.doc,t=>{Ko(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?he(this.doc,r=>{Bu(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return zu(this,e)}hasAttribute(e){return n_(this,e)}getAttributes(e){return e?uv(this,e):t_(this)}toDOM(e=document,t={},r){const i=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&i.setAttribute(o,l)}return ps(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(vv),e.writeKey(this.nodeName)}}class _v extends $l{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class Un extends ms{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Un}clone(){const e=new Un;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const s=[];for(const o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,l)=>o.key<l.key?-1:1),t.push({nodeName:i,attrs:s})}t.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const s=t[i];r+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){const l=s.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let i=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(kv)}}class l_{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ft()}mergeWith(e){return!1}write(e,t,r){throw Ft()}integrate(e,t){throw Ft()}}const yv=0;class En extends l_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Wm(e.doc.store,this)}write(e,t){e.writeInfo(yv),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Dl{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Dl(this.content)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class Wo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Wo(this.len)}splice(e){const t=new Wo(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){zm(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}}const bv=(n,e)=>new Bn({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ll{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;const 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 Ll(bv(this.doc.guid,this.opts))}splice(e){throw Ft()}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}}class ki{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ki(this.embed)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class De{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new De(this.key,this.value)}splice(e){throw Ft()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const xv=Po("node_env")==="development";class ii{constructor(e){this.arr=e,xv&&hm(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ii(this.arr)}splice(e){const t=new ii(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}class yn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new yn(this.str)}splice(e){const t=new yn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}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}}const Sv=0,Cv=1,wv=2,vv=3,Ev=4,kv=6;class Jn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Jn(this.type._copy())}splice(e){throw Ft()}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(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.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(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const a_=(n,e,t)=>{const{client:r,clock:i}=e.id,s=new Je(_e(r,i+t),e,_e(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=_e(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s};class Je extends l_{constructor(e,t,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?lh:0}set marker(e){(this.info&Sa)>0!==e&&(this.info^=Sa)}get marker(){return(this.info&Sa)>0}get keep(){return(this.info&oh)>0}set keep(e){this.keep!==e&&(this.info^=oh)}get countable(){return(this.info&lh)>0}get deleted(){return(this.info&xa)>0}set deleted(e){this.deleted!==e&&(this.info^=xa)}markDeleted(){this.info|=xa}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=it(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=it(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===io&&this.id.client!==this.parent.client&&this.parent.clock>=it(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=wh(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=zn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===En||this.right&&this.right.constructor===En)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Je?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Je&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===io){const r=Ta(t,this.parent);r.constructor===En?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wh(e,e.doc.store,_e(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 r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),Js(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(Js(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Ta(e.doc.store,i.origin)))s.has(Ta(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Wm(e.doc.store,this),this.content.integrate(e,this),Eh(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new En(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:_e(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Js(e.origin,this.lastId)&&this.right===e&&Js(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)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.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){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),zm(e.deleteSet,this.id.client,this.id.clock,this.length),Eh(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw pn();this.content.gc(e),t?ev(e,this,new En(this.id,this.length)):this.content=new Wo(this.length)}write(e,t){const r=t>0?_e(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&lC|(r===null?0:Lo)|(i===null?0:cm)|(s===null?0:oC);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=Zw(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===io?(e.writeParentInfo(!1),e.writeLeftID(l)):pn();s!==null&&e.writeString(s)}this.content.write(e,t)}}const c_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},u_="__ $YJS$ __";c_[u_]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");c_[u_]=!0;function Be(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Tv(n,e,t){const r=n.length,i=e.length;let s=0,o=0;for(;s<r&&s<i&&n[s]===e[s]&&s<t;)s++;for(;o+s<r&&o+s<i&&n[r-o-1]===e[i-o-1];)o++;for(;o+s<r&&o+s<i&&n[s]===e[s];)s++;return{index:s,insert:e.slice(s,i-o),remove:r-s-o}}class er{_xmlElem;_key;_parent;_type;constructor(e,t,r){this._key="",this._xmlElem=e,this._parent=t,this._type=r}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return V(t)?t:null}getNode(){const e=q(this._key);return V(e)?e:null}getSharedType(){return this._xmlElem}getType(){return this._type}getKey(){return this._key}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}syncPropertiesFromLexical(e,t,r){const i=this.getPrevNode(r);Wu(e,this._xmlElem,i,t)}syncPropertiesFromYjs(e,t){const r=this.getNode();r===null&&Be(83),Ku(e,this._xmlElem,r,t)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function d_(n,e,t){const r=new er(n,e,t);return n._collabNode=r,r}class Ui{_map;_key;_parent;_type;constructor(e,t){this._key="",this._map=e,this._parent=t,this._type="linebreak"}getNode(){const e=q(this._key);return ue(e)?e:null}getKey(){return this._key}getSharedType(){return this._map}getType(){return this._type}getSize(){return 1}getOffset(){return this._parent.getChildOffset(this)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function f_(n,e){const t=new Ui(n,e);return n._collabNode=t,t}class xt{_map;_key;_parent;_text;_type;_normalized;constructor(e,t,r,i){this._key="",this._map=e,this._parent=r,this._text=t,this._type=i,this._normalized=!1}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return D(t)?t:null}getNode(){const e=q(this._key);return D(e)?e:null}getSharedType(){return this._map}getType(){return this._type}getKey(){return this._key}getSize(){return this._text.length+(this._normalized?0:1)}getOffset(){return this._parent.getChildOffset(this)}spliceText(e,t,r){const i=this._parent._xmlText,s=this.getOffset()+1+e;t!==0&&i.delete(s,t),r!==""&&i.insert(s,r)}syncPropertiesAndTextFromLexical(e,t,r){const i=this.getPrevNode(r),s=t.__text;if(Wu(e,this._map,i,t),i!==null){const o=i.__text;o!==s&&((function(l,a,c,u){const d=O();let f=u.length;if(N(d)&&d.isCollapsed()){const g=d.anchor;g.key===a&&(f=g.offset)}const h=Tv(c,u,f);l.spliceText(h.index,h.remove,h.insert)})(this,t.__key,o,s),this._text=s)}}syncPropertiesAndTextFromYjs(e,t){const r=this.getNode();r===null&&Be(84),Ku(e,this._map,r,t);const i=this._text;r.__text!==i&&r.setTextContent(i)}destroy(e){const t=e.collabNodeMap;t.get(this._key)===this&&t.delete(this._key)}}function h_(n,e,t,r){const i=new xt(n,e,t,r);return n._collabNode=i,i}class rn{_key;_children;_xmlText;_type;_parent;constructor(e,t,r){this._key="",this._children=[],this._xmlText=e,this._type=r,this._parent=t}getPrevNode(e){if(e===null)return null;const t=e.get(this._key);return A(t)?t:null}getNode(){const e=q(this._key);return A(e)?e:null}getSharedType(){return this._xmlText}getType(){return this._type}getKey(){return this._key}isEmpty(){return this._children.length===0}getSize(){return 1}getOffset(){const e=this._parent;return e===null&&Be(90),e.getChildOffset(this)}syncPropertiesFromYjs(e,t){const r=this.getNode();r===null&&Be(91),Ku(e,this._xmlText,r,t)}applyChildrenYjsDelta(e,t){const r=this._children;let i=0,s=null;for(let o=0;o<t.length;o++){const l=t[o],a=l.insert,c=l.delete;if(l.retain!=null)i+=l.retain;else if(typeof c=="number"){let u=c;for(;u>0;){const{node:d,nodeIndex:f,offset:h,length:g}=Oa(this,i,!1);if(d instanceof rn||d instanceof Ui||d instanceof er)r.splice(f,1),u-=1;else{if(!(d instanceof xt))break;{const p=Math.min(u,g),m=f!==0?r[f-1]:null,b=d.getSize();if(h===0&&g===b){r.splice(f,1);const _=Ii(d._text,h,p-1,"");_.length>0&&(m instanceof xt?m._text+=_:this._xmlText.delete(h,_.length))}else d._text=Ii(d._text,h,p,"");u-=p}}}}else{if(a==null)throw new Error("Unexpected delta format");if(typeof a=="string"){const{node:u,offset:d}=Oa(this,i,!0);u instanceof xt?u._text=Ii(u._text,d,0,a):this._xmlText.delete(d,a.length),i+=a.length}else{const u=a,{node:d,nodeIndex:f,length:h}=Oa(this,i,!1),g=p_(e,u,this);if(d instanceof xt&&h>0&&h<d._text.length){const p=d._text,m=p.length-h;d._text=Ii(p,m,h,""),r.splice(f+1,0,g),s=Ii(p,0,m,"")}else r.splice(f,0,g);s!==null&&g instanceof xt&&(g._text=s+g._text,s=null),i+=1}}}}syncChildrenFromYjs(e){const t=this.getNode();t===null&&Be(92);const r=t.__key,i=or(t,null),s=i.length,o=this._children,l=o.length,a=e.collabNodeMap,c=new Set;let u,d,f=0,h=null;l!==s&&(d=t.getWritable());for(let g=0;g<l;g++){const p=i[f],m=o[g],b=m.getNode(),_=m._key;if(b!==null&&p===_){const y=D(b);if(c.add(p),y)if(m._key=p,m instanceof rn){const S=m._xmlText;m.syncPropertiesFromYjs(e,null),m.applyChildrenYjsDelta(e,S.toDelta()),m.syncChildrenFromYjs(e)}else m instanceof xt?m.syncPropertiesAndTextFromYjs(e,null):m instanceof er?m.syncPropertiesFromYjs(e,null):m instanceof Ui||Be(93);h=b,f++}else{if(u===void 0){u=new Set;for(let C=0;C<l;C++){const x=o[C]._key;x!==""&&u.add(x)}}if(b!==null&&p!==void 0&&!u.has(p)){const C=Qn(p);jt(C),g--,f++;continue}d=t.getWritable();const y=Rv(e,m,r),S=y.__key;if(a.set(S,m),h===null){const C=d.getFirstChild();if(d.__first=S,C!==null){const x=C.getWritable();x.__prev=S,y.__next=x.__key}}else{const C=h.getWritable(),x=h.getNextSibling();if(C.__next=S,y.__prev=h.__key,x!==null){const v=x.getWritable();v.__prev=S,y.__next=v.__key}}g===l-1&&(d.__last=S),d.__size++,h=y}}for(let g=0;g<s;g++){const p=i[g];if(!c.has(p)){const m=Qn(p),b=e.collabNodeMap.get(p);b!==void 0&&b.destroy(e),jt(m)}}}syncPropertiesFromLexical(e,t,r){Wu(e,this._xmlText,this.getPrevNode(r),t)}_syncChildFromLexical(e,t,r,i,s,o){const l=this._children[t],a=Qn(r);l instanceof rn&&A(a)?(l.syncPropertiesFromLexical(e,a,i),l.syncChildrenFromLexical(e,a,i,s,o)):l instanceof xt&&D(a)?l.syncPropertiesAndTextFromLexical(e,a,i):l instanceof er&&V(a)&&l.syncPropertiesFromLexical(e,a,i)}syncChildrenFromLexical(e,t,r,i,s){const o=this.getPrevNode(r),l=o===null?[]:or(o,r),a=or(t,null),c=l.length-1,u=a.length-1,d=e.collabNodeMap;let f,h,g=0,p=0;for(;g<=c&&p<=u;){const _=l[g],y=a[p];if(_===y)this._syncChildFromLexical(e,p,y,r,i,s),g++,p++;else{f===void 0&&(f=new Set(l)),h===void 0&&(h=new Set(a));const S=h.has(_),C=f.has(y);if(S){const x=Oh(e,Qn(y),this);d.set(y,x),C?(this.splice(e,p,1,x),g++,p++):(this.splice(e,p,0,x),p++)}else this.splice(e,p,1),g++}}const m=g>c,b=p>u;if(m&&!b)for(;p<=u;++p){const _=a[p],y=Oh(e,Qn(_),this);this.append(y),d.set(_,y)}else if(b&&!m)for(let _=this._children.length-1;_>=p;_--)this.splice(e,_,1)}append(e){const t=this._xmlText,r=this._children,i=r[r.length-1],s=i!==void 0?i.getOffset()+i.getSize():0;if(e instanceof rn)t.insertEmbed(s,e._xmlText);else if(e instanceof xt){const o=e._map;o.parent===null&&t.insertEmbed(s,o),t.insert(s+1,e._text)}else e instanceof Ui?t.insertEmbed(s,e._map):e instanceof er&&t.insertEmbed(s,e._xmlElem);this._children.push(e)}splice(e,t,r,i){const s=this._children,o=s[t];if(o===void 0)return i===void 0&&Be(94),void this.append(i);const l=o.getOffset();l===-1&&Be(95);const a=this._xmlText;if(r!==0&&a.delete(l,o.getSize()),i instanceof rn)a.insertEmbed(l,i._xmlText);else if(i instanceof xt){const c=i._map;c.parent===null&&a.insertEmbed(l,c),a.insert(l+1,i._text)}else i instanceof Ui?a.insertEmbed(l,i._map):i instanceof er&&a.insertEmbed(l,i._xmlElem);if(r!==0){const c=s.slice(t,t+r);for(let u=0;u<c.length;u++)c[u].destroy(e)}i!==void 0?s.splice(t,r,i):s.splice(t,r)}getChildOffset(e){let t=0;const r=this._children;for(let i=0;i<r.length;i++){const s=r[i];if(s===e)return t;t+=s.getSize()}return-1}destroy(e){const t=e.collabNodeMap,r=this._children;for(let i=0;i<r.length;i++)r[i].destroy(e);t.get(this._key)===this&&t.delete(this._key)}}function Uu(n,e,t){const r=new rn(n,e,t);return n._collabNode=r,r}function Nv(n,e,t,r,i){t==null&&Be(81);const s={clientID:t.clientID,cursors:new Map,cursorsContainer:null,doc:t,docMap:r,editor:n,excludedProperties:i||new Map,id:e,nodeProperties:new Map};return(function(o){const{editor:l,nodeProperties:a}=o;l.update(()=>{l._nodes.forEach(c=>{const u=new c.klass,d={};for(const[f,h]of Object.entries(u))g_(f,u,o)||(d[f]=h);a.set(u.__type,Object.freeze(d))})})})(s),s}function Av(n,e,t,r,i,s){r==null&&Be(81);const o=Uu(r.get("root",Un),null,"root");return o._key="root",{...Nv(n,t,r,i,s),collabNodeMap:new Map,root:o}}function Ov(n){return Object.hasOwn(n,"collabNodeMap")}const Mv=new Set(["__key","__parent","__next","__prev","__state"]),$v=new Set(["__first","__last","__size"]),Iv=new Set(["__cachedText"]),Fv=new Set(["__text"]);function g_(n,e,t){if(Mv.has(n)||typeof e[n]=="function")return!0;if(D(e)){if(Fv.has(n))return!0}else if(A(e)&&($v.has(n)||be(e)&&Iv.has(n)))return!0;const r=e.constructor,i=t.excludedProperties.get(r);return i!=null&&i.has(n)}function Dv(n,e){const t=n.__type,{nodeProperties:r}=e,i=r.get(t);return i===void 0&&Be(330,t),i}function Oh(n,e,t){const r=e.__type;let i;if(A(e))i=Uu(new Un,t,r),i.syncPropertiesFromLexical(n,e,null),i.syncChildrenFromLexical(n,e,null,null,null);else if(D(e))i=h_(new yt,e.__text,t,r),i.syncPropertiesAndTextFromLexical(n,e,null);else if(ue(e)){const s=new yt;s.set("__type","linebreak"),i=f_(s,t)}else V(e)?(i=d_(new _n,t,r),i.syncPropertiesFromLexical(n,e,null)):Be(86);return i._key=e.__key,i}function Lv(n){const e=Rl(n,"__type");return typeof e!="string"&&e!==void 0&&Be(87),e}function p_(n,e,t){const r=e._collabNode;if(r===void 0){const i=n.editor._nodes,s=Lv(e);typeof s!="string"&&Be(87),i.get(s)===void 0&&Be(88,s);const o=e.parent,l=t===void 0&&o!==null?p_(n,o):t||null;if(l instanceof rn||Be(89),e instanceof Un)return Uu(e,l,s);if(e instanceof yt)return s==="linebreak"?f_(e,l):h_(e,"",l,s);if(e instanceof _n)return d_(e,l,s)}return r}function Rv(n,e,t){const r=e.getType(),i=n.editor._nodes.get(r);i===void 0&&Be(88,r);const s=new i.klass;if(s.__parent=t,e._key=s.__key,e instanceof rn){const o=e._xmlText;e.syncPropertiesFromYjs(n,null),e.applyChildrenYjsDelta(n,o.toDelta()),e.syncChildrenFromYjs(n)}else e instanceof xt?e.syncPropertiesAndTextFromYjs(n,null):e instanceof er&&e.syncPropertiesFromYjs(n,null);return n.collabNodeMap.set(s.__key,e),s}function Ku(n,e,t,r){const i=r===null?e instanceof yt?Array.from(e.keys()):e instanceof Un||e instanceof _n?Object.keys(e.getAttributes()):Object.keys(e):Array.from(r);let s;for(let o=0;o<i.length;o++){const l=i[o];if(g_(l,t,n)){l==="__state"&&Ov(n)&&(s||(s=t.getWritable()),Pv(e,s));continue}const a=t[l];let c=Rl(e,l);if(a!==c){if(c instanceof Bn){const u=n.docMap;a instanceof Bn&&u.delete(a.guid);const d=gi(),f=c.guid;d._key=f,u.set(f,c),c=d}s===void 0&&(s=t.getWritable()),s[l]=c}}}function Rl(n,e){return n instanceof yt?n.get(e):n instanceof Un||n instanceof _n?n.getAttribute(e):n[e]}function Mh(n,e,t){n instanceof yt?n.set(e,t):n.setAttribute(e,t)}function Pv(n,e){const t=Rl(n,"__state");t instanceof yt&&Jo(e).updateFromJSON(t.toJSON())}function Wu(n,e,t,r){const i=Object.keys(Dv(r,n)),s=n.editor.constructor;(function(o,l,a,c){const u=c.__state,d=Rl(l,"__state");if(!u)return;const[f,h]=u.getInternalState(),g=a&&a.__state,p=d instanceof yt?d:new yt;if(g===u)return;const[m,b]=g&&p.doc?g.getInternalState():[void 0,new Map];if(f)for(const[_,y]of Object.entries(f))m&&y!==m[_]&&p.set(_,y);for(const[_,y]of h)b.get(_)!==y&&p.set(_.key,_.unparse(y));d||Mh(l,"__state",p)})(0,e,t,r);for(let o=0;o<i.length;o++){const l=i[o],a=t===null?void 0:t[l];let c=r[l];if(a!==c){if(c instanceof s){const u=n.docMap;let d;if(a instanceof s){const g=a._key;d=u.get(g),u.delete(g)}const f=d||new Bn,h=f.guid;c._key=h,u.set(h,f),c=f,n.editor.update(()=>{r.markDirty()})}Mh(e,l,c)}}}function Ii(n,e,t,r){return n.slice(0,e)+r+n.slice(e+t)}function Oa(n,e,t){let r=0,i=0;const s=n._children,o=s.length;for(;i<o;i++){const l=s[i],a=r;if(r+=l.getSize(),(t?r>=e:r>e)&&l instanceof xt){let c=e-a-1;return c<0&&(c=0),{length:r-e,node:l,nodeIndex:i,offset:c}}if(r>e)return{length:0,node:l,nodeIndex:i,offset:a};if(i===o-1)return{length:0,node:null,nodeIndex:i+1,offset:a+1}}return{length:0,node:null,nodeIndex:0,offset:0}}Tc("ychange",{isEqual:(n,e)=>n===e,parse:n=>n??null});async function m_(){return hb}async function Pl(n){return ox(n)}async function Bl(n){return mS(n)}async function zl(n,e){const t=qp(),r=e?.delay??300;return Yp(n,t,r)}async function Ul(n){return()=>{}}async function Kl(n){return typeof da=="function"?typeof hf=="function"?pt(da(n),hf(n)):da(n):pt(n.registerCommand(xi,()=>(fa(n,"number"),!0),G),n.registerCommand(bi,()=>(fa(n,"bullet"),!0),G),n.registerCommand(xl,()=>(fa(n,"check"),!0),G),n.registerCommand(pu,()=>(px(n),!0),G))}async function Wl(n){return n.registerCommand(lc,e=>(e===null||typeof e=="string"?ha(e):ha(e.url,e),!0),G)}async function Bv(n,e,t){const r=e?.trigger||"/";let i=!1,s=null,o=0;const l=()=>n.getEditorState().read(()=>{const p=O();if(!N(p)||!p.isCollapsed())return!1;const m=p.anchor,b=m.getNode();if(!D(b))return!1;const _=b.getTextContent(),y=m.offset;if(y===0||_[y-1]!==r)return!1;if(y===1)return!0;const C=_[y-2];return!!/\s/.test(C)}),a=()=>s?n.getEditorState().read(()=>{if(!s)return"";const p=s.getTextContent(),m=p.indexOf(r,o);if(m===-1)return"";const b=O();if(!N(b))return"";const _=b.anchor;if(_.getNode().getKey()!==s.getKey())return"";const S=_.offset;return S<=m?"":p.slice(m+1,S)}):"",c=()=>{n.getEditorState().read(()=>{const p=O();if(N(p)){const m=p.anchor,b=m.getNode();if(D(b)){s=b,o=m.offset-1,i=!0;const _={isActive:!0,filterText:"",anchorNode:s,anchorOffset:o};t?.onTrigger?.(_,d),t?.onUpdate?.(_,d)}}})},u=()=>{i&&(i=!1,s=null,o=0,t?.onDismiss?.())},d=()=>{s&&n.update(()=>{if(!s)return;const p=s.getTextContent(),m=p.indexOf(r,o);if(m===-1)return;const b=O();if(!N(b))return;const _=b.anchor;if(_.getNode().getKey()!==s.getKey())return;const S=_.offset,C=p.slice(0,m),x=p.slice(S);s.setTextContent(C+x);const v=O();N(v)&&(v.anchor.set(s.getKey(),m,"text"),v.focus.set(s.getKey(),m,"text"))})},f=()=>{if(!i)return;const m={isActive:!0,filterText:a(),anchorNode:s,anchorOffset:o};t?.onUpdate?.(m,d)},h=n.registerMutationListener(Ye,p=>{if(!i&&l()){c();return}i&&(s&&!p.has(s.getKey())?f():u())}),g=pt(n.registerUpdateListener(({editorState:p})=>{p.read(()=>{if(!i)return;const m=O();if(!N(m)){u();return}const b=m.anchor,_=b.getNode();if(!s||_.getKey()!==s.getKey()){u();return}const S=s.getTextContent().indexOf(r,o);if(S===-1||b.offset<=S){u();return}})}),n.registerCommand(dr,p=>i?(p.preventDefault(),!0):!1,G),n.registerCommand(dn,p=>i?(p.preventDefault(),!0):!1,G),n.registerCommand(Dn,p=>i?(p?.preventDefault(),!0):!1,G),n.registerCommand(ui,p=>i?(p?.preventDefault(),u(),!0):!1,G));return()=>{u(),h(),g()}}function zv(n,e,t){t(),e.handler(n),n.focus()}const Uv=z("TOGGLE_SLASH_COMMAND_PALETTE"),Ms=z("INSERT_HORIZONTAL_RULE_COMMAND"),Kv=z("INSERT_IMAGE_COMMAND");function jl(n){return n.registerCommand(Ms,()=>{const e=O();if(!N(e))return!1;if(e.focus.getNode()!==null){const r=Ns();e.insertNodes([r]);const i=H();r.insertAfter(i),i.selectStart()}return!0},G)}const __={dependencies:[Ir],export:n=>Vp(n)?"---":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const i=Ns();if(r)n.replace(i);else{n.replace(i);const s=H();i.insertAfter(s),s.selectStart()}},type:"element"},ju=[...wu,__];async function wt(n){let e="";return n.getEditorState().read(()=>{e=qS(ju)}),e}async function Kn(n,e){n.update(()=>{YS(e,ju)})}async function y_(){return ju}const Hu=Object.freeze(Object.defineProperty({__proto__:null,exportToMarkdown:wt,getMarkdownTransformers:y_,importFromMarkdown:Kn},Symbol.toStringTag,{value:"Module"}));async function vt(n){let e="";return n.getEditorState().read(()=>{e=fp(n)}),e}async function Wn(n,e){n.update(()=>{const r=new DOMParser().parseFromString(e,"text/html"),i=dp(n,r);fe().clear(),nl(i)})}const Ju=Object.freeze(Object.defineProperty({__proto__:null,exportToHtml:vt,importFromHtml:Wn},Symbol.toStringTag,{value:"Module"}));async function Wv(n,e,t){let r,i,s;switch(e){case"markdown":r=await wt(n),i="text/markdown",s="md";break;case"html":r=await vt(n),i="text/html",s="html";break;case"json":r=JSON.stringify(n.getEditorState().toJSON(),null,2),i="application/json",s="json";break}const o=new Blob([r],{type:i}),l=URL.createObjectURL(o),a=document.createElement("a");a.href=l,a.download=t??`document.${s}`,a.click(),URL.revokeObjectURL(l)}async function jv(n,e,t){const r=await new Promise((s,o)=>{const l=new FileReader;l.onload=()=>s(l.result),l.onerror=()=>o(l.error),l.readAsText(e)});switch(t??Hv(e.name)){case"markdown":{const{importFromMarkdown:s}=await Promise.resolve().then(()=>Hu);await s(n,r);break}case"html":{const{importFromHtml:s}=await Promise.resolve().then(()=>Ju);await s(n,r);break}case"json":{const s=n.parseEditorState(r);n.setEditorState(s);break}}}function Hv(n){return n.endsWith(".md")||n.endsWith(".markdown")?"markdown":n.endsWith(".html")||n.endsWith(".htm")?"html":"json"}async function Hl(n,e){return typeof vf=="function"?vf(n):()=>{}}async function Jv(n,e=3,t=3){n.dispatchCommand(Ts,{rows:String(e),columns:String(t),includeHeaders:!0})}async function Gv(n,e){return typeof Fo=="function"?Fo(n):()=>{}}async function Vv(n,e){return typeof Fo=="function"?Fo(n):()=>{}}const Yv=/#[\w\u0590-\u05ff]+/;function qv(n){return new Cl(n)}async function Zv(n,e){const t=[],r=rS(n,i=>{const s=Yv.exec(i);return s?{start:s.index,end:s.index+s[0].length}:null},Cl,qv);if(Array.isArray(r)?t.push(...r):typeof r=="function"&&t.push(r),e?.onHashtagClick){const i=n.registerCommand(br,s=>{const o=s.target;if(o.classList.contains("bc-lexical-hashtag")){const l=o.textContent;if(l)return e.onHashtagClick(l.replace("#","")),!0}return!1},G);t.push(i)}return()=>{t.forEach(i=>i())}}const Xv=/((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g,Qv=/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g,e0=[{pattern:Xv,urlTransformer:n=>n.startsWith("http")?n:`https://${n}`},{pattern:Qv,urlTransformer:n=>`mailto:${n}`}];async function t0(n,e){const t=e?.matchers??e0;return n.registerMutationListener(Ye,r=>{n.update(()=>{for(const[i,s]of r){if(s!=="created"&&s!=="updated")continue;const o=q(i);if(!o||!D(o))continue;const l=o.getTextContent();for(const a of t){const c=new RegExp(a.pattern.source,a.pattern.flags);let u;for(;(u=c.exec(l))!==null;)a.urlTransformer(u[0])}}})})}async function n0(n,e){const t=[];return e?.onMarkClick&&t.push(n.registerCommand(br,r=>{const i=r.target;if(i.classList.contains("bc-lexical-mark")){const s=i.dataset.markId;if(s)return e.onMarkClick(s,{id:s,type:i.dataset.markType||"annotation",data:{}}),!0}return!1},G)),()=>t.forEach(r=>r())}async function r0(n,e,t){n.update(()=>{const r=O();N(r)&&oS(r,r.isBackward(),e)})}async function i0(n,e){n.update(()=>{const r=fe().getAllTextNodes().filter(i=>{const s=i.getParent();return as(s)?lS(i,0)?.includes(e)??!1:!1});for(const i of r){const s=i.getParent();as(s)&&sS(s)}})}async function s0(n,e){const{maxLength:t,onOverflow:r}=e;return n.registerUpdateListener(({editorState:i})=>{i.read(()=>{const l=fe().getTextContent().length,a=l>t;r&&r(a,l)})})}async function Jl(n){return typeof ef=="function"?ef(n):()=>{}}async function Gl(n,e){const t=e.docMap??new Map,r=e.id??"lexical",i=e.doc.getText(r),s=Av(n,e.provider,i,e.doc,t),o=n.registerUpdateListener(()=>{});return()=>{o(),s&&typeof s.destroy=="function"&&s.destroy()}}function o0(n){let e={hasSelection:!1,selectedText:"",anchorOffset:0,focusOffset:0};return n.getEditorState().read(()=>{const t=O();N(t)&&(e={hasSelection:!t.isCollapsed(),selectedText:t.getTextContent(),anchorOffset:t.anchor.offset,focusOffset:t.focus.offset})}),e}function Gu(n){let e="";return n.getEditorState().read(()=>{e=fe().getTextContent()}),e}function l0(n){return Gu(n).length}function a0(n){const e=Gu(n).trim();return e?e.split(/\s+/).length:0}async function c0(){return eC}async function $s(n={}){const{nodes:e=[],plugins:t=[],onError:r}=n,s=(await m_()).createEditor({namespace:"BeatUIHeadless",nodes:e,onError:o=>{r?r(o,s):console.error("[BeatUI Headless]",o)},editable:!1});if(t.length>0)for(const o of t)o.register(s);return s}async function u0(n){const e=await $s(),{importFromMarkdown:t}=await Promise.resolve().then(()=>Hu);return await t(e,n),e.getEditorState().toJSON()}async function d0(n){const e=await $s(),{exportToMarkdown:t}=await Promise.resolve().then(()=>Hu),r=e.parseEditorState(JSON.stringify(n));return e.setEditorState(r),await t(e)}async function f0(n){const e=await $s(),{importFromHtml:t}=await Promise.resolve().then(()=>Ju);return await t(e,n),e.getEditorState().toJSON()}async function h0(n){const e=await $s(),{exportToHtml:t}=await Promise.resolve().then(()=>Ju),r=e.parseEditorState(JSON.stringify(n));return e.setEditorState(r),await t(e)}const b_=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="auto",onError:c,onInput:u,onChange:d,onBlur:f,onReady:h}=n;return w.Use(vc.Theme,({appearance:g})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-mlDYoWbF.cjs")),({default:p})=>wc.LinkPortal({id:"beatui-lexical-css",href:p})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,p=>!p):!0),i!=null?w.attr.class(w.Value.map(i,p=>p?"bc-lexical-editor--readonly":"")):null,w.WithElement(p=>{let m=null;const b=[];return(async()=>{try{const y=r??vl("bare"),S=wl(y),C=w.Value.get(t??"markdown"),x=gi({namespace:l,nodes:S,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:E=>{c?c(E,x):console.error("[BeatUI Lexical]",E)},editable:i?!w.Value.get(i):!0});m=x,x.setRootElement(p);const v=[];if(y.richText?v.push(Pl(x)):y.plainText&&v.push(Bl(x)),y.history){const E=typeof y.history=="object"?y.history:void 0;v.push(zl(x,E))}if(y.clipboard&&v.push(Ul(x)),y.list&&v.push(Kl(x)),y.link&&v.push(Wl(x)),y.yjs&&v.push(Gl(x,y.yjs)),y.dragon&&v.push(Jl(x)),y.table&&v.push(Hl(x)),(await Promise.all(v)).forEach(E=>{E&&b.push(E)}),b.push(jl(x)),e!=null){const E=w.Value.get(e);if(E!=null&&(E!==""||C==="json"&&typeof E=="object")){if(C==="markdown"&&typeof E=="string")await Kn(x,E);else if(C==="html"&&typeof E=="string")await Wn(x,E);else if(C==="json"&&typeof E=="object")try{const T=JSON.stringify(E),I=x.parseEditorState(T);x.setEditorState(I)}catch(T){console.error("[BeatUI] Failed to parse JSON editor state:",T),c&&c(T instanceof Error?T:new Error(String(T)),x)}}}b.push(x.registerUpdateListener(({editorState:E,dirtyElements:M,dirtyLeaves:T})=>{M.size===0&&T.size===0||u&&E.read(async()=>{if(C==="markdown"){const I=await wt(x);u(I,x)}else if(C==="html"){const I=await vt(x);u(I,x)}else C==="json"&&u(E.toJSON(),x)})})),e!=null&&b.push(w.Value.on(e,async E=>{if(E!=null){if(C==="markdown"&&typeof E=="string"){const M=await wt(x);E!==M&&await Kn(x,E)}else if(C==="html"&&typeof E=="string"){const M=await vt(x);E!==M&&await Wn(x,E)}else if(C==="json"&&typeof E=="object"){const M=JSON.stringify(x.getEditorState().toJSON()),T=JSON.stringify(E);if(M!==T){const I=x.parseEditorState(T);x.setEditorState(I)}}}})),i!=null&&b.push(w.Value.on(i,E=>{x.setEditable(!E)})),b.push(x.registerCommand(fi,()=>(f&&f(x),d&&x.getEditorState().read(async()=>{if(C==="markdown"){const E=await wt(x);d(E,x)}else if(C==="html"){const E=await vt(x);d(E,x)}else C==="json"&&d(x.getEditorState().toJSON(),x)}),!1),G)),b.push(g.on(E=>{const M=x.getRootElement();M&&(M.dataset.theme=E)})),h&&h(x)}catch(y){console.error("[BeatUI] Failed to initialize Lexical editor:",y);const S=p;S.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{b.forEach(y=>y())}catch{}try{m?.setRootElement(null)}catch{}})}))))};function x_(n,e,t){const r=(h,g)=>e.map(()=>{const p=n.value;return p?p.getEditorState().read(()=>{const m=O();return N(m)?h(m):g}):g}),i=h=>{const g=h.anchor.getNode();return g.getKey()==="root"?g:g.getTopLevelElementOrThrow()};return{withSelection:r,getAnchorElement:i,textFormatActive:h=>r(g=>g.hasFormat(h),!1),blockTypeActive:h=>r(g=>i(g).getType()===h,!1),listTypeActive:h=>r(g=>{const p=i(g).getParent();return J(p)&&p.getListType()===h},!1),headingActive:h=>e.map(()=>{const g=n.value;return g?g.getEditorState().read(()=>{const p=O();if(N(p)){const m=i(p);if(m.getType()==="heading")return g.getElementByKey(m.getKey())?.tagName===`H${h}`}return!1}):!1}),linkActive:()=>r(h=>{const g=h.anchor.getNode();return g.getParent()?.getType()==="link"||g.getType()==="link"},!1),dispatch:(h,g)=>()=>{const p=n.value;p&&(p.dispatchCommand(h,g),p.focus())},toggleBlock:(h,g)=>()=>{const p=n.value;p&&(p.update(()=>{const m=O();if(N(m)){const b=i(m);et(m,()=>b.getType()===h?H():g())}}),p.focus())},toggleLink:()=>{const h=n.value;h&&(h.getEditorState().read(()=>{const g=O();if(N(g)){const p=g.anchor.getNode();if(p.getParent()?.getType()==="link"||p.getType()==="link")h.dispatchCommand(lc,null);else{const _=prompt(t?.enterUrlMessage?.()??"Enter URL:");_&&h.dispatchCommand(lc,_)}}}),h.focus())}}}function S_(n,e){return t=>r=>ct.EditorToolbarButton({...r,display:t,disabled:n,size:e})}const g0=[{value:"Arial",label:"Arial"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Trebuchet MS",label:"Trebuchet MS"},{value:"Verdana",label:"Verdana"}],p0=[{value:"10px",label:"10"},{value:"12px",label:"12"},{value:"14px",label:"14"},{value:"16px",label:"16"},{value:"18px",label:"18"},{value:"20px",label:"20"},{value:"24px",label:"24"},{value:"30px",label:"30"},{value:"36px",label:"36"}];function C_({editor:n,stateUpdate:e,toolbar:t={},readOnly:r=w.signal(!1),size:i="sm"}){const{visibleGroups:s,hiddenGroups:o,maxHeadingLevel:l=3}=t,a=c=>!(o?.includes(c)||s&&!s.includes(c));return w.Use(nr.BeatUII18n,c=>w.Ensure(n,u=>{const d=u,f=c.$.lexical,h=w.signal(a("text-formatting")),g=w.signal(a("headings")),p=w.signal(a("lists")),m=w.signal(a("blocks")),b=w.signal(a("links")),_=w.signal(a("indent")),y=w.signal(a("tables")),S=w.signal(a("history")),C=w.signal(a("clipboard")),x=w.signal(a("font")),v=w.signal(a("color")),k=w.signal(a("clear-formatting")),{getAnchorElement:E,textFormatActive:M,blockTypeActive:T,listTypeActive:I,headingActive:K,linkActive:$,dispatch:R,toggleBlock:W,toggleLink:Z}=x_(d,e,{enterUrlMessage:()=>c.value.lexical.enterUrl}),Y=S_(r,i),se=()=>{const F=d.value;F&&(F.update(()=>{const U=O();N(U)&&et(U,()=>H())}),F.focus())},Ke=F=>{const U=d.value;U&&(U.update(()=>{const X=O();if(N(X)){const Gn=E(X),Is=`h${F}`,B_=U.getElementByKey(Gn.getKey());Gn.getType()==="heading"&&B_?.tagName===`H${F}`?et(X,()=>H()):et(X,()=>ft(Is))}}),U.focus())},qe=Y(h),j=Y(g),pe=Y(p),oe=Y(m),Ze=Y(b),Se=Y(_),We=Y(y),Xe=Y(k),bt=Y(S),Ce=Y(C),wn=()=>{const F=d.value;if(!F)return;const U=F.getRootElement();U&&(U.focus(),document.execCommand("copy"))},Ti=()=>{const F=d.value;if(!F)return;const U=F.getRootElement();U&&(U.focus(),document.execCommand("cut"))},Zt=()=>{const F=d.value;F&&navigator.clipboard.readText().then(U=>{F.update(()=>{const X=O();N(X)&&X.insertText(U)}),F.focus()}).catch(()=>{})},Ni=()=>{const F=d.value;F&&(F.update(()=>{const U=O();if(N(U))for(const X of U.getNodes())D(X)&&(X.setFormat(0),X.setStyle(""))}),F.focus())},Vl=()=>{const F=d.value;F&&(F.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0}),F.focus())},Vu={value:"",label:c.value.lexical.defaultOption},T_=[Vu,...t.fontFamilies??g0],N_=[Vu,...t.fontSizes??p0],A_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)?zs(U,"font-family",""):""}):""}),O_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)?zs(U,"font-size",""):""}):""}),M_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"font-family":F||null})}),U.focus())},$_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"font-size":F||null})}),U.focus())},I_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)&&zs(U,"color","")||"#000000"}):"#000000"}),F_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();return N(U)&&zs(U,"background-color","")||"#ffffff"}):"#ffffff"}),D_=e.map(()=>{const F=d.value;return F?F.getEditorState().read(()=>{const U=O();if(N(U)){const X=E(U);return F.getElementByKey(X.getKey())?.style.backgroundColor||"#ffffff"}return"#ffffff"}):"#ffffff"}),L_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{color:F})}),U.focus())},R_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();N(X)&&Bs(X,{"background-color":F})}),U.focus())},P_=F=>{const U=d.value;U&&(U.update(()=>{const X=O();if(N(X)){const Gn=E(X),Is=U.getElementByKey(Gn.getKey());Is&&(Is.style.backgroundColor=F)}}),U.focus())};return z_.Toolbar(w.attr.class("bc-lexical-toolbar"),w.When(x,()=>ct.EditorToolbarGroup({display:[x]},w.html.select(w.attr.class("bc-lexical-toolbar-select"),w.attr.title(f.map(F=>F.fontFamily)),w.attr.disabled(r),w.on.change(F=>M_(F.target.value)),...T_.map(F=>w.html.option(w.attr.value(F.value),w.attr.selected(A_.map(U=>U===F.value)),F.label))),w.html.select(w.attr.class("bc-lexical-toolbar-select"),w.attr.title(f.map(F=>F.fontSize)),w.attr.disabled(r),w.on.change(F=>$_(F.target.value)),...N_.map(F=>w.html.option(w.attr.value(F.value),w.attr.selected(O_.map(U=>U===F.value)),F.label))))),w.When(v,()=>ct.EditorToolbarGroup({display:[v]},w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.fontColor)),w.html.input(w.attr.type("color"),w.attr.value(I_),w.attr.disabled(r),w.on.input(F=>L_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon"),"A")),w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.highlightColor)),w.html.input(w.attr.type("color"),w.attr.value(F_),w.attr.disabled(r),w.on.input(F=>R_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"),"A")),w.html.label(w.attr.class("bc-lexical-toolbar-color"),w.attr.title(f.map(F=>F.backgroundColor)),w.html.input(w.attr.type("color"),w.attr.value(D_),w.attr.disabled(r),w.on.input(F=>P_(F.target.value))),w.html.span(w.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"),"■")))),ct.EditorToolbarGroup({display:Array(5).fill(h)},qe({active:M("bold"),onClick:R(ve,"bold"),label:f.map(F=>F.bold),icon:"mdi:format-bold"}),qe({active:M("italic"),onClick:R(ve,"italic"),label:f.map(F=>F.italic),icon:"mdi:format-italic"}),qe({active:M("underline"),onClick:R(ve,"underline"),label:f.map(F=>F.underline),icon:"mdi:format-underline"}),qe({active:M("strikethrough"),onClick:R(ve,"strikethrough"),label:f.map(F=>F.strikethrough),icon:"mdi:format-strikethrough"}),qe({active:M("code"),onClick:R(ve,"code"),label:f.map(F=>F.code),icon:"mdi:code-tags"})),ct.EditorToolbarGroup({display:[k]},Xe({active:w.signal(!1),onClick:Ni,label:f.map(F=>F.clearFormatting),icon:"mdi:format-clear"})),ct.EditorToolbarGroup({display:[g,...Array(l).fill(g)]},j({active:T("paragraph"),onClick:se,label:f.map(F=>F.normal),icon:"mdi:format-paragraph"}),...Array.from({length:l},(F,U)=>{const X=U+1;return j({active:K(X),onClick:()=>Ke(X),label:f.map(Gn=>Gn.heading(X)),icon:`mdi:format-header-${X}`})})),ct.EditorToolbarGroup({display:Array(3).fill(p)},pe({active:I("bullet"),onClick:R(bi,void 0),label:f.map(F=>F.bulletList),icon:"mdi:format-list-bulleted"}),pe({active:I("number"),onClick:R(xi,void 0),label:f.map(F=>F.orderedList),icon:"mdi:format-list-numbered"}),pe({active:I("check"),onClick:R(xl,void 0),label:f.map(F=>F.checkList),icon:"mdi:format-list-checks"})),ct.EditorToolbarGroup({display:Array(2).fill(_)},Se({active:w.signal(!1),onClick:R(Ut,void 0),label:f.map(F=>F.indent),icon:"mdi:format-indent-increase"}),Se({active:w.signal(!1),onClick:R(sn,void 0),label:f.map(F=>F.outdent),icon:"mdi:format-indent-decrease"})),ct.EditorToolbarGroup({display:Array(3).fill(m)},oe({active:T("quote"),onClick:W("quote",yi),label:f.map(F=>F.blockquote),icon:"mdi:format-quote-close"}),oe({active:T("code"),onClick:W("code",St),label:f.map(F=>F.codeBlock),icon:"mdi:code-braces"}),oe({active:w.signal(!1),onClick:R(Ms,void 0),label:f.map(F=>F.horizontalRule),icon:"mdi:minus"})),ct.EditorToolbarGroup({display:[y]},We({active:w.signal(!1),onClick:Vl,label:f.map(F=>F.insertTable),icon:"mdi:table-plus"})),ct.EditorToolbarGroup({display:[b]},Ze({active:$(),onClick:Z,label:f.map(F=>F.link),icon:"mdi:link"})),ct.EditorToolbarGroup({display:Array(2).fill(S)},bt({active:w.signal(!1),onClick:R(ai,void 0),label:f.map(F=>F.undo),icon:"mdi:undo"}),bt({active:w.signal(!1),onClick:R(ci,void 0),label:f.map(F=>F.redo),icon:"mdi:redo"})),ct.EditorToolbarGroup({display:Array(3).fill(C)},Ce({active:w.signal(!1),onClick:Ti,label:f.map(F=>F.cut),icon:"mdi:content-cut"}),Ce({active:w.signal(!1),onClick:wn,label:f.map(F=>F.copy),icon:"mdi:content-copy"}),Ce({active:w.signal(!1),onClick:Zt,label:f.map(F=>F.paste),icon:"mdi:content-paste"})))}))}function w_({editor:n,stateUpdate:e,readOnly:t=w.signal(!1)}){const r=w.prop(!1),i=w.prop(0),s=w.prop(0),o=()=>{const p=n.value;if(!p){r.value=!1;return}p.getEditorState().read(()=>{const m=O();if(!N(m)){r.value=!1;return}let _=m.anchor.getNode(),y=null;for(;_;){if(ge(_)){y=_;break}if(_=_.getParent(),!_||_.getKey()==="root")break}if(!y){r.value=!1;return}const S=p.getElementByKey(y.getKey()),C=p.getRootElement();if(S&&C){const x=S.getBoundingClientRect(),v=C.closest(".bc-lexical-editor-container"),k=v?v.getBoundingClientRect():C.getBoundingClientRect();i.value=x.bottom-k.top+4,s.value=x.left-k.left}r.value=!0})};e.onChange(o);const l=()=>{const p=n.value;p&&(p.update(()=>{yf(!1)}),p.focus())},a=()=>{const p=n.value;p&&(p.update(()=>{yf(!0)}),p.focus())},c=()=>{const p=n.value;p&&(p.update(()=>{bf(!1)}),p.focus())},u=()=>{const p=n.value;p&&(p.update(()=>{bf(!0)}),p.focus())},d=()=>{const p=n.value;p&&(p.update(()=>{xx()}),p.focus())},f=()=>{const p=n.value;p&&(p.update(()=>{Sx()}),p.focus())},h=()=>{const p=n.value;p&&(p.update(()=>{const m=O();if(!N(m))return;const b=m.anchor.getNode(),_=bx(b);if(!_)return;Fp(_).remove()}),p.focus())},g=w.html.div(w.attr.class("bc-table-context-menu"),w.attr.role("menu"),w.style.position("absolute"),w.style.top(i.map(p=>`${p}px`)),w.style.left(s.map(p=>`${p}px`)),w.style.zIndex("1000"),w.style.backgroundColor("var(--color-surface)"),w.style.border("1px solid var(--color-border)"),w.style.borderRadius("var(--radius-md)"),w.style.boxShadow("0 2px 8px rgba(0, 0, 0, 0.15)"),w.style.padding("var(--spacing-xs)"),w.style.minWidth("180px"),w.WithElement(p=>{const m=_=>{if(_.key==="Escape"&&r.value){r.value=!1;const y=n.value;y&&y.focus()}},b=_=>{if(r.value&&!p.contains(_.target)){const y=n.value;if(y){const S=y.getRootElement();if(S&&S.contains(_.target))return}r.value=!1}};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b),w.OnDispose(()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b)})}),Yn("Insert row above",l,t),Yn("Insert row below",a,t),Yn("Insert column left",c,t),Yn("Insert column right",u,t),w.html.div(w.attr.class("bc-table-menu-separator"),w.style.height("1px"),w.style.backgroundColor("var(--color-border)"),w.style.margin("var(--spacing-xs) 0")),Yn("Delete row",d,t,"danger"),Yn("Delete column",f,t,"danger"),Yn("Delete table",h,t,"danger"));return w.When(r,()=>g)}function Yn(n,e,t,r="default"){return w.html.button(w.attr.class("bc-table-menu-button"),w.attr.type("button"),w.attr.role("menuitem"),w.attr.disabled(t),w.on.click(e),w.style.display("block"),w.style.width("100%"),w.style.padding("var(--spacing-xs) var(--spacing-sm)"),w.style.border("none"),w.style.backgroundColor("transparent"),w.style.color(r==="danger"?"var(--color-danger-600)":"var(--color-neutral-900)"),w.style.textAlign("left"),w.style.cursor("pointer"),w.style.borderRadius("var(--radius-sm)"),w.style.fontSize("0.875rem"),w.style.transition("background-color 0.15s"),w.html.span(n))}const m0=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="fixed",toolbar:c,onError:u,onInput:d,onChange:f,onBlur:h,onReady:g}=n,p=w.prop(null),m=w.prop(0),b=y=>typeof y=="object"&&y!==null&&"map"in y&&typeof y.map=="function",_=i!=null?b(i)?i:w.prop(w.Value.get(i)):w.prop(!1);return w.Use(vc.Theme,({appearance:y})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-mlDYoWbF.cjs")),({default:S})=>wc.LinkPortal({id:"beatui-lexical-css",href:S})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),w.When(_.map(S=>!S),()=>C_({editor:p,stateUpdate:m,toolbar:c,readOnly:_,size:"sm"})),w_({editor:p,stateUpdate:m,readOnly:_}),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,S=>!S):!0),i!=null?w.attr.class(w.Value.map(i,S=>S?"bc-lexical-editor--readonly":"")):null,w.WithElement(S=>{let C=null;const x=[];return(async()=>{try{const k=r??vl("docked"),E=wl(k),M=w.Value.get(t??"markdown"),T=gi({namespace:l,nodes:E,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:$=>{u?u($,T):console.error("[BeatUI Lexical]",$)},editable:i?!w.Value.get(i):!0});C=T,p.set(T),T.setRootElement(S);const I=[];if(k.richText?I.push(Pl(T)):k.plainText&&I.push(Bl(T)),k.history){const $=typeof k.history=="object"?k.history:void 0;I.push(zl(T,$))}if(k.clipboard&&I.push(Ul(T)),k.list&&I.push(Kl(T)),k.link&&I.push(Wl(T)),k.yjs&&I.push(Gl(T,k.yjs)),k.dragon&&I.push(Jl(T)),k.table&&I.push(Hl(T)),(await Promise.all(I)).forEach($=>{$&&x.push($)}),x.push(jl(T)),x.push(T.registerCommand(oi,()=>(m.set(m.value+1),!1),G)),x.push(T.registerUpdateListener(({editorState:$,dirtyElements:R,dirtyLeaves:W})=>{(R.size>0||W.size>0)&&m.set(m.value+1),d&&(R.size>0||W.size>0)&&$.read(async()=>{if(M==="markdown"){const Z=await wt(T);d(Z,T)}else if(M==="html"){const Z=await vt(T);d(Z,T)}else M==="json"&&d($.toJSON(),T)})})),e!=null){const $=w.Value.get(e);if($!=null&&($!==""||M==="json"&&typeof $=="object")){if(M==="markdown"&&typeof $=="string")await Kn(T,$);else if(M==="html"&&typeof $=="string")await Wn(T,$);else if(M==="json"&&typeof $=="object")try{const W=JSON.stringify($),Z=T.parseEditorState(W);T.setEditorState(Z)}catch(W){console.error("[BeatUI] Failed to parse JSON editor state:",W),u&&u(W instanceof Error?W:new Error(String(W)),T)}}}e!=null&&x.push(w.Value.on(e,async $=>{if($!=null){if(M==="markdown"&&typeof $=="string"){const R=await wt(T);$!==R&&await Kn(T,$)}else if(M==="html"&&typeof $=="string"){const R=await vt(T);$!==R&&await Wn(T,$)}else if(M==="json"&&typeof $=="object"){const R=JSON.stringify(T.getEditorState().toJSON()),W=JSON.stringify($);if(R!==W){const Z=T.parseEditorState(W);T.setEditorState(Z)}}}})),i!=null&&x.push(w.Value.on(i,$=>{T.setEditable(!$)})),x.push(T.registerCommand(fi,()=>(h&&h(T),f&&T.getEditorState().read(async()=>{if(M==="markdown"){const $=await wt(T);f($,T)}else if(M==="html"){const $=await vt(T);f($,T)}else M==="json"&&f(T.getEditorState().toJSON(),T)}),!1),G)),x.push(y.on($=>{const R=T.getRootElement();R&&(R.dataset.theme=$)})),g&&g(T)}catch(k){console.error("[BeatUI] Failed to initialize Lexical editor:",k);const E=S;E.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{x.forEach(k=>k())}catch{}try{C?.setRootElement(null)}catch{}p.set(null)})}))))};function v_({editor:n,stateUpdate:e,groups:t=["text-formatting"],readOnly:r=w.signal(!1),size:i="sm"}){const s=w.prop(!1),o=w.prop(0),l=w.prop(0);return w.Use(nr.BeatUII18n,a=>w.Ensure(n,c=>{const u=c,d=a.$.lexical,f=v=>t.includes(v),{textFormatActive:h,linkActive:g,dispatch:p,toggleLink:m}=x_(u,e,{enterUrlMessage:()=>a.value.lexical.enterUrl}),_=S_(r,i)(w.signal(!0)),y=()=>{const v=u.value;if(!v){s.value=!1;return}const k=v.getRootElement();if(!k){s.value=!1;return}const E=window.getSelection();if(!E||E.rangeCount===0||E.isCollapsed){s.value=!1;return}const M=E.anchorNode;if(M&&!k.contains(M)){s.value=!1;return}const I=E.getRangeAt(0).getBoundingClientRect();if(I.width===0&&I.height===0){s.value=!1;return}const K=40,$=8;let R=I.top-K-$;const W=I.left+I.width/2;R<0&&(R=I.bottom+$),o.value=R,l.value=W,s.value=!0},S=e.onChange(y),C=()=>{y()};document.addEventListener("selectionchange",C);const x=w.html.div(w.attr.class("bc-floating-toolbar"),w.style.position("fixed"),w.style.top(o.map(v=>`${v}px`)),w.style.left(l.map(v=>`${v}px`)),w.style.transform("translateX(-50%)"),w.WithElement(v=>{const k=M=>{if(M.key==="Escape"&&s.value){s.value=!1;const T=u.value;T&&T.focus()}},E=M=>{if(s.value&&!v.contains(M.target)){const T=u.value;if(T){const I=T.getRootElement();if(I&&I.contains(M.target))return}s.value=!1}};return document.addEventListener("keydown",k),document.addEventListener("mousedown",E),w.OnDispose(()=>{S(),document.removeEventListener("keydown",k),document.removeEventListener("mousedown",E),document.removeEventListener("selectionchange",C)})}),...f("text-formatting")?[_({active:h("bold"),onClick:p(ve,"bold"),label:d.map(v=>v.bold),icon:"mdi:format-bold"}),_({active:h("italic"),onClick:p(ve,"italic"),label:d.map(v=>v.italic),icon:"mdi:format-italic"}),_({active:h("underline"),onClick:p(ve,"underline"),label:d.map(v=>v.underline),icon:"mdi:format-underline"}),_({active:h("strikethrough"),onClick:p(ve,"strikethrough"),label:d.map(v=>v.strikethrough),icon:"mdi:format-strikethrough"}),_({active:h("code"),onClick:p(ve,"code"),label:d.map(v=>v.code),icon:"mdi:code-tags"})]:[],...f("links")?[_({active:g(),onClick:m,label:d.map(v=>v.link),icon:"mdi:link"})]:[],...f("clipboard")?[_({active:w.signal(!1),onClick:()=>{const v=u.value;if(!v)return;const k=v.getRootElement();k&&(k.focus(),document.execCommand("cut"))},label:d.map(v=>v.cut),icon:"mdi:content-cut"}),_({active:w.signal(!1),onClick:()=>{const v=u.value;if(!v)return;const k=v.getRootElement();k&&(k.focus(),document.execCommand("copy"))},label:d.map(v=>v.copy),icon:"mdi:content-copy"}),_({active:w.signal(!1),onClick:()=>{const v=u.value;v&&navigator.clipboard.readText().then(k=>{v.update(()=>{const E=O();N(E)&&E.insertText(k)}),v.focus()}).catch(()=>{})},label:d.map(v=>v.paste),icon:"mdi:content-paste"})]:[]);return w.When(s,()=>x)}))}const _0=[{id:"heading1",label:"Heading 1",description:"Large section heading",icon:"mdi:format-header-1",keywords:["h1","heading","title"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h1"))})}},{id:"heading2",label:"Heading 2",description:"Medium section heading",icon:"mdi:format-header-2",keywords:["h2","heading"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h2"))})}},{id:"heading3",label:"Heading 3",description:"Small section heading",icon:"mdi:format-header-3",keywords:["h3","heading"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h3"))})}},{id:"bullet-list",label:"Bullet List",description:"Create a bulleted list",icon:"mdi:format-list-bulleted",keywords:["ul","unordered","bullets"],category:"Lists",handler:n=>{n.dispatchCommand(bi,void 0)}},{id:"ordered-list",label:"Ordered List",description:"Create a numbered list",icon:"mdi:format-list-numbered",keywords:["ol","numbered","1","2","3"],category:"Lists",handler:n=>{n.dispatchCommand(xi,void 0)}},{id:"quote",label:"Quote",description:"Insert a blockquote",icon:"mdi:format-quote-close",keywords:["blockquote","citation"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>yi())})}},{id:"code-block",label:"Code Block",description:"Insert a code block",icon:"mdi:code-braces",keywords:["code","pre","programming"],category:"Basic blocks",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>St())})}},{id:"divider",label:"Divider",description:"Insert a horizontal rule",icon:"mdi:minus",keywords:["hr","horizontal","line","separator"],category:"Basic blocks",handler:n=>{n.dispatchCommand(Ms,void 0)}},{id:"table",label:"Table",description:"Insert a table",icon:"mdi:table",keywords:["table","grid","cells","rows","columns"],category:"Advanced",handler:n=>{n.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0})}}];function y0({commands:n,isVisible:e,filterText:t,position:r,onSelect:i,onDismiss:s}){const o=w.prop(0),l=t.map(f=>{const h=f.toLowerCase().trim();return h?n.filter(g=>[g.label.toLowerCase(),g.description?.toLowerCase()||"",...g.keywords?.map(m=>m.toLowerCase())||[]].join(" ").includes(h)):n});l.onChange(()=>{o.value=0});const a=f=>{const h=l.value;if(f>=0&&f<h.length){const g=h[f];i(g)}},c=f=>{if(!e.value)return;const g=l.value.length-1;switch(f.key){case"ArrowDown":f.preventDefault(),o.value=Math.min(o.value+1,g);break;case"ArrowUp":f.preventDefault(),o.value=Math.max(o.value-1,0);break;case"Enter":f.preventDefault(),a(o.value);break;case"Escape":f.preventDefault(),s();break}},u=(f,h)=>{const g=o.map(m=>m===h),p=`slash-cmd-${f.id}`;return w.html.div(w.attr.class("bc-slash-command-palette__item"),w.attr.id(p),w.attr.role("option"),w.aria.selected(g),w.WithElement(m=>{const b=()=>{o.value=h},_=()=>{a(h)};return m.addEventListener("mouseenter",b),m.addEventListener("click",_),w.OnDispose(()=>{m.removeEventListener("mouseenter",b),m.removeEventListener("click",_)})}),typeof f.icon=="string"?w.html.div(w.attr.class("bc-slash-command-palette__icon"),nr.Icon({icon:f.icon,size:"sm"})):f.icon,w.html.div(w.attr.class("bc-slash-command-palette__content"),w.html.div(w.attr.class("bc-slash-command-palette__label"),f.label),f.description?w.html.div(w.attr.class("bc-slash-command-palette__description"),f.description):void 0),f.category?w.html.div(w.attr.class("bc-slash-command-palette__category"),f.category):void 0)},d=w.Use(nr.BeatUII18n,f=>w.html.div(w.attr.class("bc-slash-command-palette"),w.attr.role("listbox"),w.aria.label(f.$.lexical.map(h=>h.slashCommands)),w.style.position("absolute"),w.style.top(r.map(h=>`${h.top}px`)),w.style.left(r.map(h=>`${h.left}px`)),w.WithElement(()=>(document.addEventListener("keydown",c),w.OnDispose(()=>{document.removeEventListener("keydown",c)}))),w.When(l.map(h=>h.length===0),()=>w.html.div(w.attr.class("bc-slash-command-palette__empty"),f.$.lexical.map(h=>h.noCommandsFound))),w.ForEach(l,(h,g)=>{const p=h.value;return u(p,g.index)})));return w.When(e,()=>d)}const E_=[{id:"paragraph",label:"Paragraph",icon:"mdi:format-paragraph",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>H())})}},{id:"heading1",label:"Heading 1",icon:"mdi:format-header-1",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h1"))})}},{id:"heading2",label:"Heading 2",icon:"mdi:format-header-2",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h2"))})}},{id:"heading3",label:"Heading 3",icon:"mdi:format-header-3",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>ft("h3"))})}},{id:"bullet-list",label:"Bullet List",icon:"mdi:format-list-bulleted",handler:n=>{n.dispatchCommand(bi,void 0)}},{id:"ordered-list",label:"Ordered List",icon:"mdi:format-list-numbered",handler:n=>{n.dispatchCommand(xi,void 0)}},{id:"quote",label:"Quote",icon:"mdi:format-quote-close",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>yi())})}},{id:"code-block",label:"Code Block",icon:"mdi:code-braces",handler:n=>{n.update(()=>{const e=O();N(e)&&et(e,()=>St())})}},{id:"divider",label:"Divider",icon:"mdi:minus",handler:n=>{n.dispatchCommand(Ms,void 0)}},{id:"table",label:"Table",icon:"mdi:table",handler:n=>{n.dispatchCommand(Ts,{rows:"3",columns:"3",includeHeaders:!0})}}];function k_({editor:n,stateUpdate:e,readOnly:t=w.signal(!1),commands:r=E_}){const i=w.prop(!1),s=w.prop(!1),o=w.prop(0),l=w.prop(0);return w.Use(nr.BeatUII18n,a=>w.Ensure(n,c=>{const u=c;let d=null,f=!1,h=null,g=null;const p=24,m=4,b=200,_=T=>{if(T===d&&i.value)return;d=T;const I=T.getBoundingClientRect();o.value=I.top,l.value=I.left-p-m,i.value=!0},y=()=>{h!=null&&(clearTimeout(h),h=null)},S=()=>{s.value||(y(),h=setTimeout(()=>{h=null,s.value||(i.value=!1,d=null)},b))},C=()=>{const T=u.value;if(!T)return;const I=T.getRootElement();I&&(k(I),T.getEditorState().read(()=>{const K=O();if(N(K))try{const R=K.anchor.getNode().getTopLevelElementOrThrow(),W=T.getElementByKey(R.getKey());W&&_(W)}catch{}}))},x=T=>{if(s.value)return;const I=u.value;if(!I)return;const K=I.getRootElement();if(K)for(const $ of Array.from(K.children)){const R=$.getBoundingClientRect();if(T.clientY>=R.top&&T.clientY<=R.bottom){y(),_($);return}}},v=()=>{S()},k=T=>{f||(f=!0,T.addEventListener("mousemove",x),T.addEventListener("mouseleave",v))},E=e.onChange(C);return[w.OnDispose(()=>{E(),y();const T=u.value;if(T){const I=T.getRootElement();I&&f&&(I.removeEventListener("mousemove",x),I.removeEventListener("mouseleave",v))}}),w.When(i,()=>w.html.div(w.attr.class("bc-block-handle"),w.style.position("fixed"),w.style.top(o.map(T=>`${T}px`)),w.style.left(l.map(T=>`${T}px`)),w.on.mouseenter(y),w.on.mouseleave(()=>S()),w.WithElement(T=>{T.addEventListener("mousedown",I=>{I.preventDefault()})}),w.html.button(w.attr.class("bc-block-handle__button"),w.attr.type("button"),w.attr.title(a.$.lexical.map(T=>T.changeBlockType)),w.attr.disabled(t),nr.Icon({icon:"mdi:drag-horizontal-variant",size:"sm"}),w.WithElement(T=>{const I=new MutationObserver(()=>{const K=T.getAttribute("aria-expanded")==="true";s.value=K});return I.observe(T,{attributes:!0,attributeFilter:["aria-expanded"]}),w.OnDispose(()=>I.disconnect())}),qu.Menu({items:()=>r.map(T=>qu.MenuItem({key:T.id,content:T.label,startContent:nr.Icon({icon:T.icon,size:"sm"}),onClick:()=>{const I=u.value;I&&(T.handler(I),g?.(),I.focus())}})),placement:"bottom-start",showOn:(T,I)=>(g=I,w.on.click(()=>{s.value?I():(T(),s.value=!0)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const T=u.value;T&&T.focus()},ariaLabel:a.value.lexical.blockTypes}))))]}))}const b0=n=>{const{value:e,format:t,plugins:r,readOnly:i,placeholder:s,class:o,namespace:l="BeatUILexical",heightMode:a="auto",floatingToolbarGroups:c,onError:u,onInput:d,onChange:f,onBlur:h,onReady:g}=n,p=w.prop(null),m=w.prop(0),b=y=>typeof y=="object"&&y!==null&&"map"in y&&typeof y.map=="function",_=i!=null?b(i)?i:w.prop(w.Value.get(i)):w.prop(!1);return w.Use(vc.Theme,({appearance:y})=>w.html.div(w.Task(()=>Promise.resolve().then(()=>require("../styles-url-mlDYoWbF.cjs")),({default:S})=>wc.LinkPortal({id:"beatui-lexical-css",href:S})),w.attr.class("bc-lexical-editor-container"),a==="fixed"?w.attr.class("bc-lexical-editor-container--fixed"):null,w.attr.class(o),v_({editor:p,stateUpdate:m,groups:c??["text-formatting","links"],readOnly:_}),k_({editor:p,stateUpdate:m,readOnly:_}),w_({editor:p,stateUpdate:m,readOnly:_}),w.html.div(w.attr.class("bc-lexical-editor"),w.attr.class(`bc-lexical-editor--${a}`),w.attr.contenteditable(i!=null?w.Value.map(i,S=>!S):!0),i!=null?w.attr.class(w.Value.map(i,S=>S?"bc-lexical-editor--readonly":"")):null,w.WithElement(S=>{let C=null;const x=[];return(async()=>{try{const k=r??vl("contextual"),E=wl(k),M=w.Value.get(t??"markdown"),T=gi({namespace:l,nodes:E,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:$=>{u?u($,T):console.error("[BeatUI Lexical]",$)},editable:i?!w.Value.get(i):!0});C=T,p.set(T),T.setRootElement(S);const I=[];if(k.richText?I.push(Pl(T)):k.plainText&&I.push(Bl(T)),k.history){const $=typeof k.history=="object"?k.history:void 0;I.push(zl(T,$))}if(k.clipboard&&I.push(Ul(T)),k.list&&I.push(Kl(T)),k.link&&I.push(Wl(T)),k.yjs&&I.push(Gl(T,k.yjs)),k.dragon&&I.push(Jl(T)),k.table&&I.push(Hl(T)),(await Promise.all(I)).forEach($=>{$&&x.push($)}),x.push(jl(T)),x.push(T.registerCommand(oi,()=>(m.set(m.value+1),!1),G)),x.push(T.registerUpdateListener(({editorState:$,dirtyElements:R,dirtyLeaves:W})=>{(R.size>0||W.size>0)&&m.set(m.value+1),d&&(R.size>0||W.size>0)&&$.read(async()=>{if(M==="markdown"){const Z=await wt(T);d(Z,T)}else if(M==="html"){const Z=await vt(T);d(Z,T)}else M==="json"&&d($.toJSON(),T)})})),e!=null){const $=w.Value.get(e);if($!=null&&($!==""||M==="json"&&typeof $=="object")){if(M==="markdown"&&typeof $=="string")await Kn(T,$);else if(M==="html"&&typeof $=="string")await Wn(T,$);else if(M==="json"&&typeof $=="object")try{const W=JSON.stringify($),Z=T.parseEditorState(W);T.setEditorState(Z)}catch(W){console.error("[BeatUI] Failed to parse JSON editor state:",W),u&&u(W instanceof Error?W:new Error(String(W)),T)}}}e!=null&&x.push(w.Value.on(e,async $=>{if($!=null){if(M==="markdown"&&typeof $=="string"){const R=await wt(T);$!==R&&await Kn(T,$)}else if(M==="html"&&typeof $=="string"){const R=await vt(T);$!==R&&await Wn(T,$)}else if(M==="json"&&typeof $=="object"){const R=JSON.stringify(T.getEditorState().toJSON()),W=JSON.stringify($);if(R!==W){const Z=T.parseEditorState(W);T.setEditorState(Z)}}}})),i!=null&&x.push(w.Value.on(i,$=>{T.setEditable(!$)})),x.push(T.registerCommand(fi,()=>(h&&h(T),f&&T.getEditorState().read(async()=>{if(M==="markdown"){const $=await wt(T);f($,T)}else if(M==="html"){const $=await vt(T);f($,T)}else M==="json"&&f(T.getEditorState().toJSON(),T)}),!1),G)),x.push(y.on($=>{const R=T.getRootElement();R&&(R.dataset.theme=$)})),g&&g(T)}catch(k){console.error("[BeatUI] Failed to initialize Lexical editor:",k);const E=S;E.textContent="Failed to load Lexical editor."}})(),w.OnDispose(()=>{try{x.forEach(k=>k())}catch{}try{C?.setRootElement(null)}catch{}p.set(null)})}))))},x0=n=>{const{value:e,before:t,after:r,onChange:i,onInput:s,onBlur:o,disabled:l,hasError:a,name:c,placeholder:u,id:d,required:f,tabIndex:h,size:g,class:p,namespace:m,format:b,plugins:_,readOnly:y,onError:S,onReady:C,marks:x}=n,v=l!=null&&y!=null?w.computedOf(l,y)((k,E)=>(k??!1)||(E??!1)):l??y;return U_.InputContainer({disabled:l,hasError:a,size:g,baseContainer:!0,growInput:!0,focusableSelector:"[contenteditable]",before:t,after:r,input:w.html.div(w.attr.class("bc-lexical-editor-input"),w.attr.name(c),w.attr.id(d),f!=null?w.aria.required(f):null,h!=null?w.attr.tabindex(h):null,a!=null?w.attr.class(w.Value.map(a,k=>k?"bc-lexical-editor-input--error":"")):null,b_({value:e,format:b??"markdown",plugins:_,readOnly:v,placeholder:u,namespace:m,class:p,onError:S,onReady:C,onInput:s?(k,E)=>{s(k)}:void 0,onChange:i?(k,E)=>{i(k)}:void 0,onBlur:o?k=>{o()}:void 0}))})};exports.$createHorizontalRuleNode=Ns;exports.$isHorizontalRuleNode=Vp;exports.BLUR_COMMAND=fi;exports.BareEditor=b_;exports.BlockHandle=k_;exports.CLEAR_EDITOR_COMMAND=Lc;exports.CLICK_COMMAND=br;exports.COMMAND_PRIORITY_CRITICAL=Wc;exports.COMMAND_PRIORITY_EDITOR=B;exports.COMMAND_PRIORITY_HIGH=wg;exports.COMMAND_PRIORITY_LOW=G;exports.COMMAND_PRIORITY_NORMAL=Cg;exports.COPY_COMMAND=xr;exports.CUT_COMMAND=di;exports.ContextualEditor=b0;exports.DEFAULT_BLOCK_COMMANDS=E_;exports.DEFAULT_SLASH_COMMANDS=_0;exports.DecoratorNode=Ss;exports.DockedEditor=m0;exports.ElementNode=xe;exports.FOCUS_COMMAND=Rc;exports.FORMAT_ELEMENT_COMMAND=Fc;exports.FORMAT_TEXT_COMMAND=ve;exports.FloatingToolbar=v_;exports.HR_TRANSFORMER=__;exports.HorizontalRuleNode=Ir;exports.INDENT_CONTENT_COMMAND=Ut;exports.INSERT_CHECK_LIST_COMMAND=xl;exports.INSERT_HORIZONTAL_RULE_COMMAND=Ms;exports.INSERT_IMAGE_COMMAND=Kv;exports.INSERT_ORDERED_LIST_COMMAND=xi;exports.INSERT_PARAGRAPH_COMMAND=Fn;exports.INSERT_UNORDERED_LIST_COMMAND=bi;exports.KEY_ENTER_COMMAND=Dn;exports.KEY_ESCAPE_COMMAND=ui;exports.KEY_TAB_COMMAND=xs;exports.LexicalEditorInput=x0;exports.LexicalToolbar=C_;exports.OUTDENT_CONTENT_COMMAND=sn;exports.PASTE_COMMAND=li;exports.REDO_COMMAND=ci;exports.REMOVE_LIST_COMMAND=pu;exports.SELECTION_CHANGE_COMMAND=oi;exports.SlashCommandPalette=y0;exports.TOGGLE_SLASH_COMMAND_PALETTE=Uv;exports.TextNode=Ye;exports.UNDO_COMMAND=ai;exports.applyMark=r0;exports.createCommand=z;exports.createDefaultPluginConfig=vl;exports.createHeadlessEditor=$s;exports.executeSlashCommand=zv;exports.exportEditorToFile=Wv;exports.exportToHtml=vt;exports.exportToMarkdown=wt;exports.getCharacterCount=l0;exports.getMarkdownTransformers=y_;exports.getNodesForPlugins=wl;exports.getSelectionInfo=o0;exports.getTextContent=Gu;exports.getWordCount=a0;exports.htmlToLexicalJson=f0;exports.importFileToEditor=jv;exports.importFromHtml=Wn;exports.importFromMarkdown=Kn;exports.insertTable=Jv;exports.lexicalJsonToHtml=h0;exports.lexicalJsonToMarkdown=d0;exports.loadLexicalCore=m_;exports.loadOffsetUtils=c0;exports.markdownToLexicalJson=u0;exports.registerAutoLinkPlugin=t0;exports.registerClipboardPlugin=Ul;exports.registerCodePlugin=Gv;exports.registerCodeShikiPlugin=Vv;exports.registerDragonPlugin=Jl;exports.registerHashtagPlugin=Zv;exports.registerHistoryPlugin=zl;exports.registerHorizontalRulePlugin=jl;exports.registerLinkPlugin=Wl;exports.registerListPlugin=Kl;exports.registerMarkPlugin=n0;exports.registerOverflowPlugin=s0;exports.registerPlainTextPlugin=Bl;exports.registerRichTextPlugin=Pl;exports.registerSlashCommandsPlugin=Bv;exports.registerTablePlugin=Hl;exports.registerYjsPlugin=Gl;exports.removeMark=i0;
|
package/dist/lexical/index.es.js
CHANGED
|
@@ -3,10 +3,10 @@ import { Use as Tr, html as q, Task as Cc, attr as L, Value as _e, WithElement a
|
|
|
3
3
|
import { L as vc } from "../link-portal-Cr2l9f3k.js";
|
|
4
4
|
import { T as Ec } from "../theme-kQZEeusG.js";
|
|
5
5
|
import { M as j_, b as H_ } from "../menu-CV85y3Xf.js";
|
|
6
|
-
import { B as Vo, I as Aa } from "../translations-
|
|
7
|
-
import { E as J_, a as vt } from "../editor-toolbar-group-
|
|
8
|
-
import { b as G_ } from "../toolbar-
|
|
9
|
-
import { I as V_ } from "../input-container-
|
|
6
|
+
import { B as Vo, I as Aa } from "../translations-uEUkO6gJ.js";
|
|
7
|
+
import { E as J_, a as vt } from "../editor-toolbar-group-Cnta0SOa.js";
|
|
8
|
+
import { b as G_ } from "../toolbar-Cr0JGj5h.js";
|
|
9
|
+
import { I as V_ } from "../input-container-BBWCDGTv.js";
|
|
10
10
|
function D(n, ...e) {
|
|
11
11
|
const t = new URL("https://lexical.dev/docs/error"), r = new URLSearchParams();
|
|
12
12
|
r.append("code", n);
|
|
@@ -19225,7 +19225,7 @@ const i0 = (n) => {
|
|
|
19225
19225
|
({ appearance: g }) => q.div(
|
|
19226
19226
|
// CSS injection via LinkPortal
|
|
19227
19227
|
Cc(
|
|
19228
|
-
() => import("../styles-url-
|
|
19228
|
+
() => import("../styles-url-4g2WnNJ8.js"),
|
|
19229
19229
|
({ default: p }) => vc({ id: "beatui-lexical-css", href: p })
|
|
19230
19230
|
),
|
|
19231
19231
|
L.class("bc-lexical-editor-container"),
|
|
@@ -20124,7 +20124,7 @@ const V0 = (n) => {
|
|
|
20124
20124
|
({ appearance: y }) => q.div(
|
|
20125
20125
|
// CSS injection via LinkPortal
|
|
20126
20126
|
Cc(
|
|
20127
|
-
() => import("../styles-url-
|
|
20127
|
+
() => import("../styles-url-4g2WnNJ8.js"),
|
|
20128
20128
|
({ default: S }) => vc({ id: "beatui-lexical-css", href: S })
|
|
20129
20129
|
),
|
|
20130
20130
|
L.class("bc-lexical-editor-container"),
|
|
@@ -20990,7 +20990,7 @@ const Z0 = (n) => {
|
|
|
20990
20990
|
({ appearance: y }) => q.div(
|
|
20991
20991
|
// CSS injection via LinkPortal
|
|
20992
20992
|
Cc(
|
|
20993
|
-
() => import("../styles-url-
|
|
20993
|
+
() => import("../styles-url-4g2WnNJ8.js"),
|
|
20994
20994
|
({ default: S }) => vc({ id: "beatui-lexical-css", href: S })
|
|
20995
20995
|
),
|
|
20996
20996
|
L.class("bc-lexical-editor-container"),
|