-`?n.push(ut()):s===" "?n.push(St()):n.push(q(s))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,s=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(s=n,l=t),s.type==="element"&&uN(s,l,r,i);let a=s.offset,c=l.offset,m=this.getNodes(),f=m.length,d=m[0];y(d)||x(!1,"insertText: first node is not a text node");let p=d.getTextContent().length,g=d.getParentOrThrow(),h=f-1,C=m[h];if(f===1&&l.type==="element"&&(c=p,l.set(s.key,c,"text")),this.isCollapsed()&&a===p&&(d.isSegmented()||d.isToken()||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&d.getNextSibling()===null)){let N=d.getNextSibling();if((!y(N)||!N.canInsertTextBefore()||ze(N))&&(N=q(),N.setFormat(r),N.setStyle(i),g.canInsertTextAfter()?d.insertAfter(N):g.insertAfter(N)),N.select(0,0),d=N,e!==""){this.insertText(e);return}}else if(this.isCollapsed()&&a===0&&(d.isSegmented()||d.isToken()||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&d.getPreviousSibling()===null)){let N=d.getPreviousSibling();if((!y(N)||ze(N))&&(N=q(),N.setFormat(r),g.canInsertTextBefore()?d.insertBefore(N):g.insertBefore(N)),N.select(),d=N,e!==""){this.insertText(e);return}}else if(d.isSegmented()&&a!==p){let N=q(d.getTextContent());N.setFormat(r),d.replace(N),d=N}else if(!this.isCollapsed()&&e!==""){let N=C.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||E(N)&&(!N.canInsertTextBefore()||!N.canInsertTextAfter())){this.insertText(""),qd(this.anchor,this.focus,null),this.insertText(e);return}}if(f===1){if(d.isToken()){let S=q(e);S.select(),d.replace(S);return}let N=d.getFormat(),L=d.getStyle();if(a===c&&(N!==r||L!==i))if(d.getTextContent()==="")d.setFormat(r),d.setStyle(i);else{let S=q(e);if(S.setFormat(r),S.setStyle(i),S.select(),a===0)d.insertBefore(S,!1);else{let[A]=d.splitText(a);A.insertAfter(S,!1)}S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);return}else if(yl(d)){let S=q(e);S.setFormat(r),S.setStyle(i),S.select(),d.replace(S);return}let M=c-a;d=d.spliceText(a,M,e,!0),d.getTextContent()===""?d.remove():this.anchor.type==="text"&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=N,this.style=L))}else{let N=new Set([...d.getParentKeys(),...C.getParentKeys()]),L=E(d)?d:d.getParentOrThrow(),M=E(C)?C:C.getParentOrThrow(),S=C;if(!L.is(M)&&M.isInline())do S=M,M=M.getParentOrThrow();while(M.isInline());if(l.type==="text"&&(c!==0||C.getTextContent()==="")||l.type==="element"&&C.getIndexWithinParent()<c)if(y(C)&&!C.isToken()&&c!==C.getTextContentSize()){if(C.isSegmented()){let k=q(C.getTextContent());C.replace(k),C=k}!oe(l.getNode())&&l.type==="text"&&(C=C.spliceText(0,c,"")),N.add(C.__key)}else{let k=C.getParentOrThrow();!k.canBeEmpty()&&k.getChildrenSize()===1?k.remove():C.remove()}else N.add(C.__key);let A=M.getChildren(),O=new Set(m),R=L.is(M),P=L.isInline()&&d.getNextSibling()===null?L:d;for(let k=A.length-1;k>=0;k--){let W=A[k];if(W.is(d)||E(W)&&W.isParentOf(d))break;W.isAttached()&&(!O.has(W)||W.is(S)?R||P.insertAfter(W,!1):W.remove())}if(!R){let k=M,W=null;for(;k!==null;){let ie=k.getChildren(),ln=ie.length;(ln===0||ie[ln-1].is(W))&&(N.delete(k.__key),W=k),k=k.getParent()}}if(!d.isToken())d=d.spliceText(a,p-a,e,!0),d.getTextContent()===""?d.remove():d.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);else if(a===p)d.select();else{let k=q(e);k.select(),d.replace(k)}for(let k=1;k<f;k++){let W=m[k],ie=W.__key;N.has(ie)||W.remove()}}}removeText(){this.insertText("")}formatText(e){if(this.isCollapsed()){this.toggleFormat(e),se(null);return}let t=this.getNodes(),n=[];for(let N of t)y(N)&&n.push(N);let r=n.length;if(r===0){this.toggleFormat(e),se(null);return}let i=this.anchor,s=this.focus,l=this.isBackward(),a=l?s:i,c=l?i:s,m=0,f=n[0],d=a.type==="element"?0:a.offset;if(a.type==="text"&&d===f.getTextContentSize()&&(m=1,f=n[1],d=0),f==null)return;let u=f.getFormatFlags(e,null),p=r-1,g=n[p],h=c.type==="text"?c.offset:g.getTextContentSize();if(f.is(g)){if(d===h)return;if(ze(f)||d===0&&h===f.getTextContentSize())f.setFormat(u);else{let N=f.splitText(d,h),L=d===0?N[0]:N[1];L.setFormat(u),a.type==="text"&&a.set(L.__key,0,"text"),c.type==="text"&&c.set(L.__key,h-d,"text")}this.format=u;return}d!==0&&!ze(f)&&([,f]=f.splitText(d),d=0),f.setFormat(u);let C=g.getFormatFlags(e,u);h>0&&(h!==g.getTextContentSize()&&!ze(g)&&([g]=g.splitText(h)),g.setFormat(C));for(let N=m+1;N<p;N++){let L=n[N],M=L.getFormatFlags(e,C);L.setFormat(M)}a.type==="text"&&a.set(f.__key,d,"text"),c.type==="text"&&c.set(g.__key,h,"text"),this.format=u|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();let h=T();return x(_(h),"Expected RangeSelection after insertParagraph"),h.insertNodes(e)}let t=this.isBackward()?this.focus:this.anchor,n=mi(t.getNode(),$o),r=e[e.length-1];if("__language"in n&&E(n)){if("__language"in e[0])this.insertText(e[0].getTextContent());else{let h=Ll(this);n.splice(h,0,e),r.selectEnd()}return}let i=h=>(E(h)||B(h))&&!h.isInline();if(!e.some(i)){x(E(n),"Expected 'firstBlock' to be an ElementNode");let h=Ll(this);n.splice(h,0,e),r.selectEnd();return}let s=NN(e),l=s.getLastDescendant(),a=s.getChildren(),c=h=>E(h)&&$o(h)&&!h.isEmpty()&&E(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),f=!E(n)||!n.isEmpty()?this.insertParagraph():null,d=a[a.length-1],u=a[0];c(u)&&(x(E(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...u.getChildren()),u=a[1]),u&&kd(n,u);let p=mi(l,$o);f&&E(p)&&(f.canMergeWhenEmpty()||$o(d))&&(p.append(...f.getChildren()),f.remove()),E(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let g=E(n)?n.getLastChild():null;ve(g)&&p!==n&&g.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=I();return F().splice(this.anchor.offset,0,[s]),s.select(),s}let e=Ll(this),t=mi(this.anchor.getNode(),$o);x(E(t),"Expected ancestor to be an ElementNode");let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=ut();if(this.insertNodes([t]),e){let n=t.getParentOrThrow(),r=t.getIndexWithinParent();n.select(r,r)}}extract(){let e=this.getNodes(),t=e.length,n=t-1,r=this.anchor,i=this.focus,s=e[0],l=e[n],[a,c]=Mr(this);if(t===0)return[];if(t===1){if(y(s)&&!this.isCollapsed()){let f=a>c?c:a,d=a>c?a:c,u=s.splitText(f,d),p=f===0?u[0]:u[1];return p!=null?[p]:[]}return[s]}let m=r.isBefore(i);if(y(s)){let f=m?a:c;f===s.getTextContentSize()?e.shift():f!==0&&([,s]=s.splitText(f),e[0]=s)}if(y(l)){let d=l.getTextContent().length,u=m?c:a;u===0?e.pop():u!==d&&([l]=l.splitText(u),e[n]=l)}return e}modify(e,t,n){let r=this.focus,i=this.anchor,s=e==="move",l=Yt(r,t);if(B(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let u=Ho();u.add(l.__key),Y(u);return}let d=t?l.getPreviousSibling():l.getNextSibling();if(y(d)){let u=d.__key,p=t?d.getTextContent().length:0;r.set(u,p,"text"),s&&i.set(u,p,"text");return}else{let u=l.getParentOrThrow(),p,g;E(d)?(g=d.__key,p=t?d.getChildrenSize():0):(p=l.getIndexWithinParent(),g=u.__key,t||p++),r.set(g,p,"element"),s&&i.set(g,p,"element");return}}let a=j(),c=be(a._window);if(!c)return;let m=a._blockCursorElement,f=a._rootElement;if(f!==null&&m!==null&&E(l)&&!l.isInline()&&!l.canBeEmpty()&&Er(m,a,f),mN(c,e,t?"backward":"forward",n),c.rangeCount>0){let d=c.getRangeAt(0),u=this.anchor.getNode(),p=oe(u)?u:ol(u);if(this.applyDOMRange(d),this.dirty=!0,!s){let g=this.getNodes(),h=[],C=!1;for(let N=0;N<g.length;N++){let L=g[N];xn(L,p)?h.push(L):C=!0}if(C&&h.length>0)if(t){let N=h[0];E(N)?N.selectStart():N.getParentOrThrow().selectStart()}else{let N=h[h.length-1];E(N)?N.selectEnd():N.getParentOrThrow().selectEnd()}(c.anchorNode!==d.startContainer||c.anchorOffset!==d.startOffset)&&fN(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&E(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){let r=t.getParent(),i=t.getNextSibling()||(r===null?null:r.getNextSibling());if(E(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,e))return;let i=this.focus,s=Yt(i,e);if(B(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&E(r)&&r.getChildrenSize()===0){r.remove();let l=Ho();l.add(s.__key),Y(l)}else s.remove(),j().dispatchCommand(we,void 0);return}else if(!e&&E(s)&&E(r)&&r.isEmpty()){r.remove(),s.selectStart();return}if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{let l=i.type==="text"?i.getNode():null;if(r=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){let a=i.offset,c=l.getTextContentSize();if(l.is(r)||e&&a!==c||!e&&a!==0){Kd(l,e,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,c=r.getTextContentSize();if(r.is(l)||e&&a!==0||!e&&a!==c){Kd(r,e,a);return}}pN(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&oe(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){let t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),(e?this.focus:this.anchor).offset===0&&this.modify("extend",e,"character"),t){let r=e?this.anchor:this.focus;r.set(r.key,r.offset+1,r.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Se(o){return o instanceof bi}function Hd(o){let e=o.offset;if(o.type==="text")return e;let t=o.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function Mr(o){let e=o.getStartEndPoints();if(e===null)return[0,0];let[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Hd(t),Hd(n)]}function fN(o){let e=o.focus,t=o.anchor,n=t.key,r=t.offset,i=t.type;xo(t,e.key,e.offset,e.type),xo(e,n,r,i),o._cachedNodes=null}function mN(o,e,t,n){o.modify(e,t,n)}function pN(o,e){let t=o.anchor,n=o.focus,r=t.getNode(),i=n.getNode();if(r===i&&t.type==="text"&&n.type==="text"){let s=t.offset,l=n.offset,a=s<l,c=a?s:l,m=a?l:s,f=m-1;if(c!==f){let d=r.getTextContent().slice(c,m);li(d)||(e?n.offset=f:t.offset=f)}}}function Kd(o,e,t){let n=o,i=n.getTextContent().split(/(?=\s)/g),s=i.length,l=0,a=0;for(let m=0;m<s;m++){let f=i[m],d=m===s-1;if(a=l,l+=f.length,e&&l===t||l>t||d){i.splice(m,1),d&&(a=void 0);break}}let c=i.join("").trim();c===""?n.remove():(n.setTextContent(c),n.select(a,a))}function gN(o,e,t){let n=o.getParent();return t===null||n===null||!n.canBeEmpty()||n!==t.getNode()}function Ud(o,e,t,n){let r=e,i;if(o.nodeType===fo){let s=!1,l=o.childNodes,a=l.length,c=n._blockCursorElement;r===a&&(s=!0,r=a-1);let m=l[r],f=!1;if(m===c)m=l[r+1],f=!0;else if(c!==null){let d=c.parentNode;if(o===d){let u=Array.prototype.indexOf.call(d.children,c);e>u&&r--}}if(i=ko(m),y(i))r=js(i,s);else{let d=ko(o);if(d===null)return null;if(E(d)){r=Math.min(d.getChildrenSize(),r);let u=d.getChildAtIndex(r);if(E(u)&&gN(u,r,t)){let p=s?u.getLastDescendant():u.getFirstDescendant();p===null?d=u:(u=p,d=E(u)?u:u.getParentOrThrow()),r=0}y(u)?(i=u,d=null,r=js(u,s)):u!==d&&s&&!f&&r++}else{let u=d.getIndexWithinParent();e===0&&B(d)&&ko(o)===d?r=u:r=u+1,d=d.getParentOrThrow()}if(E(d))return De(d.__key,r,"element")}}else i=ko(o);return y(i)?De(i.__key,r,"text"):null}function zd(o,e,t){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!e)E(i)&&!t&&i.isInline()?(o.key=i.__key,o.offset=i.getChildrenSize(),o.type="element"):y(i)&&(o.key=i.__key,o.offset=i.getTextContent().length);else if((t||!e)&&i===null&&E(s)&&s.isInline()){let l=s.getPreviousSibling();y(l)&&(o.key=l.__key,o.offset=l.getTextContent().length)}}else if(n===r.getTextContent().length){let i=r.getNextSibling(),s=r.getParent();if(e&&E(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((t||e)&&i===null&&E(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();y(l)&&(o.key=l.__key,o.offset=0)}}}function qd(o,e,t){if(o.type==="text"&&e.type==="text"){let n=o.isBefore(e),r=o.is(e);zd(o,n,r),zd(e,!n,r),r&&(e.key=o.key,e.offset=o.offset,e.type=o.type);let i=j();if(i.isComposing()&&i._compositionKey!==o.key&&_(t)){let s=t.anchor,l=t.focus;xo(o,s.key,s.offset,s.type),xo(e,l.key,l.offset,l.type)}}}function Yd(o,e,t,n,r,i){if(o===null||t===null||!Wt(r,o,t))return null;let s=Ud(o,e,_(i)?i.anchor:null,r);if(s===null)return null;let l=Ud(t,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=ko(o),c=ko(t);if(B(a)&&B(c))return null}return qd(s,l,i),[s,l]}function Ko(o){return E(o)&&!o.isInline()}function _i(o,e,t,n,r,i){let s=je(),l=new Eo(De(o,e,r),De(t,n,i),0,"");return l.dirty=!0,s._selection=l,l}function Uo(){let o=De("root",0,"element"),e=De("root",0,"element");return new Eo(o,e,0,"")}function Ho(){return new bi(new Set)}function Zd(o){let t=o.getEditorState()._selection,n=be(o._window);return _(t)||t==null?Lr(t,n,o,null):t.clone()}function wl(o,e){return Lr(null,o,e,null)}function Lr(o,e,t,n){let r=t._window;if(r===null)return null;let i=n||r.event,s=i?i.type:void 0,l=s==="selectionchange",a=!gc()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),c,m,f,d;if(!_(o)||a){if(e===null)return null;if(c=e.anchorNode,m=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&_(o)&&!Wt(t,c,m))return o.clone()}else return o.clone();let u=Yd(c,f,m,d,t,o);if(u===null)return null;let[p,g]=u;return new Eo(p,g,_(o)?o.format:0,_(o)?o.style:"")}function T(){return je()._selection}function We(){return j()._editorState._selection}function Ln(o,e,t,n=1){let r=o.anchor,i=o.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;let a=e.__key;if(o.isCollapsed()){let c=r.offset;if(t<=c&&n>0||t<c&&n<0){let m=Math.max(0,c+n);r.set(a,m,"element"),i.set(a,m,"element"),Wd(o)}}else{let c=o.isBackward(),m=c?i:r,f=m.getNode(),d=c?r:i,u=d.getNode();if(e.is(f)){let p=m.offset;(t<=p&&n>0||t<p&&n<0)&&m.set(a,Math.max(0,p+n),"element")}if(e.is(u)){let p=d.offset;(t<=p&&n>0||t<p&&n<0)&&d.set(a,Math.max(0,p+n),"element")}}Wd(o)}function Wd(o){let e=o.anchor,t=e.offset,n=o.focus,r=n.offset,i=e.getNode(),s=n.getNode();if(o.isCollapsed()){if(!E(i))return;let l=i.getChildrenSize(),a=t>=l,c=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),e.set(c.__key,m,"text"),n.set(c.__key,m,"text")}return}if(E(i)){let l=i.getChildrenSize(),a=t>=l,c=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),e.set(c.__key,m,"text")}}if(E(s)){let l=s.getChildrenSize(),a=r>=l,c=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),n.set(c.__key,m,"text")}}}function Vd(o,e){let n=e.getEditorState()._selection,r=o._selection;if(_(r)){let i=r.anchor,s=r.focus,l;if(i.type==="text"&&(l=i.getNode(),l.selectionTransform(n,r)),s.type==="text"){let a=s.getNode();l!==a&&a.selectionTransform(n,r)}}}function Mn(o,e,t,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,y(n)?(s=n.getTextContentSize(),l="text"):E(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,y(r)?l="text":E(r)&&(l="element")),i!==null&&l!==null?o.set(i,s,l):(s=e.getIndexWithinParent(),s===-1&&(s=t.getChildrenSize()),o.set(t.__key,s,"element"))}function _l(o,e,t,n,r){o.type==="text"?(o.key=t,e||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function Xd(o,e,t,n,r,i,s){let l=n.anchorNode,a=n.focusNode,c=n.anchorOffset,m=n.focusOffset,f=document.activeElement;if(r.has("collaboration")&&f!==i||f!==null&&En(f))return;if(!_(e)){o!==null&&Wt(t,l,a)&&n.removeAllRanges();return}let d=e.anchor,u=e.focus,p=d.key,g=u.key,h=_n(t,p),C=_n(t,g),N=d.offset,L=u.offset,M=e.format,S=e.style,A=e.isCollapsed(),O=h,R=C,P=!1;if(d.type==="text"){O=Cn(h);let k=d.getNode();P=k.getFormat()!==M||k.getStyle()!==S}else _(o)&&o.anchor.type==="text"&&(P=!0);if(u.type==="text"&&(R=Cn(C)),!(O===null||R===null)&&(A&&(o===null||P||_(o)&&(o.format!==M||o.style!==S))&&Rd(M,S,N,p,performance.now()),!(c===N&&m===L&&l===O&&a===R&&!(n.type==="Range"&&A)&&((f===null||!i.contains(f))&&i.focus({preventScroll:!0}),d.type!=="element")))){try{n.setBaseAndExtent(O,N,R,L)}catch(k){__DEV__&&console.warn(k)}if(!r.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){let k=e instanceof Eo&&e.anchor.type==="element"?O.childNodes[N]||null:n.rangeCount>0?n.getRangeAt(0):null;if(k!==null){let W;if(k instanceof Text){let ie=document.createRange();ie.selectNode(k),W=ie.getBoundingClientRect()}else W=k.getBoundingClientRect();id(t,W,i)}}Ad()}}function Oe(o){let e=T()||We();e===null&&(e=F().selectEnd()),e.insertNodes(o)}function Ll(o){let e=o;o.isCollapsed()||e.removeText();let t=T();_(t)&&(e=t),x(_(e),"Unexpected dirty selection to be null");let n=e.anchor,r=n.getNode(),i=n.offset;for(;!$o(r);)[r,i]=hN(r,i);return i}function hN(o,e){let t=o.getParent();if(!t){let r=I();return F().append(r),r.select(),[F(),0]}if(y(o)){let r=o.splitText(e);if(r.length===0)return[t,o.getIndexWithinParent()];let i=e===0?0:1,s=r[0].getIndexWithinParent()+i;return[t,s]}if(!E(o)||e===0)return[t,o.getIndexWithinParent()];let n=o.getChildAtIndex(e);if(n){let r=new Eo(De(o.__key,e,"element"),De(o.__key,e,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[t,o.getIndexWithinParent()+1]}function NN(o){let e=I(),t=null;for(let n=0;n<o.length;n++){let r=o[n],i=ve(r);if(i||B(r)&&r.isInline()||E(r)&&r.isInline()||y(r)||r.isParentRequired()){if(t===null&&(t=r.createParentElementNode(),e.append(t),i))continue;t!==null&&t.append(r)}else e.append(r),t=null}return e}var ue=null,ge=null,Ae=!1,vl=!1,yi=0,Gd={characterData:!0,childList:!0,subtree:!0};function st(){return Ae||ue!==null&&ue._readOnly}function ce(){Ae&&x(!1,"Cannot use method in read-only mode.")}function rl(){yi>99&&x(!1,"One or more transforms are endlessly triggering additional transforms. May have encountered infinite recursion caused by transforms that have their preconditions too lose and/or conflict with each other.")}function je(){return ue===null&&x(!1,"Unable to find an active editor state. State helpers or node methods can only be used synchronously during the callback of editor.update(), editor.read(), or editorState.read().%s",eu()),ue}function j(){return ge===null&&x(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",eu()),ge}function eu(){let o=0,e=new Set,t=go.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Ro(r);if(Tn(i))o++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===t&&(s+=" (separately built, likely a bundler configuration issue)"),e.add(s)}}let n=` Detected on the page: ${o} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function tu(){return ge}function dd(){return ue}function jd(o,e,t){let n=e.__type,r=_c(o,n),i=t.get(n);i===void 0&&(i=Array.from(r.transforms),t.set(n,i));let s=i.length;for(let l=0;l<s&&(i[l](e),!!e.isAttached());l++);}function Jd(o,e){return o!==void 0&&o.__key!==e&&o.isAttached()}function xN(o,e){let t=e._dirtyLeaves,n=o._nodeMap;for(let r of t){let i=n.get(r);y(i)&&i.isAttached()&&i.isSimpleText()&&!i.isUnmergeable()&&Vs(i)}}function EN(o,e){let t=e._dirtyLeaves,n=e._dirtyElements,r=o._nodeMap,i=Ge(),s=new Map,l=t,a=l.size,c=n,m=c.size;for(;a>0||m>0;){if(a>0){e._dirtyLeaves=new Set;for(let f of l){let d=r.get(f);y(d)&&d.isAttached()&&d.isSimpleText()&&!d.isUnmergeable()&&Vs(d),d!==void 0&&Jd(d,i)&&jd(e,d,s),t.add(f)}if(l=e._dirtyLeaves,a=l.size,a>0){yi++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map;for(let f of c){let d=f[0],u=f[1];if(d!=="root"&&!u)continue;let p=r.get(d);p!==void 0&&Jd(p,i)&&jd(e,p,s),n.set(d,u)}l=e._dirtyLeaves,a=l.size,c=e._dirtyElements,m=c.size,yi++}e._dirtyLeaves=t,e._dirtyElements=n}function Dl(o){return Ol(o,j()._nodes)}function Ol(o,e){let t=o.type,n=e.get(t);n===void 0&&x(!1,'parseEditorState: type "%s" + not found',t);let r=n.klass;o.type!==r.getType()&&x(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(E(i)&&Array.isArray(s))for(let l=0;l<s.length;l++){let a=s[l],c=Ol(a,e);i.append(c)}return i}function ou(o,e,t){let n=wr(),r=ue,i=Ae,s=ge,l=e._dirtyElements,a=e._dirtyLeaves,c=e._cloneNotNeeded,m=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ue=n,Ae=!1,ge=e;try{let f=e._nodes,d=o.root;Ol(d,f),t&&t(),n._readOnly=!0,__DEV__&&nu(n)}catch(f){f instanceof Error&&e._onError(f)}finally{e._dirtyElements=l,e._dirtyLeaves=a,e._cloneNotNeeded=c,e._dirtyType=m,ue=r,Ae=i,ge=s}return n}function Al(o,e,t){let n=ue,r=Ae,i=ge;ue=e,Ae=!0,ge=o;try{return t()}finally{ue=n,Ae=r,ge=i}}function nu(o){let e=o._nodeMap;e.set=()=>{throw new Error("Cannot call set() on a frozen Lexical node map")},e.clear=()=>{throw new Error("Cannot call clear() on a frozen Lexical node map")},e.delete=()=>{throw new Error("Cannot call delete() on a frozen Lexical node map")}}function Lt(o,e){let t=o._pendingEditorState,n=o._rootElement,r=o._headless||n===null;if(t===null)return;let i=o._editorState,s=i._selection,l=t._selection,a=o._dirtyType!==_t,c=ue,m=Ae,f=ge,d=o._updating,u=o._observer,p=null;if(o._pendingEditorState=null,o._editorState=t,!r&&a&&u!==null){ge=o,ue=t,Ae=!1,o._updating=!0;try{let O=o._dirtyType,R=o._dirtyElements,P=o._dirtyLeaves;u.disconnect(),p=xd(i,t,o,O,R,P)}catch(O){if(O instanceof Error&&o._onError(O),!vl)Rl(o,null,n,t),ni(o),o._dirtyType=zt,vl=!0,Lt(o,i),vl=!1;else throw O;return}finally{u.observe(n,Gd),o._updating=d,ue=c,Ae=m,ge=f}}t._readOnly||(t._readOnly=!0,__DEV__&&(nu(t),_(l)&&(Object.freeze(l.anchor),Object.freeze(l.focus)),Object.freeze(l)));let g=o._dirtyLeaves,h=o._dirtyElements,C=o._normalizedNodes,N=o._updateTags,L=o._deferred,M=t._nodeMap.size;a&&(o._dirtyType=_t,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),ud(o,t);let S=r?null:be(o._window);if(o._editable&&S!==null&&(a||l===null||l.dirty)){ge=o,ue=t;try{if(u!==null&&u.disconnect(),a||l===null||l.dirty){let O=o._blockCursorElement;O!==null&&Er(O,o,n),Xd(s,l,o,S,N,n,M)}ad(o,n,l),u!==null&&u.observe(n,Gd)}finally{ge=f,ue=c}}p!==null&&CN(o,p,N,g,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(we,void 0);let A=o._pendingDecorators;A!==null&&(o._decorators=A,o._pendingDecorators=null,wn("decorator",o,!0,A)),TN(o,e||i,t),wn("update",o,!0,{dirtyElements:h,dirtyLeaves:g,editorState:t,normalizedNodes:C,prevEditorState:e||i,tags:N}),bN(o,L),_N(o)}function TN(o,e,t){let n=Gs(e),r=Gs(t);n!==r&&wn("textcontent",o,!0,r)}function CN(o,e,t,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l<s;l++){let[a,c]=i[l],m=e.get(c);m!==void 0&&a(m,{dirtyLeaves:n,prevEditorState:r,updateTags:t})}}function wn(o,e,t,...n){let r=e._updating;e._updating=t;try{let i=Array.from(e._listeners[o]);for(let s=0;s<i.length;s++)i[s].apply(null,n)}finally{e._updating=r}}function il(o,e,t){if(o._updating===!1||ge!==o){let r=!1;return o.update(()=>{r=il(o,e,t)}),r}let n=hr(o);for(let r=4;r>=0;r--)for(let i=0;i<n.length;i++){let a=n[i]._commands.get(e);if(a!==void 0){let c=a[r];if(c!==void 0){let m=Array.from(c),f=m.length;for(let d=0;d<f;d++)if(m[d](t,o)===!0)return!0}}}return!1}function _N(o){let e=o._updates;if(e.length!==0){let t=e.shift();if(t){let[n,r]=t;ru(o,n,r)}}}function bN(o,e){if(o._deferred=[],e.length!==0){let t=o._updating;o._updating=!0;try{for(let n=0;n<e.length;n++)e[n]()}finally{o._updating=t}}}function Qd(o,e){let t=o._updates,n=e||!1;for(;t.length!==0;){let r=t.shift();if(r){let[i,s]=r,l,a;if(s!==void 0){if(l=s.onUpdate,a=s.tag,s.skipTransforms&&(n=!0),s.discrete){let c=o._pendingEditorState;x(c!==null,"Unexpected empty pending editor state on discrete nested update"),c._flushSync=!0}l&&o._deferred.push(l),a&&o._updateTags.add(a)}i()}}return n}function ru(o,e,t){let n=o._updateTags,r,i,s=!1,l=!1;t!==void 0&&(r=t.onUpdate,i=t.tag,i!=null&&n.add(i),s=t.skipTransforms||!1,l=t.discrete||!1),r&&o._deferred.push(r);let a=o._editorState,c=o._pendingEditorState,m=!1;(c===null||c._readOnly)&&(c=o._pendingEditorState=su(c||a),m=!0),c._flushSync=l;let f=ue,d=Ae,u=ge,p=o._updating;ue=c,Ae=!1,o._updating=!0,ge=o;try{m&&(o._headless?a._selection!==null&&(c._selection=a._selection.clone()):c._selection=Zd(o));let h=o._compositionKey;e(),s=Qd(o,s),Vd(c,o),o._dirtyType!==_t&&(s?xN(c,o):EN(c,o),Qd(o),md(a,c,o._dirtyLeaves,o._dirtyElements));let C=o._compositionKey;h!==C&&(c._flushSync=!0);let N=c._selection;if(_(N)){let L=c._nodeMap,M=N.anchor.key,S=N.focus.key;(L.get(M)===void 0||L.get(S)===void 0)&&x(!1,"updateEditor: selection has been lost because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.")}else Se(N)&&N._nodes.size===0&&(c._selection=null)}catch(h){h instanceof Error&&o._onError(h),o._pendingEditorState=a,o._dirtyType=zt,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),Lt(o);return}finally{ue=f,Ae=d,ge=u,o._updating=p,yi=0}o._dirtyType!==_t||iu(c,o)?c._flushSync?(c._flushSync=!1,Lt(o)):m&&bc(()=>{Lt(o)}):(c._flushSync=!1,m&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function xe(o,e,t){o._updating?o._updates.push([e,t]):ru(o,e,t)}var Z=class extends yt{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__style="",this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__style=e.__style,this.__dir=e.__dir}getStyle(){return this.getLatest().__style}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let t=j()._dirtyElements;return t!==null&&t.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(y(t)&&e.push(t),E(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;E(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;E(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let i=t[n-1];return E(i)&&i.getLastDescendant()||i||null}let r=t[e];return E(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let t=this.getLatest().__first;return t===null?null:J(t)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&x(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let t=this.getLatest().__last;return t===null?null:J(t)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&x(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e="",t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),E(i)&&r!==n-1&&!i.isInline()&&(e+=Ve)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),E(i)&&r!==n-1&&!i.isInline()&&(e+=Ve.length)}return e}getDirection(){return this.getLatest().__dir}select(e,t){ce();let n=T(),r=e,i=t,s=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let a=this.getFirstChild();if(y(a)||E(a))return a.select(0,0)}else if((e===void 0||e===s)&&(t===void 0||t===s)){let a=this.getLastChild();if(y(a)||E(a))return a.select()}}r===void 0&&(r=s),i===void 0&&(i=s);let l=this.__key;if(_(n))n.anchor.set(l,r,"element"),n.focus.set(l,i,"element"),n.dirty=!0;else return _i(l,r,l,i,"element","element");return n}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(n=>n.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setStyle(e){let t=this.getWritable();return t.__style=e||"",this}splice(e,t,n){let r=n.length,i=this.getChildrenSize(),s=this.getWritable(),l=s.__key,a=[],c=[],m=this.getChildAtIndex(e+t),f=null,d=i-t+r;if(e!==0)if(e===i)f=this.getLastChild();else{let p=this.getChildAtIndex(e);p!==null&&(f=p.getPreviousSibling())}if(t>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let g=0;g<t;g++){p===null&&x(!1,"splice: sibling not found");let h=p.getNextSibling(),C=p.__key,N=p.getWritable();qt(N),c.push(C),p=h}}let u=f;for(let p=0;p<r;p++){let g=n[p];u!==null&&g.is(u)&&(f=u=u.getPreviousSibling());let h=g.getWritable();h.__parent===l&&d--,qt(h);let C=g.__key;if(u===null)s.__first=C,h.__prev=null;else{let N=u.getWritable();N.__next=C,h.__prev=N.__key}g.__key===l&&x(!1,"append: attempting to append self"),h.__parent=l,a.push(C),u=g}if(e+t===i){if(u!==null){let p=u.getWritable();p.__next=null,s.__last=u.__key}}else if(m!==null){let p=m.getWritable();if(u!==null){let g=u.getWritable();p.__prev=u.__key,g.__next=m.__key}else p.__prev=null}if(s.__size=d,c.length){let p=T();if(_(p)){let g=new Set(c),h=new Set(a),{anchor:C,focus:N}=p;lu(C,g,h)&&Mn(C,C.getNode(),this,f,m),lu(N,g,h)&&Mn(N,N.getNode(),this,f,m),d===0&&!this.canBeEmpty()&&!me(this)&&this.remove()}}return s}exportJSON(){return{children:[],direction:this.getDirection(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}};function E(o){return o instanceof Z}function lu(o,e,t){let n=o.getNode();for(;n;){let r=n.__key;if(e.has(r)&&!t.has(r))return!0;n=n.getParent()}return!1}var Mt=class extends yt{constructor(e){super(e)}decorate(e,t){x(!1,"decorate: base method not extended")}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function B(o){return o instanceof Mt}var zo=class o extends Z{static getType(){return"root"}static clone(){return new o}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){x(!1,"getTopLevelElementOrThrow: root nodes are not top level elements")}getTextContent(){let e=this.__cachedText;return(st()||j()._dirtyType===_t)&&e!==null?e:super.getTextContent()}remove(){x(!1,"remove: cannot be called on root nodes")}replace(e){x(!1,"replace: cannot be called on root nodes")}insertBefore(e){x(!1,"insertBefore: cannot be called on root nodes")}insertAfter(e){x(!1,"insertAfter: cannot be called on root nodes")}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){let n=e[t];!E(n)&&!B(n)&&x(!1,"rootNode.append: Only element or decorator nodes can be appended to the root node")}return super.append(...e)}static importJSON(e){let t=F();return t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),type:"root",version:1}}collapseAtStart(){return!0}};function au(){return new zo}function oe(o){return o instanceof zo}function iu(o,e){let t=e.getEditorState()._selection,n=o._selection;if(n!==null){if(n.dirty||!n.is(t))return!0}else if(t!==null)return!0;return!1}function su(o){return new Si(new Map(o._nodeMap))}function wr(){return new Si(new Map([["root",au()]]))}function cu(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&x(!1,"LexicalNode: Node %s does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.",t.name),E(o)){let n=e.children;Array.isArray(n)||x(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name);let r=o.getChildren();for(let i=0;i<r.length;i++){let s=r[i],l=cu(s);n.push(l)}}return e}var Si=class o{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Al(t&&t.editor||null,this,e)}clone(e){let t=new o(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return Al(null,this,()=>({root:cu(F())}))}};var To=class extends Z{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}};function b(o,e={},t=[]){let n=document.createElement(o),r=Object.keys(e);for(let i of r)e[i]!==null&&n.setAttribute(i,e[i]);for(let i of t)typeof i=="string"?n.append(document.createTextNode(i)):n.append(i);return n}function du(o){return new DOMParser().parseFromString(o,"text/html")}function ft(o,e="px"){return typeof o=="number"||/^-?\d+$/.test(o)?`${o}${e}`:o}function Wo(o){return/^-?\d+$/.test(o)?Number(o):/^-?\d+\.\d+$/.test(o)?Math.round(Number(o)):/^-?\d+px\s*$/.test(o)?Number(o.trim().replace("px","")):0}function vn(o){let e=new Map,n=(o.getAttribute("style")||"").split(";");for(let r of n){let[i,s]=r.split(":");!i||!s||e.set(i.trim().toLowerCase(),s.trim())}return e}function uu(o,e,t){t?o.setAttribute(e,t):o.removeAttribute(e)}var yN=["left","right","center","justify"];function vr(o){let e=o.style.textAlign||"";return yN.includes(e)?e:o.classList.contains("align-left")?"left":o.classList.contains("align-right")?"right":o.classList.contains("align-center")?"center":o.classList.contains("align-justify")?"justify":""}function SN(o){let e=o.style.paddingLeft||"0";return Wo(e)}function Dr(o){let e=(o.dir||"").toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Qe(o,e){o.id&&e.setId(o.id),e.setAlignment(vr(o)),e.setInset(SN(o)),e.setDirection(Dr(o))}function wt(o,e){return o.__id!==e.__id||o.__alignment!==e.__alignment||o.__inset!==e.__inset||o.__dir!==e.__dir}function et(o,e){e.__id&&o.setAttribute("id",e.__id),e.__alignment&&o.classList.add("align-"+e.__alignment),e.__inset&&(o.style.paddingLeft=`${e.__inset}px`),e.__dir&&(o.dir=e.__dir)}function tt(o,e){e.setId(o.id),e.setAlignment(o.alignment),e.setInset(o.inset),e.setDirection(o.direction)}var vt=class extends Z{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}exportJSON(){return{...super.exportJSON(),id:this.__id,alignment:this.__alignment,inset:this.__inset}}};function Co(o,e){e.__alignment=o.__alignment,e.__inset=o.__inset}var dt=class o extends vt{constructor(e){super(e),this.__textStyle=""}static getType(){return"paragraph"}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textStyle=e.__textStyle,Co(e,this)}createDOM(e){let t=document.createElement("p"),n=mo(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),et(t,this),t}updateDOM(e,t,n){return wt(e,this)}static importDOM(){return{p:e=>({conversion:LN,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=I();return tt(e,t),t}exportJSON(){return{...super.exportJSON(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){let n=I();n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||y(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function LN(o){let e=I();return Qe(o,e),{node:e}}function I(){return ne(new dt)}function ct(o){return o instanceof dt}var MN=!0,X=0,Dt=1,Li=2,qe=3,Re=4;function Rl(o,e,t,n){let r=o._keyToDOMMap;r.clear(),o._editorState=wr(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=_t,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),o._normalizedNodes=new Set,o._updateTags=new Set,o._updates=[],o._blockCursorElement=null;let i=o._observer;i!==null&&(i.disconnect(),o._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",r.set("root",t))}function wN(o,e){let t=new Map,n=new Set,r=i=>{Object.keys(i).forEach(s=>{let l=t.get(s);l===void 0&&(l=[],t.set(s,l)),l.push(i[s])})};return o.forEach(i=>{let s=i.klass.importDOM;if(s==null||n.has(s))return;n.add(s);let l=s.call(i.klass);l!==null&&r(l)}),e&&r(e),t}function kl(o){let e=o||{},t=tu(),n=e.theme||{},r=o===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,s=wr(),l=e.namespace||(r!==null?r._config.namespace:Js()),a=e.editorState,c=[zo,Je,Bo,Fo,dt,To,...e.nodes||[]],{onError:m,html:f}=e,d=e.editable!==void 0?e.editable:!0,u;if(o===void 0&&t!==null)u=t._nodes;else{u=new Map;for(let g=0;g<c.length;g++){let h=c[g],C=null,N=null;if(typeof h!="function"){let A=h;h=A.replace,C=A.with,N=A.withKlass||null}if(__DEV__){let A=Object.prototype.hasOwnProperty.call(h,"getType")&&h.getType(),O=h.name;if(N&&x(N.prototype instanceof h,"%s doesn't extend the %s",N.name,O),O!=="RootNode"&&A!=="root"&&A!=="artificial"){let R=h.prototype;["getType","clone"].forEach(P=>{h.hasOwnProperty(P)||console.warn(`${O} must implement static "${P}" method`)}),!h.hasOwnProperty("importDOM")&&h.hasOwnProperty("exportDOM")&&console.warn(`${O} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`),R instanceof Mt&&(R.hasOwnProperty("decorate")||console.warn(`${R.constructor.name} must implement "decorate" method`)),h.hasOwnProperty("importJSON")||console.warn(`${O} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`),R.hasOwnProperty("exportJSON")||console.warn(`${O} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`)}}let L=h.getType(),M=h.transform(),S=new Set;M!==null&&S.add(M),u.set(L,{exportDOM:f&&f.export?f.export.get(h):void 0,klass:h,replace:C,replaceWithKlass:N,transforms:S})}}let p=new go(s,r,u,{disableEvents:i,namespace:l,theme:n},m||console.error,wN(u,f?f.import:void 0),d);return a!==void 0&&(p._pendingEditorState=a,p._dirtyType=zt),p}var go=class{constructor(e,t,n,r,i,s,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=_t,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Js(),this._onError=i,this._htmlConversions=s,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){let t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){let t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){let t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){let t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){let t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&x(!1,'Listener for type "command" requires a "priority".');let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&x(!1,"registerCommand: Command %s not found in command map",String(e));let s=i[n];return s.add(t),()=>{s.delete(t),i.every(l=>l.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,r);let s=n&&n.skipInitialization;return(s===void 0?MN:s)||this.initializeMutationListener(t,r),()=>{i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&x(!1,"Node %s has not been registered. Ensure node has been passed to createEditor.",e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=cd(n).get(t.getType());if(!r)return;let i=new Map;for(let s of r.keys())i.set(s,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let s=this.registerNodeTransformToKlass(i,t);r.push(s)}return Mc(this,e.getType()),()=>{r.forEach(s=>s.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return D(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=mo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Rl(this,t,e,r),t!==null&&(this._config.disableEvents||Od(t),n!=null&&t.classList.remove(...n)),e!==null){let i=ld(e),s=e.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=zt,ni(this),this._updateTags.add("history-merge"),Lt(this),this._config.disableEvents||Dd(e,this),n!=null&&e.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;wn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&x(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),oi(this);let n=this._pendingEditorState,r=this._updateTags,i=t!==void 0?t.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Lt(this)),this._pendingEditorState=e,this._dirtyType=zt,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Lt(this)}parseEditorState(e,t){let n=typeof e=="string"?JSON.parse(e):e;return ou(n,this,t)}read(e){return Lt(this),this.getEditorState().read(e,{editor:this})}update(e,t){xe(this,e,t)}updateAndCommit(e,t){this.update(e,t),this.commitUpdates()}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),xe(this,()=>{let r=T(),i=F();r!==null?r.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}commitUpdates(){Lt(this)}blur(){let e=this._rootElement;e!==null&&e.blur();let t=be(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,wn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};go.version="0.17.1";function Gt(...o){return()=>{for(let e=o.length-1;e>=0;e--)o[e]();o.length=0}}var Dn=new Map;function Il(o){let e={},t=o.split(";");for(let n of t)if(n!==""){let[r,i]=n.split(/:([^]+)/);r&&i&&(e[r.trim()]=i.trim())}return e}function On(o){let e=Dn.get(o);return e===void 0&&(e=Il(o),Dn.set(o,e)),__DEV__&&Object.freeze(e),e}function mu(o){let e="";for(let t in o)t&&(e+=`${t}: ${o[t]};`);return e}function Or(o,e){let t=o.getStartEndPoints();if(e.isSelected(o)&&!e.isSegmented()&&!e.isToken()&&t!==null){let[n,r]=t,i=o.isBackward(),s=n.getNode(),l=r.getNode(),a=e.is(s),c=e.is(l);if(a||c){let[m,f]=Mr(o),d=s.is(l),u=e.is(i?l:s),p=e.is(i?s:l),g=0,h;if(d)g=m>f?f:m,h=m>f?m:f;else if(u)g=i?f:m,h=void 0;else if(p){let C=i?m:f;g=0,h=C}return e.__text=e.__text.slice(g,h),e}}return e}function $l(o){let e=o.getStyle(),t=Il(e);Dn.set(e,t)}function An(o,e){let t=On("getStyle"in o?o.getStyle():o.style),n=Object.entries(e).reduce((i,[s,l])=>(typeof l=="function"?i[s]=l(t[s],o):l===null?delete i[s]:i[s]=l,i),{...t}),r=mu(n);o.setStyle(r),Dn.set(r,n)}function Pl(o,e){let t=o.getNodes(),n=t.length,r=o.getStartEndPoints();if(r===null)return;let[i,s]=r,l=n-1,a=t[0],c=t[l];if(o.isCollapsed()&&_(o)){An(o,e);return}let f=a.getTextContent().length,d=s.offset,u=i.offset,p=i.isBefore(s),g=p?u:d,h=p?d:u,C=p?i.type:s.type,N=p?s.type:i.type,L=p?s.key:i.key;if(y(a)&&g===f){let M=a.getNextSibling();y(M)&&(u=0,g=0,a=M)}if(t.length===1){if(y(a)&&a.canHaveFormat()){if(g=C==="element"?0:u>d?d:u,h=N==="element"?f:u>d?u:d,g===h)return;if(ze(a)||g===0&&h===f)An(a,e),a.select(g,h);else{let M=a.splitText(g,h),S=g===0?M[0]:M[1];An(S,e),S.select(0,h-g)}}}else{if(y(a)&&g<a.getTextContentSize()&&a.canHaveFormat()&&(g!==0&&!ze(a)&&(a=a.splitText(g)[1],g=0,p?i.set(a.getKey(),g,"text"):s.set(a.getKey(),g,"text")),An(a,e)),y(c)&&c.canHaveFormat()){let S=c.getTextContent().length;c.__key!==L&&h!==0&&(h=S),h!==S&&!ze(c)&&([c]=c.splitText(h)),(h!==0||N==="element")&&An(c,e)}for(let M=1;M<l;M++){let S=t[M],A=S.getKey();y(S)&&S.canHaveFormat()&&A!==a.getKey()&&A!==c.getKey()&&!S.isToken()&&An(S,e)}}}function Mi(o,e){if(o===null)return;let t=o.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){let s=e(),l=F(),a=l.getFirstChild();a?a.replace(s,!0):l.append(s);return}let r=o.getNodes(),i=n!==null?DN(n.getNode(),pu):!1;i&&r.indexOf(i)===-1&&r.push(i);for(let s=0;s<r.length;s++){let l=r[s];if(!pu(l))continue;x(E(l),"Expected block node to be an ElementNode");let a=e();l.replace(a,!0)}}function wi(o,e){let t=Yt(o.focus,e);return B(t)&&!t.isIsolated()||E(t)&&!t.isInline()&&!t.canBeEmpty()}function gu(o,e,t,n){o.modify(e?"extend":"move",t,n)}function hu(o){let e=o.anchor.getNode();return(oe(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function vi(o,e,t){let n=hu(o);gu(o,e,t?!n:n,"character")}function vN(o,e,t){let n=o.getStyle(),r=On(n);return r!==null&&r[e]||t}function Bl(o,e,t=""){let n=null,r=o.getNodes(),i=o.anchor,s=o.focus,l=o.isBackward(),a=l?s.offset:i.offset,c=l?s.getNode():i.getNode();if(_(o)&&o.isCollapsed()&&o.style!==""){let m=o.style,f=On(m);if(f!==null&&e in f)return f[e]}for(let m=0;m<r.length;m++){let f=r[m];if(!(m!==0&&a===0&&f.is(c))&&y(f)){let d=vN(f,e,t);if(n===null)n=d;else if(n!==d){n="";break}}}return n===null?t:n}function pu(o){if(B(o)||!E(o)||me(o))return!1;let e=o.getFirstChild(),t=e===null||ve(e)||y(e)||e.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&t}function DN(o,e){let t=o;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function Te(o,...e){let t=bt(...e);t.length>0&&o.classList.add(...t)}function Di(o,...e){let t=bt(...e);t.length>0&&o.classList.remove(...t)}function Nu(o,e){let t=o;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function xu(o){let e=H(o,t=>E(t)&&!t.isInline());return E(e)||x(!1,"Expected node %s to have closest block element node.",o.__key),e}var H=(o,e)=>{let t=o;for(;t!==F()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function mt(o,e){return o!==null?Object.getPrototypeOf(o).constructor.name===e.name:!1}var Oi=0,Fl=1,Hl=2,pt=0,kN=1,Eu=2,IN=3,$N=4;function PN(o,e,t){let n=o._nodeMap,r=[];for(let i of e){let s=n.get(i);s!==void 0&&r.push(s)}for(let[i,s]of t){if(!s)continue;let l=n.get(i);l!==void 0&&!oe(l)&&r.push(l)}return r}function BN(o,e,t,n,r){if(o===null||t.size===0&&n.size===0&&!r)return pt;let i=e._selection,s=o._selection;if(r)return kN;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return pt;let l=PN(e,t,n);if(l.length===0)return pt;if(l.length>1){let C=e._nodeMap,N=C.get(i.anchor.key),L=C.get(s.anchor.key);return N&&L&&!o._nodeMap.has(N.__key)&&y(N)&&N.__text.length===1&&i.anchor.offset===1?Eu:pt}let a=l[0],c=o._nodeMap.get(a.__key);if(!y(c)||!y(a)||c.__mode!==a.__mode)return pt;let m=c.__text,f=a.__text;if(m===f)return pt;let d=i.anchor,u=s.anchor;if(d.key!==u.key||d.type!=="text")return pt;let p=d.offset,g=u.offset,h=f.length-m.length;return h===1&&g===p-1?Eu:h===-1&&g===p+1?IN:h===-1&&g===p?$N:pt}function FN(o,e,t){let n=e._nodeMap.get(o),r=t._nodeMap.get(o),i=e._selection,s=t._selection;return!(_(i)&&_(s)&&i.anchor.type==="element"&&i.focus.type==="element"&&s.anchor.type==="text"&&s.focus.type==="text")&&y(n)&&y(r)&&n.__parent===r.__parent?JSON.stringify(e.read(()=>n.exportJSON()))===JSON.stringify(t.read(()=>r.exportJSON())):!1}function HN(o,e){let t=Date.now(),n=pt;return(r,i,s,l,a,c)=>{let m=Date.now();if(c.has("historic"))return n=pt,t=m,Hl;let f=BN(r,i,l,a,o.isComposing()),d=(()=>{let u=s===null||s.editor===o,p=c.has("history-push");if(!p&&u&&c.has("history-merge"))return Oi;if(r===null)return Fl;let h=i._selection;if(!(l.size>0||a.size>0))return h!==null?Oi:Hl;if(p===!1&&f!==pt&&f===n&&m<t+e&&u)return Oi;if(l.size===1){let N=Array.from(l)[0];if(FN(N,r,i))return Oi}return Fl})();return t=m,n=f,d}}function KN(o,e){let t=e.redoStack,n=e.undoStack;if(t.length!==0){let r=e.current;r!==null&&(n.push(r),o.dispatchCommand(co,!0));let i=t.pop();t.length===0&&o.dispatchCommand(ao,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}function UN(o,e){let t=e.redoStack,n=e.undoStack;if(n.length!==0){let i=e.current,s=n.pop();i!==null&&(t.push(i),o.dispatchCommand(ao,!0)),n.length===0&&o.dispatchCommand(co,!1),e.current=s||null,s&&s.editor.setEditorState(s.editorState,{tag:"historic"})}}function Tu(o){o.undoStack=[],o.redoStack=[],o.current=null}function Cu(o,e,t){let n=HN(o,t),r=({editorState:s,prevEditorState:l,dirtyLeaves:a,dirtyElements:c,tags:m})=>{let f=e.current,d=e.redoStack,u=e.undoStack,p=f===null?null:f.editorState;if(f!==null&&s===p)return;let g=n(l,s,f,a,c,m);if(g===Fl)d.length!==0&&(e.redoStack=[],o.dispatchCommand(ao,!1)),f!==null&&(u.push({...f}),o.dispatchCommand(co,!0));else if(g===Hl)return;e.current={editor:o,editorState:s}};return Gt(o.registerCommand(ro,()=>(UN(o,e),!0),X),o.registerCommand(io,()=>(KN(o,e),!0),X),o.registerCommand(Is,()=>(Tu(e),!1),X),o.registerCommand($s,()=>(Tu(e),o.dispatchCommand(ao,!1),o.dispatchCommand(co,!1),!0),X),o.registerUpdateListener(r))}function _u(){return{current:null,redoStack:[],undoStack:[]}}function Ai(o,e){let t=e.body?e.body.childNodes:[],n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(!Su.has(s.nodeName)){let l=Lu(s,o,r,!1);l!==null&&(n=n.concat(l))}}return WN(r),n}function Ri(o,e){if(typeof document>"u"||typeof window>"u"&&typeof global.window>"u")throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let t=document.createElement("div"),r=F().getChildren();for(let i=0;i<r.length;i++){let s=r[i];yu(o,s,t,e)}return t.innerHTML}function yu(o,e,t,n=null){let r=n!==null?e.isSelected(n):!0,i=E(e)&&e.excludeFromCopy("html"),s=e;if(n!==null){let u=Zt(e);u=y(u)&&n!==null?Or(n,u):u,s=u}let l=E(s)?s.getChildren():[],a=o._nodes.get(s.getType()),c;a&&a.exportDOM!==void 0?c=a.exportDOM(o,s):c=s.exportDOM(o);let{element:m,after:f}=c;if(!m)return!1;let d=document.createDocumentFragment();for(let u=0;u<l.length;u++){let p=l[u],g=yu(o,p,d,n);!r&&E(e)&&g&&e.extractWithChild(p,n,"html")&&(r=!0)}if(r&&!i){if(pe(m)&&m.append(d),t.append(m),f){let u=f.call(s,m);u&&m.replaceWith(u)}}else t.append(d);return r}function zN(o,e){let{nodeName:t}=o,n=e._htmlConversions.get(t.toLowerCase()),r=null;if(n!==void 0)for(let i of n){let s=i(o);s!==null&&(r===null||(r.priority||0)<(s.priority||0))&&(r=s)}return r!==null?r.conversion:null}var Su=new Set(["STYLE","SCRIPT"]);function Lu(o,e,t,n,r=new Map,i){let s=[];if(Su.has(o.nodeName))return s;let l=null,a=zN(o,e),c=a?a(o):null,m=null;if(c!==null){m=c.after;let p=c.node;if(p==="ignore")return s;if(l=Array.isArray(p)?p[p.length-1]:p,l!==null){for(let[,g]of r)if(l=g(l,i),!l)break;l&&s.push(...Array.isArray(p)?p:[l])}c.forChild!=null&&r.set(o.nodeName,c.forChild)}let f=o.childNodes,d=[],u=l!=null&&me(l)?!1:l!=null&&Ko(l)||n;for(let p=0;p<f.length;p++)d.push(...Lu(f[p],e,t,u,new Map(r),l));return m!=null&&(d=m(d)),po(o)&&(u?d=bu(o,d,()=>{let p=new To;return t.push(p),p}):d=bu(o,d,I)),l==null?d.length>0?s=s.concat(d):po(o)&&qN(o)&&(s=s.concat(ut())):E(l)&&l.append(...d),s}function bu(o,e,t){let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(Ko(s))n.push(s);else if(r.push(s),i===e.length-1||i<e.length-1&&Ko(e[i+1])){let l=t();l.append(...r),n.push(l),r=[]}}return n}function WN(o){for(let e of o)e.getNextSibling()instanceof To&&e.insertAfter(ut());for(let e of o){let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}}function qN(o){return o.nextSibling==null||o.previousSibling==null?!1:Io(o.nextSibling)&&Io(o.previousSibling)}var wu=o=>fe?(o||window).getSelection():null;function vu(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?"":Ri(o,e)}function Du(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(Au(o,e))}function ki(o,e,t){let n=o.getData("application/x-lexical-editor");if(n)try{let s=JSON.parse(n);if(s.namespace===t._config.namespace&&Array.isArray(s.nodes)){let l=Ru(s.nodes);return Kl(t,l,e)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Ai(t,l);return Kl(t,a,e)}catch{}let i=o.getData("text/plain")||o.getData("text/uri-list");if(i!=null)if(_(e)){let s=i.split(/(\r?\n|\t)/);s[s.length-1]===""&&s.pop();for(let l=0;l<s.length;l++){let a=T();if(_(a)){let c=s[l];c===`
-`||c===`\r
-`?a.insertParagraph():c===" "?a.insertNodes([St()]):a.insertText(c)}}}else e.insertRawText(i)}function Kl(o,e,t){o.dispatchCommand(er,{nodes:e,selection:t})||t.insertNodes(e)}function YN(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&x(!1,"LexicalNode: Node %s does not implement .exportJSON().",t.name),E(o)){let n=e.children;Array.isArray(n)||x(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name)}return e}function Ou(o,e,t,n=[]){let r=e!==null?t.isSelected(e):!0,i=E(t)&&t.excludeFromCopy("html"),s=t;if(e!==null){let c=Zt(t);c=y(c)&&e!==null?Or(e,c):c,s=c}let l=E(s)?s.getChildren():[],a=YN(s);if(y(s)){let c=s.__text;c.length>0?a.text=c:r=!1}for(let c=0;c<l.length;c++){let m=l[c],f=Ou(o,e,m,a.children);!r&&E(t)&&f&&t.extractWithChild(m,e,"clone")&&(r=!0)}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let m=a.children[c];n.push(m)}return r}function Au(o,e){let t=[],r=F().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Ou(o,e,s,t)}return{namespace:o._config.namespace,nodes:t}}function Ru(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=Dl(n);y(r)&&$l(r),e.push(r)}return e}var ZN=50,Rn=null;async function kn(o,e,t){if(Rn!==null)return!1;if(e!==null)return new Promise((a,c)=>{o.update(()=>{a(Mu(o,e,t))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=wu(o._window);if(n===null||i===null)return!1;let s=r.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(r.createTextNode("#")),n.append(s);let l=new Range;return l.setStart(s,0),l.setEnd(s,1),i.removeAllRanges(),i.addRange(l),new Promise((a,c)=>{let m=o.registerCommand(so,f=>(mt(f,ClipboardEvent)&&(m(),Rn!==null&&(window.clearTimeout(Rn),Rn=null),a(Mu(o,f,t))),!0),Re);Rn=window.setTimeout(()=>{m(),Rn=null,a(!1)},ZN),r.execCommand("copy"),s.remove()})}function Mu(o,e,t){if(t===void 0){let r=wu(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!Wt(o,i,s))return!1;let l=T();if(l===null)return!1;t=Ii(l)}e.preventDefault();let n=e.clipboardData;return n===null?!1:(ku(n,t),!0)}var VN=[["text/html",vu],["application/x-lexical-editor",Du]];function Ii(o=T()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=nl();for(let[n,r]of VN){let i=r(t,o);i!==null&&(e[n]=i)}}return e}function ku(o,e){for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n)}}function $i(o,e){if(typeof document.caretRangeFromPoint<"u"){let t=document.caretRangeFromPoint(o,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let t=document.caretPositionFromPoint(o,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}else return null}var Iu=$("DRAG_DROP_PASTE_FILE");function XN(o,e){o.preventDefault(),e.update(()=>{let t=T(),n=mt(o,InputEvent)||mt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&t!==null&&ki(n,t,e)},{tag:"paste"})}async function GN(o,e){await kn(e,mt(o,ClipboardEvent)?o:null),e.update(()=>{let t=T();_(t)?t.removeText():Se(t)&&t.getNodes().forEach(n=>n.remove())})}function Pi(o){let e=null;if(mt(o,DragEvent)?e=o.dataTransfer:mt(o,ClipboardEvent)&&(e=o.clipboardData),e===null)return[!1,[],!1];let t=e.types,n=t.includes("Files"),r=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),r]}function Bi(o){let e=ee(o);return B(e)}function jN(o){let e=o.focus;return e.key==="root"&&e.offset===F().getChildrenSize()}function $u(o){return Gt(o.registerCommand(tr,t=>{let n=T();return Se(n)?(n.clear(),!0):!1},0),o.registerCommand(Ze,t=>{let n=T();return _(n)?(n.deleteCharacter(t),!0):!1},X),o.registerCommand(Tt,t=>{let n=T();return _(n)?(n.deleteWord(t),!0):!1},X),o.registerCommand(it,t=>{let n=T();return _(n)?(n.deleteLine(t),!0):!1},X),o.registerCommand(rt,t=>{let n=T();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;let r=t.dataTransfer;if(r!=null)ki(r,n,o);else if(_(n)){let i=t.data;return i&&n.insertText(i),!0}}return!0},X),o.registerCommand(cn,()=>{let t=T();return _(t)?(t.removeText(),!0):!1},X),o.registerCommand(Ne,t=>{let n=T();return _(n)?(n.formatText(t),!0):!1},X),o.registerCommand($t,t=>{let n=T();return _(n)?(n.insertLineBreak(t),!0):!1},X),o.registerCommand(Pt,()=>{let t=T();return _(t)?(t.insertParagraph(),!0):!1},X),o.registerCommand(Rs,()=>(Oe([St()]),!0),X),o.registerCommand(wo,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=Yt(n.focus,!0);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},X),o.registerCommand(Bt,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(jN(n))return t.preventDefault(),!0;let r=Yt(n.focus,!1);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},X),o.registerCommand(Mo,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(wi(n,!0)){let r=t.shiftKey;return t.preventDefault(),vi(n,r,!0),!0}return!1},X),o.registerCommand(Lo,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let i=n.getNodes();if(i.length>0)return t.preventDefault(),i[0].selectNext(0,0),!0}if(!_(n))return!1;let r=t.shiftKey;return wi(n,!1)?(t.preventDefault(),vi(n,r,!1),!0):!1},X),o.registerCommand(Ft,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ze,!0)):!1},X),o.registerCommand(Ht,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ze,!1)):!1},X),o.registerCommand(Fe,t=>{let n=T();if(!_(n))return!1;if(t!==null){if((Ct||Kt||Ut)&&uo)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand($t,!1)}return o.dispatchCommand(Pt,void 0)},X),o.registerCommand(vo,()=>{let t=T();return _(t)?(o.blur(),!0):!1},X),o.registerCommand(Oo,t=>{let[,n]=Pi(t);if(n.length>0){let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let{offset:a,node:c}=l,m=ee(c);if(m!==null){let f=Uo();if(y(m))f.anchor.set(m.getKey(),a,"text"),f.focus.set(m.getKey(),a,"text");else{let u=m.getParentOrThrow().getKey(),p=m.getIndexWithinParent()+1;f.anchor.set(u,p,"element"),f.focus.set(u,p,"element")}let d=Ao(f);Y(d)}o.dispatchCommand(Iu,n)}return t.preventDefault(),!0}let r=T();return!!_(r)},X),o.registerCommand(nr,t=>{let[n]=Pi(t),r=T();return!(n&&!_(r))},X),o.registerCommand(rr,t=>{let[n]=Pi(t),r=T();if(n&&!_(r))return!1;let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let a=ee(l.node);B(a)&&t.preventDefault()}return!0},X),o.registerCommand(dn,()=>(tl(),!0),X),o.registerCommand(so,t=>(kn(o,mt(t,ClipboardEvent)?t:null),!0),X),o.registerCommand(lo,t=>(GN(t,o),!0),X),o.registerCommand(no,t=>{let[,n,r]=Pi(t);return n.length>0&&!r?(o.dispatchCommand(Iu,n),!0):En(t.target)?!1:T()!==null?(XN(t,o),!0):!1},X))}var qo=class o extends Z{constructor(t,n){super(n);this.__id="";this.__category="info";this.__alignment="";this.__inset=0;this.__category=t}static getType(){return"callout"}static clone(t){let n=new o(t.__category,t.__key);return n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setCategory(t){let n=this.getWritable();n.__category=t}getCategory(){return this.getLatest().__category}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}createDOM(t,n){let r=document.createElement("p");return r.classList.add("callout",this.__category||""),et(r,this),r}updateDOM(t){return t.__category!==this.__category||wt(t,this)}insertNewAfter(t,n){let r=t?t.anchor.offset:0,i=r===this.getTextContentSize()||!t?I():In(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&t){let s=I();s.select(),this.replace(s,!0)}return i}static importDOM(){return{p(t){return t.classList.contains("callout")?{conversion:n=>{let r="info",i=["info","success","warning","danger"];for(let l of i)if(n.classList.contains(l)){r=l;break}let s=new o(r);return Qe(n,s),{node:s}},priority:3}:null}}}exportJSON(){return{...super.exportJSON(),type:"callout",version:1,category:this.__category,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=In(t.category);return tt(t,n),n}};function In(o="info"){return new qo(o)}function Ul(o){return o instanceof qo}function zl(o,e="info"){return o instanceof qo&&o.getCategory()===e}var JN=new Set(["http:","https:","mailto:","sms:","tel:"]),$n=class o extends Z{static getType(){return"link"}static clone(e){return new o(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);let{target:r=null,rel:i=null,title:s=null}=t;this.__url=e,this.__target=r,this.__rel=i,this.__title=s}createDOM(e){let t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Te(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){let r=this.__url,i=this.__target,s=this.__rel,l=this.__title;r!==e.__url&&(t.href=r),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),s!==e.__rel&&(s?t.rel=s:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:QN,priority:1})}}static importJSON(e){let t=gt(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setDirection(e.direction),t}sanitizeUrl(e){try{let t=new URL(e);if(!JN.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){let t=this.getWritable();t.__url=e}getTarget(){return this.getLatest().__target}setTarget(e){let t=this.getWritable();t.__target=e}getRel(){return this.getLatest().__rel}setRel(e){let t=this.getWritable();t.__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){let t=this.getWritable();t.__title=e}insertNewAfter(e,t=!0){let n=gt(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!_(t))return!1;let r=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function QN(o){let e=null;if(fi(o)){let t=o.textContent;(t!==null&&t!==""||o.children.length>0)&&(e=gt(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:e}}function gt(o,e){return ne(new $n(o,e))}function Ot(o){return o instanceof $n}var $S=$("TOGGLE_LINK_COMMAND");function ex(o){return o.map(e=>{if(y(e)){let t=I();return t.append(e),t}return e})}function _o(o,e){let t=du(e),n=Ai(o,t);return ex(n)}function At(o,e){for(let t of o.getParents())if(e(t))return t;return null}function Wl(o,e){e||(e=F());let t=[];for(let n of e.getChildren())o(n)&&t.push(n),E(n)&&t.push(...Wl(o,n));return t}function Pu(o,e,t){let n=F().getChildren();for(let r of n){let i=o.getElementByKey(r.__key);if(!i)continue;let s=i.getBoundingClientRect();if(t<=s.bottom)return r}return null}function Pn(o){let e=t=>(E(t)||B(t))&&!t.isInline()&&!oe(t);return e(o)?o:H(o,e)}function Ar(o){return"__alignment"in o}function Bu(o){return"__inset"in o}var Fu=new WeakMap;function le(o){return Fu.get(o)||null}function Hu(o,e){Fu.set(o,e)}function ae(o,e){return V(o,e)!==null}function V(o,e){if(!o)return null;for(let t of o.getNodes()){if(e(t))return t;let n=At(t,e);if(n)return n}return null}function Ku(o){return V(o,y)}function Uu(o,e){if(!o)return!1;for(let t of o.getNodes())if(y(t)&&t.hasFormat(e))return!0;return!1}function Bn(o,e){let t=T(),n=t?xu(t.getNodes()[0]):null;t&&o(n)?Mi(t,I):Mi(t,e)}function Yo(o,e=!0){ql([o],e)}function ql(o,e=!0){let t=T()?.getNodes()||[],n=t.length>0?Pn(t[0]):null;if(n)if(e)for(let r=o.length-1;r>=0;r--)n.insertAfter(o[r]);else for(let r of o)n.insertBefore(r);else F().append(...o)}function ke(o){let e=Ho();e.add(o.getKey()),Y(e)}function zu(o){for(let e of o){if(y(e))return e;if(E(e)){let t=e.getChildren(),n=zu(t);if(n!==null)return n}}return null}function Wu(o){let e=[...o].reverse();for(let t of e){if(y(t))return t;if(E(t)){let n=[...t.getChildren()].reverse(),r=Wu(n);if(r!==null)return r}}return null}function qu(o){if(o.length===0)return;let e=Uo(),t=zu(o),n=Wu(o);t&&n&&(e.setTextNodeRange(t,0,n,n.getTextContentSize()||0),Y(e))}function Yu(o){let e=le(o);e&&window.requestAnimationFrame(()=>{o.update(()=>{Y(e.clone())})})}function Fi(o,e){if(!o)return!1;let t=e.getKey();for(let n of o.getNodes())if(n.getKey()===t)return!0;return!1}function Rr(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Ar(n)&&n.getAlignment()===e)return!0;return!1}function Yl(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Ko(n)&&n.getDirection()===e)return!0;return!1}function Rt(o){if(!o)return[];let e=new Map;for(let t of o.getNodes()){let n=Pn(t);E(n)&&e.set(n.getKey(),n)}return Array.from(e.values())}var Zo=class o extends Z{constructor(t,n,r){super(r);this.__src="";this.__alt="";this.__width=0;this.__height=0;this.__alignment="";this.__src=t,n.alt&&(this.__alt=n.alt),n.width&&(this.__width=n.width),n.height&&(this.__height=n.height)}static getType(){return"image"}static clone(t){let n=new o(t.__src,{alt:t.__alt,width:t.__width,height:t.__height},t.__key);return n.__alignment=t.__alignment,n}setSrc(t){let n=this.getWritable();n.__src=t}getSrc(){return this.getLatest().__src}setAltText(t){let n=this.getWritable();n.__alt=t}getAltText(){return this.getLatest().__alt}setHeight(t){let n=this.getWritable();n.__height=t}getHeight(){return this.getLatest().__height}setWidth(t){let n=this.getWritable();n.__width=t}getWidth(){return this.getLatest().__width}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}isInline(){return!0}createDOM(t,n){let r=document.createElement("img");return r.setAttribute("src",this.__src),this.__width&&r.setAttribute("width",String(this.__width)),this.__height&&r.setAttribute("height",String(this.__height)),this.__alt&&r.setAttribute("alt",this.__alt),this.__alignment&&r.classList.add("align-"+this.__alignment),r.addEventListener("click",i=>{n.update(()=>{ke(this)})}),r}updateDOM(t,n){return t.__src!==this.__src&&n.setAttribute("src",this.__src),t.__width!==this.__width&&(this.__width?n.setAttribute("width",String(this.__width)):n.removeAttribute("width")),t.__height!==this.__height&&(this.__height?n.setAttribute("height",String(this.__height)):n.removeAttribute("height")),t.__alt!==this.__alt&&(this.__alt?n.setAttribute("alt",String(this.__alt)):n.removeAttribute("alt")),t.__alignment!==this.__alignment&&(t.__alignment&&n.classList.remove("align-"+t.__alignment),this.__alignment&&n.classList.add("align-"+this.__alignment)),!1}static importDOM(){return{img(t){return{conversion:n=>{let r=n.getAttribute("src")||"",i={alt:n.getAttribute("alt")||"",height:Number.parseInt(n.getAttribute("height")||"0"),width:Number.parseInt(n.getAttribute("width")||"0")},s=new o(r,i);return s.setAlignment(vr(n)),{node:s}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"image",version:1,src:this.__src,alt:this.__alt,height:this.__height,width:this.__width,alignment:this.__alignment}}static importJSON(t){let n=Fn(t.src,{alt:t.alt,width:t.width,height:t.height});return n.setAlignment(t.alignment),n}};function Fn(o,e={}){return new Zo(o,e)}function ht(o){return o instanceof Zo}var Hn=class o extends Z{constructor(){super(...arguments);this.__id="";this.__summary="";this.__open=!1}static getType(){return"details"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setSummary(t){let n=this.getWritable();n.__summary=t}getSummary(){return this.getLatest().__summary}setOpen(t){let n=this.getWritable();n.__open=t}getOpen(){return this.getLatest().__open}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__dir=t.__dir,n.__summary=t.__summary,n.__open=t.__open,n}createDOM(t,n){let r=document.createElement("details");this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),this.__open&&r.setAttribute("open","true");let i=document.createElement("summary");return i.textContent=this.__summary,i.setAttribute("contenteditable","false"),i.addEventListener("click",s=>{s.preventDefault(),n.update(()=>{this.select()})}),r.append(i),r}updateDOM(t,n){return t.__open!==this.__open&&n.toggleAttribute("open",this.__open),t.__id!==this.__id||t.__dir!==this.__dir||t.__summary!==this.__summary}static importDOM(){return{details(t){return{conversion:n=>{let r=new o;n.id&&r.setId(n.id),n.dir&&r.setDirection(Dr(n));let i=Array.from(n.children).find(s=>s.nodeName==="SUMMARY");return r.setSummary(i?.textContent||""),{node:r}},priority:3}},summary(t){return{conversion:n=>({node:"ignore"}),priority:3}}}}exportDOM(t){let n=this.createDOM(t._config,t),r=n.querySelectorAll("[contenteditable]");for(let i of r)i.removeAttribute("contenteditable");return n.removeAttribute("open"),{element:n}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id,summary:this.__summary}}static importJSON(t){let n=Zl();return n.setId(t.id),n.setDirection(t.direction),n}};function Zl(){return new Hn}function Ie(o){return o instanceof Hn}function Vl(o){let e=1,t=o.getParent();for(;t!=null;){if(G(t)){let n=t.getParent();if(U(n)){e++,t=n.getParent();continue}x(!1,"A ListItemNode must have a ListNode for a parent.")}return e}return e}function Xl(o){let e=o.getParent();U(e)||x(!1,"A ListItemNode must have a ListNode for a parent.");let t=e;for(;t!==null;)t=t.getParent(),U(t)&&(e=t);return e}function Gl(o){let e=[],t=o.getChildren().filter(G);for(let n=0;n<t.length;n++){let r=t[n],i=r.getFirstChild();U(i)?e=e.concat(Gl(i)):e.push(r)}return e}var A0=Symbol.for("@lexical/NestedListNodeBrand");function Kn(o){return G(o)&&U(o.getFirstChild())}function Zu(o){return $e().append(o)}function Xu(o,e){return G(o)&&(e.length===0||e.length===1&&o.is(e[0])&&o.getChildrenSize()===0)}function jl(o,e){o.update(()=>{let t=T();if(t!==null){let n=t.getNodes();if(_(t)){let i=t.getStartEndPoints();x(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(Xu(l,n)){let c=Ce(e);if(me(a)){l.replace(c);let m=$e();c.append(m)}else if(G(l)){let m=l.getParentOrThrow();kr(c,m.getChildren()),m.replace(c)}return}}let r=new Set;for(let i=0;i<n.length;i++){let s=n[i];if(E(s)&&s.isEmpty()&&!G(s)&&!r.has(s.getKey())){Vu(s,e);continue}if(gr(s)){let l=s.getParent();for(;l!=null;){let a=l.getKey();if(U(l)){if(!r.has(a)){let c=Ce(e);kr(c,l.getChildren()),l.replace(c),r.add(a)}break}else{let c=l.getParent();if(me(c)&&!r.has(a)){r.add(a),Vu(l,e);break}l=c}}}}}})}function kr(o,e){o.splice(o.getChildrenSize(),0,e)}function Vu(o,e){if(U(o))return o;let t=o.getPreviousSibling(),n=o.getNextSibling(),r=$e();if(kr(r,o.getChildren()),U(t)&&e===t.getListType())return t.append(r),o.remove(),U(n)&&e===n.getListType()&&(kr(t,n.getChildren()),n.remove()),t;if(U(n)&&e===n.getListType())return n.getFirstChildOrThrow().insertBefore(r),o.remove(),n;{let i=Ce(e);return i.append(r),o.replace(i),i}}function Hi(o,e){let t=o.getLastChild(),n=e.getFirstChild();t&&n&&Kn(t)&&Kn(n)&&(Hi(t.getFirstChild(),n.getFirstChild()),n.remove());let r=e.getChildren();r.length>0&&o.append(...r),e.remove()}function Jl(o){o.update(()=>{let e=T();if(_(e)){let t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(Xu(r,n))t.add(Xl(r));else for(let i=0;i<n.length;i++){let s=n[i];if(gr(s)){let l=Nu(s,jt);l!=null&&t.add(Xl(l))}}for(let i of t){let s=i,l=Gl(i);for(let a of l){let c=I();kr(c,a.getChildren()),s.insertAfter(c),s=c,a.__key===e.anchor.key&&e.anchor.set(c.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(c.getKey(),0,"element"),a.remove()}i.remove()}}})}function Gu(o){let e=o.getListType()!=="check",t=o.getStart();for(let n of o.getChildren())G(n)&&(n.getValue()!==t&&n.setValue(t),e&&n.getLatest().__checked!=null&&n.setChecked(void 0),U(n.getFirstChild())||t++)}function ju(o){let e=o.getNextSibling();U(e)&&o.getListType()===e.getListType()&&Hi(o,e)}var jt=class o extends Z{static getType(){return"listitem"}static clone(e){return new o(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){let t=document.createElement("li"),n=this.getParent();return U(n)&&n.getListType()==="check"&&Qu(t,this),t.value=this.__value,Ju(this)&&(t.style.listStyle="none"),t}updateDOM(e,t,n){let r=this.getParent();return U(r)&&r.getListType()==="check"&&Qu(t,this),t.style.listStyle=Ju(this)?"none":"",t.value=this.__value,!1}static transform(){return e=>{if(x(G(e),"node is not a ListItemNode"),e.__checked==null)return;let t=e.getParent();U(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tx,priority:0})}}static importJSON(e){let t=$e();return t.setChecked(e.checked),t.setValue(e.value),t.setDirection(e.direction),t}exportDOM(e){let t=this.createDOM(e._config);if(t.classList.contains("task-list-item")){let n=b("input",{type:"checkbox",disabled:"disabled"});t.hasAttribute("checked")&&(n.setAttribute("checked","checked"),t.removeAttribute("checked")),t.prepend(n)}return{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){let n=e[t];if(E(n)&&this.canMergeWith(n)){let r=n.getChildren();this.append(...r),n.remove()}else super.append(n)}return this}replace(e,t){if(G(e))return super.replace(e);let n=this.getParentOrThrow();if(!U(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{let r=Ce(n.getListType()),i=this.getNextSibling();for(;i;){let s=i;i=i.getNextSibling(),r.append(s)}n.insertAfter(e),e.insertAfter(r)}return t&&(x(E(e),"includeChildren should only be true for ElementNodes"),this.getChildren().forEach(r=>{e.append(r)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){let n=this.getParentOrThrow();if(U(n)||x(!1,"insertAfter: list node is not parent of list item node"),G(e))return super.insertAfter(e,t);let r=this.getNextSiblings();if(n.insertAfter(e,t),r.length!==0){let i=Ce(n.getListType());r.forEach(s=>i.append(s)),e.insertAfter(i,t)}return e}remove(e){let t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Kn(t)&&Kn(n)&&(Hi(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let r=this.getParentOrThrow(),i=r.getParent();if(G(i))return i.insertAfter(this),this.selectStart(),null;{let s=I();return r.insertAfter(s,t),this.remove(),s}}let n=$e(this.__checked==null?void 0:!1);return this.insertAfter(n,t),n}collapseAtStart(e){let t=I();this.getChildren().forEach(l=>t.append(l));let r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=G(i);if(r.getChildrenSize()===1)if(s)r.remove(),i.select();else{r.insertBefore(t),r.remove();let l=e.anchor,a=e.focus,c=t.getKey();l.type==="element"&&l.getNode().is(this)&&l.set(c,l.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(c,a.offset,"element")}else r.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){let t=this.getWritable();t.__value=e}getChecked(){let e=this.getLatest(),t,n=this.getParent();return U(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){let t=this.getWritable();t.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}canInsertAfter(e){return G(e)}canReplaceWith(e){return G(e)}canMergeWith(e){return ct(e)||G(e)}extractWithChild(e,t){if(!_(t))return!1;let n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Ce("bullet")}canMergeWhenEmpty(){return!0}};function Ju(o){let e=o.getChildren(),t=!1,n=!1;for(let r of e)U(r)?n=!0:r.getTextContent().trim().length>0&&(t=!0);return n&&!t}function Qu(o,e){let t=!U(e.getFirstChild());o.classList.toggle("task-list-item",t),e.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}function tx(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return ox(r)}let t=o.getAttribute("aria-checked");return{node:$e(t==="true"?!0:t==="false"?!1:void 0)}}function ox(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let t=o.hasAttribute("checked");return{node:$e(t)}}function $e(o){return ne(new jt(void 0,o))}function G(o){return o instanceof jt}var Vo=class o extends Z{constructor(t,n,r){super(r);this.__id="";let i=ix[t]||t;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=n}static getType(){return"list"}static clone(t){let n=new o(t.__listType,t.__start,t.__key);return n.__id=t.__id,n.__dir=t.__dir,n}getTag(){return this.__tag}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setListType(t){let n=this.getWritable();n.__listType=t,n.__tag=t==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(t,n){let r=this.__tag,i=document.createElement(r);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,ef(i,t.theme,this),this.__id&&i.setAttribute("id",this.__id),this.__dir&&i.setAttribute("dir",this.__dir),i}updateDOM(t,n,r){return t.__tag!==this.__tag||t.__dir!==this.__dir||t.__id!==this.__id?!0:(ef(n,r.theme,this),!1)}static transform(){return t=>{x(U(t),"node is not a ListNode"),ju(t),Gu(t)}}static importDOM(){return{ol:()=>({conversion:tf,priority:0}),ul:()=>({conversion:tf,priority:0})}}static importJSON(t){let n=Ce(t.listType,t.start);return n.setId(t.id),n.setDirection(t.direction),n}exportDOM(t){let{element:n}=super.exportDOM(t);return n&&pe(n)&&(this.__start!==1&&n.setAttribute("start",String(this.__start)),this.__listType==="check"&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1,id:this.__id}}canBeEmpty(){return!1}canIndent(){return!1}append(...t){for(let n=0;n<t.length;n++){let r=t[n];if(G(r))super.append(r);else{let i=$e();if(U(r))i.append(r);else if(E(r)){let s=q(r.getTextContent());i.append(s)}else i.append(r);super.append(i)}}return this}extractWithChild(t){return G(t)}};function ef(o,e,t){let n=[],r=[],i=e.list;if(i!==void 0){let s=i[`${t.__tag}Depth`]||[],l=Vl(t)-1,a=l%s.length,c=s[a],m=i[t.__tag],f,d=i.nested,u=i.checklist;if(d!==void 0&&d.list&&(f=d.list),m!==void 0&&n.push(m),u!==void 0&&t.__listType==="check"&&n.push(u),c!==void 0){n.push(...bt(c));for(let p=0;p<s.length;p++)p!==a&&r.push(t.__tag+p)}if(f!==void 0){let p=bt(f);l>1?n.push(...p):r.push(...p)}}r.length>0&&Di(o,...r),n.length>0&&Te(o,...n)}function nx(o){let e=[];for(let t of o)G(t)?e.push(t):e.push(Zu(t));return e}function rx(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let e of o.childNodes)if(pe(e)&&e.hasAttribute("aria-checked"))return!0;return!1}function tf(o){let e=o.nodeName.toLowerCase(),t=null;if(e==="ol"){let n=o.start;t=Ce("number",n)}else e==="ul"&&(rx(o)?t=Ce("check"):t=Ce("bullet"));return o.id&&t&&t.setId(o.id),o.dir&&t&&t.setDirection(Dr(o)),{after:nx,node:t}}var ix={ol:"number",ul:"bullet"};function Ce(o,e=1){return ne(new Vo(o,e))}function U(o){return o instanceof Vo}var ML=$("INSERT_UNORDERED_LIST_COMMAND"),wL=$("INSERT_ORDERED_LIST_COMMAND"),vL=$("INSERT_CHECK_LIST_COMMAND"),DL=$("REMOVE_LIST_COMMAND");var re={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Jt=class o extends Z{constructor(t=re.NO_STATUS,n=1,r,i){super(i);this.__styles=new Map;this.__alignment="";this.__colSpan=n,this.__rowSpan=1,this.__headerState=t,this.__width=r,this.__backgroundColor=null}static getType(){return"tablecell"}static clone(t){let n=new o(t.__headerState,t.__colSpan,t.__width,t.__key);return n.__rowSpan=t.__rowSpan,n.__backgroundColor=t.__backgroundColor,n.__styles=new Map(t.__styles),n.__alignment=t.__alignment,n}static importDOM(){return{td:t=>({conversion:of,priority:0}),th:t=>({conversion:of,priority:0})}}static importJSON(t){let n=Pe(t.headerState,t.colSpan,t.width);return t.rowSpan&&n.setRowSpan(t.rowSpan),n.setStyles(new Map(Object.entries(t.styles))),n.setAlignment(t.alignment),n}createDOM(t){let n=document.createElement(this.getTag());this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(n.style.backgroundColor=this.__backgroundColor),Te(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}exportDOM(t){let{element:n}=super.exportDOM(t);return{element:n}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth(),styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}getColSpan(){return this.__colSpan}setColSpan(t){return this.getWritable().__colSpan=t,this}getRowSpan(){return this.__rowSpan}setRowSpan(t){return this.getWritable().__rowSpan=t,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(t){let n=this.getWritable();return n.__headerState=t,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(t){let n=this.getWritable();return n.__width=t,this.__width}getWidth(){return this.getLatest().__width}clearWidth(){let t=this.getWritable();t.__width=void 0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}updateTag(t){let r=t.toLowerCase()==="th"?re.ROW:re.NO_STATUS,i=this.getWritable();i.__headerState=r}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(t){this.getWritable().__backgroundColor=t}toggleHeaderStyle(t){let n=this.getWritable();return(n.__headerState&t)===t?n.__headerState-=t:n.__headerState+=t,n}hasHeaderState(t){return(this.getHeaderStyles()&t)===t}hasHeader(){return this.getLatest().__headerState!==re.NO_STATUS}updateDOM(t){return t.__headerState!==this.__headerState||t.__width!==this.__width||t.__colSpan!==this.__colSpan||t.__rowSpan!==this.__rowSpan||t.__backgroundColor!==this.__backgroundColor||t.__styles!==this.__styles||t.__alignment!==this.__alignment}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function of(o){let e=o,t=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(e.style.width)&&(n=parseFloat(e.style.width));let i=Pe(t==="th"?re.ROW:re.NO_STATUS,e.colSpan,n);i.__rowSpan=e.rowSpan;let s=e.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",c=l.includes("line-through"),m=s.fontStyle==="italic",f=l.includes("underline");return o instanceof HTMLElement&&(i.setStyles(vn(o)),i.setAlignment(vr(o))),{after:d=>(d.length===0&&d.push(I()),d),forChild:(d,u)=>{if(v(u)&&!E(d)){let p=I();return ve(d)&&d.getTextContent()===`
-`?null:(y(d)&&(a&&d.toggleFormat("bold"),c&&d.toggleFormat("strikethrough"),m&&d.toggleFormat("italic"),f&&d.toggleFormat("underline")),p.append(d),p)}return d},node:i}}function Pe(o=re.NO_STATUS,e=1,t){return ne(new Jt(o,e,t))}function v(o){return o instanceof Jt}var sx=$("INSERT_TABLE_COMMAND");var Qt=class o extends Z{constructor(t){super(t);this.__styles=new Map}static getType(){return"tablerow"}static clone(t){let n=new o(t.__key);return n.__styles=new Map(t.__styles),n}static importDOM(){return{tr:t=>({conversion:lx,priority:0})}}static importJSON(t){let n=Xo();return n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(t){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return Te(n,t.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setHeight(t){let n=this.getWritable();return n.__height=t,this.__height}getHeight(){return this.getLatest().__height}updateDOM(t){return t.__height!==this.__height||t.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function lx(o){let e=Xo(),n=Wo(o.style.height);return e.setHeight(n),o instanceof HTMLElement&&e.setStyles(vn(o)),{node:e}}function Xo(){return ne(new Qt)}function Q(o){return o instanceof Qt}function ea(o,e,t=!0){let n=$r();for(let r=0;r<o;r++){let i=Xo();for(let s=0;s<e;s++){let l=re.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=re.ROW),s===0&&t.columns&&(l|=re.COLUMN)):t&&(r===0&&(l|=re.ROW),s===0&&(l|=re.COLUMN));let a=Pe(l),c=I();c.append(q()),a.append(c),i.append(a)}n.append(i)}return n}var Ql=(o,e)=>o===re.BOTH||o===e?e:re.NO_STATUS;function Ki(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.focus.getNode(),[n,,r]=Le(t),[i,s]=ot(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let c=a+n.__rowSpan-1,m=i[c],f=Xo();for(let u=0;u<l;u++){let{cell:p,startRow:g}=m[u];if(g+p.__rowSpan-1<=c){let C=m[u].cell.__headerState,N=Ql(C,re.COLUMN);f.append(Pe(N).append(I()))}else p.setRowSpan(p.__rowSpan+1)}let d=r.getChildAtIndex(c);x(Q(d),"focusEndRow is not a TableRowNode"),d.insertAfter(f)}else{let c=i[a],m=Xo();for(let d=0;d<l;d++){let{cell:u,startRow:p}=c[d];if(p===a){let h=c[d].cell.__headerState,C=Ql(h,re.COLUMN);m.append(Pe(C).append(I()))}else u.setRowSpan(u.__rowSpan+1)}let f=r.getChildAtIndex(a);x(Q(f),"focusEndRow is not a TableRowNode"),f.insertBefore(m)}}function Ui(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=Le(t),[i,,s]=Le(n),[l,a,c]=ot(s,i,r),m=l.length,f=o?Math.max(a.startColumn,c.startColumn):Math.min(a.startColumn,c.startColumn),d=o?f+i.__colSpan-1:f-1,u=s.getFirstChild();x(Q(u),"Expected firstTable child to be a row");let p=null;function g(C=re.NO_STATUS){let N=Pe(C).append(I());return p===null&&(p=N),N}let h=u;e:for(let C=0;C<m;C++){if(C!==0){let R=h.getNextSibling();x(Q(R),"Expected row nextSibling to be a row"),h=R}let N=l[C],L=N[d<0?0:d].cell.__headerState,M=Ql(L,re.ROW);if(d<0){na(h,g(M));continue}let{cell:S,startColumn:A,startRow:O}=N[d];if(A+S.__colSpan-1<=d){let R=S,P=O,k=d;for(;P!==C&&R.__rowSpan>1;)if(k-=S.__colSpan,k>=0){let{cell:W,startRow:ie}=N[k];R=W,P=ie}else{h.append(g(M));continue e}R.insertAfter(g(M))}else S.setColSpan(S.__colSpan+1)}p!==null&&Ir(p)}function ta(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=ot(r,n,i),{startRow:c}=l,{startRow:m}=a,f=m+i.__rowSpan-1;if(s.length===f-c+1){r.remove();return}let d=s[0].length,u=s[f+1],p=r.getChildAtIndex(f+1);for(let g=f;g>=c;g--){for(let C=d-1;C>=0;C--){let{cell:N,startRow:L,startColumn:M}=s[g][C];if(M===C&&(g===c&&L<c&&N.setRowSpan(N.__rowSpan-(L-c)),L>=c&&L+N.__rowSpan-1>f))if(N.setRowSpan(N.__rowSpan-(f-L+1)),x(p!==null,"Expected nextRowNode not to be null"),C===0)na(p,N);else{let{cell:S}=u[C-1];S.insertAfter(N)}}let h=r.getChildAtIndex(g);x(Q(h),"Expected GridNode childAtIndex(%s) to be RowNode",String(g)),h.remove()}if(u!==void 0){let{cell:g}=u[0];Ir(g)}else{let g=s[c-1],{cell:h}=g[0];Ir(h)}}function oa(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=ot(r,n,i),{startColumn:c}=l,{startRow:m,startColumn:f}=a,d=Math.min(c,f),u=Math.max(c+n.__colSpan-1,f+i.__colSpan-1),p=u-d+1;if(s[0].length===u-d+1){r.selectPrevious(),r.remove();return}let h=s.length;for(let L=0;L<h;L++)for(let M=d;M<=u;M++){let{cell:S,startColumn:A}=s[L][M];if(A<d){if(M===d){let O=d-A;S.setColSpan(S.__colSpan-Math.min(p,S.__colSpan-O))}}else if(A+S.__colSpan-1>u){if(M===u){let O=u-A+1;S.setColSpan(S.__colSpan-O)}}else S.remove()}let C=s[m],N=c>f?C[c+n.__colSpan]:C[f+i.__colSpan];if(N!==void 0){let{cell:L}=N;Ir(L)}else{let L=f<c?C[f-1]:C[c-1],{cell:M}=L;Ir(M)}}function Ir(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart()}function na(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e)}function ra(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),[t,n,r]=Le(e),i=t.__colSpan,s=t.__rowSpan;if(i>1){for(let l=1;l<i;l++)t.insertAfter(Pe(re.NO_STATUS).append(I()));t.setColSpan(1)}if(s>1){let[l,a]=ot(r,t,t),{startColumn:c,startRow:m}=a,f;for(let d=1;d<s;d++){let u=m+d,p=l[u];f=(f||n).getNextSibling(),x(Q(f),"Expected row next sibling to be a row");let g=null;for(let h=0;h<c;h++){let C=p[h],N=C.cell;C.startRow===u&&(g=N),N.__colSpan>1&&(h+=N.__colSpan-1)}if(g===null)for(let h=0;h<i;h++)na(f,Pe(re.NO_STATUS).append(I()));else for(let h=0;h<i;h++)g.insertAfter(Pe(re.NO_STATUS).append(I()))}t.setRowSpan(1)}}function ot(o,e,t){let[n,r,i]=nf(o,e,t);return x(r!==null,"Anchor not found in Grid"),x(i!==null,"Focus not found in Grid"),[n,r,i]}function nf(o,e,t){let n=[],r=null,i=null;function s(c,m,f){let d={cell:f,startColumn:m,startRow:c},u=f.__rowSpan,p=f.__colSpan;for(let g=0;g<u;g++){n[c+g]===void 0&&(n[c+g]=[]);for(let h=0;h<p;h++)n[c+g][m+h]=d}e!==null&&e.is(f)&&(r=d),t!==null&&t.is(f)&&(i=d)}function l(c,m){return n[c]===void 0||n[c][m]===void 0}let a=o.getChildren();for(let c=0;c<a.length;c++){let m=a[c];x(Q(m),"Expected GridNode children to be TableRowNode");let f=m.getChildren(),d=0;for(let u of f){for(x(v(u),"Expected TableRowNode children to be TableCellNode");!l(c,d);)d++;s(c,d,u),d+=u.__colSpan}}return[n,r,i]}function Le(o){let e;if(o instanceof Jt)e=o;else if("__type"in o){let r=H(o,v);x(v(r),"Expected to find a parent TableCellNode"),e=r}else{let r=H(o.getNode(),v);x(v(r),"Expected to find a parent TableCellNode"),e=r}let t=e.getParent();x(Q(t),"Expected TableCellNode to have a parent TableRowNode");let n=t.getParent();return x(K(n),"Expected TableRowNode to have a parent GridNode"),[e,t,n]}function zi(o){let[e,,t]=Le(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let c=n[l].getChildren(),m=0;for(let f=0;f<c.length;f++){for(;s[l][m];)m++;let d=c[f],u=d.__rowSpan||1,p=d.__colSpan||1;for(let g=0;g<u;g++)for(let h=0;h<p;h++)s[l+g][m+h]=d;if(e===d)return{colSpan:p,columnIndex:m,rowIndex:l,rowSpan:u};m+=p}}return null}var Wi=class o{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return z(e)?this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus):!1}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new o(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.focus.getNode();x(E(t),"Expected TableSelection focus to be an ElementNode"),Ao(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){let e=J(this.anchor.key);x(v(e),"Expected TableSelection anchor to be (or a child of) TableCellNode");let t=zi(e);x(t!==null,"getCellRect: expected to find AnchorNode");let n=J(this.focus.key);x(v(n),"Expected TableSelection focus to be (or a child of) TableCellNode");let r=zi(n);x(r!==null,"getCellRect: expected to find focusCellNode");let i=Math.min(t.columnIndex,r.columnIndex),s=Math.max(t.columnIndex,r.columnIndex),l=Math.min(t.rowIndex,r.rowIndex),a=Math.max(t.rowIndex,r.rowIndex);return{fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this.anchor.getNode(),n=this.focus.getNode(),r=H(t,v),i=H(n,v);x(v(r),"Expected TableSelection anchor to be (or a child of) TableCellNode"),x(v(i),"Expected TableSelection focus to be (or a child of) TableCellNode");let s=r.getParent();x(Q(s),"Expected anchorCell to have a parent TableRowNode");let l=s.getParent();x(K(l),"Expected tableNode to have a parent TableNode");let a=i.getParents()[1];if(a!==l){if(l.isParentOf(i)){let O=a.getParent();x(O!=null,"Expected focusCellParent to have a parent"),this.set(this.tableKey,i.getKey(),O.getKey())}else{let O=l.getParent();x(O!=null,"Expected gridParent to have a parent"),this.set(this.tableKey,O.getKey(),i.getKey())}return this.getNodes()}let[c,m,f]=ot(l,r,i),d=Math.min(m.startColumn,f.startColumn),u=Math.min(m.startRow,f.startRow),p=Math.max(m.startColumn+m.cell.__colSpan-1,f.startColumn+f.cell.__colSpan-1),g=Math.max(m.startRow+m.cell.__rowSpan-1,f.startRow+f.cell.__rowSpan-1),h=d,C=u,N=d,L=u;function M(O){let{cell:R,startColumn:P,startRow:k}=O;d=Math.min(d,P),u=Math.min(u,k),p=Math.max(p,P+R.__colSpan-1),g=Math.max(g,k+R.__rowSpan-1)}for(;d<h||u<C||p>N||g>L;){if(d<h){let O=L-C,R=h-1;for(let P=0;P<=O;P++)M(c[C+P][R]);h=R}if(u<C){let O=N-h,R=C-1;for(let P=0;P<=O;P++)M(c[R][h+P]);C=R}if(p>N){let O=L-C,R=N+1;for(let P=0;P<=O;P++)M(c[C+P][R]);N=R}if(g>L){let O=N-h,R=L+1;for(let P=0;P<=O;P++)M(c[R][h+P]);L=R}}let S=[l],A=null;for(let O=u;O<=g;O++)for(let R=d;R<=p;R++){let{cell:P}=c[O][R],k=P.getParent();x(Q(k),"Expected TableCellNode parent to be a TableRowNode"),k!==A&&S.push(k),S.push(P,...ax(P)),A=k}return st()||(this._cachedNodes=S),S}getTextContent(){let e=this.getNodes().filter(n=>v(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
-`:" ")}return t}};function z(o){return o instanceof Wi}function qi(){let o=De("root",0,"element"),e=De("root",0,"element");return new Wi("root",o,e)}function ax(o){let e=[],t=[o];for(;t.length>0;){let n=t.pop();x(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&t.unshift(...n.getChildren()),n!==o&&e.push(n)}return e}var Br=class{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.trackTable(),this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(e=>e())}trackTable(){let e=new MutationObserver(t=>{this.editor.update(()=>{let n=!1;for(let i=0;i<t.length;i++){let a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){n=!0;break}}if(!n)return;let r=this.editor.getElementByKey(this.tableNodeKey);if(!r)throw new Error("Expected to find TableElement in DOM");this.table=Go(r)})});this.editor.update(()=>{let t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=Go(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=e.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=Go(n);Pr(e,r,null),Y(null),e.dispatchCommand(we,void 0)})}enableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Di(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Te(t,e._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(e){if(e!==null&&e.tableKey===this.tableNodeKey){let t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Pr(t,this.table,this.tableSelection)}else e==null?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){let n=this.editor;n.update(()=>{let r=J(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=e.x,l=e.y;if(this.focusCell=e,this.anchorCell!==null){let a=ia(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||t))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(s===this.focusX&&l===this.focusY)return;if(this.focusX=s,this.focusY=l,this.isHighlightingCells){let a=ee(e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&v(a)&&r.is(bo(a))){let c=a.getKey();this.tableSelection=this.tableSelection.clone()||qi(),this.focusCellNodeKey=c,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(we,void 0),Pr(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update(()=>{let t=ee(e.elem);if(v(t)){let n=t.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():qi(),this.anchorCellNodeKey=n}})}formatCells(e){this.editor.update(()=>{let t=T();z(t)||x(!1,"Expected grid selection");let n=Uo(),r=n.anchor,i=n.focus;t.getNodes().forEach(s=>{v(s)&&s.getTextContentSize()!==0&&(r.set(s.getKey(),0,"element"),i.set(s.getKey(),s.getChildrenSize(),"element"),n.formatText(e))}),Y(t),this.editor.dispatchCommand(we,void 0)})}clearText(){let e=this.editor;e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=T();z(n)||x(!1,"Expected grid selection");let r=n.getNodes().filter(v);if(r.length===this.table.columns*this.table.rows){t.selectPrevious(),t.remove(),F().selectStart();return}r.forEach(i=>{if(E(i)){let s=I(),l=q();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),Pr(e,this.table,null),Y(null),e.dispatchCommand(we,void 0)})}};var cx="__lexicalTableSelection",ia=o=>fe?(o||window).getSelection():null,dx=o=>(o.buttons&1)===1;function aa(o,e,t,n){let r=t.getRootElement();if(r===null)throw new Error("No root element.");let i=new Br(t,o.getKey()),s=t._window||window;ux(e,i);let l=()=>{let d=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",d),s.removeEventListener("mousemove",u)},u=p=>{setTimeout(()=>{if(!dx(p)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",d),s.removeEventListener("mousemove",u);return}let g=la(p.target);g!==null&&(i.anchorX!==g.x||i.anchorY!==g.y)&&(p.preventDefault(),i.setFocusCellForSelection(g))},0)};return{onMouseMove:u,onMouseUp:d}};e.addEventListener("mousedown",d=>{setTimeout(()=>{if(d.button!==0||!s)return;let u=la(d.target);u!==null&&(Jo(d),i.setAnchorCellForSelection(u));let{onMouseUp:p,onMouseMove:g}=l();i.isSelecting=!0,s.addEventListener("mouseup",p),s.addEventListener("mousemove",g)},0)});let a=d=>{d.button===0&&t.update(()=>{let u=T(),p=d.target;z(u)&&u.tableKey===i.tableNodeKey&&r.contains(p)&&i.clearHighlight()})};s.addEventListener("mousedown",a),i.listenersToRemove.add(()=>s.removeEventListener("mousedown",a)),i.listenersToRemove.add(t.registerCommand(Bt,d=>Fr(t,d,"down",o,i),qe)),i.listenersToRemove.add(t.registerCommand(wo,d=>Fr(t,d,"up",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Mo,d=>Fr(t,d,"backward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Lo,d=>Fr(t,d,"forward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(vo,d=>{let u=T();if(z(u)){let p=H(u.focus.getNode(),v);if(v(p))return Jo(d),p.selectEnd(),!0}return!1},qe));let c=d=>()=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),A=>v(A));if(!v(p))return!1;let g=u.anchor.getNode(),h=u.focus.getNode(),C=o.isParentOf(g),N=o.isParentOf(h);if(C&&!N||N&&!C)return i.clearText(),!0;let M=H(u.anchor.getNode(),A=>E(A)),S=M&&H(M,A=>E(A)&&v(A.getParent()));if(!E(S)||!E(M))return!1;if(d===it&&S.getPreviousSibling()===null)return!0}return!1};[Tt,it,Ze].forEach(d=>{i.listenersToRemove.add(t.registerCommand(d,c(d),Re))});let m=d=>{let u=T();if(!jo(u,o)){let p=u?u.getNodes():null;if(p){let g=p.find(h=>K(h)&&h.getKey()===i.tableNodeKey);if(K(g)){if(!g.getParent())return!1;g.remove()}}return!1}if(z(u))return d&&(d.preventDefault(),d.stopPropagation()),i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1};i.listenersToRemove.add(t.registerCommand(Ft,m,Re)),i.listenersToRemove.add(t.registerCommand(Ht,m,Re)),i.listenersToRemove.add(t.registerCommand(lo,d=>{let u=T();if(u){if(!(z(u)||_(u)))return!1;kn(t,mt(d,ClipboardEvent)?d:null,Ii(u));let p=m(d);return _(u)&&u.removeText(),p}return!1},Re)),i.listenersToRemove.add(t.registerCommand(Ne,d=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.formatCells(d),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1},Re)),i.listenersToRemove.add(t.registerCommand(rt,d=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.clearHighlight(),!1;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1;if(typeof d=="string"){let g=lf(t,u,o);if(g)return sf(g,o,[q(d)]),!0}}return!1},Re)),n&&i.listenersToRemove.add(t.registerCommand(Do,d=>{let u=T();if(!_(u)||!u.isCollapsed()||!jo(u,o))return!1;let p=Zi(u.anchor.getNode());if(p===null)return!1;Jo(d);let g=o.getCordsFromCellNode(p,i.table);return af(i,o,g.x,g.y,d.shiftKey?"backward":"forward"),!0},Re)),i.listenersToRemove.add(t.registerCommand(ir,d=>o.isSelected(),qe));function f(d){let u=o.getCordsFromCellNode(d,i.table);return o.getDOMCellFromCordsOrThrow(u.x,u.y,i.table)}return i.listenersToRemove.add(t.registerCommand(er,d=>{let{nodes:u,selection:p}=d,g=p.getStartEndPoints(),h=z(p),N=_(p)&&H(p.anchor.getNode(),Be=>v(Be))!==null&&H(p.focus.getNode(),Be=>v(Be))!==null||h;if(u.length!==1||!K(u[0])||!N||g===null)return!1;let[L]=g,M=u[0],S=M.getChildren(),A=M.getFirstChildOrThrow().getChildrenSize(),O=M.getChildrenSize(),R=H(L.getNode(),Be=>v(Be)),P=R&&H(R,Be=>Q(Be)),k=P&&H(P,Be=>K(Be));if(!v(R)||!Q(P)||!K(k))return!1;let W=P.getIndexWithinParent(),ie=Math.min(k.getChildrenSize()-1,W+O-1),ln=R.getIndexWithinParent(),ec=Math.min(P.getChildrenSize()-1,ln+A-1),sh=Math.min(ln,ec),lh=Math.min(W,ie),ah=Math.max(ln,ec),ch=Math.max(W,ie),dh=k.getChildren(),tc=0;for(let Be=lh;Be<=ch;Be++){let oc=dh[Be];if(!Q(oc))return!1;let nc=S[tc];if(!Q(nc))return!1;let uh=oc.getChildren(),fh=nc.getChildren(),rc=0;for(let vs=sh;vs<=ah;vs++){let Jr=uh[vs];if(!v(Jr))return!1;let ic=fh[rc];if(!v(ic))return!1;let mh=Jr.getChildren();ic.getChildren().forEach(an=>{y(an)&&I().append(an),Jr.append(an)}),mh.forEach(an=>an.remove()),rc++}tc++}return!0},Re)),i.listenersToRemove.add(t.registerCommand(we,()=>{let d=T(),u=We();if(_(d)){let{anchor:p,focus:g}=d,h=p.getNode(),C=g.getNode(),N=Zi(h),L=Zi(C),M=!!(N&&o.is(bo(N))),S=!!(L&&o.is(bo(L))),A=M!==S,O=M&&S,R=d.isBackward();if(A){let P=d.clone();if(S){let[k]=ot(o,L,L),W=k[0][0].cell,ie=k[k.length-1].at(-1).cell;P.focus.set(R?W.getKey():ie.getKey(),R?W.getChildrenSize():ie.getChildrenSize(),"element")}Y(P),rf(t,i)}else O&&(N.is(L)||(i.setAnchorCellForSelection(f(N)),i.setFocusCellForSelection(f(L),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:P,onMouseMove:k}=l();i.isSelecting=!0,s.addEventListener("mouseup",P),s.addEventListener("mousemove",k)},0)))}else if(d&&z(d)&&d.is(u)&&d.tableKey===o.getKey()){let p=ia(t._window);if(p&&p.anchorNode&&p.focusNode){let g=ee(p.focusNode),h=g&&!o.is(bo(g)),C=ee(p.anchorNode),N=C&&o.is(bo(C));if(h&&N&&p.rangeCount>0){let L=wl(p,t);L&&(L.anchor.set(o.getKey(),d.isBackward()?o.getChildrenSize():0,"element"),p.removeAllRanges(),Y(L))}}}return d&&!d.is(u)&&(z(d)||z(u))&&i.tableSelection&&!i.tableSelection.is(u)?(z(d)&&d.tableKey===i.tableNodeKey?i.updateTableTableSelection(d):!z(d)&&z(u)&&u.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?fx(t,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&rf(t,i),!1)},Re)),i.listenersToRemove.add(t.registerCommand(Pt,()=>{let d=T();if(!_(d)||!d.isCollapsed()||!jo(d,o))return!1;let u=lf(t,d,o);return u?(sf(u,o),!0):!1},Re)),i}function ux(o,e){o[cx]=e}function la(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode}return null}function Go(o){let e=[],t={columns:0,domRows:e,rows:0},n=o.firstChild,r=0,i=0;for(e.length=0;n!=null;){let s=n.nodeName;if(s==="TD"||s==="TH"){let c=n,m={elem:c,hasBackgroundColor:c.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=m;let f=e[i];f===void 0&&(f=e[i]=[]),f[r]=m}else{let c=n.firstChild;if(c!=null){n=c;continue}}let l=n.nextSibling;if(l!=null){r++,n=l;continue}let a=n.parentNode;if(a!=null){let c=a.nextSibling;if(c==null)break;i++,r=0,n=c}}return t.columns=r+1,t.rows=i+1,t}function Pr(o,e,t){let n=new Set(t?t.getNodes():[]);ca(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,cf(o,r)):(r.highlighted=!1,df(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function ca(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=ee(s.elem);l!==null&&e(s,l,{x:i,y:n})}}}function rf(o,e){e.disableHighlightStyle(),ca(e.table,t=>{t.highlighted=!0,cf(o,t)})}function fx(o,e){e.enableHighlightStyle(),ca(e.table,t=>{let n=t.elem;t.highlighted=!1,df(o,t),n.getAttribute("style")||n.removeAttribute("style")})}var af=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)?Yi(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Yi(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),!0;case"up":return n!==0?Yi(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),!1):e.selectPrevious(),!0;case"down":return n!==o.table.rows-1?Yi(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),!0):e.selectNext(),!0;default:return!1}},mx=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)&&o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t+(i?1:-1),n,o.table)),!0;case"up":return n!==0?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n-1,o.table)),!0):!1;case"down":return n!==o.table.rows-1?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n+1,o.table)),!0):!1;default:return!1}};function jo(o,e){if(_(o)||z(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return!1}function Yi(o,e){e?o.selectStart():o.selectEnd()}var sa="172,206,247";function cf(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?t.style.setProperty("background-color",`rgb(${sa})`):t.style.setProperty("background-image",`linear-gradient(to right, rgba(${sa},0.85), rgba(${sa},0.85))`),t.style.setProperty("caret-color","transparent")}function df(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null&&t.style.removeProperty("background-color"),t.style.removeProperty("background-image"),t.style.removeProperty("caret-color")}function Zi(o){let e=H(o,v);return v(e)?e:null}function bo(o){let e=H(o,K);return K(e)?e:null}function Fr(o,e,t,n,r){if((t==="up"||t==="down")&&px(o))return!1;let i=T();if(!jo(i,n)){if(_(i)){if(i.isCollapsed()&&t==="backward"){let s=i.anchor.type,l=i.anchor.offset;if(s!=="element"&&!(s==="text"&&l===0))return!1;let a=i.anchor.getNode();if(!a)return!1;let c=H(a,f=>E(f)&&!f.isInline());if(!c)return!1;let m=c.getPreviousSibling();return!m||!K(m)?!1:(Jo(e),m.selectEnd(),!0)}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(me(s)){let l=i.getNodes()[0];if(l){let a=H(l,v);if(a&&n.isParentOf(a)){let c=n.getFirstDescendant(),m=n.getLastDescendant();if(!c||!m)return!1;let[f]=Le(c),[d]=Le(m),u=n.getCordsFromCellNode(f,r.table),p=n.getCordsFromCellNode(d,r.table),g=n.getDOMCellFromCordsOrThrow(u.x,u.y,r.table),h=n.getDOMCellFromCordsOrThrow(p.x,p.y,r.table);return r.setAnchorCellForSelection(g),r.setFocusCellForSelection(h,!0),!0}}return!1}else{let l=H(s,c=>E(c)&&!c.isInline());if(!l)return!1;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(K(a)&&r.tableNodeKey===a.getKey()){let c=a.getFirstDescendant(),m=a.getLastDescendant();if(!c||!m)return!1;let[f]=Le(c),[d]=Le(m),u=i.clone();return u.focus.set((t==="up"?f:d).getKey(),t==="up"?0:d.getChildrenSize(),"element"),Y(u),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),c=H(l.getNode(),v);if(!v(a)||!a.is(c))return!1;let m=bo(a);if(m!==n&&m!=null){let N=o.getElementByKey(m.getKey());if(N!=null)return r.table=Go(N),Fr(o,e,t,m,r)}if(t==="backward"||t==="forward"){let N=s.type,L=s.offset,M=s.getNode();if(!M)return!1;let S=i.getNodes();return S.length===1&&B(S[0])?!1:gx(N,L,M,t)?xx(e,M,n,t):!1}let f=o.getElementByKey(a.__key),d=o.getElementByKey(s.key);if(d==null||f==null)return!1;let u;if(s.type==="element")u=d.getBoundingClientRect();else{let N=window.getSelection();if(N===null||N.rangeCount===0)return!1;u=N.getRangeAt(0).getBoundingClientRect()}let p=t==="up"?a.getFirstChild():a.getLastChild();if(p==null)return!1;let g=o.getElementByKey(p.__key);if(g==null)return!1;let h=g.getBoundingClientRect();if(t==="up"?h.top>u.top-u.height:u.bottom+u.height>h.bottom){Jo(e);let N=n.getCordsFromCellNode(a,r.table);if(e.shiftKey){let L=n.getDOMCellFromCordsOrThrow(N.x,N.y,r.table);r.setAnchorCellForSelection(L),r.setFocusCellForSelection(L,!0)}else return af(r,n,N.x,N.y,t);return!0}}else if(z(i)){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),c=H(l.getNode(),v),[m]=i.getNodes(),f=o.getElementByKey(m.getKey());if(!v(a)||!v(c)||!K(m)||f==null)return!1;r.updateTableTableSelection(i);let d=Go(f),u=n.getCordsFromCellNode(a,d),p=n.getDOMCellFromCordsOrThrow(u.x,u.y,d);if(r.setAnchorCellForSelection(p),Jo(e),e.shiftKey){let g=n.getCordsFromCellNode(c,d);return mx(r,m,g.x,g.y,t)}else c.selectEnd();return!0}return!1}function Jo(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function px(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":!1}function gx(o,e,t,n){return hx(o,t,n)||Nx(o,e,t,n)}function hx(o,e,t){return o==="element"&&(t==="backward"?e.getPreviousSibling()===null:e.getNextSibling()===null)}function Nx(o,e,t,n){let r=H(t,s=>E(s)&&!s.isInline());if(!r)return!1;let i=n==="backward"?e===0:e===t.getTextContentSize();return o==="text"&&i&&(n==="backward"?r.getPreviousSibling()===null:r.getNextSibling()===null)}function xx(o,e,t,n){let r=H(e,v);if(!v(r))return!1;let[i,s]=ot(t,r,r);if(!Ex(i,s,n))return!1;let l=Tx(e,n,t);return!l||K(l)?!1:(Jo(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function Ex(o,e,t){let n=o[0][0],r=o[o.length-1][o[0].length-1],{startColumn:i,startRow:s}=e;return t==="backward"?i===n.startColumn&&s===n.startRow:i===r.startColumn&&s===r.startRow}function Tx(o,e,t){let n=H(o,i=>E(i)&&!i.isInline());if(!n)return;let r=e==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&K(r)?r:e==="backward"?t.getPreviousSibling():t.getNextSibling()}function sf(o,e,t){let n=I();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd()}function lf(o,e,t){let n=t.getParent();if(!n)return;let r=o.getElementByKey(n.getKey());if(!r)return;let i=window.getSelection();if(!i||i.anchorNode!==r)return;let s=H(e.anchor.getNode(),h=>v(h));if(!s)return;let l=H(s,h=>K(h));if(!K(l)||!l.is(t))return;let[a,c]=ot(t,s,s),m=a[0][0],f=a[a.length-1][a[0].length-1],{startRow:d,startColumn:u}=c,p=d===m.startRow&&u===m.startColumn,g=d===f.startRow&&u===f.startColumn;return p?"first":g?"last":void 0}var kt=class{constructor(e){this.rowCount=0;this.columnCount=0;this.cells=[];this.buildCellMap(e)}buildCellMap(e){let t=[],n=(a,c,m)=>{typeof t[c]>"u"&&(t[c]=[]),t[c][a]=m},r=(a,c)=>!!(t[c]&&t[c][a]),i=e.getChildren().filter(a=>Q(a));for(let a=0;a<i.length;a++){let m=i[a].getChildren().filter(d=>v(d)),f=0;for(let d=0;d<m.length;d++){let u=m[d],p=u.getColSpan()||1,g=u.getRowSpan()||1;for(let h=f;h<f+p;h++)for(let C=a;C<a+g;C++){for(;r(h,C);)f+=1,h+=1;n(h,C,u)}f+=p}}this.rowCount=t.length,this.columnCount=Math.max(...t.map(a=>a.length));let s=[],l=t[0][0];for(let a=0;a<this.rowCount;a++)for(let c=0;c<this.columnCount;c++)!t[a]||!t[a][c]?s.push(l):(s.push(t[a][c]),l=t[a][c]);this.cells=s}getCellAtPosition(e,t){let n=t*this.columnCount+e;if(n>=this.cells.length)throw new Error(`TableMap Error: Attempted to get cell ${n+1} of ${this.cells.length}`);return this.cells[n]}getCellsInRange(e){let t=Math.max(Math.min(e.fromX,e.toX),0),n=Math.min(Math.max(e.fromX,e.toX),this.columnCount-1),r=Math.max(Math.min(e.fromY,e.toY),0),i=Math.min(Math.max(e.fromY,e.toY),this.rowCount-1),s=new Set;for(let l=r;l<=i;l++)for(let a=t;a<=n;a++)s.add(this.getCellAtPosition(a,l));return[...s.values()]}getCellsInColumn(e){return this.getCellsInRange({fromX:e,toX:e,fromY:0,toY:this.rowCount-1})}getRangeForCell(e){let t=null,n=e.getKey();for(let r=0;r<this.rowCount;r++)for(let i=0;i<this.columnCount;i++){let s=r*this.columnCount+i;this.cells[s].getKey()===n&&(t===null?t={fromX:i,toX:i,fromY:r,toY:r}:(t.fromX=Math.min(t.fromX,i),t.toX=Math.max(t.toX,i),t.fromY=Math.min(t.fromY,r),t.toY=Math.max(t.toY,r)))}return t}};function da(o){return At(o,K)}function ff(o){let e=mf(o),t=o.querySelector("colgroup"),n=[];return t&&(t.childElementCount===e?.childElementCount||!e)&&(n=uf(t)),n.filter(Boolean).length===0&&e&&(n=uf(e)),n}function mf(o){let e=o.querySelectorAll("tr"),t=0,n=null;for(let r of e)r.childElementCount>t&&(n=r,t=r.childElementCount);return n}function uf(o){return[...o.children].map(e=>Cx(e))}function Cx(o){let e=o.style.width||o.getAttribute("width");return e&&!Number.isNaN(Number(e))&&(e=e+"px"),e||""}function ua(o,e,t){let n=o.getChildren(),r=0;for(let s of n){let l=s.getChildren().length;l>r&&(r=l)}let i=o.getColWidths();(i.length===0||i.length<r)&&(i=Array(r).fill("")),e+1>i.length&&console.error(`Attempted to set table column width for column [${e}] but only ${i.length} columns found`),i[e]=ft(t),o.setColWidths(i)}function pf(o,e,t){let n=e.getColWidths();if(n.length>t&&n[t].endsWith("px"))return Number(n[t].replace("px",""));let r=o.getElementByKey(e.__key);if(r){let i=mf(r);if(i&&i.children.length>t)return i.children[t].clientWidth}return 0}function gf(o){let e=o.getParent();if(!Q(e))return-1;let t=0,n=e.getChildren();for(let r of n){let i=r.getColSpan()||1;if(t+=i,r.getKey()===o.getKey())break}return t-1}function hf(o,e){let t=da(o),n=gf(o);t&&n>=0&&ua(t,n,e)}function Nf(o,e){let t=da(e),n=gf(e);if(!t)return"";let r=t.getColWidths();return r.length>n?r[n]:""}function Qo(o){if(z(o))return o.getNodes().filter(n=>v(n));let e=V(o,v);return e?[e]:[]}function xf(o){let e=o.getShape(),t=Qo(o);if(t.length===0)return;let n=da(t[0]);if(!n)return;let r=new kt(n),i=r.getCellAtPosition(e.toX,e.toY);if(!i)return;let s=e.toX+((i.getColSpan()||1)-1),l=e.toY+((i.getRowSpan()||1)-1),a=r.getCellsInRange({fromX:e.fromX,fromY:e.fromY,toX:s,toY:l});if(a.length===0)return;let c=a[0],m=Math.abs(e.fromX-s)+1,f=Math.abs(e.fromY-l)+1;for(let d=1;d<a.length;d++){let u=a[d];c.append(...u.getChildren()),u.remove()}c.setColSpan(m),c.setRowSpan(f)}function eo(o){let e=Qo(o),t={};for(let n of e){let r=n.getParent();Q(r)&&(t[r.getKey()]=r)}return Object.values(t)}function Nt(o){let e=Qo(o);if(e.length===0)return null;let t=At(e[0],K);return K(t)?t:null}function Ef(o){o.setColWidths([]);for(let e of o.getChildren()){if(!Q(e))continue;let t=e.getStyles();t.delete("height"),t.delete("width"),e.setStyles(t);let n=e.getChildren().filter(r=>v(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function Tf(o){o.setColWidths([]),o.setStyles(new Map);for(let e of o.getChildren()){if(!Q(e))continue;e.setStyles(new Map);let t=e.getChildren().filter(n=>v(n));for(let n of t)n.setStyles(new Map),n.clearWidth()}}function fa(o,e){e:for(let t of o.getChildren()){if(!Q(t))continue;let n=t.getChildren();for(let r of n){if(!v(r))return;if(e(r)===!1)break e}}}function Cf(o){let e=null;return fa(o,t=>{let n=t.getStyles().get("padding")||"";if(e===null&&(e=n),n!==e)return e=null,!1}),e||""}var xt=class o extends vt{constructor(t){super(t);this.__colWidths=[];this.__styles=new Map}static getType(){return"table"}static clone(t){let n=new o(t.__key);return Co(t,n),n.__colWidths=t.__colWidths,n.__styles=new Map(t.__styles),n}static importDOM(){return{table:t=>({conversion:_x,priority:1})}}static importJSON(t){let n=$r();return tt(t,n),n.setColWidths(t.colWidths),n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"table",version:1,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles)}}createDOM(t,n){let r=document.createElement("table");Te(r,t.theme.table),et(r,this);let i=this.getColWidths();if(i.length>0){let s=b("colgroup");for(let l of i){let a=b("col");l&&(a.style.width=l),s.append(a)}r.append(s)}for(let[s,l]of this.__styles.entries())r.style.setProperty(s,l);return r}updateDOM(t){return wt(t,this)||this.__colWidths.join(":")!==t.__colWidths.join(":")||this.__styles.size!==t.__styles.size||Array.from(this.__styles.values()).join(":")!==Array.from(t.__styles.values()).join(":")}exportDOM(t){return{...super.exportDOM(t),after:n=>{if(!n)return;let r=n.cloneNode(),i=document.createElement("tbody");if(pe(n))for(let s of Array.from(n.children))s.nodeName==="TR"?i.append(s):s.nodeName==="CAPTION"?r.insertBefore(s,r.firstChild):r.append(s);return r.append(i),r}}}canBeEmpty(){return!1}isShadowRoot(){return!0}setColWidths(t){let n=this.getWritable();n.__colWidths=t}getColWidths(){return this.getLatest().__colWidths}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}getCordsFromCellNode(t,n){let{rows:r,domRows:i}=n;for(let s=0;s<r;s++){let l=i[s];if(l==null)continue;let a=l.findIndex(c=>{if(!c)return;let{elem:m}=c;return ee(m)===t});if(a!==-1)return{x:a,y:s}}throw new Error("Cell not found in table.")}getDOMCellFromCords(t,n,r){let{domRows:i}=r,s=i[n];if(s==null)return null;let l=t<s.length?t:s.length-1,a=s[l];return a??null}getDOMCellFromCordsOrThrow(t,n,r){let i=this.getDOMCellFromCords(t,n,r);if(!i)throw new Error("Cell not found at cords.");return i}getCellNodeFromCords(t,n,r){let i=this.getDOMCellFromCords(t,n,r);if(i==null)return null;let s=ee(i.elem);return v(s)?s:null}getCellNodeFromCordsOrThrow(t,n,r){let i=this.getCellNodeFromCords(t,n,r);if(!i)throw new Error("Node at cords not TableCellNode.");return i}canSelectBefore(){return!0}canIndent(){return!1}};function _x(o){let e=$r();Qe(o,e);let t=ff(o);return e.setColWidths(t),e.setStyles(vn(o)),{node:e}}function $r(){return ne(new xt)}function K(o){return o instanceof xt}var Un=class o extends Z{constructor(){super(...arguments);this.__id=""}static getType(){return"horizontal-rule"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n}createDOM(t,n){let r=document.createElement("hr");return this.__id&&r.setAttribute("id",this.__id),r}updateDOM(t,n){return t.__id!==this.__id}static importDOM(){return{hr(t){return{conversion:n=>{let r=new o;return n.id&&r.setId(n.id),{node:r}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"horizontal-rule",version:1,id:this.__id}}static importJSON(t){let n=ma();return n.setId(t.id),n}};function ma(){return new Un}function _f(o){return o instanceof Un}var bf=o=>(o.split(" ").filter(t=>t.startsWith("language-"))[0]||"").replace("language-",""),en=class o extends Mt{constructor(t="",n="",r){super(r);this.__id="";this.__language="";this.__code="";this.__language=t,this.__code=n}static getType(){return"code-block"}static clone(t){let n=new o(t.__language,t.__code,t.__key);return n.__id=t.__id,n}setLanguage(t){let n=this.getWritable();n.__language=t}getLanguage(){return this.getLatest().__language}setCode(t){let n=this.getWritable();n.__code=t}getCode(){return this.getLatest().__code}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"code",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){let r=b("pre",{id:this.__id||null},[b("code",{class:this.__language?`language-${this.__language}`:null},[this.__code])]);return b("div",{class:"editor-code-block-wrap"},[r])}updateDOM(t,n){let r=n.querySelector("code");return r&&(t.__language!==this.__language&&(r.className=this.__language?`language-${this.__language}`:""),t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__code!==this.__code&&(r.textContent=this.__code)),!1}exportDOM(t){return{element:this.createDOM(t._config,t).querySelector("pre")}}static importDOM(){return{pre(t){return{conversion:n=>{let r=n.querySelector("code"),i=bf(n.className)||r&&bf(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=Vi(i,s);return n.id&&l.setId(n.id),{node:l,after(a){return[]}}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(t){let n=Vi(t.language,t.code);return n.setId(t.id||""),n}};function Vi(o="",e=""){return new en(o,e)}function Xi(o){return o instanceof en}function Hr(o,e){let t=e.getCode(),n=e.getLanguage();window.$components.first("code-editor").open(t,n,"ltr",(i,s)=>{o.update(()=>{e.setCode(i),e.setLanguage(s)})},()=>{})}var yo=class o extends Mt{constructor(t,n,r){super(r);this.__id="";this.__drawingId="";this.__drawingUrl="";this.__drawingId=t,this.__drawingUrl=n}static getType(){return"diagram"}static clone(t){let n=new o(t.__drawingId,t.__drawingUrl);return n.__id=t.__id,n}setDrawingIdAndUrl(t,n){let r=this.getWritable();r.__drawingUrl=n,r.__drawingId=t}getDrawingIdAndUrl(){let t=this.getLatest();return{id:t.__drawingId,url:t.__drawingUrl}}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"diagram",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){return b("div",{id:this.__id||null,"drawio-diagram":this.__drawingId},[b("img",{src:this.__drawingUrl})])}updateDOM(t,n){let r=n.querySelector("img");return r&&(t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__drawingUrl!==this.__drawingUrl&&r.setAttribute("src",this.__drawingUrl),t.__drawingId!==this.__drawingId&&n.setAttribute("drawio-diagram",this.__drawingId)),!1}static importDOM(){return{div(t){return t.hasAttribute("drawio-diagram")?{conversion:n=>{let i=n.querySelector("img")?.getAttribute("src")||"",s=n.getAttribute("drawio-diagram")||"",l=zn(s,i);return n.id&&l.setId(n.id),{node:l}},priority:3}:null}}}exportJSON(){return{type:"diagram",version:1,id:this.__id,drawingId:this.__drawingId,drawingUrl:this.__drawingUrl}}static importJSON(t){let n=zn(t.drawingId,t.drawingUrl);return n.setId(t.id||""),n}};function zn(o="",e=""){return new yo(o,e)}var bx=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function yx(o){let e={};for(let t of Object.keys(o))bx.includes(t)&&(e[t]=o[t]);return e}function yf(o,e){let t=Sf(o),n={};for(let i of e.attributes)n[i.name]=i.value;t.setAttributes(n);let r=[];if(o==="video"||o==="audio"){for(let i of e.children)if(i.tagName==="SOURCE"){let s=i.getAttribute("src"),l=i.getAttribute("type");s&&l&&r.push({src:s,type:l})}t.setSources(r)}return Qe(e,t),t}var So=class o extends Z{constructor(t,n){super(n);this.__id="";this.__alignment="";this.__attributes={};this.__sources=[];this.__inset=0;this.__tag=t}static getType(){return"media"}static clone(t){let n=new o(t.__tag,t.__key);return n.__attributes=Object.assign({},t.__attributes),n.__sources=t.__sources.map(r=>Object.assign({},r)),n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setTag(t){let n=this.getWritable();n.__tag=t}getTag(){return this.getLatest().__tag}setAttributes(t){let n=this.getWritable();n.__attributes=yx(t)}getAttributes(){return this.getLatest().__attributes}setSources(t){let n=this.getWritable();n.__sources=t}getSources(){return this.getLatest().__sources}setSrc(t){let n=Object.assign({},this.getAttributes());this.__tag==="object"?n.data=t:n.src=t,this.setAttributes(n)}setWidthAndHeight(t,n){let r=Object.assign({},this.getAttributes(),{width:t,height:n});this.setAttributes(r)}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}setHeight(t){if(!t)return;let n=Object.assign({},this.getAttributes(),{height:t});this.setAttributes(n)}getHeight(){let t=this.getLatest();return Wo(t.__attributes.height||"0")}setWidth(t){let n=Object.assign({},this.getAttributes(),{width:t});this.setAttributes(n)}getWidth(){let t=this.getLatest();return Wo(t.__attributes.width||"0")}isInline(){return!0}isParentRequired(){return!0}createInnerDOM(){let n=(this.__tag==="video"||this.__tag==="audio"?this.__sources:[]).map(i=>b("source",i)),r=b(this.__tag,this.__attributes,n);return et(r,this),r}createDOM(t,n){let r=this.createInnerDOM(),i=b("span",{class:r.className+" editor-media-wrap"},[r]);return i.addEventListener("click",s=>{n.update(()=>ke(this))}),i}updateDOM(t,n){if(t.__tag!==this.__tag||JSON.stringify(t.__sources)!==JSON.stringify(this.__sources)||JSON.stringify(t.__attributes)!==JSON.stringify(this.__attributes))return!0;let r=n.firstElementChild;return t.__id!==this.__id&&uu(r,"id",this.__id),t.__alignment!==this.__alignment&&(t.__alignment&&(n.classList.remove(`align-${t.__alignment}`),r.classList.remove(`align-${t.__alignment}`)),this.__alignment&&(n.classList.add(`align-${this.__alignment}`),r.classList.add(`align-${this.__alignment}`))),t.__inset!==this.__inset&&(n.style.paddingLeft=`${this.__inset}px`),!1}static importDOM(){let t=n=>r=>({conversion:i=>({node:yf(n,i)}),priority:3});return{iframe:t("iframe"),embed:t("embed"),object:t("object"),video:t("video"),audio:t("audio")}}exportDOM(t){return{element:this.createInnerDOM()}}exportJSON(){return{...super.exportJSON(),type:"media",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset,tag:this.__tag,attributes:this.__attributes,sources:this.__sources}}static importJSON(t){let n=Sf(t.tag);return tt(t,n),n}};function Sf(o){return new So(o)}function Lf(o){let n=new DOMParser().parseFromString(`<body>${o}</body>`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?yf(r,n):null}var Sx=[{regex:/.*?youtu\.be\/([\w\-_\?&=.]+)/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"},{regex:/.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,w:560,h:314,url:"https://www.youtube.com/embed/$2?$4"},{regex:/.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"}],Lx=["mp4","mpeg","m4v","m4p","mov"],Mx=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],wx=["html","htm","php","asp","aspx",""];function Mf(o){for(let s of Sx)if(o.match(s.regex)){let a=o.replace(s.regex,s.url),c=new So("iframe");return c.setSrc(a),c.setHeight(s.h),c.setWidth(s.w),c}let e="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();Lx.includes(r)?e="video":Mx.includes(r)?e="audio":r&&!wx.includes(r)&&(e="embed");let i=new So(e);return i.setSrc(o),i}function to(o){return o instanceof So}var Yn=class o extends vt{static getType(){return"heading"}static clone(e){let t=new o(e.__tag,e.__key);return Co(e,t),t}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){let t=this.__tag,n=document.createElement(t),i=e.theme.heading;if(i!==void 0){let s=i[t];Te(n,s)}return et(n,this),n}updateDOM(e,t){return wt(e,this)}static importDOM(){return{h1:e=>({conversion:Wn,priority:0}),h2:e=>({conversion:Wn,priority:0}),h3:e=>({conversion:Wn,priority:0}),h4:e=>({conversion:Wn,priority:0}),h5:e=>({conversion:Wn,priority:0}),h6:e=>({conversion:Wn,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=qn(e.tag);return tt(e,t),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){let n=e?e.anchor.offset:0,r=this.getLastDescendant(),s=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?I():qn(this.getTag()),l=this.getDirection();if(s.setDirection(l),this.insertAfter(s,t),n===0&&!this.isEmpty()&&e){let a=I();a.select(),this.replace(a,!0)}return s}collapseAtStart(){let e=this.isEmpty()?I():qn(this.getTag());return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}extractWithChild(){return!0}};function Wn(o){let e=o.nodeName.toLowerCase(),t=null;return(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6")&&(t=qn(e),Qe(o,t)),{node:t}}function qn(o){return ne(new Yn(o))}function Zn(o){return o instanceof Yn}var Vn=class o extends vt{static getType(){return"quote"}static clone(e){let t=new o(e.__key);return Co(e,t),t}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Te(t,e.theme.quote),et(t,this),t}updateDOM(e,t){return wt(e,this)}static importDOM(){return{blockquote:e=>({conversion:vx,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=Gi();return tt(e,t),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){let n=I(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){let e=I();return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function Gi(){return ne(new Vn)}function ji(o){return o instanceof Vn}function vx(o){let e=Gi();return Qe(o,e),{node:e}}var Xn=class o extends Z{static getType(){return"caption"}static clone(e){return new o(e.__key)}createDOM(e,t){return document.createElement("caption")}updateDOM(e,t,n){return!1}isParentRequired(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),type:"caption",version:1}}insertDOMIntoParent(e,t){return t.insertBefore(e,t.firstChild),!0}static importJSON(e){return pa()}static importDOM(){return{caption:e=>({conversion(t){return{node:pa()}},priority:0})}}};function pa(){return new Xn}function ga(o){return o instanceof Xn}function ha(o){for(let e of o.getChildren())if(ga(e))return!0;return!1}function wf(o,e=""){let t=pa(),n=q(e||" ");t.append(n),o.append(t)}function vf(){return[qo,Yn,Vn,Vo,jt,xt,Qt,Jt,Xn,Zo,Un,Hn,en,yo,So,dt,$n]}function Df(o){let e=[Zo,en,yo],t=n=>{for(let[r,i]of n)if(i==="destroyed"){let s=o.manager.getDecoratorByNodeKey(r);s&&s.destroy(o)}};for(let n of e)o.editor.registerMutationListener(n,r=>t(r))}function Na(o){return"build"in o}var Me=class{constructor(){this.dom=null;this.context=null}setContext(e){this.context=e}getContext(){if(this.context===null)throw new Error("Attempted to use EditorUIContext before it has been set");return this.context}getDOMElement(){return this.dom||(this.dom=this.buildDOM()),this.dom}rebuildDOM(){let e=this.buildDOM();return this.dom?.replaceWith(e),this.dom=e,this.dom}trans(e){return this.getContext().translate(e)}updateState(e){}},te=class extends Me{constructor(t){super();this.children=[];this.children.push(...t)}buildDOM(){return b("div",{},this.getChildren().map(t=>t.getDOMElement()))}getChildren(){return this.children}addChildren(...t){this.children.push(...t)}removeChildren(...t){for(let n of t)this.removeChild(n)}removeChild(t){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,1)}updateState(t){for(let n of this.children)n.updateState(t)}setContext(t){super.setContext(t);for(let n of this.getChildren())n.setContext(t)}},Ji=class extends te{constructor(e,t){super(t),this.className=e}buildDOM(){return b("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};var w=class extends Me{constructor(t){super();this.active=!1;this.completedSetup=!1;this.disabled=!1;t.action!==void 0?this.definition=t:this.definition={...t,action(){return!1},isActive:()=>!1}}setContext(t){super.setContext(t),this.definition.setup&&!this.completedSetup&&(this.definition.setup(t,this),this.completedSetup=!0)}buildDOM(){let t=this.getLabel(),n=this.definition.format||"small",r=[];if(this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-icon"});s.innerHTML=this.definition.icon||"",r.push(s)}if(!this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-text"},[t]);r.push(s)}let i=b("button",{type:"button",class:`editor-button editor-button-${n}`,title:this.definition.icon?t:null,disabled:this.disabled?"true":null},r);return i.addEventListener("click",this.onClick.bind(this)),i}onClick(){this.definition.action(this.getContext(),this)}updateActiveState(t){let n=this.definition.isActive(t,this.getContext());this.setActiveState(n)}updateDisabledState(t){if(this.definition.isDisabled){let n=this.definition.isDisabled(t,this.getContext());this.toggleDisabled(n)}}setActiveState(t){this.active=t,this.dom?.classList.toggle("editor-button-active",this.active)}updateState(t){this.updateActiveState(t.selection),this.updateDisabledState(t.selection)}isActive(){return this.active}getLabel(){return this.trans(this.definition.label)}toggleDisabled(t){this.disabled=t,t?this.dom?.setAttribute("disabled","true"):this.dom?.removeAttribute("disabled")}};function Dx(o,e,t){let n=e.getBoundingClientRect(),r=o.getBoundingClientRect();if(o.style.position="fixed",t){let i=n.right;n.right+r.width>window.innerWidth&&(i=Math.max(n.left-r.width,0)),o.style.top=n.top+"px",o.style.left=i+"px"}else{let i=n.left+r.width>window.innerWidth,s=n.left;i&&(s=Math.max(n.right-r.width,0)),o.style.top=n.bottom+"px",o.style.left=s+"px"}}function Qi(o){let{menu:e,toggle:t,onClose:n,onOpen:r,showOnHover:i,showAside:s}=o,l=null,a=()=>{e.hidden=!0,e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),l&&window.removeEventListener("click",l),n&&n()},c=()=>{e.hidden=!1,Dx(e,t,!!s),l=f=>{!t.contains(f.target)&&!e.contains(f.target)&&a()},window.addEventListener("click",l),r&&r()},m=f=>{e.hasAttribute("hidden")?c():a()};t.addEventListener("click",m),i&&t.addEventListener("mouseenter",m),e.parentElement?.addEventListener("mouseleave",f=>{let d=t.getBoundingClientRect(),u=f.clientX<=d.right&&f.clientX>=d.left,p=f.clientY<=d.bottom&&f.clientY>=d.top;u&&p||a()})}var es=class extends te{buildDOM(){let e=this.getChildren().map(i=>i.getDOMElement()),t=b("div",{class:"editor-format-menu-dropdown editor-dropdown-menu editor-dropdown-menu-vertical",hidden:"true"},e),n=b("button",{class:"editor-format-menu-toggle editor-button",type:"button"},[this.trans("Formats")]),r=b("div",{class:"editor-format-menu editor-dropdown-menu-container"},[n,t]);return Qi({toggle:n,menu:t}),r}updateState(e){super.updateState(e);for(let t of this.children){if(t instanceof w&&t.isActive()){this.updateToggleLabel(t.getLabel());return}if(t instanceof te){for(let n of t.getChildren())if(n instanceof w&&n.isActive()){this.updateToggleLabel(n.getLabel());return}}}this.updateToggleLabel(this.trans("Formats"))}updateToggleLabel(e){let t=this.getDOMElement().querySelector("button");t&&(t.innerText=e)}};var Ye=class extends w{constructor(e,t){super(t),this.previewSampleElement=e}buildDOM(){let e=super.buildDOM();e.innerHTML="";let t=b("span",{class:"editor-button-format-preview"},[this.getLabel()]),n=this.getStylesFromPreview();for(let r of Object.keys(n))t.style.setProperty(r,n[r]);return e.append(t),e}getStylesFromPreview(){let e=b("div",{style:"display: none",hidden:"true",class:"page-content"}),t=this.previewSampleElement.cloneNode();t.textContent=this.getLabel(),e.append(t),document.body.append(e);let n=["color","font-size","background-color","border-inline-start"],r={},i=window.getComputedStyle(t);for(let s of n)r[s]=i.getPropertyValue(s);return e.remove(),r}};var Of='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>';var ts=class extends w{buildDOM(){let e=super.buildDOM(),t=b("div",{class:"editor-menu-button-icon"});return t.innerHTML=Of,e.append(t),e}};var Ax={showOnHover:!1,direction:"horizontal",showAside:void 0,button:{label:"Menu"}},Ee=class extends te{constructor(t,n){super(n);this.open=!1;if(this.childItems=n,this.options=Object.assign({},Ax,t),t.button instanceof w)this.button=t.button;else{let r=t.button.format==="long"?ts:w;this.button=new r({...t.button,action(){return!1},isActive:()=>this.open})}this.addChildren(this.button)}insertItems(...t){this.addChildren(...t),this.childItems.push(...t)}buildDOM(){let t=this.button.getDOMElement(),n=this.childItems.map(s=>s.getDOMElement()),r=b("div",{class:`editor-dropdown-menu editor-dropdown-menu-${this.options.direction}`,hidden:"true"},n),i=b("div",{class:"editor-dropdown-menu-container"},[t,r]);return Qi({toggle:t,menu:r,showOnHover:this.options.showOnHover,showAside:typeof this.options.showAside=="boolean"?this.options.showAside:this.options.direction==="vertical",onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),i}};var Af='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"/></svg>';var Rf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 32.5-156t88-127Q256-817 330-848.5T488-880q80 0 151 27.5t124.5 76q53.5 48.5 85 115T880-518q0 115-70 176.5T640-280h-74q-9 0-12.5 5t-3.5 11q0 12 15 34.5t15 51.5q0 50-27.5 74T480-80Zm0-400Zm-220 40q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120-160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm200 0q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120 160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17ZM480-160q9 0 14.5-5t5.5-13q0-14-15-33t-15-57q0-42 29-67t71-25h70q66 0 113-38.5T800-518q0-121-92.5-201.5T488-800q-136 0-232 93t-96 227q0 133 93.5 226.5T480-160Z"/></svg>';function kf(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function os(){return((1+Math.random())*65536|0).toString(16).substring(1)}var If=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],$f="bs-lexical-custom-colors",tn=class extends Me{constructor(e){super(),this.callback=e}buildDOM(){let e=os(),n=[...If,...this.getCustomColorChoices()].map(c=>b("div",{class:"editor-color-select-option",style:`background-color: ${c}`,"data-color":c,"aria-label":c})),r=b("div",{class:"editor-color-select-option","data-color":"",title:this.getContext().translate("Remove color")},[]);r.innerHTML=Af,n.push(r);let i=b("label",{class:"editor-color-select-option",for:`color-select-${e}`,"data-color":"",title:this.getContext().translate("Custom color")},[]);i.innerHTML=Rf,n.push(i);let s=b("input",{type:"color",hidden:"true",id:`color-select-${e}`});n.push(s),s.addEventListener("change",c=>{s.value&&(this.storeCustomColorChoice(s.value),this.setColor(s.value),this.rebuildDOM())});let l=[];for(let c=0;c<n.length;c+=5){let m=n.slice(c,c+5);l.push(b("div",{class:"editor-color-select-row"},m))}let a=b("div",{class:"editor-color-select"},l);return a.addEventListener("click",this.onClick.bind(this)),a}storeCustomColorChoice(e){if(If.includes(e))return;let t=this.getCustomColorChoices();t.includes(e)||(t.push(e),window.localStorage.setItem($f,JSON.stringify(t)))}getCustomColorChoices(){return JSON.parse(window.localStorage.getItem($f)||"[]")}onClick(e){let t=e.target.closest("[data-color]");if(!t)return;let n=t.dataset.color;this.setColor(n)}setColor(e){this.callback(e,this.getContext())}};var ns=class extends Me{buildDOM(){let t=[],n=[];for(let s=1;s<11;s++){let l=[];for(let a=1;a<11;a++){let c=b("div",{class:"editor-table-creator-cell","data-rows":String(s),"data-columns":String(a)});l.push(c),n.push(c)}t.push(b("div",{class:"editor-table-creator-row"},l))}let r=b("div",{class:"editor-table-creator-display"},["0 x 0"]),i=b("div",{class:"editor-table-creator-grid"},t);return i.addEventListener("mousemove",s=>{let l=s.target.closest(".editor-table-creator-cell");if(l){let a=Number(l.dataset.rows||0),c=Number(l.dataset.columns||0);this.updateGridSelection(a,c,n,r)}}),i.addEventListener("click",s=>{let l=s.target.closest(".editor-table-creator-cell");l&&this.onCellClick(l)}),i.addEventListener("mouseleave",s=>{this.updateGridSelection(0,0,n,r)}),b("div",{class:"editor-table-creator"},[i,r])}updateGridSelection(e,t,n,r){for(let i of n){let s=Number(i.dataset.rows)<=e&&Number(i.dataset.columns)<=t;i.classList.toggle("active",s)}r.textContent=`${e} x ${t}`}onCellClick(e){let t=Number(e.dataset.rows||0),n=Number(e.dataset.columns||0);if(t<1||n<1)return;let r=Math.min(Math.round(840/n),240),i=Array(n).fill(r+"px");this.getContext().editor.update(()=>{let s=ea(t,n,!1);s.setColWidths(i),Yo(s)})}};var Kr=class extends w{constructor(e,t){super(e),this.style=t}getColorBar(){let e=this.getDOMElement().querySelector("svg .editor-icon-color-bar");if(!e)throw new Error(`Could not find expected color bar in the icon for this ${this.definition.label} button`);return e}updateState(e){if(super.updateState(e),_(e.selection)){let t=Bl(e.selection,this.style);this.getColorBar().setAttribute("fill",t)}}};var Pf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"/></svg>';var nt=class extends te{constructor(e,t){super(t),this.size=e,this.content=t,this.overflowButton=new Ee({button:{label:"More",icon:Pf}},[]),this.addChildren(this.overflowButton)}buildDOM(){let e=this.content.length>this.size?this.size-1:this.size,t=this.content.slice(0,e),n=this.content.slice(e),r=t.map(i=>i.getDOMElement());return n.length>0&&(this.removeChildren(...n),this.overflowButton.insertItems(...n),r.push(this.overflowButton.getDOMElement())),b("div",{class:"editor-overflow-container"},r)}};var xa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z"/></svg>';var rs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>';var Bf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>';var Ff='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>';var Hf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>';var Kf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>';var Uf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>';var zf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>';var It=class extends Me{constructor(e){super(),this.definition=e}setValue(e){let t=this.getDOMElement().querySelector("input,select,textarea");this.definition.type==="checkbox"?t.checked=!!e:t.value=e,t.dispatchEvent(new Event("change"))}getName(){return this.definition.name}buildDOM(){let e=`editor-form-field-${this.definition.name}-${Date.now()}`,t;if(this.definition.type==="select"){let n=this.definition.valuesByLabel,i=Object.keys(n).map(s=>b("option",{value:n[s]},[this.trans(s)]));t=b("select",{id:e,name:this.definition.name,class:"editor-form-field-input"},i)}else this.definition.type==="textarea"?t=b("textarea",{id:e,name:this.definition.name,class:"editor-form-field-input"}):this.definition.type==="checkbox"?t=b("input",{id:e,name:this.definition.name,type:"checkbox",class:"editor-form-field-input-checkbox",value:"true"}):t=b("input",{id:e,name:this.definition.name,class:"editor-form-field-input"});return b("div",{class:"editor-form-field-wrapper"},[b("label",{class:"editor-form-field-label",for:e},[this.trans(this.definition.label)]),t])}},is=class extends te{constructor(t){let n=t.fields.map(r=>Na(r)?r.build():new It(r));super(n);this.onCancel=null;this.onSuccessfulSubmit=null;this.definition=t}setValues(t){for(let n of Object.keys(t)){let r=this.getFieldByName(n);r&&r.setValue(t[n])}}setOnCancel(t){this.onCancel=t}setOnSuccessfulSubmit(t){this.onSuccessfulSubmit=t}getFieldByName(t){let n=r=>{for(let i of r){if(i instanceof It&&i.getName()===t)return i;if(i instanceof te){let s=n(i.getChildren());if(s)return s}}return null};return n(this.getChildren())}buildDOM(){let t=b("button",{type:"button",class:"editor-form-action-secondary"},[this.trans("Cancel")]),n=b("form",{},[...this.children.map(r=>r.getDOMElement()),b("div",{class:"editor-form-actions"},[t,b("button",{type:"submit",class:"editor-form-action-primary"},[this.trans(this.definition.submitText)])])]);return n.addEventListener("submit",async r=>{r.preventDefault();let i=new FormData(n);await this.definition.action(i,this.getContext())&&this.onSuccessfulSubmit&&this.onSuccessfulSubmit()}),t.addEventListener("click",r=>{this.onCancel&&this.onCancel()}),n}},Ea=class extends te{constructor(e){let t=e.contents.map(n=>Na(n)?n.build():new It(n));super(t),this.definition=e,this.fields=t,this.id=kf()}getLabel(){return this.getContext().translate(this.definition.label)}getId(){return this.id}buildDOM(){return b("div",{class:"editor-form-tab-content",role:"tabpanel",id:`editor-tabpanel-${this.id}`,"aria-labelledby":`editor-tab-${this.id}`},this.fields.map(e=>e.getDOMElement()))}},on=class extends te{constructor(t){let n=t.map(r=>new Ea(r));super(n);this.definitions=[];this.tabs=[];this.definitions=t,this.tabs=n}buildDOM(){let t=[],n=[],r=i=>{for(let s=0;s<t.length;s++)t[s].setAttribute("aria-selected",s===i?"true":"false");for(let s=0;s<n.length;s++)n[s].hidden=s!==i};for(let i of this.tabs){let s=b("button",{class:"editor-form-tab-control",type:"button",role:"tab",id:`editor-tab-${i.getId()}`,"aria-controls":`editor-tabpanel-${i.getId()}`},[i.getLabel()]);n.push(i.getDOMElement()),t.push(s),s.addEventListener("click",l=>{r(t.indexOf(s))})}return r(0),b("div",{class:"editor-form-tab-container"},[b("div",{class:"editor-form-tab-controls"},t),b("div",{class:"editor-form-tab-contents"},n)])}};var Wf=`<svg version="1.1" viewBox="0 -960 960 960" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+`?n.push(ut()):s===" "?n.push(Lt()):n.push(q(s))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,s=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(s=n,l=t),s.type==="element"&&mN(s,l,r,i);let a=s.offset,d=l.offset,m=this.getNodes(),f=m.length,c=m[0];y(c)||x(!1,"insertText: first node is not a text node");let p=c.getTextContent().length,g=c.getParentOrThrow(),h=f-1,C=m[h];if(f===1&&l.type==="element"&&(d=p,l.set(s.key,d,"text")),this.isCollapsed()&&a===p&&(c.isSegmented()||c.isToken()||!c.canInsertTextAfter()||!g.canInsertTextAfter()&&c.getNextSibling()===null)){let N=c.getNextSibling();if((!y(N)||!N.canInsertTextBefore()||Ue(N))&&(N=q(),N.setFormat(r),N.setStyle(i),g.canInsertTextAfter()?c.insertAfter(N):g.insertAfter(N)),N.select(0,0),c=N,e!==""){this.insertText(e);return}}else if(this.isCollapsed()&&a===0&&(c.isSegmented()||c.isToken()||!c.canInsertTextBefore()||!g.canInsertTextBefore()&&c.getPreviousSibling()===null)){let N=c.getPreviousSibling();if((!y(N)||Ue(N))&&(N=q(),N.setFormat(r),g.canInsertTextBefore()?c.insertBefore(N):g.insertBefore(N)),N.select(),c=N,e!==""){this.insertText(e);return}}else if(c.isSegmented()&&a!==p){let N=q(c.getTextContent());N.setFormat(r),c.replace(N),c=N}else if(!this.isCollapsed()&&e!==""){let N=C.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||E(N)&&(!N.canInsertTextBefore()||!N.canInsertTextAfter())){this.insertText(""),Yc(this.anchor,this.focus,null),this.insertText(e);return}}if(f===1){if(c.isToken()){let S=q(e);S.select(),c.replace(S);return}let N=c.getFormat(),L=c.getStyle();if(a===d&&(N!==r||L!==i))if(c.getTextContent()==="")c.setFormat(r),c.setStyle(i);else{let S=q(e);if(S.setFormat(r),S.setStyle(i),S.select(),a===0)c.insertBefore(S,!1);else{let[A]=c.splitText(a);A.insertAfter(S,!1)}S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);return}else if(yl(c)){let S=q(e);S.setFormat(r),S.setStyle(i),S.select(),c.replace(S);return}let M=d-a;c=c.spliceText(a,M,e,!0),c.getTextContent()===""?c.remove():this.anchor.type==="text"&&(c.isComposing()?this.anchor.offset-=e.length:(this.format=N,this.style=L))}else{let N=new Set([...c.getParentKeys(),...C.getParentKeys()]),L=E(c)?c:c.getParentOrThrow(),M=E(C)?C:C.getParentOrThrow(),S=C;if(!L.is(M)&&M.isInline())do S=M,M=M.getParentOrThrow();while(M.isInline());if(l.type==="text"&&(d!==0||C.getTextContent()==="")||l.type==="element"&&C.getIndexWithinParent()<d)if(y(C)&&!C.isToken()&&d!==C.getTextContentSize()){if(C.isSegmented()){let k=q(C.getTextContent());C.replace(k),C=k}!oe(l.getNode())&&l.type==="text"&&(C=C.spliceText(0,d,"")),N.add(C.__key)}else{let k=C.getParentOrThrow();!k.canBeEmpty()&&k.getChildrenSize()===1?k.remove():C.remove()}else N.add(C.__key);let A=M.getChildren(),O=new Set(m),R=L.is(M),P=L.isInline()&&c.getNextSibling()===null?L:c;for(let k=A.length-1;k>=0;k--){let W=A[k];if(W.is(c)||E(W)&&W.isParentOf(c))break;W.isAttached()&&(!O.has(W)||W.is(S)?R||P.insertAfter(W,!1):W.remove())}if(!R){let k=M,W=null;for(;k!==null;){let ie=k.getChildren(),an=ie.length;(an===0||ie[an-1].is(W))&&(N.delete(k.__key),W=k),k=k.getParent()}}if(!c.isToken())c=c.spliceText(a,p-a,e,!0),c.getTextContent()===""?c.remove():c.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);else if(a===p)c.select();else{let k=q(e);k.select(),c.replace(k)}for(let k=1;k<f;k++){let W=m[k],ie=W.__key;N.has(ie)||W.remove()}}}removeText(){this.insertText("")}formatText(e){if(this.isCollapsed()){this.toggleFormat(e),se(null);return}let t=this.getNodes(),n=[];for(let N of t)y(N)&&n.push(N);let r=n.length;if(r===0){this.toggleFormat(e),se(null);return}let i=this.anchor,s=this.focus,l=this.isBackward(),a=l?s:i,d=l?i:s,m=0,f=n[0],c=a.type==="element"?0:a.offset;if(a.type==="text"&&c===f.getTextContentSize()&&(m=1,f=n[1],c=0),f==null)return;let u=f.getFormatFlags(e,null),p=r-1,g=n[p],h=d.type==="text"?d.offset:g.getTextContentSize();if(f.is(g)){if(c===h)return;if(Ue(f)||c===0&&h===f.getTextContentSize())f.setFormat(u);else{let N=f.splitText(c,h),L=c===0?N[0]:N[1];L.setFormat(u),a.type==="text"&&a.set(L.__key,0,"text"),d.type==="text"&&d.set(L.__key,h-c,"text")}this.format=u;return}c!==0&&!Ue(f)&&([,f]=f.splitText(c),c=0),f.setFormat(u);let C=g.getFormatFlags(e,u);h>0&&(h!==g.getTextContentSize()&&!Ue(g)&&([g]=g.splitText(h)),g.setFormat(C));for(let N=m+1;N<p;N++){let L=n[N],M=L.getFormatFlags(e,C);L.setFormat(M)}a.type==="text"&&a.set(f.__key,c,"text"),d.type==="text"&&d.set(g.__key,h,"text"),this.format=u|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();let h=T();return x(_(h),"Expected RangeSelection after insertParagraph"),h.insertNodes(e)}let t=this.isBackward()?this.focus:this.anchor,n=mi(t.getNode(),$o),r=e[e.length-1];if("__language"in n&&E(n)){if("__language"in e[0])this.insertText(e[0].getTextContent());else{let h=Ll(this);n.splice(h,0,e),r.selectEnd()}return}let i=h=>(E(h)||B(h))&&!h.isInline();if(!e.some(i)){x(E(n),"Expected 'firstBlock' to be an ElementNode");let h=Ll(this);n.splice(h,0,e),r.selectEnd();return}let s=EN(e),l=s.getLastDescendant(),a=s.getChildren(),d=h=>E(h)&&$o(h)&&!h.isEmpty()&&E(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),f=!E(n)||!n.isEmpty()?this.insertParagraph():null,c=a[a.length-1],u=a[0];d(u)&&(x(E(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...u.getChildren()),u=a[1]),u&&Ic(n,u);let p=mi(l,$o);f&&E(p)&&(f.canMergeWhenEmpty()||$o(c))&&(p.append(...f.getChildren()),f.remove()),E(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let g=E(n)?n.getLastChild():null;ve(g)&&p!==n&&g.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=I();return F().splice(this.anchor.offset,0,[s]),s.select(),s}let e=Ll(this),t=mi(this.anchor.getNode(),$o);x(E(t),"Expected ancestor to be an ElementNode");let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=ut();if(this.insertNodes([t]),e){let n=t.getParentOrThrow(),r=t.getIndexWithinParent();n.select(r,r)}}extract(){let e=this.getNodes(),t=e.length,n=t-1,r=this.anchor,i=this.focus,s=e[0],l=e[n],[a,d]=Mr(this);if(t===0)return[];if(t===1){if(y(s)&&!this.isCollapsed()){let f=a>d?d:a,c=a>d?a:d,u=s.splitText(f,c),p=f===0?u[0]:u[1];return p!=null?[p]:[]}return[s]}let m=r.isBefore(i);if(y(s)){let f=m?a:d;f===s.getTextContentSize()?e.shift():f!==0&&([,s]=s.splitText(f),e[0]=s)}if(y(l)){let c=l.getTextContent().length,u=m?d:a;u===0?e.pop():u!==c&&([l]=l.splitText(u),e[n]=l)}return e}modify(e,t,n){let r=this.focus,i=this.anchor,s=e==="move",l=Zt(r,t);if(B(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let u=Ho();u.add(l.__key),Y(u);return}let c=t?l.getPreviousSibling():l.getNextSibling();if(y(c)){let u=c.__key,p=t?c.getTextContent().length:0;r.set(u,p,"text"),s&&i.set(u,p,"text");return}else{let u=l.getParentOrThrow(),p,g;E(c)?(g=c.__key,p=t?c.getChildrenSize():0):(p=l.getIndexWithinParent(),g=u.__key,t||p++),r.set(g,p,"element"),s&&i.set(g,p,"element");return}}let a=j(),d=be(a._window);if(!d)return;let m=a._blockCursorElement,f=a._rootElement;if(f!==null&&m!==null&&E(l)&&!l.isInline()&&!l.canBeEmpty()&&Er(m,a,f),gN(d,e,t?"backward":"forward",n),d.rangeCount>0){let c=d.getRangeAt(0),u=this.anchor.getNode(),p=oe(u)?u:ol(u);if(this.applyDOMRange(c),this.dirty=!0,!s){let g=this.getNodes(),h=[],C=!1;for(let N=0;N<g.length;N++){let L=g[N];En(L,p)?h.push(L):C=!0}if(C&&h.length>0)if(t){let N=h[0];E(N)?N.selectStart():N.getParentOrThrow().selectStart()}else{let N=h[h.length-1];E(N)?N.selectEnd():N.getParentOrThrow().selectEnd()}(d.anchorNode!==c.startContainer||d.anchorOffset!==c.startOffset)&&pN(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&E(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){let r=t.getParent(),i=t.getNextSibling()||(r===null?null:r.getNextSibling());if(E(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,e))return;let i=this.focus,s=Zt(i,e);if(B(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&E(r)&&r.getChildrenSize()===0){r.remove();let l=Ho();l.add(s.__key),Y(l)}else s.remove(),j().dispatchCommand(we,void 0);return}else if(!e&&E(s)&&E(r)&&r.isEmpty()){r.remove(),s.selectStart();return}if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{let l=i.type==="text"?i.getNode():null;if(r=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){let a=i.offset,d=l.getTextContentSize();if(l.is(r)||e&&a!==d||!e&&a!==0){Uc(l,e,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,d=r.getTextContentSize();if(r.is(l)||e&&a!==0||!e&&a!==d){Uc(r,e,a);return}}hN(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&oe(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){let t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),(e?this.focus:this.anchor).offset===0&&this.modify("extend",e,"character"),t){let r=e?this.anchor:this.focus;r.set(r.key,r.offset+1,r.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Se(o){return o instanceof bi}function Kc(o){let e=o.offset;if(o.type==="text")return e;let t=o.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function Mr(o){let e=o.getStartEndPoints();if(e===null)return[0,0];let[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Kc(t),Kc(n)]}function pN(o){let e=o.focus,t=o.anchor,n=t.key,r=t.offset,i=t.type;Eo(t,e.key,e.offset,e.type),Eo(e,n,r,i),o._cachedNodes=null}function gN(o,e,t,n){o.modify(e,t,n)}function hN(o,e){let t=o.anchor,n=o.focus,r=t.getNode(),i=n.getNode();if(r===i&&t.type==="text"&&n.type==="text"){let s=t.offset,l=n.offset,a=s<l,d=a?s:l,m=a?l:s,f=m-1;if(d!==f){let c=r.getTextContent().slice(d,m);li(c)||(e?n.offset=f:t.offset=f)}}}function Uc(o,e,t){let n=o,i=n.getTextContent().split(/(?=\s)/g),s=i.length,l=0,a=0;for(let m=0;m<s;m++){let f=i[m],c=m===s-1;if(a=l,l+=f.length,e&&l===t||l>t||c){i.splice(m,1),c&&(a=void 0);break}}let d=i.join("").trim();d===""?n.remove():(n.setTextContent(d),n.select(a,a))}function NN(o,e,t){let n=o.getParent();return t===null||n===null||!n.canBeEmpty()||n!==t.getNode()}function zc(o,e,t,n){let r=e,i;if(o.nodeType===mo){let s=!1,l=o.childNodes,a=l.length,d=n._blockCursorElement;r===a&&(s=!0,r=a-1);let m=l[r],f=!1;if(m===d)m=l[r+1],f=!0;else if(d!==null){let c=d.parentNode;if(o===c){let u=Array.prototype.indexOf.call(c.children,d);e>u&&r--}}if(i=ko(m),y(i))r=js(i,s);else{let c=ko(o);if(c===null)return null;if(E(c)){r=Math.min(c.getChildrenSize(),r);let u=c.getChildAtIndex(r);if(E(u)&&NN(u,r,t)){let p=s?u.getLastDescendant():u.getFirstDescendant();p===null?c=u:(u=p,c=E(u)?u:u.getParentOrThrow()),r=0}y(u)?(i=u,c=null,r=js(u,s)):u!==c&&s&&!f&&r++}else{let u=c.getIndexWithinParent();e===0&&B(c)&&ko(o)===c?r=u:r=u+1,c=c.getParentOrThrow()}if(E(c))return De(c.__key,r,"element")}}else i=ko(o);return y(i)?De(i.__key,r,"text"):null}function Wc(o,e,t){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!e)E(i)&&!t&&i.isInline()?(o.key=i.__key,o.offset=i.getChildrenSize(),o.type="element"):y(i)&&(o.key=i.__key,o.offset=i.getTextContent().length);else if((t||!e)&&i===null&&E(s)&&s.isInline()){let l=s.getPreviousSibling();y(l)&&(o.key=l.__key,o.offset=l.getTextContent().length)}}else if(n===r.getTextContent().length){let i=r.getNextSibling(),s=r.getParent();if(e&&E(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((t||e)&&i===null&&E(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();y(l)&&(o.key=l.__key,o.offset=0)}}}function Yc(o,e,t){if(o.type==="text"&&e.type==="text"){let n=o.isBefore(e),r=o.is(e);Wc(o,n,r),Wc(e,!n,r),r&&(e.key=o.key,e.offset=o.offset,e.type=o.type);let i=j();if(i.isComposing()&&i._compositionKey!==o.key&&_(t)){let s=t.anchor,l=t.focus;Eo(o,s.key,s.offset,s.type),Eo(e,l.key,l.offset,l.type)}}}function Zc(o,e,t,n,r,i){if(o===null||t===null||!qt(r,o,t))return null;let s=zc(o,e,_(i)?i.anchor:null,r);if(s===null)return null;let l=zc(t,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=ko(o),d=ko(t);if(B(a)&&B(d))return null}return Yc(s,l,i),[s,l]}function Ko(o){return E(o)&&!o.isInline()}function _i(o,e,t,n,r,i){let s=Ge(),l=new To(De(o,e,r),De(t,n,i),0,"");return l.dirty=!0,s._selection=l,l}function Uo(){let o=De("root",0,"element"),e=De("root",0,"element");return new To(o,e,0,"")}function Ho(){return new bi(new Set)}function Vc(o){let t=o.getEditorState()._selection,n=be(o._window);return _(t)||t==null?Lr(t,n,o,null):t.clone()}function wl(o,e){return Lr(null,o,e,null)}function Lr(o,e,t,n){let r=t._window;if(r===null)return null;let i=n||r.event,s=i?i.type:void 0,l=s==="selectionchange",a=!hd()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),d,m,f,c;if(!_(o)||a){if(e===null)return null;if(d=e.anchorNode,m=e.focusNode,f=e.anchorOffset,c=e.focusOffset,l&&_(o)&&!qt(t,d,m))return o.clone()}else return o.clone();let u=Zc(d,f,m,c,t,o);if(u===null)return null;let[p,g]=u;return new To(p,g,_(o)?o.format:0,_(o)?o.style:"")}function T(){return Ge()._selection}function ze(){return j()._editorState._selection}function Mn(o,e,t,n=1){let r=o.anchor,i=o.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;let a=e.__key;if(o.isCollapsed()){let d=r.offset;if(t<=d&&n>0||t<d&&n<0){let m=Math.max(0,d+n);r.set(a,m,"element"),i.set(a,m,"element"),qc(o)}}else{let d=o.isBackward(),m=d?i:r,f=m.getNode(),c=d?r:i,u=c.getNode();if(e.is(f)){let p=m.offset;(t<=p&&n>0||t<p&&n<0)&&m.set(a,Math.max(0,p+n),"element")}if(e.is(u)){let p=c.offset;(t<=p&&n>0||t<p&&n<0)&&c.set(a,Math.max(0,p+n),"element")}}qc(o)}function qc(o){let e=o.anchor,t=e.offset,n=o.focus,r=n.offset,i=e.getNode(),s=n.getNode();if(o.isCollapsed()){if(!E(i))return;let l=i.getChildrenSize(),a=t>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(d)){let m=0;a&&(m=d.getTextContentSize()),e.set(d.__key,m,"text"),n.set(d.__key,m,"text")}return}if(E(i)){let l=i.getChildrenSize(),a=t>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(d)){let m=0;a&&(m=d.getTextContentSize()),e.set(d.__key,m,"text")}}if(E(s)){let l=s.getChildrenSize(),a=r>=l,d=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(y(d)){let m=0;a&&(m=d.getTextContentSize()),n.set(d.__key,m,"text")}}}function Xc(o,e){let n=e.getEditorState()._selection,r=o._selection;if(_(r)){let i=r.anchor,s=r.focus,l;if(i.type==="text"&&(l=i.getNode(),l.selectionTransform(n,r)),s.type==="text"){let a=s.getNode();l!==a&&a.selectionTransform(n,r)}}}function wn(o,e,t,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,y(n)?(s=n.getTextContentSize(),l="text"):E(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,y(r)?l="text":E(r)&&(l="element")),i!==null&&l!==null?o.set(i,s,l):(s=e.getIndexWithinParent(),s===-1&&(s=t.getChildrenSize()),o.set(t.__key,s,"element"))}function _l(o,e,t,n,r){o.type==="text"?(o.key=t,e||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function Gc(o,e,t,n,r,i,s){let l=n.anchorNode,a=n.focusNode,d=n.anchorOffset,m=n.focusOffset,f=document.activeElement;if(r.has("collaboration")&&f!==i||f!==null&&Tn(f))return;if(!_(e)){o!==null&&qt(t,l,a)&&n.removeAllRanges();return}let c=e.anchor,u=e.focus,p=c.key,g=u.key,h=bn(t,p),C=bn(t,g),N=c.offset,L=u.offset,M=e.format,S=e.style,A=e.isCollapsed(),O=h,R=C,P=!1;if(c.type==="text"){O=_n(h);let k=c.getNode();P=k.getFormat()!==M||k.getStyle()!==S}else _(o)&&o.anchor.type==="text"&&(P=!0);if(u.type==="text"&&(R=_n(C)),!(O===null||R===null)&&(A&&(o===null||P||_(o)&&(o.format!==M||o.style!==S))&&kc(M,S,N,p,performance.now()),!(d===N&&m===L&&l===O&&a===R&&!(n.type==="Range"&&A)&&((f===null||!i.contains(f))&&i.focus({preventScroll:!0}),c.type!=="element")))){try{n.setBaseAndExtent(O,N,R,L)}catch(k){__DEV__&&console.warn(k)}if(!r.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){let k=e instanceof To&&e.anchor.type==="element"?O.childNodes[N]||null:n.rangeCount>0?n.getRangeAt(0):null;if(k!==null){let W;if(k instanceof Text){let ie=document.createRange();ie.selectNode(k),W=ie.getBoundingClientRect()}else W=k.getBoundingClientRect();sc(t,W,i)}}Rc()}}function Oe(o){let e=T()||ze();e===null&&(e=F().selectEnd()),e.insertNodes(o)}function Ll(o){let e=o;o.isCollapsed()||e.removeText();let t=T();_(t)&&(e=t),x(_(e),"Unexpected dirty selection to be null");let n=e.anchor,r=n.getNode(),i=n.offset;for(;!$o(r);)[r,i]=xN(r,i);return i}function xN(o,e){let t=o.getParent();if(!t){let r=I();return F().append(r),r.select(),[F(),0]}if(y(o)){let r=o.splitText(e);if(r.length===0)return[t,o.getIndexWithinParent()];let i=e===0?0:1,s=r[0].getIndexWithinParent()+i;return[t,s]}if(!E(o)||e===0)return[t,o.getIndexWithinParent()];let n=o.getChildAtIndex(e);if(n){let r=new To(De(o.__key,e,"element"),De(o.__key,e,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[t,o.getIndexWithinParent()+1]}function EN(o){let e=I(),t=null;for(let n=0;n<o.length;n++){let r=o[n],i=ve(r);if(i||B(r)&&r.isInline()||E(r)&&r.isInline()||y(r)||r.isParentRequired()){if(t===null&&(t=r.createParentElementNode(),e.append(t),i))continue;t!==null&&t.append(r)}else e.append(r),t=null}return e}var ue=null,ge=null,Ae=!1,vl=!1,yi=0,jc={characterData:!0,childList:!0,subtree:!0};function st(){return Ae||ue!==null&&ue._readOnly}function de(){Ae&&x(!1,"Cannot use method in read-only mode.")}function rl(){yi>99&&x(!1,"One or more transforms are endlessly triggering additional transforms. May have encountered infinite recursion caused by transforms that have their preconditions too lose and/or conflict with each other.")}function Ge(){return ue===null&&x(!1,"Unable to find an active editor state. State helpers or node methods can only be used synchronously during the callback of editor.update(), editor.read(), or editorState.read().%s",tu()),ue}function j(){return ge===null&&x(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",tu()),ge}function tu(){let o=0,e=new Set,t=ho.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Ro(r);if(Cn(i))o++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===t&&(s+=" (separately built, likely a bundler configuration issue)"),e.add(s)}}let n=` Detected on the page: ${o} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function ou(){return ge}function uc(){return ue}function Jc(o,e,t){let n=e.__type,r=bd(o,n),i=t.get(n);i===void 0&&(i=Array.from(r.transforms),t.set(n,i));let s=i.length;for(let l=0;l<s&&(i[l](e),!!e.isAttached());l++);}function Qc(o,e){return o!==void 0&&o.__key!==e&&o.isAttached()}function TN(o,e){let t=e._dirtyLeaves,n=o._nodeMap;for(let r of t){let i=n.get(r);y(i)&&i.isAttached()&&i.isSimpleText()&&!i.isUnmergeable()&&Vs(i)}}function CN(o,e){let t=e._dirtyLeaves,n=e._dirtyElements,r=o._nodeMap,i=Xe(),s=new Map,l=t,a=l.size,d=n,m=d.size;for(;a>0||m>0;){if(a>0){e._dirtyLeaves=new Set;for(let f of l){let c=r.get(f);y(c)&&c.isAttached()&&c.isSimpleText()&&!c.isUnmergeable()&&Vs(c),c!==void 0&&Qc(c,i)&&Jc(e,c,s),t.add(f)}if(l=e._dirtyLeaves,a=l.size,a>0){yi++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map;for(let f of d){let c=f[0],u=f[1];if(c!=="root"&&!u)continue;let p=r.get(c);p!==void 0&&Qc(p,i)&&Jc(e,p,s),n.set(c,u)}l=e._dirtyLeaves,a=l.size,d=e._dirtyElements,m=d.size,yi++}e._dirtyLeaves=t,e._dirtyElements=n}function Dl(o){return Ol(o,j()._nodes)}function Ol(o,e){let t=o.type,n=e.get(t);n===void 0&&x(!1,'parseEditorState: type "%s" + not found',t);let r=n.klass;o.type!==r.getType()&&x(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(E(i)&&Array.isArray(s))for(let l=0;l<s.length;l++){let a=s[l],d=Ol(a,e);i.append(d)}return i}function nu(o,e,t){let n=wr(),r=ue,i=Ae,s=ge,l=e._dirtyElements,a=e._dirtyLeaves,d=e._cloneNotNeeded,m=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ue=n,Ae=!1,ge=e;try{let f=e._nodes,c=o.root;Ol(c,f),t&&t(),n._readOnly=!0,__DEV__&&ru(n)}catch(f){f instanceof Error&&e._onError(f)}finally{e._dirtyElements=l,e._dirtyLeaves=a,e._cloneNotNeeded=d,e._dirtyType=m,ue=r,Ae=i,ge=s}return n}function Al(o,e,t){let n=ue,r=Ae,i=ge;ue=e,Ae=!0,ge=o;try{return t()}finally{ue=n,Ae=r,ge=i}}function ru(o){let e=o._nodeMap;e.set=()=>{throw new Error("Cannot call set() on a frozen Lexical node map")},e.clear=()=>{throw new Error("Cannot call clear() on a frozen Lexical node map")},e.delete=()=>{throw new Error("Cannot call delete() on a frozen Lexical node map")}}function Mt(o,e){let t=o._pendingEditorState,n=o._rootElement,r=o._headless||n===null;if(t===null)return;let i=o._editorState,s=i._selection,l=t._selection,a=o._dirtyType!==bt,d=ue,m=Ae,f=ge,c=o._updating,u=o._observer,p=null;if(o._pendingEditorState=null,o._editorState=t,!r&&a&&u!==null){ge=o,ue=t,Ae=!1,o._updating=!0;try{let O=o._dirtyType,R=o._dirtyElements,P=o._dirtyLeaves;u.disconnect(),p=Ec(i,t,o,O,R,P)}catch(O){if(O instanceof Error&&o._onError(O),!vl)Rl(o,null,n,t),ni(o),o._dirtyType=Wt,vl=!0,Mt(o,i),vl=!1;else throw O;return}finally{u.observe(n,jc),o._updating=c,ue=d,Ae=m,ge=f}}t._readOnly||(t._readOnly=!0,__DEV__&&(ru(t),_(l)&&(Object.freeze(l.anchor),Object.freeze(l.focus)),Object.freeze(l)));let g=o._dirtyLeaves,h=o._dirtyElements,C=o._normalizedNodes,N=o._updateTags,L=o._deferred,M=t._nodeMap.size;a&&(o._dirtyType=bt,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),fc(o,t);let S=r?null:be(o._window);if(o._editable&&S!==null&&(a||l===null||l.dirty)){ge=o,ue=t;try{if(u!==null&&u.disconnect(),a||l===null||l.dirty){let O=o._blockCursorElement;O!==null&&Er(O,o,n),Gc(s,l,o,S,N,n,M)}dc(o,n,l),u!==null&&u.observe(n,jc)}finally{ge=f,ue=d}}p!==null&&bN(o,p,N,g,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(we,void 0);let A=o._pendingDecorators;A!==null&&(o._decorators=A,o._pendingDecorators=null,vn("decorator",o,!0,A)),_N(o,e||i,t),vn("update",o,!0,{dirtyElements:h,dirtyLeaves:g,editorState:t,normalizedNodes:C,prevEditorState:e||i,tags:N}),SN(o,L),yN(o)}function _N(o,e,t){let n=Gs(e),r=Gs(t);n!==r&&vn("textcontent",o,!0,r)}function bN(o,e,t,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l<s;l++){let[a,d]=i[l],m=e.get(d);m!==void 0&&a(m,{dirtyLeaves:n,prevEditorState:r,updateTags:t})}}function vn(o,e,t,...n){let r=e._updating;e._updating=t;try{let i=Array.from(e._listeners[o]);for(let s=0;s<i.length;s++)i[s].apply(null,n)}finally{e._updating=r}}function il(o,e,t){if(o._updating===!1||ge!==o){let r=!1;return o.update(()=>{r=il(o,e,t)}),r}let n=hr(o);for(let r=4;r>=0;r--)for(let i=0;i<n.length;i++){let a=n[i]._commands.get(e);if(a!==void 0){let d=a[r];if(d!==void 0){let m=Array.from(d),f=m.length;for(let c=0;c<f;c++)if(m[c](t,o)===!0)return!0}}}return!1}function yN(o){let e=o._updates;if(e.length!==0){let t=e.shift();if(t){let[n,r]=t;iu(o,n,r)}}}function SN(o,e){if(o._deferred=[],e.length!==0){let t=o._updating;o._updating=!0;try{for(let n=0;n<e.length;n++)e[n]()}finally{o._updating=t}}}function eu(o,e){let t=o._updates,n=e||!1;for(;t.length!==0;){let r=t.shift();if(r){let[i,s]=r,l,a;if(s!==void 0){if(l=s.onUpdate,a=s.tag,s.skipTransforms&&(n=!0),s.discrete){let d=o._pendingEditorState;x(d!==null,"Unexpected empty pending editor state on discrete nested update"),d._flushSync=!0}l&&o._deferred.push(l),a&&o._updateTags.add(a)}i()}}return n}function iu(o,e,t){let n=o._updateTags,r,i,s=!1,l=!1;t!==void 0&&(r=t.onUpdate,i=t.tag,i!=null&&n.add(i),s=t.skipTransforms||!1,l=t.discrete||!1),r&&o._deferred.push(r);let a=o._editorState,d=o._pendingEditorState,m=!1;(d===null||d._readOnly)&&(d=o._pendingEditorState=lu(d||a),m=!0),d._flushSync=l;let f=ue,c=Ae,u=ge,p=o._updating;ue=d,Ae=!1,o._updating=!0,ge=o;try{m&&(o._headless?a._selection!==null&&(d._selection=a._selection.clone()):d._selection=Vc(o));let h=o._compositionKey;e(),s=eu(o,s),Xc(d,o),o._dirtyType!==bt&&(s?TN(d,o):CN(d,o),eu(o),pc(a,d,o._dirtyLeaves,o._dirtyElements));let C=o._compositionKey;h!==C&&(d._flushSync=!0);let N=d._selection;if(_(N)){let L=d._nodeMap,M=N.anchor.key,S=N.focus.key;(L.get(M)===void 0||L.get(S)===void 0)&&x(!1,"updateEditor: selection has been lost because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.")}else Se(N)&&N._nodes.size===0&&(d._selection=null)}catch(h){h instanceof Error&&o._onError(h),o._pendingEditorState=a,o._dirtyType=Wt,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),Mt(o);return}finally{ue=f,Ae=c,ge=u,o._updating=p,yi=0}o._dirtyType!==bt||su(d,o)?d._flushSync?(d._flushSync=!1,Mt(o)):m&&yd(()=>{Mt(o)}):(d._flushSync=!1,m&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function xe(o,e,t){o._updating?o._updates.push([e,t]):iu(o,e,t)}var Z=class extends St{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__style="",this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__style=e.__style,this.__dir=e.__dir}getStyle(){return this.getLatest().__style}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let t=j()._dirtyElements;return t!==null&&t.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(y(t)&&e.push(t),E(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;E(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;E(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let i=t[n-1];return E(i)&&i.getLastDescendant()||i||null}let r=t[e];return E(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let t=this.getLatest().__first;return t===null?null:J(t)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&x(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let t=this.getLatest().__last;return t===null?null:J(t)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&x(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e="",t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),E(i)&&r!==n-1&&!i.isInline()&&(e+=Ze)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),E(i)&&r!==n-1&&!i.isInline()&&(e+=Ze.length)}return e}getDirection(){return this.getLatest().__dir}select(e,t){de();let n=T(),r=e,i=t,s=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let a=this.getFirstChild();if(y(a)||E(a))return a.select(0,0)}else if((e===void 0||e===s)&&(t===void 0||t===s)){let a=this.getLastChild();if(y(a)||E(a))return a.select()}}r===void 0&&(r=s),i===void 0&&(i=s);let l=this.__key;if(_(n))n.anchor.set(l,r,"element"),n.focus.set(l,i,"element"),n.dirty=!0;else return _i(l,r,l,i,"element","element");return n}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(n=>n.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setStyle(e){let t=this.getWritable();return t.__style=e||"",this}splice(e,t,n){let r=n.length,i=this.getChildrenSize(),s=this.getWritable(),l=s.__key,a=[],d=[],m=this.getChildAtIndex(e+t),f=null,c=i-t+r;if(e!==0)if(e===i)f=this.getLastChild();else{let p=this.getChildAtIndex(e);p!==null&&(f=p.getPreviousSibling())}if(t>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let g=0;g<t;g++){p===null&&x(!1,"splice: sibling not found");let h=p.getNextSibling(),C=p.__key,N=p.getWritable();Yt(N),d.push(C),p=h}}let u=f;for(let p=0;p<r;p++){let g=n[p];u!==null&&g.is(u)&&(f=u=u.getPreviousSibling());let h=g.getWritable();h.__parent===l&&c--,Yt(h);let C=g.__key;if(u===null)s.__first=C,h.__prev=null;else{let N=u.getWritable();N.__next=C,h.__prev=N.__key}g.__key===l&&x(!1,"append: attempting to append self"),h.__parent=l,a.push(C),u=g}if(e+t===i){if(u!==null){let p=u.getWritable();p.__next=null,s.__last=u.__key}}else if(m!==null){let p=m.getWritable();if(u!==null){let g=u.getWritable();p.__prev=u.__key,g.__next=m.__key}else p.__prev=null}if(s.__size=c,d.length){let p=T();if(_(p)){let g=new Set(d),h=new Set(a),{anchor:C,focus:N}=p;au(C,g,h)&&wn(C,C.getNode(),this,f,m),au(N,g,h)&&wn(N,N.getNode(),this,f,m),c===0&&!this.canBeEmpty()&&!me(this)&&this.remove()}}return s}exportJSON(){return{children:[],direction:this.getDirection(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}};function E(o){return o instanceof Z}function au(o,e,t){let n=o.getNode();for(;n;){let r=n.__key;if(e.has(r)&&!t.has(r))return!0;n=n.getParent()}return!1}var wt=class extends St{constructor(e){super(e)}decorate(e,t){x(!1,"decorate: base method not extended")}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function B(o){return o instanceof wt}var zo=class o extends Z{static getType(){return"root"}static clone(){return new o}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){x(!1,"getTopLevelElementOrThrow: root nodes are not top level elements")}getTextContent(){let e=this.__cachedText;return(st()||j()._dirtyType===bt)&&e!==null?e:super.getTextContent()}remove(){x(!1,"remove: cannot be called on root nodes")}replace(e){x(!1,"replace: cannot be called on root nodes")}insertBefore(e){x(!1,"insertBefore: cannot be called on root nodes")}insertAfter(e){x(!1,"insertAfter: cannot be called on root nodes")}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){let n=e[t];!E(n)&&!B(n)&&x(!1,"rootNode.append: Only element or decorator nodes can be appended to the root node")}return super.append(...e)}static importJSON(e){let t=F();return t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),type:"root",version:1}}collapseAtStart(){return!0}};function du(){return new zo}function oe(o){return o instanceof zo}function su(o,e){let t=e.getEditorState()._selection,n=o._selection;if(n!==null){if(n.dirty||!n.is(t))return!0}else if(t!==null)return!0;return!1}function lu(o){return new Si(new Map(o._nodeMap))}function wr(){return new Si(new Map([["root",du()]]))}function cu(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&x(!1,"LexicalNode: Node %s does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.",t.name),E(o)){let n=e.children;Array.isArray(n)||x(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name);let r=o.getChildren();for(let i=0;i<r.length;i++){let s=r[i],l=cu(s);n.push(l)}}return e}var Si=class o{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Al(t&&t.editor||null,this,e)}clone(e){let t=new o(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return Al(null,this,()=>({root:cu(F())}))}};var Co=class extends Z{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}};function b(o,e={},t=[]){let n=document.createElement(o),r=Object.keys(e);for(let i of r)e[i]!==null&&n.setAttribute(i,e[i]);for(let i of t)typeof i=="string"?n.append(document.createTextNode(i)):n.append(i);return n}function uu(o){return new DOMParser().parseFromString(o,"text/html")}function ft(o,e="px"){return typeof o=="number"||/^-?\d+$/.test(o)?`${o}${e}`:o}function Wo(o){return/^-?\d+$/.test(o)?Number(o):/^-?\d+\.\d+$/.test(o)?Math.round(Number(o)):/^-?\d+px\s*$/.test(o)?Number(o.trim().replace("px","")):0}function Dn(o){let e=new Map,n=(o.getAttribute("style")||"").split(";");for(let r of n){let[i,s]=r.split(":");!i||!s||e.set(i.trim().toLowerCase(),s.trim())}return e}function fu(o,e,t){t?o.setAttribute(e,t):o.removeAttribute(e)}var LN=["left","right","center","justify"];function vr(o){let e=o.style.textAlign||"";return LN.includes(e)?e:o.classList.contains("align-left")?"left":o.classList.contains("align-right")?"right":o.classList.contains("align-center")?"center":o.classList.contains("align-justify")?"justify":""}function MN(o){let e=o.style.paddingLeft||"0";return Wo(e)}function Dr(o){let e=(o.dir||"").toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Je(o,e){o.id&&e.setId(o.id),e.setAlignment(vr(o)),e.setInset(MN(o)),e.setDirection(Dr(o))}function vt(o,e){return o.__id!==e.__id||o.__alignment!==e.__alignment||o.__inset!==e.__inset||o.__dir!==e.__dir}function Qe(o,e){e.__id&&o.setAttribute("id",e.__id),e.__alignment&&o.classList.add("align-"+e.__alignment),e.__inset&&(o.style.paddingLeft=`${e.__inset}px`),e.__dir&&(o.dir=e.__dir)}function et(o,e){e.setId(o.id),e.setAlignment(o.alignment),e.setInset(o.inset),e.setDirection(o.direction)}var Dt=class extends Z{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}exportJSON(){return{...super.exportJSON(),id:this.__id,alignment:this.__alignment,inset:this.__inset}}};function _o(o,e){e.__alignment=o.__alignment,e.__inset=o.__inset}var ct=class o extends Dt{constructor(e){super(e),this.__textStyle=""}static getType(){return"paragraph"}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textStyle=e.__textStyle,_o(e,this)}createDOM(e){let t=document.createElement("p"),n=po(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),Qe(t,this),t}updateDOM(e,t,n){return vt(e,this)}static importDOM(){return{p:e=>({conversion:wN,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=I();return et(e,t),t}exportJSON(){return{...super.exportJSON(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){let n=I();n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||y(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function wN(o){let e=I();return Je(o,e),{node:e}}function I(){return ne(new ct)}function dt(o){return o instanceof ct}var vN=!0,G=0,mt=1,Li=2,We=3,Re=4;function Rl(o,e,t,n){let r=o._keyToDOMMap;r.clear(),o._editorState=wr(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=bt,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),o._normalizedNodes=new Set,o._updateTags=new Set,o._updates=[],o._blockCursorElement=null;let i=o._observer;i!==null&&(i.disconnect(),o._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",r.set("root",t))}function DN(o,e){let t=new Map,n=new Set,r=i=>{Object.keys(i).forEach(s=>{let l=t.get(s);l===void 0&&(l=[],t.set(s,l)),l.push(i[s])})};return o.forEach(i=>{let s=i.klass.importDOM;if(s==null||n.has(s))return;n.add(s);let l=s.call(i.klass);l!==null&&r(l)}),e&&r(e),t}function kl(o){let e=o||{},t=ou(),n=e.theme||{},r=o===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,s=wr(),l=e.namespace||(r!==null?r._config.namespace:Js()),a=e.editorState,d=[zo,je,Bo,Fo,ct,Co,...e.nodes||[]],{onError:m,html:f}=e,c=e.editable!==void 0?e.editable:!0,u;if(o===void 0&&t!==null)u=t._nodes;else{u=new Map;for(let g=0;g<d.length;g++){let h=d[g],C=null,N=null;if(typeof h!="function"){let A=h;h=A.replace,C=A.with,N=A.withKlass||null}if(__DEV__){let A=Object.prototype.hasOwnProperty.call(h,"getType")&&h.getType(),O=h.name;if(N&&x(N.prototype instanceof h,"%s doesn't extend the %s",N.name,O),O!=="RootNode"&&A!=="root"&&A!=="artificial"){let R=h.prototype;["getType","clone"].forEach(P=>{h.hasOwnProperty(P)||console.warn(`${O} must implement static "${P}" method`)}),!h.hasOwnProperty("importDOM")&&h.hasOwnProperty("exportDOM")&&console.warn(`${O} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`),R instanceof wt&&(R.hasOwnProperty("decorate")||console.warn(`${R.constructor.name} must implement "decorate" method`)),h.hasOwnProperty("importJSON")||console.warn(`${O} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`),R.hasOwnProperty("exportJSON")||console.warn(`${O} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`)}}let L=h.getType(),M=h.transform(),S=new Set;M!==null&&S.add(M),u.set(L,{exportDOM:f&&f.export?f.export.get(h):void 0,klass:h,replace:C,replaceWithKlass:N,transforms:S})}}let p=new ho(s,r,u,{disableEvents:i,namespace:l,theme:n},m||console.error,DN(u,f?f.import:void 0),c);return a!==void 0&&(p._pendingEditorState=a,p._dirtyType=Wt),p}var ho=class{constructor(e,t,n,r,i,s,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=bt,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Js(),this._onError=i,this._htmlConversions=s,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){let t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){let t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){let t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){let t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){let t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&x(!1,'Listener for type "command" requires a "priority".');let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&x(!1,"registerCommand: Command %s not found in command map",String(e));let s=i[n];return s.add(t),()=>{s.delete(t),i.every(l=>l.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,r);let s=n&&n.skipInitialization;return(s===void 0?vN:s)||this.initializeMutationListener(t,r),()=>{i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&x(!1,"Node %s has not been registered. Ensure node has been passed to createEditor.",e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=cc(n).get(t.getType());if(!r)return;let i=new Map;for(let s of r.keys())i.set(s,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let s=this.registerNodeTransformToKlass(i,t);r.push(s)}return wd(this,e.getType()),()=>{r.forEach(s=>s.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return D(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=po(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Rl(this,t,e,r),t!==null&&(this._config.disableEvents||Ac(t),n!=null&&t.classList.remove(...n)),e!==null){let i=ac(e),s=e.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Wt,ni(this),this._updateTags.add("history-merge"),Mt(this),this._config.disableEvents||Oc(e,this),n!=null&&e.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;vn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&x(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),oi(this);let n=this._pendingEditorState,r=this._updateTags,i=t!==void 0?t.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Mt(this)),this._pendingEditorState=e,this._dirtyType=Wt,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Mt(this)}parseEditorState(e,t){let n=typeof e=="string"?JSON.parse(e):e;return nu(n,this,t)}read(e){return Mt(this),this.getEditorState().read(e,{editor:this})}update(e,t){xe(this,e,t)}updateAndCommit(e,t){this.update(e,t),this.commitUpdates()}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),xe(this,()=>{let r=T(),i=F();r!==null?r.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}commitUpdates(){Mt(this)}blur(){let e=this._rootElement;e!==null&&e.blur();let t=be(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,vn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};ho.version="0.17.1";function jt(...o){return()=>{for(let e=o.length-1;e>=0;e--)o[e]();o.length=0}}var On=new Map;function Il(o){let e={},t=o.split(";");for(let n of t)if(n!==""){let[r,i]=n.split(/:([^]+)/);r&&i&&(e[r.trim()]=i.trim())}return e}function An(o){let e=On.get(o);return e===void 0&&(e=Il(o),On.set(o,e)),__DEV__&&Object.freeze(e),e}function pu(o){let e="";for(let t in o)t&&(e+=`${t}: ${o[t]};`);return e}function Or(o,e){let t=o.getStartEndPoints();if(e.isSelected(o)&&!e.isSegmented()&&!e.isToken()&&t!==null){let[n,r]=t,i=o.isBackward(),s=n.getNode(),l=r.getNode(),a=e.is(s),d=e.is(l);if(a||d){let[m,f]=Mr(o),c=s.is(l),u=e.is(i?l:s),p=e.is(i?s:l),g=0,h;if(c)g=m>f?f:m,h=m>f?m:f;else if(u)g=i?f:m,h=void 0;else if(p){let C=i?m:f;g=0,h=C}return e.__text=e.__text.slice(g,h),e}}return e}function $l(o){let e=o.getStyle(),t=Il(e);On.set(e,t)}function Rn(o,e){let t=An("getStyle"in o?o.getStyle():o.style),n=Object.entries(e).reduce((i,[s,l])=>(typeof l=="function"?i[s]=l(t[s],o):l===null?delete i[s]:i[s]=l,i),{...t}),r=pu(n);o.setStyle(r),On.set(r,n)}function Pl(o,e){let t=o.getNodes(),n=t.length,r=o.getStartEndPoints();if(r===null)return;let[i,s]=r,l=n-1,a=t[0],d=t[l];if(o.isCollapsed()&&_(o)){Rn(o,e);return}let f=a.getTextContent().length,c=s.offset,u=i.offset,p=i.isBefore(s),g=p?u:c,h=p?c:u,C=p?i.type:s.type,N=p?s.type:i.type,L=p?s.key:i.key;if(y(a)&&g===f){let M=a.getNextSibling();y(M)&&(u=0,g=0,a=M)}if(t.length===1){if(y(a)&&a.canHaveFormat()){if(g=C==="element"?0:u>c?c:u,h=N==="element"?f:u>c?u:c,g===h)return;if(Ue(a)||g===0&&h===f)Rn(a,e),a.select(g,h);else{let M=a.splitText(g,h),S=g===0?M[0]:M[1];Rn(S,e),S.select(0,h-g)}}}else{if(y(a)&&g<a.getTextContentSize()&&a.canHaveFormat()&&(g!==0&&!Ue(a)&&(a=a.splitText(g)[1],g=0,p?i.set(a.getKey(),g,"text"):s.set(a.getKey(),g,"text")),Rn(a,e)),y(d)&&d.canHaveFormat()){let S=d.getTextContent().length;d.__key!==L&&h!==0&&(h=S),h!==S&&!Ue(d)&&([d]=d.splitText(h)),(h!==0||N==="element")&&Rn(d,e)}for(let M=1;M<l;M++){let S=t[M],A=S.getKey();y(S)&&S.canHaveFormat()&&A!==a.getKey()&&A!==d.getKey()&&!S.isToken()&&Rn(S,e)}}}function Mi(o,e){if(o===null)return;let t=o.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){let s=e(),l=F(),a=l.getFirstChild();a?a.replace(s,!0):l.append(s);return}let r=o.getNodes(),i=n!==null?AN(n.getNode(),gu):!1;i&&r.indexOf(i)===-1&&r.push(i);for(let s=0;s<r.length;s++){let l=r[s];if(!gu(l))continue;x(E(l),"Expected block node to be an ElementNode");let a=e();l.replace(a,!0)}}function wi(o,e){let t=Zt(o.focus,e);return B(t)&&!t.isIsolated()||E(t)&&!t.isInline()&&!t.canBeEmpty()}function hu(o,e,t,n){o.modify(e?"extend":"move",t,n)}function Nu(o){let e=o.anchor.getNode();return(oe(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function vi(o,e,t){let n=Nu(o);hu(o,e,t?!n:n,"character")}function ON(o,e,t){let n=o.getStyle(),r=An(n);return r!==null&&r[e]||t}function Bl(o,e,t=""){let n=null,r=o.getNodes(),i=o.anchor,s=o.focus,l=o.isBackward(),a=l?s.offset:i.offset,d=l?s.getNode():i.getNode();if(_(o)&&o.isCollapsed()&&o.style!==""){let m=o.style,f=An(m);if(f!==null&&e in f)return f[e]}for(let m=0;m<r.length;m++){let f=r[m];if(!(m!==0&&a===0&&f.is(d))&&y(f)){let c=ON(f,e,t);if(n===null)n=c;else if(n!==c){n="";break}}}return n===null?t:n}function gu(o){if(B(o)||!E(o)||me(o))return!1;let e=o.getFirstChild(),t=e===null||ve(e)||y(e)||e.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&t}function AN(o,e){let t=o;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function Te(o,...e){let t=yt(...e);t.length>0&&o.classList.add(...t)}function Di(o,...e){let t=yt(...e);t.length>0&&o.classList.remove(...t)}function xu(o,e){let t=o;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function Eu(o){let e=H(o,t=>E(t)&&!t.isInline());return E(e)||x(!1,"Expected node %s to have closest block element node.",o.__key),e}var H=(o,e)=>{let t=o;for(;t!==F()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function pt(o,e){return o!==null?Object.getPrototypeOf(o).constructor.name===e.name:!1}var Oi=0,Fl=1,Hl=2,gt=0,$N=1,Tu=2,PN=3,BN=4;function FN(o,e,t){let n=o._nodeMap,r=[];for(let i of e){let s=n.get(i);s!==void 0&&r.push(s)}for(let[i,s]of t){if(!s)continue;let l=n.get(i);l!==void 0&&!oe(l)&&r.push(l)}return r}function HN(o,e,t,n,r){if(o===null||t.size===0&&n.size===0&&!r)return gt;let i=e._selection,s=o._selection;if(r)return $N;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return gt;let l=FN(e,t,n);if(l.length===0)return gt;if(l.length>1){let C=e._nodeMap,N=C.get(i.anchor.key),L=C.get(s.anchor.key);return N&&L&&!o._nodeMap.has(N.__key)&&y(N)&&N.__text.length===1&&i.anchor.offset===1?Tu:gt}let a=l[0],d=o._nodeMap.get(a.__key);if(!y(d)||!y(a)||d.__mode!==a.__mode)return gt;let m=d.__text,f=a.__text;if(m===f)return gt;let c=i.anchor,u=s.anchor;if(c.key!==u.key||c.type!=="text")return gt;let p=c.offset,g=u.offset,h=f.length-m.length;return h===1&&g===p-1?Tu:h===-1&&g===p+1?PN:h===-1&&g===p?BN:gt}function KN(o,e,t){let n=e._nodeMap.get(o),r=t._nodeMap.get(o),i=e._selection,s=t._selection;return!(_(i)&&_(s)&&i.anchor.type==="element"&&i.focus.type==="element"&&s.anchor.type==="text"&&s.focus.type==="text")&&y(n)&&y(r)&&n.__parent===r.__parent?JSON.stringify(e.read(()=>n.exportJSON()))===JSON.stringify(t.read(()=>r.exportJSON())):!1}function UN(o,e){let t=Date.now(),n=gt;return(r,i,s,l,a,d)=>{let m=Date.now();if(d.has("historic"))return n=gt,t=m,Hl;let f=HN(r,i,l,a,o.isComposing()),c=(()=>{let u=s===null||s.editor===o,p=d.has("history-push");if(!p&&u&&d.has("history-merge"))return Oi;if(r===null)return Fl;let h=i._selection;if(!(l.size>0||a.size>0))return h!==null?Oi:Hl;if(p===!1&&f!==gt&&f===n&&m<t+e&&u)return Oi;if(l.size===1){let N=Array.from(l)[0];if(KN(N,r,i))return Oi}return Fl})();return t=m,n=f,c}}function zN(o,e){let t=e.redoStack,n=e.undoStack;if(t.length!==0){let r=e.current;r!==null&&(n.push(r),o.dispatchCommand(uo,!0));let i=t.pop();t.length===0&&o.dispatchCommand(co,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}function WN(o,e){let t=e.redoStack,n=e.undoStack;if(n.length!==0){let i=e.current,s=n.pop();i!==null&&(t.push(i),o.dispatchCommand(co,!0)),n.length===0&&o.dispatchCommand(uo,!1),e.current=s||null,s&&s.editor.setEditorState(s.editorState,{tag:"historic"})}}function Cu(o){o.undoStack=[],o.redoStack=[],o.current=null}function _u(o,e,t){let n=UN(o,t),r=({editorState:s,prevEditorState:l,dirtyLeaves:a,dirtyElements:d,tags:m})=>{let f=e.current,c=e.redoStack,u=e.undoStack,p=f===null?null:f.editorState;if(f!==null&&s===p)return;let g=n(l,s,f,a,d,m);if(g===Fl)c.length!==0&&(e.redoStack=[],o.dispatchCommand(co,!1)),f!==null&&(u.push({...f}),o.dispatchCommand(uo,!0));else if(g===Hl)return;e.current={editor:o,editorState:s}};return jt(o.registerCommand(io,()=>(WN(o,e),!0),G),o.registerCommand(so,()=>(zN(o,e),!0),G),o.registerCommand(Is,()=>(Cu(e),!1),G),o.registerCommand($s,()=>(Cu(e),o.dispatchCommand(co,!1),o.dispatchCommand(uo,!1),!0),G),o.registerUpdateListener(r))}function bu(){return{current:null,redoStack:[],undoStack:[]}}function Ai(o,e){let t=e.body?e.body.childNodes:[],n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(!Lu.has(s.nodeName)){let l=Mu(s,o,r,!1);l!==null&&(n=n.concat(l))}}return YN(r),n}function Ri(o,e){if(typeof document>"u"||typeof window>"u"&&typeof global.window>"u")throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let t=document.createElement("div"),r=F().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Su(o,s,t,e)}return t.innerHTML}function Su(o,e,t,n=null){let r=n!==null?e.isSelected(n):!0,i=E(e)&&e.excludeFromCopy("html"),s=e;if(n!==null){let u=Vt(e);u=y(u)&&n!==null?Or(n,u):u,s=u}let l=E(s)?s.getChildren():[],a=o._nodes.get(s.getType()),d;a&&a.exportDOM!==void 0?d=a.exportDOM(o,s):d=s.exportDOM(o);let{element:m,after:f}=d;if(!m)return!1;let c=document.createDocumentFragment();for(let u=0;u<l.length;u++){let p=l[u],g=Su(o,p,c,n);!r&&E(e)&&g&&e.extractWithChild(p,n,"html")&&(r=!0)}if(r&&!i){if(pe(m)&&m.append(c),t.append(m),f){let u=f.call(s,m);u&&m.replaceWith(u)}}else t.append(c);return r}function qN(o,e){let{nodeName:t}=o,n=e._htmlConversions.get(t.toLowerCase()),r=null;if(n!==void 0)for(let i of n){let s=i(o);s!==null&&(r===null||(r.priority||0)<(s.priority||0))&&(r=s)}return r!==null?r.conversion:null}var Lu=new Set(["STYLE","SCRIPT"]);function Mu(o,e,t,n,r=new Map,i){let s=[];if(Lu.has(o.nodeName))return s;let l=null,a=qN(o,e),d=a?a(o):null,m=null;if(d!==null){m=d.after;let p=d.node;if(p==="ignore")return s;if(l=Array.isArray(p)?p[p.length-1]:p,l!==null){for(let[,g]of r)if(l=g(l,i),!l)break;l&&s.push(...Array.isArray(p)?p:[l])}d.forChild!=null&&r.set(o.nodeName,d.forChild)}let f=o.childNodes,c=[],u=l!=null&&me(l)?!1:l!=null&&Ko(l)||n;for(let p=0;p<f.length;p++)c.push(...Mu(f[p],e,t,u,new Map(r),l));return m!=null&&(c=m(c)),go(o)&&(u?c=yu(o,c,()=>{let p=new Co;return t.push(p),p}):c=yu(o,c,I)),l==null?c.length>0?s=s.concat(c):go(o)&&ZN(o)&&(s=s.concat(ut())):E(l)&&l.append(...c),s}function yu(o,e,t){let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(Ko(s))n.push(s);else if(r.push(s),i===e.length-1||i<e.length-1&&Ko(e[i+1])){let l=t();l.append(...r),n.push(l),r=[]}}return n}function YN(o){for(let e of o)e.getNextSibling()instanceof Co&&e.insertAfter(ut());for(let e of o){let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}}function ZN(o){return o.nextSibling==null||o.previousSibling==null?!1:Io(o.nextSibling)&&Io(o.previousSibling)}var vu=o=>fe?(o||window).getSelection():null;function Du(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?"":Ri(o,e)}function Ou(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(Ru(o,e))}function ki(o,e,t){let n=o.getData("application/x-lexical-editor");if(n)try{let s=JSON.parse(n);if(s.namespace===t._config.namespace&&Array.isArray(s.nodes)){let l=ku(s.nodes);return Kl(t,l,e)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Ai(t,l);return Kl(t,a,e)}catch{}let i=o.getData("text/plain")||o.getData("text/uri-list");if(i!=null)if(_(e)){let s=i.split(/(\r?\n|\t)/);s[s.length-1]===""&&s.pop();for(let l=0;l<s.length;l++){let a=T();if(_(a)){let d=s[l];d===`
+`||d===`\r
+`?a.insertParagraph():d===" "?a.insertNodes([Lt()]):a.insertText(d)}}}else e.insertRawText(i)}function Kl(o,e,t){o.dispatchCommand(er,{nodes:e,selection:t})||t.insertNodes(e)}function VN(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&x(!1,"LexicalNode: Node %s does not implement .exportJSON().",t.name),E(o)){let n=e.children;Array.isArray(n)||x(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name)}return e}function Au(o,e,t,n=[]){let r=e!==null?t.isSelected(e):!0,i=E(t)&&t.excludeFromCopy("html"),s=t;if(e!==null){let d=Vt(t);d=y(d)&&e!==null?Or(e,d):d,s=d}let l=E(s)?s.getChildren():[],a=VN(s);if(y(s)){let d=s.__text;d.length>0?a.text=d:r=!1}for(let d=0;d<l.length;d++){let m=l[d],f=Au(o,e,m,a.children);!r&&E(t)&&f&&t.extractWithChild(m,e,"clone")&&(r=!0)}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let d=0;d<a.children.length;d++){let m=a.children[d];n.push(m)}return r}function Ru(o,e){let t=[],r=F().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Au(o,e,s,t)}return{namespace:o._config.namespace,nodes:t}}function ku(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=Dl(n);y(r)&&$l(r),e.push(r)}return e}var XN=50,kn=null;async function In(o,e,t){if(kn!==null)return!1;if(e!==null)return new Promise((a,d)=>{o.update(()=>{a(wu(o,e,t))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=vu(o._window);if(n===null||i===null)return!1;let s=r.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(r.createTextNode("#")),n.append(s);let l=new Range;return l.setStart(s,0),l.setEnd(s,1),i.removeAllRanges(),i.addRange(l),new Promise((a,d)=>{let m=o.registerCommand(lo,f=>(pt(f,ClipboardEvent)&&(m(),kn!==null&&(window.clearTimeout(kn),kn=null),a(wu(o,f,t))),!0),Re);kn=window.setTimeout(()=>{m(),kn=null,a(!1)},XN),r.execCommand("copy"),s.remove()})}function wu(o,e,t){if(t===void 0){let r=vu(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!qt(o,i,s))return!1;let l=T();if(l===null)return!1;t=Ii(l)}e.preventDefault();let n=e.clipboardData;return n===null?!1:(Iu(n,t),!0)}var GN=[["text/html",Du],["application/x-lexical-editor",Ou]];function Ii(o=T()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=nl();for(let[n,r]of GN){let i=r(t,o);i!==null&&(e[n]=i)}}return e}function Iu(o,e){for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n)}}function $i(o,e){if(typeof document.caretRangeFromPoint<"u"){let t=document.caretRangeFromPoint(o,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let t=document.caretPositionFromPoint(o,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}else return null}var $u=$("DRAG_DROP_PASTE_FILE");function jN(o,e){o.preventDefault(),e.update(()=>{let t=T(),n=pt(o,InputEvent)||pt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&t!==null&&ki(n,t,e)},{tag:"paste"})}async function JN(o,e){await In(e,pt(o,ClipboardEvent)?o:null),e.update(()=>{let t=T();_(t)?t.removeText():Se(t)&&t.getNodes().forEach(n=>n.remove())})}function Pi(o){let e=null;if(pt(o,DragEvent)?e=o.dataTransfer:pt(o,ClipboardEvent)&&(e=o.clipboardData),e===null)return[!1,[],!1];let t=e.types,n=t.includes("Files"),r=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),r]}function Bi(o){let e=ee(o);return B(e)}function QN(o){let e=o.focus;return e.key==="root"&&e.offset===F().getChildrenSize()}function Pu(o){return jt(o.registerCommand(tr,t=>{let n=T();return Se(n)?(n.clear(),!0):!1},0),o.registerCommand(Ye,t=>{let n=T();return _(n)?(n.deleteCharacter(t),!0):!1},G),o.registerCommand(Ct,t=>{let n=T();return _(n)?(n.deleteWord(t),!0):!1},G),o.registerCommand(it,t=>{let n=T();return _(n)?(n.deleteLine(t),!0):!1},G),o.registerCommand(rt,t=>{let n=T();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;let r=t.dataTransfer;if(r!=null)ki(r,n,o);else if(_(n)){let i=t.data;return i&&n.insertText(i),!0}}return!0},G),o.registerCommand(cn,()=>{let t=T();return _(t)?(t.removeText(),!0):!1},G),o.registerCommand(Ne,t=>{let n=T();return _(n)?(n.formatText(t),!0):!1},G),o.registerCommand($t,t=>{let n=T();return _(n)?(n.insertLineBreak(t),!0):!1},G),o.registerCommand(Pt,()=>{let t=T();return _(t)?(t.insertParagraph(),!0):!1},G),o.registerCommand(Rs,()=>(Oe([Lt()]),!0),G),o.registerCommand(Bt,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=Zt(n.focus,!0);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},G),o.registerCommand(Ft,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(QN(n))return t.preventDefault(),!0;let r=Zt(n.focus,!1);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},G),o.registerCommand(wo,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(wi(n,!0)){let r=t.shiftKey;return t.preventDefault(),vi(n,r,!0),!0}return!1},G),o.registerCommand(Mo,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let i=n.getNodes();if(i.length>0)return t.preventDefault(),i[0].selectNext(0,0),!0}if(!_(n))return!1;let r=t.shiftKey;return wi(n,!1)?(t.preventDefault(),vi(n,r,!1),!0):!1},G),o.registerCommand(Ht,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ye,!0)):!1},G),o.registerCommand(Kt,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ye,!1)):!1},G),o.registerCommand(Be,t=>{let n=T();if(!_(n))return!1;if(t!==null){if((_t||Ut||zt)&&fo)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand($t,!1)}return o.dispatchCommand(Pt,void 0)},G),o.registerCommand(vo,()=>{let t=T();return _(t)?(o.blur(),!0):!1},G),o.registerCommand(Oo,t=>{let[,n]=Pi(t);if(n.length>0){let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let{offset:a,node:d}=l,m=ee(d);if(m!==null){let f=Uo();if(y(m))f.anchor.set(m.getKey(),a,"text"),f.focus.set(m.getKey(),a,"text");else{let u=m.getParentOrThrow().getKey(),p=m.getIndexWithinParent()+1;f.anchor.set(u,p,"element"),f.focus.set(u,p,"element")}let c=Ao(f);Y(c)}o.dispatchCommand($u,n)}return t.preventDefault(),!0}let r=T();return!!_(r)},G),o.registerCommand(nr,t=>{let[n]=Pi(t),r=T();return!(n&&!_(r))},G),o.registerCommand(rr,t=>{let[n]=Pi(t),r=T();if(n&&!_(r))return!1;let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let a=ee(l.node);B(a)&&t.preventDefault()}return!0},G),o.registerCommand(un,()=>(tl(),!0),G),o.registerCommand(lo,t=>(In(o,pt(t,ClipboardEvent)?t:null),!0),G),o.registerCommand(ao,t=>(JN(t,o),!0),G),o.registerCommand(ro,t=>{let[,n,r]=Pi(t);return n.length>0&&!r?(o.dispatchCommand($u,n),!0):Tn(t.target)?!1:T()!==null?(jN(t,o),!0):!1},G))}var qo=class o extends Z{constructor(t,n){super(n);this.__id="";this.__category="info";this.__alignment="";this.__inset=0;this.__category=t}static getType(){return"callout"}static clone(t){let n=new o(t.__category,t.__key);return n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setCategory(t){let n=this.getWritable();n.__category=t}getCategory(){return this.getLatest().__category}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}createDOM(t,n){let r=document.createElement("p");return r.classList.add("callout",this.__category||""),Qe(r,this),r}updateDOM(t){return t.__category!==this.__category||vt(t,this)}insertNewAfter(t,n){let r=t?t.anchor.offset:0,i=r===this.getTextContentSize()||!t?I():$n(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&t){let s=I();s.select(),this.replace(s,!0)}return i}static importDOM(){return{p(t){return t.classList.contains("callout")?{conversion:n=>{let r="info",i=["info","success","warning","danger"];for(let l of i)if(n.classList.contains(l)){r=l;break}let s=new o(r);return Je(n,s),{node:s}},priority:3}:null}}}exportJSON(){return{...super.exportJSON(),type:"callout",version:1,category:this.__category,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=$n(t.category);return et(t,n),n}};function $n(o="info"){return new qo(o)}function Ul(o){return o instanceof qo}function zl(o,e="info"){return o instanceof qo&&o.getCategory()===e}var ex=new Set(["http:","https:","mailto:","sms:","tel:"]),Pn=class o extends Z{static getType(){return"link"}static clone(e){return new o(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);let{target:r=null,rel:i=null,title:s=null}=t;this.__url=e,this.__target=r,this.__rel=i,this.__title=s}createDOM(e){let t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Te(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){let r=this.__url,i=this.__target,s=this.__rel,l=this.__title;r!==e.__url&&(t.href=r),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),s!==e.__rel&&(s?t.rel=s:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:tx,priority:1})}}static importJSON(e){let t=ht(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setDirection(e.direction),t}sanitizeUrl(e){try{let t=new URL(e);if(!ex.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){let t=this.getWritable();t.__url=e}getTarget(){return this.getLatest().__target}setTarget(e){let t=this.getWritable();t.__target=e}getRel(){return this.getLatest().__rel}setRel(e){let t=this.getWritable();t.__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){let t=this.getWritable();t.__title=e}insertNewAfter(e,t=!0){let n=ht(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!_(t))return!1;let r=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function tx(o){let e=null;if(fi(o)){let t=o.textContent;(t!==null&&t!==""||o.children.length>0)&&(e=ht(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:e}}function ht(o,e){return ne(new Pn(o,e))}function Ot(o){return o instanceof Pn}var BS=$("TOGGLE_LINK_COMMAND");var Yo=class o extends Z{constructor(t,n,r){super(r);this.__src="";this.__alt="";this.__width=0;this.__height=0;this.__alignment="";this.__src=t,n.alt&&(this.__alt=n.alt),n.width&&(this.__width=n.width),n.height&&(this.__height=n.height)}static getType(){return"image"}static clone(t){let n=new o(t.__src,{alt:t.__alt,width:t.__width,height:t.__height},t.__key);return n.__alignment=t.__alignment,n}setSrc(t){let n=this.getWritable();n.__src=t}getSrc(){return this.getLatest().__src}setAltText(t){let n=this.getWritable();n.__alt=t}getAltText(){return this.getLatest().__alt}setHeight(t){let n=this.getWritable();n.__height=t}getHeight(){return this.getLatest().__height}setWidth(t){let n=this.getWritable();n.__width=t}getWidth(){return this.getLatest().__width}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}isInline(){return!0}createDOM(t,n){let r=document.createElement("img");return r.setAttribute("src",this.__src),this.__width&&r.setAttribute("width",String(this.__width)),this.__height&&r.setAttribute("height",String(this.__height)),this.__alt&&r.setAttribute("alt",this.__alt),this.__alignment&&r.classList.add("align-"+this.__alignment),r.addEventListener("click",i=>{n.update(()=>{this.select()})}),r}updateDOM(t,n){return t.__src!==this.__src&&n.setAttribute("src",this.__src),t.__width!==this.__width&&(this.__width?n.setAttribute("width",String(this.__width)):n.removeAttribute("width")),t.__height!==this.__height&&(this.__height?n.setAttribute("height",String(this.__height)):n.removeAttribute("height")),t.__alt!==this.__alt&&(this.__alt?n.setAttribute("alt",String(this.__alt)):n.removeAttribute("alt")),t.__alignment!==this.__alignment&&(t.__alignment&&n.classList.remove("align-"+t.__alignment),this.__alignment&&n.classList.add("align-"+this.__alignment)),!1}static importDOM(){return{img(t){return{conversion:n=>{let r=n.getAttribute("src")||"",i={alt:n.getAttribute("alt")||"",height:Number.parseInt(n.getAttribute("height")||"0"),width:Number.parseInt(n.getAttribute("width")||"0")},s=new o(r,i);return s.setAlignment(vr(n)),{node:s}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"image",version:1,src:this.__src,alt:this.__alt,height:this.__height,width:this.__width,alignment:this.__alignment}}static importJSON(t){let n=Bn(t.src,{alt:t.alt,width:t.width,height:t.height});return n.setAlignment(t.alignment),n}};function Bn(o,e={}){return new Yo(o,e)}function Nt(o){return o instanceof Yo}var Fn=class o extends Z{constructor(){super(...arguments);this.__id="";this.__summary="";this.__open=!1}static getType(){return"details"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setSummary(t){let n=this.getWritable();n.__summary=t}getSummary(){return this.getLatest().__summary}setOpen(t){let n=this.getWritable();n.__open=t}getOpen(){return this.getLatest().__open}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__dir=t.__dir,n.__summary=t.__summary,n.__open=t.__open,n}createDOM(t,n){let r=document.createElement("details");this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),this.__open&&r.setAttribute("open","true");let i=document.createElement("summary");return i.textContent=this.__summary,i.setAttribute("contenteditable","false"),i.addEventListener("click",s=>{s.preventDefault(),n.update(()=>{this.select()})}),r.append(i),r}updateDOM(t,n){return t.__open!==this.__open&&n.toggleAttribute("open",this.__open),t.__id!==this.__id||t.__dir!==this.__dir||t.__summary!==this.__summary}static importDOM(){return{details(t){return{conversion:n=>{let r=new o;n.id&&r.setId(n.id),n.dir&&r.setDirection(Dr(n));let i=Array.from(n.children).find(s=>s.nodeName==="SUMMARY");return r.setSummary(i?.textContent||""),{node:r}},priority:3}},summary(t){return{conversion:n=>({node:"ignore"}),priority:3}}}}exportDOM(t){let n=this.createDOM(t._config,t),r=n.querySelectorAll("[contenteditable]");for(let i of r)i.removeAttribute("contenteditable");return n.removeAttribute("open"),{element:n}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id,summary:this.__summary}}static importJSON(t){let n=Wl();return n.setId(t.id),n.setDirection(t.direction),n}};function Wl(){return new Fn}function ke(o){return o instanceof Fn}function ql(o){let e=1,t=o.getParent();for(;t!=null;){if(V(t)){let n=t.getParent();if(U(n)){e++,t=n.getParent();continue}x(!1,"A ListItemNode must have a ListNode for a parent.")}return e}return e}function Yl(o){let e=o.getParent();U(e)||x(!1,"A ListItemNode must have a ListNode for a parent.");let t=e;for(;t!==null;)t=t.getParent(),U(t)&&(e=t);return e}function Zl(o){let e=[],t=o.getChildren().filter(V);for(let n=0;n<t.length;n++){let r=t[n],i=r.getFirstChild();U(i)?e=e.concat(Zl(i)):e.push(r)}return e}var m0=Symbol.for("@lexical/NestedListNodeBrand");function Hn(o){return V(o)&&U(o.getFirstChild())}function Bu(o){return Ie().append(o)}function Hu(o,e){return V(o)&&(e.length===0||e.length===1&&o.is(e[0])&&o.getChildrenSize()===0)}function Vl(o,e){o.update(()=>{let t=T();if(t!==null){let n=t.getNodes();if(_(t)){let i=t.getStartEndPoints();x(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(Hu(l,n)){let d=Ce(e);if(me(a)){l.replace(d);let m=Ie();d.append(m)}else if(V(l)){let m=l.getParentOrThrow();Ar(d,m.getChildren()),m.replace(d)}return}}let r=new Set;for(let i=0;i<n.length;i++){let s=n[i];if(E(s)&&s.isEmpty()&&!V(s)&&!r.has(s.getKey())){Fu(s,e);continue}if(gr(s)){let l=s.getParent();for(;l!=null;){let a=l.getKey();if(U(l)){if(!r.has(a)){let d=Ce(e);Ar(d,l.getChildren()),l.replace(d),r.add(a)}break}else{let d=l.getParent();if(me(d)&&!r.has(a)){r.add(a),Fu(l,e);break}l=d}}}}}})}function Ar(o,e){o.splice(o.getChildrenSize(),0,e)}function Fu(o,e){if(U(o))return o;let t=o.getPreviousSibling(),n=o.getNextSibling(),r=Ie();if(Ar(r,o.getChildren()),U(t)&&e===t.getListType())return t.append(r),o.remove(),U(n)&&e===n.getListType()&&(Ar(t,n.getChildren()),n.remove()),t;if(U(n)&&e===n.getListType())return n.getFirstChildOrThrow().insertBefore(r),o.remove(),n;{let i=Ce(e);return i.append(r),o.replace(i),i}}function Fi(o,e){let t=o.getLastChild(),n=e.getFirstChild();t&&n&&Hn(t)&&Hn(n)&&(Fi(t.getFirstChild(),n.getFirstChild()),n.remove());let r=e.getChildren();r.length>0&&o.append(...r),e.remove()}function Xl(o){o.update(()=>{let e=T();if(_(e)){let t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(Hu(r,n))t.add(Yl(r));else for(let i=0;i<n.length;i++){let s=n[i];if(gr(s)){let l=xu(s,Jt);l!=null&&t.add(Yl(l))}}for(let i of t){let s=i,l=Zl(i);for(let a of l){let d=I();Ar(d,a.getChildren()),s.insertAfter(d),s=d,a.__key===e.anchor.key&&e.anchor.set(d.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(d.getKey(),0,"element"),a.remove()}i.remove()}}})}function Ku(o){let e=o.getListType()!=="check",t=o.getStart();for(let n of o.getChildren())V(n)&&(n.getValue()!==t&&n.setValue(t),e&&n.getLatest().__checked!=null&&n.setChecked(void 0),U(n.getFirstChild())||t++)}function Uu(o){let e=o.getNextSibling();U(e)&&o.getListType()===e.getListType()&&Fi(o,e)}var Jt=class o extends Z{static getType(){return"listitem"}static clone(e){return new o(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){let t=document.createElement("li"),n=this.getParent();return U(n)&&n.getListType()==="check"&&Wu(t,this),t.value=this.__value,zu(this)&&(t.style.listStyle="none"),t}updateDOM(e,t,n){let r=this.getParent();return U(r)&&r.getListType()==="check"&&Wu(t,this),t.style.listStyle=zu(this)?"none":"",t.value=this.__value,!1}static transform(){return e=>{if(x(V(e),"node is not a ListItemNode"),e.__checked==null)return;let t=e.getParent();U(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:ox,priority:0})}}static importJSON(e){let t=Ie();return t.setChecked(e.checked),t.setValue(e.value),t.setDirection(e.direction),t}exportDOM(e){let t=this.createDOM(e._config);if(t.classList.contains("task-list-item")){let n=b("input",{type:"checkbox",disabled:"disabled"});t.hasAttribute("checked")&&(n.setAttribute("checked","checked"),t.removeAttribute("checked")),t.prepend(n)}return{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){let n=e[t];if(E(n)&&this.canMergeWith(n)){let r=n.getChildren();this.append(...r),n.remove()}else super.append(n)}return this}replace(e,t){if(V(e))return super.replace(e);let n=this.getParentOrThrow();if(!U(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{let r=Ce(n.getListType()),i=this.getNextSibling();for(;i;){let s=i;i=i.getNextSibling(),r.append(s)}n.insertAfter(e),e.insertAfter(r)}return t&&(x(E(e),"includeChildren should only be true for ElementNodes"),this.getChildren().forEach(r=>{e.append(r)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){let n=this.getParentOrThrow();if(U(n)||x(!1,"insertAfter: list node is not parent of list item node"),V(e))return super.insertAfter(e,t);let r=this.getNextSiblings();if(n.insertAfter(e,t),r.length!==0){let i=Ce(n.getListType());r.forEach(s=>i.append(s)),e.insertAfter(i,t)}return e}remove(e){let t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Hn(t)&&Hn(n)&&(Fi(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let r=this.getParentOrThrow(),i=r.getParent();if(V(i))return i.insertAfter(this),this.selectStart(),null;{let s=I();return r.insertAfter(s,t),this.remove(),s}}let n=Ie(this.__checked==null?void 0:!1);return this.insertAfter(n,t),n}collapseAtStart(e){let t=I();this.getChildren().forEach(l=>t.append(l));let r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=V(i);if(r.getChildrenSize()===1)if(s)r.remove(),i.select();else{r.insertBefore(t),r.remove();let l=e.anchor,a=e.focus,d=t.getKey();l.type==="element"&&l.getNode().is(this)&&l.set(d,l.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(d,a.offset,"element")}else r.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){let t=this.getWritable();t.__value=e}getChecked(){let e=this.getLatest(),t,n=this.getParent();return U(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){let t=this.getWritable();t.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}canInsertAfter(e){return V(e)}canReplaceWith(e){return V(e)}canMergeWith(e){return dt(e)||V(e)}extractWithChild(e,t){if(!_(t))return!1;let n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Ce("bullet")}canMergeWhenEmpty(){return!0}};function zu(o){let e=o.getChildren(),t=!1,n=!1;for(let r of e)U(r)?n=!0:r.getTextContent().trim().length>0&&(t=!0);return n&&!t}function Wu(o,e){let t=!U(e.getFirstChild());o.classList.toggle("task-list-item",t),e.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}function ox(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return nx(r)}let t=o.getAttribute("aria-checked");return{node:Ie(t==="true"?!0:t==="false"?!1:void 0)}}function nx(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let t=o.hasAttribute("checked");return{node:Ie(t)}}function Ie(o){return ne(new Jt(void 0,o))}function V(o){return o instanceof Jt}var Zo=class o extends Z{constructor(t,n,r){super(r);this.__id="";let i=sx[t]||t;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=n}static getType(){return"list"}static clone(t){let n=new o(t.__listType,t.__start,t.__key);return n.__id=t.__id,n.__dir=t.__dir,n}getTag(){return this.__tag}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setListType(t){let n=this.getWritable();n.__listType=t,n.__tag=t==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(t,n){let r=this.__tag,i=document.createElement(r);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,qu(i,t.theme,this),this.__id&&i.setAttribute("id",this.__id),this.__dir&&i.setAttribute("dir",this.__dir),i}updateDOM(t,n,r){return t.__tag!==this.__tag||t.__dir!==this.__dir||t.__id!==this.__id?!0:(qu(n,r.theme,this),!1)}static transform(){return t=>{x(U(t),"node is not a ListNode"),Uu(t),Ku(t)}}static importDOM(){return{ol:()=>({conversion:Yu,priority:0}),ul:()=>({conversion:Yu,priority:0})}}static importJSON(t){let n=Ce(t.listType,t.start);return n.setId(t.id),n.setDirection(t.direction),n}exportDOM(t){let{element:n}=super.exportDOM(t);return n&&pe(n)&&(this.__start!==1&&n.setAttribute("start",String(this.__start)),this.__listType==="check"&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1,id:this.__id}}canBeEmpty(){return!1}canIndent(){return!1}append(...t){for(let n=0;n<t.length;n++){let r=t[n];if(V(r))super.append(r);else{let i=Ie();if(U(r))i.append(r);else if(E(r)){let s=q(r.getTextContent());i.append(s)}else i.append(r);super.append(i)}}return this}extractWithChild(t){return V(t)}};function qu(o,e,t){let n=[],r=[],i=e.list;if(i!==void 0){let s=i[`${t.__tag}Depth`]||[],l=ql(t)-1,a=l%s.length,d=s[a],m=i[t.__tag],f,c=i.nested,u=i.checklist;if(c!==void 0&&c.list&&(f=c.list),m!==void 0&&n.push(m),u!==void 0&&t.__listType==="check"&&n.push(u),d!==void 0){n.push(...yt(d));for(let p=0;p<s.length;p++)p!==a&&r.push(t.__tag+p)}if(f!==void 0){let p=yt(f);l>1?n.push(...p):r.push(...p)}}r.length>0&&Di(o,...r),n.length>0&&Te(o,...n)}function rx(o){let e=[];for(let t of o)V(t)?e.push(t):e.push(Bu(t));return e}function ix(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let e of o.childNodes)if(pe(e)&&(e.hasAttribute("aria-checked")||e.classList.contains("task-list-item")||e.firstElementChild&&e.firstElementChild.matches('input[type="checkbox"]')))return!0;return!1}function Yu(o){let e=o.nodeName.toLowerCase(),t=null;if(e==="ol"){let n=o.start;t=Ce("number",n)}else e==="ul"&&(ix(o)?t=Ce("check"):t=Ce("bullet"));return o.id&&t&&t.setId(o.id),o.dir&&t&&t.setDirection(Dr(o)),{after:rx,node:t}}var sx={ol:"number",ul:"bullet"};function Ce(o,e=1){return ne(new Zo(o,e))}function U(o){return o instanceof Zo}var aL=$("INSERT_UNORDERED_LIST_COMMAND"),dL=$("INSERT_ORDERED_LIST_COMMAND"),cL=$("INSERT_CHECK_LIST_COMMAND"),uL=$("REMOVE_LIST_COMMAND");var re={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Qt=class o extends Z{constructor(t=re.NO_STATUS,n=1,r,i){super(i);this.__styles=new Map;this.__alignment="";this.__colSpan=n,this.__rowSpan=1,this.__headerState=t,this.__width=r,this.__backgroundColor=null}static getType(){return"tablecell"}static clone(t){let n=new o(t.__headerState,t.__colSpan,t.__width,t.__key);return n.__rowSpan=t.__rowSpan,n.__backgroundColor=t.__backgroundColor,n.__styles=new Map(t.__styles),n.__alignment=t.__alignment,n}static importDOM(){return{td:t=>({conversion:Zu,priority:0}),th:t=>({conversion:Zu,priority:0})}}static importJSON(t){let n=$e(t.headerState,t.colSpan,t.width);return t.rowSpan&&n.setRowSpan(t.rowSpan),n.setStyles(new Map(Object.entries(t.styles))),n.setAlignment(t.alignment),n}createDOM(t){let n=document.createElement(this.getTag());this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(n.style.backgroundColor=this.__backgroundColor),Te(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}exportDOM(t){let{element:n}=super.exportDOM(t);return{element:n}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth(),styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}getColSpan(){return this.__colSpan}setColSpan(t){return this.getWritable().__colSpan=t,this}getRowSpan(){return this.__rowSpan}setRowSpan(t){return this.getWritable().__rowSpan=t,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(t){let n=this.getWritable();return n.__headerState=t,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(t){let n=this.getWritable();return n.__width=t,this.__width}getWidth(){return this.getLatest().__width}clearWidth(){let t=this.getWritable();t.__width=void 0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}updateTag(t){let r=t.toLowerCase()==="th"?re.ROW:re.NO_STATUS,i=this.getWritable();i.__headerState=r}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(t){this.getWritable().__backgroundColor=t}toggleHeaderStyle(t){let n=this.getWritable();return(n.__headerState&t)===t?n.__headerState-=t:n.__headerState+=t,n}hasHeaderState(t){return(this.getHeaderStyles()&t)===t}hasHeader(){return this.getLatest().__headerState!==re.NO_STATUS}updateDOM(t){return t.__headerState!==this.__headerState||t.__width!==this.__width||t.__colSpan!==this.__colSpan||t.__rowSpan!==this.__rowSpan||t.__backgroundColor!==this.__backgroundColor||t.__styles!==this.__styles||t.__alignment!==this.__alignment}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function Zu(o){let e=o,t=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(e.style.width)&&(n=parseFloat(e.style.width));let i=$e(t==="th"?re.ROW:re.NO_STATUS,e.colSpan,n);i.__rowSpan=e.rowSpan;let s=e.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",d=l.includes("line-through"),m=s.fontStyle==="italic",f=l.includes("underline");return o instanceof HTMLElement&&(i.setStyles(Dn(o)),i.setAlignment(vr(o))),{after:c=>(c.length===0&&c.push(I()),c),forChild:(c,u)=>{if(v(u)&&!E(c)){let p=I();return ve(c)&&c.getTextContent()===`
+`?null:(y(c)&&(a&&c.toggleFormat("bold"),d&&c.toggleFormat("strikethrough"),m&&c.toggleFormat("italic"),f&&c.toggleFormat("underline")),p.append(c),p)}return c},node:i}}function $e(o=re.NO_STATUS,e=1,t){return ne(new Qt(o,e,t))}function v(o){return o instanceof Qt}var lx=$("INSERT_TABLE_COMMAND");var eo=class o extends Z{constructor(t){super(t);this.__styles=new Map}static getType(){return"tablerow"}static clone(t){let n=new o(t.__key);return n.__styles=new Map(t.__styles),n}static importDOM(){return{tr:t=>({conversion:ax,priority:0})}}static importJSON(t){let n=Vo();return n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(t){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return Te(n,t.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setHeight(t){let n=this.getWritable();return n.__height=t,this.__height}getHeight(){return this.getLatest().__height}updateDOM(t){return t.__height!==this.__height||t.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function ax(o){let e=Vo(),n=Wo(o.style.height);return e.setHeight(n),o instanceof HTMLElement&&e.setStyles(Dn(o)),{node:e}}function Vo(){return ne(new eo)}function Q(o){return o instanceof eo}function jl(o,e,t=!0){let n=kr();for(let r=0;r<o;r++){let i=Vo();for(let s=0;s<e;s++){let l=re.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=re.ROW),s===0&&t.columns&&(l|=re.COLUMN)):t&&(r===0&&(l|=re.ROW),s===0&&(l|=re.COLUMN));let a=$e(l),d=I();d.append(q()),a.append(d),i.append(a)}n.append(i)}return n}var Gl=(o,e)=>o===re.BOTH||o===e?e:re.NO_STATUS;function Hi(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.focus.getNode(),[n,,r]=Le(t),[i,s]=tt(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let d=a+n.__rowSpan-1,m=i[d],f=Vo();for(let u=0;u<l;u++){let{cell:p,startRow:g}=m[u];if(g+p.__rowSpan-1<=d){let C=m[u].cell.__headerState,N=Gl(C,re.COLUMN);f.append($e(N).append(I()))}else p.setRowSpan(p.__rowSpan+1)}let c=r.getChildAtIndex(d);x(Q(c),"focusEndRow is not a TableRowNode"),c.insertAfter(f)}else{let d=i[a],m=Vo();for(let c=0;c<l;c++){let{cell:u,startRow:p}=d[c];if(p===a){let h=d[c].cell.__headerState,C=Gl(h,re.COLUMN);m.append($e(C).append(I()))}else u.setRowSpan(u.__rowSpan+1)}let f=r.getChildAtIndex(a);x(Q(f),"focusEndRow is not a TableRowNode"),f.insertBefore(m)}}function Ki(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=Le(t),[i,,s]=Le(n),[l,a,d]=tt(s,i,r),m=l.length,f=o?Math.max(a.startColumn,d.startColumn):Math.min(a.startColumn,d.startColumn),c=o?f+i.__colSpan-1:f-1,u=s.getFirstChild();x(Q(u),"Expected firstTable child to be a row");let p=null;function g(C=re.NO_STATUS){let N=$e(C).append(I());return p===null&&(p=N),N}let h=u;e:for(let C=0;C<m;C++){if(C!==0){let R=h.getNextSibling();x(Q(R),"Expected row nextSibling to be a row"),h=R}let N=l[C],L=N[c<0?0:c].cell.__headerState,M=Gl(L,re.ROW);if(c<0){ea(h,g(M));continue}let{cell:S,startColumn:A,startRow:O}=N[c];if(A+S.__colSpan-1<=c){let R=S,P=O,k=c;for(;P!==C&&R.__rowSpan>1;)if(k-=S.__colSpan,k>=0){let{cell:W,startRow:ie}=N[k];R=W,P=ie}else{h.append(g(M));continue e}R.insertAfter(g(M))}else S.setColSpan(S.__colSpan+1)}p!==null&&Rr(p)}function Jl(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=tt(r,n,i),{startRow:d}=l,{startRow:m}=a,f=m+i.__rowSpan-1;if(s.length===f-d+1){r.remove();return}let c=s[0].length,u=s[f+1],p=r.getChildAtIndex(f+1);for(let g=f;g>=d;g--){for(let C=c-1;C>=0;C--){let{cell:N,startRow:L,startColumn:M}=s[g][C];if(M===C&&(g===d&&L<d&&N.setRowSpan(N.__rowSpan-(L-d)),L>=d&&L+N.__rowSpan-1>f))if(N.setRowSpan(N.__rowSpan-(f-L+1)),x(p!==null,"Expected nextRowNode not to be null"),C===0)ea(p,N);else{let{cell:S}=u[C-1];S.insertAfter(N)}}let h=r.getChildAtIndex(g);x(Q(h),"Expected GridNode childAtIndex(%s) to be RowNode",String(g)),h.remove()}if(u!==void 0){let{cell:g}=u[0];Rr(g)}else{let g=s[d-1],{cell:h}=g[0];Rr(h)}}function Ql(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=tt(r,n,i),{startColumn:d}=l,{startRow:m,startColumn:f}=a,c=Math.min(d,f),u=Math.max(d+n.__colSpan-1,f+i.__colSpan-1),p=u-c+1;if(s[0].length===u-c+1){r.selectPrevious(),r.remove();return}let h=s.length;for(let L=0;L<h;L++)for(let M=c;M<=u;M++){let{cell:S,startColumn:A}=s[L][M];if(A<c){if(M===c){let O=c-A;S.setColSpan(S.__colSpan-Math.min(p,S.__colSpan-O))}}else if(A+S.__colSpan-1>u){if(M===u){let O=u-A+1;S.setColSpan(S.__colSpan-O)}}else S.remove()}let C=s[m],N=d>f?C[d+n.__colSpan]:C[f+i.__colSpan];if(N!==void 0){let{cell:L}=N;Rr(L)}else{let L=f<d?C[f-1]:C[d-1],{cell:M}=L;Rr(M)}}function Rr(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart()}function ea(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e)}function ta(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),[t,n,r]=Le(e),i=t.__colSpan,s=t.__rowSpan;if(i>1){for(let l=1;l<i;l++)t.insertAfter($e(re.NO_STATUS).append(I()));t.setColSpan(1)}if(s>1){let[l,a]=tt(r,t,t),{startColumn:d,startRow:m}=a,f;for(let c=1;c<s;c++){let u=m+c,p=l[u];f=(f||n).getNextSibling(),x(Q(f),"Expected row next sibling to be a row");let g=null;for(let h=0;h<d;h++){let C=p[h],N=C.cell;C.startRow===u&&(g=N),N.__colSpan>1&&(h+=N.__colSpan-1)}if(g===null)for(let h=0;h<i;h++)ea(f,$e(re.NO_STATUS).append(I()));else for(let h=0;h<i;h++)g.insertAfter($e(re.NO_STATUS).append(I()))}t.setRowSpan(1)}}function tt(o,e,t){let[n,r,i]=Vu(o,e,t);return x(r!==null,"Anchor not found in Grid"),x(i!==null,"Focus not found in Grid"),[n,r,i]}function Vu(o,e,t){let n=[],r=null,i=null;function s(d,m,f){let c={cell:f,startColumn:m,startRow:d},u=f.__rowSpan,p=f.__colSpan;for(let g=0;g<u;g++){n[d+g]===void 0&&(n[d+g]=[]);for(let h=0;h<p;h++)n[d+g][m+h]=c}e!==null&&e.is(f)&&(r=c),t!==null&&t.is(f)&&(i=c)}function l(d,m){return n[d]===void 0||n[d][m]===void 0}let a=o.getChildren();for(let d=0;d<a.length;d++){let m=a[d];x(Q(m),"Expected GridNode children to be TableRowNode");let f=m.getChildren(),c=0;for(let u of f){for(x(v(u),"Expected TableRowNode children to be TableCellNode");!l(d,c);)c++;s(d,c,u),c+=u.__colSpan}}return[n,r,i]}function Le(o){let e;if(o instanceof Qt)e=o;else if("__type"in o){let r=H(o,v);x(v(r),"Expected to find a parent TableCellNode"),e=r}else{let r=H(o.getNode(),v);x(v(r),"Expected to find a parent TableCellNode"),e=r}let t=e.getParent();x(Q(t),"Expected TableCellNode to have a parent TableRowNode");let n=t.getParent();return x(K(n),"Expected TableRowNode to have a parent GridNode"),[e,t,n]}function Ui(o){let[e,,t]=Le(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let d=n[l].getChildren(),m=0;for(let f=0;f<d.length;f++){for(;s[l][m];)m++;let c=d[f],u=c.__rowSpan||1,p=c.__colSpan||1;for(let g=0;g<u;g++)for(let h=0;h<p;h++)s[l+g][m+h]=c;if(e===c)return{colSpan:p,columnIndex:m,rowIndex:l,rowSpan:u};m+=p}}return null}var zi=class o{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return z(e)?this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus):!1}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new o(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.focus.getNode();x(E(t),"Expected TableSelection focus to be an ElementNode"),Ao(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){let e=J(this.anchor.key);x(v(e),"Expected TableSelection anchor to be (or a child of) TableCellNode");let t=Ui(e);x(t!==null,"getCellRect: expected to find AnchorNode");let n=J(this.focus.key);x(v(n),"Expected TableSelection focus to be (or a child of) TableCellNode");let r=Ui(n);x(r!==null,"getCellRect: expected to find focusCellNode");let i=Math.min(t.columnIndex,r.columnIndex),s=Math.max(t.columnIndex,r.columnIndex),l=Math.min(t.rowIndex,r.rowIndex),a=Math.max(t.rowIndex,r.rowIndex);return{fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this.anchor.getNode(),n=this.focus.getNode(),r=H(t,v),i=H(n,v);x(v(r),"Expected TableSelection anchor to be (or a child of) TableCellNode"),x(v(i),"Expected TableSelection focus to be (or a child of) TableCellNode");let s=r.getParent();x(Q(s),"Expected anchorCell to have a parent TableRowNode");let l=s.getParent();x(K(l),"Expected tableNode to have a parent TableNode");let a=i.getParents()[1];if(a!==l){if(l.isParentOf(i)){let O=a.getParent();x(O!=null,"Expected focusCellParent to have a parent"),this.set(this.tableKey,i.getKey(),O.getKey())}else{let O=l.getParent();x(O!=null,"Expected gridParent to have a parent"),this.set(this.tableKey,O.getKey(),i.getKey())}return this.getNodes()}let[d,m,f]=tt(l,r,i),c=Math.min(m.startColumn,f.startColumn),u=Math.min(m.startRow,f.startRow),p=Math.max(m.startColumn+m.cell.__colSpan-1,f.startColumn+f.cell.__colSpan-1),g=Math.max(m.startRow+m.cell.__rowSpan-1,f.startRow+f.cell.__rowSpan-1),h=c,C=u,N=c,L=u;function M(O){let{cell:R,startColumn:P,startRow:k}=O;c=Math.min(c,P),u=Math.min(u,k),p=Math.max(p,P+R.__colSpan-1),g=Math.max(g,k+R.__rowSpan-1)}for(;c<h||u<C||p>N||g>L;){if(c<h){let O=L-C,R=h-1;for(let P=0;P<=O;P++)M(d[C+P][R]);h=R}if(u<C){let O=N-h,R=C-1;for(let P=0;P<=O;P++)M(d[R][h+P]);C=R}if(p>N){let O=L-C,R=N+1;for(let P=0;P<=O;P++)M(d[C+P][R]);N=R}if(g>L){let O=N-h,R=L+1;for(let P=0;P<=O;P++)M(d[R][h+P]);L=R}}let S=[l],A=null;for(let O=u;O<=g;O++)for(let R=c;R<=p;R++){let{cell:P}=d[O][R],k=P.getParent();x(Q(k),"Expected TableCellNode parent to be a TableRowNode"),k!==A&&S.push(k),S.push(P,...dx(P)),A=k}return st()||(this._cachedNodes=S),S}getTextContent(){let e=this.getNodes().filter(n=>v(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
+`:" ")}return t}};function z(o){return o instanceof zi}function Wi(){let o=De("root",0,"element"),e=De("root",0,"element");return new zi("root",o,e)}function dx(o){let e=[],t=[o];for(;t.length>0;){let n=t.pop();x(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&t.unshift(...n.getChildren()),n!==o&&e.push(n)}return e}var $r=class{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.trackTable(),this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(e=>e())}trackTable(){let e=new MutationObserver(t=>{this.editor.update(()=>{let n=!1;for(let i=0;i<t.length;i++){let a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){n=!0;break}}if(!n)return;let r=this.editor.getElementByKey(this.tableNodeKey);if(!r)throw new Error("Expected to find TableElement in DOM");this.table=Xo(r)})});this.editor.update(()=>{let t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=Xo(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=e.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=Xo(n);Ir(e,r,null),Y(null),e.dispatchCommand(we,void 0)})}enableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Di(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Te(t,e._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(e){if(e!==null&&e.tableKey===this.tableNodeKey){let t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Ir(t,this.table,this.tableSelection)}else e==null?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){let n=this.editor;n.update(()=>{let r=J(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=e.x,l=e.y;if(this.focusCell=e,this.anchorCell!==null){let a=oa(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||t))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(s===this.focusX&&l===this.focusY)return;if(this.focusX=s,this.focusY=l,this.isHighlightingCells){let a=ee(e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&v(a)&&r.is(bo(a))){let d=a.getKey();this.tableSelection=this.tableSelection.clone()||Wi(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(we,void 0),Ir(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update(()=>{let t=ee(e.elem);if(v(t)){let n=t.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():Wi(),this.anchorCellNodeKey=n}})}formatCells(e){this.editor.update(()=>{let t=T();z(t)||x(!1,"Expected grid selection");let n=Uo(),r=n.anchor,i=n.focus;t.getNodes().forEach(s=>{v(s)&&s.getTextContentSize()!==0&&(r.set(s.getKey(),0,"element"),i.set(s.getKey(),s.getChildrenSize(),"element"),n.formatText(e))}),Y(t),this.editor.dispatchCommand(we,void 0)})}clearText(){let e=this.editor;e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=T();z(n)||x(!1,"Expected grid selection");let r=n.getNodes().filter(v);if(r.length===this.table.columns*this.table.rows){t.selectPrevious(),t.remove(),F().selectStart();return}r.forEach(i=>{if(E(i)){let s=I(),l=q();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),Ir(e,this.table,null),Y(null),e.dispatchCommand(we,void 0)})}};var cx="__lexicalTableSelection",oa=o=>fe?(o||window).getSelection():null,ux=o=>(o.buttons&1)===1;function ia(o,e,t,n){let r=t.getRootElement();if(r===null)throw new Error("No root element.");let i=new $r(t,o.getKey()),s=t._window||window;fx(e,i);let l=()=>{let c=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u)},u=p=>{setTimeout(()=>{if(!ux(p)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);return}let g=ra(p.target);g!==null&&(i.anchorX!==g.x||i.anchorY!==g.y)&&(p.preventDefault(),i.setFocusCellForSelection(g))},0)};return{onMouseMove:u,onMouseUp:c}};e.addEventListener("mousedown",c=>{setTimeout(()=>{if(c.button!==0||!s)return;let u=ra(c.target);u!==null&&(jo(c),i.setAnchorCellForSelection(u));let{onMouseUp:p,onMouseMove:g}=l();i.isSelecting=!0,s.addEventListener("mouseup",p),s.addEventListener("mousemove",g)},0)});let a=c=>{c.button===0&&t.update(()=>{let u=T(),p=c.target;z(u)&&u.tableKey===i.tableNodeKey&&r.contains(p)&&i.clearHighlight()})};s.addEventListener("mousedown",a),i.listenersToRemove.add(()=>s.removeEventListener("mousedown",a)),i.listenersToRemove.add(t.registerCommand(Ft,c=>Pr(t,c,"down",o,i),We)),i.listenersToRemove.add(t.registerCommand(Bt,c=>Pr(t,c,"up",o,i),We)),i.listenersToRemove.add(t.registerCommand(wo,c=>Pr(t,c,"backward",o,i),We)),i.listenersToRemove.add(t.registerCommand(Mo,c=>Pr(t,c,"forward",o,i),We)),i.listenersToRemove.add(t.registerCommand(vo,c=>{let u=T();if(z(u)){let p=H(u.focus.getNode(),v);if(v(p))return jo(c),p.selectEnd(),!0}return!1},We));let d=c=>()=>{let u=T();if(!Go(u,o))return!1;if(z(u))return i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),A=>v(A));if(!v(p))return!1;let g=u.anchor.getNode(),h=u.focus.getNode(),C=o.isParentOf(g),N=o.isParentOf(h);if(C&&!N||N&&!C)return i.clearText(),!0;let M=H(u.anchor.getNode(),A=>E(A)),S=M&&H(M,A=>E(A)&&v(A.getParent()));if(!E(S)||!E(M))return!1;if(c===it&&S.getPreviousSibling()===null)return!0}return!1};[Ct,it,Ye].forEach(c=>{i.listenersToRemove.add(t.registerCommand(c,d(c),Re))});let m=c=>{let u=T();if(!Go(u,o)){let p=u?u.getNodes():null;if(p){let g=p.find(h=>K(h)&&h.getKey()===i.tableNodeKey);if(K(g)){if(!g.getParent())return!1;g.remove()}}return!1}if(z(u))return c&&(c.preventDefault(),c.stopPropagation()),i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1};i.listenersToRemove.add(t.registerCommand(Ht,m,Re)),i.listenersToRemove.add(t.registerCommand(Kt,m,Re)),i.listenersToRemove.add(t.registerCommand(ao,c=>{let u=T();if(u){if(!(z(u)||_(u)))return!1;In(t,pt(c,ClipboardEvent)?c:null,Ii(u));let p=m(c);return _(u)&&u.removeText(),p}return!1},Re)),i.listenersToRemove.add(t.registerCommand(Ne,c=>{let u=T();if(!Go(u,o))return!1;if(z(u))return i.formatCells(c),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1},Re)),i.listenersToRemove.add(t.registerCommand(rt,c=>{let u=T();if(!Go(u,o))return!1;if(z(u))return i.clearHighlight(),!1;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1;if(typeof c=="string"){let g=ju(t,u,o);if(g)return Gu(g,o,[q(c)]),!0}}return!1},Re)),n&&i.listenersToRemove.add(t.registerCommand(Do,c=>{let u=T();if(!_(u)||!u.isCollapsed()||!Go(u,o))return!1;let p=Yi(u.anchor.getNode());if(p===null)return!1;jo(c);let g=o.getCordsFromCellNode(p,i.table);return Ju(i,o,g.x,g.y,c.shiftKey?"backward":"forward"),!0},Re)),i.listenersToRemove.add(t.registerCommand(ir,c=>o.isSelected(),We));function f(c){let u=o.getCordsFromCellNode(c,i.table);return o.getDOMCellFromCordsOrThrow(u.x,u.y,i.table)}return i.listenersToRemove.add(t.registerCommand(er,c=>{let{nodes:u,selection:p}=c,g=p.getStartEndPoints(),h=z(p),N=_(p)&&H(p.anchor.getNode(),Pe=>v(Pe))!==null&&H(p.focus.getNode(),Pe=>v(Pe))!==null||h;if(u.length!==1||!K(u[0])||!N||g===null)return!1;let[L]=g,M=u[0],S=M.getChildren(),A=M.getFirstChildOrThrow().getChildrenSize(),O=M.getChildrenSize(),R=H(L.getNode(),Pe=>v(Pe)),P=R&&H(R,Pe=>Q(Pe)),k=P&&H(P,Pe=>K(Pe));if(!v(R)||!Q(P)||!K(k))return!1;let W=P.getIndexWithinParent(),ie=Math.min(k.getChildrenSize()-1,W+O-1),an=R.getIndexWithinParent(),td=Math.min(P.getChildrenSize()-1,an+A-1),ah=Math.min(an,td),dh=Math.min(W,ie),ch=Math.max(an,td),uh=Math.max(W,ie),fh=k.getChildren(),od=0;for(let Pe=dh;Pe<=uh;Pe++){let nd=fh[Pe];if(!Q(nd))return!1;let rd=S[od];if(!Q(rd))return!1;let mh=nd.getChildren(),ph=rd.getChildren(),id=0;for(let vs=ah;vs<=ch;vs++){let Jr=mh[vs];if(!v(Jr))return!1;let sd=ph[id];if(!v(sd))return!1;let gh=Jr.getChildren();sd.getChildren().forEach(dn=>{y(dn)&&I().append(dn),Jr.append(dn)}),gh.forEach(dn=>dn.remove()),id++}od++}return!0},Re)),i.listenersToRemove.add(t.registerCommand(we,()=>{let c=T(),u=ze();if(_(c)){let{anchor:p,focus:g}=c,h=p.getNode(),C=g.getNode(),N=Yi(h),L=Yi(C),M=!!(N&&o.is(bo(N))),S=!!(L&&o.is(bo(L))),A=M!==S,O=M&&S,R=c.isBackward();if(A){let P=c.clone();if(S){let[k]=tt(o,L,L),W=k[0][0].cell,ie=k[k.length-1].at(-1).cell;P.focus.set(R?W.getKey():ie.getKey(),R?W.getChildrenSize():ie.getChildrenSize(),"element")}Y(P),Xu(t,i)}else O&&(N.is(L)||(i.setAnchorCellForSelection(f(N)),i.setFocusCellForSelection(f(L),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:P,onMouseMove:k}=l();i.isSelecting=!0,s.addEventListener("mouseup",P),s.addEventListener("mousemove",k)},0)))}else if(c&&z(c)&&c.is(u)&&c.tableKey===o.getKey()){let p=oa(t._window);if(p&&p.anchorNode&&p.focusNode){let g=ee(p.focusNode),h=g&&!o.is(bo(g)),C=ee(p.anchorNode),N=C&&o.is(bo(C));if(h&&N&&p.rangeCount>0){let L=wl(p,t);L&&(L.anchor.set(o.getKey(),c.isBackward()?o.getChildrenSize():0,"element"),p.removeAllRanges(),Y(L))}}}return c&&!c.is(u)&&(z(c)||z(u))&&i.tableSelection&&!i.tableSelection.is(u)?(z(c)&&c.tableKey===i.tableNodeKey?i.updateTableTableSelection(c):!z(c)&&z(u)&&u.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?mx(t,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&Xu(t,i),!1)},Re)),i.listenersToRemove.add(t.registerCommand(Pt,()=>{let c=T();if(!_(c)||!c.isCollapsed()||!Go(c,o))return!1;let u=ju(t,c,o);return u?(Gu(u,o),!0):!1},Re)),i}function fx(o,e){o[cx]=e}function ra(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode}return null}function Xo(o){let e=[],t={columns:0,domRows:e,rows:0},n=o.firstChild,r=0,i=0;for(e.length=0;n!=null;){let s=n.nodeName;if(s==="TD"||s==="TH"){let d=n,m={elem:d,hasBackgroundColor:d.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=m;let f=e[i];f===void 0&&(f=e[i]=[]),f[r]=m}else{let d=n.firstChild;if(d!=null){n=d;continue}}let l=n.nextSibling;if(l!=null){r++,n=l;continue}let a=n.parentNode;if(a!=null){let d=a.nextSibling;if(d==null)break;i++,r=0,n=d}}return t.columns=r+1,t.rows=i+1,t}function Ir(o,e,t){let n=new Set(t?t.getNodes():[]);sa(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,Qu(o,r)):(r.highlighted=!1,ef(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function sa(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=ee(s.elem);l!==null&&e(s,l,{x:i,y:n})}}}function Xu(o,e){e.disableHighlightStyle(),sa(e.table,t=>{t.highlighted=!0,Qu(o,t)})}function mx(o,e){e.enableHighlightStyle(),sa(e.table,t=>{let n=t.elem;t.highlighted=!1,ef(o,t),n.getAttribute("style")||n.removeAttribute("style")})}var Ju=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)?qi(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?qi(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),!0;case"up":return n!==0?qi(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),!1):e.selectPrevious(),!0;case"down":return n!==o.table.rows-1?qi(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),!0):e.selectNext(),!0;default:return!1}},px=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)&&o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t+(i?1:-1),n,o.table)),!0;case"up":return n!==0?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n-1,o.table)),!0):!1;case"down":return n!==o.table.rows-1?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n+1,o.table)),!0):!1;default:return!1}};function Go(o,e){if(_(o)||z(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return!1}function qi(o,e){e?o.selectStart():o.selectEnd()}var na="172,206,247";function Qu(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?t.style.setProperty("background-color",`rgb(${na})`):t.style.setProperty("background-image",`linear-gradient(to right, rgba(${na},0.85), rgba(${na},0.85))`),t.style.setProperty("caret-color","transparent")}function ef(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null&&t.style.removeProperty("background-color"),t.style.removeProperty("background-image"),t.style.removeProperty("caret-color")}function Yi(o){let e=H(o,v);return v(e)?e:null}function bo(o){let e=H(o,K);return K(e)?e:null}function Pr(o,e,t,n,r){if((t==="up"||t==="down")&&gx(o))return!1;let i=T();if(!Go(i,n)){if(_(i)){if(i.isCollapsed()&&t==="backward"){let s=i.anchor.type,l=i.anchor.offset;if(s!=="element"&&!(s==="text"&&l===0))return!1;let a=i.anchor.getNode();if(!a)return!1;let d=H(a,f=>E(f)&&!f.isInline());if(!d)return!1;let m=d.getPreviousSibling();return!m||!K(m)?!1:(jo(e),m.selectEnd(),!0)}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(me(s)){let l=i.getNodes()[0];if(l){let a=H(l,v);if(a&&n.isParentOf(a)){let d=n.getFirstDescendant(),m=n.getLastDescendant();if(!d||!m)return!1;let[f]=Le(d),[c]=Le(m),u=n.getCordsFromCellNode(f,r.table),p=n.getCordsFromCellNode(c,r.table),g=n.getDOMCellFromCordsOrThrow(u.x,u.y,r.table),h=n.getDOMCellFromCordsOrThrow(p.x,p.y,r.table);return r.setAnchorCellForSelection(g),r.setFocusCellForSelection(h,!0),!0}}return!1}else{let l=H(s,d=>E(d)&&!d.isInline());if(!l)return!1;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(K(a)&&r.tableNodeKey===a.getKey()){let d=a.getFirstDescendant(),m=a.getLastDescendant();if(!d||!m)return!1;let[f]=Le(d),[c]=Le(m),u=i.clone();return u.focus.set((t==="up"?f:c).getKey(),t==="up"?0:c.getChildrenSize(),"element"),Y(u),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),d=H(l.getNode(),v);if(!v(a)||!a.is(d))return!1;let m=bo(a);if(m!==n&&m!=null){let N=o.getElementByKey(m.getKey());if(N!=null)return r.table=Xo(N),Pr(o,e,t,m,r)}if(t==="backward"||t==="forward"){let N=s.type,L=s.offset,M=s.getNode();if(!M)return!1;let S=i.getNodes();return S.length===1&&B(S[0])?!1:hx(N,L,M,t)?Ex(e,M,n,t):!1}let f=o.getElementByKey(a.__key),c=o.getElementByKey(s.key);if(c==null||f==null)return!1;let u;if(s.type==="element")u=c.getBoundingClientRect();else{let N=window.getSelection();if(N===null||N.rangeCount===0)return!1;u=N.getRangeAt(0).getBoundingClientRect()}let p=t==="up"?a.getFirstChild():a.getLastChild();if(p==null)return!1;let g=o.getElementByKey(p.__key);if(g==null)return!1;let h=g.getBoundingClientRect();if(t==="up"?h.top>u.top-u.height:u.bottom+u.height>h.bottom){jo(e);let N=n.getCordsFromCellNode(a,r.table);if(e.shiftKey){let L=n.getDOMCellFromCordsOrThrow(N.x,N.y,r.table);r.setAnchorCellForSelection(L),r.setFocusCellForSelection(L,!0)}else return Ju(r,n,N.x,N.y,t);return!0}}else if(z(i)){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),d=H(l.getNode(),v),[m]=i.getNodes(),f=o.getElementByKey(m.getKey());if(!v(a)||!v(d)||!K(m)||f==null)return!1;r.updateTableTableSelection(i);let c=Xo(f),u=n.getCordsFromCellNode(a,c),p=n.getDOMCellFromCordsOrThrow(u.x,u.y,c);if(r.setAnchorCellForSelection(p),jo(e),e.shiftKey){let g=n.getCordsFromCellNode(d,c);return px(r,m,g.x,g.y,t)}else d.selectEnd();return!0}return!1}function jo(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function gx(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":!1}function hx(o,e,t,n){return Nx(o,t,n)||xx(o,e,t,n)}function Nx(o,e,t){return o==="element"&&(t==="backward"?e.getPreviousSibling()===null:e.getNextSibling()===null)}function xx(o,e,t,n){let r=H(t,s=>E(s)&&!s.isInline());if(!r)return!1;let i=n==="backward"?e===0:e===t.getTextContentSize();return o==="text"&&i&&(n==="backward"?r.getPreviousSibling()===null:r.getNextSibling()===null)}function Ex(o,e,t,n){let r=H(e,v);if(!v(r))return!1;let[i,s]=tt(t,r,r);if(!Tx(i,s,n))return!1;let l=Cx(e,n,t);return!l||K(l)?!1:(jo(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function Tx(o,e,t){let n=o[0][0],r=o[o.length-1][o[0].length-1],{startColumn:i,startRow:s}=e;return t==="backward"?i===n.startColumn&&s===n.startRow:i===r.startColumn&&s===r.startRow}function Cx(o,e,t){let n=H(o,i=>E(i)&&!i.isInline());if(!n)return;let r=e==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&K(r)?r:e==="backward"?t.getPreviousSibling():t.getNextSibling()}function Gu(o,e,t){let n=I();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd()}function ju(o,e,t){let n=t.getParent();if(!n)return;let r=o.getElementByKey(n.getKey());if(!r)return;let i=window.getSelection();if(!i||i.anchorNode!==r)return;let s=H(e.anchor.getNode(),h=>v(h));if(!s)return;let l=H(s,h=>K(h));if(!K(l)||!l.is(t))return;let[a,d]=tt(t,s,s),m=a[0][0],f=a[a.length-1][a[0].length-1],{startRow:c,startColumn:u}=d,p=c===m.startRow&&u===m.startColumn,g=c===f.startRow&&u===f.startColumn;return p?"first":g?"last":void 0}function _x(o){return o.map(e=>{if(y(e)){let t=I();return t.append(e),t}return e})}function yo(o,e){let t=uu(e),n=Ai(o,t);return _x(n)}function At(o,e){for(let t of o.getParents())if(e(t))return t;return null}function la(o,e){e||(e=F());let t=[];for(let n of e.getChildren())o(n)&&t.push(n),E(n)&&t.push(...la(o,n));return t}function tf(o,e,t){let n=F().getChildren();for(let r of n){let i=o.getElementByKey(r.__key);if(!i)continue;let s=i.getBoundingClientRect();if(t<=s.bottom)return r}return null}function Jo(o){let e=t=>(E(t)||B(t))&&!t.isInline()&&!oe(t);return e(o)?o:H(o,e)}function of(o){let e=[],t=i=>{for(let s of i.getChildren())e.push(s.getKey()),E(s)&&t(s)},n=F();t(n);let r=Array.from(o);return r.sort((i,s)=>{let l=e.indexOf(i.getKey()),a=e.indexOf(s.getKey());return l-a}),r}function Br(o){return"__alignment"in o}function nf(o){return"__inset"in o}var rf=new WeakMap;function le(o){return rf.get(o)||null}function sf(o,e){rf.set(o,e)}function ae(o,e){return X(o,e)!==null}function X(o,e){if(!o)return null;for(let t of o.getNodes()){if(e(t))return t;let n=At(t,e);if(n)return n}return null}function lf(o){return X(o,y)}function af(o,e){if(!o)return!1;for(let t of o.getNodes())if(y(t)&&t.hasFormat(e))return!0;return!1}function Kn(o,e){let t=T(),n=t?Eu(t.getNodes()[0]):null;t&&o(n)?Mi(t,I):Mi(t,e)}function Qo(o,e=!0){aa([o],e)}function aa(o,e=!0){let t=T()?.getNodes()||[],n=t.length>0?Jo(t[0]):null;if(n)if(e)for(let r=o.length-1;r>=0;r--)n.insertAfter(o[r]);else for(let r of o)n.insertBefore(r);else F().append(...o)}function ot(o){let e=Ho();e.add(o.getKey()),Y(e)}function df(o){for(let e of o){if(y(e))return e;if(E(e)){let t=e.getChildren(),n=df(t);if(n!==null)return n}}return null}function cf(o){let e=[...o].reverse();for(let t of e){if(y(t))return t;if(E(t)){let n=[...t.getChildren()].reverse(),r=cf(n);if(r!==null)return r}}return null}function uf(o){if(o.length===0)return;let e=Uo(),t=df(o),n=cf(o);t&&n&&(e.setTextNodeRange(t,0,n,n.getTextContentSize()||0),Y(e))}function ff(o){let e=le(o);e&&window.requestAnimationFrame(()=>{o.update(()=>{Y(e.clone())})})}function Zi(o,e){if(!o)return!1;let t=e.getKey();for(let n of o.getNodes())if(n.getKey()===t)return!0;return!1}function Fr(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Br(n)&&n.getAlignment()===e)return!0;return!1}function da(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Ko(n)&&n.getDirection()===e)return!0;return!1}function Rt(o){if(!o)return[];let e=new Map;for(let t of o.getNodes()){let n=Jo(t);E(n)&&e.set(n.getKey(),n)}return Array.from(e.values())}var kt=class{constructor(e){this.rowCount=0;this.columnCount=0;this.cells=[];this.buildCellMap(e)}buildCellMap(e){let t=[],n=(a,d,m)=>{typeof t[d]>"u"&&(t[d]=[]),t[d][a]=m},r=(a,d)=>!!(t[d]&&t[d][a]),i=e.getChildren().filter(a=>Q(a));for(let a=0;a<i.length;a++){let m=i[a].getChildren().filter(c=>v(c)),f=0;for(let c=0;c<m.length;c++){let u=m[c],p=u.getColSpan()||1,g=u.getRowSpan()||1;for(let h=f;h<f+p;h++)for(let C=a;C<a+g;C++){for(;r(h,C);)f+=1,h+=1;n(h,C,u)}f+=p}}this.rowCount=t.length,this.columnCount=Math.max(...t.map(a=>a.length));let s=[],l=t[0][0];for(let a=0;a<this.rowCount;a++)for(let d=0;d<this.columnCount;d++)!t[a]||!t[a][d]?s.push(l):(s.push(t[a][d]),l=t[a][d]);this.cells=s}getCellAtPosition(e,t){let n=t*this.columnCount+e;if(n>=this.cells.length)throw new Error(`TableMap Error: Attempted to get cell ${n+1} of ${this.cells.length}`);return this.cells[n]}getCellsInRange(e){let t=Math.max(Math.min(e.fromX,e.toX),0),n=Math.min(Math.max(e.fromX,e.toX),this.columnCount-1),r=Math.max(Math.min(e.fromY,e.toY),0),i=Math.min(Math.max(e.fromY,e.toY),this.rowCount-1),s=new Set;for(let l=r;l<=i;l++)for(let a=t;a<=n;a++)s.add(this.getCellAtPosition(a,l));return[...s.values()]}getCellsInColumn(e){return this.getCellsInRange({fromX:e,toX:e,fromY:0,toY:this.rowCount-1})}getRangeForCell(e){let t=null,n=e.getKey();for(let r=0;r<this.rowCount;r++)for(let i=0;i<this.columnCount;i++){let s=r*this.columnCount+i;this.cells[s].getKey()===n&&(t===null?t={fromX:i,toX:i,fromY:r,toY:r}:(t.fromX=Math.min(t.fromX,i),t.toX=Math.max(t.toX,i),t.fromY=Math.min(t.fromY,r),t.toY=Math.max(t.toY,r)))}return t}};function ca(o){return At(o,K)}function pf(o){let e=gf(o),t=o.querySelector("colgroup"),n=[];return t&&(t.childElementCount===e?.childElementCount||!e)&&(n=mf(t)),n.filter(Boolean).length===0&&e&&(n=mf(e)),n}function gf(o){let e=o.querySelectorAll("tr"),t=0,n=null;for(let r of e)r.childElementCount>t&&(n=r,t=r.childElementCount);return n}function mf(o){return[...o.children].map(e=>bx(e))}function bx(o){let e=o.style.width||o.getAttribute("width");return e&&!Number.isNaN(Number(e))&&(e=e+"px"),e||""}function ua(o,e,t){let n=o.getChildren(),r=0;for(let s of n){let l=s.getChildren().length;l>r&&(r=l)}let i=o.getColWidths();(i.length===0||i.length<r)&&(i=Array(r).fill("")),e+1>i.length&&console.error(`Attempted to set table column width for column [${e}] but only ${i.length} columns found`),i[e]=ft(t),o.setColWidths(i)}function hf(o,e,t){let n=e.getColWidths();if(n.length>t&&n[t].endsWith("px"))return Number(n[t].replace("px",""));let r=o.getElementByKey(e.__key);if(r){let i=gf(r);if(i&&i.children.length>t)return i.children[t].clientWidth}return 0}function Nf(o){let e=o.getParent();if(!Q(e))return-1;let t=0,n=e.getChildren();for(let r of n){let i=r.getColSpan()||1;if(t+=i,r.getKey()===o.getKey())break}return t-1}function xf(o,e){let t=ca(o),n=Nf(o);t&&n>=0&&ua(t,n,e)}function Ef(o,e){let t=ca(e),n=Nf(e);if(!t)return"";let r=t.getColWidths();return r.length>n?r[n]:""}function en(o){if(z(o))return o.getNodes().filter(n=>v(n));let e=X(o,v);return e?[e]:[]}function Tf(o){let e=o.getShape(),t=en(o);if(t.length===0)return;let n=ca(t[0]);if(!n)return;let r=new kt(n),i=r.getCellAtPosition(e.toX,e.toY);if(!i)return;let s=e.toX+((i.getColSpan()||1)-1),l=e.toY+((i.getRowSpan()||1)-1),a=r.getCellsInRange({fromX:e.fromX,fromY:e.fromY,toX:s,toY:l});if(a.length===0)return;let d=a[0],m=Math.abs(e.fromX-s)+1,f=Math.abs(e.fromY-l)+1;for(let c=1;c<a.length;c++){let u=a[c];d.append(...u.getChildren()),u.remove()}d.setColSpan(m),d.setRowSpan(f)}function to(o){let e=en(o),t={};for(let n of e){let r=n.getParent();Q(r)&&(t[r.getKey()]=r)}return Object.values(t)}function xt(o){let e=en(o);if(e.length===0)return null;let t=At(e[0],K);return K(t)?t:null}function Cf(o){o.setColWidths([]);for(let e of o.getChildren()){if(!Q(e))continue;let t=e.getStyles();t.delete("height"),t.delete("width"),e.setStyles(t);let n=e.getChildren().filter(r=>v(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function _f(o){o.setColWidths([]),o.setStyles(new Map);for(let e of o.getChildren()){if(!Q(e))continue;e.setStyles(new Map);let t=e.getChildren().filter(n=>v(n));for(let n of t)n.setStyles(new Map),n.clearWidth()}}function fa(o,e){e:for(let t of o.getChildren()){if(!Q(t))continue;let n=t.getChildren();for(let r of n){if(!v(r))return;if(e(r)===!1)break e}}}function bf(o){let e=null;return fa(o,t=>{let n=t.getStyles().get("padding")||"";if(e===null&&(e=n),n!==e)return e=null,!1}),e||""}var Et=class o extends Dt{constructor(t){super(t);this.__colWidths=[];this.__styles=new Map}static getType(){return"table"}static clone(t){let n=new o(t.__key);return _o(t,n),n.__colWidths=t.__colWidths,n.__styles=new Map(t.__styles),n}static importDOM(){return{table:t=>({conversion:yx,priority:1})}}static importJSON(t){let n=kr();return et(t,n),n.setColWidths(t.colWidths),n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"table",version:1,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles)}}createDOM(t,n){let r=document.createElement("table");Te(r,t.theme.table),Qe(r,this);let i=this.getColWidths();if(i.length>0){let s=b("colgroup");for(let l of i){let a=b("col");l&&(a.style.width=l),s.append(a)}r.append(s)}for(let[s,l]of this.__styles.entries())r.style.setProperty(s,l);return r}updateDOM(t){return vt(t,this)||this.__colWidths.join(":")!==t.__colWidths.join(":")||this.__styles.size!==t.__styles.size||Array.from(this.__styles.values()).join(":")!==Array.from(t.__styles.values()).join(":")}exportDOM(t){return{...super.exportDOM(t),after:n=>{if(!n)return;let r=n.cloneNode(),i=document.createElement("tbody");if(pe(n))for(let s of Array.from(n.children))s.nodeName==="TR"?i.append(s):s.nodeName==="CAPTION"?r.insertBefore(s,r.firstChild):r.append(s);return r.append(i),r}}}canBeEmpty(){return!1}isShadowRoot(){return!0}setColWidths(t){let n=this.getWritable();n.__colWidths=t}getColWidths(){return this.getLatest().__colWidths}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}getCordsFromCellNode(t,n){let{rows:r,domRows:i}=n;for(let s=0;s<r;s++){let l=i[s];if(l==null)continue;let a=l.findIndex(d=>{if(!d)return;let{elem:m}=d;return ee(m)===t});if(a!==-1)return{x:a,y:s}}throw new Error("Cell not found in table.")}getDOMCellFromCords(t,n,r){let{domRows:i}=r,s=i[n];if(s==null)return null;let l=t<s.length?t:s.length-1,a=s[l];return a??null}getDOMCellFromCordsOrThrow(t,n,r){let i=this.getDOMCellFromCords(t,n,r);if(!i)throw new Error("Cell not found at cords.");return i}getCellNodeFromCords(t,n,r){let i=this.getDOMCellFromCords(t,n,r);if(i==null)return null;let s=ee(i.elem);return v(s)?s:null}getCellNodeFromCordsOrThrow(t,n,r){let i=this.getCellNodeFromCords(t,n,r);if(!i)throw new Error("Node at cords not TableCellNode.");return i}canSelectBefore(){return!0}canIndent(){return!1}};function yx(o){let e=kr();Je(o,e);let t=pf(o);return e.setColWidths(t),e.setStyles(Dn(o)),{node:e}}function kr(){return ne(new Et)}function K(o){return o instanceof Et}var Un=class o extends Z{constructor(){super(...arguments);this.__id=""}static getType(){return"horizontal-rule"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n}createDOM(t,n){let r=document.createElement("hr");return this.__id&&r.setAttribute("id",this.__id),r}updateDOM(t,n){return t.__id!==this.__id}static importDOM(){return{hr(t){return{conversion:n=>{let r=new o;return n.id&&r.setId(n.id),{node:r}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"horizontal-rule",version:1,id:this.__id}}static importJSON(t){let n=ma();return n.setId(t.id),n}};function ma(){return new Un}function yf(o){return o instanceof Un}var Sf=o=>(o.split(" ").filter(t=>t.startsWith("language-"))[0]||"").replace("language-",""),tn=class o extends wt{constructor(t="",n="",r){super(r);this.__id="";this.__language="";this.__code="";this.__language=t,this.__code=n}static getType(){return"code-block"}static clone(t){let n=new o(t.__language,t.__code,t.__key);return n.__id=t.__id,n}setLanguage(t){let n=this.getWritable();n.__language=t}getLanguage(){return this.getLatest().__language}setCode(t){let n=this.getWritable();n.__code=t}getCode(){return this.getLatest().__code}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"code",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){let r=b("pre",{id:this.__id||null},[b("code",{class:this.__language?`language-${this.__language}`:null},[this.__code])]);return b("div",{class:"editor-code-block-wrap"},[r])}updateDOM(t,n){let r=n.querySelector("code");return r&&(t.__language!==this.__language&&(r.className=this.__language?`language-${this.__language}`:""),t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__code!==this.__code&&(r.textContent=this.__code)),!1}exportDOM(t){return{element:this.createDOM(t._config,t).querySelector("pre")}}static importDOM(){return{pre(t){return{conversion:n=>{let r=n.querySelector("code"),i=Sf(n.className)||r&&Sf(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=Vi(i,s);return n.id&&l.setId(n.id),{node:l,after(a){return[]}}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(t){let n=Vi(t.language,t.code);return n.setId(t.id||""),n}};function Vi(o="",e=""){return new tn(o,e)}function Xi(o){return o instanceof tn}function Hr(o,e){let t=e.getCode(),n=e.getLanguage();window.$components.first("code-editor").open(t,n,"ltr",(i,s)=>{o.update(()=>{e.setCode(i),e.setLanguage(s)})},()=>{})}var So=class o extends wt{constructor(t,n,r){super(r);this.__id="";this.__drawingId="";this.__drawingUrl="";this.__drawingId=t,this.__drawingUrl=n}static getType(){return"diagram"}static clone(t){let n=new o(t.__drawingId,t.__drawingUrl);return n.__id=t.__id,n}setDrawingIdAndUrl(t,n){let r=this.getWritable();r.__drawingUrl=n,r.__drawingId=t}getDrawingIdAndUrl(){let t=this.getLatest();return{id:t.__drawingId,url:t.__drawingUrl}}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"diagram",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){return b("div",{id:this.__id||null,"drawio-diagram":this.__drawingId},[b("img",{src:this.__drawingUrl})])}updateDOM(t,n){let r=n.querySelector("img");return r&&(t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__drawingUrl!==this.__drawingUrl&&r.setAttribute("src",this.__drawingUrl),t.__drawingId!==this.__drawingId&&n.setAttribute("drawio-diagram",this.__drawingId)),!1}static importDOM(){return{div(t){return t.hasAttribute("drawio-diagram")?{conversion:n=>{let i=n.querySelector("img")?.getAttribute("src")||"",s=n.getAttribute("drawio-diagram")||"",l=zn(s,i);return n.id&&l.setId(n.id),{node:l}},priority:3}:null}}}exportJSON(){return{type:"diagram",version:1,id:this.__id,drawingId:this.__drawingId,drawingUrl:this.__drawingUrl}}static importJSON(t){let n=zn(t.drawingId,t.drawingUrl);return n.setId(t.id||""),n}};function zn(o="",e=""){return new So(o,e)}var Sx=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function Lx(o){let e={};for(let t of Object.keys(o))Sx.includes(t)&&(e[t]=o[t]);return e}function Lf(o,e){let t=Mf(o),n={};for(let i of e.attributes)n[i.name]=i.value;t.setAttributes(n);let r=[];if(o==="video"||o==="audio"){for(let i of e.children)if(i.tagName==="SOURCE"){let s=i.getAttribute("src"),l=i.getAttribute("type");s&&l&&r.push({src:s,type:l})}t.setSources(r)}return Je(e,t),t}var Lo=class o extends Z{constructor(t,n){super(n);this.__id="";this.__alignment="";this.__attributes={};this.__sources=[];this.__inset=0;this.__tag=t}static getType(){return"media"}static clone(t){let n=new o(t.__tag,t.__key);return n.__attributes=Object.assign({},t.__attributes),n.__sources=t.__sources.map(r=>Object.assign({},r)),n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setTag(t){let n=this.getWritable();n.__tag=t}getTag(){return this.getLatest().__tag}setAttributes(t){let n=this.getWritable();n.__attributes=Lx(t)}getAttributes(){return this.getLatest().__attributes}setSources(t){let n=this.getWritable();n.__sources=t}getSources(){return this.getLatest().__sources}setSrc(t){let n=Object.assign({},this.getAttributes());this.__tag==="object"?n.data=t:n.src=t,this.setAttributes(n)}setWidthAndHeight(t,n){let r=Object.assign({},this.getAttributes(),{width:t,height:n});this.setAttributes(r)}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}setHeight(t){if(!t)return;let n=Object.assign({},this.getAttributes(),{height:t});this.setAttributes(n)}getHeight(){let t=this.getLatest();return Wo(t.__attributes.height||"0")}setWidth(t){let n=Object.assign({},this.getAttributes(),{width:t});this.setAttributes(n)}getWidth(){let t=this.getLatest();return Wo(t.__attributes.width||"0")}isInline(){return!0}isParentRequired(){return!0}createInnerDOM(){let n=(this.__tag==="video"||this.__tag==="audio"?this.__sources:[]).map(i=>b("source",i)),r=b(this.__tag,this.__attributes,n);return Qe(r,this),r}createDOM(t,n){let r=this.createInnerDOM(),i=b("span",{class:r.className+" editor-media-wrap"},[r]);return i.addEventListener("click",s=>{n.update(()=>ot(this))}),i}updateDOM(t,n){if(t.__tag!==this.__tag||JSON.stringify(t.__sources)!==JSON.stringify(this.__sources)||JSON.stringify(t.__attributes)!==JSON.stringify(this.__attributes))return!0;let r=n.firstElementChild;return t.__id!==this.__id&&fu(r,"id",this.__id),t.__alignment!==this.__alignment&&(t.__alignment&&(n.classList.remove(`align-${t.__alignment}`),r.classList.remove(`align-${t.__alignment}`)),this.__alignment&&(n.classList.add(`align-${this.__alignment}`),r.classList.add(`align-${this.__alignment}`))),t.__inset!==this.__inset&&(n.style.paddingLeft=`${this.__inset}px`),!1}static importDOM(){let t=n=>r=>({conversion:i=>({node:Lf(n,i)}),priority:3});return{iframe:t("iframe"),embed:t("embed"),object:t("object"),video:t("video"),audio:t("audio")}}exportDOM(t){return{element:this.createInnerDOM()}}exportJSON(){return{...super.exportJSON(),type:"media",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset,tag:this.__tag,attributes:this.__attributes,sources:this.__sources}}static importJSON(t){let n=Mf(t.tag);return et(t,n),n}};function Mf(o){return new Lo(o)}function wf(o){let n=new DOMParser().parseFromString(`<body>${o}</body>`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?Lf(r,n):null}var Mx=[{regex:/.*?youtu\.be\/([\w\-_\?&=.]+)/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"},{regex:/.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,w:560,h:314,url:"https://www.youtube.com/embed/$2?$4"},{regex:/.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"}],wx=["mp4","mpeg","m4v","m4p","mov"],vx=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],Dx=["html","htm","php","asp","aspx",""];function vf(o){for(let s of Mx)if(o.match(s.regex)){let a=o.replace(s.regex,s.url),d=new Lo("iframe");return d.setSrc(a),d.setHeight(s.h),d.setWidth(s.w),d}let e="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();wx.includes(r)?e="video":vx.includes(r)?e="audio":r&&!Dx.includes(r)&&(e="embed");let i=new Lo(e);return i.setSrc(o),i}function oo(o){return o instanceof Lo}var Yn=class o extends Dt{static getType(){return"heading"}static clone(e){let t=new o(e.__tag,e.__key);return _o(e,t),t}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){let t=this.__tag,n=document.createElement(t),i=e.theme.heading;if(i!==void 0){let s=i[t];Te(n,s)}return Qe(n,this),n}updateDOM(e,t){return vt(e,this)}static importDOM(){return{h1:e=>({conversion:Wn,priority:0}),h2:e=>({conversion:Wn,priority:0}),h3:e=>({conversion:Wn,priority:0}),h4:e=>({conversion:Wn,priority:0}),h5:e=>({conversion:Wn,priority:0}),h6:e=>({conversion:Wn,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=qn(e.tag);return et(e,t),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){let n=e?e.anchor.offset:0,r=this.getLastDescendant(),s=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?I():qn(this.getTag()),l=this.getDirection();if(s.setDirection(l),this.insertAfter(s,t),n===0&&!this.isEmpty()&&e){let a=I();a.select(),this.replace(a,!0)}return s}collapseAtStart(){let e=this.isEmpty()?I():qn(this.getTag());return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}extractWithChild(){return!0}};function Wn(o){let e=o.nodeName.toLowerCase(),t=null;return(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6")&&(t=qn(e),Je(o,t)),{node:t}}function qn(o){return ne(new Yn(o))}function Zn(o){return o instanceof Yn}var Vn=class o extends Dt{static getType(){return"quote"}static clone(e){let t=new o(e.__key);return _o(e,t),t}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Te(t,e.theme.quote),Qe(t,this),t}updateDOM(e,t){return vt(e,this)}static importDOM(){return{blockquote:e=>({conversion:Ox,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=Gi();return et(e,t),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){let n=I(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){let e=I();return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function Gi(){return ne(new Vn)}function ji(o){return o instanceof Vn}function Ox(o){let e=Gi();return Je(o,e),{node:e}}var Xn=class o extends Z{static getType(){return"caption"}static clone(e){return new o(e.__key)}createDOM(e,t){return document.createElement("caption")}updateDOM(e,t,n){return!1}isParentRequired(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),type:"caption",version:1}}insertDOMIntoParent(e,t){return t.insertBefore(e,t.firstChild),!0}static importJSON(e){return pa()}static importDOM(){return{caption:e=>({conversion(t){return{node:pa()}},priority:0})}}};function pa(){return new Xn}function ga(o){return o instanceof Xn}function ha(o){for(let e of o.getChildren())if(ga(e))return!0;return!1}function Df(o,e=""){let t=pa(),n=q(e||" ");t.append(n),o.append(t)}function Of(){return[qo,Yn,Vn,Zo,Jt,Et,eo,Qt,Xn,Yo,Un,Fn,tn,So,Lo,ct,Pn]}function Af(o){let e=[Yo,tn,So],t=n=>{for(let[r,i]of n)if(i==="destroyed"){let s=o.manager.getDecoratorByNodeKey(r);s&&s.destroy(o)}};for(let n of e)o.editor.registerMutationListener(n,r=>t(r))}function Na(o){return"build"in o}var Me=class{constructor(){this.dom=null;this.context=null}setContext(e){this.context=e}getContext(){if(this.context===null)throw new Error("Attempted to use EditorUIContext before it has been set");return this.context}getDOMElement(){return this.dom||(this.dom=this.buildDOM()),this.dom}rebuildDOM(){let e=this.buildDOM();return this.dom?.replaceWith(e),this.dom=e,this.dom}trans(e){return this.getContext().translate(e)}updateState(e){}},te=class extends Me{constructor(t){super();this.children=[];this.children.push(...t)}buildDOM(){return b("div",{},this.getChildren().map(t=>t.getDOMElement()))}getChildren(){return this.children}addChildren(...t){this.children.push(...t)}removeChildren(...t){for(let n of t)this.removeChild(n)}removeChild(t){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,1)}updateState(t){for(let n of this.children)n.updateState(t)}setContext(t){super.setContext(t);for(let n of this.getChildren())n.setContext(t)}},Ji=class extends te{constructor(e,t){super(t),this.className=e}buildDOM(){return b("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};var w=class extends Me{constructor(t){super();this.active=!1;this.completedSetup=!1;this.disabled=!1;t.action!==void 0?this.definition=t:this.definition={...t,action(){return!1},isActive:()=>!1}}setContext(t){super.setContext(t),this.definition.setup&&!this.completedSetup&&(this.definition.setup(t,this),this.completedSetup=!0)}buildDOM(){let t=this.getLabel(),n=this.definition.format||"small",r=[];if(this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-icon"});s.innerHTML=this.definition.icon||"",r.push(s)}if(!this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-text"},[t]);r.push(s)}let i=b("button",{type:"button",class:`editor-button editor-button-${n}`,title:this.definition.icon?t:null,disabled:this.disabled?"true":null},r);return i.addEventListener("click",this.onClick.bind(this)),i}onClick(){this.definition.action(this.getContext(),this)}updateActiveState(t){let n=this.definition.isActive(t,this.getContext());this.setActiveState(n)}updateDisabledState(t){if(this.definition.isDisabled){let n=this.definition.isDisabled(t,this.getContext());this.toggleDisabled(n)}}setActiveState(t){this.active=t,this.dom?.classList.toggle("editor-button-active",this.active)}updateState(t){this.updateActiveState(t.selection),this.updateDisabledState(t.selection)}isActive(){return this.active}getLabel(){return this.trans(this.definition.label)}toggleDisabled(t){this.disabled=t,t?this.dom?.setAttribute("disabled","true"):this.dom?.removeAttribute("disabled")}};function Ax(o,e,t){let n=e.getBoundingClientRect(),r=o.getBoundingClientRect();if(o.style.position="fixed",t){let i=n.right;n.right+r.width>window.innerWidth&&(i=Math.max(n.left-r.width,0)),o.style.top=n.top+"px",o.style.left=i+"px"}else{let i=n.left+r.width>window.innerWidth,s=n.left;i&&(s=Math.max(n.right-r.width,0)),o.style.top=n.bottom+"px",o.style.left=s+"px"}}function Qi(o){let{menu:e,toggle:t,onClose:n,onOpen:r,showOnHover:i,showAside:s}=o,l=null,a=()=>{e.hidden=!0,e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),l&&window.removeEventListener("click",l),n&&n()},d=()=>{e.hidden=!1,Ax(e,t,!!s),l=f=>{!t.contains(f.target)&&!e.contains(f.target)&&a()},window.addEventListener("click",l),r&&r()},m=f=>{e.hasAttribute("hidden")?d():a()};t.addEventListener("click",m),i&&t.addEventListener("mouseenter",m),e.parentElement?.addEventListener("mouseleave",f=>{let c=t.getBoundingClientRect(),u=f.clientX<=c.right&&f.clientX>=c.left,p=f.clientY<=c.bottom&&f.clientY>=c.top;u&&p||a()})}var es=class extends te{buildDOM(){let e=this.getChildren().map(i=>i.getDOMElement()),t=b("div",{class:"editor-format-menu-dropdown editor-dropdown-menu editor-dropdown-menu-vertical",hidden:"true"},e),n=b("button",{class:"editor-format-menu-toggle editor-button",type:"button"},[this.trans("Formats")]),r=b("div",{class:"editor-format-menu editor-dropdown-menu-container"},[n,t]);return Qi({toggle:n,menu:t}),r}updateState(e){super.updateState(e);for(let t of this.children){if(t instanceof w&&t.isActive()){this.updateToggleLabel(t.getLabel());return}if(t instanceof te){for(let n of t.getChildren())if(n instanceof w&&n.isActive()){this.updateToggleLabel(n.getLabel());return}}}this.updateToggleLabel(this.trans("Formats"))}updateToggleLabel(e){let t=this.getDOMElement().querySelector("button");t&&(t.innerText=e)}};var qe=class extends w{constructor(e,t){super(t),this.previewSampleElement=e}buildDOM(){let e=super.buildDOM();e.innerHTML="";let t=b("span",{class:"editor-button-format-preview"},[this.getLabel()]),n=this.getStylesFromPreview();for(let r of Object.keys(n))t.style.setProperty(r,n[r]);return e.append(t),e}getStylesFromPreview(){let e=b("div",{style:"display: none",hidden:"true",class:"page-content"}),t=this.previewSampleElement.cloneNode();t.textContent=this.getLabel(),e.append(t),document.body.append(e);let n=["color","font-size","background-color","border-inline-start"],r={},i=window.getComputedStyle(t);for(let s of n)r[s]=i.getPropertyValue(s);return e.remove(),r}};var Rf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>';var ts=class extends w{buildDOM(){let e=super.buildDOM(),t=b("div",{class:"editor-menu-button-icon"});return t.innerHTML=Rf,e.append(t),e}};var kx={showOnHover:!1,direction:"horizontal",showAside:void 0,button:{label:"Menu"}},Ee=class extends te{constructor(t,n){super(n);this.open=!1;if(this.childItems=n,this.options=Object.assign({},kx,t),t.button instanceof w)this.button=t.button;else{let r=t.button.format==="long"?ts:w;this.button=new r({...t.button,action(){return!1},isActive:()=>this.open})}this.addChildren(this.button)}insertItems(...t){this.addChildren(...t),this.childItems.push(...t)}buildDOM(){let t=this.button.getDOMElement(),n=this.childItems.map(s=>s.getDOMElement()),r=b("div",{class:`editor-dropdown-menu editor-dropdown-menu-${this.options.direction}`,hidden:"true"},n),i=b("div",{class:"editor-dropdown-menu-container"},[t,r]);return Qi({toggle:t,menu:r,showOnHover:this.options.showOnHover,showAside:typeof this.options.showAside=="boolean"?this.options.showAside:this.options.direction==="vertical",onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),i}};var kf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"/></svg>';var If='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 32.5-156t88-127Q256-817 330-848.5T488-880q80 0 151 27.5t124.5 76q53.5 48.5 85 115T880-518q0 115-70 176.5T640-280h-74q-9 0-12.5 5t-3.5 11q0 12 15 34.5t15 51.5q0 50-27.5 74T480-80Zm0-400Zm-220 40q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120-160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm200 0q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120 160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17ZM480-160q9 0 14.5-5t5.5-13q0-14-15-33t-15-57q0-42 29-67t71-25h70q66 0 113-38.5T800-518q0-121-92.5-201.5T488-800q-136 0-232 93t-96 227q0 133 93.5 226.5T480-160Z"/></svg>';function $f(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function os(){return((1+Math.random())*65536|0).toString(16).substring(1)}var Pf=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],Bf="bs-lexical-custom-colors",on=class extends Me{constructor(e){super(),this.callback=e}buildDOM(){let e=os(),n=[...Pf,...this.getCustomColorChoices()].map(d=>b("div",{class:"editor-color-select-option",style:`background-color: ${d}`,"data-color":d,"aria-label":d})),r=b("div",{class:"editor-color-select-option","data-color":"",title:this.getContext().translate("Remove color")},[]);r.innerHTML=kf,n.push(r);let i=b("label",{class:"editor-color-select-option",for:`color-select-${e}`,"data-color":"",title:this.getContext().translate("Custom color")},[]);i.innerHTML=If,n.push(i);let s=b("input",{type:"color",hidden:"true",id:`color-select-${e}`});n.push(s),s.addEventListener("change",d=>{s.value&&(this.storeCustomColorChoice(s.value),this.setColor(s.value),this.rebuildDOM())});let l=[];for(let d=0;d<n.length;d+=5){let m=n.slice(d,d+5);l.push(b("div",{class:"editor-color-select-row"},m))}let a=b("div",{class:"editor-color-select"},l);return a.addEventListener("click",this.onClick.bind(this)),a}storeCustomColorChoice(e){if(Pf.includes(e))return;let t=this.getCustomColorChoices();t.includes(e)||(t.push(e),window.localStorage.setItem(Bf,JSON.stringify(t)))}getCustomColorChoices(){return JSON.parse(window.localStorage.getItem(Bf)||"[]")}onClick(e){let t=e.target.closest("[data-color]");if(!t)return;let n=t.dataset.color;this.setColor(n)}setColor(e){this.callback(e,this.getContext())}};var ns=class extends Me{buildDOM(){let t=[],n=[];for(let s=1;s<11;s++){let l=[];for(let a=1;a<11;a++){let d=b("div",{class:"editor-table-creator-cell","data-rows":String(s),"data-columns":String(a)});l.push(d),n.push(d)}t.push(b("div",{class:"editor-table-creator-row"},l))}let r=b("div",{class:"editor-table-creator-display"},["0 x 0"]),i=b("div",{class:"editor-table-creator-grid"},t);return i.addEventListener("mousemove",s=>{let l=s.target.closest(".editor-table-creator-cell");if(l){let a=Number(l.dataset.rows||0),d=Number(l.dataset.columns||0);this.updateGridSelection(a,d,n,r)}}),i.addEventListener("click",s=>{let l=s.target.closest(".editor-table-creator-cell");l&&this.onCellClick(l)}),i.addEventListener("mouseleave",s=>{this.updateGridSelection(0,0,n,r)}),b("div",{class:"editor-table-creator"},[i,r])}updateGridSelection(e,t,n,r){for(let i of n){let s=Number(i.dataset.rows)<=e&&Number(i.dataset.columns)<=t;i.classList.toggle("active",s)}r.textContent=`${e} x ${t}`}onCellClick(e){let t=Number(e.dataset.rows||0),n=Number(e.dataset.columns||0);if(t<1||n<1)return;let r=Math.min(Math.round(840/n),240),i=Array(n).fill(r+"px");this.getContext().editor.update(()=>{let s=jl(t,n,!1);s.setColWidths(i),Qo(s)})}};var Kr=class extends w{constructor(e,t){super(e),this.style=t}getColorBar(){let e=this.getDOMElement().querySelector("svg .editor-icon-color-bar");if(!e)throw new Error(`Could not find expected color bar in the icon for this ${this.definition.label} button`);return e}updateState(e){if(super.updateState(e),_(e.selection)){let t=Bl(e.selection,this.style);this.getColorBar().setAttribute("fill",t)}}};var Ff='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"/></svg>';var nt=class extends te{constructor(e,t){super(t),this.size=e,this.content=t,this.overflowButton=new Ee({button:{label:"More",icon:Ff}},[]),this.addChildren(this.overflowButton)}buildDOM(){let e=this.content.length>this.size?this.size-1:this.size,t=this.content.slice(0,e),n=this.content.slice(e),r=t.map(i=>i.getDOMElement());return n.length>0&&(this.removeChildren(...n),this.overflowButton.insertItems(...n),r.push(this.overflowButton.getDOMElement())),b("div",{class:"editor-overflow-container"},r)}};var xa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z"/></svg>';var rs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>';var Hf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>';var Kf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>';var Uf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>';var zf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>';var Wf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>';var qf='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>';var It=class extends Me{constructor(e){super(),this.definition=e}setValue(e){let t=this.getDOMElement().querySelector("input,select,textarea");this.definition.type==="checkbox"?t.checked=!!e:t.value=e,t.dispatchEvent(new Event("change"))}getName(){return this.definition.name}buildDOM(){let e=`editor-form-field-${this.definition.name}-${Date.now()}`,t;if(this.definition.type==="select"){let n=this.definition.valuesByLabel,i=Object.keys(n).map(s=>b("option",{value:n[s]},[this.trans(s)]));t=b("select",{id:e,name:this.definition.name,class:"editor-form-field-input"},i)}else this.definition.type==="textarea"?t=b("textarea",{id:e,name:this.definition.name,class:"editor-form-field-input"}):this.definition.type==="checkbox"?t=b("input",{id:e,name:this.definition.name,type:"checkbox",class:"editor-form-field-input-checkbox",value:"true"}):t=b("input",{id:e,name:this.definition.name,class:"editor-form-field-input"});return b("div",{class:"editor-form-field-wrapper"},[b("label",{class:"editor-form-field-label",for:e},[this.trans(this.definition.label)]),t])}},is=class extends te{constructor(t){let n=t.fields.map(r=>Na(r)?r.build():new It(r));super(n);this.onCancel=null;this.onSuccessfulSubmit=null;this.definition=t}setValues(t){for(let n of Object.keys(t)){let r=this.getFieldByName(n);r&&r.setValue(t[n])}}setOnCancel(t){this.onCancel=t}setOnSuccessfulSubmit(t){this.onSuccessfulSubmit=t}getFieldByName(t){let n=r=>{for(let i of r){if(i instanceof It&&i.getName()===t)return i;if(i instanceof te){let s=n(i.getChildren());if(s)return s}}return null};return n(this.getChildren())}buildDOM(){let t=b("button",{type:"button",class:"editor-form-action-secondary"},[this.trans("Cancel")]),n=b("form",{},[...this.children.map(r=>r.getDOMElement()),b("div",{class:"editor-form-actions"},[t,b("button",{type:"submit",class:"editor-form-action-primary"},[this.trans(this.definition.submitText)])])]);return n.addEventListener("submit",async r=>{r.preventDefault();let i=new FormData(n);await this.definition.action(i,this.getContext())&&this.onSuccessfulSubmit&&this.onSuccessfulSubmit()}),t.addEventListener("click",r=>{this.onCancel&&this.onCancel()}),n}},Ea=class extends te{constructor(e){let t=e.contents.map(n=>Na(n)?n.build():new It(n));super(t),this.definition=e,this.fields=t,this.id=$f()}getLabel(){return this.getContext().translate(this.definition.label)}getId(){return this.id}buildDOM(){return b("div",{class:"editor-form-tab-content",role:"tabpanel",id:`editor-tabpanel-${this.id}`,"aria-labelledby":`editor-tab-${this.id}`},this.fields.map(e=>e.getDOMElement()))}},nn=class extends te{constructor(t){let n=t.map(r=>new Ea(r));super(n);this.definitions=[];this.tabs=[];this.definitions=t,this.tabs=n}buildDOM(){let t=[],n=[],r=i=>{for(let s=0;s<t.length;s++)t[s].setAttribute("aria-selected",s===i?"true":"false");for(let s=0;s<n.length;s++)n[s].hidden=s!==i};for(let i of this.tabs){let s=b("button",{class:"editor-form-tab-control",type:"button",role:"tab",id:`editor-tab-${i.getId()}`,"aria-controls":`editor-tabpanel-${i.getId()}`},[i.getLabel()]);n.push(i.getDOMElement()),t.push(s),s.addEventListener("click",l=>{r(t.indexOf(s))})}return r(0),b("div",{class:"editor-form-tab-container"},[b("div",{class:"editor-form-tab-controls"},t),b("div",{class:"editor-form-tab-contents"},n)])}};var Yf=`<svg version="1.1" viewBox="0 -960 960 960" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">