@nextblock-cms/editor 0.12.9 → 0.12.11

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/index.js CHANGED
@@ -163,7 +163,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ye=$,Ee=ee),me===void
163
163
  ${n.toString()}`)};class V2{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:vo(e),h:n}),this}else(e){return this.if(ec,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw Cn("Unhandled pattern")}}}const W2=t=>new V2(t),sv=W2(ec).if(tv,(t,e)=>md(e,xy,Ga)).if(nv,(t,e)=>b2(e)).if(H2,(t,e)=>Ty(e)).if(z2,(t,e)=>BigInt(md(e,xy,Ga))).if(Qa,(t,e)=>ms(e,gd(e,t.shape))).if(M2,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(C2.check(s)){if(Ty(e))continue;s=s.shape}n[r]=sv(s,e)}return n}).if(_2,(t,e)=>{const n=[],r=U1(e,0,42);for(let s=0;s<r;s++)n.push(ms(e,t.shape));return n}).if(V1,(t,e)=>gd(e,t.shape)).if(F2,(t,e)=>null).if(P2,(t,e)=>{const n=ms(e,t.res);return()=>n}).if(B2,(t,e)=>ms(e,gd(e,[Ts,Js,qc,rv,hp,Wc,X1(Ts),J1(ri("a","b","c"),Ts)]))).if(N2,(t,e)=>{const n={},r=md(e,0,3);for(let s=0;s<r;s++){const i=ms(e,t.shape.keys),o=ms(e,t.shape.values);n[i]=o}return n}).done(),ms=(t,e)=>sv(vo(e),t),Ho=typeof document<"u"?document:{};rt(t=>t.nodeType===Y2);typeof DOMParser<"u"&&new DOMParser;rt(t=>t.nodeType===K2);rt(t=>t.nodeType===J2);const q2=t=>dI(t,(e,n)=>`${n}:${e};`).join(""),K2=Ho.ELEMENT_NODE,J2=Ho.TEXT_NODE,G2=Ho.DOCUMENT_NODE,Y2=Ho.DOCUMENT_FRAGMENT_NODE;rt(t=>t.nodeType===G2);const X2=t=>class{constructor(n){this._=n}destroy(){t(this._)}},Z2=X2(clearTimeout),iv=(t,e)=>new Z2(setTimeout(e,t)),Kn=Symbol,ov=Kn(),lv=Kn(),Q2=Kn(),eP=Kn(),tP=Kn(),av=Kn(),nP=Kn(),fp=Kn(),rP=Kn(),sP=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},iP={[ov]:_n("font-weight","bold"),[lv]:_n("font-weight","normal"),[Q2]:_n("color","blue"),[tP]:_n("color","green"),[eP]:_n("color","grey"),[av]:_n("color","red"),[nP]:_n("color","purple"),[fp]:_n("color","orange"),[rP]:_n("color","black")},oP=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=sn();let s=[],i=0;for(;i<t.length;i++){const o=t[i],l=iP[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=q2(r);i>0||a.length>0?(e.push("%c"+o),n.push(a)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const o=t[i];o instanceof Symbol||s.push(o)}return s},cv=d2?oP:sP,lP=(...t)=>{console.log(...cv(t)),dv.forEach(e=>e.print(t))},uv=(...t)=>{console.warn(...cv(t)),t.unshift(fp),dv.forEach(e=>e.print(t))},dv=Zr(),hv=t=>({[Symbol.iterator](){return this},next:t}),aP=(t,e)=>hv(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),yd=(t,e)=>hv(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Kc{constructor(e,n){this.clock=e,this.len=n}}class si{constructor(){this.clients=new Map}}const xr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])wv(t,i,c.clock,c.len,n)}}),cP=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=ln((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},ii=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&cP(n,e.clock)!==null},pp=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?e[r-1]=new Kc(s.clock,br(s.len,i.clock+i.len-s.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},Ah=t=>{const e=new si;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)fI(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return pp(e),e},ko=(t,e,n,r)=>{qn(t.clients,e,()=>[]).push(new Kc(n,r))},fv=()=>new si,uP=t=>{const e=fv();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new Kc(l,a))}}s.length>0&&e.clients.set(r,s)}),e},mp=(t,e)=>{be(t.restEncoder,e.clients.size),Qr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),be(t.restEncoder,n);const s=r.length;be(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},dP=t=>{const e=new si,n=Re(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Re(t.restDecoder),i=Re(t.restDecoder);if(i>0){const o=qn(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new Kc(t.readDsClock(),t.readDsLen()))}}return e},Ry=(t,e,n)=>{const r=new si,s=Re(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Re(t.restDecoder),l=Re(t.restDecoder),a=n.clients.get(o)||[],c=Ue(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),h=d+t.readDsLen();if(d<c){c<h&&ko(r,o,c,h-c);let f=an(a,d),p=a[f];for(!p.deleted&&p.id.clock<d&&(a.splice(f+1,0,lc(e,p,d-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,lc(e,p,h-p.id.clock)),p.delete(e))}else ko(r,o,d,h-d)}}if(r.clients.size>0){const i=new Jc;return be(i.restEncoder,0),mp(i,r),i.toUint8Array()}return null},pv=P1;class ls extends _1{constructor({guid:e=YI(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=pv(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new bv,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ay(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>Ay(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&&Se(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Qr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Se(this,e,n)}get(e,n=nt){const r=qn(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==nt&&s!==n)if(s===nt){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}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,_s)}getText(e=""){return this.get(e,wr)}getMap(e=""){return this.get(e,Gs)}getXmlElement(e=""){return this.get(e,St)}getXmlFragment(e=""){return this.get(e,es)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Qr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ls({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Se(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class hP{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Re(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Re(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class tc extends hP{constructor(e){super(e),this.keys=[],Re(e),this.keyClockDecoder=new pd(Vt(e)),this.clientDecoder=new Yl(Vt(e)),this.leftClockDecoder=new pd(Vt(e)),this.rightClockDecoder=new pd(Vt(e)),this.infoDecoder=new Ey(Vt(e),xo),this.stringDecoder=new WI(Vt(e)),this.parentInfoDecoder=new Ey(Vt(e),xo),this.typeRefDecoder=new Yl(Vt(e)),this.lenDecoder=new Yl(Vt(e))}readLeftID(){return new Ns(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ns(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ya(this.restDecoder)}readBuf(){return Vt(this.restDecoder)}readJSON(){return Ya(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class fP{constructor(){this.restEncoder=zo()}toUint8Array(){return rn(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){be(this.restEncoder,e)}writeDsLen(e){be(this.restEncoder,e)}}class pP extends fP{writeLeftID(e){be(this.restEncoder,e.client),be(this.restEncoder,e.clock)}writeRightID(e){be(this.restEncoder,e.client),be(this.restEncoder,e.clock)}writeClient(e){be(this.restEncoder,e)}writeInfo(e){vh(this.restEncoder,e)}writeString(e){Ms(this.restEncoder,e)}writeParentInfo(e){be(this.restEncoder,e?1:0)}writeTypeRef(e){be(this.restEncoder,e)}writeLen(e){be(this.restEncoder,e)}writeAny(e){qs(this.restEncoder,e)}writeBuf(e){It(this.restEncoder,e)}writeJSON(e){Ms(this.restEncoder,JSON.stringify(e))}writeKey(e){Ms(this.restEncoder,e)}}class mP{constructor(){this.restEncoder=zo(),this.dsCurrVal=0}toUint8Array(){return rn(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,be(this.restEncoder,n)}writeDsLen(e){e===0&&Mt(),be(this.restEncoder,e-1),this.dsCurrVal+=e}}class Jc extends mP{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new fd,this.clientEncoder=new Gl,this.leftClockEncoder=new fd,this.rightClockEncoder=new fd,this.infoEncoder=new ky(vh),this.stringEncoder=new PI,this.parentInfoEncoder=new ky(vh),this.typeRefEncoder=new Gl,this.lenEncoder=new Gl}toUint8Array(){const e=zo();return be(e,0),It(e,this.keyClockEncoder.toUint8Array()),It(e,this.clientEncoder.toUint8Array()),It(e,this.leftClockEncoder.toUint8Array()),It(e,this.rightClockEncoder.toUint8Array()),It(e,rn(this.infoEncoder)),It(e,this.stringEncoder.toUint8Array()),It(e,rn(this.parentInfoEncoder)),It(e,this.typeRefEncoder.toUint8Array()),It(e,this.lenEncoder.toUint8Array()),zc(e,rn(this.restEncoder)),rn(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){qs(this.restEncoder,e)}writeBuf(e){It(this.restEncoder,e)}writeJSON(e){qs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const gP=(t,e,n,r)=>{r=br(r,e[0].id.clock);const s=an(e,r);be(t.restEncoder,e.length-s),t.writeClient(n),be(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},mv=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ue(e,i)>s&&r.set(i,s)}),Gc(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),be(t.restEncoder,r.size),Qr(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{gP(t,e.clients.get(s),s,i)})},yP=(t,e)=>{const n=sn(),r=Re(t.restDecoder);for(let s=0;s<r;s++){const i=Re(t.restDecoder),o=new Array(i),l=t.readClient();let a=Re(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const u=t.readInfo();switch(Bc&u){case 0:{const d=t.readLen();o[c]=new Kt(fe(l,a),d),a+=d;break}case 10:{const d=Re(t.restDecoder);o[c]=new nn(fe(l,a),d),a+=d;break}default:{const d=(u&(Hn|Ct))===0,h=new ke(fe(l,a),null,(u&Ct)===Ct?t.readLeftID():null,null,(u&Hn)===Hn?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&yo)===yo?t.readString():null,Fv(t,u));o[c]=h,a+=h.length}}}}return n},bP=(t,e,n)=>{const r=[];let s=Qr(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new bv,a=new Map,c=(f,p)=>{const m=a.get(f);(m==null||m>p)&&a.set(f,p)};let u=o.refs[o.i++];const d=new Map,h=()=>{for(const f of r){const p=f.id.client,m=n.get(p);m?(m.i--,l.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==nn){const p=qn(d,u.id.client,()=>Ue(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),h();else{const m=u.getMissing(t,e);if(m!==null){r.push(u);const y=n.get(m)||{refs:[],i:0};if(y.refs.length===y.i)c(m,Ue(e,m)),h();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const f=new Jc;return mv(f,l,new Map),be(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},xP=(t,e)=>mv(t,e.doc.store,e.beforeState),wP=(t,e,n,r=new tc(t))=>Se(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=yP(r,o),c=bP(s,l,a),u=l.pendingStructs;if(u){for(const[h,f]of u.missing)if(f<Ue(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=By([u.update,c.update])}}else l.pendingStructs=c;const d=Ry(r,s,l);if(l.pendingDs){const h=new tc(rp(l.pendingDs));Re(h.restDecoder);const f=Ry(h,s,l);d&&f?l.pendingDs=By([d,f]):l.pendingDs=d||f}else l.pendingDs=d;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,Mh(s.doc,h)}},n,!1),Mh=(t,e,n,r=tc)=>{const s=rp(e);wP(s,t,n,new r(s))};class vP{constructor(){this.l=[]}}const _y=()=>new vP,Oy=(t,e)=>t.l.push(e),Dy=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},gv=(t,e,n)=>lp(t.l,[e,n]);class Ns{constructor(e,n){this.client=e,this.clock=n}}const Nl=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,fe=(t,e)=>new Ns(t,e),So=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Mt()},Co=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class nc{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class kP{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const SP=(t,e,n=0)=>new kP(t,e,n),Rl=(t,e,n)=>{let r=null,s=null;return t._item===null?s=So(t):r=fe(t._item.id.client,t._item.id.clock),new nc(r,s,e,n)},bd=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Rl(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Rl(t,fe(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Rl(t,r.lastId,n);r=r.right}return Rl(t,null,n)},CP=(t,e)=>{const n=Rs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},EP=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ue(r,s.client)<=s.clock)return null;const u=n?_h(r,s):CP(r,s),d=u.item;if(!(d instanceof ke))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ue(r,i.client)<=i.clock)return null;const{item:u}=n?_h(r,i):{item:Rs(r,i)};if(u instanceof ke&&u.content instanceof hn)a=u.content.type;else return null}else throw Mt();l>=0?c=a._length:c=0}return SP(a,c,t.assoc)};class gp{constructor(e,n){this.ds=e,this.sv=n}}const yv=(t,e)=>new gp(t,e),xd=t=>yv(uP(t.store),Gc(t.store)),Nr=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ii(e.ds,t.id),Th=(t,e)=>{const n=qn(t.meta,Th,Zr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ue(r,i)&&_t(t,fe(i,s))}),xr(t,e.ds,s=>{}),n.add(e))};class bv{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Gc=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ue=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},xv=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Mt()}n.push(e)},an=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=ln(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=ln((n+r)/2)}throw Mt()},AP=(t,e)=>{const n=t.clients.get(e.client);return n[an(n,e.clock)]},Rs=AP,Nh=(t,e,n)=>{const r=an(e,n),s=e[r];return s.id.clock<n&&s instanceof ke?(e.splice(r+1,0,lc(t,s,n-s.id.clock)),r+1):r},_t=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Nh(t,n,e.clock)]},Ly=(t,e,n)=>{const r=e.clients.get(n.client),s=an(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Kt&&r.splice(s+1,0,lc(t,i,n.clock-i.id.clock+1)),i},MP=(t,e,n)=>{const r=t.clients.get(e.id.client);r[an(r,e.id.clock)]=n},wv=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Nh(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Nh(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class TP{constructor(e,n,r){this.doc=e,this.deleteSet=new si,this.beforeState=Gc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Iy=(t,e)=>e.deleteSet.clients.size===0&&!hI(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(pp(e.deleteSet),xP(t,e),mp(t,e.deleteSet),!0),Py=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&qn(t.changed,e,Zr).add(n)},Zl=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ke&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},NP=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=an(i,l.clock),u=i[c];c<i.length&&u.id.clock<a;u=i[++c]){const d=i[c];if(l.clock+l.len<=d.id.clock)break;d instanceof ke&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},RP=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=Ws(s.length-1,1+an(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Zl(s,a)}})},vv=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{pp(i),n.afterState=Gc(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.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(()=>{gv(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&YP(n)})}),lp(l,[])}finally{r.gc&&NP(i,s,r.gcFilter),RP(i,s),n.afterState.forEach((u,d)=>{const h=n.beforeState.get(d)||0;if(h!==u){const f=s.clients.get(d),p=br(an(f,h),1);for(let m=f.length-1;m>=p;)m-=1+Zl(f,m)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:h}=o[u].id,f=s.clients.get(d),p=an(f,h);p+1<f.length&&Zl(f,p+1)>1||p>0&&Zl(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(lP(fp,ov,"[yjs] ",lv,av,"Changed the client-id because another client seems to be using it."),r.clientID=pv()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new pP;Iy(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Jc;Iy(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(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,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):vv(t,e+1)}}},Se=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new TP(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&vv(s,0)}}return o};class _P{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const jy=(t,e,n)=>{xr(t,n.deletions,r=>{r instanceof ke&&e.scope.some(s=>s===t.doc||Co(s,r))&&vp(r,!1)})},$y=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Se(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let h=!1;xr(l,c.insertions,f=>{if(f instanceof ke){if(f.redone!==null){let{item:p,diff:m}=_h(a,f.id);m>0&&(p=_t(l,fe(p.id.client,p.id.clock+m))),f=p}!f.deleted&&i.some(p=>p===l.doc||Co(p,f))&&d.push(f)}}),xr(l,c.deletions,f=>{f instanceof ke&&i.some(p=>p===l.doc||Co(p,f))&&!ii(c.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Hv(l,f,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=d.length-1;f>=0;f--){const p=d[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class kv extends _1{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Vs(e)?e[0].doc:e instanceof ls?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const h=new si;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,k=y-w;k>0&&ko(h,b,w,k)});const f=XI();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=Ah([y.deletions,a.deleteSet]),y.insertions=Ah([y.insertions,h])}else d.push(new _P(a.deleteSet,h)),p=!0;!c&&!u&&(this.lastChange=f),xr(a,a.deleteSet,y=>{y instanceof ke&&this.scope.some(b=>b===a.doc||Co(b,y))&&vp(y,!0)});const m=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Vs(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof nt?r.doc!==this.doc:r!==this.doc)&&uv("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>jy(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>jy(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=$y(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=$y(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*OP(t){const e=Re(t.restDecoder);for(let n=0;n<e;n++){const r=Re(t.restDecoder),s=t.readClient();let i=Re(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Re(t.restDecoder);yield new nn(fe(s,i),a),i+=a}else if((Bc&l)!==0){const a=(l&(Hn|Ct))===0,c=new ke(fe(s,i),null,(l&Ct)===Ct?t.readLeftID():null,null,(l&Hn)===Hn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&yo)===yo?t.readString():null,Fv(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Kt(fe(s,i),a),i+=a}}}}class DP{constructor(e,n){this.gen=OP(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===nn);return this.curr}}class LP{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const IP=(t,e)=>{if(t.constructor===Kt){const{client:n,clock:r}=t.id;return new Kt(fe(n,r+e),t.length-e)}else if(t.constructor===nn){const{client:n,clock:r}=t.id;return new nn(fe(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new ke(fe(r,s+e),null,fe(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},By=(t,e=tc,n=Jc)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(rp(u)));let s=r.map(u=>new DP(u,!0)),i=null;const o=new n,l=new LP(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===nn?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(i!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)gi(l,i.struct,i.offset),i={struct:h,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===nn)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{gi(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new nn(fe(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===nn?i.struct.length-=p:h=IP(h,p)),i.struct.mergeWith(h)||(gi(l,i.struct,i.offset),i={struct:h,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==nn;h=u.next())gi(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(gi(l,i.struct,i.offset),i=null),PP(l);const a=r.map(u=>dP(u)),c=Ah(a);return mp(o,c),o.toUint8Array()},Sv=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:rn(t.encoder.restEncoder)}),t.encoder.restEncoder=zo(),t.written=0)},gi=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Sv(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),be(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},PP=t=>{Sv(t);const e=t.encoder.restEncoder;be(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];be(e,r.written),zc(e,r.restEncoder)}},zy="You must not compute changes after the event-handler fired.";class Yc{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=jP(this.currentTarget,this.target))}deletes(e){return ii(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Cn(zy);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=ud(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=ud(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=ud(i.content.getContent());else return;e.set(s,{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 Cn(zy);const n=this.target,r=Zr(),s=Zr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._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,s.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 jP=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},ft=()=>{uv("Invalid access: Add Yjs type to a document before reading data.")},Cv=80;let yp=0;class $P{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=yp++}}const BP=t=>{t.timestamp=yp++},Ev=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=yp++},zP=(t,e,n)=>{if(t.length>=Cv){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Ev(r,e,n),r}else{const r=new $P(e,n);return t.push(r),r}},Xc=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>Jl(e-i.index)<Jl(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,BP(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=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&&(s-=r.length);return n!==null&&Jl(n.index-s)<r.parent.length/Cv?(Ev(n,r,s),n):zP(t._searchMarker,r,s)},Eo=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=br(e,s.index+n))}},Zc=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;qn(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;gv(r._eH,n,e)};class nt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=_y(),this._dEH=_y(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Yt()}clone(){throw Yt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Oy(this._eH,e)}observeDeep(e){Oy(this._dEH,e)}unobserve(e){Dy(this._eH,e)}unobserveDeep(e){Dy(this._dEH,e)}toJSON(){}}const Av=(t,e,n)=>{t.doc??ft(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},Mv=t=>{t.doc??ft();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},Tv=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Nr(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Ao=(t,e)=>{let n=0,r=t._start;for(t.doc??ft();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},Nv=(t,e)=>{const n=[];return Ao(t,(r,s)=>{n.push(e(r,s,t))}),n},HP=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Rv=(t,e)=>{t.doc??ft();const n=Xc(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},rc=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new ke(fe(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new ts(c)),s.integrate(t,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:s=new ke(fe(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Fo(new Uint8Array(d))),s.integrate(t,0);break;case ls:s=new ke(fe(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Uo(d)),s.integrate(t,0);break;default:if(d instanceof nt)s=new ke(fe(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new hn(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},_v=()=>Cn("Length exceeded!"),Ov=(t,e,n,r)=>{if(n>e._length)throw _v();if(n===0)return e._searchMarker&&Eo(e._searchMarker,n,r.length),rc(t,e,null,r);const s=n,i=Xc(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&_t(t,fe(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Eo(e._searchMarker,s,r.length),rc(t,e,o,r)},FP=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return rc(t,e,s,n)},Dv=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=Xc(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&_t(t,fe(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&_t(t,fe(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw _v();e._searchMarker&&Eo(e._searchMarker,s,-i+r)},sc=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},bp=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new ts([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new ts([r]);break;case Uint8Array:l=new Fo(r);break;case ls:l=new Uo(r);break;default:if(r instanceof nt)l=new hn(r);else throw new Error("Unexpected content type")}new ke(fe(o,Ue(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},xp=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Lv=t=>{const e={};return t.doc??ft(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Iv=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted},UP=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Nr(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},_l=t=>(t.doc??ft(),aP(t._map.entries(),e=>!e[1].deleted));class VP extends Yc{}class _s extends nt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new _s;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new _s}clone(){const e=new _s;return e.insert(0,this.toArray().map(n=>n instanceof nt?n.clone():n)),e}get length(){return this.doc??ft(),this._length}_callObserver(e,n){super._callObserver(e,n),Zc(this,e,new VP(this,e))}insert(e,n){this.doc!==null?Se(this.doc,r=>{Ov(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Se(this.doc,n=>{FP(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Se(this.doc,r=>{Dv(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Rv(this,e)}toArray(){return Mv(this)}slice(e=0,n=this.length){return Av(this,e,n)}toJSON(){return this.map(e=>e instanceof nt?e.toJSON():e)}map(e){return Nv(this,e)}forEach(e){Ao(this,e)}[Symbol.iterator](){return HP(this)}_write(e){e.writeTypeRef(mj)}}const WP=t=>new _s;class qP extends Yc{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Gs extends nt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Gs}clone(){const e=new Gs;return this.forEach((n,r)=>{e.set(r,n instanceof nt?n.clone():n)}),e}_callObserver(e,n){Zc(this,e,new qP(this,e,n))}toJSON(){this.doc??ft();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof nt?s.toJSON():s}}),e}get size(){return[..._l(this)].length}keys(){return yd(_l(this),e=>e[0])}values(){return yd(_l(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return yd(_l(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ft(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Se(this.doc,n=>{sc(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Se(this.doc,r=>{bp(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return xp(this,e)}has(e){return Iv(this,e)}clear(){this.doc!==null?Se(this.doc,e=>{this.forEach(function(n,r,s){sc(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(gj)}}const KP=t=>new Gs,ar=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&i2(t,e);class Rh{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&Mt(),this.right.content.constructor===Je?this.right.deleted||oi(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const Hy=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Je?e.right.deleted||oi(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&_t(t,fe(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Ol=(t,e,n,r)=>{const s=new Map,i=r?Xc(e,n):null;if(i){const o=new Rh(i.p.left,i.p,i.index,s);return Hy(t,o,n-i.index)}else{const o=new Rh(null,e._start,0,s);return Hy(t,o,n)}},Pv=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Je&&ar(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new ke(fe(i,Ue(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Je(l,o));u.integrate(t,0),n.right=u,n.forward()})},oi=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},jv=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Je&&ar(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},$v=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!ar(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new ke(fe(i,Ue(s.store,i)),u,u&&u.lastId,d,d&&d.id,e,null,new Je(l,a)),n.right.integrate(t,0),n.forward()}}return o},wd=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;jv(n,s);const l=$v(t,e,n,s),a=r.constructor===String?new cn(r):r instanceof nt?new hn(r):new as(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Eo(e._searchMarker,n.index,a.getLength()),u=new ke(fe(o,Ue(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),Pv(t,e,n,l)},Fy=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;jv(n,s);const l=$v(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Je));){if(!n.right.deleted)switch(n.right.content.constructor){case Je:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(ar(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&_t(t,fe(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
164
164
  `;n.right=new ke(fe(o,Ue(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new cn(a)),n.right.integrate(t,0),n.forward()}Pv(t,e,n,l)},Bv=(t,e,n,r,s)=>{let i=e;const o=sn();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Je){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;if(c.constructor===Je){const{key:u,value:d}=c,h=r.get(u)??null;(o.get(u)!==c||h===d)&&(e.delete(t),l++,!a&&(s.get(u)??null)===d&&h!==d&&(h===null?s.delete(u):s.set(u,h))),!a&&!e.deleted&&oi(s,c)}}e=e.right}return l},JP=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Je){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},GP=t=>{let e=0;return Se(t.doc,n=>{let r=t._start,s=t._start,i=sn();const o=xh(i);for(;s;)s.deleted===!1&&(s.content.constructor===Je?oi(o,s.content):(e+=Bv(n,r,s,i,o),i=xh(o),r=s)),s=s.right}),e},YP=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&wv(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Je&&o.constructor!==Kt&&e.add(o.parent)})}Se(n,r=>{xr(t,t.deleteSet,s=>{if(s instanceof Kt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Je?e.add(i):JP(r,s)});for(const s of e)GP(s)})},Uy=(t,e,n)=>{const r=n,s=xh(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case hn:case as:case cn:n<e.right.length&&_t(t,fe(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Bv(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Eo(o._searchMarker,e.index,-r+n),e};class XP extends Yc{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}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,n=[];Se(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,m)=>{p!==null&&(f.attributes[m]=p)}))),c="";break;case"retain":u>0&&(f={retain:u},s2(a)||(f.attributes=n2({},a))),u=0;break}f&&n.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case hn:case as:this.adds(o)?this.deletes(o)||(h(),l="insert",c=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case cn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=o.length);break;case Je:{const{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=s.get(f)??null;ar(m,p)?p!==null&&o.delete(r):(l==="retain"&&h(),ar(p,i.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(o)){i.set(f,p);const m=s.get(f)??null;ar(m,p)||(l==="retain"&&h(),a[f]=m)}else if(!o.deleted){i.set(f,p);const m=a[f];m!==void 0&&(ar(m,p)?m!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}o.deleted||(l==="insert"&&h(),oi(s,o.content));break}}o=o.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class wr extends nt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ft(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new wr}clone(){const e=new wr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new XP(this,e,n);Zc(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ft();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===cn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Se(this.doc,r=>{const s=new Rh(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
165
165
  `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&wd(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Fy(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Uy(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??ft();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let h=!1;i.forEach((p,m)=>{h=!0,d[m]=p});const f={insert:l};h&&(f.attributes=d),s.push(f),l=""}}const u=()=>{for(;a!==null;){if(Nr(a,e)||n!==void 0&&Nr(a,n))switch(a.content.constructor){case cn:{const d=i.get("ychange");e!==void 0&&!Nr(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!Nr(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case hn:case as:{c();const d={insert:a.content.getContent()[0]};if(i.size>0){const h={};d.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(d);break}case Je:Nr(a,e)&&(c(),oi(i,a.content));break}a=a.right}c()};return e||n?Se(o,d=>{e&&Th(d,e),n&&Th(d,n),u()},"cleanup"):u(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Se(s,i=>{const o=Ol(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),wd(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Se(s,i=>{const o=Ol(i,this,e,!r);wd(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Se(r,s=>{Uy(s,Ol(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Se(s,i=>{const o=Ol(i,this,e,!1);o.right!==null&&Fy(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Se(this.doc,n=>{sc(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Se(this.doc,r=>{bp(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return xp(this,e)}getAttributes(){return Lv(this)}_write(e){e.writeTypeRef(yj)}}const ZP=t=>new wr;class vd{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ft()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===St||n.constructor===es)&&n._start!==null)e=n._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 es extends nt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new es}clone(){const e=new es;return e.insert(0,this.toArray().map(n=>n instanceof nt?n.clone():n)),e}get length(){return this.doc??ft(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new vd(this,e)}querySelector(e){e=e.toUpperCase();const r=new vd(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Qr(new vd(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Zc(this,e,new tj(this,n,e))}toString(){return Nv(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Ao(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Se(this.doc,r=>{Ov(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Se(this.doc,r=>{const s=e&&e instanceof nt?e._item:e;rc(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw Cn("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Se(this.doc,r=>{Dv(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Mv(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Rv(this,e)}slice(e=0,n=this.length){return Av(this,e,n)}forEach(e){Ao(this,e)}_write(e){e.writeTypeRef(xj)}}const QP=t=>new es;class St extends es{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,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new St(this.nodeName)}clone(){const e=new St(this.nodeName),n=this.getAttributes();return r2(n,(r,s)=>{e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof nt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Se(this.doc,n=>{sc(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Se(this.doc,r=>{bp(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return xp(this,e)}hasAttribute(e){return Iv(this,e)}getAttributes(e){return e?UP(this,e):Lv(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return Ao(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(bj),e.writeKey(this.nodeName)}}const ej=t=>new St(t.readKey());class tj extends Yc{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class ic extends Gs{constructor(e){super(),this.hookName=e}_copy(){return new ic(this.hookName)}clone(){const e=new ic(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(wj),e.writeKey(this.hookName)}}const nj=t=>new ic(t.readKey());class Bt extends wr{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 Bt}clone(){const e=new Bt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(vj)}}const rj=t=>new Bt;class wp{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Yt()}mergeWith(e){return!1}write(e,n,r){throw Yt()}integrate(e,n){throw Yt()}}const sj=0;class Kt extends wp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),xv(e.doc.store,this)}write(e,n){e.writeInfo(sj),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Fo{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Fo(this.content)}splice(e){throw Yt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const ij=t=>new Fo(t.readBuf());class Mo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Mo(this.len)}splice(e){const n=new Mo(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ko(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const oj=t=>new Mo(t.readLen()),zv=(t,e)=>new ls({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Uo{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 n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Uo(zv(this.doc.guid,this.opts))}splice(e){throw Yt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,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,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const lj=t=>new Uo(zv(t.readString(),t.readAny()));class as{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new as(this.embed)}splice(e){throw Yt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const aj=t=>new as(t.readJSON());class Je{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Je(this.key,this.value)}splice(e){throw Yt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const cj=t=>new Je(t.readKey(),t.readJSON());class oc{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new oc(this.arr)}splice(e){const n=new oc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const uj=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new oc(n)},dj=Za("node_env")==="development";class ts{constructor(e){this.arr=e,dj&&z1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ts(this.arr)}splice(e){const n=new ts(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const hj=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ts(n)};class cn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new cn(this.str)}splice(e){const n=new cn(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)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const fj=t=>new cn(t.readString()),pj=[WP,KP,ZP,ej,QP,nj,rj],mj=0,gj=1,yj=2,bj=3,xj=4,wj=5,vj=6;class hn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new hn(this.type._copy())}splice(e){throw Yt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.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 n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.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,n){this.type._write(e)}getRef(){return 7}}const kj=t=>new hn(pj[t.readTypeRef()](t)),_h=(t,e)=>{let n=e,r=0,s;do r>0&&(n=fe(n.client,n.clock+r)),s=Rs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof ke);return{item:s,diff:r}},vp=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},lc=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new ke(fe(r,s+n),e,fe(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=fe(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Vy=(t,e)=>ep(t,n=>ii(n.deletions,e)),Hv=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return _t(t,c);let u=e.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Hv(t,u,n,r,s,i)===null))return null;for(;u.redone!==null;)u=_t(t,u.redone)}const f=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,h=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:_t(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:_t(t,b.redone);if(b!==null&&b.parent._item===u){h=b;break}h=h.right}}else{if(h=null,e.right&&!s){for(d=e;d!==null&&d.right!==null&&(d.right.redone||ii(r,d.right.id)||Vy(i.undoStack,d.right.id)||Vy(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=_t(t,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(e.parentSub)||null;d!==null&&d.parent._item!==u&&(d=f._map.get(e.parentSub)||null)}const p=Ue(l,a),m=fe(a,p),y=new ke(m,d,d&&d.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=m,vp(y,!0),y.integrate(t,0),y};class ke extends wp{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?by:0}set marker(e){(this.info&hd)>0!==e&&(this.info^=hd)}get marker(){return(this.info&hd)>0}get keep(){return(this.info&yy)>0}set keep(e){this.keep!==e&&(this.info^=yy)}get countable(){return(this.info&by)>0}get deleted(){return(this.info&dd)>0}set deleted(e){this.deleted!==e&&(this.info^=dd)}markDeleted(){this.info|=dd}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ue(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ue(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ns&&this.id.client!==this.parent.client&&this.parent.clock>=Ue(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Ly(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=_t(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Kt||this.right&&this.right.constructor===Kt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ke?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ke&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ns){const r=Rs(n,this.parent);r.constructor===Kt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Ly(e,e.doc.store,fe(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Nl(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Nl(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Rs(e.doc.store,s.origin)))i.has(Rs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.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),xv(e.doc.store,this),this.content.integrate(e,this),Py(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Kt(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:fe(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Nl(e.origin,this.lastId)&&this.right===e&&Nl(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 n=this.parent._searchMarker;return n&&n.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 n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ko(e.deleteSet,this.id.client,this.id.clock,this.length),Py(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Mt();this.content.gc(e),n?MP(e,this,new Kt(this.id,this.length)):this.content=new Mo(this.length)}write(e,n){const r=n>0?fe(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Bc|(r===null?0:Ct)|(s===null?0:Hn)|(i===null?0:yo);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=So(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===Ns?(e.writeParentInfo(!1),e.writeLeftID(l)):Mt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Fv=(t,e)=>Sj[e&Bc](t),Sj=[()=>{Mt()},oj,uj,ij,fj,aj,cj,kj,hj,lj,()=>{Mt()}],Cj=10;class nn extends wp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Mt()}write(e,n){e.writeInfo(Cj),be(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Uv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vv="__ $YJS$ __";Uv[Vv]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Uv[Vv]=!0;const Ej=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},Aj=/[\uD800-\uDBFF]/,Mj=/[\uDC00-\uDFFF]/,Tj=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&Aj.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&Mj.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Nj=Tj,vn=(t,e)=>t>>>e|t<<32-e,Rj=t=>vn(t,2)^vn(t,13)^vn(t,22),_j=t=>vn(t,6)^vn(t,11)^vn(t,25),Oj=t=>vn(t,7)^vn(t,18)^t>>>3,Dj=t=>vn(t,17)^vn(t,19)^t>>>10,Lj=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ij=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class Pj{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Ij),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=Dj(n[d-2])+n[d-7]+Oj(n[d-15])+n[d-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],u=e[7];for(let d=0,h,f;d<64;d++)h=u+_j(l)+(l&a^~l&c)+Lj[d]+n[d]>>>0,f=Rj(r)+(r&s^r&i^s&i)>>>0,u=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=Ct<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=Ct<<(3-n%4)*8),this._W[14]=e.byteLength/mI,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const jj=t=>new Pj().digest(t),Oe=new ye("y-sync"),Fn=new ye("y-undo");new ye("yjs-cursor");const $j=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},Bj=t=>p2($j(jj(m2(t)))),ac=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!ii(e.ds,t.id),zj=[{light:"#ecd44433",dark:"#ecd444"}],Hj=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Zr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,JI(e))}return t.get(n)},Fj=(t,{colors:e=zj,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new qj(t,i),a=new pe({props:{editable:c=>{const u=Oe.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Oe,state:{init:(c,u)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(Oe);if(d!==void 0){u=Object.assign({},u);for(const h in d)u[h]=d[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&iv(0,()=>{l.prosemirrorView!=null&&(d.restore==null?l._renderSnapshot(d.snapshot,d.prevSnapshot,u):(l._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const u=a.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=Fn.getState(c.state),h=d&&d.undoManager;h&&h.stopCapturing()}l.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(c.state.doc)},Oe)})}},destroy:()=>{l.destroy()}})});return a},Uj=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new xn(t.doc));else if(e.type==="node"){const r=Rr(n.doc,n.type,e.anchor,n.mapping);r!==null&&t.setSelection(Vj(t,r))}else if(e.type==="nodeRange"){const r=Rr(n.doc,n.type,e.anchor,n.mapping),s=Rr(n.doc,n.type,e.head,n.mapping),i=Wj(t,r,s,e.depth);i!==null&&t.setSelection(i)}else{const r=Rr(n.doc,n.type,e.anchor,n.mapping),s=Rr(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(X.between(t.doc.resolve(r),t.doc.resolve(s)))}},Vj=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?Z.create(t.doc,e):X.near(n)},Wj=(t,e,n,r)=>{if(e===null||n===null)return null;const s=Math.min(Math.max(e,0),t.doc.content.size),i=Math.min(Math.max(n,0),t.doc.content.size);try{const o=te.fromJSON(t.doc,{type:"nodeRange",anchor:s,head:i,depth:r});return o.ranges.length?o:X.near(t.doc.resolve(s))}catch{return X.near(t.doc.resolve(s))}},Oh=(t,e)=>{const n=e.selection.jsonID;return{type:n,depth:n==="nodeRange"?e.selection.depth:void 0,anchor:uc(e.selection.anchor,t.type,t.mapping),head:uc(e.selection.head,t.type,t.mapping)}};class qj{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=Ej(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Oh(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(H1&&this._domSelectionInView===null&&(iv(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=Ho.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=yv(fv(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Oe,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Ql(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new H(P.from(e),0,0));n.setMeta(Oe,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Ql(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new H(P.from(n),0,0));if(e){const s=Ws(br(e.anchor,0),r.doc.content.size),i=Ws(br(e.head,0),r.doc.content.size);r.setSelection(X.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Oe,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=xd(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Mt(),s=new ls({gc:!1}),Mh(s,n),n=xd(s),Mh(s,e),e=xd(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=an(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(d=>{xr(o,d,h=>{})});const a=(d,h)=>{const f=d==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:d,color:Hj(r.colorMapping,r.colors,f)}},c=Tv(i,new gp(n.ds,e.sv)).map(d=>!d._item.deleted||ac(d._item,e)||ac(d._item,n)?Ql(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new H(P.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(Oe,{isChangeOrigin:!0}))},Oe)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Oe.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);xr(n,n.deleteSet,l=>{if(l.constructor===ke){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(l=>Wv(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new H(P.from(i),0,0));Uj(o,this.beforeTransactionSelection,this),o=o.setMeta(Oe,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof kv}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Lh(this.doc,this.type,e,this),this.beforeTransactionSelection=Oh(this,this.prosemirrorView.state)},Oe)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Wv=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof St)return Ql(t,e,n,r,s,i);throw Yt()}return o},Ql=(t,e,n,r,s,i)=>{const o=[],l=a=>{if(a instanceof St){const c=Wv(a,e,n,r,s,i);c!==null&&o.push(c)}else{const c=a._item.right?.content?.type;c instanceof wr&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(d=>{c._item.delete(d)}));const u=Kj(a,e,n,r,s,i);u!==null&&u.forEach(d=>{d!==null&&o.push(d)})}};r===void 0||s===void 0?t.toArray().forEach(l):Tv(t,new gp(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(ac(t._item,r)?ac(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Oe),n.mapping.delete(t),null}},Kj=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,Qj(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Oe),null}return o},Jj=(t,e)=>{const n=new Bt,r=t.map(s=>({insert:s.text,attributes:Jv(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},Gj=(t,e)=>{const n=new St(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Qc(t).map(r=>Dh(r,e))),e.mapping.set(n,t),n},Dh=(t,e)=>t instanceof Array?Jj(t,e):Gj(t,e),Wy=t=>typeof t=="object"&&t!==null,kp=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Wy(o)&&Wy(l)&&kp(o,l)}return r},Qc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},qv=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&B1(r.attributes||{}).length===e[s].marks.length&&ni(r.attributes,(i,o)=>{const l=Kv(o),a=e[s].marks;return a.find(u=>u.type.name===l)?kp(i,a.find(u=>u.type.name===l)?.attrs):!1}))},To=(t,e)=>{if(t instanceof St&&!(e instanceof Array)&&Ih(t,e)){const n=Qc(e);return t._length===n.length&&kp(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>To(r,n[s]))}return t instanceof Bt&&e instanceof Array&&qv(t,e)},cc=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),qy=(t,e,n)=>{const r=t.toArray(),s=Qc(e),i=s.length,o=r.length,l=Ws(o,i);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],h=s[a];if(cc(n.mapping.get(d),h))u=!0;else if(!To(d,h))break}for(;a+c<l;c++){const d=r[o-c-1],h=s[i-c-1];if(cc(n.mapping.get(d),h))u=!0;else if(!To(d,h))break}return{equalityFactor:a+c,foundMappedChild:u}},Yj=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof cn?e+=n.content.str:n.content instanceof Je&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},Xj=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=Yj(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Jv(c.marks,n))})),{insert:o,remove:l,index:a}=Nj(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Zj=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Kv=t=>Zj.exec(t)?.[1]??t,Qj=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(Kv(r),t[r]));return n},Jv=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=qn(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${Bj(r.toJSON())}`:r.type.name]=r.attrs}}),n},Lh=(t,e,n,r)=>{if(e instanceof St&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof St){const d=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?d[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in d)h[f]===void 0&&e.removeAttribute(f)}const s=Qc(n),i=s.length,o=e.toArray(),l=o.length,a=Ws(i,l);let c=0,u=0;for(;c<a;c++){const d=o[c],h=s[c];if(!cc(r.mapping.get(d),h))if(To(d,h))r.mapping.set(d,h);else break}for(;u+c+1<a;u++){const d=o[l-u-1],h=s[i-u-1];if(!cc(r.mapping.get(d),h))if(To(d,h))r.mapping.set(d,h);else break}t.transact(()=>{for(;l-c-u>0&&i-c-u>0;){const h=o[c],f=s[c],p=o[l-u-1],m=s[i-u-1];if(h instanceof Bt&&f instanceof Array)qv(h,f)||Xj(h,f,r),c+=1;else{let y=h instanceof St&&Ih(h,f),b=p instanceof St&&Ih(p,m);if(y&&b){const w=qy(h,f,r),k=qy(p,m,r);w.foundMappedChild&&!k.foundMappedChild?b=!1:!w.foundMappedChild&&k.foundMappedChild||w.equalityFactor<k.equalityFactor?y=!1:b=!1}y?(Lh(t,h,f,r),c+=1):b?(Lh(t,p,m,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[Dh(f,r)]),c+=1)}}const d=l-c-u;if(l===1&&i===0&&o[0]instanceof Bt?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(h=>r.mapping.delete(h)),e.delete(c,d)),c+u<i){const h=[];for(let f=c;f<i-u;f++)h.push(Dh(s[f],r));e.insert(c,h)}},Oe)},Ih=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,uc=(t,e,n)=>{if(t===0)return bd(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Bt){if(r._length>=t)return bd(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new nc(r._item===null?null:r._item.id,r._item===null?So(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new nc(r._item===null?null:r._item.id,r._item===null?So(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Mt();if(t===0&&r.constructor!==Bt&&r!==e)return e$(r._item.parent,r._item)}return bd(e,e._length,-1)},e$=(t,e)=>{let n=null,r=null;return t._item===null?r=So(t):n=fe(t._item.id.client,t._item.id.clock),new nc(n,r,e.id)},Rr=(t,e,n,r)=>{const s=EP(n,t);if(s===null||s.type!==e&&!Co(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Bt)o=s.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;if(a++,c instanceof Bt)o+=c._length;else{const u=r.get(c);if(u==null)return null;o+=u.nodeSize}}l=l.right}o+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){o+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;if(!a.deleted)if(c instanceof Bt)o+=c._length;else{const u=r.get(c);if(u==null)return null;o+=u.nodeSize}a=a.right}}i=l}return o-1},t$=t=>{const e=Fn.getState(t).undoManager;if(e!=null)return e.undo(),!0},n$=t=>{const e=Fn.getState(t).undoManager;if(e!=null)return e.redo(),!0},r$=new Set(["paragraph"]),s$=(t,e)=>!(t instanceof ke)||!(t.content instanceof hn)||!(t.content.type instanceof wr||t.content.type instanceof St&&e.has(t.content.type.nodeName))||t.content.type._length===0,i$=({protectedNodes:t=r$,trackedOrigins:e=[],undoManager:n=null}={})=>new pe({key:Fn,state:{init:(r,s)=>{const i=Oe.getState(s);let o=n;if(!o){const l=i.doc,a=new Set(l?l._observers.get("destroy"):[]);o=new kv(i.type,{trackedOrigins:new Set([Oe].concat(e)),deleteFilter:u=>s$(u,t),captureTransaction:u=>u.meta.get("addToHistory")!==!1});const c=l?l._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(c||[]).filter(u=>!a.has(u))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Oe.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:Oh(l,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Oe.getState(r.state),i=Fn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Fn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy();const o=i._yTiptapDocDestroyListeners;o&&i.doc&&(o.forEach(l=>i.doc.off("destroy",l)),i._yTiptapDocDestroyListeners=null)}}}});function Sp(t){return!!t.getMeta(Oe)}function o$(t,e){const n=Oe.getState(t);return Rr(n.doc,n.type,e,n.binding.mapping)||0}function Gv(t,e){const n=Oe.getState(t);return uc(e,n.type,n.binding.mapping)}var ea=class Yv extends vf{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new Yv(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function l$(t,e){const n=Gv(e,t);return new ea(t,n)}function a$(t,e,n){const r=t instanceof ea?t.yRelativePosition:null;if(Sp(e)&&r){const o=o$(n,r);return{position:new ea(o,r),mapResult:null}}const s=Ax(t,e),i=s.position.position;return{position:new ea(i,r??Gv(n,i)),mapResult:s.mapResult}}ue.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>a$(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>l$(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Fn.getState(e).undoManager.undoStack.length===0?!1:n?t$(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Fn.getState(e).undoManager.redoStack.length===0?!1:n?n$(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=i$(this.options.yUndoOptions),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=Fn.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const l=n?n(i):void 0;return{destroy:()=>{const a=o.trackedOrigins.has(o),c=o._observers;o.restore=()=>{a&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=c},l?.destroy&&l.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[Fj(t,r),e,this.editor.options.enableContentCheck&&new pe({key:new ye("filterInvalidContent"),filterTransaction:i=>{if(!Sp(i))return!0;if(this.storage.isDisabled)return!1;if(!i.docChanged)return!0;try{return i.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy()}}),!0}}})].filter(Boolean)}});function Ky(t){if(!t.length)return xe.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(Ne.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),xe.create(n,e)}function c$(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}function eu(t,e,n,r={}){const s=[],i=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const l=new no(t,e,n),a=l.depth===0?0:i.resolve(l.start).posAtIndex(0);return l.parent.forEach((c,u)=>{const d=a+u,h=d+c.nodeSize,f=c$(d,c.nodeSize,c),p=o?e.pos>=f.start&&t.pos<=f.end:e.pos>f.start&&t.pos<f.end;if(d<l.start||d>=l.end||!p)return;const m=new Zh(i.resolve(d),i.resolve(h));s.push(m)}),s}var u$=class Xv{constructor(e,n,r){this.anchor=e,this.head=n,this.depth=r??0}map(e){return new Xv(e.map(this.anchor),e.map(this.head),this.depth)}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new bn(n,r,this.depth)}},bn=class nr extends te{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,u=eu(c.min(a),c.max(a),r),d=a.pos>=e.pos?u[0].$from:u[u.length-1].$to,h=a.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,h,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof nr&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new nr(r,s,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new nr(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new nr(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new nr(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new nr(this.$anchor,r,this.depth)}static fromJSON(e,n){return new nr(e.resolve(n.anchor),e.resolve(n.head),n.depth)}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new u$(this.anchor,this.head,this.depth)}};bn.prototype.visible=!1;try{te.jsonID("nodeRange",bn)}catch{}function Ii(t){return t instanceof bn}var d$=ue.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Ii(i)){const u=bn.create(s,l,a,e,-1);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Ii(i)){const u=bn.create(s,l,a,e);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=bn.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Ii(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new pe({key:new ye("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,u=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:h,selection:f,tr:p}=d,{$anchor:m,$head:y}=f;if(m.sameParent(y))return;const b=bn.create(h,m.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=Ii(r);if(t=!1,!e)return s?(t=!0,Ky(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=eu(i,o,this.options.depth);return l.length?(t=!0,Ky(l)):null}}})]}}),h$=d$;function f$(t,e){const n=getComputedStyle(t);if(e)return e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>`${s}:${n.getPropertyValue(s)};`).join("");let r="";for(let s=0;s<n.length;s+=1)r+=`${n[s]}:${n.getPropertyValue(n[s])};`;return r}function p$(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((i,o)=>{s[o].style.cssText=f$(i,e)}),n}var m$={id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},g$={id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=["listItem","taskItem"],n=t.firstChild;return n&&e.includes(n.type.name)?1e3:0}},y$={id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&e.type.name==="tableHeader"?1e3:0},b$={id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0},x$=[m$,g$,y$,b$],Jy={edges:["left","top"],threshold:12,strength:500};function kd(t){return t===void 0||t==="left"?{...Jy}:t==="right"?{edges:["right","top"],threshold:12,strength:500}:t==="both"?{edges:["left","right","top"],threshold:12,strength:500}:t==="none"?{edges:[],threshold:0,strength:0}:{...Jy,...t}}function w$(t,e,n){if(n.edges.length===0)return!1;const r=e.getBoundingClientRect(),{threshold:s,edges:i}=n;return i.some(o=>o==="left"?t.x-r.left<s:o==="right"?r.right-t.x<s:o==="top"?t.y-r.top<s:o==="bottom"?r.bottom-t.y<s:!1)}function v$(t,e,n,r){return!e||n.edges.length===0?0:w$(t,e,n)?n.strength*r:0}var k$=1e3;function Gy(t,e,n,r){let s=k$,i=!1;if(e.every(l=>{const a=l.evaluate(t);return s-=a,s<=0?(i=!0,!1):!0}),i)return-1;const o=t.view.nodeDOM(t.pos);return s-=v$(r,o,n,t.depth),s<=0?-1:s}function Yy(t,e,n){return Array.from({length:e},(s,i)=>e-1-i).some(s=>n.includes(t.node(s).type.name))}function S$(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:s}=t.state,i=s.resolve(r.pos),o=[];n.defaultRules&&o.push(...x$),o.push(...n.rules);const a=Array.from({length:i.depth},(d,h)=>i.depth-h).map(d=>{const h=i.node(d),f=i.before(d);if(n.allowedContainers&&d>0&&!Yy(i,d,n.allowedContainers))return null;const p=d>0?i.node(d-1):null,m=d>0?i.index(d-1):0,y=p?p.childCount:1,b={node:h,pos:f,depth:d,parent:p,index:m,isFirst:m===0,isLast:m===y-1,$pos:i,view:t},w=Gy(b,o,n.edgeDetection,e);if(w<0)return null;const k=t.nodeDOM(f);return{node:h,pos:f,depth:d,score:w,dom:k}}).filter(d=>d!==null),c=i.nodeAfter;if(c&&c.isAtom&&!c.isInline){const d=r.pos,h=i.depth+1,f=i.parent,p=i.index(),m=f.childCount;let y=!0;if(n.allowedContainers&&(y=Yy(i,h,n.allowedContainers)),y){const b={node:c,pos:d,depth:h,parent:f,index:p,isFirst:p===0,isLast:p===m-1,$pos:i,view:t},w=Gy(b,o,n.edgeDetection,e);if(w>=0){const k=t.nodeDOM(d);k&&a.push({node:c,pos:d,depth:h,score:w,dom:k})}}}if(a.length===0)return null;a.sort((d,h)=>h.score!==d.score?h.score-d.score:h.depth-d.depth);const u=a[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function C$(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function Xy(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function E$(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return null;const l=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(!Xy(l)||!Xy(a))return null;const c=Math.min(Math.max(l.top+r,n),a.bottom-r),u=.5,d=Math.abs(l.left-a.left)<u,h=Math.abs(l.right-a.right)<u;let f=l;d&&h&&(f=l);const p=Math.min(Math.max(f.left+r,e),f.right-r);return!Number.isFinite(p)||!Number.isFinite(c)?null:{x:p,y:c}}var Zv=t=>{const{x:e,y:n,editor:r,nestedOptions:s}=t,{view:i,state:o}=r,l=E$(i,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:a,y:c}=l;if(s?.enabled){const p=S$(i,{x:a,y:c},s);return p?{resultElement:p.dom,resultNode:p.node,pos:p.pos}:{resultElement:null,resultNode:null,pos:null}}const u=i.root.elementsFromPoint(a,c);let d;if(Array.prototype.some.call(u,p=>{if(!i.dom.contains(p))return!1;const m=C$(p,i);return m?(d=m,!0):!1}),!d){const p=i.posAtCoords({left:a,top:c});if(p){const m=o.doc.resolve(p.pos),y=Math.min(m.depth,1),b=y>0?m.before(y):m.pos,w=o.doc.nodeAt(b);if(w){const k=i.nodeDOM(b);return{resultElement:k instanceof HTMLElement?k:null,resultNode:w,pos:b}}}return{resultElement:null,resultNode:null,pos:null}}let h;try{h=i.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const f=o.doc.nodeAt(h);if(!f){const p=o.doc.resolve(h),m=p.parent;return{resultElement:d,resultNode:m,pos:p.start()}}return{resultElement:d,resultNode:f,pos:h}};function Qv(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:s}=t.domAtPos(e),i=r.childNodes[s];return i instanceof Element?i:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function A$(t,e){const n=Qv(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}function ek(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function M$(t,e){return t==="rtl"?e:0}function T$(t){return t?!t.some(e=>{const n=e.trim().toLowerCase();return n==="margin"||n.startsWith("margin-")}):!0}function N$(t,e,n,r){const{doc:s}=e.view.state;if(n?.enabled&&r?.node&&r.pos>=0){const c=r.pos,u=r.pos+r.node.nodeSize;return[{$from:s.resolve(c),$to:s.resolve(u)}]}const i=Zv({editor:e,x:t.clientX,y:t.clientY,nestedOptions:n});if(!i.resultNode||i.pos===null)return[];const o=i.resultNode.isText||i.resultNode.isAtom?0:-1,l=s.resolve(i.pos),a=s.resolve(i.pos+i.resultNode.nodeSize+o);return eu(l,a,0,{extendOnBoundaryOverlap:!1})}function R$(t,e,n,r,s){const{view:i}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:a}=i.state.selection,c=N$(t,e,n,r),u=eu(l,a,0,{extendOnBoundaryOverlap:!1}),d=u.some(D=>c.find(L=>L.$from===D.$from&&L.$to===D.$to)),h=o||!d?c:u;if(!h.length)return;const{tr:f}=i.state,p=document.createElement("div"),m=h[0].$from.pos,y=h[h.length-1].$to.pos,b=A$(i,m);p.setAttribute("dir",b);const w=n?.enabled&&r?.node,k=h.length===1;let x,M;w&&k?(x=i.state.doc.slice(m,y),M=Z.create(i.state.doc,m)):(M=bn.create(i.state.doc,m,y),x=M.content());const v=T$(s);h.forEach(D=>{const L=Qv(i,D.$from.pos);if(!L)return;const I=p$(L,s);v&&(I.style.margin="0"),p.append(I)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),t.dataTransfer.clearData();const E=p.getBoundingClientRect(),A=M$(b,E.width);t.dataTransfer.setDragImage(p,A,0);let C=!1;const O=()=>{C||(C=!0,ek(p),document.removeEventListener("drop",O),document.removeEventListener("dragend",O))},B=M instanceof Z?M:void 0;i.dragging={slice:x,move:!0,node:B},f.setSelection(M),i.dispatch(f),document.addEventListener("drop",O),document.addEventListener("dragend",O)}function Zy(t,e,n){let r=0;for(let s=e;s<n;s+=1)r+=t.child(s).nodeSize;return r}function _$(t){var e;return Ii(t)?{anchorPos:t.from,nodeCount:t.ranges.length,depth:(e=t.depth)!=null?e:0}:null}function O$(t,e,n,r){const s=t.resolve(e),i=s.node(r);let o=s.index(r);o>=i.childCount&&(o=Math.max(0,i.childCount-n));const l=Math.min(n,i.childCount-o);if(l<=0)return null;const a=s.start(r)+Zy(i,0,o),c=a+Zy(i,o,o+l);return{anchor:a,head:c,count:l}}function D$(t,e,n,r){try{const s=O$(t,e,n,r);if(!s)return null;const i=bn.create(t,s.anchor,s.head,r);return i.ranges.length===n?i:null}catch{return null}}var Qy=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},eb=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Sd=(t,e)=>{const n=Oe.getState(t);return n?uc(e,n.type,n.binding.mapping):null},L$=(t,e)=>{const n=Oe.getState(t);return n?Rr(n.doc,n.type,e,n.binding.mapping)||0:-1},tb=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},tk=new ye("dragHandle"),nk=({pluginKey:t=tk,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,nestedOptions:a,dragImageProperties:c})=>{const u=document.createElement("div");let d=!1,h=null,f=-1,p,m=null,y=null,b=null,w=null,k=null;function x(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function M(){if(e){if(!n.isEditable){x();return}e.style.visibility="",e.style.pointerEvents="auto"}}function v(D){const L=s?.()||{getBoundingClientRect:()=>D.getBoundingClientRect()};Dc(L,e,r).then(I=>{Object.assign(e.style,{position:I.strategy,left:`${I.x}px`,top:`${I.y}px`})})}function E(D){o?.(D),R$(D,n,a,{node:h,pos:f},c),w=_$(n.state.selection),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function A(D){l?.(D),w=null,x(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function C({nodeCount:D,depth:L,anchorPos:I}){const V=D$(n.state.doc,I,D,L);V&&n.view.dispatch(n.state.tr.setSelection(V))}function O(D){if(!(!D.target||!n.view.dom.contains(D.target))){if(CT()){const L=n.view.dom;requestAnimationFrame(()=>{L.isContentEditable&&(L.contentEditable="false",L.contentEditable="true")})}!w||n.view.state.selection.empty||(k={...w,anchorPos:n.state.selection.from},y=requestAnimationFrame(()=>{y=null,k&&(C(k),k=null)}))}}function B(){e.removeEventListener("dragstart",E),e.removeEventListener("dragend",A),document.removeEventListener("drop",O),m&&(cancelAnimationFrame(m),m=null,b=null),y&&(cancelAnimationFrame(y),y=null)}return u.appendChild(e),{unbind(){B()},plugin:new pe({key:typeof t=="string"?new ye(t):t,state:{init(){return{locked:!1}},apply(D,L,I,V){if(k&&D.docChanged){const _=D.mapping.mapResult(k.anchorPos,1);_.deleted?k=null:k.anchorPos=_.pos}const q=D.getMeta("lockDragHandle"),ne=D.getMeta("hideDragHandle");if(q!==void 0&&(d=q),ne)return x(),d=!1,h=null,f=-1,i?.({editor:n,node:null,pos:-1}),L;if(D.docChanged&&f!==-1&&e)if(Sp(D)){const _=L$(V,p);_!==f&&(f=_)}else{const _=D.mapping.map(f);_!==f&&(f=_,p=Sd(V,f))}return L}},view:D=>{var L;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(L=n.view.dom.parentElement)==null||L.appendChild(u),u.style.pointerEvents="none",u.style.position="absolute",u.style.top="0",u.style.left="0",e.addEventListener("dragstart",E),e.addEventListener("dragend",A),document.addEventListener("drop",O),{update(I,V){if(!e)return;if(!n.isEditable){x();return}if(d?e.draggable=!1:e.draggable=!0,D.state.doc.eq(V.doc)||f===-1)return;let q=D.nodeDOM(f);if(q=tb(D,q),q===D.dom||q?.nodeType!==1)return;const ne=D.posAtDOM(q,0),_=eb(n.state.doc,ne),U=Qy(n.state.doc,ne);h=_,f=U,p=Sd(D.state,f),i?.({editor:n,node:h,pos:f}),v(q)},destroy(){B(),e&&ek(u)}}},props:{handleDOMEvents:{keydown(D){return!e||d||D.hasFocus()&&(x(),h=null,f=-1,i?.({editor:n,node:null,pos:-1})),!1},mouseleave(D,L){return d||L.target&&!u.contains(L.relatedTarget)&&(x(),h=null,f=-1,i?.({editor:n,node:null,pos:-1})),!1},mousemove(D,L){return!e||d||(b={x:L.clientX,y:L.clientY},m)||(m=requestAnimationFrame(()=>{if(m=null,!b)return;const{x:I,y:V}=b;b=null;const q=Zv({x:I,y:V,editor:n,nestedOptions:a});if(!q.resultElement)return;let ne=q.resultElement,_=q.resultNode,U=q.pos;if(!a?.enabled){if(ne=tb(D,ne),ne===D.dom||ne?.nodeType!==1)return;const le=D.posAtDOM(ne,0);_=eb(n.state.doc,le),U=Qy(n.state.doc,le)}_!==h&&(h=_,f=U??-1,p=Sd(D.state,f),i?.({editor:n,node:h,pos:f}),v(ne),M())})),!1}}}})}};function rk(t){var e,n;return t===!1||t===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:kd("none")}:t===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:kd("left")}:{enabled:!0,rules:(e=t.rules)!=null?e:[],defaultRules:(n=t.defaultRules)!=null?n:!0,allowedContainers:t.allowedContainers,edgeDetection:kd(t.edgeDetection)}}var Ph={placement:"left-start",strategy:"absolute"},I$=ue.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=rk(this.options.nested);return[nk({computePositionConfig:{...Ph,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}}),P$=I$;function j$(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},w=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],k=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],x=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],M=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:y,built_in:[...w,...k,"set","shopt",...x,...M]},contains:[f,t.SHEBANG(),p,d,i,o,b,l,a,c,u,n]}}const $$=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),B$=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],z$=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],H$=[...B$,...z$],F$=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),U$=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),V$=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),W$=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function q$(t){const e=t.regex,n=$$(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+U$.join("|")+")"},{begin:":(:)?("+V$.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+W$.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:F$.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+H$.join("|")+")\\b"}]}}const nb="[A-Za-z$_][0-9A-Za-z$_]*",K$=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],J$=["true","false","null","undefined","NaN","Infinity"],sk=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],ik=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],ok=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],G$=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Y$=[].concat(ok,sk,ik);function X$(t){const e=t.regex,n=(_,{after:U})=>{const le="</"+_[0].slice(1);return _.input.indexOf(le,U)!==-1},r=nb,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(_,U)=>{const le=_[0].length+_.index,N=_.input[le];if(N==="<"||N===","){U.ignoreMatch();return}N===">"&&(n(_,{after:le})||U.ignoreMatch());let K;const ae=_.input.substring(le);if(K=ae.match(/^\s*=/)){U.ignoreMatch();return}if((K=ae.match(/^\s+extends\s+/))&&K.index===0){U.ignoreMatch();return}}},l={$pattern:nb,keyword:K$,literal:J$,built_in:Y$,"variable.language":G$},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},k=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,{match:/\$\d+/},d];h.contains=k.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(k)});const x=[].concat(w,h.contains),M=x.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(x)}]),v={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},E={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},A={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...sk,...ik]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},O={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function D(_){return e.concat("(?!",_.join("|"),")")}const L={match:e.concat(/\b/,D([...ok,"super","import"].map(_=>`${_}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:A},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,w,{match:/\$\d+/},d,A,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},O,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},L,B,E,V,{match:/\$[(.]/}]}}function Z$(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Q$(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},u={begin:/\{\{/,relevance:0},d={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,u,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${p})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${p})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${p})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${p})`},{begin:`\\b(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,m,d,t.HASH_COMMENT_MODE]}]};return c.contains=[d,m,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},d,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,b,d]}]}}function eB(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],c=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],u=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],f=u,p=[...c,...a].filter(M=>!u.includes(M)),m={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function w(M){return e.concat(/\b/,e.either(...M.map(v=>v.replace(/\s+/,"\\s+"))),/\b/)}const k={scope:"keyword",match:w(h),relevance:0};function x(M,{exceptions:v,when:E}={}){const A=E;return v=v||[],M.map(C=>C.match(/\|\d+$/)||v.includes(C)?C:A(C)?`${C}|0`:C)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:x(p,{when:M=>M.length<3}),literal:i,type:l,built_in:d},contains:[{scope:"type",match:w(o)},k,b,m,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const dc="[A-Za-z$_][0-9A-Za-z$_]*",lk=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ak=["true","false","null","undefined","NaN","Infinity"],ck=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],uk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],dk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],hk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],fk=[].concat(dk,ck,uk);function tB(t){const e=t.regex,n=(_,{after:U})=>{const le="</"+_[0].slice(1);return _.input.indexOf(le,U)!==-1},r=dc,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(_,U)=>{const le=_[0].length+_.index,N=_.input[le];if(N==="<"||N===","){U.ignoreMatch();return}N===">"&&(n(_,{after:le})||U.ignoreMatch());let K;const ae=_.input.substring(le);if(K=ae.match(/^\s*=/)){U.ignoreMatch();return}if((K=ae.match(/^\s+extends\s+/))&&K.index===0){U.ignoreMatch();return}}},l={$pattern:dc,keyword:lk,literal:ak,built_in:fk,"variable.language":hk},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},k=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,{match:/\$\d+/},d];h.contains=k.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(k)});const x=[].concat(w,h.contains),M=x.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(x)}]),v={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},E={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},A={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...ck,...uk]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},O={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function D(_){return e.concat("(?!",_.join("|"),")")}const L={match:e.concat(/\b/,D([...dk,"super","import"].map(_=>`${_}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:A},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,w,{match:/\$\d+/},d,A,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},O,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},L,B,E,V,{match:/\$[(.]/}]}}function nB(t){const e=t.regex,n=tB(t),r=dc,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:dc,keyword:lk.concat(a),literal:ak,built_in:fk.concat(s),"variable.language":hk},u={className:"meta",begin:"@"+r},d=(m,y,b)=>{const w=m.contains.findIndex(k=>k.label===y);if(w===-1)throw new Error("can not find mode to replace");m.contains.splice(w,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(u);const h=n.contains.find(m=>m.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([u,i,o,f]),d(n,"shebang",t.SHEBANG()),d(n,"use_strict",l);const p=n.contains.find(m=>m.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function rB(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const rb={},sB="hljs-";function iB(t){const e=u1.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,u){const d=u||rb,h=typeof d.prefix=="string"?d.prefix:sB;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:oB,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,m=p.data;return m.language=f.language,m.relevance=f.relevance,p}function r(a,c){const d=(c||rb).subset||s();let h=-1,f=0,p;for(;++h<d.length;){const m=d[h];if(!e.getLanguage(m))continue;const y=n(m,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let u;for(u in a)Object.hasOwn(a,u)&&e.registerLanguage(u,a[u])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let u;for(u in a)if(Object.hasOwn(a,u)){const d=a[u];e.registerAliases(typeof d=="string"?d:[...d],{languageName:u})}}}function l(a){return!!e.getLanguage(a)}}class oB{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}var lB=YO;const aB=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},cB=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=aB(t);if(r==="heading"){const i=n.attrs.level??1;switch(i){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${i}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const i=s?.type.name;return i==="bulletList"?"Add a bullet...":i==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const i=n.attrs.language;return i?`Write ${i} code...`:"Write some code..."}if(r==="paragraph"){const i=s?.type.name;if(!i||i==="doc")return e}return r==="doc"?e:""},pk=lB.extend({addOptions(){return{...this.parent?.(),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,dataAttribute:"data-placeholder",placeholder:e=>cB(e)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const i=r.node(s);if(t.has(i.type.name))return!0}return!1};return[new pe({key:new ye("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:i}=r,o=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const u=i>=c&&i<=c+a.nodeSize,d=!a.isLeaf&&$s(a);if((u||!this.options.showOnlyCurrent)&&d){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:u}):this.options.placeholder,p=Ne.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});o.push(p)}return this.options.includeChildren}),o.length?xe.create(n,o):null}}})]}}),uB=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=S.useState(!1),{type:i,title:o,message:l,align:a,size:c,textAlign:u}=t.attrs,d={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return g.jsxs(Mf,{children:[g.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:g.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${d[i]||d.info} ${h[c]||h["fit-content"]} ${p[u]||p.left}`,children:[g.jsx("strong",{className:"font-bold block",children:o}),g.jsx("span",{children:l})]})}),r&&g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:g.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:m=>m.stopPropagation(),children:[g.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),g.jsx("input",{type:"text",id:"title",defaultValue:o,onBlur:m=>e({title:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),g.jsx("textarea",{id:"message",defaultValue:l,onBlur:m=>e({message:m.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),g.jsxs("select",{id:"type",defaultValue:i,onChange:m=>e({type:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"info",children:"Info"}),g.jsx("option",{value:"warning",children:"Warning"}),g.jsx("option",{value:"error",children:"Error"}),g.jsx("option",{value:"success",children:"Success"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),g.jsxs("select",{id:"align",defaultValue:a,onChange:m=>e({align:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),g.jsxs("select",{id:"size",defaultValue:c,onChange:m=>e({size:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"small",children:"Small"}),g.jsx("option",{value:"medium",children:"Medium"}),g.jsx("option",{value:"large",children:"Large"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),g.jsxs("select",{id:"textAlign",defaultValue:u,onChange:m=>e({textAlign:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]})]}),g.jsx("div",{className:"mt-6 flex justify-end",children:g.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},mk=_e.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",ge(t,{"data-alert-widget":""})]},addNodeView(){return Tf(uB)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),dB=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=S.useState(!1),{text:i,url:o,style:l,size:a,textAlign:c}=t.attrs,u={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},d={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return g.jsxs(Mf,{children:[g.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:g.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${u[l]} ${d[a]||d["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:i})}),r&&g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:g.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[g.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),g.jsx("input",{type:"text",id:"text",defaultValue:i,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),g.jsx("input",{type:"text",id:"url",defaultValue:o,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),g.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"primary",children:"Primary"}),g.jsx("option",{value:"secondary",children:"Secondary"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),g.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"fit-content",children:"Fit Content"}),g.jsx("option",{value:"full-width",children:"Full Width"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),g.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]})]}),g.jsx("div",{className:"mt-6 flex justify-end",children:g.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},gk=_e.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",ge(t,{"data-cta-widget":""})]},addNodeView(){return Tf(dB)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function hB(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=ST(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",h=s?"":c,f=a?new RegExp(`${d}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const m=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const k=m+y.index;let x=k+y[0].length;return a&&u.test(p.slice(x-1,x+1))&&(y[0]+=" ",x+=1),k<l.pos&&x>=l.pos?{range:{from:k,to:x},query:y[0].slice(n.length),text:y[0]}:null}function fB(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!n?.content)return!1;const r=n.content.textBetween(0,n.content.size,`
166
- `);return/\s/.test(r)}):!1}function pB(t){return()=>{const e=t.state.selection.$anchor.pos,n=t.view.coordsAtPos(e),{top:r,right:s,bottom:i,left:o}=n;try{return new DOMRect(o,r,s-o,i-r)}catch{return null}}}function mB(t,e,n,r){return n?()=>{const s=r.getState(t.state),i=s?.decorationId,o=e.dom.querySelector(`[data-decoration-id="${i}"]`);return o?.getBoundingClientRect()||null}:pB(t)}function gB({match:t,dismissedRange:e,state:n,transaction:r,editor:s,shouldResetDismissed:i,effectiveAllowSpaces:o}){return i?.({editor:s,state:n,range:e,match:t,transaction:r,allowSpaces:o})?!1:o?t.range.from===e.from:t.range.from===e.from&&!fB(r)}function yB({view:t,pluginKeyRef:e}){const n=t.state.tr.setMeta(e,{exit:!0});t.dispatch(n)}function bB({pluginKey:t,decorationTag:e,decorationClass:n,decorationContent:r,decorationEmptyClass:s,renderer:i,dispatchExit:o}){return{handleKeyDown(l,a){var c,u;const d=t.getState(l.state);return d.active?a.key==="Escape"||a.key==="Esc"?((c=i?.onKeyDown)==null||c.call(i,{view:l,event:a,range:d.range}),o(l),!0):((u=i?.onKeyDown)==null?void 0:u.call(i,{view:l,event:a,range:d.range}))||!1:!1},decorations(l){const a=t.getState(l),{active:c,range:u,decorationId:d,query:h}=a;if(!c)return null;const f=!h?.length,p=[n];return f&&p.push(s),xe.create(l.doc,[Ne.inline(u.from,u.to,{nodeName:e,class:p.join(" "),"data-decoration-id":d||void 0,"data-decoration-content":r})])}}}function xB({editor:t,char:e,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:i,findSuggestionMatch:o,allow:l,shouldShow:a,shouldKeepDismissed:c,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,h,f,p){const{isEditable:m}=t,{composing:y}=t.view,{selection:b}=d,{empty:w,from:k}=b,x={...h},M=d.getMeta(u);if(M&&M.exit)return x.active=!1,x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null,x.dismissedRange=h.active?{...h.range}:h.dismissedRange,x;if(x.composing=y,d.docChanged&&x.dismissedRange!==null&&(x.dismissedRange={from:d.mapping.map(x.dismissedRange.from),to:d.mapping.map(x.dismissedRange.to)}),m&&(w||t.view.composing)){(k<h.range.from||k>h.range.to)&&!y&&!h.composing&&(x.active=!1);const v=o({char:e,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:i,$position:b.$from}),E=`id_${Math.floor(Math.random()*4294967295)}`;v&&l({editor:t,state:p,range:v.range,isActive:h.active})&&(!a||a({editor:t,range:v.range,query:v.query,text:v.text,transaction:d}))?(x.dismissedRange!==null&&!c({match:v,dismissedRange:x.dismissedRange,state:p,transaction:d})&&(x.dismissedRange=null),x.dismissedRange===null?(x.active=!0,x.decorationId=h.decorationId||E,x.range=v.range,x.query=v.query,x.text=v.text):x.active=!1):(v||(x.dismissedRange=null),x.active=!1)}else x.active=!1;return x.active||(x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null),x}}}function wB({editor:t,items:e}){let n=null,r=null,s=null;const i=()=>{r!==null&&(clearTimeout(r),r=null),s?.(),s=null},o=c=>new Promise(u=>{s=u,r=setTimeout(()=>{r=null;const d=s;s=null,d?.()},c)}),l=()=>{n?.abort(),i(),n=null};return{abort:l,fetch:async(c,u)=>{l(),n=new AbortController;const d=n;if(u>0&&await o(u),n!==d||d.signal.aborted)return{status:"aborted"};try{const h=await e({editor:t,query:c,signal:d.signal});return n!==d||d.signal.aborted?{status:"aborted"}:{status:"resolved",items:h}}catch{return n!==d||d.signal.aborted?{status:"aborted"}:{status:"error"}}}}}function vB({placement:t,offset:e,flip:n,floatingUi:r}){var s,i,o,l;const a=[Oc({mainAxis:(s=e.mainAxis)!=null?s:4,crossAxis:(i=e.crossAxis)!=null?i:0})];return n&&a.push(Df()),(o=r?.middleware)!=null&&o.length&&a.push(...r.middleware),{placement:t,strategy:(l=r?.strategy)!=null?l:"absolute",middleware:a}}function kB(t){if(t instanceof HTMLElement)return t;if(typeof t=="string")try{const e=document.querySelector(t);if(e)return e}catch{return document.body}return document.body}function SB({getReferenceRect:t,contextElement:e,config:n,container:r,dismissOnOutsideClick:s,dismiss:i}){return(o,l={})=>{const a={getBoundingClientRect:()=>{var p;return(p=t())!=null?p:new DOMRect},contextElement:e};let c=!1;const u=!o.isConnected;u&&kB(r).appendChild(o),l.onPosition||(o.style.visibility="hidden",o.style.width="max-content");const h=is(a,o,()=>{Dc(a,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:p,y:m,placement:y,strategy:b})=>{if(l.onPosition){l.onPosition({x:p,y:m,placement:y,strategy:b});return}Object.assign(o.style,{position:b,left:`${p}px`,top:`${m}px`}),c||(c=!0,o.style.visibility="")})},l.autoUpdate);let f;return s&&(f=p=>{const m=p.target;!(m instanceof Node)||o.contains(m)||e.contains(m)||i()},document.addEventListener("pointerdown",f,!0)),()=>{h(),f&&document.removeEventListener("pointerdown",f,!0),u&&o.remove()}}}function CB({editor:t,pluginKey:e,items:n,renderer:r,minQueryLength:s,debounce:i,initialItems:o,placement:l,offset:a,container:c,flip:u,floatingUi:d,dismissOnOutsideClick:h,command:f,clientRectFor:p,dispatchExit:m}){let y;const b=wB({editor:t,items:n}),w=vB({placement:l,offset:a,flip:u,floatingUi:d});function k(x,M){var v,E,A;switch(x){case"started":(v=r?.onStart)==null||v.call(r,M);break;case"updated":(E=r?.onUpdate)==null||E.call(r,M);break;case"stopped":(A=r?.onExit)==null||A.call(r,M);break}}return{update:async(x,M)=>{var v,E,A,C;const O=e.getState(M),B=e.getState(x.state);if(!O||!B)return;let D=null;const L=O.query!==B.query,I=O.text!==B.text,V=O.range.from!==B.range.from||O.range.to!==B.range.to,q=L||I||V;if(!O.active&&B.active)D="started";else if(O.active&&!B.active)D="stopped";else if(B.active&&q)D="updated";else return;const ne=D==="stopped"?O:B,_=x.dom.querySelector(`[data-decoration-id="${ne.decorationId}"]`),U=p(x,_),le=s===0||(ne.query?ne.query.length>=s:!1),N=(D==="started"||D==="updated")&&le;if(y={editor:t,range:ne.range,query:ne.query||"",text:ne.text||"",items:o??[],command:K=>f({editor:t,range:ne.range,props:K}),decorationNode:_,clientRect:U,loading:N,placement:l,offset:{mainAxis:(v=a.mainAxis)!=null?v:4,crossAxis:(E=a.crossAxis)!=null?E:0},container:c,flip:u,floatingUi:w,mount:SB({getReferenceRect:U,contextElement:x.dom,config:w,container:c,dismissOnOutsideClick:h,dismiss:()=>m(t.view)})},D==="started"&&((A=r?.onBeforeStart)==null||A.call(r,y)),D==="updated"&&((C=r?.onBeforeUpdate)==null||C.call(r,y)),D==="started"&&k(D,y),D==="started"||D==="updated")if(!N)b.abort(),y={...y,items:o??[],loading:!1};else{y={...y,items:o??[],loading:!0},D="updated",k(D,y);const K=await b.fetch(ne.query||"",i);if(K.status==="aborted")return;const ae=e.getState(x.state);if(!ae?.active){b.abort();return}y=K.status==="resolved"?{...y,items:K.items,loading:!1}:{...y,loading:!1}}if(D==="stopped"){b.abort(),k(D,y),y=void 0;return}D==="updated"&&k(D,y)},destroy:()=>{var x;b.abort(),y&&((x=r?.onExit)==null||x.call(r,y))}}}var EB=new ye("suggestion");function AB({pluginKey:t=EB,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],minQueryLength:f=0,debounce:p=0,initialItems:m,placement:y="bottom-start",offset:b={},container:w,flip:k=!0,floatingUi:x,dismissOnOutsideClick:M=!0,render:v=()=>({}),allow:E=()=>!0,findSuggestionMatch:A=hB,shouldShow:C,shouldResetDismissed:O}){const B=v?.(),D=r&&!s,L=(q,ne)=>mB(e,q,ne,t);function I(q){return gB({...q,editor:e,shouldResetDismissed:O,effectiveAllowSpaces:D})}const V=q=>yB({view:q,pluginKeyRef:t});return new pe({key:t,view:()=>CB({editor:e,pluginKey:t,items:h,renderer:B,minQueryLength:f,debounce:p,initialItems:m,placement:y,offset:b,container:w,flip:k,floatingUi:x,dismissOnOutsideClick:M,command:d,clientRectFor:L,dispatchExit:V}),state:xB({editor:e,char:n,effectiveAllowSpaces:D,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,findSuggestionMatch:A,allow:E,shouldShow:C,shouldKeepDismissed:I,pluginKey:t}),props:bB({pluginKey:t,decorationTag:l,decorationClass:a,decorationContent:c,decorationEmptyClass:u,renderer:B,dispatchExit:V})})}const yk=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const MB=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const TB=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const sb=t=>{const e=TB(t);return e.charAt(0).toUpperCase()+e.slice(1)};var NB={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const RB=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const _B=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>S.createElement("svg",{ref:a,...NB,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:yk("lucide",s),...!i&&!RB(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,u])=>S.createElement(c,u)),...Array.isArray(i)?i:[i]]));const Q=(t,e)=>{const n=S.forwardRef(({className:r,...s},i)=>S.createElement(_B,{ref:i,iconNode:e,className:yk(`lucide-${MB(sb(t))}`,`lucide-${t}`,r),...s}));return n.displayName=sb(t),n};const OB=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],hc=Q("bold",OB);const DB=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ib=Q("circle-alert",DB);const LB=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],IB=Q("circle-check-big",LB);const PB=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],jB=Q("circle-plus",PB);const $B=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],BB=Q("circle-x",$B);const zB=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Fr=Q("code-xml",zB);const HB=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],li=Q("code",HB);const FB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],UB=Q("columns-2",FB);const VB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],WB=Q("columns-3",VB);const qB=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],bk=Q("download",qB);const KB=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],JB=Q("eraser",KB);const GB=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],YB=Q("eye",GB);const XB=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ZB=Q("file-code-corner",XB);const QB=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ez=Q("hash",QB);const tz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Ys=Q("heading-1",tz);const nz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Vo=Q("heading-2",nz);const rz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],tu=Q("heading-3",rz);const sz=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],iz=Q("heading-4",sz);const oz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],lz=Q("heading-5",oz);const az=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],cz=Q("heading-6",az);const uz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ns=Q("image",uz);const dz=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Cp=Q("italic",dz);const hz=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],nu=Q("link-2",hz);const fz=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Wo=Q("list-ordered",fz);const pz=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],ai=Q("list",pz);const mz=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gz=Q("loader-circle",mz);const yz=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],ru=Q("megaphone",yz);const bz=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],xz=Q("menu",bz);const wz=[["path",{d:"M5 12h14",key:"1ays0h"}]],su=Q("minus",wz);const vz=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Ep=Q("palette",vz);const kz=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Sz=Q("play",kz);const Cz=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Ez=Q("redo-2",Cz);const Az=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],Mz=Q("replace",Az);const Tz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Nz=Q("rotate-ccw",Tz);const Rz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],_z=Q("rows-2",Rz);const Oz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Dz=Q("rows-3",Oz);const Lz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Iz=Q("search",Lz);const Pz=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],jz=Q("sparkles",Pz);const $z=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],iu=Q("square-check-big",$z);const Bz=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],xk=Q("strikethrough",Bz);const zz=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],wk=Q("subscript",zz);const Hz=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],vk=Q("superscript",Hz);const Fz=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],qo=Q("table-2",Fz);const Uz=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Vz=Q("terminal",Uz);const Wz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ko=Q("text-align-center",Wz);const qz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Jo=Q("text-align-end",qz);const Kz=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Ap=Q("text-align-justify",Kz);const Jz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Xs=Q("text-align-start",Jz);const Gz=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],Go=Q("text-quote",Gz);const Yz=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],kk=Q("trash-2",Yz);const Xz=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ou=Q("triangle-alert",Xz);const Zz=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],cs=Q("type",Zz);const Qz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Mp=Q("underline",Qz);const eH=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],tH=Q("undo-2",eH);const nH=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Sk=Q("video",nH);const rH=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ck=Q("x",rH),Tp=S.forwardRef(({items:t,command:e},n)=>{const[r,s]=S.useState(-1),i=S.useRef(null),o=a=>{const c=t[a];c&&e(c)};S.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),S.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),S.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return g.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const u=r!==-1&&c===r;return g.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":u,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(c),className:De.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",u&&"bg-accent text-accent-foreground"),children:[g.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?g.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):g.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});Tp.displayName="SlashCommandList";const sH=[{title:"Text",description:"Start writing with plain text.",icon:S.createElement(cs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:S.createElement(Ys,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:S.createElement(Vo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:S.createElement(tu,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:S.createElement(iz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:S.createElement(lz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:S.createElement(cz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:S.createElement(ai,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:S.createElement(Wo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:S.createElement(iu,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:S.createElement(Go,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:S.createElement(li,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:S.createElement(su,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:S.createElement(ns,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:S.createElement(qo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:S.createElement(Xs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:S.createElement(Ko,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:S.createElement(Jo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:S.createElement(Ap,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:S.createElement(Sk,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:S.createElement(ou,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:S.createElement(ru,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],Ek=ue.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[AB({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>sH.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Dc(o,e,{placement:"bottom-start",middleware:[Oc(6),Df({fallbackPlacements:["top-start","bottom-start"]}),dw({padding:8}),hw({apply({availableWidth:c,availableHeight:u,elements:d}){Object.assign(d.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,u-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new Xx(Tp,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=is(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var iH=Wf,oH=Yf;mO.extend({draggable:!0});i_.extend({draggable:!0});qR.extend({draggable:!0});iH.extend({draggable:!0});oH.extend({draggable:!0});p1.extend({draggable:!0});m1.extend({draggable:!0});h1.extend({draggable:!0});f1.extend({draggable:!0});const Ak=ue.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),lH=_e.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),aH=_e.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",ge(this.options.HTMLAttributes,t.attrs),0]}}),cH=ue.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),uH=_e.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),dH=_e.create({name:"svg",group:"inline",inline:!0,atom:!0,addOptions(){return{HTMLAttributes:{class:"inline-block align-middle"}}},addAttributes(){return{html:{default:""},viewBox:{default:"0 0 24 24"},width:{default:null},height:{default:null},fill:{default:"none"},stroke:{default:"currentColor"},class:{default:null},style:{default:null},xmlns:{default:"http://www.w3.org/2000/svg"}}},parseHTML(){return[{tag:"svg",priority:60,getAttrs:t=>{if(!(t instanceof Element))return!1;const e={html:t.innerHTML};return t.getAttribute("viewBox")&&(e.viewBox=t.getAttribute("viewBox")),t.getAttribute("width")&&(e.width=t.getAttribute("width")),t.getAttribute("height")&&(e.height=t.getAttribute("height")),t.getAttribute("fill")&&(e.fill=t.getAttribute("fill")),t.getAttribute("stroke")&&(e.stroke=t.getAttribute("stroke")),t.getAttribute("class")&&(e.class=t.getAttribute("class")),t.getAttribute("style")&&(e.style=t.getAttribute("style")),t.getAttribute("xmlns")&&(e.xmlns=t.getAttribute("xmlns")),e}}]},renderHTML({HTMLAttributes:t}){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:n,...r}=t;return Object.entries(ge(this.options.HTMLAttributes,r)).forEach(([s,i])=>{i!=null&&e.setAttribute(s,String(i))}),n&&(e.innerHTML=n),{dom:e}},addNodeView(){return({node:t,HTMLAttributes:e})=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:r,...s}=e;return Object.entries(s).forEach(([i,o])=>{i!=="html"&&o!==null&&o!==void 0&&n.setAttribute(i,String(o))}),t.attrs.html?n.innerHTML=t.attrs.html:r&&(n.innerHTML=r),n.classList.add("parsed-svg-node"),{dom:n}}}}),hH=_e.create({name:"spanComponent",group:"inline",inline:!0,content:"inline*",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}}}},parseHTML(){return[{tag:"span",priority:60,getAttrs:t=>t instanceof HTMLElement&&t.hasAttribute("class")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",ge(this.options.HTMLAttributes,t),0]}}),fH=iB({html:rB,css:q$,js:X$,ts:nB,python:Q$,json:Z$,bash:j$,sql:eB}),ob="http://www.w3.org/2000/svg";function lb(t){const e=document.createElementNS(ob,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(ob,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const fc=[tD.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),j_.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),cI,uI.configure({depth:100,newGroupDelay:500}),h1.configure({lowlight:fH,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),aH,lH,uH,dH,hH,cH,dD.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),p1.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),m1.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),N1.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),wL.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),vL.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),kL.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),HL.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),AL.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),TL,RL,OL.extend({addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{if(t.style.textAlign)return t.style.textAlign;if(t.getAttribute("align"))return t.getAttribute("align");const e=t.getAttribute("class")||"";return/(?:^|\s)text-center(?:\s|$)/.test(e)?"center":/(?:^|\s)text-right(?:\s|$)/.test(e)?"right":/(?:^|\s)text-justify(?:\s|$)/.test(e)?"justify":/(?:^|\s)text-left(?:\s|$)/.test(e)?"left":null},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign} !important`}}}}]}}).configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),aI,pk,FL.configure({limit:5e4,mode:"textSize"}),mk,gk,Ek,Ak,h$,P$.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[Oc({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=lb(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=lb(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var pH=typeof document<"u",mH=function(){},jh=pH?S.useLayoutEffect:mH;const gH={...se},yH=gH.useInsertionEffect,bH=yH||(t=>t());function xH(t){const e=se.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return bH(()=>{e.current=t}),se.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var wH=typeof document<"u",vH=function(){},ta=wH?S.useLayoutEffect:vH;function pc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!pc(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!pc(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Mk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function ab(t,e){const n=Mk(t);return Math.round(e*n)/n}function Cd(t){const e=se.useRef(t);return ta(()=>{e.current=t}),e}function kH(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=se.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=se.useState(r);pc(h,r)||f(r);const[p,m]=se.useState(null),[y,b]=se.useState(null),w=se.useCallback(_=>{_!==v.current&&(v.current=_,m(_))},[]),k=se.useCallback(_=>{_!==E.current&&(E.current=_,b(_))},[]),x=i||p,M=o||y,v=se.useRef(null),E=se.useRef(null),A=se.useRef(u),C=a!=null,O=Cd(a),B=Cd(s),D=Cd(c),L=se.useCallback(()=>{if(!v.current||!E.current)return;const _={placement:e,strategy:n,middleware:h};B.current&&(_.platform=B.current),Dc(v.current,E.current,_).then(U=>{const le={...U,isPositioned:D.current!==!1};I.current&&!pc(A.current,le)&&(A.current=le,RS.flushSync(()=>{d(le)}))})},[h,e,n,B,D]);ta(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,d(_=>({..._,isPositioned:!1})))},[c]);const I=se.useRef(!1);ta(()=>(I.current=!0,()=>{I.current=!1}),[]),ta(()=>{if(x&&(v.current=x),M&&(E.current=M),x&&M){if(O.current)return O.current(x,M,L);L()}},[x,M,L,O,C]);const V=se.useMemo(()=>({reference:v,floating:E,setReference:w,setFloating:k}),[w,k]),q=se.useMemo(()=>({reference:x,floating:M}),[x,M]),ne=se.useMemo(()=>{const _={position:n,left:0,top:0};if(!q.floating)return _;const U=ab(q.floating,u.x),le=ab(q.floating,u.y);return l?{..._,transform:"translate("+U+"px, "+le+"px)",...Mk(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:le}},[n,l,q.floating,u.x,u.y]);return se.useMemo(()=>({...u,update:L,refs:V,elements:q,floatingStyles:ne}),[u,L,V,q,ne])}const Yo=(t,e)=>{const n=Oc(t);return{name:n.name,fn:n.fn,options:[t,e]}},lu=(t,e)=>{const n=dw(t);return{name:n.name,fn:n.fn,options:[t,e]}},au=(t,e)=>{const n=Df(t);return{name:n.name,fn:n.fn,options:[t,e]}},SH=(t,e)=>{const n=hw(t);return{name:n.name,fn:n.fn,options:[t,e]}},CH={...se};let cb=!1,EH=0;const ub=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+EH++;function AH(){const[t,e]=se.useState(()=>cb?ub():void 0);return jh(()=>{t==null&&e(ub())},[]),se.useEffect(()=>{cb=!0},[]),t}const MH=CH.useId,TH=MH||AH;let $h;process.env.NODE_ENV!=="production"&&($h=new Set);function NH(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=$h)!=null&&t.has(s))){var i;(i=$h)==null||i.add(s),console.error(s)}}function RH(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const _H=se.createContext(null),OH=se.createContext(null),DH=()=>{var t;return((t=se.useContext(_H))==null?void 0:t.id)||null},LH=()=>se.useContext(OH);function IH(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=TH(),i=se.useRef({}),[o]=se.useState(()=>RH()),l=DH()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ht(f)&&NH("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=se.useState(r.reference),u=xH((f,p,m)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:m,nested:l}),n?.(f,p,m)}),d=se.useMemo(()=>({setPositionReference:c}),[]),h=se.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return se.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:h,events:o,floatingId:s,refs:d}),[e,u,h,o,s,d])}function Xo(t){t===void 0&&(t={});const{nodeId:e}=t,n=IH({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=se.useState(null),[l,a]=se.useState(null),u=s?.domReference||i,d=se.useRef(null),h=LH();jh(()=>{u&&(d.current=u)},[u]);const f=kH({...t,elements:{...s,...l&&{reference:l}}}),p=se.useCallback(k=>{const x=ht(k)?{getBoundingClientRect:()=>k.getBoundingClientRect(),getClientRects:()=>k.getClientRects(),contextElement:k}:k;a(x),f.refs.setReference(x)},[f.refs]),m=se.useCallback(k=>{(ht(k)||k===null)&&(d.current=k,o(k)),(ht(f.refs.reference.current)||f.refs.reference.current===null||k!==null&&!ht(k))&&f.refs.setReference(k)},[f.refs]),y=se.useMemo(()=>({...f.refs,setReference:m,setPositionReference:p,domReference:d}),[f.refs,m,p]),b=se.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),w=se.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return jh(()=>{r.dataRef.current.floatingContext=w;const k=h?.nodesRef.current.find(x=>x.id===e);k&&(k.context=w)}),se.useMemo(()=>({...f,context:w,refs:y,elements:b}),[f,y,b,w])}const PH="_pickerRoot_1wq30_1",jH="_picker_1wq30_1",db={pickerRoot:PH,picker:jH};function cu(){return(cu=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function Tk(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Yi(t){var e=S.useRef(t),n=S.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var No=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},Xi=function(t){return"touches"in t},Bh=function(t){return t&&t.ownerDocument.defaultView||self},hb=function(t,e,n){var r=t.getBoundingClientRect(),s=Xi(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:No((s.pageX-(r.left+Bh(t).pageXOffset))/r.width),top:No((s.pageY-(r.top+Bh(t).pageYOffset))/r.height)}},fb=function(t){!Xi(t)&&t.preventDefault()},Nk=S.memo(function(t){var e=t.onMove,n=t.onKey,r=t.onEnd,s=Tk(t,["onMove","onKey","onEnd"]),i=S.useRef(null),o=Yi(e),l=Yi(n),a=Yi(r),c=S.useRef(null),u=S.useRef(!1),d=S.useMemo(function(){var y=function(k){fb(k),(Xi(k)?k.touches.length>0:k.buttons>0)&&i.current?o(hb(i.current,k,c.current)):(w(!1),a())},b=function(){w(!1),a()};function w(k){var x=u.current,M=Bh(i.current),v=k?M.addEventListener:M.removeEventListener;v(x?"touchmove":"mousemove",y),v(x?"touchend":"mouseup",b)}return[function(k){var x=k.nativeEvent,M=i.current;if(M&&(fb(x),!(function(E,A){return A&&!Xi(E)})(x,u.current)&&M)){if(Xi(x)){u.current=!0;var v=x.changedTouches||[];v.length&&(c.current=v[0].identifier)}M.focus(),o(hb(M,x,c.current)),w(!0)}},function(k){var x=k.which||k.keyCode;x<37||x>40||(k.preventDefault(),l({left:x===39?.05:x===37?-.05:0,top:x===40?.05:x===38?-.05:0}))},function(k){var x=k.which||k.keyCode;x>=37&&x<=40&&a()},w]},[l,o,a]),h=d[0],f=d[1],p=d[2],m=d[3];return S.useEffect(function(){return m},[m]),S.createElement("div",cu({},s,{onTouchStart:h,onMouseDown:h,className:"react-colorful__interactive",ref:i,onKeyDown:f,onKeyUp:p,tabIndex:0,role:"slider"}))}),Np=function(t){return t.filter(Boolean).join(" ")},Rk=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=Np(["react-colorful__pointer",t.className]);return S.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},S.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},at=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},$H=function(t){return UH(zh(t))},zh=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?at(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?at(parseInt(t.substring(6,8),16)/255,2):1}},BH=function(t){return FH(HH(t))},zH=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:at(t.h),s:at(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:at(s/2),a:at(r,2)}},Hh=function(t){var e=zH(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},HH=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:at(255*[r,l,o,o,a,r][c]),g:at(255*[a,r,r,l,o,o][c]),b:at(255*[o,o,a,r,r,l][c]),a:at(s,2)}},Dl=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},FH=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Dl(at(255*s)):"";return"#"+Dl(e)+Dl(n)+Dl(r)+i},UH=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:at(60*(l<0?l+6:l)),s:at(i?o/i*100:0),v:at(i/255*100),a:s}},VH=S.memo(function(t){var e=t.hue,n=t.onChange,r=t.onChangeEnd,s=Np(["react-colorful__hue",t.className]);return S.createElement("div",{className:s},S.createElement(Nk,{onMove:function(i){n({h:360*i.left})},onKey:function(i){n({h:No(e+360*i.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":at(e),"aria-valuemax":"360","aria-valuemin":"0"},S.createElement(Rk,{className:"react-colorful__hue-pointer",left:e/360,color:Hh({h:e,s:100,v:100,a:1})})))}),WH=S.memo(function(t){var e=t.hsva,n=t.onChange,r=t.onChangeEnd,s={backgroundColor:Hh({h:e.h,s:100,v:100,a:1})};return S.createElement("div",{className:"react-colorful__saturation",style:s},S.createElement(Nk,{onMove:function(i){n({s:100*i.left,v:100-100*i.top})},onKey:function(i){n({s:No(e.s+100*i.left,0,100),v:No(e.v-100*i.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+at(e.s)+"%, Brightness "+at(e.v)+"%"},S.createElement(Rk,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Hh(e)})))}),_k=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},qH=function(t,e){return t.toLowerCase()===e.toLowerCase()||_k(zh(t),zh(e))};function KH(t,e,n,r){var s=Yi(n),i=Yi(r),o=S.useState(function(){return t.toHsva(e)}),l=o[0],a=o[1],c=S.useRef({color:e,hsva:l}),u=S.useRef(!1);S.useEffect(function(){if(!t.equal(e,c.current.color)){var f=t.toHsva(e);c.current={hsva:f,color:e},a(f),u.current=!1}},[e,t]),S.useEffect(function(){var f;_k(l,c.current.hsva)||t.equal(f=t.fromHsva(l),c.current.color)||(c.current={hsva:l,color:f},s(f),u.current=!0)},[l,t,s]);var d=S.useCallback(function(f){a(function(p){return Object.assign({},p,f)})},[]),h=S.useCallback(function(){u.current&&(u.current=!1,i(c.current.color))},[i]);return[l,d,h]}var JH=typeof window<"u"?S.useLayoutEffect:S.useEffect,GH=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},pb=new Map,YH=function(t){JH(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!pb.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,pb.set(e,n);var r=GH();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},XH=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=t.onChangeEnd,l=Tk(t,["className","colorModel","color","onChange","onChangeEnd"]),a=S.useRef(null);YH(a);var c=KH(n,s,i,o),u=c[0],d=c[1],h=c[2],f=Np(["react-colorful",e]);return S.createElement("div",cu({},l,{ref:a,className:f}),S.createElement(WH,{hsva:u,onChange:d,onChangeEnd:h}),S.createElement(VH,{hue:u.h,onChange:d,onChangeEnd:h,className:"react-colorful__last-control"}))},ZH={defaultColor:"000",toHsva:$H,fromHsva:function(t){return BH({h:t.h,s:t.s,v:t.v,a:1})},equal:qH},QH=function(t){return S.createElement(XH,cu({},t,{colorModel:ZH}))};const mb="#1F2937",gb="#FFF7D1",e4=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],t4=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],n4=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,r4=/^#[0-9a-f]{6}$/i,Ok=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,Dk=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function mc(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function Lk(t){const e=mc(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Fh(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function Zi(t,e=2){const n=10**e;return Math.round(t*n)/n}function Qi(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,u=0;const d=(l+a)/2;if(l!==a){const m=l-a;switch(u=d>.5?m/(2-l-a):m/(l+a),l){case s:c=(i-o)/m+(i<o?6:0);break;case i:c=(o-s)/m+2;break;case o:c=(s-i)/m+4;break}c/=6}const h=Math.round(c*360),f=Math.round(u*100),p=Math.round(d*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${Zi(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function yb(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function In(t){if(!t)return null;const e=t.trim();if(n4.test(e)){const r=mc(e),s=Lk(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${Zi(s.a,2)})`,hsl:Qi(s.r,s.g,s.b,s.a),alpha:s.a}}if(Ok.test(e)||Dk.test(e)){const r=yb(e);return r?{source:e,hex:Fh(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${Zi(r.a,2)})`,hsl:Qi(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=yb(e);return n?{source:e,hex:Fh(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${Zi(n.a,2)})`,hsl:Qi(n.r,n.g,n.b,n.a),alpha:n.a}:null}function Ik(t){const e=Lk(t);if(e)return{source:mc(t),hex:Fh(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Zi(e.a,2)})`,hsl:Qi(e.r,e.g,e.b,e.a),alpha:e.a};const n=mc(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:Qi(0,0,0,1),alpha:1}}const yi=In(mb)??Ik(mb),bb=In(gb)??Ik(gb);function Pk({editor:t,className:e,initialMode:n="text"}){const r=S.useRef(null),[s,i]=S.useState(n),[o,l]=S.useState(null),[a,c]=S.useState(yi),[u,d]=S.useState(bb);S.useEffect(()=>{i(n)},[n]);const[h,f]=S.useState(yi.hex),[p,m]=S.useState(!1),[y,b]=S.useState(yi.rgb),[w,k]=S.useState(!1),[x,M]=S.useState(yi.hsl),[v,E]=S.useState(!1),A=s==="text"?a:u;S.useEffect(()=>{const L=()=>{if(o)return;const I=t.getAttributes("textStyle").color,V=t.getAttributes("highlight").color,q=In(I)??yi,ne=In(V)??bb;c(q),d(ne)};return L(),t.on("selectionUpdate",L),t.on("transaction",L),()=>{t.off("selectionUpdate",L),t.off("transaction",L)}},[t,o,s]),S.useEffect(()=>{o!=="hex"&&f(A.hex),o!=="rgb"&&b(A.rgb),o!=="hsl"&&M(A.hsl),o===null&&(m(!1),k(!1),E(!1))},[A,o]);const C=S.useCallback((L,I,V=!0)=>{const q=t.chain();V&&q.focus(),L==="text"?(c(I),q.setColor(I.source).run()):(d(I),q.setHighlight({color:I.source}).run())},[t,c,d]),O=S.useCallback((L,I)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{C(L,I,!1)},300)},[C]),B=S.useCallback(L=>{r.current&&clearTimeout(r.current);const I=In(L);I&&(C(s,I,!1),m(!1))},[C,s,m]),D=S.useCallback(L=>{r.current&&clearTimeout(r.current);const I=In(L);I&&(C(s,I),m(!1))},[C,s,m]);return g.jsxs("div",{className:De.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[g.jsx(ce.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),g.jsx(ce.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),g.jsx("div",{className:"flex items-center",children:g.jsx(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),g.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[g.jsx("div",{className:db.pickerRoot,children:g.jsx(QH,{color:A.hex,onChange:B,className:db.picker})}),g.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),g.jsx(Es.Input,{value:h,onFocus:()=>l("hex"),onChange:L=>{const I=L.target.value;if(f(I),r4.test(I)){const V=In(I);V&&(O(s,V),m(!1))}else m(!0)},onBlur:()=>{l(null),p&&(f(A.hex),m(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),g.jsx(Es.Input,{value:y,onFocus:()=>l("rgb"),onChange:L=>{const I=L.target.value;if(b(I),Ok.test(I)){const V=In(I);V&&(O(s,V),k(!1))}else k(!0)},onBlur:()=>{l(null),w&&(b(A.rgb),k(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),g.jsx(Es.Input,{value:x,onFocus:()=>l("hsl"),onChange:L=>{const I=L.target.value;if(M(I),Dk.test(I)){const V=In(I);V&&(O(s,V),E(!1))}else E(!0)},onBlur:()=>{l(null),v&&(M(A.hsl),E(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",v&&"border-destructive focus-visible:ring-destructive")})]})]})]}),g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),g.jsx("div",{className:"space-y-1",children:t4.map(L=>g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:L.title}),g.jsx("div",{className:"flex items-center gap-1.5",children:L.colors.map(I=>g.jsx("button",{type:"button",onClick:()=>D(I.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:I.value},"aria-label":`${L.title} color ${I.label}`,title:`${L.title} color ${I.label}`},I.label))})]},L.title))})]}),s==="highlight"?g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),g.jsx("div",{className:"flex flex-wrap gap-1.5",children:e4.map(L=>g.jsxs("button",{type:"button",onClick:()=>D(L),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[g.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:L},"aria-hidden":!0}),L]},L))})]}):null]})}const s4=["px","pt","rem","em","%"];function na(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Uh(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function i4(t){const e=na(t);return e?Uh(e):null}function o4(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const d=c.style.fontSize,h=c.selectorText;if(d&&h&&o.has(h)){const f=i4(d)??d.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function l4(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function gc(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Rp(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:gc()}catch{return gc()}}function a4(t,e,n){const r=gc(),s=Rp(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function c4(t,e,n){const r=gc(),s=Rp(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function jk({editor:t,className:e}){const[n,r]=S.useState([]),[s,i]=S.useState(null),[o,l]=S.useState(""),[a,c]=S.useState("px"),[u,d]=S.useState(!1),h=S.useRef(null),f=S.useCallback(()=>{const x=t.getAttributes("textStyle").fontSize,M=na(x);if(M)l(String(M.value)),c(M.unit),d(!1);else{if(x&&typeof x=="string"){const v=l4(x);if(v>0&&!s){l(String(Math.round(v))),c("px"),d(!1);return}}s||(l(""),c("px"),d(!1))}},[t,s]);S.useEffect(()=>{f();const x=()=>f();return t.on("selectionUpdate",x),t.on("transaction",x),()=>{t.off("selectionUpdate",x),t.off("transaction",x)}},[t,f]),S.useEffect(()=>{r(o4())},[]);const p=S.useCallback((x,M=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const v=t.chain();M&&v.focus(),v.setFontSize(x).run()},120)},[t]),m=S.useCallback(x=>{l(x);const M=`${x}${a}`,v=na(M);if(v){d(!1);const E=Uh(v);E&&p(E,!1)}else d(x.trim().length>0)},[a,p]),y=S.useCallback(x=>{const M=a;c(x);let v=0;const E=parseFloat(o);Number.isFinite(E)?v=a4(E,M,t):v=Rp(t);const A=c4(v,x,t);let C;x==="px"||x==="pt"||x==="%"?C=String(Math.round(A)):C=String(Math.max(.01,Math.round(A*100)/100)),l(C);const O=Uh(na(`${C}${x}`));O&&p(O)},[a,o,t,p]),b=S.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),d(!1)},[t]),w=S.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),k=S.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return g.jsxs("div",{className:De.cn("space-y-3",e),onMouseDown:x=>x.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(cs,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),g.jsxs(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[g.jsx(JB,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),g.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),g.jsx(Es.Input,{type:"number",inputMode:"decimal",step:w,placeholder:k,value:o,onFocus:()=>i("value"),onChange:x=>m(x.target.value),onBlur:()=>i(null),className:De.cn("h-9",u&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),g.jsx("div",{className:"flex gap-1",children:g.jsx("select",{value:a,onChange:x=>y(x.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s4.map(x=>g.jsx("option",{value:x,children:x},x))})})]})]}),g.jsxs("div",{className:"space-y-2",children:[n.length>0?g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:x,value:M})=>g.jsx("button",{type:"button",onClick:()=>p(M),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${x} (${M})`,children:`H${x} (${M})`},`h${x}`))})]}):null,g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(x=>g.jsx("button",{type:"button",onClick:()=>p(x),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${x}`,children:x.replace(/\b\w/g,M=>M.toUpperCase())},x))})]})]})]})}const u4=({editor:t})=>{const[e,n]=S.useState(t.getAttributes("link")?.href??"");S.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return g.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[g.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),g.jsx(ce.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},d4=({editor:t})=>g.jsx("div",{className:"w-[380px]",children:g.jsx(Pk,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),_p=({editor:t})=>{const[e,n]=S.useState(!1),[r,s]=S.useState(!1),[i,o]=S.useState(!1),[l,a]=S.useState(!1),{x:c,y:u,refs:d,strategy:h,update:f}=Xo({placement:"top",middleware:[Yo(6),au(),lu()],whileElementsMounted:is}),p=S.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:w}=y.selection,k=b!==w,x=y.selection instanceof Z,M=t.isActive("codeBlock"),v=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),E=t.isActive("image");return k&&!x&&!M&&!v&&!E},[t]),m=S.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,w=t.view.coordsAtPos(y),k=t.view.coordsAtPos(b),x={getBoundingClientRect:()=>({x:w.left,y:w.top,top:w.top,left:w.left,bottom:k.bottom,right:k.right,width:k.right-w.left,height:k.bottom-w.top})};d.setReference(x),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,d,f,p]);return S.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),m()):!i&&!l&&n(!1)})},w=({event:k})=>{i||l||d.floating.current&&k.relatedTarget&&d.floating.current.contains(k.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",w),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",w)}},[t,p,m,i,l,d.floating]),!t||!e?null:g.jsxs("div",{ref:d.setFloating,style:{position:h,top:u??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:g.jsx(hc,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:g.jsx(Cp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:g.jsx(Mp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:g.jsx(xk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:g.jsx(li,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:g.jsx(wk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:g.jsx(vk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:g.jsx(Xs,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:g.jsx(Ko,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:g.jsx(Jo,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:g.jsx(Ap,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsxs(wt.Popover,{open:l,onOpenChange:a,children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:g.jsx(cs,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:g.jsx(jk,{editor:t,className:"p-4"})})]}),g.jsxs(wt.Popover,{children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:g.jsx(nu,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:g.jsx(u4,{editor:t})})]}),g.jsxs(wt.Popover,{open:i,onOpenChange:o,children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:g.jsx(Ep,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:g.jsx(d4,{editor:t})})]}),g.jsx("div",{className:"w-px bg-border h-5"})]})};function xb(t,e){t.storage.mediaPicker={open:e}}function uu(t){return t.storage?.mediaPicker?.open}const h4=[{title:"Heading 1",icon:g.jsx(Ys,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:g.jsx(Vo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:g.jsx(Wo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:g.jsx(Go,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:g.jsx(ns,{className:"h-4 w-4"}),command:async t=>{const e=uu(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:g.jsx(su,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:g.jsx(nu,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:g.jsx(ou,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:g.jsx(ru,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],Op=({editor:t})=>{const[e,n]=S.useState(!1),[r,s]=S.useState(null),[i,o]=S.useState(null),l=S.useRef(null),a=S.useRef(null),c=S.useRef(!1),u=S.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:d,y:h,refs:f,strategy:p}=Xo({placement:"right-start",open:e,middleware:[Yo(8),au(),lu()],whileElementsMounted:is});S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const m=S.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);S.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const w=k=>{const x=k,{handle:M,button:v}=x.detail;try{const A=t.state.selection?.$from;if(A){let C=A.depth;for(;C>0&&!A.node(C)?.isBlock;)C-=1;const O=typeof A.after=="function"?A.after(C):void 0;typeof O=="number"?o(O):typeof A.pos=="number"?o(A.pos):o(null)}else o(null)}catch{o(null)}if(l.current===v&&c.current){u();return}l.current&&l.current!==v&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==M&&a.current.removeAttribute("data-menu-open"),l.current=v,a.current=M,v.setAttribute("aria-expanded","true"),M.setAttribute("data-menu-open","true"),s(v),n(!0)};return b.addEventListener("tiptap-gutter-toggle",w),()=>{b.removeEventListener("tiptap-gutter-toggle",w)}},[t,m,u]),S.useEffect(()=>{if(!t)return;const b=()=>{m()||u()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",u),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",u)}},[t,m,u]),S.useEffect(()=>{if(!e)return;const b=k=>{const x=k.target,M=f.floating.current;if(M&&!M.contains(x)){const v=l.current;(!v||!v.contains(x))&&u()}},w=k=>{k.key==="Escape"&&u()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[e,u,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),u()};return!r||!e?null:g.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:d??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:g.jsx("div",{className:"flex flex-col",children:h4.map(b=>g.jsxs(ce.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,g.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},f4=[{title:"Text",description:"Start writing with plain text",icon:g.jsx(cs,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:g.jsx(Ys,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:g.jsx(Vo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:g.jsx(tu,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:g.jsx(Wo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:g.jsx(iu,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:g.jsx(ns,{className:"h-4 w-4"}),command:async t=>{const e=uu(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:g.jsx(Sk,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:g.jsx(Go,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:g.jsx(su,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:g.jsx(ou,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:g.jsx(ru,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],wb={basic:g.jsx(cs,{className:"h-3 w-3"}),headings:g.jsx(ez,{className:"h-3 w-3"}),lists:g.jsx(ai,{className:"h-3 w-3"}),media:g.jsx(ns,{className:"h-3 w-3"}),advanced:g.jsx(Vz,{className:"h-3 w-3"})},vb={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},$k=({editor:t,wrapperRef:e})=>{const[n,r]=S.useState(!1),[s,i]=S.useState(!1),[o,l]=S.useState(!1),[a,c]=S.useState(""),[u,d]=S.useState("all"),[h,f]=S.useState({top:-9999,left:-9999,width:0}),{x:p,y:m,refs:y,strategy:b,update:w}=Xo({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Yo(10),au({fallbackPlacements:["top-start","bottom-start","right-start"]}),lu({padding:8}),SH({apply({availableWidth:A,availableHeight:C,elements:O}){Object.assign(O.floating.style,{maxWidth:`${Math.min(400,A-16)}px`,maxHeight:`${Math.min(500,C-16)}px`})}})],whileElementsMounted:is}),k=S.useCallback(()=>{const{$from:A}=t.state.selection,C=A.parent;if(C.type.name==="paragraph"&&C.content.size===0||C.type.name==="heading"&&C.content.size===0)return!0;if(C.type.name==="listItem"&&C.content.size===1){const O=C.firstChild;if(O&&O.type.name==="paragraph"&&O.content.size===0)return!0}return t.isEditable},[t]),x=S.useCallback(()=>{if(!e?.current)return;const A=e.current.getBoundingClientRect(),C=t.view.dom.getBoundingClientRect(),B=t.view.coordsAtPos(t.state.selection.from).top-A.top,D=C.left-A.left,L=C.width;f({top:B,left:D,width:L}),w(),requestAnimationFrame(()=>l(!0))},[t,w,e]);S.useEffect(()=>{if(!t)return;let A=0;const C=()=>{cancelAnimationFrame(A),A=requestAnimationFrame(()=>{k()?(i(!0),l(!1),x()):(i(!1),r(!1),l(!1))})},O=()=>{i(!1),r(!1),l(!1)};return C(),t.on("selectionUpdate",C),t.on("transaction",C),t.on("focus",C),t.on("blur",O),()=>{cancelAnimationFrame(A),t.off("selectionUpdate",C),t.off("transaction",C),t.off("focus",C),t.off("blur",O)}},[t,k,x]);const M=A=>{A(t),r(!1),c(""),d("all")},v=f4.filter(A=>{const C=u==="all"||A.category===u,O=a===""||A.title.toLowerCase().includes(a.toLowerCase())||A.description.toLowerCase().includes(a.toLowerCase())||A.keywords.some(B=>B.toLowerCase().includes(a.toLowerCase()));return C&&O}),E=v.reduce((A,C)=>(A[C.category]||(A[C.category]=[]),A[C.category].push(C),A),{});return s?g.jsxs(g.Fragment,{children:[g.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:g.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[g.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),g.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(A=>!A),children:[g.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),g.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:g.jsx(jB,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&g.jsxs("div",{ref:y.setFloating,style:{position:b,top:m??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:A=>A.preventDefault(),children:[g.jsx("div",{className:"p-2 border-b border-border",children:g.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:A=>c(A.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),g.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[g.jsx(ce.Button,{variant:u==="all"?"default":"ghost",size:"sm",onClick:()=>d("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(vb).map(([A,C])=>g.jsxs(ce.Button,{variant:u===A?"default":"ghost",size:"sm",onClick:()=>d(A),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[wb[A],C]},A))]}),g.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[u==="all"?Object.entries(E).map(([A,C])=>g.jsxs("div",{className:"py-2",children:[g.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[wb[A],vb[A]]}),C.map(O=>g.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(O.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:O.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:O.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:O.description})]})]})},O.title))]},A)):v.map(A=>g.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(A.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:A.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:A.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:A.description})]})]})},A.title)),v.length===0&&g.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},p4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kb=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function Bk(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function m4(t){return/^<\s*[^/!][^>]*>$/.test(t)}function Sb(t){return/^<\s*\//.test(t)}function g4(t){if(/\/\s*>$/.test(t))return!0;const e=Bk(t);return e?p4.has(e):!1}function y4(t){return/^<\s*!/.test(t)}function Ed(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
166
+ `);return/\s/.test(r)}):!1}function pB(t){return()=>{const e=t.state.selection.$anchor.pos,n=t.view.coordsAtPos(e),{top:r,right:s,bottom:i,left:o}=n;try{return new DOMRect(o,r,s-o,i-r)}catch{return null}}}function mB(t,e,n,r){return n?()=>{const s=r.getState(t.state),i=s?.decorationId,o=e.dom.querySelector(`[data-decoration-id="${i}"]`);return o?.getBoundingClientRect()||null}:pB(t)}function gB({match:t,dismissedRange:e,state:n,transaction:r,editor:s,shouldResetDismissed:i,effectiveAllowSpaces:o}){return i?.({editor:s,state:n,range:e,match:t,transaction:r,allowSpaces:o})?!1:o?t.range.from===e.from:t.range.from===e.from&&!fB(r)}function yB({view:t,pluginKeyRef:e}){const n=t.state.tr.setMeta(e,{exit:!0});t.dispatch(n)}function bB({pluginKey:t,decorationTag:e,decorationClass:n,decorationContent:r,decorationEmptyClass:s,renderer:i,dispatchExit:o}){return{handleKeyDown(l,a){var c,u;const d=t.getState(l.state);return d.active?a.key==="Escape"||a.key==="Esc"?((c=i?.onKeyDown)==null||c.call(i,{view:l,event:a,range:d.range}),o(l),!0):((u=i?.onKeyDown)==null?void 0:u.call(i,{view:l,event:a,range:d.range}))||!1:!1},decorations(l){const a=t.getState(l),{active:c,range:u,decorationId:d,query:h}=a;if(!c)return null;const f=!h?.length,p=[n];return f&&p.push(s),xe.create(l.doc,[Ne.inline(u.from,u.to,{nodeName:e,class:p.join(" "),"data-decoration-id":d||void 0,"data-decoration-content":r})])}}}function xB({editor:t,char:e,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:i,findSuggestionMatch:o,allow:l,shouldShow:a,shouldKeepDismissed:c,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,h,f,p){const{isEditable:m}=t,{composing:y}=t.view,{selection:b}=d,{empty:w,from:k}=b,x={...h},M=d.getMeta(u);if(M&&M.exit)return x.active=!1,x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null,x.dismissedRange=h.active?{...h.range}:h.dismissedRange,x;if(x.composing=y,d.docChanged&&x.dismissedRange!==null&&(x.dismissedRange={from:d.mapping.map(x.dismissedRange.from),to:d.mapping.map(x.dismissedRange.to)}),m&&(w||t.view.composing)){(k<h.range.from||k>h.range.to)&&!y&&!h.composing&&(x.active=!1);const v=o({char:e,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:i,$position:b.$from}),E=`id_${Math.floor(Math.random()*4294967295)}`;v&&l({editor:t,state:p,range:v.range,isActive:h.active})&&(!a||a({editor:t,range:v.range,query:v.query,text:v.text,transaction:d}))?(x.dismissedRange!==null&&!c({match:v,dismissedRange:x.dismissedRange,state:p,transaction:d})&&(x.dismissedRange=null),x.dismissedRange===null?(x.active=!0,x.decorationId=h.decorationId||E,x.range=v.range,x.query=v.query,x.text=v.text):x.active=!1):(v||(x.dismissedRange=null),x.active=!1)}else x.active=!1;return x.active||(x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null),x}}}function wB({editor:t,items:e}){let n=null,r=null,s=null;const i=()=>{r!==null&&(clearTimeout(r),r=null),s?.(),s=null},o=c=>new Promise(u=>{s=u,r=setTimeout(()=>{r=null;const d=s;s=null,d?.()},c)}),l=()=>{n?.abort(),i(),n=null};return{abort:l,fetch:async(c,u)=>{l(),n=new AbortController;const d=n;if(u>0&&await o(u),n!==d||d.signal.aborted)return{status:"aborted"};try{const h=await e({editor:t,query:c,signal:d.signal});return n!==d||d.signal.aborted?{status:"aborted"}:{status:"resolved",items:h}}catch{return n!==d||d.signal.aborted?{status:"aborted"}:{status:"error"}}}}}function vB({placement:t,offset:e,flip:n,floatingUi:r}){var s,i,o,l;const a=[Oc({mainAxis:(s=e.mainAxis)!=null?s:4,crossAxis:(i=e.crossAxis)!=null?i:0})];return n&&a.push(Df()),(o=r?.middleware)!=null&&o.length&&a.push(...r.middleware),{placement:t,strategy:(l=r?.strategy)!=null?l:"absolute",middleware:a}}function kB(t){if(t instanceof HTMLElement)return t;if(typeof t=="string")try{const e=document.querySelector(t);if(e)return e}catch{return document.body}return document.body}function SB({getReferenceRect:t,contextElement:e,config:n,container:r,dismissOnOutsideClick:s,dismiss:i}){return(o,l={})=>{const a={getBoundingClientRect:()=>{var p;return(p=t())!=null?p:new DOMRect},contextElement:e};let c=!1;const u=!o.isConnected;u&&kB(r).appendChild(o),l.onPosition||(o.style.visibility="hidden",o.style.width="max-content");const h=is(a,o,()=>{Dc(a,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:p,y:m,placement:y,strategy:b})=>{if(l.onPosition){l.onPosition({x:p,y:m,placement:y,strategy:b});return}Object.assign(o.style,{position:b,left:`${p}px`,top:`${m}px`}),c||(c=!0,o.style.visibility="")})},l.autoUpdate);let f;return s&&(f=p=>{const m=p.target;!(m instanceof Node)||o.contains(m)||e.contains(m)||i()},document.addEventListener("pointerdown",f,!0)),()=>{h(),f&&document.removeEventListener("pointerdown",f,!0),u&&o.remove()}}}function CB({editor:t,pluginKey:e,items:n,renderer:r,minQueryLength:s,debounce:i,initialItems:o,placement:l,offset:a,container:c,flip:u,floatingUi:d,dismissOnOutsideClick:h,command:f,clientRectFor:p,dispatchExit:m}){let y;const b=wB({editor:t,items:n}),w=vB({placement:l,offset:a,flip:u,floatingUi:d});function k(x,M){var v,E,A;switch(x){case"started":(v=r?.onStart)==null||v.call(r,M);break;case"updated":(E=r?.onUpdate)==null||E.call(r,M);break;case"stopped":(A=r?.onExit)==null||A.call(r,M);break}}return{update:async(x,M)=>{var v,E,A,C;const O=e.getState(M),B=e.getState(x.state);if(!O||!B)return;let D=null;const L=O.query!==B.query,I=O.text!==B.text,V=O.range.from!==B.range.from||O.range.to!==B.range.to,q=L||I||V;if(!O.active&&B.active)D="started";else if(O.active&&!B.active)D="stopped";else if(B.active&&q)D="updated";else return;const ne=D==="stopped"?O:B,_=x.dom.querySelector(`[data-decoration-id="${ne.decorationId}"]`),U=p(x,_),le=s===0||(ne.query?ne.query.length>=s:!1),N=(D==="started"||D==="updated")&&le;if(y={editor:t,range:ne.range,query:ne.query||"",text:ne.text||"",items:o??[],command:K=>f({editor:t,range:ne.range,props:K}),decorationNode:_,clientRect:U,loading:N,placement:l,offset:{mainAxis:(v=a.mainAxis)!=null?v:4,crossAxis:(E=a.crossAxis)!=null?E:0},container:c,flip:u,floatingUi:w,mount:SB({getReferenceRect:U,contextElement:x.dom,config:w,container:c,dismissOnOutsideClick:h,dismiss:()=>m(t.view)})},D==="started"&&((A=r?.onBeforeStart)==null||A.call(r,y)),D==="updated"&&((C=r?.onBeforeUpdate)==null||C.call(r,y)),D==="started"&&k(D,y),D==="started"||D==="updated")if(!N)b.abort(),y={...y,items:o??[],loading:!1};else{y={...y,items:o??[],loading:!0},D="updated",k(D,y);const K=await b.fetch(ne.query||"",i);if(K.status==="aborted")return;const ae=e.getState(x.state);if(!ae?.active){b.abort();return}y=K.status==="resolved"?{...y,items:K.items,loading:!1}:{...y,loading:!1}}if(D==="stopped"){b.abort(),k(D,y),y=void 0;return}D==="updated"&&k(D,y)},destroy:()=>{var x;b.abort(),y&&((x=r?.onExit)==null||x.call(r,y))}}}var EB=new ye("suggestion");function AB({pluginKey:t=EB,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],minQueryLength:f=0,debounce:p=0,initialItems:m,placement:y="bottom-start",offset:b={},container:w,flip:k=!0,floatingUi:x,dismissOnOutsideClick:M=!0,render:v=()=>({}),allow:E=()=>!0,findSuggestionMatch:A=hB,shouldShow:C,shouldResetDismissed:O}){const B=v?.(),D=r&&!s,L=(q,ne)=>mB(e,q,ne,t);function I(q){return gB({...q,editor:e,shouldResetDismissed:O,effectiveAllowSpaces:D})}const V=q=>yB({view:q,pluginKeyRef:t});return new pe({key:t,view:()=>CB({editor:e,pluginKey:t,items:h,renderer:B,minQueryLength:f,debounce:p,initialItems:m,placement:y,offset:b,container:w,flip:k,floatingUi:x,dismissOnOutsideClick:M,command:d,clientRectFor:L,dispatchExit:V}),state:xB({editor:e,char:n,effectiveAllowSpaces:D,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,findSuggestionMatch:A,allow:E,shouldShow:C,shouldKeepDismissed:I,pluginKey:t}),props:bB({pluginKey:t,decorationTag:l,decorationClass:a,decorationContent:c,decorationEmptyClass:u,renderer:B,dispatchExit:V})})}const yk=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const MB=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const TB=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const sb=t=>{const e=TB(t);return e.charAt(0).toUpperCase()+e.slice(1)};var NB={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const RB=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const _B=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>S.createElement("svg",{ref:a,...NB,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:yk("lucide",s),...!i&&!RB(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,u])=>S.createElement(c,u)),...Array.isArray(i)?i:[i]]));const Q=(t,e)=>{const n=S.forwardRef(({className:r,...s},i)=>S.createElement(_B,{ref:i,iconNode:e,className:yk(`lucide-${MB(sb(t))}`,`lucide-${t}`,r),...s}));return n.displayName=sb(t),n};const OB=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],hc=Q("bold",OB);const DB=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ib=Q("circle-alert",DB);const LB=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],IB=Q("circle-check-big",LB);const PB=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],jB=Q("circle-plus",PB);const $B=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],BB=Q("circle-x",$B);const zB=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Fr=Q("code-xml",zB);const HB=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],li=Q("code",HB);const FB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],UB=Q("columns-2",FB);const VB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],WB=Q("columns-3",VB);const qB=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],bk=Q("download",qB);const KB=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],JB=Q("eraser",KB);const GB=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],YB=Q("eye",GB);const XB=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ZB=Q("file-code-corner",XB);const QB=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ez=Q("hash",QB);const tz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Ys=Q("heading-1",tz);const nz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Vo=Q("heading-2",nz);const rz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],tu=Q("heading-3",rz);const sz=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],iz=Q("heading-4",sz);const oz=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],lz=Q("heading-5",oz);const az=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],cz=Q("heading-6",az);const uz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ns=Q("image",uz);const dz=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Cp=Q("italic",dz);const hz=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],nu=Q("link-2",hz);const fz=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Wo=Q("list-ordered",fz);const pz=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],ai=Q("list",pz);const mz=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gz=Q("loader-circle",mz);const yz=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],ru=Q("megaphone",yz);const bz=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],xz=Q("menu",bz);const wz=[["path",{d:"M5 12h14",key:"1ays0h"}]],su=Q("minus",wz);const vz=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Ep=Q("palette",vz);const kz=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Sz=Q("play",kz);const Cz=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Ez=Q("redo-2",Cz);const Az=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],Mz=Q("replace",Az);const Tz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Nz=Q("rotate-ccw",Tz);const Rz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],_z=Q("rows-2",Rz);const Oz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Dz=Q("rows-3",Oz);const Lz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Iz=Q("search",Lz);const Pz=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],jz=Q("sparkles",Pz);const $z=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],iu=Q("square-check-big",$z);const Bz=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],xk=Q("strikethrough",Bz);const zz=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],wk=Q("subscript",zz);const Hz=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],vk=Q("superscript",Hz);const Fz=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],qo=Q("table-2",Fz);const Uz=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Vz=Q("terminal",Uz);const Wz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ko=Q("text-align-center",Wz);const qz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Jo=Q("text-align-end",qz);const Kz=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Ap=Q("text-align-justify",Kz);const Jz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Xs=Q("text-align-start",Jz);const Gz=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],Go=Q("text-quote",Gz);const Yz=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],kk=Q("trash-2",Yz);const Xz=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ou=Q("triangle-alert",Xz);const Zz=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],cs=Q("type",Zz);const Qz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Mp=Q("underline",Qz);const eH=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],tH=Q("undo-2",eH);const nH=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Sk=Q("video",nH);const rH=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ck=Q("x",rH),Tp=S.forwardRef(({items:t,command:e},n)=>{const[r,s]=S.useState(-1),i=S.useRef(null),o=a=>{const c=t[a];c&&e(c)};S.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),S.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),S.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return g.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const u=r!==-1&&c===r;return g.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":u,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(c),className:De.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",u&&"bg-accent text-accent-foreground"),children:[g.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?g.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):g.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});Tp.displayName="SlashCommandList";const sH=[{title:"Text",description:"Start writing with plain text.",icon:S.createElement(cs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:S.createElement(Ys,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:S.createElement(Vo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:S.createElement(tu,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:S.createElement(iz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:S.createElement(lz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:S.createElement(cz,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:S.createElement(ai,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:S.createElement(Wo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:S.createElement(iu,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:S.createElement(Go,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:S.createElement(li,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:S.createElement(su,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:S.createElement(ns,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:S.createElement(qo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:S.createElement(Xs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:S.createElement(Ko,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:S.createElement(Jo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:S.createElement(Ap,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:S.createElement(Sk,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:S.createElement(ou,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:S.createElement(ru,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],Ek=ue.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[AB({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>sH.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Dc(o,e,{placement:"bottom-start",middleware:[Oc(6),Df({fallbackPlacements:["top-start","bottom-start"]}),dw({padding:8}),hw({apply({availableWidth:c,availableHeight:u,elements:d}){Object.assign(d.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,u-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new Xx(Tp,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=is(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var iH=Wf,oH=Yf;mO.extend({draggable:!0});i_.extend({draggable:!0});qR.extend({draggable:!0});iH.extend({draggable:!0});oH.extend({draggable:!0});p1.extend({draggable:!0});m1.extend({draggable:!0});h1.extend({draggable:!0});f1.extend({draggable:!0});const Ak=ue.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),lH=_e.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),aH=_e.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",ge(this.options.HTMLAttributes,t.attrs),0]}}),cH=ue.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),uH=_e.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),dH=_e.create({name:"svg",group:"inline",inline:!0,atom:!0,addOptions(){return{HTMLAttributes:{class:"inline-block align-middle"}}},addAttributes(){return{html:{default:""},viewBox:{default:"0 0 24 24"},width:{default:null},height:{default:null},fill:{default:"none"},stroke:{default:"currentColor"},class:{default:null},style:{default:null},xmlns:{default:"http://www.w3.org/2000/svg"}}},parseHTML(){return[{tag:"svg",priority:60,getAttrs:t=>{if(!(t instanceof Element))return!1;const e={html:t.innerHTML};return t.getAttribute("viewBox")&&(e.viewBox=t.getAttribute("viewBox")),t.getAttribute("width")&&(e.width=t.getAttribute("width")),t.getAttribute("height")&&(e.height=t.getAttribute("height")),t.getAttribute("fill")&&(e.fill=t.getAttribute("fill")),t.getAttribute("stroke")&&(e.stroke=t.getAttribute("stroke")),t.getAttribute("class")&&(e.class=t.getAttribute("class")),t.getAttribute("style")&&(e.style=t.getAttribute("style")),t.getAttribute("xmlns")&&(e.xmlns=t.getAttribute("xmlns")),e}}]},renderHTML({HTMLAttributes:t}){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:n,...r}=t;return Object.entries(ge(this.options.HTMLAttributes,r)).forEach(([s,i])=>{i!=null&&e.setAttribute(s,String(i))}),n&&(e.innerHTML=n),{dom:e}},addNodeView(){return({node:t,HTMLAttributes:e})=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:r,...s}=e;return Object.entries(s).forEach(([i,o])=>{i!=="html"&&o!==null&&o!==void 0&&n.setAttribute(i,String(o))}),t.attrs.html?n.innerHTML=t.attrs.html:r&&(n.innerHTML=r),n.classList.add("parsed-svg-node"),{dom:n}}}}),hH=_e.create({name:"spanComponent",group:"inline",inline:!0,content:"inline*",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}}}},parseHTML(){return[{tag:"span",priority:60,getAttrs:t=>t instanceof HTMLElement&&t.hasAttribute("class")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",ge(this.options.HTMLAttributes,t),0]}}),fH=iB({html:rB,css:q$,js:X$,ts:nB,python:Q$,json:Z$,bash:j$,sql:eB}),ob="http://www.w3.org/2000/svg";function lb(t){const e=document.createElementNS(ob,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(ob,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const fc=[tD.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),j_.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),cI,uI.configure({depth:100,newGroupDelay:500}),h1.configure({lowlight:fH,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),aH,lH,uH,dH,hH,cH,dD.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),p1.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),m1.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),N1.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),wL.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),vL.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),kL.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),HL.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),AL.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),TL,RL,OL.extend({addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{if(t.style.textAlign)return t.style.textAlign;if(t.getAttribute("align"))return t.getAttribute("align");const e=t.getAttribute("class")||"";return/(?:^|\s)text-center(?:\s|$)/.test(e)?"center":/(?:^|\s)text-right(?:\s|$)/.test(e)?"right":/(?:^|\s)text-justify(?:\s|$)/.test(e)?"justify":/(?:^|\s)text-left(?:\s|$)/.test(e)?"left":null},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign} !important`}}}}]}}).configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),aI,pk,FL.configure({limit:5e4,mode:"textSize"}),mk,gk,Ek,Ak,h$,P$.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[Oc({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=lb(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=lb(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var pH=typeof document<"u",mH=function(){},jh=pH?S.useLayoutEffect:mH;const gH={...se},yH=gH.useInsertionEffect,bH=yH||(t=>t());function xH(t){const e=se.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return bH(()=>{e.current=t}),se.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var wH=typeof document<"u",vH=function(){},ta=wH?S.useLayoutEffect:vH;function pc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!pc(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!pc(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Mk(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function ab(t,e){const n=Mk(t);return Math.round(e*n)/n}function Cd(t){const e=se.useRef(t);return ta(()=>{e.current=t}),e}function kH(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=se.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=se.useState(r);pc(h,r)||f(r);const[p,m]=se.useState(null),[y,b]=se.useState(null),w=se.useCallback(_=>{_!==v.current&&(v.current=_,m(_))},[]),k=se.useCallback(_=>{_!==E.current&&(E.current=_,b(_))},[]),x=i||p,M=o||y,v=se.useRef(null),E=se.useRef(null),A=se.useRef(u),C=a!=null,O=Cd(a),B=Cd(s),D=Cd(c),L=se.useCallback(()=>{if(!v.current||!E.current)return;const _={placement:e,strategy:n,middleware:h};B.current&&(_.platform=B.current),Dc(v.current,E.current,_).then(U=>{const le={...U,isPositioned:D.current!==!1};I.current&&!pc(A.current,le)&&(A.current=le,RS.flushSync(()=>{d(le)}))})},[h,e,n,B,D]);ta(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,d(_=>({..._,isPositioned:!1})))},[c]);const I=se.useRef(!1);ta(()=>(I.current=!0,()=>{I.current=!1}),[]),ta(()=>{if(x&&(v.current=x),M&&(E.current=M),x&&M){if(O.current)return O.current(x,M,L);L()}},[x,M,L,O,C]);const V=se.useMemo(()=>({reference:v,floating:E,setReference:w,setFloating:k}),[w,k]),q=se.useMemo(()=>({reference:x,floating:M}),[x,M]),ne=se.useMemo(()=>{const _={position:n,left:0,top:0};if(!q.floating)return _;const U=ab(q.floating,u.x),le=ab(q.floating,u.y);return l?{..._,transform:"translate("+U+"px, "+le+"px)",...Mk(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:le}},[n,l,q.floating,u.x,u.y]);return se.useMemo(()=>({...u,update:L,refs:V,elements:q,floatingStyles:ne}),[u,L,V,q,ne])}const Yo=(t,e)=>{const n=Oc(t);return{name:n.name,fn:n.fn,options:[t,e]}},lu=(t,e)=>{const n=dw(t);return{name:n.name,fn:n.fn,options:[t,e]}},au=(t,e)=>{const n=Df(t);return{name:n.name,fn:n.fn,options:[t,e]}},SH=(t,e)=>{const n=hw(t);return{name:n.name,fn:n.fn,options:[t,e]}},CH={...se};let cb=!1,EH=0;const ub=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+EH++;function AH(){const[t,e]=se.useState(()=>cb?ub():void 0);return jh(()=>{t==null&&e(ub())},[]),se.useEffect(()=>{cb=!0},[]),t}const MH=CH.useId,TH=MH||AH;let $h;process.env.NODE_ENV!=="production"&&($h=new Set);function NH(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=$h)!=null&&t.has(s))){var i;(i=$h)==null||i.add(s),console.error(s)}}function RH(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const _H=se.createContext(null),OH=se.createContext(null),DH=()=>{var t;return((t=se.useContext(_H))==null?void 0:t.id)||null},LH=()=>se.useContext(OH);function IH(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=TH(),i=se.useRef({}),[o]=se.useState(()=>RH()),l=DH()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ht(f)&&NH("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=se.useState(r.reference),u=xH((f,p,m)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:m,nested:l}),n?.(f,p,m)}),d=se.useMemo(()=>({setPositionReference:c}),[]),h=se.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return se.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:h,events:o,floatingId:s,refs:d}),[e,u,h,o,s,d])}function Xo(t){t===void 0&&(t={});const{nodeId:e}=t,n=IH({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=se.useState(null),[l,a]=se.useState(null),u=s?.domReference||i,d=se.useRef(null),h=LH();jh(()=>{u&&(d.current=u)},[u]);const f=kH({...t,elements:{...s,...l&&{reference:l}}}),p=se.useCallback(k=>{const x=ht(k)?{getBoundingClientRect:()=>k.getBoundingClientRect(),getClientRects:()=>k.getClientRects(),contextElement:k}:k;a(x),f.refs.setReference(x)},[f.refs]),m=se.useCallback(k=>{(ht(k)||k===null)&&(d.current=k,o(k)),(ht(f.refs.reference.current)||f.refs.reference.current===null||k!==null&&!ht(k))&&f.refs.setReference(k)},[f.refs]),y=se.useMemo(()=>({...f.refs,setReference:m,setPositionReference:p,domReference:d}),[f.refs,m,p]),b=se.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),w=se.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return jh(()=>{r.dataRef.current.floatingContext=w;const k=h?.nodesRef.current.find(x=>x.id===e);k&&(k.context=w)}),se.useMemo(()=>({...f,context:w,refs:y,elements:b}),[f,y,b,w])}const PH="_pickerRoot_bg11z_1",jH="_picker_bg11z_1",db={pickerRoot:PH,picker:jH};function cu(){return(cu=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function Tk(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Yi(t){var e=S.useRef(t),n=S.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var No=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},Xi=function(t){return"touches"in t},Bh=function(t){return t&&t.ownerDocument.defaultView||self},hb=function(t,e,n){var r=t.getBoundingClientRect(),s=Xi(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:No((s.pageX-(r.left+Bh(t).pageXOffset))/r.width),top:No((s.pageY-(r.top+Bh(t).pageYOffset))/r.height)}},fb=function(t){!Xi(t)&&t.preventDefault()},Nk=S.memo(function(t){var e=t.onMove,n=t.onKey,r=t.onEnd,s=Tk(t,["onMove","onKey","onEnd"]),i=S.useRef(null),o=Yi(e),l=Yi(n),a=Yi(r),c=S.useRef(null),u=S.useRef(!1),d=S.useMemo(function(){var y=function(k){fb(k),(Xi(k)?k.touches.length>0:k.buttons>0)&&i.current?o(hb(i.current,k,c.current)):(w(!1),a())},b=function(){w(!1),a()};function w(k){var x=u.current,M=Bh(i.current),v=k?M.addEventListener:M.removeEventListener;v(x?"touchmove":"mousemove",y),v(x?"touchend":"mouseup",b)}return[function(k){var x=k.nativeEvent,M=i.current;if(M&&(fb(x),!(function(E,A){return A&&!Xi(E)})(x,u.current)&&M)){if(Xi(x)){u.current=!0;var v=x.changedTouches||[];v.length&&(c.current=v[0].identifier)}M.focus(),o(hb(M,x,c.current)),w(!0)}},function(k){var x=k.which||k.keyCode;x<37||x>40||(k.preventDefault(),l({left:x===39?.05:x===37?-.05:0,top:x===40?.05:x===38?-.05:0}))},function(k){var x=k.which||k.keyCode;x>=37&&x<=40&&a()},w]},[l,o,a]),h=d[0],f=d[1],p=d[2],m=d[3];return S.useEffect(function(){return m},[m]),S.createElement("div",cu({},s,{onTouchStart:h,onMouseDown:h,className:"react-colorful__interactive",ref:i,onKeyDown:f,onKeyUp:p,tabIndex:0,role:"slider"}))}),Np=function(t){return t.filter(Boolean).join(" ")},Rk=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=Np(["react-colorful__pointer",t.className]);return S.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},S.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},at=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},$H=function(t){return UH(zh(t))},zh=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?at(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?at(parseInt(t.substring(6,8),16)/255,2):1}},BH=function(t){return FH(HH(t))},zH=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:at(t.h),s:at(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:at(s/2),a:at(r,2)}},Hh=function(t){var e=zH(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},HH=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:at(255*[r,l,o,o,a,r][c]),g:at(255*[a,r,r,l,o,o][c]),b:at(255*[o,o,a,r,r,l][c]),a:at(s,2)}},Dl=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},FH=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Dl(at(255*s)):"";return"#"+Dl(e)+Dl(n)+Dl(r)+i},UH=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:at(60*(l<0?l+6:l)),s:at(i?o/i*100:0),v:at(i/255*100),a:s}},VH=S.memo(function(t){var e=t.hue,n=t.onChange,r=t.onChangeEnd,s=Np(["react-colorful__hue",t.className]);return S.createElement("div",{className:s},S.createElement(Nk,{onMove:function(i){n({h:360*i.left})},onKey:function(i){n({h:No(e+360*i.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":at(e),"aria-valuemax":"360","aria-valuemin":"0"},S.createElement(Rk,{className:"react-colorful__hue-pointer",left:e/360,color:Hh({h:e,s:100,v:100,a:1})})))}),WH=S.memo(function(t){var e=t.hsva,n=t.onChange,r=t.onChangeEnd,s={backgroundColor:Hh({h:e.h,s:100,v:100,a:1})};return S.createElement("div",{className:"react-colorful__saturation",style:s},S.createElement(Nk,{onMove:function(i){n({s:100*i.left,v:100-100*i.top})},onKey:function(i){n({s:No(e.s+100*i.left,0,100),v:No(e.v-100*i.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+at(e.s)+"%, Brightness "+at(e.v)+"%"},S.createElement(Rk,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Hh(e)})))}),_k=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},qH=function(t,e){return t.toLowerCase()===e.toLowerCase()||_k(zh(t),zh(e))};function KH(t,e,n,r){var s=Yi(n),i=Yi(r),o=S.useState(function(){return t.toHsva(e)}),l=o[0],a=o[1],c=S.useRef({color:e,hsva:l}),u=S.useRef(!1);S.useEffect(function(){if(!t.equal(e,c.current.color)){var f=t.toHsva(e);c.current={hsva:f,color:e},a(f),u.current=!1}},[e,t]),S.useEffect(function(){var f;_k(l,c.current.hsva)||t.equal(f=t.fromHsva(l),c.current.color)||(c.current={hsva:l,color:f},s(f),u.current=!0)},[l,t,s]);var d=S.useCallback(function(f){a(function(p){return Object.assign({},p,f)})},[]),h=S.useCallback(function(){u.current&&(u.current=!1,i(c.current.color))},[i]);return[l,d,h]}var JH=typeof window<"u"?S.useLayoutEffect:S.useEffect,GH=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},pb=new Map,YH=function(t){JH(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!pb.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,pb.set(e,n);var r=GH();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},XH=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=t.onChangeEnd,l=Tk(t,["className","colorModel","color","onChange","onChangeEnd"]),a=S.useRef(null);YH(a);var c=KH(n,s,i,o),u=c[0],d=c[1],h=c[2],f=Np(["react-colorful",e]);return S.createElement("div",cu({},l,{ref:a,className:f}),S.createElement(WH,{hsva:u,onChange:d,onChangeEnd:h}),S.createElement(VH,{hue:u.h,onChange:d,onChangeEnd:h,className:"react-colorful__last-control"}))},ZH={defaultColor:"000",toHsva:$H,fromHsva:function(t){return BH({h:t.h,s:t.s,v:t.v,a:1})},equal:qH},QH=function(t){return S.createElement(XH,cu({},t,{colorModel:ZH}))};const mb="#1F2937",gb="#FFF7D1",e4=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],t4=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],n4=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,r4=/^#[0-9a-f]{6}$/i,Ok=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,Dk=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function mc(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function Lk(t){const e=mc(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Fh(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function Zi(t,e=2){const n=10**e;return Math.round(t*n)/n}function Qi(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,u=0;const d=(l+a)/2;if(l!==a){const m=l-a;switch(u=d>.5?m/(2-l-a):m/(l+a),l){case s:c=(i-o)/m+(i<o?6:0);break;case i:c=(o-s)/m+2;break;case o:c=(s-i)/m+4;break}c/=6}const h=Math.round(c*360),f=Math.round(u*100),p=Math.round(d*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${Zi(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function yb(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function In(t){if(!t)return null;const e=t.trim();if(n4.test(e)){const r=mc(e),s=Lk(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${Zi(s.a,2)})`,hsl:Qi(s.r,s.g,s.b,s.a),alpha:s.a}}if(Ok.test(e)||Dk.test(e)){const r=yb(e);return r?{source:e,hex:Fh(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${Zi(r.a,2)})`,hsl:Qi(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=yb(e);return n?{source:e,hex:Fh(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${Zi(n.a,2)})`,hsl:Qi(n.r,n.g,n.b,n.a),alpha:n.a}:null}function Ik(t){const e=Lk(t);if(e)return{source:mc(t),hex:Fh(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Zi(e.a,2)})`,hsl:Qi(e.r,e.g,e.b,e.a),alpha:e.a};const n=mc(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:Qi(0,0,0,1),alpha:1}}const yi=In(mb)??Ik(mb),bb=In(gb)??Ik(gb);function Pk({editor:t,className:e,initialMode:n="text"}){const r=S.useRef(null),[s,i]=S.useState(n),[o,l]=S.useState(null),[a,c]=S.useState(yi),[u,d]=S.useState(bb);S.useEffect(()=>{i(n)},[n]);const[h,f]=S.useState(yi.hex),[p,m]=S.useState(!1),[y,b]=S.useState(yi.rgb),[w,k]=S.useState(!1),[x,M]=S.useState(yi.hsl),[v,E]=S.useState(!1),A=s==="text"?a:u;S.useEffect(()=>{const L=()=>{if(o)return;const I=t.getAttributes("textStyle").color,V=t.getAttributes("highlight").color,q=In(I)??yi,ne=In(V)??bb;c(q),d(ne)};return L(),t.on("selectionUpdate",L),t.on("transaction",L),()=>{t.off("selectionUpdate",L),t.off("transaction",L)}},[t,o,s]),S.useEffect(()=>{o!=="hex"&&f(A.hex),o!=="rgb"&&b(A.rgb),o!=="hsl"&&M(A.hsl),o===null&&(m(!1),k(!1),E(!1))},[A,o]);const C=S.useCallback((L,I,V=!0)=>{const q=t.chain();V&&q.focus(),L==="text"?(c(I),q.setColor(I.source).run()):(d(I),q.setHighlight({color:I.source}).run())},[t,c,d]),O=S.useCallback((L,I)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{C(L,I,!1)},300)},[C]),B=S.useCallback(L=>{r.current&&clearTimeout(r.current);const I=In(L);I&&(C(s,I,!1),m(!1))},[C,s,m]),D=S.useCallback(L=>{r.current&&clearTimeout(r.current);const I=In(L);I&&(C(s,I),m(!1))},[C,s,m]);return g.jsxs("div",{className:De.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[g.jsx(ce.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),g.jsx(ce.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),g.jsx("div",{className:"flex items-center",children:g.jsx(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),g.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[g.jsx("div",{className:db.pickerRoot,children:g.jsx(QH,{color:A.hex,onChange:B,className:db.picker})}),g.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),g.jsx(Es.Input,{value:h,onFocus:()=>l("hex"),onChange:L=>{const I=L.target.value;if(f(I),r4.test(I)){const V=In(I);V&&(O(s,V),m(!1))}else m(!0)},onBlur:()=>{l(null),p&&(f(A.hex),m(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),g.jsx(Es.Input,{value:y,onFocus:()=>l("rgb"),onChange:L=>{const I=L.target.value;if(b(I),Ok.test(I)){const V=In(I);V&&(O(s,V),k(!1))}else k(!0)},onBlur:()=>{l(null),w&&(b(A.rgb),k(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),g.jsx(Es.Input,{value:x,onFocus:()=>l("hsl"),onChange:L=>{const I=L.target.value;if(M(I),Dk.test(I)){const V=In(I);V&&(O(s,V),E(!1))}else E(!0)},onBlur:()=>{l(null),v&&(M(A.hsl),E(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",v&&"border-destructive focus-visible:ring-destructive")})]})]})]}),g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),g.jsx("div",{className:"space-y-1",children:t4.map(L=>g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:L.title}),g.jsx("div",{className:"flex items-center gap-1.5",children:L.colors.map(I=>g.jsx("button",{type:"button",onClick:()=>D(I.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:I.value},"aria-label":`${L.title} color ${I.label}`,title:`${L.title} color ${I.label}`},I.label))})]},L.title))})]}),s==="highlight"?g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),g.jsx("div",{className:"flex flex-wrap gap-1.5",children:e4.map(L=>g.jsxs("button",{type:"button",onClick:()=>D(L),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[g.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:L},"aria-hidden":!0}),L]},L))})]}):null]})}const s4=["px","pt","rem","em","%"];function na(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Uh(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function i4(t){const e=na(t);return e?Uh(e):null}function o4(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const d=c.style.fontSize,h=c.selectorText;if(d&&h&&o.has(h)){const f=i4(d)??d.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function l4(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function gc(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Rp(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:gc()}catch{return gc()}}function a4(t,e,n){const r=gc(),s=Rp(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function c4(t,e,n){const r=gc(),s=Rp(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function jk({editor:t,className:e}){const[n,r]=S.useState([]),[s,i]=S.useState(null),[o,l]=S.useState(""),[a,c]=S.useState("px"),[u,d]=S.useState(!1),h=S.useRef(null),f=S.useCallback(()=>{const x=t.getAttributes("textStyle").fontSize,M=na(x);if(M)l(String(M.value)),c(M.unit),d(!1);else{if(x&&typeof x=="string"){const v=l4(x);if(v>0&&!s){l(String(Math.round(v))),c("px"),d(!1);return}}s||(l(""),c("px"),d(!1))}},[t,s]);S.useEffect(()=>{f();const x=()=>f();return t.on("selectionUpdate",x),t.on("transaction",x),()=>{t.off("selectionUpdate",x),t.off("transaction",x)}},[t,f]),S.useEffect(()=>{r(o4())},[]);const p=S.useCallback((x,M=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const v=t.chain();M&&v.focus(),v.setFontSize(x).run()},120)},[t]),m=S.useCallback(x=>{l(x);const M=`${x}${a}`,v=na(M);if(v){d(!1);const E=Uh(v);E&&p(E,!1)}else d(x.trim().length>0)},[a,p]),y=S.useCallback(x=>{const M=a;c(x);let v=0;const E=parseFloat(o);Number.isFinite(E)?v=a4(E,M,t):v=Rp(t);const A=c4(v,x,t);let C;x==="px"||x==="pt"||x==="%"?C=String(Math.round(A)):C=String(Math.max(.01,Math.round(A*100)/100)),l(C);const O=Uh(na(`${C}${x}`));O&&p(O)},[a,o,t,p]),b=S.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),d(!1)},[t]),w=S.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),k=S.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return g.jsxs("div",{className:De.cn("space-y-3",e),onMouseDown:x=>x.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(cs,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),g.jsxs(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[g.jsx(JB,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),g.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),g.jsx(Es.Input,{type:"number",inputMode:"decimal",step:w,placeholder:k,value:o,onFocus:()=>i("value"),onChange:x=>m(x.target.value),onBlur:()=>i(null),className:De.cn("h-9",u&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),g.jsx("div",{className:"flex gap-1",children:g.jsx("select",{value:a,onChange:x=>y(x.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s4.map(x=>g.jsx("option",{value:x,children:x},x))})})]})]}),g.jsxs("div",{className:"space-y-2",children:[n.length>0?g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:x,value:M})=>g.jsx("button",{type:"button",onClick:()=>p(M),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${x} (${M})`,children:`H${x} (${M})`},`h${x}`))})]}):null,g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(x=>g.jsx("button",{type:"button",onClick:()=>p(x),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${x}`,children:x.replace(/\b\w/g,M=>M.toUpperCase())},x))})]})]})]})}const u4=({editor:t})=>{const[e,n]=S.useState(t.getAttributes("link")?.href??"");S.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return g.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[g.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),g.jsx(ce.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},d4=({editor:t})=>g.jsx("div",{className:"w-[380px]",children:g.jsx(Pk,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),_p=({editor:t})=>{const[e,n]=S.useState(!1),[r,s]=S.useState(!1),[i,o]=S.useState(!1),[l,a]=S.useState(!1),{x:c,y:u,refs:d,strategy:h,update:f}=Xo({placement:"top",middleware:[Yo(6),au(),lu()],whileElementsMounted:is}),p=S.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:w}=y.selection,k=b!==w,x=y.selection instanceof Z,M=t.isActive("codeBlock"),v=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),E=t.isActive("image");return k&&!x&&!M&&!v&&!E},[t]),m=S.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,w=t.view.coordsAtPos(y),k=t.view.coordsAtPos(b),x={getBoundingClientRect:()=>({x:w.left,y:w.top,top:w.top,left:w.left,bottom:k.bottom,right:k.right,width:k.right-w.left,height:k.bottom-w.top})};d.setReference(x),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,d,f,p]);return S.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),m()):!i&&!l&&n(!1)})},w=({event:k})=>{i||l||d.floating.current&&k.relatedTarget&&d.floating.current.contains(k.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",w),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",w)}},[t,p,m,i,l,d.floating]),!t||!e?null:g.jsxs("div",{ref:d.setFloating,style:{position:h,top:u??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:g.jsx(hc,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:g.jsx(Cp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:g.jsx(Mp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:g.jsx(xk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:g.jsx(li,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:g.jsx(wk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:g.jsx(vk,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:g.jsx(Xs,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:g.jsx(Ko,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:g.jsx(Jo,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:g.jsx(Ap,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsxs(wt.Popover,{open:l,onOpenChange:a,children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:g.jsx(cs,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:g.jsx(jk,{editor:t,className:"p-4"})})]}),g.jsxs(wt.Popover,{children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:g.jsx(nu,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:g.jsx(u4,{editor:t})})]}),g.jsxs(wt.Popover,{open:i,onOpenChange:o,children:[g.jsx(wt.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:g.jsx(Ep,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(wt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:g.jsx(d4,{editor:t})})]}),g.jsx("div",{className:"w-px bg-border h-5"})]})};function xb(t,e){t.storage.mediaPicker={open:e}}function uu(t){return t.storage?.mediaPicker?.open}const h4=[{title:"Heading 1",icon:g.jsx(Ys,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:g.jsx(Vo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:g.jsx(Wo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:g.jsx(Go,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:g.jsx(ns,{className:"h-4 w-4"}),command:async t=>{const e=uu(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:g.jsx(su,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:g.jsx(nu,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:g.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:g.jsx(ou,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:g.jsx(ru,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],Op=({editor:t})=>{const[e,n]=S.useState(!1),[r,s]=S.useState(null),[i,o]=S.useState(null),l=S.useRef(null),a=S.useRef(null),c=S.useRef(!1),u=S.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:d,y:h,refs:f,strategy:p}=Xo({placement:"right-start",open:e,middleware:[Yo(8),au(),lu()],whileElementsMounted:is});S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const m=S.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);S.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const w=k=>{const x=k,{handle:M,button:v}=x.detail;try{const A=t.state.selection?.$from;if(A){let C=A.depth;for(;C>0&&!A.node(C)?.isBlock;)C-=1;const O=typeof A.after=="function"?A.after(C):void 0;typeof O=="number"?o(O):typeof A.pos=="number"?o(A.pos):o(null)}else o(null)}catch{o(null)}if(l.current===v&&c.current){u();return}l.current&&l.current!==v&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==M&&a.current.removeAttribute("data-menu-open"),l.current=v,a.current=M,v.setAttribute("aria-expanded","true"),M.setAttribute("data-menu-open","true"),s(v),n(!0)};return b.addEventListener("tiptap-gutter-toggle",w),()=>{b.removeEventListener("tiptap-gutter-toggle",w)}},[t,m,u]),S.useEffect(()=>{if(!t)return;const b=()=>{m()||u()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",u),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",u)}},[t,m,u]),S.useEffect(()=>{if(!e)return;const b=k=>{const x=k.target,M=f.floating.current;if(M&&!M.contains(x)){const v=l.current;(!v||!v.contains(x))&&u()}},w=k=>{k.key==="Escape"&&u()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[e,u,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),u()};return!r||!e?null:g.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:d??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:g.jsx("div",{className:"flex flex-col",children:h4.map(b=>g.jsxs(ce.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,g.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},f4=[{title:"Text",description:"Start writing with plain text",icon:g.jsx(cs,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:g.jsx(Ys,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:g.jsx(Vo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:g.jsx(tu,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:g.jsx(Wo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:g.jsx(iu,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:g.jsx(ns,{className:"h-4 w-4"}),command:async t=>{const e=uu(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:g.jsx(Sk,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:g.jsx(Go,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:g.jsx(su,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:g.jsx(ou,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:g.jsx(ru,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],wb={basic:g.jsx(cs,{className:"h-3 w-3"}),headings:g.jsx(ez,{className:"h-3 w-3"}),lists:g.jsx(ai,{className:"h-3 w-3"}),media:g.jsx(ns,{className:"h-3 w-3"}),advanced:g.jsx(Vz,{className:"h-3 w-3"})},vb={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},$k=({editor:t,wrapperRef:e})=>{const[n,r]=S.useState(!1),[s,i]=S.useState(!1),[o,l]=S.useState(!1),[a,c]=S.useState(""),[u,d]=S.useState("all"),[h,f]=S.useState({top:-9999,left:-9999,width:0}),{x:p,y:m,refs:y,strategy:b,update:w}=Xo({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Yo(10),au({fallbackPlacements:["top-start","bottom-start","right-start"]}),lu({padding:8}),SH({apply({availableWidth:A,availableHeight:C,elements:O}){Object.assign(O.floating.style,{maxWidth:`${Math.min(400,A-16)}px`,maxHeight:`${Math.min(500,C-16)}px`})}})],whileElementsMounted:is}),k=S.useCallback(()=>{const{$from:A}=t.state.selection,C=A.parent;if(C.type.name==="paragraph"&&C.content.size===0||C.type.name==="heading"&&C.content.size===0)return!0;if(C.type.name==="listItem"&&C.content.size===1){const O=C.firstChild;if(O&&O.type.name==="paragraph"&&O.content.size===0)return!0}return t.isEditable},[t]),x=S.useCallback(()=>{if(!e?.current)return;const A=e.current.getBoundingClientRect(),C=t.view.dom.getBoundingClientRect(),B=t.view.coordsAtPos(t.state.selection.from).top-A.top,D=C.left-A.left,L=C.width;f({top:B,left:D,width:L}),w(),requestAnimationFrame(()=>l(!0))},[t,w,e]);S.useEffect(()=>{if(!t)return;let A=0;const C=()=>{cancelAnimationFrame(A),A=requestAnimationFrame(()=>{k()?(i(!0),l(!1),x()):(i(!1),r(!1),l(!1))})},O=()=>{i(!1),r(!1),l(!1)};return C(),t.on("selectionUpdate",C),t.on("transaction",C),t.on("focus",C),t.on("blur",O),()=>{cancelAnimationFrame(A),t.off("selectionUpdate",C),t.off("transaction",C),t.off("focus",C),t.off("blur",O)}},[t,k,x]);const M=A=>{A(t),r(!1),c(""),d("all")},v=f4.filter(A=>{const C=u==="all"||A.category===u,O=a===""||A.title.toLowerCase().includes(a.toLowerCase())||A.description.toLowerCase().includes(a.toLowerCase())||A.keywords.some(B=>B.toLowerCase().includes(a.toLowerCase()));return C&&O}),E=v.reduce((A,C)=>(A[C.category]||(A[C.category]=[]),A[C.category].push(C),A),{});return s?g.jsxs(g.Fragment,{children:[g.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:g.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[g.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),g.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(A=>!A),children:[g.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),g.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:g.jsx(jB,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&g.jsxs("div",{ref:y.setFloating,style:{position:b,top:m??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:A=>A.preventDefault(),children:[g.jsx("div",{className:"p-2 border-b border-border",children:g.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:A=>c(A.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),g.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[g.jsx(ce.Button,{variant:u==="all"?"default":"ghost",size:"sm",onClick:()=>d("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(vb).map(([A,C])=>g.jsxs(ce.Button,{variant:u===A?"default":"ghost",size:"sm",onClick:()=>d(A),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[wb[A],C]},A))]}),g.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[u==="all"?Object.entries(E).map(([A,C])=>g.jsxs("div",{className:"py-2",children:[g.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[wb[A],vb[A]]}),C.map(O=>g.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(O.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:O.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:O.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:O.description})]})]})},O.title))]},A)):v.map(A=>g.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(A.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:A.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:A.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:A.description})]})]})},A.title)),v.length===0&&g.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},p4=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kb=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function Bk(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function m4(t){return/^<\s*[^/!][^>]*>$/.test(t)}function Sb(t){return/^<\s*\//.test(t)}function g4(t){if(/\/\s*>$/.test(t))return!0;const e=Bk(t);return e?p4.has(e):!1}function y4(t){return/^<\s*!/.test(t)}function Ed(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
167
167
  `).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0;const i=[];let o=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=Bk(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&Sb(a)&&(o=null),Sb(a)&&s>0&&(s-=1);const u=c&&kb.has(c)||y4(a),d=`${u?r.repeat(s):""}${a.trim()}`;if(u)i.push(d);else{const h=i.length?i[i.length-1]:"";h&&!h.endsWith(`
168
168
  `)?i[i.length-1]=h+a.trim():i.push(r.repeat(s)+a.trim())}c&&m4(a)&&!g4(a)&&kb.has(c)&&(s+=1,(c==="pre"||c==="code"||c==="script"||c==="style")&&(o=c))}else if(o){const c=a.split(`
169
169
  `);for(const u of c)i.push(u)}else{const c=a.replace(/\s+/g," ");if(c.length>0){const u=i.length?i[i.length-1]:"";if(u&&!u.endsWith(`