react-reason-editor 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/{Attachment-DGzsbPZZ.js → Attachment-FN0H4pdR.js} +2 -2
- package/dist/Attachment.js +1 -1
- package/dist/BulletList.cjs +1 -1
- package/dist/{Callout-heY7R-Zu.js → Callout-C6kKHIbW.js} +2 -2
- package/dist/Callout.js +1 -1
- package/dist/{CodeBlock-B7Wklup8.js → CodeBlock-DLhI2Guf.js} +1 -1
- package/dist/{CodeBlock-D2OKvGCF.cjs → CodeBlock-zh4cX5EA.cjs} +1 -1
- package/dist/CodeBlock.cjs +1 -1
- package/dist/CodeBlock.js +1 -1
- package/dist/CodeView.cjs +1 -1
- package/dist/CodeView.js +1 -1
- package/dist/{Color-BxzxtvJH.cjs → Color-D5zLljFV.cjs} +1 -1
- package/dist/Color.cjs +1 -1
- package/dist/{Drawer-DxCO6TBr.cjs → Drawer-B0QvuSOf.cjs} +1 -1
- package/dist/{Drawer-Dunw22Q1.js → Drawer-bqo2XUCW.js} +12 -12
- package/dist/Drawer.cjs +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{Drawio-eqEGDkwW.js → Drawio-CIXM-WGy.js} +4 -4
- package/dist/Drawio.js +1 -1
- package/dist/{Emoji-BU-itkPp.js → Emoji-CTvSFbHz.js} +3 -3
- package/dist/Emoji.js +1 -1
- package/dist/FontFamily.js +2 -2
- package/dist/{Highlight-BeqLxfbY.cjs → Highlight-DQxtCrNN.cjs} +1 -1
- package/dist/Highlight.cjs +1 -1
- package/dist/{History-C6yBYB2w.js → History-PbMa-usl.js} +1 -1
- package/dist/History.js +1 -1
- package/dist/Image.js +1 -1
- package/dist/{ImageCropper-Dlz4nJQu.js → ImageCropper-CN_GzBBG.js} +5 -5
- package/dist/{ImageGif-D5Qw_Xf-.js → ImageGif-D9goI48J.js} +3 -3
- package/dist/ImageGif.js +1 -1
- package/dist/{ImportWord-BCcs3dYp.js → ImportWord-Bux3L57d.js} +1 -1
- package/dist/ImportWord.js +1 -1
- package/dist/{Indent-DpTPoZMk.js → Indent-fBwkYx_q.js} +1 -1
- package/dist/Indent.js +1 -1
- package/dist/{Katex-D_vF5gsD.cjs → Katex-B1xls7hE.cjs} +1 -1
- package/dist/{Katex-Bo_vfXrd.js → Katex-D2g86C-B.js} +3 -3
- package/dist/Katex.cjs +1 -1
- package/dist/Katex.js +1 -1
- package/dist/LineHeight.js +1 -1
- package/dist/{Link-C0cNnjXo.js → Link-Dpaom2jX.js} +1 -1
- package/dist/Link.js +1 -1
- package/dist/{Mention-DEkbeL04.js → Mention-D0HVk1SC.js} +1 -1
- package/dist/Mention.js +1 -1
- package/dist/{Mermaid-BB15qd24.cjs → Mermaid-3vSlkOlc.cjs} +1 -1
- package/dist/Mermaid-B3KGZMBo.js +5 -0
- package/dist/Mermaid.cjs +1 -1
- package/dist/Mermaid.js +1 -1
- package/dist/MoreMark.js +1 -1
- package/dist/OrderedList.cjs +1 -1
- package/dist/SearchAndReplace.cjs +1 -1
- package/dist/SearchAndReplace.js +1 -1
- package/dist/{SlashCommand-8LkH8bHy.js → SlashCommand-ZFZhrxKb.js} +1 -1
- package/dist/SlashCommand.js +1 -1
- package/dist/{Table-C9t-k9Qu.js → Table-6kM52sUH.js} +2 -2
- package/dist/Table.js +1 -1
- package/dist/TaskList.cjs +1 -1
- package/dist/{TextAlign-C75gn_OM.js → TextAlign-BKo82ocx.js} +1 -1
- package/dist/TextAlign.js +1 -1
- package/dist/TextDirection.js +1 -1
- package/dist/{Twitter-DyrQT0n4.cjs → Twitter-3yCP2UdP.cjs} +1 -1
- package/dist/{Twitter-D5UNfT-K.js → Twitter-D38giVew.js} +2 -2
- package/dist/Twitter.cjs +1 -1
- package/dist/Twitter.js +1 -1
- package/dist/{Video-_YlAC2R_.js → Video-DcfPDZLP.js} +3 -3
- package/dist/Video.js +1 -1
- package/dist/WordCount.js +1 -1
- package/dist/{bubble---c27x7L.js → bubble-4RecyKlX.js} +1 -1
- package/dist/bubble.cjs +1 -1
- package/dist/bubble.js +1 -1
- package/dist/editor-kit.cjs +1 -0
- package/dist/editor-kit.d.ts +13 -0
- package/dist/editor-kit.js +1 -0
- package/dist/editor-views/components/AlignToolbar.d.ts +4 -0
- package/dist/editor-views/components/BubbleMenus.d.ts +4 -0
- package/dist/editor-views/components/EditorContainer.d.ts +10 -0
- package/dist/editor-views/components/Header.d.ts +8 -0
- package/dist/editor-views/components/Toolbar.d.ts +26 -0
- package/dist/editor-views/components/constants.d.ts +14 -0
- package/dist/editor-views/components/extensions.d.ts +8 -0
- package/dist/editor-views/components/index.d.ts +9 -0
- package/dist/editor-views/config/baseKit.d.ts +7 -0
- package/dist/editor-views/config/editorConfig.d.ts +37 -0
- package/dist/editor-views/config/pluginRegistry.d.ts +43 -0
- package/dist/editorConfig-Cgs4P8O5.js +184 -0
- package/dist/editorConfig-CnzPmOCy.cjs +1 -0
- package/dist/html-to-docx.esm-DkztZsL5-BqrjWkoQ.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/reason-docs.cjs +1 -1
- package/dist/reason-docs.js +1 -1
- package/dist/{separator-BHN46aj5.cjs → separator-CXjMk9dM.cjs} +1 -1
- package/dist/src-73l1pSjp.js +463 -0
- package/dist/src-CF0U82SA.cjs +1 -0
- package/package.json +12 -2
- package/dist/Mermaid-DxpFRVu0.js +0 -5
- package/dist/html-to-docx.esm-DkztZsL5-DQYdhD3B.cjs +0 -1
- package/dist/src-C7k3RYxJ.js +0 -646
- package/dist/src-DYbBlAjR.cjs +0 -1
package/dist/bubble.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./rolldown-runtime-BeavJI0R.cjs"),e=require("./toggle-CRftKzl0.cjs"),n=require("./separator-BHN46aj5.cjs"),r=require("./locales-Dg9XL0yP.cjs"),i=require("./Icon-DQdA22_-.cjs"),s=require("./button-CYMsgP3Y.cjs"),o=require("./floating-ui.dom-D9FglguG.cjs"),l=require("./dialog-CxZ2oxD2.cjs"),c=require("./dropdown-menu-CVJhYAPA.cjs"),a=require("./input-AvqqajGM.cjs"),h=require("./label-DPSH3PiY.cjs"),d=require("./popover-DEGqjF2J.cjs"),u=require("./Callout-DOHjjQtT.cjs"),p=require("./textarea-BFbGcrSO.cjs"),f=require("./ImageCropper-BAWOk69J.cjs"),g=require("./events.constant-BkYOoqSk.cjs"),m=require("./useButtonProps-D2Hd5DbR.cjs"),x=require("./file-B1Z0XcVJ.cjs"),w=require("./Video-BSH5k6Jd.cjs"),y=require("./Drawio-Bx8zt_CW.cjs"),b=require("./Katex-D_vF5gsD.cjs"),v=require("./Column-I4gS_xKw.cjs"),S=require("./Drawer-DxCO6TBr.cjs"),k=require("./shortId-B25DIOpW.cjs"),C=require("./Iframe-DS5N9EFx.cjs"),E=require("./cdn-loader-D76eUWN7.cjs"),_=require("./LinkEditBlock-Or1HIYih.cjs"),A=require("./ImageGif-CWfgVc6e.cjs"),j=require("./Mermaid-BB15qd24.cjs"),D=require("./Table-B4KNW7Yq.cjs"),O=require("./Bold-M6IKTPME.cjs"),I=require("./Code-BsD1D1sK.cjs"),T=require("./Color-BxzxtvJH.cjs"),M=require("./Highlight-BeqLxfbY.cjs"),N=require("./Italic-Brjxxqsi.cjs"),R=require("./renderCommandListDefault-CykwYpTX.cjs"),z=require("./TextAlign-6ElUYI4_.cjs"),P=require("./TextUnderline-ofstnQx_.cjs"),B=require("./Twitter-DyrQT0n4.cjs"),L=require("./Clear.cjs"),U=require("./Indent-6tc8tB62.cjs"),F=require("./CodeBlock-D2OKvGCF.cjs");let $=require("@tiptap/react"),H=require("react");H=t.__toESM(H,1);let V=require("react/jsx-runtime"),q=require("lucide-react"),J=require("react-dom"),K=require("@tiptap/core"),W=require("@tiptap/pm/state"),G=require("@tiptap/pm/view"),X=require("@tiptap/pm/model"),Y=require("@tiptap/pm/tables"),Z=require("easydrawer"),Q=require("@tiptap/pm/commands");var tt=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:c,options:a}){var h;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:t,state:e,from:n,to:r})=>{const{doc:i,selection:s}=e,{empty:o}=s,l=!i.textBetween(n,r).length&&(0,K.isTextSelection)(e.selection),c=this.element.contains(document.activeElement);return!(!t.hasFocus()&&!c||o||l||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(t,e)=>{const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(t,n,r,e)},this.updateDelay))},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(h=null==a?void 0:a.scrollTarget)?h:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(o.flip("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(o.shift("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(o.offset("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(o.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(o.size("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(o.autoPlacement("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(o.hide("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(o.inline("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=null==(t=this.getReferencedVirtualElement)?void 0:t.call(this);if(i)return i;if(!(null==(n=null==(e=this.view)?void 0:e.dom)?void 0:n.parentNode))return;const s=(0,K.posToDOMRect)(this.view,r.from,r.to);let o={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(r instanceof W.NodeSelection){let t=this.view.nodeDOM(r.from);const e=t.dataset.nodeViewWrapper?t:t.querySelector("[data-node-view-wrapper]");e&&(t=e),t&&(o={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(r instanceof Y.CellSelection){const{$anchorCell:t,$headCell:e}=r,n=t?t.pos:e.pos,i=e?e.pos:t.pos,s=this.view.nodeDOM(n),l=this.view.nodeDOM(i);if(!s||!l)return;const c=s===l?s.getBoundingClientRect():function(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),s=Math.max(t.right,e.right)-i;return new DOMRect(i,n,s,r-n)}(s.getBoundingClientRect(),l.getBoundingClientRect());o={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&o.computePosition(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,s;this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(t,e);const i=!(null==e?void 0:e.selection.eq(t.state.selection)),s=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,i,s,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),o=Math.max(...i.map(t=>t.$to.pos));return(null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:s,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.getReferencedVirtualElement&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},et=t=>new W.Plugin({key:"string"==typeof t.pluginKey?new W.PluginKey(t.pluginKey):t.pluginKey,view:e=>new tt({view:e,...t})}),nt=(K.Extension.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[et({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:o,appendTo:l,shouldShow:c}){var a;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:t,state:e})=>{const{selection:n}=e,{$anchor:r,empty:i}=n,s=1===r.depth,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!(t.hasFocus()&&i&&s&&o&&this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(a=null==o?void 0:o.scrollTarget)?a:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return(0,K.getText)(t,{textSerializers:(0,K.getTextSerializersFromSchema)(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(o.flip("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(o.shift("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(o.offset("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(o.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(o.size("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(o.autoPlacement("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(o.hide("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(o.inline("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),o=Math.max(...i.map(t=>t.$to.pos));return null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:s,to:o})}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!(null==(e=null==(t=this.view)?void 0:t.dom)?void 0:e.parentNode))return;const{selection:n}=this.editor.state,r=(0,K.posToDOMRect)(this.view,n.from,n.to);o.computePosition({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,s;(null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate())})}update(t,e){const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}}),rt=t=>new W.Plugin({key:"string"==typeof t.pluginKey?new W.PluginKey(t.pluginKey):t.pluginKey,view:e=>new nt({view:e,...t})});K.Extension.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[rt({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function it(t,e){return null!=t?t:new W.PluginKey(e)}var st="undefined"!=typeof window?H.useLayoutEffect:H.useEffect,ot=new Set(["left","opacity","position","top","visibility","width"]),lt=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),ct=new Set(["children","className","style"]),at=new Set(["tabIndex"]),ht=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),dt={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function ut(t,e){return/^on[A-Z]/.test(t)&&"function"==typeof e}function pt(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ft(t){return at.has(t)}function gt(t,e,n){"tabIndex"!==e?t[e]=n:t.tabIndex=Number(n)}function mt(t,e,n){ot.has(e)||t.style.setProperty(pt(e),function(t,e){return"number"!=typeof e||0===e||t.startsWith("--")||lt.has(t)?String(e):`${e}px`}(e,n))}function xt(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(r=>{if(ct.has(r)||!function(t){return t.startsWith("aria-")||t.startsWith("data-")||ht.has(t)}(r)||ut(r,e[r])||ut(r,n[r]))return;const i=e[r],s=n[r];if(i===s)return;const o=function(t){return t.startsWith("aria-")||t.startsWith("data-"),t}(r);return null==s||!1===s?(ft(r)&&function(t,e){if("tabIndex"===e)return void t.removeAttribute("tabindex");const n=t[e];t[e]="boolean"!=typeof n&&("number"!=typeof n?"":0)}(t,r),void t.removeAttribute(o)):!0===s?(ft(r)&>(t,r,!0),void t.setAttribute(o,"")):void(ft(r)?gt(t,r,s):t.setAttribute(o,String(s)))})}function wt(t,e,n){const r=null!=e?e:{},i=null!=n?n:{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(e=>{const n=r[e],s=i[e];n!==s&&(null!=s?mt(t,e,s):function(t,e){ot.has(e)||t.style.removeProperty(pt(e))}(t,e))})}function yt(t,e,n){e.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)});const r=[];return Object.entries(n).forEach(([e,n])=>{if(!ut(e,n))return;const{eventName:i,options:s}=function(t){var e;const n=t.endsWith("Capture"),r=(n?t.slice(0,-7):t).slice(2);return{eventName:null!=(e=dt[r])?e:r.toLowerCase(),options:n?{capture:!0}:void 0}}(e),o=e=>{n(function(t,e){let n=e.defaultPrevented,r=!1;const i=Object.create(e);return Object.defineProperties(i,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),i}(t,e))};t.addEventListener(i,o,s),r.push({eventName:i,listener:o,options:s})}),r}function bt(t,e){const n=(0,H.useRef)({}),r=(0,H.useRef)([]);st(()=>{const i=n.current;return function(t,e,n){e!==n&&(n?t.className=n:t.removeAttribute("class"))}(t,i.className,e.className),wt(t,i.style,e.style),xt(t,i,e),r.current=yt(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)}),r.current=[]}},[t,e])}var vt=H.default.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:o,options:l,children:c,...a},h)=>{const d=(0,H.useRef)(document.createElement("div")),u=(0,H.useRef)(it(t,"bubbleMenu")).current;bt(d.current,a),"function"==typeof h?h(d.current):h&&(h.current=d.current);const{editor:p}=(0,$.useCurrentEditor)(),f=e||p,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:u,shouldShow:s,getReferencedVirtualElement:o,options:l},m=(0,H.useRef)(g);m.current=g;const[x,w]=(0,H.useState)(!1),y=(0,H.useRef)(!0);return(0,H.useEffect)(()=>{if(null==f?void 0:f.isDestroyed)return;if(!f)return;const t=d.current;t.style.visibility="hidden",t.style.position="absolute";const e=et({...m.current,editor:f,element:t});f.registerPlugin(e);const n=m.current.pluginKey;return y.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[f]),(0,H.useEffect)(()=>{x&&f&&!f.isDestroyed&&(y.current?y.current=!1:f.view.dispatch(f.state.tr.setMeta(u,{type:"updateOptions",options:m.current})))},[x,f,n,r,s,l,i,o,u]),(0,J.createPortal)(c,d.current)});H.default.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,options:o,children:l,...c},a)=>{const h=(0,H.useRef)(document.createElement("div")),d=(0,H.useRef)(it(t,"floatingMenu")).current;bt(h.current,c),"function"==typeof a?a(h.current):a&&(a.current=h.current);const{editor:u}=(0,$.useCurrentEditor)(),p=e||u,f={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:s,options:o},g=(0,H.useRef)(f);g.current=f;const[m,x]=(0,H.useState)(!1),w=(0,H.useRef)(!0);return(0,H.useEffect)(()=>{if(null==p?void 0:p.isDestroyed)return;if(!p)return;const t=h.current;t.style.visibility="hidden",t.style.position="absolute";const e=rt({...g.current,editor:p,element:t});p.registerPlugin(e);const n=g.current.pluginKey;return w.current=!0,x(!0),()=>{x(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[p]),(0,H.useEffect)(()=>{m&&p&&!p.isDestroyed&&(w.current?w.current=!1:p.view.dispatch(p.state.tr.setMeta(d,{type:"updateOptions",options:g.current})))},[m,p,n,r,s,o,i,d]),(0,J.createPortal)(l,h.current)});function St(t,e){const{state:n}=e,r=n.selection.$anchor;let i=!1;if(r.depth)for(let s=r.depth;s>0;s--)r.node(s).type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(r.before(s),r.after(s)).scrollIntoView()),i=!0);else{const r=n.selection.node;r&&r.type.name===t&&(e.chain().deleteSelection().run(),i=!0)}if(!i){const s=r.pos;if(s){const r=n.tr.doc.nodeAt(s);r&&r.type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(s,s+r.nodeSize)),i=!0)}}return i}var kt=[{value:"note",label:"Note",icon:"Info"},{value:"tip",label:"Tip",icon:"Lightbulb"},{value:"important",label:"Important",icon:"AlertCircle"},{value:"warning",label:"Warning",icon:"TriangleAlert"},{value:"caution",label:"Caution",icon:"OctagonAlert"}];function Ct(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`image-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateImage({width:r.IMAGE_SIZE[s]}),isActive:()=>t.isActive("image",{width:r.IMAGE_SIZE[s]})}}))}function Et(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`image-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateImageGif({width:r.IMAGE_SIZE[s]}),isActive:()=>t.isActive("image",{width:r.IMAGE_SIZE[s]})}}))}function _t(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImage?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function At(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageGif?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function jt(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageMermaid?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function Dt(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageDrawer?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function Ot(t){return[{type:"flex-start",icon:"AlignLeft",tooltip:"Align left"},{type:"center",icon:"AlignCenter",tooltip:"Align center"},{type:"flex-end",icon:"AlignRight",tooltip:"Align right"}].map(n=>({type:`video-align-${n.type}`,component:e.ActionButton,componentProps:{tooltip:n.tooltip,icon:n.icon,action:()=>t.commands.updateVideo({align:n.type}),isActive:()=>t.getAttributes("video").align===n.type}}))}function It(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`video-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateVideo({width:r.VIDEO_SIZE[s]}),isActive:()=>t.isActive("video",{width:r.VIDEO_SIZE[s]})}}))}var Tt=!1;function Mt({editor:t,attrs:n,extension:r}){const[i,o]=(0,H.useState)(!1),c=(0,H.useRef)(null),a=(0,H.useRef)(null),{alt:h,align:d}=n,u=r?.options.upload;(0,H.useEffect)(()=>{i&&setTimeout(()=>{(async()=>{const t=document.querySelector("#easydrawer");t&&(c.current=new Z.Editor(t,{wheelEventsEnabled:!1,disableZoom:!0}),a.current=(0,Z.makeDropdownToolbar)(c.current),a.current.addDefaultToolWidgets(),c.current.loadFromSVG(decodeURIComponent(h)))})()},200)},[i]);const p=()=>{if(Tt){for(;c.current.history.redoStackSize>0;)c.current.history.redo();Tt=!1}else c.current.history.undo()};return(0,V.jsxs)(l.Dialog,{onOpenChange:o,open:i,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{action:()=>o(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:"Edit Drawer"}),(0,V.jsxs)("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,V.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,V.jsx)(S.ControlDrawer,{changeBorderColorShape:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setBorderColor(t),n.serializeState())},changeColorShape:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setColor(t),n.serializeState())},changeShape:t=>{const e=a.current.getWidgetById("shape");e&&e.setShapeType(t)},onClear:()=>{if(!Tt){for(;c.current.history.undoStackSize>0;)p();Tt=!0}},onRedo:()=>{Tt||c.current.history.redo()},onThicknessChange:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setThickness(t),n.serializeState())},onUndo:p,refEditor:c,setColorHighlight:t=>{const e=c.current.toolController.getPrimaryTools()[3],n=a.current.getWidgetById("pen-2");e&&n&&(e.setColor(t),n.serializeState())},setColorPen:t=>{const e=c.current.toolController.getPrimaryTools()[2],n=a.current.getWidgetById("pen-1");e&&n&&(e.setColor(t),n.serializeState())},setThicknessPen:t=>{const e=c.current.toolController.getPrimaryTools()[2],n=a.current.getWidgetById("pen-1");e&&n&&(e.setThickness(t),n.serializeState())}})]}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:async()=>{if(c.current){const e=c.current.toSVG(),n=e.outerHTML,r=`drawer-${k.shortId()}.svg`;let i=k.i(e.outerHTML);if(u){const t=x.dataURLtoFile(i,r);i=await u(t)}t?.chain().focus().setDrawer({type:"drawer",src:i,alt:encodeURIComponent(n),width:426,height:212},!!n).run(),t?.commands.setAlignImageDrawer(d)}o(!1)},type:"button",children:"Save changes"})})]})]})}function Nt({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentProps?.disabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}var Rt=({width:t,maxWidth:e,height:n,onOk:i,children:o})=>{const{t:l}=r.useLocale(),[c,u]=(0,H.useState)({width:"",height:"",maxWidth:""});return(0,H.useEffect)(()=>{u({width:t,height:n,maxWidth:e})},[n,e,t]),(0,V.jsxs)(d.Popover,{modal:!0,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,children:o}),(0,V.jsx)(d.PopoverContent,{children:(0,V.jsxs)("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:function(t){t.preventDefault(),t.stopPropagation(),i(c)},children:[(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Width"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,width:t.target.value}),required:!0,type:"number",value:c.width})})}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Max Width"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,maxWidth:t.target.value}),required:!0,type:"number",value:c.maxWidth})})}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Height"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,height:t.target.value}),required:!0,type:"number",value:c.height})})}),(0,V.jsx)(s.Button,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:l("editor.link.dialog.button.apply")})]})})]})},zt=new Map;function Pt({children:t,visible:e,toggleVisible:n}){const{t:i}=r.useLocale(),o=m.useEditorInstance(),[c,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{E.loadKatex().then(a)},[]);const{text:d,macros:u}=b.useAttributes(o,b.Katex.name,{text:"",macros:""}),[f,g]=(0,H.useState)(decodeURIComponent(d||"")),[x,w]=(0,H.useState)(decodeURIComponent(u||""));(0,H.useEffect)(()=>{e&&(g(decodeURIComponent(d||"")),w(decodeURIComponent(u||"")))},[e]);const y=(0,H.useCallback)(()=>{o.chain().focus().setKatex({text:encodeURIComponent(f),macros:encodeURIComponent(x)}).run(),g(""),w(""),n(!1)},[o,f,x,n]),v=(0,H.useMemo)(()=>{if(!c)return f;try{return c.renderToString(f,{macros:b.safeJSONParse(x||"")})}catch{return f}},[f,x,c]),S=(0,H.useMemo)(()=>`${f}`.trim()?v:null,[f,v]);return(0,V.jsxs)(l.Dialog,{onOpenChange:n,open:e,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:t}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:i("editor.formula.dialog.text")}),(0,V.jsx)("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,V.jsxs)("div",{className:"richtext-flex-1",children:[(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Expression"}),(0,V.jsx)(p.Textarea,{autoFocus:!0,className:"richtext-mb-[10px]",onChange:t=>g(t.target.value),placeholder:"Text",required:!0,rows:10,value:f,style:{color:"hsl(var(--foreground))"}}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Macros"}),(0,V.jsx)(p.Textarea,{onChange:t=>w(t.target.value),placeholder:"Macros",rows:10,value:x,style:{color:"hsl(var(--foreground))"}})]}),(0,V.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:S||""},style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:y,type:"button",children:"Save changes"})})]})]})}function Bt(t){const{t:n}=r.useLocale();return(0,V.jsxs)("div",{className:"richtext-flex richtext-flex-nowrap",children:[(0,V.jsx)(e.ActionButton,{disabled:!t?.link,icon:"ExternalLink",tooltip:n("editor.link.open.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{window.open(t?.link,"_blank")}}),(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:n("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{t?.onEdit()}}),(0,V.jsx)(e.ActionButton,{icon:"Unlink",tooltip:n("editor.link.unlink.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{t?.onClear()}})]})}function Lt({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentdisabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}var Ut="graph TB\na--\x3eb",Ft=({editor:t,attrs:n,extension:r})=>{const{alt:i,align:o}=n,[c,a]=(0,H.useState)(decodeURIComponent(i??Ut)),[h,d]=(0,H.useState)(""),[u,f]=(0,H.useState)(!1),g=(0,H.useRef)(null),[m,w]=(0,H.useState)(null),y=r?.options.upload,b=(0,H.useCallback)(t=>{t&&import("mermaid").then(t=>{w(t.default)})},[]),v=async t=>{try{const{svg:e}=await m.render("mermaid-svg",t);d(e)}catch{d("")}};(0,H.useEffect)(()=>{m&&u&&(m.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),v(c))},[m,u]),(0,H.useEffect)(()=>{m&&u&&v(c)},[m,c]);return(0,V.jsxs)(l.Dialog,{onOpenChange:f,open:u,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{action:()=>f(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:"Edit Mermaid"}),(0,V.jsx)("div",{ref:b,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,V.jsx)(p.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Ut,onChange:t=>a(t.target.value),placeholder:"Text",required:!0,rows:10,value:c,style:{color:"hsl(var(--foreground))"}}),(0,V.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:h},ref:g,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500}})]})}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:async()=>{if(""!==c){if(c){const e=g.current.querySelector("svg"),{width:n,height:r}=e.getBoundingClientRect(),i=`mermaid-${k.shortId()}.svg`;let s=k.i(e.outerHTML);if(y){const t=x.dataURLtoFile(s,i);s=await y(t)}t?.chain().focus().setMermaid({type:"mermaid",src:s,alt:encodeURIComponent(c),width:n,height:r},!!c).run(),t?.commands.setAlignImageMermaid(o)}f(!1)}},type:"button",children:"Save changes"})})]})]})};function $t({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentProps?.disabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}function Ht(){const{t:t}=r.useLocale(),[n,s]=(0,H.useState)(!1),o=m.useEditorInstance(),l=(0,H.useMemo)(()=>R.renderCommandListDefault({t:t})?.[0]?.commands,[t]),c=(0,H.useMemo)(()=>l?.find(t=>t?.isActive?.(o))?.label,[o.state.selection.ranges,n,o,l,t]),a=(0,H.useMemo)(()=>l?.find(t=>t?.isActive?.(o)),[o.state.selection.ranges,n,o,l]);return(0,V.jsxs)(d.Popover,{modal:!0,onOpenChange:s,open:n,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,V.jsx)(e.ActionButton,{dataState:!!c,tooltip:c||t("editor.paragraph.tooltip"),children:(0,V.jsx)(i.IconComponent,{name:a?.iconName||"Type"})})}),(0,V.jsx)(d.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:l?.map(e=>{const n=e?.isActive?.(o);return(0,V.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-1.5 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:t=>{t.preventDefault(),e.action({editor:o,range:o.state.selection.ranges}),s(!1)},children:[(0,V.jsxs)("div",{className:"!richtext-min-w-[16px]",children:[n&&(0,V.jsx)(q.Check,{size:16}),!c&&e.label===t("editor.paragraph.tooltip")&&!n&&(0,V.jsx)(q.Check,{size:16})]}),(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:[e.iconName&&(0,V.jsx)(i.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:e.iconName}),e.label]})]},e.name)})})]})}function Vt(){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ht,{}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(O.RichTextBold,{}),(0,V.jsx)(N.RichTextItalic,{}),(0,V.jsx)(P.RichTextUnderline,{}),(0,V.jsx)(I.RichTextCode,{}),(0,V.jsx)(_.RichTextLink,{}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(T.RichTextColor,{}),(0,V.jsx)(M.RichTextHighlight,{}),(0,V.jsx)(z.RichTextAlign,{})]})}var qt=()=>new Map,Jt=t=>{const e=qt();return t.forEach((t,n)=>{e.set(n,t)}),e},Kt=(t,e,n)=>{let r=t.get(e);return void 0===r&&t.set(e,r=n()),r},Wt=()=>new Set,Gt=t=>t[t.length-1],Xt=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Yt=Array.from,Zt=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Qt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},te=Array.isArray,ee=class{constructor(){this._observers=qt()}on(t,e){return Kt(this._observers,t,Wt).add(e),e}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(t,e){return Yt((this._observers.get(t)||qt()).values()).forEach(t=>t(...e))}destroy(){this._observers=qt()}},ne=Math.floor,re=Math.abs,ie=(t,e)=>t<e?t:e,se=(t,e)=>t>e?t:e,oe=(Number.isNaN,t=>0!==t?t<0:1/t<0),le=Number.MAX_SAFE_INTEGER,ce=Number.MIN_SAFE_INTEGER,ae=Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&ne(t)===t),he=(Number.isNaN,Number.parseInt,String.fromCharCode),de=(String.fromCodePoint,he(65535),/^\s*/g),ue=/([A-Z])/g,pe=(t,e)=>(t=>t.replace(de,""))(t.replace(ue,t=>`${e}${(t=>t.toLowerCase())(t)}`)),fe="undefined"!=typeof TextEncoder?new TextEncoder:null,ge=fe?t=>fe.encode(t):t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},me="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});me&&1===me.decode(new Uint8Array).length&&(me=null);var xe=(t,e)=>((t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n})(e,()=>t).join(""),we=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ye=()=>new we,be=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e})(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ve=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},Se=ve,ke=(t,e)=>{for(;e>127;)ve(t,128|127&e),e=ne(e/128);ve(t,127&e)},Ce=(t,e)=>{const n=oe(e);for(n&&(e=-e),ve(t,(e>63?128:0)|(n?64:0)|63&e),e=ne(e/64);e>0;)ve(t,(e>127?128:0)|127&e),e=ne(e/128)},Ee=new Uint8Array(3e4),_e=Ee.length/3,Ae=fe&&fe.encodeInto?(t,e)=>{if(e.length<_e){const n=fe.encodeInto(e,Ee).written||0;ke(t,n);for(let e=0;e<n;e++)ve(t,Ee[e])}else De(t,ge(e))}:(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ke(t,r);for(let i=0;i<r;i++)ve(t,n.codePointAt(i))},je=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=ie(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(se(2*n,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},De=(t,e)=>{ke(t,e.byteLength),je(t,e)},Oe=(t,e)=>{((t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(2*se(n,e)),t.cpos=0)})(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Ie=new DataView(new ArrayBuffer(4)),Te=(t,e)=>{switch(typeof e){case"string":ve(t,119),Ae(t,e);break;case"number":ae(e)&&re(e)<=2147483647?(ve(t,125),Ce(t,e)):(n=e,Ie.setFloat32(0,n),Ie.getFloat32(0)===n?(ve(t,124),((t,e)=>{Oe(t,4).setFloat32(0,e,!1)})(t,e)):(ve(t,123),((t,e)=>{Oe(t,8).setFloat64(0,e,!1)})(t,e)));break;case"bigint":ve(t,122),((t,e)=>{Oe(t,8).setBigInt64(0,e,!1)})(t,e);break;case"object":if(null===e)ve(t,126);else if(te(e)){ve(t,117),ke(t,e.length);for(let n=0;n<e.length;n++)Te(t,e[n])}else if(e instanceof Uint8Array)ve(t,116),De(t,e);else{ve(t,118);const n=Object.keys(e);ke(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];Ae(t,i),Te(t,e[i])}}break;case"boolean":ve(t,e?120:121);break;default:ve(t,127)}var n},Me=class extends we{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&ke(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}},Ne=t=>{t.count>0&&(Ce(t.encoder,1===t.count?t.s:-t.s),t.count>1&&ke(t.encoder,t.count-2))},Re=class{constructor(){this.encoder=new we,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Ne(this),this.count=1,this.s=t)}toUint8Array(){return Ne(this),be(this.encoder)}},ze=t=>{if(t.count>0){const e=2*t.diff+(1===t.count?0:1);Ce(t.encoder,e),t.count>1&&ke(t.encoder,t.count-2)}},Pe=class{constructor(){this.encoder=new we,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(ze(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return ze(this),be(this.encoder)}},Be=class{constructor(){this.sarr=[],this.s="",this.lensE=new Re}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new we;return this.sarr.push(this.s),this.s="",Ae(t,this.sarr.join("")),je(t,this.lensE.toUint8Array()),be(t)}},Le=t=>new Error(t),Ue=()=>{throw Le("Method unimplemented")},Fe=()=>{throw Le("Unexpected case")},$e=Le("Unexpected end of array"),He=Le("Integer out of Range"),Ve=class{constructor(t){this.arr=t,this.pos=0}},qe=t=>new Ve(t),Je=t=>((t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n})(t,We(t)),Ke=t=>t.arr[t.pos++],We=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const r=t.arr[t.pos++];if(e+=(127&r)*n,n*=128,r<128)return e;if(e>le)throw He}throw $e},Ge=t=>{let e=t.arr[t.pos++],n=63&e,r=64;const i=(64&e)>0?-1:1;if(!(128&e))return i*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n+=(127&e)*r,r*=128,e<128)return i*n;if(n>le)throw He}throw $e},Xe=me?t=>me.decode(Je(t)):t=>{let e=We(t);if(0===e)return"";{let n=String.fromCodePoint(Ke(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Ke(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Ye=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Ze=[t=>{},t=>null,Ge,t=>Ye(t,4).getFloat32(0,!1),t=>Ye(t,8).getFloat64(0,!1),t=>Ye(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Xe,t=>{const e=We(t),n={};for(let r=0;r<e;r++){n[Xe(t)]=Qe(t)}return n},t=>{const e=We(t),n=[];for(let r=0;r<e;r++)n.push(Qe(t));return n},Je],Qe=t=>Ze[127-Ke(t)](t),tn=class extends Ve{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){var t;return 0===this.count&&(this.s=this.reader(this),(t=this).pos!==t.arr.length?this.count=We(this)+1:this.count=-1),this.count--,this.s}},en=class extends Ve{constructor(t){super(t),this.s=0,this.count=0}read(){if(0===this.count){this.s=Ge(this);const t=oe(this.s);this.count=1,t&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}},nn=class extends Ve{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const t=Ge(this),e=1&t;this.diff=ne(t/2),this.count=1,e&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}},rn=class{constructor(t){this.decoder=new en(t),this.str=Xe(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}},sn=(crypto.subtle,crypto.getRandomValues.bind(crypto)),on=Math.random,ln=()=>sn(new Uint32Array(1))[0],cn=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^ln()&15>>t/4).toString(16)),an=Date.now,hn=t=>new Promise(t),dn=(Promise.all.bind(Promise),t=>void 0===t?null:t),un=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}};try{"undefined"!=typeof localStorage&&localStorage&&(un=localStorage,!1)}catch(Xa){}var pn,fn,gn,mn,xn=un,wn=Symbol("Equality"),yn=(t,e)=>t===e||!!t?.[wn]?.(e)||!1,bn=Object.assign,vn=Object.keys,Sn=t=>vn(t).length,kn=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Cn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),En=Object.freeze,_n=t=>{for(const e in t){const n=t[e];"object"!=typeof n&&"function"!=typeof n||_n(t[e])}return En(t)},An=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&An(t,e,n+1)}},jn=(t,e)=>{if(t===e)return!0;if(null==t||null==e||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(null!=t[wn])return t[wn](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break;case Set:if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break;case Map:if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!jn(t.get(n),e.get(n)))return!1;break;case void 0:case Object:if(Sn(t)!==Sn(e))return!1;for(const n in t)if(!Cn(t,n)||!jn(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!jn(t[n],e[n]))return!1;break;default:return!1}return!0},Dn="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),On="undefined"!=typeof window&&"undefined"!=typeof document&&!Dn,In=("undefined"!=typeof navigator&&/Mac/.test(navigator.platform),[]),Tn=t=>(()=>{if(void 0===pn)if(Dn){pn=qt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];"-"===r[0]?(null!==e&&pn.set(e,""),e=r):null!==e?(pn.set(e,r),e=null):In.push(r)}null!==e&&pn.set(e,"")}else"object"==typeof location?(pn=qt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(0!==t.length){const[e,n]=t.split("=");pn.set(`--${pe(e,"-")}`,n),pn.set(`-${pe(e,"-")}`,n)}})):pn=qt();return pn})().has(t),Mn=t=>dn(Dn?process.env[t.toUpperCase().replaceAll("-","_")]:xn.getItem(t)),Nn=t=>Tn("--"+t)||null!==Mn(t),Rn=Nn("production"),zn=Dn&&(fn=process.env.FORCE_COLOR,gn=["true","1","2"],gn.includes(fn)),Pn=(zn||!Tn("--no-colors")&&!Nn("no-color")&&(!Dn||process.stdout.isTTY)&&(!Dn||Tn("--color")||null!==Mn("COLORTERM")||(Mn("TERM")||"").includes("color")),On?t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=he(t[n]);return btoa(e)}:t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64")),Bn=t=>(t=>{const e=ye();return t(e),be(e)})(e=>Te(e,t)),Ln=class{constructor(t,e){this.left=t,this.right=e}},Un=(t,e)=>new Ln(t,e),Fn=t=>t.next()>=.5,$n=(t,e,n)=>ne(t.next()*(n+1-e)+e),Hn=(t,e,n)=>ne(t.next()*(n+1-e)+e),Vn=(t,e,n)=>Hn(t,e,n),qn=t=>he(Vn(t,97,122)),Jn=(t,e)=>e[Vn(t,0,e.length-1)],Kn=Symbol("0schema"),Wn=class{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){const t=[];for(let e=this._rerrs.length-1;e>0;e--){const n=this._rerrs[e];t.push(xe(" ",2*(this._rerrs.length-e))+`${null!=n.path?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join("\n")}},Gn=(t,e)=>t===e||null!=t&&null!=e&&t.constructor===e.constructor&&(t[wn]?yn(t,e):te(t)?Zt(t,t=>Qt(e,e=>Gn(t,e))):"object"==typeof t&&kn(t,(t,n)=>Gn(t,e[n]))),Xn=class{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];return this.constructor._dilutes&&([n,e]=[e,n]),Gn(e,n)}equals(t){return this.constructor===t.constructor&&jn(this.shape,t.shape)}[Kn](){return!0}[wn](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){Ue()}get nullable(){return _r(this,Fr)}get optional(){return new lr(this)}cast(t){return qr(t,this),t}expect(t){return qr(t,this),t}},Yn=class extends Xn{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e=void 0){const n=t?.constructor===this.shape&&(null==this._c||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}},Zn=(t,e=null)=>new Yn(t,e),Qn=(Zn(Yn),class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}),tr=t=>new Qn(t),er=(Zn(Qn),class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=this.shape.some(e=>e===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}),nr=(...t)=>new er(t),rr=Zn(er),ir=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),sr=t=>zr.check(t)?[ir(t)]:rr.check(t)?t.shape.map(t=>t+""):Rr.check(t)?["[+-]?\\d+.?\\d*"]:Pr.check(t)?[".*"]:Ar.check(t)?t.shape.map(sr).flat(1):void Fe(),or=(Zn(class extends Xn{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(sr).map(t=>`(${t.join("|")})`).join("")+"$")}check(t,e){const n=null!=this._r.exec(t);return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}),Symbol("optional")),lr=class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=void 0===t||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[or](){return!0}},cr=Zn(lr),ar=class extends Xn{check(t,e){return e?.extend(null,"never",typeof t),!1}},hr=(new ar,Zn(ar),class t extends Xn{constructor(t,e=!1){super(),this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new t(this.shape,!0)}check(t,e){return null==t?(e?.extend(null,"object","null"),!1):kn(this.shape,(n,r)=>{const i=this._isPartial&&!Cn(t,r)||n.check(t[r],e);return!i&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),i})}}),dr=Zn(hr),ur=tr(t=>null!=t&&(t.constructor===Object||null==t.constructor)),pr=class extends Xn{constructor(t,e){super(),this.shape={keys:t,values:e}}check(t,e){return null!=t&&kn(t,(n,r)=>{const i=this.shape.keys.check(r,e);return!i&&e?.extend(r+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(n,e)})}},fr=(t,e)=>new pr(t,e),gr=Zn(pr),mr=class extends Xn{constructor(t){super(),this.shape=t}check(t,e){return null!=t&&kn(this.shape,(n,r)=>{const i=n.check(t[r],e);return!i&&e?.extend(r.toString(),"Tuple",typeof n),i})}},xr=(Zn(mr),class extends Xn{constructor(t){super(),this.shape=1===t.length?t[0]:new Er(t)}check(t,e){const n=te(t)&&Zt(t,t=>this.shape.check(t));return!n&&e?.extend(null,"Array",""),n}}),wr=(...t)=>new xr(t),yr=Zn(xr),br=tr(t=>te(t)),vr=class extends Xn{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e){const n=t instanceof this.shape&&(null==this._c||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}},Sr=(Zn(vr),((t,e=null)=>new vr(t,e))(Xn)),kr=Zn(class extends Xn{constructor(t){super(),this.len=t.length-1,this.args=((...t)=>new mr(t))(...t.slice(-1)),this.res=t[this.len]}check(t,e){const n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}),Cr=tr(t=>"function"==typeof t),Er=(Zn(class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=Zt(this.shape,n=>n.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}},t=>t.shape.length>0),class extends Xn{static _dilutes=!0;constructor(t){super(),this.shape=t}check(t,e){const n=Qt(this.shape,n=>n.check(t,e));return e?.extend(null,"Union",typeof t),n}}),_r=(...t)=>t.findIndex(t=>Ar.check(t))>=0?_r(...t.map(t=>Vr(t)).map(t=>Ar.check(t)?t.shape:[t]).flat(1)):1===t.length?t[0]:new Er(t),Ar=Zn(Er),jr=()=>!0,Dr=tr(jr),Or=Zn(Qn,t=>t.shape===jr),Ir=tr(t=>"bigint"==typeof t),Tr=tr(t=>t===Ir),Mr=tr(t=>"symbol"==typeof t),Nr=(tr(t=>t===Mr),tr(t=>"number"==typeof t)),Rr=tr(t=>t===Nr),zr=tr(t=>"string"==typeof t),Pr=tr(t=>t===zr),Br=tr(t=>"boolean"==typeof t),Lr=tr(t=>t===Br),Ur=nr(void 0),Fr=(Zn(er,t=>1===t.shape.length&&void 0===t.shape[0]),nr(void 0),nr(null)),$r=Zn(er,t=>1===t.shape.length&&null===t.shape[0]),Hr=(Zn(Uint8Array),Zn(Yn,t=>t.shape===Uint8Array),_r(Nr,zr,Fr,Ur,Ir,Br,Mr)),Vr=((()=>{const t=wr(Dr),e=fr(zr,Dr),n=_r(Nr,zr,Fr,Br,t,e);t.shape=n,e.shape.values=n})(),t=>{if(Sr.check(t))return t;if(ur.check(t)){const e={};for(const n in t)e[n]=Vr(t[n]);return new hr(e)}return br.check(t)?_r(...t.map(Vr)):Hr.check(t)?nr(t):Cr.check(t)?Zn(t):void Fe()}),qr=Rn?()=>{}:(t,e)=>{const n=new Wn;if(!e.check(t,n))throw Le(`Expected value to be of type ${e.constructor.name}.\n${n.toString()}`)},Jr=(mn=Dr,new class{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Vr(t),h:e}),this}else(t){return this.if(Dr,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw Le("Unhandled pattern")}}}(mn)).if(Rr,(t,e)=>$n(e,ce,le)).if(Pr,(t,e)=>((t,e=0,n=20)=>{const r=Vn(t,e,n);let i="";for(let s=0;s<r;s++)i+=qn(t);return i})(e)).if(Lr,(t,e)=>Fn(e)).if(Tr,(t,e)=>BigInt($n(e,ce,le))).if(Ar,(t,e)=>Kr(e,Jn(e,t.shape))).if(dr,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(cr.check(i)){if(Fn(e))continue;i=i.shape}n[r]=Jr(i,e)}return n}).if(yr,(t,e)=>{const n=[],r=Hn(e,0,42);for(let i=0;i<r;i++)n.push(Kr(e,t.shape));return n}).if(rr,(t,e)=>Jn(e,t.shape)).if($r,(t,e)=>null).if(kr,(t,e)=>{const n=Kr(e,t.res);return()=>n}).if(Or,(t,e)=>Kr(e,Jn(e,[Nr,zr,Fr,Ur,Ir,Br,wr(Nr),fr(_r("a","b","c"),Nr)]))).if(gr,(t,e)=>{const n={},r=$n(e,0,3);for(let i=0;i<r;i++){n[Kr(e,t.shape.keys)]=Kr(e,t.shape.values)}return n}).done(),Kr=(t,e)=>Jr(Vr(e),t),Wr="undefined"!=typeof document?document:{},Gr=(tr(t=>t.nodeType===Zr),"undefined"!=typeof DOMParser&&new DOMParser,tr(t=>t.nodeType===Gr),tr(t=>t.nodeType===Xr),Wr.ELEMENT_NODE),Xr=Wr.TEXT_NODE,Yr=(Wr.CDATA_SECTION_NODE,Wr.COMMENT_NODE,Wr.DOCUMENT_NODE),Zr=(Wr.DOCUMENT_TYPE_NODE,Wr.DOCUMENT_FRAGMENT_NODE),Qr=(tr(t=>t.nodeType===Yr),t=>class{constructor(t){this._=t}destroy(){t(this._)}}),ti=Qr(clearTimeout),ei=(t,e)=>new ti(setTimeout(e,t)),ni=(Qr(clearInterval),Qr(t=>"undefined"!=typeof requestAnimationFrame&&cancelAnimationFrame(t)),Qr(t=>"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(t)),Symbol),ri=ni(),ii=ni(),si=ni(),oi=ni(),li=ni(),ci=ni(),ai=ni(),hi=ni(),di=ni(),ui=(an(),Un("font-weight","bold"),Un("font-weight","normal"),Un("color","blue"),Un("color","green"),Un("color","grey"),Un("color","red"),Un("color","purple"),Un("color","orange"),Un("color","black"),(...t)=>{t.unshift(hi),pi.forEach(e=>e.print(t))}),pi=Wt(),fi=t=>({[Symbol.iterator](){return this},next:t}),gi=(t,e)=>fi(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}}),mi=class{constructor(t,e){this.clock=t,this.len=e}},xi=class{constructor(){this.clients=new Map}},wi=(t,e,n)=>e.clients.forEach((e,r)=>{const i=t.doc.store.clients.get(r);if(null!=i){const r=i[i.length-1],s=r.id.clock+r.length;for(let o=0,l=e[o];o<e.length&&l.clock<s;l=e[++o])us(t,i,l.clock,l.len,n)}}),yi=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=ne((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;n=i+1}else r=i-1}return null})(n,e.clock)},bi=t=>{t.clients.forEach(t=>{let e,n;for(t.sort((t,e)=>t.clock-e.clock),e=1,n=1;e<t.length;e++){const r=t[n-1],i=t[e];r.clock+r.len>=i.clock?t[n-1]=new mi(r.clock,se(r.len,i.clock+i.len-r.clock)):(n<e&&(t[n]=i),n++)}t.length=n})},vi=t=>{const e=new xi;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let e=n+1;e<t.length;e++)Xt(s,t[e].clients.get(i)||[]);e.clients.set(i,s)}});return bi(e),e},Si=(t,e,n,r)=>{Kt(t.clients,e,()=>[]).push(new mi(n,r))},ki=()=>new xi,Ci=(t,e)=>{ke(t.restEncoder,e.clients.size),Yt(e.clients.entries()).sort((t,e)=>e[0]-t[0]).forEach(([e,n])=>{t.resetDsCurVal(),ke(t.restEncoder,e);const r=n.length;ke(t.restEncoder,r);for(let i=0;i<r;i++){const e=n[i];t.writeDsClock(e.clock),t.writeDsLen(e.len)}})},Ei=(t,e,n)=>{const r=new xi,i=We(t.restDecoder);for(let s=0;s<i;s++){t.resetDsCurVal();const i=We(t.restDecoder),s=We(t.restDecoder),o=n.clients.get(i)||[],l=ss(n,i);for(let n=0;n<s;n++){const n=t.readDsClock(),s=n+t.readDsLen();if(n<l){l<s&&Si(r,i,l,s-l);let t=ls(o,n),c=o[t];for(!c.deleted&&c.id.clock<n&&(o.splice(t+1,0,tl(e,c,n-c.id.clock)),t++);t<o.length&&(c=o[t++],c.id.clock<s);)c.deleted||(s<c.id.clock+c.length&&o.splice(t,0,tl(e,c,s-c.id.clock)),c.delete(e))}else Si(r,i,n,s-n)}}if(r.clients.size>0){const t=new Mi;return ke(t.restEncoder,0),Ci(t,r),t.toUint8Array()}return null},_i=ln,Ai=class t extends ee{constructor({guid:t=cn(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:s=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=_i(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new rs,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=hn(t=>{this.on("load",()=>{this.isLoaded=!0,t(this)})});const l=()=>hn(t=>{const e=n=>{void 0!==n&&!0!==n||(this.off("sync",e),t())};this.on("sync",e)});this.on("sync",t=>{!1===t&&this.isSynced&&(this.whenSynced=l()),this.isSynced=void 0===t||!0===t,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;null===t||this.shouldLoad||ws(t.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Yt(this.subdocs).map(t=>t.guid))}transact(t,e=null){return ws(this,t,e)}get(t,e=Us){const n=Kt(this.share,t,()=>{const t=new e;return t._integrate(this,null),t}),r=n.constructor;if(e!==Us&&r!==e){if(r===Us){const r=new e;r._map=n._map,n._map.forEach(t=>{for(;null!==t;t=t.left)t.parent=r}),r._start=n._start;for(let t=r._start;null!==t;t=t.right)t.parent=r;return r._length=n._length,this.share.set(t,r),r._integrate(this,null),r}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return n}getArray(t=""){return this.get(t,so)}getText(t=""){return this.get(t,Co)}getMap(t=""){return this.get(t,lo)}getXmlElement(t=""){return this.get(t,Ao)}getXmlFragment(t=""){return this.get(t,_o)}toJSON(){const t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,Yt(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(null!==e){this._item=null;const n=e.content;n.doc=new t({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ws(e.parent.doc,t=>{const r=n.doc;e.deleted||t.subdocsAdded.add(r),t.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},ji=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const t=We(this.restDecoder)+1;return this.dsCurrVal+=t,t}},Di=class extends ji{constructor(t){super(t),this.keys=[],We(t),this.keyClockDecoder=new nn(Je(t)),this.clientDecoder=new en(Je(t)),this.leftClockDecoder=new nn(Je(t)),this.rightClockDecoder=new nn(Je(t)),this.infoDecoder=new tn(Je(t),Ke),this.stringDecoder=new rn(Je(t)),this.parentInfoDecoder=new tn(Je(t),Ke),this.typeRefDecoder=new en(Je(t)),this.lenDecoder=new en(Je(t))}readLeftID(){return new $i(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new $i(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Qe(this.restDecoder)}readBuf(){return Je(this.restDecoder)}readJSON(){return Qe(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const t=this.stringDecoder.read();return this.keys.push(t),t}}},Oi=class{constructor(){this.restEncoder=ye()}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){ke(this.restEncoder,t)}writeDsLen(t){ke(this.restEncoder,t)}},Ii=class extends Oi{writeLeftID(t){ke(this.restEncoder,t.client),ke(this.restEncoder,t.clock)}writeRightID(t){ke(this.restEncoder,t.client),ke(this.restEncoder,t.clock)}writeClient(t){ke(this.restEncoder,t)}writeInfo(t){Se(this.restEncoder,t)}writeString(t){Ae(this.restEncoder,t)}writeParentInfo(t){ke(this.restEncoder,t?1:0)}writeTypeRef(t){ke(this.restEncoder,t)}writeLen(t){ke(this.restEncoder,t)}writeAny(t){Te(this.restEncoder,t)}writeBuf(t){De(this.restEncoder,t)}writeJSON(t){Ae(this.restEncoder,JSON.stringify(t))}writeKey(t){Ae(this.restEncoder,t)}},Ti=class{constructor(){this.restEncoder=ye(),this.dsCurrVal=0}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,ke(this.restEncoder,e)}writeDsLen(t){0===t&&Fe(),ke(this.restEncoder,t-1),this.dsCurrVal+=t}},Mi=class extends Ti{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pe,this.clientEncoder=new Re,this.leftClockEncoder=new Pe,this.rightClockEncoder=new Pe,this.infoEncoder=new Me(Se),this.stringEncoder=new Be,this.parentInfoEncoder=new Me(Se),this.typeRefEncoder=new Re,this.lenEncoder=new Re}toUint8Array(){const t=ye();return ke(t,0),De(t,this.keyClockEncoder.toUint8Array()),De(t,this.clientEncoder.toUint8Array()),De(t,this.leftClockEncoder.toUint8Array()),De(t,this.rightClockEncoder.toUint8Array()),De(t,be(this.infoEncoder)),De(t,this.stringEncoder.toUint8Array()),De(t,be(this.parentInfoEncoder)),De(t,this.typeRefEncoder.toUint8Array()),De(t,this.lenEncoder.toUint8Array()),je(t,be(this.restEncoder)),be(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Te(this.restEncoder,t)}writeBuf(t){De(this.restEncoder,t)}writeJSON(t){Te(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);void 0===e?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}},Ni=(t,e,n)=>{const r=new Map;n.forEach((t,n)=>{ss(e,n)>t&&r.set(n,t)}),is(e).forEach((t,e)=>{n.has(e)||r.set(e,0)}),ke(t.restEncoder,r.size),Yt(r.entries()).sort((t,e)=>e[0]-t[0]).forEach(([n,r])=>{((t,e,n,r)=>{r=se(r,e[0].id.clock);const i=ls(e,r);ke(t.restEncoder,e.length-i),t.writeClient(n),ke(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(t,0)})(t,e.clients.get(n),n,r)})},Ri=(t,e,n,r=new Di(t))=>ws(e,t=>{t.local=!1;let e=!1;const n=t.doc,i=n.store,s=((t,e)=>{const n=qt(),r=We(t.restDecoder);for(let i=0;i<r;i++){const r=We(t.restDecoder),i=new Array(r),s=t.readClient();let o=We(t.restDecoder);n.set(s,{i:0,refs:i});for(let n=0;n<r;n++){const r=t.readInfo();switch(31&r){case 0:{const e=t.readLen();i[n]=new To(Vi(s,o),e),o+=e;break}case 10:{const e=We(t.restDecoder);i[n]=new ol(Vi(s,o),e),o+=e;break}default:{const l=!(192&r),c=new rl(Vi(s,o),null,128&~r?null:t.readLeftID(),null,64&~r?null:t.readRightID(),l?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,!l||32&~r?null:t.readString(),il(t,r));i[n]=c,o+=c.length}}}}return n})(r,n),o=((t,e,n)=>{const r=[];let i=Yt(n.keys()).sort((t,e)=>t-e);if(0===i.length)return null;const s=()=>{if(0===i.length)return null;let t=n.get(i[i.length-1]);for(;t.refs.length===t.i;){if(i.pop(),!(i.length>0))return null;t=n.get(i[i.length-1])}return t};let o=s();if(null===o)return null;const l=new rs,c=new Map,a=(t,e)=>{const n=c.get(t);(null==n||n>e)&&c.set(t,e)};let h=o.refs[o.i++];const d=new Map,u=()=>{for(const t of r){const e=t.id.client,r=n.get(e);r?(r.i--,l.clients.set(e,r.refs.slice(r.i)),n.delete(e),r.i=0,r.refs=[]):l.clients.set(e,[t]),i=i.filter(t=>t!==e)}r.length=0};for(;;){if(h.constructor!==ol){const i=Kt(d,h.id.client,()=>ss(e,h.id.client))-h.id.clock;if(i<0)r.push(h),a(h.id.client,h.id.clock-1),u();else{const s=h.getMissing(t,e);if(null!==s){r.push(h);const t=n.get(s)||{refs:[],i:0};if(t.refs.length!==t.i){h=t.refs[t.i++];continue}a(s,ss(e,s)),u()}else(0===i||i<h.length)&&(h.integrate(t,i),d.set(h.id.client,h.id.clock+h.length))}}if(r.length>0)h=r.pop();else if(null!==o&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=s(),null===o)break;h=o.refs[o.i++]}}if(l.clients.size>0){const t=new Mi;return Ni(t,l,new Map),ke(t.restEncoder,0),{missing:c,update:t.toUint8Array()}}return null})(t,i,s),l=i.pendingStructs;if(l){for(const[t,n]of l.missing)if(n<ss(i,t)){e=!0;break}if(o){for(const[t,e]of o.missing){const n=l.missing.get(t);(null==n||n>e)&&l.missing.set(t,e)}l.update=_s([l.update,o.update])}}else i.pendingStructs=o;const c=Ei(r,t,i);if(i.pendingDs){const e=new Di(qe(i.pendingDs));We(e.restDecoder);const n=Ei(e,t,i);i.pendingDs=c&&n?_s([c,n]):c||n}else i.pendingDs=c;if(e){const e=i.pendingStructs.update;i.pendingStructs=null,zi(t.doc,e)}},n,!1),zi=(t,e,n,r=Di)=>{const i=qe(e);Ri(i,t,n,new r(i))},Pi=class{constructor(){this.l=[]}},Bi=()=>new Pi,Li=(t,e)=>t.l.push(e),Ui=(t,e)=>{const n=t.l;n.length;t.l=n.filter(t=>e!==t),t.l.length},Fi=(t,e,n)=>An(t.l,[e,n]),$i=class{constructor(t,e){this.client=t,this.clock=e}},Hi=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,Vi=(t,e)=>new $i(t,e),qi=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Fe()},Ji=(t,e)=>{for(;null!==e;){if(e.parent===t)return!0;e=e.parent._item}return!1},Ki=class{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}},Wi=class{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}},Gi=(t,e,n)=>{let r=null,i=null;return null===t._item?i=qi(t):r=Vi(t._item.id.client,t._item.id.clock),new Ki(r,i,e,n)},Xi=(t,e,n=0)=>{let r=t._start;if(n<0){if(0===e)return Gi(t,null,n);e--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>e)return Gi(t,Vi(r.id.client,r.id.clock+e),n);e-=r.length}if(null===r.right&&n<0)return Gi(t,r.lastId,n);r=r.right}return Gi(t,null,n)},Yi=(t,e,n=!0)=>{const r=e.store,i=t.item,s=t.type,o=t.tname,l=t.assoc;let c=null,a=0;if(null!==i){if(ss(r,i.client)<=i.clock)return null;const t=n?Zo(r,i):((t,e)=>{const n=cs(t,e);return{item:n,diff:e.clock-n.id.clock}})(r,i),e=t.item;if(!(e instanceof rl))return null;if(c=e.parent,null===c._item||!c._item.deleted){a=e.deleted||!e.countable?0:t.diff+(l>=0?0:1);let n=e.left;for(;null!==n;)!n.deleted&&n.countable&&(a+=n.length),n=n.left}}else{if(null!==o)c=e.get(o);else{if(null===s)throw Fe();{if(ss(r,s.client)<=s.clock)return null;const{item:t}=n?Zo(r,s):{item:cs(r,s)};if(!(t instanceof rl&&t.content instanceof Yo))return null;c=t.content.type}}a=l>=0?c._length:0}return((t,e,n=0)=>new Wi(t,e,n))(c,a,t.assoc)},Zi=class{constructor(t,e){this.ds=t,this.sv=e}},Qi=(t,e)=>new Zi(t,e),ts=(Qi(ki(),new Map),t=>Qi((t=>{const e=ki();return t.clients.forEach((t,n)=>{const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.deleted){const i=n.id.clock;let s=n.length;if(e+1<t.length)for(let n=t[e+1];e+1<t.length&&n.deleted;n=t[1+ ++e])s+=n.length;r.push(new mi(i,s))}}r.length>0&&e.clients.set(n,r)}),e})(t.store),is(t.store))),es=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!yi(e.ds,t.id),ns=(t,e)=>{const n=Kt(t.meta,ns,Wt),r=t.doc.store;n.has(e)||(e.sv.forEach((e,n)=>{e<ss(r,n)&&hs(t,Vi(n,e))}),wi(t,e.ds,t=>{}),n.add(e))},rs=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},is=t=>{const e=new Map;return t.clients.forEach((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)}),e},ss=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},os=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw Fe()}n.push(e)},ls=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=ne(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;n=o+1}else r=o-1;o=ne((n+r)/2)}throw Fe()},cs=(t,e)=>{const n=t.clients.get(e.client);return n[ls(n,e.clock)]},as=(t,e,n)=>{const r=ls(e,n),i=e[r];return i.id.clock<n&&i instanceof rl?(e.splice(r+1,0,tl(t,i,n-i.id.clock)),r+1):r},hs=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[as(t,n,e.clock)]},ds=(t,e,n)=>{const r=e.clients.get(n.client),i=ls(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==To&&r.splice(i+1,0,tl(t,s,n.clock-s.id.clock+1)),s},us=(t,e,n,r,i)=>{if(0===r)return;const s=n+r;let o,l=as(t,e,n);do{o=e[l++],s<o.id.clock+o.length&&as(t,e,s),i(o)}while(l<e.length&&e[l].id.clock<s)},ps=class{constructor(t,e,n){this.doc=t,this.deleteSet=new xi,this.beforeState=is(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},fs=(t,e)=>!(0===e.deleteSet.clients.size&&!((t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1})(e.afterState,(t,n)=>e.beforeState.get(n)!==t))&&(bi(e.deleteSet),((t,e)=>{Ni(t,e.doc.store,e.beforeState)})(t,e),Ci(t,e.deleteSet),!0),gs=(t,e,n)=>{const r=e._item;(null===r||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kt(t.changed,e,Wt).add(n)},ms=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=t[--i-1])n instanceof rl&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const s=e-i;return s&&t.splice(e+1-s,s),s},xs=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,s=n.deleteSet,o=n._mergeStructs;try{bi(s),n.afterState=is(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const t=[];n.changed.forEach((e,r)=>t.push(()=>{null!==r._item&&r._item.deleted||r._callObserver(n,e)})),t.push(()=>{n.changedParentTypes.forEach((e,r)=>{r._dEH.l.length>0&&(null===r._item||!r._item.deleted)&&((e=e.filter(t=>null===t.target._item||!t.target._item.deleted)).forEach(t=>{t.currentTarget=r,t._path=null}),e.sort((t,e)=>t.path.length-e.path.length),t.push(()=>{Fi(r._dEH,e,n)}))}),t.push(()=>r.emit("afterTransaction",[n,r])),t.push(()=>{n._needFormattingCleanup&&vo(n)})}),An(t,[])}finally{r.gc&&((t,e,n)=>{for(const[r,i]of t.clients.entries()){const t=e.clients.get(r);for(let r=i.length-1;r>=0;r--){const s=i[r],o=s.clock+s.len;for(let r=ls(t,s.clock),i=t[r];r<t.length&&i.id.clock<o;i=t[++r]){const i=t[r];if(s.clock+s.len<=i.id.clock)break;i instanceof rl&&i.deleted&&!i.keep&&n(i)&&i.gc(e,!1)}}}})(s,i,r.gcFilter),((t,e)=>{t.clients.forEach((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=ie(r.length-1,1+ls(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[t])t-=1+ms(r,t)}})})(s,i),n.afterState.forEach((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=i.clients.get(e),n=se(ls(t,r),1);for(let e=t.length-1;e>=n;)e-=1+ms(t,e)}});for(let t=o.length-1;t>=0;t--){const{client:e,clock:n}=o[t].id,r=i.clients.get(e),s=ls(r,n);s+1<r.length&&ms(r,s+1)>1||s>0&&ms(r,s)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(((...t)=>{pi.forEach(e=>e.print(t))})(hi,ri,"[yjs] ",ii,ci,"Changed the client-id because another client seems to be using it."),r.clientID=_i()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new Ii;fs(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new Mi;fs(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=n;(l.size>0||a.size>0||c.size>0)&&(l.forEach(t=>{t.clientID=r.clientID,null==t.collectionid&&(t.collectionid=r.collectionid),r.subdocs.add(t)}),a.forEach(t=>r.subdocs.delete(t)),r.emit("subdocs",[{loaded:c,added:l,removed:a},r,n]),a.forEach(t=>t.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):xs(t,e+1)}}},ws=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;null===t._transaction&&(s=!0,t._transaction=new ps(t,n,r),i.push(t._transaction),1===i.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const e=t._transaction===i[0];t._transaction=null,e&&xs(i,0)}}return o},ys=class{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}},bs=(t,e,n)=>{wi(t,n.deletions,n=>{n instanceof rl&&e.scope.some(e=>e===t.doc||Ji(e,n))&&Qo(n,!1)})},vs=(t,e,n)=>{let r=null;const i=t.doc,s=t.scope;ws(i,n=>{for(;e.length>0&&null===t.currStackItem;){const r=i.store,o=e.pop(),l=new Set,c=[];let a=!1;wi(n,o.insertions,t=>{if(t instanceof rl){if(null!==t.redone){let{item:e,diff:i}=Zo(r,t.id);i>0&&(e=hs(n,Vi(e.id.client,e.id.clock+i))),t=e}!t.deleted&&s.some(e=>e===n.doc||Ji(e,t))&&c.push(t)}}),wi(n,o.deletions,t=>{t instanceof rl&&s.some(e=>e===n.doc||Ji(e,t))&&!yi(o.insertions,t.id)&&l.add(t)}),l.forEach(e=>{a=null!==nl(n,e,l,o.insertions,t.ignoreRemoteMapChanges,t)||a});for(let e=c.length-1;e>=0;e--){const r=c[e];t.deleteFilter(r)&&(r.delete(n),a=!0)}t.currStackItem=a?o:null}n.changed.forEach((t,e)=>{t.has(null)&&e._searchMarker&&(e._searchMarker.length=0)}),r=n},t);const o=t.currStackItem;if(null!=o){const e=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:e,origin:t},t]),t.currStackItem=null}return o},Ss=class extends ee{constructor(t,{captureTimeout:e=500,captureTransaction:n=t=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:o=(te(t)?t[0].doc:t instanceof Ai?t:t.doc)}={}){super(),this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=e,this.afterTransactionHandler=t=>{if(!(this.captureTransaction(t)&&this.scope.some(e=>t.changedParentTypes.has(e)||e===this.doc)&&(this.trackedOrigins.has(t.origin)||t.origin&&this.trackedOrigins.has(t.origin.constructor))))return;const e=this.undoing,n=this.redoing,r=e?this.redoStack:this.undoStack;e?this.stopCapturing():n||this.clear(!1,!0);const i=new xi;t.afterState.forEach((e,n)=>{const r=t.beforeState.get(n)||0,s=e-r;s>0&&Si(i,n,r,s)});const s=an();let o=!1;if(this.lastChange>0&&s-this.lastChange<this.captureTimeout&&r.length>0&&!e&&!n){const e=r[r.length-1];e.deletions=vi([e.deletions,t.deleteSet]),e.insertions=vi([e.insertions,i])}else r.push(new ys(t.deleteSet,i)),o=!0;e||n||(this.lastChange=s),wi(t,t.deleteSet,e=>{e instanceof rl&&this.scope.some(n=>n===t.doc||Ji(n,e))&&Qo(e,!0)});const l=[{stackItem:r[r.length-1],origin:t.origin,type:e?"redo":"undo",changedParentTypes:t.changedParentTypes},this];o?this.emit("stack-item-added",l):this.emit("stack-item-updated",l)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const e=new Set(this.scope);(t=te(t)?t:[t]).forEach(t=>{e.has(t)||(e.add(t),(t instanceof Us?t.doc!==this.doc:t!==this.doc)&&ui("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(n=>{t&&(this.undoStack.forEach(t=>bs(n,this,t)),this.undoStack=[]),e&&(this.redoStack.forEach(t=>bs(n,this,t)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){let t;this.undoing=!0;try{t=vs(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){let t;this.redoing=!0;try{t=vs(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};var ks=class{constructor(t,e){this.gen=function*(t){const e=We(t.restDecoder);for(let n=0;n<e;n++){const e=We(t.restDecoder),n=t.readClient();let r=We(t.restDecoder);for(let i=0;i<e;i++){const e=t.readInfo();if(10===e){const e=We(t.restDecoder);yield new ol(Vi(n,r),e),r+=e}else if(31&e){const i=!(192&e),s=new rl(Vi(n,r),null,128&~e?null:t.readLeftID(),null,64&~e?null:t.readRightID(),i?t.readParentInfo()?t.readString():t.readLeftID():null,!i||32&~e?null:t.readString(),il(t,e));yield s,r+=s.length}else{const e=t.readLen();yield new To(Vi(n,r),e),r+=e}}}}(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===ol);return this.curr}},Cs=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Es=(t,e)=>{if(t.constructor===To){const{client:n,clock:r}=t.id;return new To(Vi(n,r+e),t.length-e)}if(t.constructor===ol){const{client:n,clock:r}=t.id;return new ol(Vi(n,r+e),t.length-e)}{const n=t,{client:r,clock:i}=n.id;return new rl(Vi(r,i+e),null,Vi(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},_s=(t,e=Di,n=Mi)=>{if(1===t.length)return t[0];const r=t.map(t=>new e(qe(t)));let i=r.map(t=>new ks(t,!0)),s=null;const o=new n,l=new Cs(o);for(;i=i.filter(t=>null!==t.curr),i.sort((t,e)=>{if(t.curr.id.client===e.curr.id.client){const n=t.curr.id.clock-e.curr.id.clock;return 0===n?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===ol?1:-1:n}return e.curr.id.client-t.curr.id.client}),0!==i.length;){const t=i[0],e=t.curr.id.client;if(null!==s){let n=t.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=s.struct.id.clock+s.struct.length&&n.id.client>=s.struct.id.client;)n=t.next(),r=!0;if(null===n||n.id.client!==e||r&&n.id.clock>s.struct.id.clock+s.struct.length)continue;if(e!==s.struct.id.client)js(l,s.struct,s.offset),s={struct:n,offset:0},t.next();else if(s.struct.id.clock+s.struct.length<n.id.clock)if(s.struct.constructor===ol)s.struct.length=n.id.clock+n.length-s.struct.id.clock;else{js(l,s.struct,s.offset);const t=n.id.clock-s.struct.id.clock-s.struct.length;s={struct:new ol(Vi(e,s.struct.id.clock+s.struct.length),t),offset:0}}else{const e=s.struct.id.clock+s.struct.length-n.id.clock;e>0&&(s.struct.constructor===ol?s.struct.length-=e:n=Es(n,e)),s.struct.mergeWith(n)||(js(l,s.struct,s.offset),s={struct:n,offset:0},t.next())}}else s={struct:t.curr,offset:0},t.next();for(let n=t.curr;null!==n&&n.id.client===e&&n.id.clock===s.struct.id.clock+s.struct.length&&n.constructor!==ol;n=t.next())js(l,s.struct,s.offset),s={struct:n,offset:0}}null!==s&&(js(l,s.struct,s.offset),s=null),Ds(l);const c=r.map(t=>(t=>{const e=new xi,n=We(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const n=We(t.restDecoder),r=We(t.restDecoder);if(r>0){const i=Kt(e.clients,n,()=>[]);for(let e=0;e<r;e++)i.push(new mi(t.readDsClock(),t.readDsLen()))}}return e})(t)),a=vi(c);return Ci(o,a),o.toUint8Array()},As=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:be(t.encoder.restEncoder)}),t.encoder.restEncoder=ye(),t.written=0)},js=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&As(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ke(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Ds=t=>{As(t);const e=t.encoder.restEncoder;ke(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ke(e,r.written),je(e,r.restEncoder)}},Os="You must not compute changes after the event-handler fired.",Is=class{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Ts(this.currentTarget,this.target))}deletes(t){return yi(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw Le(Os);const t=new Map,e=this.target;this.transaction.changed.get(e).forEach(n=>{if(null!==n){const r=e._map.get(n);let i,s;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;i="delete",s=Gt(t.content.getContent())}else null!==t&&this.deletes(t)?(i="update",s=Gt(t.content.getContent())):(i="add",s=void 0)}else{if(!this.deletes(r))return;i="delete",s=Gt(r.content.getContent())}t.set(n,{action:i,oldValue:s})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){if(0===this.transaction.doc._transactionCleanups.length)throw Le(Os);const e=this.target,n=Wt(),r=Wt(),i=[];if(t={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let t=null;const s=()=>{t&&i.push(t)};for(let i=e._start;null!==i;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&(null!==t&&void 0!==t.delete||(s(),t={delete:0}),t.delete+=i.length,r.add(i)):this.adds(i)?(null!==t&&void 0!==t.insert||(s(),t={insert:[]}),t.insert=t.insert.concat(i.content.getContent()),n.add(i)):(null!==t&&void 0!==t.retain||(s(),t={retain:0}),t.retain+=i.length);null!==t&&void 0===t.retain&&s()}this._changes=t}return t}},Ts=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)!r.deleted&&r.countable&&(t+=r.length),r=r.right;n.unshift(t)}e=e._item.parent}return n},Ms=()=>{ui("Invalid access: Add Yjs type to a document before reading data.")},Ns=0,Rs=class{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Ns++}},zs=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ns++},Ps=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce((t,n)=>re(e-t.index)<re(e-n.index)?t:n);let r=t._start,i=0;for(null!==n&&(r=n.p,i=n.index,(t=>{t.timestamp=Ns++})(n));null!==r.right&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;null!==r.left&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return null!==n&&re(n.index-i)<r.parent.length/80?(zs(n,r,i),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce((t,e)=>t.timestamp<e.timestamp?t:e);return zs(r,e,n),r}{const r=new Rs(e,n);return t.push(r),r}})(t._searchMarker,r,i)},Bs=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let e=i.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(i.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}i.p=e,e.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=se(e,i.index+n))}},Ls=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Kt(i,t,()=>[]).push(n),null!==t._item;)t=t._item.parent;Fi(r._eH,n,e)},Us=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Bi(),this._dEH=Bi(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw Ue()}clone(){throw Ue()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Li(this._eH,t)}observeDeep(t){Li(this._dEH,t)}unobserve(t){Ui(this._eH,t)}unobserveDeep(t){Ui(this._dEH,t)}toJSON(){}},Fs=(t,e,n)=>{t.doc??Ms(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;null!==s&&r>0;){if(s.countable&&!s.deleted){const t=s.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)i.push(t[n]),r--;e=0}}s=s.right}return i},$s=t=>{t.doc??Ms();const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},Hs=(t,e)=>{const n=[];let r=t._start;for(;null!==r;){if(r.countable&&es(r,e)){const t=r.content.getContent();for(let e=0;e<t.length;e++)n.push(t[e])}r=r.right}return n},Vs=(t,e)=>{let n=0,r=t._start;for(t.doc??Ms();null!==r;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let r=0;r<i.length;r++)e(i[r],n++,t)}r=r.right}},qs=(t,e)=>{const n=[];return Vs(t,(r,i)=>{n.push(e(r,i,t))}),n},Js=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},Ks=(t,e)=>{t.doc??Ms();const n=Ps(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Ws=(t,e,n,r)=>{let i=n;const s=t.doc,o=s.clientID,l=s.store,c=null===n?e._start:n.right;let a=[];const h=()=>{a.length>0&&(i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Fo(a)),i.integrate(t,0),a=[])};r.forEach(n=>{if(null===n)a.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(n);break;default:switch(h(),n.constructor){case Uint8Array:case ArrayBuffer:i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Mo(new Uint8Array(n))),i.integrate(t,0);break;case Ai:i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new zo(n)),i.integrate(t,0);break;default:if(!(n instanceof Us))throw new Error("Unexpected content type in insert operation");i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Yo(n)),i.integrate(t,0)}}}),h()},Gs=()=>Le("Length exceeded!"),Xs=(t,e,n,r)=>{if(n>e._length)throw Gs();if(0===n)return e._searchMarker&&Bs(e._searchMarker,n,r.length),Ws(t,e,null,r);const i=n,s=Ps(e,n);let o=e._start;for(null!==s&&(o=s.p,0===(n-=s.index)&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));null!==o;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&hs(t,Vi(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Bs(e._searchMarker,i,r.length),Ws(t,e,o,r)},Ys=(t,e,n,r)=>{if(0===r)return;const i=n,s=r,o=Ps(e,n);let l=e._start;for(null!==o&&(l=o.p,n-=o.index);null!==l&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&hs(t,Vi(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&null!==l;)l.deleted||(r<l.length&&hs(t,Vi(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Gs();e._searchMarker&&Bs(e._searchMarker,i,-s+r)},Zs=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},Qs=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(null==r)l=new Fo([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Fo([r]);break;case Uint8Array:l=new Mo(r);break;case Ai:l=new zo(r);break;default:if(!(r instanceof Us))throw new Error("Unexpected content type");l=new Yo(r)}new rl(Vi(o,ss(s.store,o)),i,i&&i.lastId,null,null,e,n,l).integrate(t,0)},to=(t,e)=>{t.doc??Ms();const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},eo=t=>{const e={};return t.doc??Ms(),t._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},no=(t,e)=>{t.doc??Ms();const n=t._map.get(e);return void 0!==n&&!n.deleted},ro=t=>{return t.doc??Ms(),e=t._map.entries(),n=t=>!t[1].deleted,fi(()=>{let t;do{t=e.next()}while(!t.done&&!n(t.value));return t});var e,n},io=class extends Is{},so=class t extends Us{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new t;return n.push(e),n}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}get length(){return this.doc??Ms(),this._length}_callObserver(t,e){super._callObserver(t,e),Ls(this,t,new io(this,t))}insert(t,e){null!==this.doc?ws(this.doc,n=>{Xs(n,this,t,e)}):this._prelimContent.splice(t,0,...e)}push(t){null!==this.doc?ws(this.doc,e=>{((t,e,n)=>{let r=(e._searchMarker||[]).reduce((t,e)=>e.index>t.index?e:t,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;Ws(t,e,r,n)})(e,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?ws(this.doc,n=>{Ys(n,this,t,e)}):this._prelimContent.splice(t,e)}get(t){return Ks(this,t)}toArray(){return $s(this)}slice(t=0,e=this.length){return Fs(this,t,e)}toJSON(){return this.map(t=>t instanceof Us?t.toJSON():t)}map(t){return qs(this,t)}forEach(t){Vs(this,t)}[Symbol.iterator](){return Js(this)}_write(t){t.writeTypeRef(Vo)}},oo=class extends Is{constructor(t,e,n){super(t,e),this.keysChanged=n}},lo=class t extends Us{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((t,e)=>{this.set(e,t)}),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return this.forEach((t,n)=>{e.set(n,t instanceof Us?t.clone():t)}),e}_callObserver(t,e){Ls(this,t,new oo(this,t,e))}toJSON(){this.doc??Ms();const t={};return this._map.forEach((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof Us?r.toJSON():r}}),t}get size(){return[...ro(this)].length}keys(){return gi(ro(this),t=>t[0])}values(){return gi(ro(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return gi(ro(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??Ms(),this._map.forEach((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._prelimContent.set(t,e),e}get(t){return to(this,t)}has(t){return no(this,t)}clear(){null!==this.doc?ws(this.doc,t=>{this.forEach(function(e,n,r){Zs(t,r,n)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(qo)}},co=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&((t,e)=>t===e||Sn(t)===Sn(e)&&kn(t,(t,n)=>(void 0!==t||Cn(e,n))&&yn(e[n],t)))(t,e),ao=class{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&Fe(),this.right.content.constructor===Bo)this.right.deleted||fo(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}},ho=(t,e,n)=>{for(;null!==e.right&&n>0;){if(e.right.content.constructor===Bo)e.right.deleted||fo(e.currentAttributes,e.right.content);else e.right.deleted||(n<e.right.length&&hs(t,Vi(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);e.left=e.right,e.right=e.right.right}return e},uo=(t,e,n,r)=>{const i=new Map,s=r?Ps(e,n):null;if(s){const e=new ao(s.p.left,s.p,s.index,i);return ho(t,e,n-s.index)}{const r=new ao(null,e._start,0,i);return ho(t,r,n)}},po=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===Bo&&co(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((r,o)=>{const l=n.left,c=n.right,a=new rl(Vi(s,ss(i.store,s)),l,l&&l.lastId,c,c&&c.id,e,null,new Bo(o,r));a.integrate(t,0),n.right=a,n.forward()})},fo=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},go=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===Bo&&co(e[t.right.content.key]??null,t.right.content.value));)t.forward()},mo=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const l in r){const c=r[l],a=n.currentAttributes.get(l)??null;if(!co(a,c)){o.set(l,a);const{left:r,right:h}=n;n.right=new rl(Vi(s,ss(i.store,s)),r,r&&r.lastId,h,h&&h.id,e,null,new Bo(l,c)),n.right.integrate(t,0),n.forward()}}return o},xo=(t,e,n,r,i)=>{n.currentAttributes.forEach((t,e)=>{void 0===i[e]&&(i[e]=null)});const s=t.doc,o=s.clientID;go(n,i);const l=mo(t,e,n,i),c=r.constructor===String?new $o(r):r instanceof Us?new Yo(r):new Po(r);let{left:a,right:h,index:d}=n;e._searchMarker&&Bs(e._searchMarker,n.index,c.getLength()),h=new rl(Vi(o,ss(s.store,o)),a,a&&a.lastId,h,h&&h.id,e,null,c),h.integrate(t,0),n.right=h,n.index=d,n.forward(),po(t,e,n,l)},wo=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;go(n,i);const l=mo(t,e,n,i);t:for(;null!==n.right&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Bo));){if(!n.right.deleted)switch(n.right.content.constructor){case Bo:{const{key:e,value:s}=n.right.content,o=i[e];if(void 0!==o){if(co(o,s))l.delete(e);else{if(0===r)break t;l.set(e,s)}n.right.delete(t)}else n.currentAttributes.set(e,s);break}default:r<n.right.length&&hs(t,Vi(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i="";for(;r>0;r--)i+="\n";n.right=new rl(Vi(o,ss(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new $o(i)),n.right.integrate(t,0),n.forward()}po(t,e,n,l)},yo=(t,e,n,r,i)=>{let s=e;const o=qt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Bo){const t=s.content;o.set(t.key,t)}s=s.right}let l=0,c=!1;for(;e!==s;){if(n===e&&(c=!0),!e.deleted){const n=e.content;switch(n.constructor){case Bo:{const{key:s,value:a}=n,h=r.get(s)??null;o.get(s)===n&&h!==a||(e.delete(t),l++,c||(i.get(s)??null)!==a||h===a||(null===h?i.delete(s):i.set(s,h))),c||e.deleted||fo(i,n);break}}}e=e.right}return l},bo=t=>{let e=0;return ws(t.doc,n=>{let r=t._start,i=t._start,s=qt();const o=Jt(s);for(;i;){if(!1===i.deleted)if(i.content.constructor===Bo)fo(o,i.content);else e+=yo(n,r,i,s,o),s=Jt(o),r=i;i=i.right}}),e},vo=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const s=t.beforeState.get(r)||0;i!==s&&us(t,n.store.clients.get(r),s,i,t=>{t.deleted||t.content.constructor!==Bo||t.constructor===To||e.add(t.parent)})}ws(n,n=>{wi(t,t.deleteSet,t=>{if(t instanceof To||!t.parent._hasFormatting||e.has(t.parent))return;const r=t.parent;t.content.constructor===Bo?e.add(r):((t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Bo){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(n,t)});for(const t of e)bo(t)})},So=(t,e,n)=>{const r=n,i=Jt(e.currentAttributes),s=e.right;for(;n>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case Yo:case Po:case $o:n<e.right.length&&hs(t,Vi(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t)}e.forward()}s&&yo(t,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Bs(o._searchMarker,e.index,-r+n),e},ko=class extends Is{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)})}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];ws(t,t=>{const n=new Map,r=new Map;let i=this.target._start,s=null;const o={};let l="",c=0,a=0;const h=()=>{if(null!==s){let t=null;switch(s){case"delete":a>0&&(t={delete:a}),a=0;break;case"insert":("object"==typeof l||l.length>0)&&(t={insert:l},n.size>0&&(t.attributes={},n.forEach((e,n)=>{null!==e&&(t.attributes[n]=e)}))),l="";break;case"retain":c>0&&(t={retain:c},(t=>{for(const e in t)return!1;return!0})(o)||(t.attributes=bn({},o))),c=0}t&&e.push(t),s=null}};for(;null!==i;){switch(i.content.constructor){case Yo:case Po:this.adds(i)?this.deletes(i)||(h(),s="insert",l=i.content.getContent()[0],h()):this.deletes(i)?("delete"!==s&&(h(),s="delete"),a+=1):i.deleted||("retain"!==s&&(h(),s="retain"),c+=1);break;case $o:this.adds(i)?this.deletes(i)||("insert"!==s&&(h(),s="insert"),l+=i.content.str):this.deletes(i)?("delete"!==s&&(h(),s="delete"),a+=i.length):i.deleted||("retain"!==s&&(h(),s="retain"),c+=i.length);break;case Bo:{const{key:e,value:l}=i.content;if(this.adds(i)){if(!this.deletes(i)){const c=n.get(e)??null;co(c,l)?null!==l&&i.delete(t):("retain"===s&&h(),co(l,r.get(e)??null)?delete o[e]:o[e]=l)}}else if(this.deletes(i)){r.set(e,l);const t=n.get(e)??null;co(t,l)||("retain"===s&&h(),o[e]=t)}else if(!i.deleted){r.set(e,l);const n=o[e];void 0!==n&&(co(n,l)?null!==n&&i.delete(t):("retain"===s&&h(),null===l?delete o[e]:o[e]=l))}i.deleted||("insert"===s&&h(),fo(n,i.content));break}}i=i.right}for(h();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}}),this._delta=e}return this._delta}},Co=class t extends Us{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ms(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach(t=>t())}catch(Xa){}this._pending=null}_copy(){return new t}clone(){const e=new t;return e.applyDelta(this.toDelta()),e}_callObserver(t,e){super._callObserver(t,e);const n=new ko(this,t,e);Ls(this,t,n),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??Ms();let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===$o&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?ws(this.doc,n=>{const r=new ao(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const s=t[i];if(void 0!==s.insert){const o=e||"string"!=typeof s.insert||i!==t.length-1||null!==r.right||"\n"!==s.insert.slice(-1)?s.insert:s.insert.slice(0,-1);("string"!=typeof o||o.length>0)&&xo(n,this,r,o,s.attributes||{})}else void 0!==s.retain?wo(n,this,r,s.retain,s.attributes||{}):void 0!==s.delete&&So(n,r,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??Ms();const r=[],i=new Map,s=this.doc;let o="",l=this._start;function c(){if(o.length>0){const t={};let e=!1;i.forEach((n,r)=>{e=!0,t[r]=n});const n={insert:o};e&&(n.attributes=t),r.push(n),o=""}}const a=()=>{for(;null!==l;){if(es(l,t)||void 0!==e&&es(l,e))switch(l.content.constructor){case $o:{const r=i.get("ychange");void 0===t||es(l,t)?void 0===e||es(l,e)?void 0!==r&&(c(),i.delete("ychange")):void 0!==r&&r.user===l.id.client&&"added"===r.type||(c(),i.set("ychange",n?n("added",l.id):{type:"added"})):void 0!==r&&r.user===l.id.client&&"removed"===r.type||(c(),i.set("ychange",n?n("removed",l.id):{type:"removed"})),o+=l.content.str;break}case Yo:case Po:{c();const t={insert:l.content.getContent()[0]};if(i.size>0){const e={};t.attributes=e,i.forEach((t,n)=>{e[n]=t})}r.push(t);break}case Bo:es(l,t)&&(c(),fo(i,l.content))}l=l.right}c()};return t||e?ws(s,n=>{t&&ns(n,t),e&&ns(n,e),a()},"cleanup"):a(),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!n);n||(n={},i.currentAttributes.forEach((t,e)=>{n[e]=t})),xo(r,this,i,e,n)}):this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!n);xo(r,this,i,e,n||{})}):this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?ws(n,n=>{So(n,uo(n,this,t,!0),e)}):this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!1);null!==i.right&&wo(r,this,i,e,n)}):this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return to(this,t)}getAttributes(){return eo(this)}_write(t){t.writeTypeRef(Jo)}},Eo=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??Ms()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==Ao&&e.constructor!==_o||null===e._start)for(;null!==t;){const e=t.next;if(null!==e){t=e;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},_o=class t extends Us{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}get length(){return this.doc??Ms(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new Eo(this,t)}querySelector(t){t=t.toUpperCase();const e=new Eo(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Yt(new Eo(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){Ls(this,t,new jo(this,e,t))}toString(){return qs(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Vs(this,i=>{r.insertBefore(i.toDOM(t,e,n),null)}),r}insert(t,e){null!==this.doc?ws(this.doc,n=>{Xs(n,this,t,e)}):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)ws(this.doc,n=>{const r=t&&t instanceof Us?t._item:t;Ws(n,this,r,e)});else{const n=this._prelimContent,r=null===t?0:n.findIndex(e=>e===t)+1;if(0===r&&null!==t)throw Le("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?ws(this.doc,n=>{Ys(n,this,t,e)}):this._prelimContent.splice(t,e)}toArray(){return $s(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Ks(this,t)}slice(t=0,e=this.length){return Fs(this,t,e)}forEach(t){Vs(this,t)}_write(t){t.writeTypeRef(Wo)}},Ao=class t extends _o{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((t,e)=>{this.setAttribute(e,t)}),this._prelimAttrs=null}_copy(){return new t(this.nodeName)}clone(){const e=new t(this.nodeName);return((t,e)=>{for(const n in t)e(t[n],n)})(this.getAttributes(),(t,n)=>{e.setAttribute(n,t)}),e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}toString(){const t=this.getAttributes(),e=[],n=[];for(const s in t)n.push(s);n.sort();const r=n.length;for(let s=0;s<r;s++){const r=n[s];e.push(r+'="'+t[r]+'"')}const i=this.nodeName.toLocaleLowerCase();return`<${i}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${i}>`}removeAttribute(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._prelimAttrs.set(t,e)}getAttribute(t){return to(this,t)}hasAttribute(t){return no(this,t)}getAttributes(t){return t?((t,e)=>{const n={};return t._map.forEach((t,r)=>{let i=t;for(;null!==i&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;null!==i&&es(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n})(this,t):eo(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const s in i){const t=i[s];"string"==typeof t&&r.setAttribute(s,t)}return Vs(this,i=>{r.appendChild(i.toDOM(t,e,n))}),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(Ko),t.writeKey(this.nodeName)}},jo=class extends Is{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)})}},Do=class t extends lo{constructor(t){super(),this.hookName=t}_copy(){return new t(this.hookName)}clone(){const e=new t(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(t=document,e={},n){const r=e[this.hookName];let i;return i=void 0!==r?r.createDom(this):document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(i,this),i}_write(t){t.writeTypeRef(Go),t.writeKey(this.hookName)}},Oo=class t extends Co{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new t}clone(){const e=new t;return e.applyDelta(this.toDelta()),e}toDOM(t=document,e,n){const r=t.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const e=[];for(const r in t.attributes){const n=[];for(const e in t.attributes[r])n.push({key:e,value:t.attributes[r][e]});n.sort((t,e)=>t.key<e.key?-1:1),e.push({nodeName:r,attrs:n})}e.sort((t,e)=>t.nodeName<e.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){const t=e[r];n+=`<${t.nodeName}`;for(let e=0;e<t.attrs.length;e++){const r=t.attrs[e];n+=` ${r.key}="${r.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Xo)}},Io=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw Ue()}mergeWith(t){return!1}write(t,e,n){throw Ue()}integrate(t,e){throw Ue()}},To=class extends Io{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),os(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}},Mo=class t{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new t(this.content)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}},No=class t{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.len)}splice(e){const n=new t(this.len-e);return this.len=e,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){Si(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}},Ro=(t,e)=>new Ai({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),zo=class t{constructor(t){t._item,this.doc=t;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new t(Ro(this.doc.guid,this.opts))}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},Po=class t{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new t(this.embed)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}},Bo=class t{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.key,this.value)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){const n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},Lo=class t{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){const n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeString(void 0===e?"undefined":JSON.stringify(e))}}getRef(){return 2}},Uo="development"===Mn("node_env"),Fo=class t{constructor(t){this.arr=t,Uo&&_n(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){const n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}},$o=class t{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new t(this.str)}splice(e){const n=new t(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}},Ho=[t=>new so,t=>new lo,t=>new Co,t=>new Ao(t.readKey()),t=>new _o,t=>new Do(t.readKey()),t=>new Oo],Vo=0,qo=1,Jo=2,Ko=3,Wo=4,Go=5,Xo=6,Yo=class t{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new t(this.type._copy())}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach(e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach(e=>{for(;null!==e;)e.gc(t,!0),e=e.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}},Zo=(t,e)=>{let n,r=e,i=0;do{i>0&&(r=Vi(r.client,r.clock+i)),n=cs(t,r),i=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof rl);return{item:n,diff:i}},Qo=(t,e)=>{for(;null!==t&&t.keep!==e;)t.keep=e,t=t.parent._item},tl=(t,e,n)=>{const{client:r,clock:i}=e.id,s=new rl(Vi(r,i+n),e,Vi(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),null!==e.redone&&(s.redone=Vi(e.redone.client,e.redone.clock+n)),e.right=s,null!==s.right&&(s.right.left=s),t._mergeStructs.push(s),null!==s.parentSub&&null===s.right&&s.parent._map.set(s.parentSub,s),e.length=n,s},el=(t,e)=>Qt(t,t=>yi(t.deletions,e)),nl=(t,e,n,r,i,s)=>{const o=t.doc,l=o.store,c=o.clientID,a=e.redone;if(null!==a)return hs(t,a);let h,d=e.parent._item,u=null;if(null!==d&&!0===d.deleted){if(null===d.redone&&(!n.has(d)||null===nl(t,d,n,r,i,s)))return null;for(;null!==d.redone;)d=hs(t,d.redone)}const p=null===d?e.parent:d.content.type;if(null===e.parentSub){for(u=e.left,h=e;null!==u;){let e=u;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:hs(t,e.redone);if(null!==e&&e.parent._item===d){u=e;break}u=u.left}for(;null!==h;){let e=h;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:hs(t,e.redone);if(null!==e&&e.parent._item===d){h=e;break}h=h.right}}else{if(h=null,e.right&&!i){for(u=e;null!==u&&null!==u.right&&(u.right.redone||yi(r,u.right.id)||el(s.undoStack,u.right.id)||el(s.redoStack,u.right.id));)for(u=u.right;u.redone;)u=hs(t,u.redone);if(u&&null!==u.right)return null}else u=p._map.get(e.parentSub)||null;null!==u&&u.parent._item!==d&&(u=p._map.get(e.parentSub)||null)}const f=ss(l,c),g=Vi(c,f),m=new rl(g,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=g,Qo(m,!0),m.integrate(t,0),m},rl=class t extends Io{constructor(t,e,n,r,i,s,o,l){super(t,l.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=i,this.parent=s,this.parentSub=o,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(8&this.info)>0!==t&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ss(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ss(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$i&&this.id.client!==this.parent.client&&this.parent.clock>=ss(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ds(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=hs(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===To||this.right&&this.right.constructor===To)this.parent=null;else if(this.parent){if(this.parent.constructor===$i){const t=cs(n,this.parent);t.constructor===To?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===t?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===t&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=ds(t,t.doc.store,Vi(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,i=new Set;for(;null!==e&&e!==this.right;){if(i.add(e),r.add(e),Hi(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(Hi(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!i.has(cs(t.doc.store,e.origin)))break;r.has(cs(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),os(t.doc.store,this),this.content.integrate(t,this),gs(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new To(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:Vi(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Hi(t.origin,this.lastId)&&this.right===t&&Hi(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach(e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),Si(t.deleteSet,this.id.client,this.id.clock,this.length),gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw Fe();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[ls(r,e.id.clock)]=n})(t,this,new To(this.id,this.length)):this.content=new No(this.length)}write(t,e){const n=e>0?Vi(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,i=this.parentSub,s=31&this.content.getRef()|(null===n?0:128)|(null===r?0:64)|(null===i?0:32);if(t.writeInfo(s),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=qi(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===$i?(t.writeParentInfo(!1),t.writeLeftID(e)):Fe();null!==i&&t.writeString(i)}this.content.write(t,e)}},il=(t,e)=>sl[31&e](t),sl=[()=>{Fe()},t=>new No(t.readLen()),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const e=t.readString();"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return new Lo(n)},t=>new Mo(t.readBuf()),t=>new $o(t.readString()),t=>new Po(t.readJSON()),t=>new Bo(t.readKey(),t.readJSON()),t=>new Yo(Ho[t.readTypeRef()](t)),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Fo(n)},t=>new zo(Ro(t.readString(),t.readAny())),()=>{Fe()}],ol=class extends Io{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){Fe()}write(t,e){t.writeInfo(10),ke(t.restEncoder,this.length-e)}getMissing(t,e){return null}},ll="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},cl="__ $YJS$ __";function al(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let t=i.text,e=s.text,r=0;for(;t[r]==e[r];r++)n++;return r&&r<t.length&&r<e.length&&ul(t.charCodeAt(r-1))&&dl(t.charCodeAt(r))&&n--,n}if(i.content.size||s.content.size){let t=al(i.content,s.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function hl(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),c=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let t=o.text,e=l.text,i=t.length,s=e.length;for(;i>0&&s>0&&t[i-1]==e[s-1];)i--,s--,n--,r--;return i&&s&&i<t.length&&ul(t.charCodeAt(i-1))&&dl(t.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let t=hl(o.content,l.content,n-1,r-1);if(t)return t}n-=c,r-=c}else n-=c,r-=c}}function dl(t){return t>=56320&&t<57344}function ul(t){return t>=55296&&t<56320}ll[cl],ll[cl]=!0;var pl=class t{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let n=0;n<t.length;n++)this.size+=t[n].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],c=o+l.nodeSize;if(c>t&&!1!==n(l,r+o,i||null,s)&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),n,r+i)}o=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,(o,l)=>{let c=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(s?s=!1:i+=n),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new t(i,this.size+e.size)}cut(e,n=this.size){if(0==e&&n==this.size)return this;let r=[],i=0;if(n>e)for(let t=0,s=0;s<n;t++){let o=this.content[t],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new t(r,i)}cutByIndex(e,n){return e==n?t.empty:0==e&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new t(i,s)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return al(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return hl(this,t,e,n)}findIndex(t){if(0==t)return gl(0,t);if(t==this.size)return gl(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=n+this.child(e).nodeSize;if(r>=t)return r==t?gl(e+1,r):gl(e,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let t=0;t<e.length;t++){let i=e[t];r+=i.nodeSize,t&&i.isText&&e[t-1].sameMarkup(i)?(n||(n=e.slice(0,t)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};pl.empty=new pl([],0);var fl={index:0,offset:0};function gl(t,e){return fl.index=t,fl.offset=e,fl}function ml(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!ml(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!ml(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}var xl=class t{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&ml(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((t,e)=>t.type.rank-e.type.rank),n}};xl.none=[];var wl=class extends Error{},yl=class t{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=vl(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(bl(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,i=n.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new t(pl.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let t=e.firstChild;t&&!t.isLeaf&&(n||!t.type.spec.isolating);t=t.firstChild)r++;for(let t=e.lastChild;t&&!t.isLeaf&&(n||!t.type.spec.isolating);t=t.lastChild)i++;return new t(e,r,i)}};function bl(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(bl(s.content,e-i-1,n-i-1)))}function vl(t,e,n,r,i,s){let{index:o,offset:l}=t.findIndex(e),c=t.maybeChild(o);if(l==e||c.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=vl(c.content,e-l-1,n,0==o?r-1:0,o==t.childCount-1?i-1:0,c);return a&&t.replaceChild(o,c.copy(a))}yl.empty=new yl(pl.empty,0,0);Object.create(null);var Sl=class t{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new kl(e,n);if(null==r.next)return t.empty;let i=Cl(r);r.next&&r.err("Unexpected trailing text");let s=Il(function(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach(t=>t.to=e)}function s(t,e){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(s(n,e)),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(e,o),i(s(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return i(s(t.expr,e),o),i(s(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(e)].concat(s(t.expr,e));if("range"==t.type){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e),o=e}if(-1==t.max)i(s(t.expr,o),o);else for(let e=t.min;e<t.max;e++){let e=n();r(o,e),i(s(t.expr,o),e),o=e}return[r(o)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}}(i));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,r),s}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let l=s.matchFragment(t,n);if(l&&(!e||l.validEnd))return pl.from(o.map(t=>t.createAndFill()));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==t)return this.wrapCache[n+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r}).join("\n")}};Sl.empty=new Sl(!0);var kl=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function Cl(t){let e=[];do{e.push(El(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function El(t){let e=[];do{e.push(_l(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function _l(t){let e=function(t){if(t.eat("(")){let e=Cl(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let t=n[s];t.isInGroup(e)&&i.push(t)}0==i.length&&t.err("No node type or group '"+e+"' found");return i}(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=jl(t,e)}return e}function Al(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function jl(t,e){let n=Al(t),r=n;return t.eat(",")&&(r="}"!=t.next?Al(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Dl(t,e){return e-t}function Ol(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort(Dl)}function Il(t){let e=Object.create(null);return function n(r){let i=[];r.forEach(e=>{t[e].forEach(({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);Ol(t,n).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})})});let s=e[r.join(",")]=new Sl(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(Dl);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}(Ol(t,0))}var Tl=Math.pow(2,16);function Ml(t,e){return t+e*Tl}function Nl(t){return 65535&t}var Rl=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}},zl=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(t){let e=0,n=Nl(t);if(!this.inverted)for(let r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/Tl}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[o+i],a=this.ranges[o+s],h=l+c;if(t<=h){let i=l+r+((c?t==l?-1:t==h?1:e:e)<0?0:a);if(n)return i;let s=t==(e<0?l:h)?null:Ml(o/3,t-l),d=t==l?2:t==h?1:4;return(e<0?t!=l:t!=h)&&(d|=8),new Rl(i,d,s)}r+=a-c}return n?t+r:new Rl(t+r,0,null)}touches(t,e){let n=0,r=Nl(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let e=this.ranges[o]-(this.inverted?n:0);if(e>t)break;let l=this.ranges[o+i];if(t<=e+l&&o==3*r)return!0;n+=this.ranges[o+s]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),c=this.ranges[r+e],a=this.ranges[r+n];t(o,o+c,l,l+a),i+=a-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};zl.empty=new zl([]);var Pl=Object.create(null),Bl=class{getMap(){return zl.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Pl[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Pl)throw new RangeError("Duplicate use of step JSON ID "+t);return Pl[t]=e,e.prototype.jsonID=t,e}},Ll=class t{constructor(t,e){this.doc=t,this.failed=e}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,i){try{return t.ok(e.replace(n,r,i))}catch(Xa){if(Xa instanceof wl)return t.fail(Xa.message);throw Xa}}};function Ul(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Ul(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pl.fromArray(r)}var Fl=class t extends Bl{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new yl(Ul(e.content,(t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t,r),e.openStart,e.openEnd);return Ll.fromReplace(t,this.from,this.to,i)}invert(){return new $l(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Bl.jsonID("addMark",Fl);var $l=class t extends Bl{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new yl(Ul(e.content,t=>t.mark(this.mark.removeFromSet(t.marks)),t),e.openStart,e.openEnd);return Ll.fromReplace(t,this.from,this.to,n)}invert(){return new Fl(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Bl.jsonID("removeMark",$l);var Hl=class t extends Bl{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(n),0,e.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let e=this.mark.addToSet(n.marks);if(e.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(e))return new t(this.pos,n.marks[r]);return new t(this.pos,this.mark)}}return new Vl(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Bl.jsonID("addNodeMark",Hl);var Vl=class t extends Bl{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Hl(this.pos,this.mark):this}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Bl.jsonID("removeNodeMark",Vl);var ql=class t extends Bl{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&Kl(t,this.from,this.to)?Ll.fail("Structure replace would overwrite content"):Ll.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new zl([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let n=this.slice.size+e.slice.size==0?yl.empty:new yl(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}}{let n=this.slice.size+e.slice.size==0?yl.empty:new yl(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,yl.fromJSON(e,n.slice),!!n.structure)}};ql.MAP_BIAS=1,Bl.jsonID("replace",ql);var Jl=class t extends Bl{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Kl(t,this.from,this.gapFrom)||Kl(t,this.gapTo,this.to)))return Ll.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Ll.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?Ll.fromReplace(t,this.from,this.to,n):Ll.fail("Content does not fit in gap")}getMap(){return new zl([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new t(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,yl.fromJSON(e,n.slice),n.insert,!!n.structure)}};function Kl(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}Bl.jsonID("replaceAround",Jl);Bl.jsonID("attr",class t extends Bl{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at attribute step's position");let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(r),0,e.isLeaf?0:1))}getMap(){return zl.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}});Bl.jsonID("docAttr",class t extends Bl{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return Ll.ok(n)}getMap(){return zl.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}});var Wl=Error;((Wl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n}).prototype=Object.create(Error.prototype)).constructor=Wl,Wl.prototype.name="TransformError";var Gl=Object.create(null),Xl=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Yl(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=yl.empty){let n=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:c}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(c.pos),o?yl.empty:e),0==o&&lc(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],l=t.mapping.slice(n),c=l.map(s.pos),a=l.map(o.pos);i?t.deleteRange(c,a):(t.replaceRangeWith(c,a,e),lc(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new tc(t):oc(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let i=t.depth-1;i>=0;i--){let r=e<0?oc(t.node(0),t.node(i),t.before(i+1),t.index(i),e,n):oc(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ic(t.node(0))}static atStart(t){return oc(t,t,0,0,1)||new ic(t)}static atEnd(t){return oc(t,t,t.content.size,t.childCount,-1)||new ic(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Gl[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Gl)throw new RangeError("Duplicate use of selection JSON ID "+t);return Gl[t]=e,e.prototype.jsonID=t,e}getBookmark(){return tc.between(this.$anchor,this.$head).getBookmark()}};Xl.prototype.visible=!0;var Yl=class{constructor(t,e){this.$from=t,this.$to=e}},Zl=!1;function Ql(t){Zl||t.parent.inlineContent||(Zl=!0)}var tc=class t extends Xl{constructor(t,e=t){Ql(t),Ql(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Xl.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(t,e=yl.empty){if(super.replace(t,e),e==yl.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ec(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(e,n,r){let i=e.pos-n.pos;if(r&&!i||(r=i>=0?1:-1),!n.parent.inlineContent){let t=Xl.findFrom(n,r,!0)||Xl.findFrom(n,-r,!0);if(!t)return Xl.near(n,r);n=t.$head}return e.parent.inlineContent||(0==i||(e=(Xl.findFrom(e,-r,!0)||Xl.findFrom(e,r,!0)).$anchor).pos<n.pos!=i<0)&&(e=n),new t(e,n)}};Xl.jsonID("text",tc);var ec=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){return tc.between(t.resolve(this.anchor),t.resolve(this.head))}},nc=class t extends Xl{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?Xl.near(s):new t(s)}content(){return new yl(pl.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new rc(this.anchor)}static fromJSON(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}};nc.prototype.visible=!1,Xl.jsonID("node",nc);var rc=class t{constructor(t){this.anchor=t}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ec(r,r):new t(r)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&nc.isSelectable(n)?new nc(e):Xl.near(e)}},ic=class t extends Xl{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=yl.empty){if(e==yl.empty){t.delete(0,t.doc.content.size);let e=Xl.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return sc}};Xl.jsonID("all",ic);var sc={map(){return this},resolve:t=>new ic(t)};function oc(t,e,n,r,i,s=!1){if(e.inlineContent)return tc.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&nc.isSelectable(r))return nc.create(t,n-(i<0?r.nodeSize:0))}else{let e=oc(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function lc(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof ql||s instanceof Jl)&&(t.mapping.maps[r].forEach((t,e,n,r)=>{null==i&&(i=r)}),t.setSelection(Xl.near(t.doc.resolve(i),n)))}function cc(t,e){return e&&t?t.bind(e):t}var ac=class{constructor(t,e,n){this.name=t,this.init=cc(e.init,n),this.apply=cc(e.apply,n)}};new ac("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ac("selection",{init:(t,e)=>t.selection||Xl.atStart(e.doc),apply:t=>t.selection}),new ac("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new ac("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e});function hc(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=hc(i,e,{})),n[r]=i}return n}var dc=class{constructor(t){this.spec=t,this.props={},t.props&&hc(t.props,this,this.props),this.key=t.key?t.key.key:pc("plugin")}getState(t){return t[this.key]}},uc=Object.create(null);function pc(t){return t in uc?t+"$"+ ++uc[t]:(uc[t]=0,t+"$")}var fc=class{constructor(t="key"){this.key=pc(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}},gc=/[\uD800-\uDBFF]/,mc=/[\uDC00-\uDFFF]/,xc=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&gc.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&mc.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},wc=(t,e)=>t>>>e|t<<32-e,yc=t=>wc(t,2)^wc(t,13)^wc(t,22),bc=t=>wc(t,6)^wc(t,11)^wc(t,25),vc=t=>wc(t,7)^wc(t,18)^t>>>3,Sc=t=>wc(t,17)^wc(t,19)^t>>>10,kc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Cc=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ec=class{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(Cc),this._W=new Uint32Array(t,64,64)}_updateHash(){const t=this._H,e=this._W;for(let h=16;h<64;h++)e[h]=Sc(e[h-2])+e[h-7]+vc(e[h-15])+e[h-16];let n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],l=t[5],c=t[6],a=t[7];for(let h,d,u=0;u<64;u++)h=a+bc(o)+(o&l^~o&c)+kc[u]+e[u]>>>0,d=yc(n)+(n&r^n&i^r&i)>>>0,a=c,c=l,l=o,o=s+h>>>0,s=i,i=r,r=n,n=h+d>>>0;t[0]+=n,t[1]+=r,t[2]+=i,t[3]+=s,t[4]+=o,t[5]+=l,t[6]+=c,t[7]+=a}digest(t){let e=0;for(;e+56<=t.length;){let n=0;for(;n<16&&e+3<t.length;n++)this._W[n]=t[e++]<<24|t[e++]<<16|t[e++]<<8|t[e++];if(e%64!=0){for(this._W.fill(0,n,16);e<t.length;)this._W[n]|=t[e]<<8*(3-e%4),e++;this._W[n]|=128<<8*(3-e%4)}this._updateHash()}const n=e%64!=0;this._W.fill(0,0,16);let r=0;for(;e<t.length;r++)for(let n=3;n>=0&&e<t.length;n--)this._W[r]|=t[e++]<<8*n;n||(this._W[r-(e%4==0?0:1)]|=128<<8*(3-e%4)),this._W[14]=t.byteLength/536870912,this._W[15]=8*t.byteLength,this._updateHash();const i=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let t=0;t<4;t++)i[4*s+t]=this._H[s]>>>8*(3-t);return i}},_c=new fc("y-sync"),Ac=new fc("y-undo"),jc=(new fc("yjs-cursor"),t=>{return Pn((t=>{for(let e=6;e<t.length;e++)t[e%6]=t[e%6]^t[e];return t.slice(0,6)})((e=Bn(t),(new Ec).digest(e))));var e}),Dc=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!yi(e.ds,t.id),Oc=[{light:"#ecd44433",dark:"#ecd444"}],Ic=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const n=Wt();t.forEach(t=>n.add(t)),e=e.filter(t=>!n.has(t))}t.set(n,(r=e)[ne(on()*r.length)])}var r;return t.get(n)},Tc=(t,{colors:e=Oc,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1;const l=new Pc(t,s),c=new dc({props:{editable:t=>{const e=_c.getState(t);return null==e.snapshot&&null==e.prevSnapshot}},key:_c,state:{init:(i,s)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(t,e)=>{const n=t.getMeta(_c);if(void 0!==n){e=Object.assign({},e);for(const t in n)e[t]=n[t]}return e.addToHistory=!1!==t.getMeta("addToHistory"),e.isChangeOrigin=void 0!==n&&!!n.isChangeOrigin,e.isUndoRedoOperation=void 0!==n&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,null!==l.prosemirrorView&&(void 0===n||null==n.snapshot&&null==n.prevSnapshot||ei(0,()=>{null!=l.prosemirrorView&&(null==n.restore?l._renderSnapshot(n.snapshot,n.prevSnapshot,e):(l._renderSnapshot(n.snapshot,n.snapshot,e),delete e.restore,delete e.snapshot,delete e.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))})),e}},view:t=>(l.initView(t),null==s&&l._forceRerender(),i(),{update:()=>{const e=c.getState(t.state);if(null==e.snapshot&&null==e.prevSnapshot&&(o||null!==t.state.doc.content.findDiffStart(t.state.doc.type.createAndFill().content))){if(o=!0,!1===e.addToHistory&&!e.isChangeOrigin){const e=Ac.getState(t.state),n=e&&e.undoManager;n&&n.stopCapturing()}l.mux(()=>{e.doc.transact(n=>{n.meta.set("addToHistory",e.addToHistory),l._prosemirrorChanged(t.state.doc)},_c)})}},destroy:()=>{l.destroy()}})});return c},Mc=(t,e,n,r)=>{if(null==n)return r;if(!(null===r||n>1&&r<=1||ua(e,t,n,r)))return r;const i=da(e,t,n);return null!==i?i:r},Nc=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?nc.create(t.doc,e):tc.near(n)},Rc=(t,e,n,r)=>{if(null===e||null===n)return null;const i=Math.min(Math.max(e,0),t.doc.content.size),s=Math.min(Math.max(n,0),t.doc.content.size);try{const e=Xl.fromJSON(t.doc,{type:"nodeRange",anchor:i,head:s,depth:r});return e.ranges.length?e:tc.near(t.doc.resolve(i))}catch(Xa){return tc.near(t.doc.resolve(i))}},zc=(t,e)=>{const n=e.selection.jsonID;return{type:n,depth:"nodeRange"===n?e.selection.depth:void 0,anchor:la(e.selection.anchor,t.type,t.mapping),head:la(e.selection.head,t.type,t.mapping),absAnchor:e.selection.anchor,absHead:e.selection.head}},Pc=class{constructor(t,e=new Map){this.type=t,this.prosemirrorView=null,this.mux=(()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else void 0!==n&&n()}})(),this.mapping=e,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=t.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{null===this.beforeTransactionSelection&&null!=this.prosemirrorView&&(this.beforeTransactionSelection=zc(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return!!this.prosemirrorView.hasFocus()&&(On&&null===this._domSelectionInView&&(ei(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView)}_isDomSelectionInView(){const t=this.prosemirrorView._root.getSelection();if(null==t||null==t.anchorNode)return!1;const e=this.prosemirrorView._root.createRange();e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),0===e.getClientRects().length&&e.startContainer&&e.collapsed&&e.selectNodeContents(e.startContainer);const n=e.getBoundingClientRect(),r=Wr.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(t,e){e||(e=Qi(ki(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(_c,{snapshot:t,prevSnapshot:e}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const t=this.type.toArray().map(t=>Lc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),e=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(t),0,0));e.setMeta(_c,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(e)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const t=null!==this.beforeTransactionSelection?null:this.prosemirrorView.state.selection,e=this.type.toArray().map(t=>Lc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(e),0,0));if(t){const e=ie(se(t.anchor,0),n.doc.content.size),r=ie(se(t.head,0),n.doc.content.size);n.setSelection(tc.create(n.doc,e,r))}this.prosemirrorView.dispatch(n.setMeta(_c,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(t,e,n){let r=this.doc,i=this.type;if(t||(t=ts(this.doc)),t instanceof Uint8Array||e instanceof Uint8Array)if(t instanceof Uint8Array&&e instanceof Uint8Array||Fe(),r=new Ai({gc:!1}),zi(r,e),e=ts(r),zi(r,t),t=ts(r),null===i._item){const t=Array.from(this.doc.share.keys()).find(t=>this.doc.share.get(t)===this.type);i=r.getXmlFragment(t)}else{const t=r.store.clients.get(i._item.id.client)??[];i=t[ls(t,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{const s=n.permanentUserData;s&&s.dss.forEach(t=>{wi(r,t,t=>{})});const o=(t,e)=>{const r="added"===t?s.getUserByClientId(e.client):s.getUserByDeletedId(e);return{user:r,type:t,color:Ic(n.colorMapping,n.colors,r)}},l=Hs(i,new Zi(e.ds,t.sv)).map(n=>!n._item.deleted||Dc(n._item,t)||Dc(n._item,e)?Lc(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},t,e,o):null).filter(t=>null!==t),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(l),0,0));this.prosemirrorView.dispatch(c.setMeta(_c,{isChangeOrigin:!0}))},_c)})}_typeChanged(t,e){if(null==this.prosemirrorView)return;const n=_c.getState(this.prosemirrorView.state);0!==t.length&&null==n.snapshot&&null==n.prevSnapshot?this.mux(()=>{const t=(t,e)=>this.mapping.delete(e);wi(e,e.deleteSet,t=>{if(t.constructor===rl){const e=t.content.type;e&&this.mapping.delete(e)}}),e.changed.forEach(t),e.changedParentTypes.forEach(t),this.mapping.clear();const n=this.type.toArray().map(t=>Bc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),r=this.prosemirrorView.state.doc;let i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(n),0,0));((t,e,n,r)=>{if(null!==e&&null!==e.anchor&&null!==e.head)if("all"===e.type)t.setSelection(new ic(t.doc));else if("node"===e.type){const r=aa(n.doc,n.type,e.anchor,n.mapping);null!==r&&t.setSelection(Nc(t,r))}else if("nodeRange"===e.type){const r=aa(n.doc,n.type,e.anchor,n.mapping),i=aa(n.doc,n.type,e.head,n.mapping),s=Rc(t,r,i,e.depth);null!==s&&t.setSelection(s)}else{let i=aa(n.doc,n.type,e.anchor,n.mapping),s=aa(n.doc,n.type,e.head,n.mapping);null!=r&&(i=Mc(t.doc,r,e.absAnchor,i),s=Mc(t.doc,r,e.absHead,s)),null===i&&(i=s),null===s&&(s=i),null!==i&&null!==s&&t.setSelection(tc.between(t.doc.resolve(i),t.doc.resolve(s)))}})(i,this.beforeTransactionSelection,this,r),i=i.setMeta(_c,{isChangeOrigin:!0,isUndoRedoOperation:e.origin instanceof Ss}),null!==this.beforeTransactionSelection&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)}):this.renderSnapshot(n.snapshot,n.prevSnapshot)}_prosemirrorChanged(t){this.doc.transact(()=>{sa(this.doc,this.type,t,this),this.beforeTransactionSelection=zc(this,this.prosemirrorView.state)},_c)}initView(t){null!=this.prosemirrorView&&this.destroy(),this.prosemirrorView=t,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){null!=this.prosemirrorView&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}},Bc=(t,e,n,r,i,s)=>{const o=n.mapping.get(t);if(void 0===o){if(t instanceof Ao)return Lc(t,e,n,r,i,s);throw Ue()}return o},Lc=(t,e,n,r,i,s)=>{const o=[],l=t=>{if(t instanceof Ao){const l=Bc(t,e,n,r,i,s);null!==l&&o.push(l)}else{const l=(t._item.right?.content)?.type;l instanceof Co&&!l._item.deleted&&l._item.id.client===l.doc.clientID&&(t.applyDelta([{retain:t.length},...l.toDelta()]),l.doc.transact(t=>{l._item.delete(t)}));const c=Uc(t,e,n,r,i,s);null!==c&&c.forEach(t=>{null!==t&&o.push(t)})}};void 0===r||void 0===i?t.toArray().forEach(l):Hs(t,new Zi(i.ds,r.sv)).forEach(l);try{const l=t.getAttributes(r);void 0!==r&&(Dc(t._item,r)?Dc(t._item,i)||(l.ychange=s?s("added",t._item.id):{type:"added"}):l.ychange=s?s("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,o);return n.mapping.set(t,c),c}catch(Xa){return t.doc.transact(e=>{t._item.delete(e)},_c),n.mapping.delete(t),null}},Uc=(t,e,n,r,i,s)=>{const o=[],l=t.toDelta(r,i,s);try{for(let t=0;t<l.length;t++){const n=l[t];o.push(e.text(n.insert,ra(n.attributes,e)))}}catch(Xa){return t.doc.transact(e=>{t._item.delete(e)},_c),null}return o},Fc=(t,e)=>t instanceof Array?((t,e)=>{const n=new Oo,r=t.map(t=>({insert:t.text,attributes:ia(t.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n})(t,e):((t,e)=>{const n=new Ao(t.type.name);for(const r in t.attrs){const e=t.attrs[r];null!==e&&"ychange"!==r&&n.setAttribute(r,e)}return n.insert(0,Vc(t).map(t=>Fc(t,e))),e.mapping.set(n,t),n})(t,e),$c=t=>"object"==typeof t&&null!==t,Hc=(t,e)=>{const n=Object.keys(t).filter(e=>null!==t[e]);let r=n.length===Object.keys(e).filter(t=>null!==e[t]).length;for(let i=0;i<n.length&&r;i++){const s=n[i],o=t[s],l=e[s];r="ychange"===s||o===l||$c(o)&&$c(l)&&Hc(o,l)}return r},Vc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const t=e[r];if(t.isText){const t=[];for(let n=e[r];r<e.length&&n.isText;n=e[++r])t.push(n);r--,n.push(t)}else n.push(t)}return n},qc=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((t,n)=>t.insert===e[n].text&&vn(t.attributes||{}).length===e[n].marks.length&&kn(t.attributes,(t,r)=>{const i=na(r),s=e[n].marks;return!!s.find(t=>t.type.name===i)&&Hc(t,s.find(t=>t.type.name===i)?.attrs)}))},Jc=(t,e)=>{if(t instanceof Ao&&!(e instanceof Array)&&oa(t,e)){const n=Vc(e);return t._length===n.length&&Hc(t.getAttributes(),e.attrs)&&t.toArray().every((t,e)=>Jc(t,n[e]))}return t instanceof Oo&&e instanceof Array&&qc(t,e)},Kc=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((t,n)=>e[n]===t),Wc=(t,e,n,r)=>{n>0&&(t.slice(e,e+n).forEach(t=>r.mapping.delete(t)),t.delete(e,n))},Gc=(t,e,n,r,i,s)=>{if(r<i){const o=[];for(let t=r;t<i;t++)o.push(Fc(n[t],s));t.insert(e,o)}},Xc=(t,e,n,r)=>e instanceof Oo&&n instanceof Array?(qc(e,n)?r.mapping.set(e,n):ta(e,n,r),!0):!(!(e instanceof Ao)||n instanceof Array||!oa(e,n))&&(Jc(e,n)?r.mapping.set(e,n):sa(t,e,n,r),!0),Yc=(t,e,n,r,i,s,o,l,c)=>{const a=ie(s-i,l-o);for(let h=0;h<a;h++){const s=r[i+h],l=n[o+h];Xc(t,s,l,c)||(Wc(e,o+h,1,c),Gc(e,o+h,n,o+h,o+h+1,c))}Wc(e,o+a,s-i-a,c),Gc(e,o+a,n,o+a,l,c)},Zc=(t,e,n,r,i)=>{const s=((t,e,n)=>{const r=new Map;e.forEach((t,e)=>{r.has(t)||r.set(t,e)});const i=[];if(t.forEach((t,s)=>{const o=n.mapping.get(t),l=r.get(o);void 0!==l&&Kc(o,e[l])&&i.push({yIndex:s,pIndex:l,yChild:t})}),0===i.length)return[];const s=new Array(i.length),o=[];for(let c=0;c<i.length;c++){let t=0,e=o.length;for(;t<e;){const n=t+e>>1;i[o[n]].pIndex<i[c].pIndex?t=n+1:e=n}s[c]=t>0?o[t-1]:-1,o[t]=c}const l=[];for(let c=o[o.length-1];-1!==c;c=s[c])l.push(i[c]);return l.reverse()})(r,n,i);if(s.length<2||!s.some(t=>t.yIndex!==t.pIndex)||s.some(t=>{const e=n[t.pIndex];return!(t.yChild instanceof Oo&&e instanceof Array||t.yChild instanceof Ao&&!(e instanceof Array))}))return!1;let o=0,l=0;for(const c of s){Yc(t,e,n,r,o,c.yIndex,l,c.pIndex,i);const s=n[c.pIndex];Xc(t,c.yChild,s,i),o=c.yIndex+1,l=c.pIndex+1}return Yc(t,e,n,r,o,r.length,l,n.length,i),!0},Qc=(t,e,n)=>{const r=t.toArray(),i=Vc(e),s=i.length,o=r.length,l=ie(o,s);let c=0,a=0,h=!1;for(;c<l;c++){const t=r[c],e=i[c];if(Kc(n.mapping.get(t),e))h=!0;else if(!Jc(t,e))break}for(;c+a<l;a++){const t=r[o-a-1],e=i[s-a-1];if(Kc(n.mapping.get(t),e))h=!0;else if(!Jc(t,e))break}return{equalityFactor:c+a,foundMappedChild:h}},ta=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=(t=>{let e="",n=t._start;const r={};for(;null!==n;)n.deleted||(n.countable&&n.content instanceof $o?e+=n.content.str:n.content instanceof Bo&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}})(t),s=e.map(t=>({insert:t.text,attributes:Object.assign({},r,ia(t.marks,n))})),{insert:o,remove:l,index:c}=xc(i,s.map(t=>t.insert).join(""));t.delete(c,l),t.insert(c,o),t.applyDelta(s.map(t=>({retain:t.insert.length,attributes:t.attributes})))},ea=/(.*)(--[a-zA-Z0-9+/=]{8})$/,na=t=>ea.exec(t)?.[1]??t,ra=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(na(r),t[r]));return n},ia=(t,e)=>{const n={};return t.forEach(t=>{if("ychange"!==t.type.name){const r=Kt(e.isOMark,t.type,()=>!t.type.excludes(t.type));n[r?`${t.type.name}--${jc(t.toJSON())}`:t.type.name]=t.attrs}}),n},sa=(t,e,n,r)=>{if(e instanceof Ao&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof Ao){const t=e.getAttributes(),r=n.attrs;for(const n in r)null!==r[n]?t[n]!==r[n]&&"ychange"!==n&&e.setAttribute(n,r[n]):e.removeAttribute(n);for(const n in t)void 0===r[n]&&e.removeAttribute(n)}const i=Vc(n),s=i.length,o=e.toArray(),l=o.length,c=ie(s,l);if(Zc(t,e,i,o,r))return;let a=0,h=0;for(;a<c;a++){const t=o[a],e=i[a];if(!Kc(r.mapping.get(t),e)){if(!Jc(t,e))break;r.mapping.set(t,e)}}for(;h+a+1<c;h++){const t=o[l-h-1],e=i[s-h-1];if(!Kc(r.mapping.get(t),e)){if(!Jc(t,e))break;r.mapping.set(t,e)}}t.transact(()=>{for(;l-a-h>0&&s-a-h>0;){const n=o[a],c=i[a],d=o[l-h-1],u=i[s-h-1];if(n instanceof Oo&&c instanceof Array)qc(n,c)||ta(n,c,r),a+=1;else{let i=n instanceof Ao&&oa(n,c),s=d instanceof Ao&&oa(d,u);if(i&&s){const t=Qc(n,c,r),e=Qc(d,u,r);t.foundMappedChild&&!e.foundMappedChild?s=!1:!t.foundMappedChild&&e.foundMappedChild||t.equalityFactor<e.equalityFactor?i=!1:s=!1}i?(sa(t,n,c,r),a+=1):s?(sa(t,d,u,r),h+=1):(r.mapping.delete(e.get(a)),e.delete(a,1),e.insert(a,[Fc(c,r)]),a+=1)}}const n=l-a-h;if(1===l&&0===s&&o[0]instanceof Oo?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(e.slice(a,a+n).forEach(t=>r.mapping.delete(t)),e.delete(a,n)),a+h<s){const t=[];for(let e=a;e<s-h;e++)t.push(Fc(i[e],r));e.insert(a,t)}},_c)},oa=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,la=(t,e,n)=>{if(0===t)return Xi(e,0,-1);let r=null===e._first?null:e._first.content.type;for(;null!==r&&e!==r;){if(r instanceof Oo){if(r._length>=t)return Xi(r,t,-1);if(t-=r._length,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{do{r=null===r._item?null:r._item.parent,t--}while(r!==e&&null!==r&&null!==r._item&&null===r._item.next);null!==r&&r!==e&&(r=null===r._item?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(null!==r._first&&t<i)r=r._first.content.type,t--;else{if(1===t&&0===r._length&&i>1)return new Ki(null===r._item?null:r._item.id,null===r._item?qi(r):null,null);if(t-=i,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{if(0===t)return r=null===r._item?r:r._item.parent,new Ki(null===r._item?null:r._item.id,null===r._item?qi(r):null,null);do{r=r._item.parent,t--}while(r!==e&&null===r._item.next);r!==e&&(r=r._item.next.content.type)}}}if(null===r)throw Fe();if(0===t&&r.constructor!==Oo&&r!==e)return ca(r._item.parent,r._item)}return Xi(e,e._length,-1)},ca=(t,e)=>{let n=null,r=null;return null===t._item?r=qi(t):n=Vi(t._item.id.client,t._item.id.clock),new Ki(n,r,e.id)},aa=(t,e,n,r)=>{const i=Yi(n,t);if(null===i||i.type!==e&&!Ji(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Oo)o=i.index;else if(null===s._item||!s._item.deleted){let t=s._first,e=0;for(;e<s._length&&e<i.index&&null!==t;){if(!t.deleted){const n=t.content.type;if(e++,n instanceof Oo)o+=n._length;else{const t=r.get(n);if(null==t)return null;o+=t.nodeSize}}t=t.right}o+=1}for(;s!==e&&null!==s._item;){const t=s._item.parent;if(null===t._item||!t._item.deleted){o+=1;let e=t._first;for(;null!==e;){const t=e.content.type;if(t===s)break;if(!e.deleted)if(t instanceof Oo)o+=t._length;else{const e=r.get(t);if(null==e)return null;o+=e.nodeSize}e=e.right}}s=t}const l=o-1;return((t,e,n)=>{if(null===n)return!1;const r=Yi(e,t);return null!==r&&r.type instanceof Oo&&null!==e.item&&n<=1})(t,n,l)?null:l},ha=(t,e)=>{if(t===e)return!0;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>t[n]===e[n])},da=(t,e,n)=>{let r=0,i=0;for(;i<t.childCount;i++){const e=t.child(i);if(r+e.nodeSize>n)break;r+=e.nodeSize}if(i>=t.childCount)return null;const s=t.child(i),o=t.resolve(n),l=(t,e)=>{if(0===o.depth){const i=t+(n-r),s=t+1,o=t+e.nodeSize-1;return Math.max(s,Math.min(i,o))}return((t,e,n)=>{let r=e+1,i=n;for(let s=1;s<t.depth;s++){const e=t.index(s);if(e>=i.childCount)return null;for(let t=0;t<e;t++)r+=i.child(t).nodeSize;if(r+=1,i=i.child(e),i.type!==t.node(s+1).type)return null}return i.isTextblock?r+Math.min(t.parentOffset,i.content.size):null})(o,t,e)},c=(n,r=!1)=>{let s=0;for(let e=0;e<=i;e++)n(t.child(e))&&s++;let o=0,c=-1,a=null,h=0;for(let t=0;t<e.childCount;t++){const r=e.child(t);n(r)&&(o++,o===s&&(c=h,a=r)),h+=r.nodeSize}return null===a||r&&(1!==s||1!==o)?null:l(c,a)},a=t=>t.type===s.type&&ha(t.attrs,s.attrs),h=s.textContent,d=c(t=>a(t)&&t.textContent===h);if(null!==d)return d;const u=c(t=>t.type===s.type&&t.textContent===h);if(null!==u)return u;if((t=>{const e=t.type.spec.attrs||{};return Object.keys(t.attrs).some(n=>{const r=e[n];return null==r||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==t.attrs[n]})})(s)){const t=c(a,!0);if(null!==t)return t}return c(t=>a(t)&&""!==h&&""!==t.textContent&&(h.startsWith(t.textContent)||t.textContent.startsWith(h)),!0)},ua=(t,e,n,r)=>{if(null===r)return!1;const i=t.resolve(n),s=e.resolve(r);if(!i.parent.isTextblock)return!1;if(!s.parent.isTextblock)return!0;if(i.parent.textContent!==s.parent.textContent)return!0;if(0!==i.parentOffset&&0===s.parentOffset)return!0;const o=0===i.parentOffset&&0===s.parentOffset,l=i.parentOffset!==s.parentOffset||i.parent.type!==s.parent.type||!ha(i.parent.attrs,s.parent.attrs);if(o||l){const i=da(t,e,n);return null!==i&&i!==r}return!1},pa=new Set(["paragraph"]),fa=({protectedNodes:t=pa,trackedOrigins:e=[],undoManager:n=null}={})=>new dc({key:Ac,state:{init:(r,i)=>{const s=_c.getState(i);let o=n;if(!o){const n=s.doc,r=new Set(n?n._observers.get("destroy"):[]);o=new Ss(s.type,{trackedOrigins:new Set([_c].concat(e)),deleteFilter:e=>((t,e)=>!(t instanceof rl&&t.content instanceof Yo&&(t.content.type instanceof Co||t.content.type instanceof Ao&&e.has(t.content.type.nodeName))&&0!==t.content.type._length))(e,t),captureTransaction:t=>!1!==t.meta.get("addToHistory")});const i=n?n._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(i||[]).filter(t=>!r.has(t))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(t,e,n,r)=>{const i=_c.getState(r).binding,s=e.undoManager,o=s.undoStack.length>0,l=s.redoStack.length>0;return i?{undoManager:s,prevSel:zc(i,n),hasUndoOps:o,hasRedoOps:l}:o!==e.hasUndoOps||l!==e.hasRedoOps?Object.assign({},e,{hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}):e}},view:t=>{const e=_c.getState(t.state),n=Ac.getState(t.state).undoManager;return n.on("stack-item-added",({stackItem:n})=>{const r=e.binding;r&&n.meta.set(r,Ac.getState(t.state).prevSel)}),n.on("stack-item-popped",({stackItem:t})=>{const n=e.binding;n&&(n.beforeTransactionSelection=t.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy();const t=n._yTiptapDocDestroyListeners;t&&n.doc&&(t.forEach(t=>n.doc.off("destroy",t)),n._yTiptapDocDestroyListeners=null)}}}});function ga(t){return!!t.getMeta(_c)}function ma(t,e){const n=_c.getState(t);return aa(n.doc,n.type,e,n.binding.mapping)||0}function xa(t,e){const n=_c.getState(t);return la(e,n.type,n.binding.mapping)}var wa=class t extends K.MappablePosition{constructor(t,e){super(t),this.yRelativePosition=e}static fromJSON(e){return new t(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};K.Extension.create({name:"collaboration",priority:1e3,addOptions:()=>({document:null,field:"default",fragment:null,provider:null}),addStorage:()=>({isDisabled:!1}),onCreate(){this.editor.extensionManager.extensions.find(t=>"undoRedo"===t.name)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>function(t,e,n){const r=t instanceof wa?t.yRelativePosition:null;if(ga(e)&&r)return{position:new wa(ma(n,r),r),mapResult:null};const i=(0,K.getUpdatedPosition)(t,e),s=i.position.position;return{position:new wa(s,null!=r?r:xa(n,s)),mapResult:i.mapResult}}(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>function(t,e){return new wa(t,xa(e,t))}(t,this.editor.state)},addCommands:()=>({undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),0!==Ac.getState(e).undoManager.undoStack.length&&(!n||(t=>{const e=Ac.getState(t).undoManager;if(null!=e)return e.undo(),!0})(e))),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),0!==Ac.getState(e).undoManager.redoStack.length&&(!n||(t=>{const e=Ac.getState(t).undoManager;if(null!=e)return e.redo(),!0})(e)))}),addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=fa(this.options.yUndoOptions),n=e.spec.view;e.spec.view=t=>{const{undoManager:e}=Ac.getState(t.state);e.restore&&(e.restore(),e.restore=()=>{});const r=n?n(t):void 0;return{destroy:()=>{const t=e.trackedOrigins.has(e),n=e._observers;e.restore=()=>{t&&e.trackedOrigins.add(e),e.doc.on("afterTransaction",e.afterTransactionHandler),e._observers=n},(null==r?void 0:r.destroy)&&r.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[Tc(t,r),e,this.editor.options.enableContentCheck&&new W.Plugin({key:new W.PluginKey("filterInvalidContent"),filterTransaction:e=>{if(!ga(e))return!0;if(this.storage.isDisabled)return!1;if(!e.docChanged)return!0;try{return e.doc.check(),!0}catch(n){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:n,editor:this.editor,disableCollaboration:()=>{var e;null==(e=t.doc)||e.destroy()}}),!0}}})].filter(Boolean)}});function ya(t){if(!t.length)return G.DecorationSet.empty;const e=[],n=t[0].$from.node(0);return t.forEach(t=>{const n=t.$from.pos,r=t.$from.nodeAfter;r&&e.push(G.Decoration.node(n,n+r.nodeSize,{class:"ProseMirror-selectednoderange"}))}),G.DecorationSet.create(n,e)}function ba(t,e,n,r={}){const i=[],s=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;"number"==typeof n&&n>=0||(n=t.sameParent(e)?Math.max(0,t.sharedDepth(e.pos)-1):t.sharedDepth(e.pos));const l=new X.NodeRange(t,e,n),c=0===l.depth?0:s.resolve(l.start).posAtIndex(0);return l.parent.forEach((n,r)=>{const a=c+r,h=a+n.nodeSize,d=function(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}(a,n.nodeSize,n),u=o?e.pos>=d.start&&t.pos<=d.end:e.pos>d.start&&t.pos<d.end;if(a<l.start||a>=l.end)return;if(!u)return;const p=new W.SelectionRange(s.resolve(a),s.resolve(h));i.push(p)}),i}var va=class t{constructor(t,e,n){this.anchor=t,this.head=e,this.depth=null!=n?n:0}map(e){return new t(e.map(this.anchor),e.map(this.head),this.depth)}resolve(t){return new Sa(t.resolve(this.anchor),t.resolve(this.head),this.depth)}},Sa=class t extends W.Selection{constructor(t,e,n,r=1){const{doc:i}=t,s=t===e,o=t.pos===i.content.size&&e.pos===i.content.size,l=s&&!o?i.resolve(e.pos+(r>0?1:-1)):e,c=s&&o?i.resolve(t.pos-(r>0?1:-1)):t,a=ba(c.min(l),c.max(l),n);super(l.pos>=t.pos?a[0].$from:a[a.length-1].$to,l.pos>=t.pos?a[a.length-1].$to:a[0].$from,a),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof t&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),i=e.resolve(n.map(this.head));return new t(r,i,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const e=this.ranges.slice(0,-1),n=e[0].$from,r=e[e.length-1].$to;return new t(n,r,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new t(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const e=this.ranges.slice(1),n=e[0].$from,r=e[e.length-1].$to;return new t(r,n,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new t(this.$anchor,r,this.depth)}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head),n.depth)}static create(t,e,n,r,i=1){return new this(t.resolve(e),t.resolve(n),r,i)}getBookmark(){return new va(this.anchor,this.head,this.depth)}};Sa.prototype.visible=!1;try{W.Selection.jsonID("nodeRange",Sa)}catch{}function ka(t){return t instanceof Sa}K.Extension.create({name:"nodeRange",addOptions:()=>({depth:void 0,key:"Mod"}),addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:s,tr:o}=r,{anchor:l,head:c}=s;if(!ka(s)){const t=Sa.create(i,l,c,e,-1);return o.setSelection(t),n.dispatch(o),!0}const a=s.extendBackwards();return o.setSelection(a),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:s,tr:o}=r,{anchor:l,head:c}=s;if(!ka(s)){const t=Sa.create(i,l,c,e);return o.setSelection(t),n.dispatch(o),!0}const a=s.extendForwards();return o.setSelection(a),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,tr:s}=r,o=Sa.create(i,0,i.content.size,e);return s.setSelection(o),n.dispatch(s),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;ka(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new W.Plugin({key:new W.PluginKey("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(t,n)=>{const{key:r}=this.options,i=/Mac/.test(navigator.platform),s=!!n.shiftKey,o=!!n.ctrlKey,l=!!n.altKey,c=!!n.metaKey;return(null==r||"Shift"===r&&s||"Control"===r&&o||"Alt"===r&&l||"Meta"===r&&c||"Mod"===r&&(i?c:o))&&(e=!0),!!e&&(document.addEventListener("mouseup",()=>{e=!1;const{state:n}=t,{doc:r,selection:i,tr:s}=n,{$anchor:o,$head:l}=i;if(o.sameParent(l))return;const c=Sa.create(r,o.pos,l.pos,this.options.depth);s.setSelection(c),t.dispatch(s)},{once:!0}),!1)}},decorations:n=>{const{selection:r}=n,i=ka(r);if(t=!1,!e)return i?(t=!0,ya(r.ranges)):null;const{$from:s,$to:o}=r;if(!i&&s.sameParent(o))return null;const l=ba(s,o,this.options.depth);return l.length?(t=!0,ya(l)):null}}})]}});function Ca(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],i=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((t,n)=>{i[n].style.cssText=function(t,e){const n=getComputedStyle(t);if(e)return e.map(t=>t.trim()).filter(t=>t.length>0).map(t=>`${t}:${n.getPropertyValue(t)};`).join("");let r="";for(let i=0;i<n.length;i+=1)r+=`${n[i]}:${n.getPropertyValue(n[i])};`;return r}(t,e)}),n}var Ea=[{id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},{id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=t.firstChild;return e&&["listItem","taskItem"].includes(e.type.name)?1e3:0}},{id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&"tableHeader"===e.type.name?1e3:0},{id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0}],_a={edges:["left","top"],threshold:12,strength:500};function Aa(t){return void 0===t||"left"===t?{..._a}:"right"===t?{edges:["right","top"],threshold:12,strength:500}:"both"===t?{edges:["left","right","top"],threshold:12,strength:500}:"none"===t?{edges:[],threshold:0,strength:0}:{..._a,...t}}function ja(t,e,n,r){let i=1e3,s=!1;if(e.every(e=>{const n=e.evaluate(t);return i-=n,!(i<=0)||(s=!0,!1)}),s)return-1;const o=t.view.nodeDOM(t.pos);return i-=function(t,e,n,r){return e&&0!==n.edges.length&&function(t,e,n){if(0===n.edges.length)return!1;const r=e.getBoundingClientRect(),{threshold:i,edges:s}=n;return s.some(e=>"left"===e?t.x-r.left<i:"right"===e?r.right-t.x<i:"top"===e?t.y-r.top<i:"bottom"===e&&r.bottom-t.y<i)}(t,e,n)?n.strength*r:0}(r,o,n,t.depth),i<=0?-1:i}function Da(t,e,n){return Array.from({length:e},(t,n)=>e-1-n).some(e=>n.includes(t.node(e).type.name))}function Oa(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function Ia(t,e){let n="first"===e?t.firstElementChild:t.lastElementChild;for(;n;){const t=n.getBoundingClientRect();if(Oa(t))return t;n="first"===e?n.nextElementSibling:n.previousElementSibling}return null}var Ta=t=>{const{x:e,y:n,editor:r,nestedOptions:i}=t,{view:s,state:o}=r,l=function(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const i=t.dom,s=Ia(i,"first"),o=Ia(i,"last");if(!s||!o)return null;const l=Math.min(Math.max(s.top+r,n),o.bottom-r),c=Math.abs(s.left-o.left)<.5,a=Math.abs(s.right-o.right)<.5;let h=s;c&&a&&(h=s);const d=Math.min(Math.max(h.left+r,e),h.right-r);return Number.isFinite(d)&&Number.isFinite(l)?{x:d,y:l}:null}(s,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:c,y:a}=l;if(null==i?void 0:i.enabled){const t=function(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:i}=t.state,s=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...Ea),o.push(...n.rules);const l=Array.from({length:s.depth},(t,e)=>s.depth-e).map(r=>{const i=s.node(r),l=s.before(r);if(n.allowedContainers&&r>0&&!Da(s,r,n.allowedContainers))return null;const c=r>0?s.node(r-1):null,a=r>0?s.index(r-1):0,h=ja({node:i,pos:l,depth:r,parent:c,index:a,isFirst:0===a,isLast:a===(c?c.childCount:1)-1,$pos:s,view:t},o,n.edgeDetection,e);return h<0?null:{node:i,pos:l,depth:r,score:h,dom:t.nodeDOM(l)}}).filter(t=>null!==t),c=s.nodeAfter;if(c&&c.isAtom&&!c.isInline){const i=r.pos,a=s.depth+1,h=s.parent,d=s.index(),u=h.childCount;let p=!0;if(n.allowedContainers&&(p=Da(s,a,n.allowedContainers)),p){const r=ja({node:c,pos:i,depth:a,parent:h,index:d,isFirst:0===d,isLast:d===u-1,$pos:s,view:t},o,n.edgeDetection,e);if(r>=0){const e=t.nodeDOM(i);e&&l.push({node:c,pos:i,depth:a,score:r,dom:e})}}}if(0===l.length)return null;l.sort((t,e)=>e.score!==t.score?e.score-t.score:e.depth-t.depth);const a=l[0];return a.dom?{node:a.node,pos:a.pos,dom:a.dom}:null}(s,{x:c,y:a},i);return t?{resultElement:t.dom,resultNode:t.node,pos:t.pos}:{resultElement:null,resultNode:null,pos:null}}const h=s.root.elementsFromPoint(c,a);let d,u;if(Array.prototype.some.call(h,t=>{if(!s.dom.contains(t))return!1;const e=function(t,e){var n;let r=t;for(;(null==r?void 0:r.parentElement)&&r.parentElement!==e.dom;)r=r.parentElement;if((null==r?void 0:r.parentElement)===e.dom&&(null==(n=r.pmViewDesc)?void 0:n.node))return r}(t,s);return!!e&&(d=e,!0)}),!d){const t=s.posAtCoords({left:c,top:a});if(t){const e=o.doc.resolve(t.pos),n=Math.min(e.depth,1),r=n>0?e.before(n):e.pos,i=o.doc.nodeAt(r);if(i){const t=s.nodeDOM(r);return{resultElement:t instanceof HTMLElement?t:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}try{u=s.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const p=o.doc.nodeAt(u);if(!p){const t=o.doc.resolve(u),e=t.parent;return{resultElement:d,resultNode:e,pos:t.start()}}return{resultElement:d,resultNode:p,pos:u}};function Ma(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:i}=t.domAtPos(e),s=r.childNodes[i];return s instanceof Element?s:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function Na(t){var e;null==(e=t.parentNode)||e.removeChild(t)}function Ra(t,e,n,r,i){const{view:s}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:c}=s.state.selection,a=function(t,e,n,r){const{doc:i}=e.view.state;if((null==n?void 0:n.enabled)&&(null==r?void 0:r.node)&&r.pos>=0){const t=r.pos,e=r.pos+r.node.nodeSize;return[{$from:i.resolve(t),$to:i.resolve(e)}]}const s=Ta({editor:e,x:t.clientX,y:t.clientY,direction:"right",nestedOptions:n});if(!s.resultNode||null===s.pos)return[];const o=s.resultNode.isText||s.resultNode.isAtom?0:-1;return ba(i.resolve(s.pos),i.resolve(s.pos+s.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}(t,e,n,r),h=ba(l,c,0,{extendOnBoundaryOverlap:!1}),d=h.some(t=>a.find(e=>e.$from===t.$from&&e.$to===t.$to)),u=o||!d?a:h;if(!u.length)return;const{tr:p}=s.state,f=document.createElement("div"),g=u[0].$from.pos,m=u[u.length-1].$to.pos,x=function(t,e){const n=Ma(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}(s,g);f.setAttribute("dir",x);const w=(null==n?void 0:n.enabled)&&(null==r?void 0:r.node),y=1===u.length;let b,v;w&&y?(b=s.state.doc.slice(g,m),v=W.NodeSelection.create(s.state.doc,g)):(v=Sa.create(s.state.doc,g,m),b=v.content());const S=function(t){return!t||!t.some(t=>{const e=t.trim().toLowerCase();return"margin"===e||e.startsWith("margin-")})}(i);u.forEach(t=>{const e=Ma(s,t.$from.pos);if(!e)return;const n=Ca(e,i);S&&(n.style.margin="0"),f.append(n)}),f.style.position="absolute",f.style.top="-10000px",document.body.append(f),t.dataTransfer.clearData();const k=function(t,e){return"rtl"===t?e:0}(x,f.getBoundingClientRect().width);t.dataTransfer.setDragImage(f,k,0);let C=!1;const E=()=>{C||(C=!0,Na(f),document.removeEventListener("drop",E),document.removeEventListener("dragend",E))},_=v instanceof W.NodeSelection?v:void 0;s.dragging={slice:b,move:!0,node:_},p.setSelection(v),s.dispatch(p),document.addEventListener("drop",E),document.addEventListener("dragend",E)}var za=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return 0===r?e:n.pos-n.parentOffset-1},Pa=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:i}=r,s=n;for(;i>0;){const t=r.node(i);i-=1,0===i&&(s=t)}return s};function Ba(t,e,n){let r=0;for(let i=e;i<n;i+=1)r+=t.child(i).nodeSize;return r}function La(t,e,n,r){try{const i=function(t,e,n,r){const i=t.resolve(e),s=i.node(r);let o=i.index(r);o>=s.childCount&&(o=Math.max(0,s.childCount-n));const l=Math.min(n,s.childCount-o);if(l<=0)return null;const c=i.start(r)+Ba(s,0,o);return{anchor:c,head:c+Ba(s,o,o+l),count:l}}(t,e,n,r);if(!i)return null;const s=Sa.create(t,i.anchor,i.head,r);return s.ranges.length===n?s:null}catch{return null}}var Ua=(t,e)=>{const n=_c.getState(t);return n?la(e,n.type,n.binding.mapping):null},Fa=(t,e)=>{const n=_c.getState(t);return n?aa(n.doc,n.type,e,n.binding.mapping)||0:-1},$a=(t,e)=>{let n=e;for(;(null==n?void 0:n.parentNode)&&n.parentNode!==t.dom;)n=n.parentNode;return n},Ha=new W.PluginKey("dragHandle"),Va=({pluginKey:t=Ha,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:s,onElementDragStart:l,onElementDragEnd:c,nestedOptions:a,dragImageProperties:h})=>{const d=document.createElement("div");let u,p=!1,f=null,g=-1,m=null,x=null,w=null,y=null;function b(){w=null,y=null}function v(t,e){y&&(y=function(t,e,n){if(!e.docChanged)return t;if(n.isChangeOrigin&&null!=t.relativeAnchorPos){const e=n.getAbsolutePos(t.relativeAnchorPos);return!Number.isFinite(e)||e<=0?null:{...t,anchorPos:e}}const r=e.mapping.mapResult(t.anchorPos,1);return r.deleted?null:{...t,anchorPos:r.pos}}(y,t,{isChangeOrigin:ga(t),getAbsolutePos:t=>Fa(e,t)}))}function S(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function k(t){const n=(null==i?void 0:i())||{getBoundingClientRect:()=>t.getBoundingClientRect()};o.computePosition(n,e,r).then(t=>{Object.assign(e.style,{position:t.strategy,left:`${t.x}px`,top:`${t.y}px`})})}function C(t){var r,i;l?.(t),Ra(t,n,a,{node:f,pos:g},h),r=n.state.selection,w=ka(r)?{anchorPos:r.from,nodeCount:r.ranges.length,depth:null!=(i=r.depth)?i:0}:null,e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function E(t){c?.(t),w=null,S(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function _(t){if(!t.target||!n.view.dom.contains(t.target))return;if((0,K.isFirefox)()){const t=n.view.dom;requestAnimationFrame(()=>{t.isContentEditable&&(t.contentEditable="false",t.contentEditable="true")})}if(!w||n.view.state.selection.empty)return;const e=n.state.selection.from,r=Ua(n.state,e);y={...w,anchorPos:e,relativeAnchorPos:null!=r?r:void 0},n.view.dispatch(n.state.tr.setMeta("addToHistory",!1))}function A(){e.removeEventListener("dragstart",C),e.removeEventListener("dragend",E),document.removeEventListener("drop",_),m&&(cancelAnimationFrame(m),m=null,x=null),b()}return d.appendChild(e),{unbind(){A()},plugin:new W.Plugin({key:"string"==typeof t?new W.PluginKey(t):t,state:{init:()=>({locked:!1}),apply(t,r,i,o){v(t,o);const l=t.getMeta("lockDragHandle"),c=t.getMeta("hideDragHandle");if(void 0!==l&&(p=l),c)return S(),p=!1,f=null,g=-1,s?.({editor:n,node:null,pos:-1}),r;if(t.docChanged&&-1!==g&&e)if(ga(t)){const t=Fa(o,u);t!==g&&(g=t)}else{const e=t.mapping.map(g);e!==g&&(g=e,u=Ua(o,g))}return r}},appendTransaction:(t,e,n)=>function(t){if(!y)return null;const e=La(t.doc,y.anchorPos,y.nodeCount,y.depth);return e?(b(),t.tr.setSelection(e)):(y=null,w=null,null)}(n),view:t=>{var r;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",null==(r=n.view.dom.parentElement)||r.appendChild(d),d.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.left="0",d.style.zIndex="10",e.addEventListener("dragstart",C),e.addEventListener("dragend",E),document.addEventListener("drop",_),{update(r,i){if(!e)return;if(!n.isEditable)return void S();if(e.draggable=!p,t.state.doc.eq(i.doc)||-1===g)return;let o=t.nodeDOM(g);if(o=$a(t,o),o===t.dom)return;if(1!==(null==o?void 0:o.nodeType))return;const l=t.posAtDOM(o,0),c=Pa(n.state.doc,l),a=za(n.state.doc,l);f=c,g=a,u=Ua(t.state,g),s?.({editor:n,node:f,pos:g}),k(o)},destroy(){A(),e&&Na(d)}}},props:{handleDOMEvents:{keydown:t=>!(!e||p)&&(!!t.hasFocus()&&(S(),f=null,g=-1,s?.({editor:n,node:null,pos:-1}),!1)),mouseleave:(t,e)=>(p||e.target&&!d.contains(e.relatedTarget)&&(S(),f=null,g=-1,s?.({editor:n,node:null,pos:-1})),!1),mousemove:(t,r)=>!(!e||p)&&(x={x:r.clientX,y:r.clientY},m||(m=requestAnimationFrame(()=>{if(m=null,!x)return;const{x:r,y:i}=x;x=null;const o=Ta({x:r,y:i,direction:"right",editor:n,nestedOptions:a});if(!o.resultElement)return;let l=o.resultElement,c=o.resultNode,h=o.pos;if(!(null==a?void 0:a.enabled)){if(l=$a(t,l),l===t.dom)return;if(1!==(null==l?void 0:l.nodeType))return;const e=t.posAtDOM(l,0);c=Pa(n.state.doc,e),h=za(n.state.doc,e)}c!==f&&(f=c,g=null!=h?h:-1,u=Ua(t.state,g),s?.({editor:n,node:f,pos:g}),k(l),e&&(n.isEditable?(e.style.visibility="",e.style.pointerEvents="auto"):S()))})),!1)}}})}};function qa(t){var e,n;return!1===t||void 0===t?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Aa("none")}:!0===t?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Aa("left")}:{enabled:!0,rules:null!=(e=t.rules)?e:[],defaultRules:null==(n=t.defaultRules)||n,allowedContainers:t.allowedContainers,edgeDetection:Aa(t.edgeDetection)}}var Ja={placement:"left-start",strategy:"absolute"},Ka=(K.Extension.create({name:"dragHandle",addOptions:()=>({render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}),addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=qa(this.options.nested);return[Va({computePositionConfig:{...Ja,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}}),t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:i=Ha,onNodeChange:s,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:c,computePositionConfig:a=Ja,nested:h=!1}=t,d=(0,H.useRef)(null);null===d.current&&"undefined"!=typeof document&&(d.current=document.createElement("div"));const u=(0,H.useMemo)(()=>qa(h),[JSON.stringify(h)]);(0,H.useEffect)(()=>{const t=d.current;t&&(t.className=e)},[e]),(0,H.useEffect)(()=>{if("undefined"==typeof document)return;if(r.isDestroyed)return;const t=d.current;if(!t)return;t.style.visibility="hidden",t.style.position="absolute",t.dataset.dragging="false";const{plugin:e,unbind:n}=Va({editor:r,element:t,pluginKey:i,computePositionConfig:{...Ja,...a},onElementDragStart:o,onElementDragEnd:l,onNodeChange:s,getReferencedVirtualElement:c,nestedOptions:u});return r.registerPlugin(e),()=>{r.isDestroyed||r.unregisterPlugin(i),n()}},[r,s,c,i,a,o,l,u]);const p=d.current;return p?(0,J.createPortal)(n,p):null});var Wa={plaintext:"Plain Text",js:"JavaScript",ts:"TypeScript",css:"CSS",html:"HTML",python:"Python",bash:"Bash"};function Ga({listLanguages:t}){const{t:n}=r.useLocale(),[s,o]=(0,H.useState)(!1),l=m.useEditorInstance(),c=(0,H.useMemo)(()=>{const{selection:t}=l.state,e=t.$from.parent;if("codeBlock"===e.type.name){const t=e.attrs.language||"plaintext";return Wa[t]||t}},[l.state,t]),a=(0,H.useMemo)(()=>{let e=t||[];return t?.includes("plaintext")||(e=["plaintext",...e]),e.map(t=>({label:Wa[t]||t,value:t}))},[t]);return(0,V.jsxs)(d.Popover,{modal:!0,onOpenChange:o,open:s,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,V.jsxs)(e.ActionButton,{dataState:!!c,children:[c?(0,V.jsx)(V.Fragment,{children:c}):(0,V.jsx)(V.Fragment,{children:n("editor.paragraph.tooltip")}),(0,V.jsx)(i.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})]})}),(0,V.jsx)(d.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:a?.map(t=>(0,V.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:e=>{e.preventDefault(),l.chain().focus().setCodeBlock({language:t.value}).run(),o(!1)},children:[(0,V.jsx)("div",{className:"!richtext-min-w-[20px]",children:c===t.value&&(0,V.jsx)(q.Check,{size:16})}),(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:t.label})]},t.value))})]})}exports.RichTextBubbleCallout=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{type:o,title:c,body:d}=b.useAttributes(n,u.Callout.name,{type:"note",title:"",body:""}),[p,f]=(0,H.useState)(!1),[g,x]=(0,H.useState)("note"),[w,y]=(0,H.useState)(""),[v,S]=(0,H.useState)("");(0,H.useEffect)(()=>{p&&(x(o||"note"),y(c||""),S(d||""))},[p,o,c,d]);const k=(0,H.useCallback)(()=>{n&&(n.chain().updateAttributes(u.Callout.name,{type:g,title:w,body:v}).focus().run(),f(!1))},[n,g,w,v]),C=(0,H.useCallback)(()=>{f(!1)},[]),E=(0,H.useCallback)(()=>{St(u.Callout.name,n)},[n]),_=(0,H.useCallback)(()=>n.isActive(u.Callout.name),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:_,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsxs)(l.Dialog,{onOpenChange:f,open:p,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:i("editor.callout.edit.title")})}),(0,V.jsxs)(l.DialogContent,{children:[(0,V.jsx)(l.DialogTitle,{children:i("editor.callout.edit.title")}),(0,V.jsxs)("div",{className:"richtext-space-y-4 richtext-py-4",children:[(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.type")}),(0,V.jsxs)(u.Select,{onValueChange:x,value:g,children:[(0,V.jsx)(u.SelectTrigger,{children:(0,V.jsx)(u.SelectValue,{className:"richtext-text-accent",placeholder:i("editor.callout.dialog.type.placeholder")})}),(0,V.jsx)(u.SelectContent,{children:kt.map(t=>(0,V.jsx)(u.SelectItem,{value:t.value,children:i(`editor.callout.type.${t.value}`)},t.value))})]})]}),(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.title.label")}),(0,V.jsx)(a.Input,{onChange:t=>y(t.target.value),placeholder:i("editor.callout.dialog.title.placeholder"),type:"text",value:w})]}),(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.body.label")}),(0,V.jsx)(a.Input,{onChange:t=>S(t.target.value),placeholder:i("editor.callout.dialog.body.placeholder"),type:"text",value:v})]})]}),(0,V.jsxs)(l.DialogFooter,{children:[(0,V.jsx)(s.Button,{onClick:C,variant:"outline",children:i("editor.callout.dialog.button.cancel")}),(0,V.jsx)(s.Button,{onClick:k,children:i("editor.callout.dialog.button.apply")})]})]})]}),(0,V.jsx)(e.ActionButton,{action:E,icon:"Trash2",tooltip:i("editor.delete")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleCodeBlock=function(){const t=m.useEditableEditor(),r=m.useEditorInstance(),i=m.useExtension(F.CodeBlock.name),s=(0,H.useCallback)(({editor:t})=>t.isActive(F.CodeBlock.name),[]),o=(0,H.useMemo)(()=>i?i.options?.lowlight?.listLanguages?.()||["plaintext","html","css","js","ts"]:[],[i]),l=(0,H.useCallback)(()=>St(F.CodeBlock.name,r),[r]);return t?(0,V.jsx)(vt,{editor:r,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleCodeBlock",shouldShow:s,getReferencedVirtualElement:()=>{const{from:t}=r.state.selection,e=r.view.domAtPos(t).node.parentElement;return e?{getBoundingClientRect:()=>e.getBoundingClientRect()}:null},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(Ga,{listLanguages:o}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(e.ActionButton,{action:()=>{const t=(()=>{const{from:t}=r.state.selection,e=r.state.doc.resolve(t);for(let n=e.depth;n>=0;n--){const t=e.node(n);if("codeBlock"===t.type.name)return t.textContent}return""})();navigator.clipboard.writeText(t)},tooltip:"Copy",children:(0,V.jsx)(q.Copy,{size:16})}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(e.ActionButton,{action:l,tooltip:"Delete",children:(0,V.jsx)(q.Trash2,{size:16})})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleColumns=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),s=(0,H.useCallback)(()=>n.isActive(v.MultipleColumnNode.name),[n]),o=(0,H.useCallback)(()=>St(v.MultipleColumnNode.name,n),[n]),l=(0,H.useCallback)(()=>n.chain().focus().addColBefore().run(),[n]),c=(0,H.useCallback)(()=>n.chain().focus().addColAfter().run(),[n]),a=(0,H.useCallback)(()=>n.chain().focus().deleteCol().run(),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleColumns",shouldShow:s,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:l,icon:"ColumnAddLeft",tooltip:i("editor.table.menu.insertColumnBefore")}),(0,V.jsx)(e.ActionButton,{action:c,icon:"ColumnAddRight",tooltip:i("editor.table.menu.insertColumnAfter")}),(0,V.jsx)(e.ActionButton,{action:a,icon:"DeleteColumn",tooltip:i("editor.table.menu.deleteColumn")}),(0,V.jsx)(e.ActionButton,{action:o,icon:"Trash2",tooltip:i("editor.table.menu.delete_column")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleDrawer=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=b.useAttributes(s,S.Drawer.name),l=m.useExtension(S.Drawer.name),c=(0,H.useMemo)(()=>function(t,n){return[...Dt(t,n),{type:"edit",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawer",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(t.type.name===S.Drawer.name)return i=!0,!1}),i},children:c?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:c?.map((t,e)=>"edit"===t.type&&o?.src?(0,V.jsx)(Mt,{attrs:o,editor:s,extension:l},`bubbleMenu-drawer-${e}`):(0,V.jsx)(Nt,{editor:s,item:t},`bubbleMenu-drawer-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleDrawio=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{width:s}=function(t){const e=t.options.element;zt.has("width")||zt.set("width",e.clientWidth),zt.has("width")&&zt.get("width")<=0&&zt.set("width",e.clientWidth);const n=new MutationObserver(function(){zt.set("width",e.clientWidth)});return n.observe(e,{attributes:!0,childList:!0,subtree:!0}),t.on("destroy",()=>{n.disconnect()}),{width:zt.get("width")}}(n),o=b.useAttributes(n,y.Drawio.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:l,createUser:c,width:a,height:h}=o,d=(0,H.useCallback)(t=>{n.chain().updateAttributes(y.Drawio.name,t).setNodeSelection(n.state.selection.from).focus().run()},[n]),u=(0,H.useCallback)(()=>{const t=g.EVENTS.DRAWIO?.(n.id)||`drawio-${n.id}`;g.emit(t,o)},[n,o]),p=(0,H.useCallback)(()=>n.isActive(y.Drawio.name),[n]),f=(0,H.useCallback)(()=>St(y.Drawio.name,n),[n]);return(0,H.useEffect)(()=>{l&&(u(),n.chain().updateAttributes(y.Drawio.name,{defaultShowPicker:!1}).focus().run())},[c,l,n,u]),t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawio",shouldShow:p,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:u,icon:"Pencil",tooltip:i("editor.edit")}),(0,V.jsx)(Rt,{height:h,maxWidth:s,onOk:d,width:a,children:(0,V.jsx)(e.ActionButton,{icon:"Settings",tooltip:i("editor.settings")})}),(0,V.jsx)(e.ActionButton,{action:f,icon:"Trash2",tooltip:i("editor.delete")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleIframe=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{width:o,height:c,src:h}=b.useAttributes(n,C.Iframe.name,{width:0,height:0,src:"",defaultShowPicker:!1}),[d,u]=(0,H.useState)(!1),[p,f]=(0,H.useState)(""),g=(0,H.useCallback)(t=>{t?.preventDefault?.(),u(!1)},[u]);(0,H.useEffect)(()=>{d&&f(h)},[d,h]);const x=(0,H.useCallback)(t=>{t?.preventDefault?.();const e=C.getServiceSrc(p);n.chain().updateAttributes(C.Iframe.name,{src:e?.src||p}).setNodeSelection(n.state.selection.from).focus().run(),u(!1)},[n,p,u]),w=(0,H.useCallback)(()=>{window.open(h,"_blank")},[h]),y=(0,H.useCallback)(t=>{n.chain().updateAttributes(C.Iframe.name,t).setNodeSelection(n.state.selection.from).focus().run()},[n]),v=(0,H.useCallback)(()=>n.isActive(C.Iframe.name)&&!h,[n,h]),S=(0,H.useCallback)(()=>St(C.Iframe.name,n),[n]);return t?(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleIframe",shouldShow:v,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:w,icon:"Eye",tooltip:"Visit Link"}),(0,V.jsxs)(l.Dialog,{onOpenChange:u,open:d,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:"Open Edit Link"})}),(0,V.jsxs)(l.DialogContent,{children:[(0,V.jsx)(l.DialogHeader,{children:(0,V.jsx)(l.DialogTitle,{children:"Edit Link Iframe"})}),(0,V.jsx)(a.Input,{autoFocus:!0,onInput:t=>f(t.target.value),placeholder:"Enter link",type:"url",value:p}),(0,V.jsxs)(l.DialogFooter,{children:[(0,V.jsx)(s.Button,{onClick:g,type:"button",children:"Cancel"}),(0,V.jsx)(s.Button,{onClick:x,type:"button",children:"OK"})]})]})]}),(0,V.jsx)(Rt,{height:c,onOk:y,width:o,children:(0,V.jsx)(e.ActionButton,{icon:"Settings",tooltip:i("editor.settings")})}),(0,V.jsx)(e.ActionButton,{action:S,icon:"Trash2",tooltip:i("editor.delete")})]})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleImage=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=(0,H.useMemo)(()=>function(t,n){return[{type:"flipX",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const{flipX:e}=t.getAttributes("image");t.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!e}).run()}}},{type:"flipY",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const{flipY:e}=t.getAttributes("image");t.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!e}).run()}}},...Ct(t,n),..._t(t,n),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImage",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===f.Image.name}(t))return i=!0,!1}),i},children:o?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:o?.map((t,e)=>(0,V.jsx)(Lt,{editor:s,item:t},`bubbleMenu-image-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleImageGif=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=(0,H.useMemo)(()=>function(t,n){return[...Et(t,n),...At(t,n),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,n,t]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImageGif",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===A.ImageGif.name}(t))return i=!0,!1}),i},children:o?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:o?.map((t,e)=>(0,V.jsx)(Lt,{editor:s,item:t},`bubbleMenu-image-gif-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleKatex=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),[r,i]=(0,H.useState)(!1),s=(0,H.useCallback)(()=>n.isActive(b.Katex.name),[n]),o=(0,H.useCallback)(()=>St(b.Katex.name,n),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleKatex",shouldShow:s,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(Pt,{toggleVisible:i,visible:r,children:(0,V.jsx)(e.ActionButton,{action:()=>i(!r),tooltip:"Edit",children:(0,V.jsx)(q.Pencil,{size:16})})}),(0,V.jsx)(e.ActionButton,{action:o,tooltip:"Delete",children:(0,V.jsx)(q.Trash2,{size:16})})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleLink=function(){const t=m.useEditableEditor(),e=m.useEditorInstance(),[n,r]=(0,H.useState)(!1),i=b.useAttributes(e,_.Link.name)?.href,s=(0,H.useCallback)(({editor:t})=>t.isActive(_.Link.name),[]),o=(0,H.useCallback)(()=>{e.chain().extendMarkRange("link").unsetLink().focus().run(),r(!1)},[e]);return t?(0,V.jsx)(vt,{editor:e,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleLink",shouldShow:s,children:(0,V.jsx)(V.Fragment,{children:n?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(_.LinkEditBlock,{editor:e,onClose:()=>{r(!1)},onSetLink:(t,n,i)=>{const{from:s}=e.state.selection,o=s+(n?.length??0);e.chain().extendMarkRange("link").insertContent({type:"text",text:n,marks:[{type:"link",attrs:{href:t,target:i?"_blank":""}}]}).setLink({href:t}).setTextSelection({from:s,to:o}).focus().run(),r(!1)}})}):(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(Bt,{editor:e,link:i,onClear:o,onEdit:()=>{r(!0)}})})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleMenuDragHandle=function(){const t=m.useEditorInstance(),n=m.useEditableEditor(),{t:s}=r.useLocale(),[o,l]=(0,H.useState)(null),[a,h]=(0,H.useState)(-1),[d,u]=(0,H.useState)(!1),p=t?.extensionManager?.extensions?.some(t=>t?.name===z.TextAlign.name),f=t?.extensionManager?.extensions?.some(t=>t?.name===U.Indent.name),g=t?.extensionManager?.extensions?.some(t=>t?.name===L.Clear.name);function x(e){t.commands.setTextAlign(e)}const w=(0,H.useCallback)(t=>{t.node&&l(t.node),h(t.pos),requestAnimationFrame(()=>{t.editor.commands.focus()})},[]);(0,H.useEffect)(()=>(d?t.commands.setMeta("lockDragHandle",!0):t.commands.setMeta("lockDragHandle",!1),()=>{t.commands.setMeta("lockDragHandle",!1)}),[d]);const y=t=>{n&&u(t)};return(0,V.jsx)(Ka,{className:"richtext-transition-all richtext-duration-200 richtext-ease-out",editor:t,onNodeChange:w,pluginKey:"RichTextBubbleMenuDragHandle",children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[(0,V.jsx)(e.ActionButton,{disabled:!n,icon:"Grip",tooltip:s("editor.draghandle.grip"),action:t=>{t.preventDefault(),t.stopPropagation(),y(!d)}}),(0,V.jsxs)(c.DropdownMenu,{onOpenChange:y,open:d,children:[(0,V.jsx)(c.DropdownMenuTrigger,{className:"richtext-pointer-events-none"}),(0,V.jsxs)(c.DropdownMenuContent,{align:"start",className:"richtext-w-48",hideWhenDetached:!0,side:"bottom",sideOffset:0,children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3 richtext-bg-opacity-10 hover:richtext-bg-red-400 hover:richtext-bg-opacity-20 focus:richtext-bg-red-400 focus:richtext-bg-opacity-30 focus:richtext-text-red-500 dark:hover:richtext-bg-opacity-20 dark:hover:richtext-text-red-500",onClick:function(){t.chain().setMeta("hideDragHandle",!0).setNodeSelection(a).deleteSelection().run()},children:[(0,V.jsx)(i.IconComponent,{name:"Trash2"}),(0,V.jsx)("span",{children:s("editor.remove")})]}),g?(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:function(){const e=t.chain();e.setNodeSelection(a).unsetAllMarks(),"paragraph"!==o?.type.name&&e.setParagraph(),e.run()},children:[(0,V.jsx)(i.IconComponent,{name:"PaintRoller"}),(0,V.jsx)("span",{children:s("editor.clear.tooltip")})]}):null,(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:function(){t.commands.setNodeSelection(a);const{$anchor:e}=t.state.selection,n=e.node(1)||t.state.selection.node;t.chain().setMeta("hideDragHandle",!0).insertContentAt(a+(o?.nodeSize||0),n.toJSON()).run()},children:[(0,V.jsx)(i.IconComponent,{name:"Copy"}),(0,V.jsx)("span",{children:s("editor.copy")})]}),p||f?(0,V.jsx)(c.DropdownMenuSeparator,{}):null,p?(0,V.jsxs)(c.DropdownMenuSub,{children:[(0,V.jsxs)(c.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[(0,V.jsx)(i.IconComponent,{name:"AlignCenter"}),(0,V.jsx)("span",{children:s("editor.textalign.tooltip")})]}),(0,V.jsx)(c.DropdownMenuPortal,{children:(0,V.jsxs)(c.DropdownMenuSubContent,{children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("left"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignLeft"}),(0,V.jsx)("span",{children:s("editor.textalign.left.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("center"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignCenter"}),(0,V.jsx)("span",{children:s("editor.textalign.center.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("right"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignRight"}),(0,V.jsx)("span",{children:s("editor.textalign.right.tooltip")})]})]})})]}):null,f?(0,V.jsxs)(c.DropdownMenuSub,{children:[(0,V.jsxs)(c.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[(0,V.jsx)(i.IconComponent,{name:"IndentIncrease"}),(0,V.jsx)("span",{children:s("editor.indent")})]}),(0,V.jsx)(c.DropdownMenuPortal,{children:(0,V.jsxs)(c.DropdownMenuSubContent,{children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:o?.attrs?.indent>=U.IndentProps.max,onClick:function(){const e=U.setNodeIndentMarkup(t.state.tr,a,1);e.setMeta("hideDragHandle",!0),t.view.dispatch&&t.view.dispatch(e)},children:[(0,V.jsx)(i.IconComponent,{name:"IndentIncrease"}),(0,V.jsx)("span",{children:s("editor.indent.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:o?.attrs?.indent<=U.IndentProps.min,onClick:function(){const e=U.setNodeIndentMarkup(t.state.tr,a,-1);t.view.dispatch&&t.view.dispatch(e)},children:[(0,V.jsx)(i.IconComponent,{name:"IndentDecrease"}),(0,V.jsx)("span",{children:s("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})},exports.RichTextBubbleMermaid=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=b.useAttributes(s,j.Mermaid.name),l=m.useExtension(j.Mermaid.name),c=(0,H.useMemo)(()=>function(t,n){return[...jt(t,n),{type:"edit",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleMermaid",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===j.Mermaid.name}(t))return i=!0,!1}),i},children:c?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:c?.map((t,e)=>"edit"===t.type&&o?.src?(0,V.jsx)(Ft,{attrs:o,editor:s,extension:l},`bubbleMenu-mermaid-${e}`):(0,V.jsx)($t,{editor:s,item:t},`bubbleMenu-mermaid-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleTable=function({hiddenActions:t=[]}){const{t:i}=r.useLocale(),s=m.useEditableEditor(),o=m.useEditorInstance(),l=e=>t.includes(e);return s?(0,V.jsx)(vt,{editor:o,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTable",shouldShow:({editor:t})=>(0,K.isActive)(t.view.state,D.Table.name),children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[!l("addColumnBefore")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addColumnBefore().run()},disabled:!o?.can()?.addColumnBefore?.(),icon:"BetweenHorizonalEnd",tooltip:i("editor.table.menu.insertColumnBefore"),tooltipOptions:{sideOffset:15}}),!l("addColumnAfter")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addColumnAfter().run()},disabled:!o?.can()?.addColumnAfter?.(),icon:"BetweenHorizonalStart",tooltip:i("editor.table.menu.insertColumnAfter"),tooltipOptions:{sideOffset:15}}),!l("deleteColumn")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteColumn().run()},disabled:!o?.can().deleteColumn?.(),icon:"DeleteColumn",tooltip:i("editor.table.menu.deleteColumn"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("addRowAbove")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addRowBefore().run()},disabled:!o?.can().addRowBefore?.(),icon:"BetweenVerticalEnd",tooltip:i("editor.table.menu.insertRowAbove"),tooltipOptions:{sideOffset:15}}),!l("addRowBelow")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addRowAfter().run()},disabled:!o?.can()?.addRowAfter?.(),icon:"BetweenVerticalStart",tooltip:i("editor.table.menu.insertRowBelow"),tooltipOptions:{sideOffset:15}}),!l("deleteRow")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteRow().run()},disabled:!o?.can()?.deleteRow?.(),icon:"DeleteRow",tooltip:i("editor.table.menu.deleteRow"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("mergeCells")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().mergeCells().run()},disabled:!o?.can()?.mergeCells?.(),icon:"TableCellsMerge",tooltip:i("editor.table.menu.mergeCells"),tooltipOptions:{sideOffset:15}}),!l("splitCells")&&(0,V.jsx)(e.ActionButton,{action:function(){o?.chain().focus().splitCell().run()},disabled:!o?.can()?.splitCell?.(),icon:"TableCellsSplit",tooltip:i("editor.table.menu.splitCells"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("deleteTable")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteTable().run()},disabled:!o?.can()?.deleteTable?.(),icon:"Trash2",tooltip:i("editor.table.menu.deleteTable"),tooltipOptions:{sideOffset:15}})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleText=function({buttonBubble:t}){const e=m.useEditorInstance();return m.useEditableEditor()?(0,V.jsx)(vt,{editor:e,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleText",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;return!t.isActive("codeBlock")&&(n.pos!==r&&e instanceof W.TextSelection)},children:t?(0,V.jsx)(V.Fragment,{children:t}):(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(Vt,{})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleTwitter=function(){const{t:t}=r.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),[s,o]=(0,H.useState)(!1),l=(0,H.useCallback)(({editor:t})=>t.isActive(B.Twitter.name),[]),c=(0,H.useCallback)(()=>St(B.Twitter.name,i),[i]);return n?(0,V.jsx)(vt,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTwitter",shouldShow:l,children:(0,V.jsx)(V.Fragment,{children:s?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(B.FormEditLinkTwitter,{editor:i,onSetLink:t=>{i.commands.updateTweet({src:t}),o(!1)}})}):(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{o(!0)}}),(0,V.jsx)(e.ActionButton,{action:c,icon:"Trash",tooltip:t("editor.delete"),tooltipOptions:{sideOffset:15}})]})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleVideo=function(){const{t:t}=r.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=(0,H.useMemo)(()=>function(t,n){return[...It(t,n),...Ot(t),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(i,t),[i,t]);return n?(0,V.jsx)(vt,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleVideo",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===w.Video.name}(t))return i=!0,!1}),i},children:s?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:s?.map((t,e)=>(0,V.jsx)(Lt,{editor:i,item:t},`bubbleMenu-video-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})};
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./rolldown-runtime-BeavJI0R.cjs"),e=require("./toggle-CRftKzl0.cjs"),n=require("./separator-CXjMk9dM.cjs"),r=require("./locales-Dg9XL0yP.cjs"),i=require("./Icon-DQdA22_-.cjs"),s=require("./button-CYMsgP3Y.cjs"),o=require("./floating-ui.dom-D9FglguG.cjs"),l=require("./dialog-CxZ2oxD2.cjs"),c=require("./dropdown-menu-CVJhYAPA.cjs"),a=require("./input-AvqqajGM.cjs"),h=require("./label-DPSH3PiY.cjs"),d=require("./popover-DEGqjF2J.cjs"),u=require("./Callout-DOHjjQtT.cjs"),p=require("./textarea-BFbGcrSO.cjs"),f=require("./ImageCropper-BAWOk69J.cjs"),g=require("./events.constant-BkYOoqSk.cjs"),m=require("./useButtonProps-D2Hd5DbR.cjs"),x=require("./file-B1Z0XcVJ.cjs"),w=require("./Video-BSH5k6Jd.cjs"),y=require("./Drawio-Bx8zt_CW.cjs"),b=require("./Katex-B1xls7hE.cjs"),v=require("./Column-I4gS_xKw.cjs"),S=require("./Drawer-B0QvuSOf.cjs"),k=require("./shortId-B25DIOpW.cjs"),C=require("./Iframe-DS5N9EFx.cjs"),E=require("./cdn-loader-D76eUWN7.cjs"),_=require("./LinkEditBlock-Or1HIYih.cjs"),A=require("./ImageGif-CWfgVc6e.cjs"),j=require("./Mermaid-3vSlkOlc.cjs"),D=require("./Table-B4KNW7Yq.cjs"),O=require("./Bold-M6IKTPME.cjs"),I=require("./Code-BsD1D1sK.cjs"),T=require("./Color-D5zLljFV.cjs"),M=require("./Highlight-DQxtCrNN.cjs"),N=require("./Italic-Brjxxqsi.cjs"),R=require("./renderCommandListDefault-CykwYpTX.cjs"),z=require("./TextAlign-6ElUYI4_.cjs"),P=require("./TextUnderline-ofstnQx_.cjs"),B=require("./Twitter-3yCP2UdP.cjs"),L=require("./Clear.cjs"),U=require("./Indent-6tc8tB62.cjs"),F=require("./CodeBlock-zh4cX5EA.cjs");let $=require("@tiptap/react"),H=require("react");H=t.__toESM(H,1);let V=require("react/jsx-runtime"),q=require("lucide-react"),J=require("react-dom"),K=require("@tiptap/core"),W=require("@tiptap/pm/state"),G=require("@tiptap/pm/view"),X=require("@tiptap/pm/model"),Y=require("@tiptap/pm/tables"),Z=require("easydrawer"),Q=require("@tiptap/pm/commands");var tt=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:c,options:a}){var h;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:t,state:e,from:n,to:r})=>{const{doc:i,selection:s}=e,{empty:o}=s,l=!i.textBetween(n,r).length&&(0,K.isTextSelection)(e.selection),c=this.element.contains(document.activeElement);return!(!t.hasFocus()&&!c||o||l||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(t,e)=>{const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(t,n,r,e)},this.updateDelay))},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(h=null==a?void 0:a.scrollTarget)?h:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(o.flip("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(o.shift("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(o.offset("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(o.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(o.size("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(o.autoPlacement("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(o.hide("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(o.inline("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=null==(t=this.getReferencedVirtualElement)?void 0:t.call(this);if(i)return i;if(!(null==(n=null==(e=this.view)?void 0:e.dom)?void 0:n.parentNode))return;const s=(0,K.posToDOMRect)(this.view,r.from,r.to);let o={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(r instanceof W.NodeSelection){let t=this.view.nodeDOM(r.from);const e=t.dataset.nodeViewWrapper?t:t.querySelector("[data-node-view-wrapper]");e&&(t=e),t&&(o={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(r instanceof Y.CellSelection){const{$anchorCell:t,$headCell:e}=r,n=t?t.pos:e.pos,i=e?e.pos:t.pos,s=this.view.nodeDOM(n),l=this.view.nodeDOM(i);if(!s||!l)return;const c=s===l?s.getBoundingClientRect():function(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),s=Math.max(t.right,e.right)-i;return new DOMRect(i,n,s,r-n)}(s.getBoundingClientRect(),l.getBoundingClientRect());o={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&o.computePosition(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,s;this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(t,e);const i=!(null==e?void 0:e.selection.eq(t.state.selection)),s=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,i,s,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),o=Math.max(...i.map(t=>t.$to.pos));return(null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:s,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.getReferencedVirtualElement&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},et=t=>new W.Plugin({key:"string"==typeof t.pluginKey?new W.PluginKey(t.pluginKey):t.pluginKey,view:e=>new tt({view:e,...t})}),nt=(K.Extension.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[et({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:o,appendTo:l,shouldShow:c}){var a;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:t,state:e})=>{const{selection:n}=e,{$anchor:r,empty:i}=n,s=1===r.depth,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!(t.hasFocus()&&i&&s&&o&&this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(a=null==o?void 0:o.scrollTarget)?a:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return(0,K.getText)(t,{textSerializers:(0,K.getTextSerializersFromSchema)(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(o.flip("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(o.shift("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(o.offset("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(o.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(o.size("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(o.autoPlacement("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(o.hide("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(o.inline("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),o=Math.max(...i.map(t=>t.$to.pos));return null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:s,to:o})}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!(null==(e=null==(t=this.view)?void 0:t.dom)?void 0:e.parentNode))return;const{selection:n}=this.editor.state,r=(0,K.posToDOMRect)(this.view,n.from,n.to);o.computePosition({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,s;(null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate())})}update(t,e){const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}}),rt=t=>new W.Plugin({key:"string"==typeof t.pluginKey?new W.PluginKey(t.pluginKey):t.pluginKey,view:e=>new nt({view:e,...t})});K.Extension.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[rt({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function it(t,e){return null!=t?t:new W.PluginKey(e)}var st="undefined"!=typeof window?H.useLayoutEffect:H.useEffect,ot=new Set(["left","opacity","position","top","visibility","width"]),lt=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),ct=new Set(["children","className","style"]),at=new Set(["tabIndex"]),ht=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),dt={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function ut(t,e){return/^on[A-Z]/.test(t)&&"function"==typeof e}function pt(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ft(t){return at.has(t)}function gt(t,e,n){"tabIndex"!==e?t[e]=n:t.tabIndex=Number(n)}function mt(t,e,n){ot.has(e)||t.style.setProperty(pt(e),function(t,e){return"number"!=typeof e||0===e||t.startsWith("--")||lt.has(t)?String(e):`${e}px`}(e,n))}function xt(t,e,n){new Set([...Object.keys(e),...Object.keys(n)]).forEach(r=>{if(ct.has(r)||!function(t){return t.startsWith("aria-")||t.startsWith("data-")||ht.has(t)}(r)||ut(r,e[r])||ut(r,n[r]))return;const i=e[r],s=n[r];if(i===s)return;const o=function(t){return t.startsWith("aria-")||t.startsWith("data-"),t}(r);return null==s||!1===s?(ft(r)&&function(t,e){if("tabIndex"===e)return void t.removeAttribute("tabindex");const n=t[e];t[e]="boolean"!=typeof n&&("number"!=typeof n?"":0)}(t,r),void t.removeAttribute(o)):!0===s?(ft(r)&>(t,r,!0),void t.setAttribute(o,"")):void(ft(r)?gt(t,r,s):t.setAttribute(o,String(s)))})}function wt(t,e,n){const r=null!=e?e:{},i=null!=n?n:{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(e=>{const n=r[e],s=i[e];n!==s&&(null!=s?mt(t,e,s):function(t,e){ot.has(e)||t.style.removeProperty(pt(e))}(t,e))})}function yt(t,e,n){e.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)});const r=[];return Object.entries(n).forEach(([e,n])=>{if(!ut(e,n))return;const{eventName:i,options:s}=function(t){var e;const n=t.endsWith("Capture"),r=(n?t.slice(0,-7):t).slice(2);return{eventName:null!=(e=dt[r])?e:r.toLowerCase(),options:n?{capture:!0}:void 0}}(e),o=e=>{n(function(t,e){let n=e.defaultPrevented,r=!1;const i=Object.create(e);return Object.defineProperties(i,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),i}(t,e))};t.addEventListener(i,o,s),r.push({eventName:i,listener:o,options:s})}),r}function bt(t,e){const n=(0,H.useRef)({}),r=(0,H.useRef)([]);st(()=>{const i=n.current;return function(t,e,n){e!==n&&(n?t.className=n:t.removeAttribute("class"))}(t,i.className,e.className),wt(t,i.style,e.style),xt(t,i,e),r.current=yt(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)}),r.current=[]}},[t,e])}var vt=H.default.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:o,options:l,children:c,...a},h)=>{const d=(0,H.useRef)(document.createElement("div")),u=(0,H.useRef)(it(t,"bubbleMenu")).current;bt(d.current,a),"function"==typeof h?h(d.current):h&&(h.current=d.current);const{editor:p}=(0,$.useCurrentEditor)(),f=e||p,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:u,shouldShow:s,getReferencedVirtualElement:o,options:l},m=(0,H.useRef)(g);m.current=g;const[x,w]=(0,H.useState)(!1),y=(0,H.useRef)(!0);return(0,H.useEffect)(()=>{if(null==f?void 0:f.isDestroyed)return;if(!f)return;const t=d.current;t.style.visibility="hidden",t.style.position="absolute";const e=et({...m.current,editor:f,element:t});f.registerPlugin(e);const n=m.current.pluginKey;return y.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[f]),(0,H.useEffect)(()=>{x&&f&&!f.isDestroyed&&(y.current?y.current=!1:f.view.dispatch(f.state.tr.setMeta(u,{type:"updateOptions",options:m.current})))},[x,f,n,r,s,l,i,o,u]),(0,J.createPortal)(c,d.current)});H.default.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,options:o,children:l,...c},a)=>{const h=(0,H.useRef)(document.createElement("div")),d=(0,H.useRef)(it(t,"floatingMenu")).current;bt(h.current,c),"function"==typeof a?a(h.current):a&&(a.current=h.current);const{editor:u}=(0,$.useCurrentEditor)(),p=e||u,f={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:s,options:o},g=(0,H.useRef)(f);g.current=f;const[m,x]=(0,H.useState)(!1),w=(0,H.useRef)(!0);return(0,H.useEffect)(()=>{if(null==p?void 0:p.isDestroyed)return;if(!p)return;const t=h.current;t.style.visibility="hidden",t.style.position="absolute";const e=rt({...g.current,editor:p,element:t});p.registerPlugin(e);const n=g.current.pluginKey;return w.current=!0,x(!0),()=>{x(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[p]),(0,H.useEffect)(()=>{m&&p&&!p.isDestroyed&&(w.current?w.current=!1:p.view.dispatch(p.state.tr.setMeta(d,{type:"updateOptions",options:g.current})))},[m,p,n,r,s,o,i,d]),(0,J.createPortal)(l,h.current)});function St(t,e){const{state:n}=e,r=n.selection.$anchor;let i=!1;if(r.depth)for(let s=r.depth;s>0;s--)r.node(s).type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(r.before(s),r.after(s)).scrollIntoView()),i=!0);else{const r=n.selection.node;r&&r.type.name===t&&(e.chain().deleteSelection().run(),i=!0)}if(!i){const s=r.pos;if(s){const r=n.tr.doc.nodeAt(s);r&&r.type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(s,s+r.nodeSize)),i=!0)}}return i}var kt=[{value:"note",label:"Note",icon:"Info"},{value:"tip",label:"Tip",icon:"Lightbulb"},{value:"important",label:"Important",icon:"AlertCircle"},{value:"warning",label:"Warning",icon:"TriangleAlert"},{value:"caution",label:"Caution",icon:"OctagonAlert"}];function Ct(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`image-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateImage({width:r.IMAGE_SIZE[s]}),isActive:()=>t.isActive("image",{width:r.IMAGE_SIZE[s]})}}))}function Et(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`image-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateImageGif({width:r.IMAGE_SIZE[s]}),isActive:()=>t.isActive("image",{width:r.IMAGE_SIZE[s]})}}))}function _t(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImage?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function At(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageGif?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function jt(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageMermaid?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function Dt(t,n){const r={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return["left","center","right"].map(i=>({type:`image-${i}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.textalign.${i}.tooltip`),icon:r[i],action:()=>t.commands?.setAlignImageDrawer?.(i),isActive:()=>t.isActive({align:i})||!1,disabled:!1}}))}function Ot(t){return[{type:"flex-start",icon:"AlignLeft",tooltip:"Align left"},{type:"center",icon:"AlignCenter",tooltip:"Align center"},{type:"flex-end",icon:"AlignRight",tooltip:"Align right"}].map(n=>({type:`video-align-${n.type}`,component:e.ActionButton,componentProps:{tooltip:n.tooltip,icon:n.icon,action:()=>t.commands.updateVideo({align:n.type}),isActive:()=>t.getAttributes("video").align===n.type}}))}function It(t,n){const i=["SizeS","SizeM","SizeL"];return["size-small","size-medium","size-large"].map((s,o)=>({type:`video-${s}`,component:e.ActionButton,componentProps:{tooltip:n(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>t.commands.updateVideo({width:r.VIDEO_SIZE[s]}),isActive:()=>t.isActive("video",{width:r.VIDEO_SIZE[s]})}}))}var Tt=!1;function Mt({editor:t,attrs:n,extension:r}){const[i,o]=(0,H.useState)(!1),c=(0,H.useRef)(null),a=(0,H.useRef)(null),{alt:h,align:d}=n,u=r?.options.upload;(0,H.useEffect)(()=>{i&&setTimeout(()=>{(async()=>{const t=document.querySelector("#easydrawer");t&&(c.current=new Z.Editor(t,{wheelEventsEnabled:!1,disableZoom:!0}),a.current=(0,Z.makeDropdownToolbar)(c.current),a.current.addDefaultToolWidgets(),c.current.loadFromSVG(decodeURIComponent(h)))})()},200)},[i]);const p=()=>{if(Tt){for(;c.current.history.redoStackSize>0;)c.current.history.redo();Tt=!1}else c.current.history.undo()};return(0,V.jsxs)(l.Dialog,{onOpenChange:o,open:i,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{action:()=>o(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:"Edit Drawer"}),(0,V.jsxs)("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,V.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,V.jsx)(S.ControlDrawer,{changeBorderColorShape:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setBorderColor(t),n.serializeState())},changeColorShape:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setColor(t),n.serializeState())},changeShape:t=>{const e=a.current.getWidgetById("shape");e&&e.setShapeType(t)},onClear:()=>{if(!Tt){for(;c.current.history.undoStackSize>0;)p();Tt=!0}},onRedo:()=>{Tt||c.current.history.redo()},onThicknessChange:t=>{const e=c.current.toolController.getPrimaryTools()[5],n=a.current.getWidgetById("shape");e&&n&&(e.setThickness(t),n.serializeState())},onUndo:p,refEditor:c,setColorHighlight:t=>{const e=c.current.toolController.getPrimaryTools()[3],n=a.current.getWidgetById("pen-2");e&&n&&(e.setColor(t),n.serializeState())},setColorPen:t=>{const e=c.current.toolController.getPrimaryTools()[2],n=a.current.getWidgetById("pen-1");e&&n&&(e.setColor(t),n.serializeState())},setThicknessPen:t=>{const e=c.current.toolController.getPrimaryTools()[2],n=a.current.getWidgetById("pen-1");e&&n&&(e.setThickness(t),n.serializeState())}})]}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:async()=>{if(c.current){const e=c.current.toSVG(),n=e.outerHTML,r=`drawer-${k.shortId()}.svg`;let i=k.i(e.outerHTML);if(u){const t=x.dataURLtoFile(i,r);i=await u(t)}t?.chain().focus().setDrawer({type:"drawer",src:i,alt:encodeURIComponent(n),width:426,height:212},!!n).run(),t?.commands.setAlignImageDrawer(d)}o(!1)},type:"button",children:"Save changes"})})]})]})}function Nt({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentProps?.disabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}var Rt=({width:t,maxWidth:e,height:n,onOk:i,children:o})=>{const{t:l}=r.useLocale(),[c,u]=(0,H.useState)({width:"",height:"",maxWidth:""});return(0,H.useEffect)(()=>{u({width:t,height:n,maxWidth:e})},[n,e,t]),(0,V.jsxs)(d.Popover,{modal:!0,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,children:o}),(0,V.jsx)(d.PopoverContent,{children:(0,V.jsxs)("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:function(t){t.preventDefault(),t.stopPropagation(),i(c)},children:[(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Width"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,width:t.target.value}),required:!0,type:"number",value:c.width})})}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Max Width"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,maxWidth:t.target.value}),required:!0,type:"number",value:c.maxWidth})})}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Height"}),(0,V.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,V.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,V.jsx)(a.Input,{onChange:t=>u({...c,height:t.target.value}),required:!0,type:"number",value:c.height})})}),(0,V.jsx)(s.Button,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:l("editor.link.dialog.button.apply")})]})})]})},zt=new Map;function Pt({children:t,visible:e,toggleVisible:n}){const{t:i}=r.useLocale(),o=m.useEditorInstance(),[c,a]=(0,H.useState)(null);(0,H.useEffect)(()=>{E.loadKatex().then(a)},[]);const{text:d,macros:u}=b.useAttributes(o,b.Katex.name,{text:"",macros:""}),[f,g]=(0,H.useState)(decodeURIComponent(d||"")),[x,w]=(0,H.useState)(decodeURIComponent(u||""));(0,H.useEffect)(()=>{e&&(g(decodeURIComponent(d||"")),w(decodeURIComponent(u||"")))},[e]);const y=(0,H.useCallback)(()=>{o.chain().focus().setKatex({text:encodeURIComponent(f),macros:encodeURIComponent(x)}).run(),g(""),w(""),n(!1)},[o,f,x,n]),v=(0,H.useMemo)(()=>{if(!c)return f;try{return c.renderToString(f,{macros:b.safeJSONParse(x||"")})}catch{return f}},[f,x,c]),S=(0,H.useMemo)(()=>`${f}`.trim()?v:null,[f,v]);return(0,V.jsxs)(l.Dialog,{onOpenChange:n,open:e,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:t}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:i("editor.formula.dialog.text")}),(0,V.jsx)("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,V.jsxs)("div",{className:"richtext-flex-1",children:[(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Expression"}),(0,V.jsx)(p.Textarea,{autoFocus:!0,className:"richtext-mb-[10px]",onChange:t=>g(t.target.value),placeholder:"Text",required:!0,rows:10,value:f,style:{color:"hsl(var(--foreground))"}}),(0,V.jsx)(h.Label,{className:"mb-[6px]",children:"Macros"}),(0,V.jsx)(p.Textarea,{onChange:t=>w(t.target.value),placeholder:"Macros",rows:10,value:x,style:{color:"hsl(var(--foreground))"}})]}),(0,V.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:S||""},style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:y,type:"button",children:"Save changes"})})]})]})}function Bt(t){const{t:n}=r.useLocale();return(0,V.jsxs)("div",{className:"richtext-flex richtext-flex-nowrap",children:[(0,V.jsx)(e.ActionButton,{disabled:!t?.link,icon:"ExternalLink",tooltip:n("editor.link.open.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{window.open(t?.link,"_blank")}}),(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:n("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{t?.onEdit()}}),(0,V.jsx)(e.ActionButton,{icon:"Unlink",tooltip:n("editor.link.unlink.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{t?.onClear()}})]})}function Lt({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentdisabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}var Ut="graph TB\na--\x3eb",Ft=({editor:t,attrs:n,extension:r})=>{const{alt:i,align:o}=n,[c,a]=(0,H.useState)(decodeURIComponent(i??Ut)),[h,d]=(0,H.useState)(""),[u,f]=(0,H.useState)(!1),g=(0,H.useRef)(null),[m,w]=(0,H.useState)(null),y=r?.options.upload,b=(0,H.useCallback)(t=>{t&&import("mermaid").then(t=>{w(t.default)})},[]),v=async t=>{try{const{svg:e}=await m.render("mermaid-svg",t);d(e)}catch{d("")}};(0,H.useEffect)(()=>{m&&u&&(m.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),v(c))},[m,u]),(0,H.useEffect)(()=>{m&&u&&v(c)},[m,c]);return(0,V.jsxs)(l.Dialog,{onOpenChange:f,open:u,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{action:()=>f(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),(0,V.jsxs)(l.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,V.jsx)(l.DialogTitle,{children:"Edit Mermaid"}),(0,V.jsx)("div",{ref:b,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[(0,V.jsx)(p.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Ut,onChange:t=>a(t.target.value),placeholder:"Text",required:!0,rows:10,value:c,style:{color:"hsl(var(--foreground))"}}),(0,V.jsx)("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:h},ref:g,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500}})]})}),(0,V.jsx)(l.DialogFooter,{children:(0,V.jsx)(s.Button,{onClick:async()=>{if(""!==c){if(c){const e=g.current.querySelector("svg"),{width:n,height:r}=e.getBoundingClientRect(),i=`mermaid-${k.shortId()}.svg`;let s=k.i(e.outerHTML);if(y){const t=x.dataURLtoFile(s,i);s=await y(t)}t?.chain().focus().setMermaid({type:"mermaid",src:s,alt:encodeURIComponent(c),width:n,height:r},!!c).run(),t?.commands.setAlignImageMermaid(o)}f(!1)}},type:"button",children:"Save changes"})})]})]})};function $t({item:t,disabled:e,editor:r}){const i=t.component;return i?(0,V.jsx)(H.Fragment,{children:"divider"===t.type?(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):(0,V.jsx)(i,{...t.componentProps,disabled:e||t?.componentProps?.disabled,editor:r})}):(0,V.jsx)(V.Fragment,{})}function Ht(){const{t:t}=r.useLocale(),[n,s]=(0,H.useState)(!1),o=m.useEditorInstance(),l=(0,H.useMemo)(()=>R.renderCommandListDefault({t:t})?.[0]?.commands,[t]),c=(0,H.useMemo)(()=>l?.find(t=>t?.isActive?.(o))?.label,[o.state.selection.ranges,n,o,l,t]),a=(0,H.useMemo)(()=>l?.find(t=>t?.isActive?.(o)),[o.state.selection.ranges,n,o,l]);return(0,V.jsxs)(d.Popover,{modal:!0,onOpenChange:s,open:n,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,V.jsx)(e.ActionButton,{dataState:!!c,tooltip:c||t("editor.paragraph.tooltip"),children:(0,V.jsx)(i.IconComponent,{name:a?.iconName||"Type"})})}),(0,V.jsx)(d.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:l?.map(e=>{const n=e?.isActive?.(o);return(0,V.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-1.5 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:t=>{t.preventDefault(),e.action({editor:o,range:o.state.selection.ranges}),s(!1)},children:[(0,V.jsxs)("div",{className:"!richtext-min-w-[16px]",children:[n&&(0,V.jsx)(q.Check,{size:16}),!c&&e.label===t("editor.paragraph.tooltip")&&!n&&(0,V.jsx)(q.Check,{size:16})]}),(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:[e.iconName&&(0,V.jsx)(i.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:e.iconName}),e.label]})]},e.name)})})]})}function Vt(){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ht,{}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(O.RichTextBold,{}),(0,V.jsx)(N.RichTextItalic,{}),(0,V.jsx)(P.RichTextUnderline,{}),(0,V.jsx)(I.RichTextCode,{}),(0,V.jsx)(_.RichTextLink,{}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(T.RichTextColor,{}),(0,V.jsx)(M.RichTextHighlight,{}),(0,V.jsx)(z.RichTextAlign,{})]})}var qt=()=>new Map,Jt=t=>{const e=qt();return t.forEach((t,n)=>{e.set(n,t)}),e},Kt=(t,e,n)=>{let r=t.get(e);return void 0===r&&t.set(e,r=n()),r},Wt=()=>new Set,Gt=t=>t[t.length-1],Xt=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Yt=Array.from,Zt=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Qt=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},te=Array.isArray,ee=class{constructor(){this._observers=qt()}on(t,e){return Kt(this._observers,t,Wt).add(e),e}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(t,e){return Yt((this._observers.get(t)||qt()).values()).forEach(t=>t(...e))}destroy(){this._observers=qt()}},ne=Math.floor,re=Math.abs,ie=(t,e)=>t<e?t:e,se=(t,e)=>t>e?t:e,oe=(Number.isNaN,t=>0!==t?t<0:1/t<0),le=Number.MAX_SAFE_INTEGER,ce=Number.MIN_SAFE_INTEGER,ae=Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&ne(t)===t),he=(Number.isNaN,Number.parseInt,String.fromCharCode),de=(String.fromCodePoint,he(65535),/^\s*/g),ue=/([A-Z])/g,pe=(t,e)=>(t=>t.replace(de,""))(t.replace(ue,t=>`${e}${(t=>t.toLowerCase())(t)}`)),fe="undefined"!=typeof TextEncoder?new TextEncoder:null,ge=fe?t=>fe.encode(t):t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},me="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});me&&1===me.decode(new Uint8Array).length&&(me=null);var xe=(t,e)=>((t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n})(e,()=>t).join(""),we=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ye=()=>new we,be=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e})(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ve=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},Se=ve,ke=(t,e)=>{for(;e>127;)ve(t,128|127&e),e=ne(e/128);ve(t,127&e)},Ce=(t,e)=>{const n=oe(e);for(n&&(e=-e),ve(t,(e>63?128:0)|(n?64:0)|63&e),e=ne(e/64);e>0;)ve(t,(e>127?128:0)|127&e),e=ne(e/128)},Ee=new Uint8Array(3e4),_e=Ee.length/3,Ae=fe&&fe.encodeInto?(t,e)=>{if(e.length<_e){const n=fe.encodeInto(e,Ee).written||0;ke(t,n);for(let e=0;e<n;e++)ve(t,Ee[e])}else De(t,ge(e))}:(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ke(t,r);for(let i=0;i<r;i++)ve(t,n.codePointAt(i))},je=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=ie(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(se(2*n,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},De=(t,e)=>{ke(t,e.byteLength),je(t,e)},Oe=(t,e)=>{((t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(2*se(n,e)),t.cpos=0)})(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Ie=new DataView(new ArrayBuffer(4)),Te=(t,e)=>{switch(typeof e){case"string":ve(t,119),Ae(t,e);break;case"number":ae(e)&&re(e)<=2147483647?(ve(t,125),Ce(t,e)):(n=e,Ie.setFloat32(0,n),Ie.getFloat32(0)===n?(ve(t,124),((t,e)=>{Oe(t,4).setFloat32(0,e,!1)})(t,e)):(ve(t,123),((t,e)=>{Oe(t,8).setFloat64(0,e,!1)})(t,e)));break;case"bigint":ve(t,122),((t,e)=>{Oe(t,8).setBigInt64(0,e,!1)})(t,e);break;case"object":if(null===e)ve(t,126);else if(te(e)){ve(t,117),ke(t,e.length);for(let n=0;n<e.length;n++)Te(t,e[n])}else if(e instanceof Uint8Array)ve(t,116),De(t,e);else{ve(t,118);const n=Object.keys(e);ke(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];Ae(t,i),Te(t,e[i])}}break;case"boolean":ve(t,e?120:121);break;default:ve(t,127)}var n},Me=class extends we{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&ke(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}},Ne=t=>{t.count>0&&(Ce(t.encoder,1===t.count?t.s:-t.s),t.count>1&&ke(t.encoder,t.count-2))},Re=class{constructor(){this.encoder=new we,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Ne(this),this.count=1,this.s=t)}toUint8Array(){return Ne(this),be(this.encoder)}},ze=t=>{if(t.count>0){const e=2*t.diff+(1===t.count?0:1);Ce(t.encoder,e),t.count>1&&ke(t.encoder,t.count-2)}},Pe=class{constructor(){this.encoder=new we,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(ze(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return ze(this),be(this.encoder)}},Be=class{constructor(){this.sarr=[],this.s="",this.lensE=new Re}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new we;return this.sarr.push(this.s),this.s="",Ae(t,this.sarr.join("")),je(t,this.lensE.toUint8Array()),be(t)}},Le=t=>new Error(t),Ue=()=>{throw Le("Method unimplemented")},Fe=()=>{throw Le("Unexpected case")},$e=Le("Unexpected end of array"),He=Le("Integer out of Range"),Ve=class{constructor(t){this.arr=t,this.pos=0}},qe=t=>new Ve(t),Je=t=>((t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n})(t,We(t)),Ke=t=>t.arr[t.pos++],We=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const r=t.arr[t.pos++];if(e+=(127&r)*n,n*=128,r<128)return e;if(e>le)throw He}throw $e},Ge=t=>{let e=t.arr[t.pos++],n=63&e,r=64;const i=(64&e)>0?-1:1;if(!(128&e))return i*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n+=(127&e)*r,r*=128,e<128)return i*n;if(n>le)throw He}throw $e},Xe=me?t=>me.decode(Je(t)):t=>{let e=We(t);if(0===e)return"";{let n=String.fromCodePoint(Ke(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Ke(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Ye=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Ze=[t=>{},t=>null,Ge,t=>Ye(t,4).getFloat32(0,!1),t=>Ye(t,8).getFloat64(0,!1),t=>Ye(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Xe,t=>{const e=We(t),n={};for(let r=0;r<e;r++){n[Xe(t)]=Qe(t)}return n},t=>{const e=We(t),n=[];for(let r=0;r<e;r++)n.push(Qe(t));return n},Je],Qe=t=>Ze[127-Ke(t)](t),tn=class extends Ve{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){var t;return 0===this.count&&(this.s=this.reader(this),(t=this).pos!==t.arr.length?this.count=We(this)+1:this.count=-1),this.count--,this.s}},en=class extends Ve{constructor(t){super(t),this.s=0,this.count=0}read(){if(0===this.count){this.s=Ge(this);const t=oe(this.s);this.count=1,t&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}},nn=class extends Ve{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const t=Ge(this),e=1&t;this.diff=ne(t/2),this.count=1,e&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}},rn=class{constructor(t){this.decoder=new en(t),this.str=Xe(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}},sn=(crypto.subtle,crypto.getRandomValues.bind(crypto)),on=Math.random,ln=()=>sn(new Uint32Array(1))[0],cn=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(t^ln()&15>>t/4).toString(16)),an=Date.now,hn=t=>new Promise(t),dn=(Promise.all.bind(Promise),t=>void 0===t?null:t),un=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}};try{"undefined"!=typeof localStorage&&localStorage&&(un=localStorage,!1)}catch(Xa){}var pn,fn,gn,mn,xn=un,wn=Symbol("Equality"),yn=(t,e)=>t===e||!!t?.[wn]?.(e)||!1,bn=Object.assign,vn=Object.keys,Sn=t=>vn(t).length,kn=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Cn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),En=Object.freeze,_n=t=>{for(const e in t){const n=t[e];"object"!=typeof n&&"function"!=typeof n||_n(t[e])}return En(t)},An=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&An(t,e,n+1)}},jn=(t,e)=>{if(t===e)return!0;if(null==t||null==e||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(null!=t[wn])return t[wn](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break;case Set:if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break;case Map:if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!jn(t.get(n),e.get(n)))return!1;break;case void 0:case Object:if(Sn(t)!==Sn(e))return!1;for(const n in t)if(!Cn(t,n)||!jn(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!jn(t[n],e[n]))return!1;break;default:return!1}return!0},Dn="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),On="undefined"!=typeof window&&"undefined"!=typeof document&&!Dn,In=("undefined"!=typeof navigator&&/Mac/.test(navigator.platform),[]),Tn=t=>(()=>{if(void 0===pn)if(Dn){pn=qt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];"-"===r[0]?(null!==e&&pn.set(e,""),e=r):null!==e?(pn.set(e,r),e=null):In.push(r)}null!==e&&pn.set(e,"")}else"object"==typeof location?(pn=qt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(0!==t.length){const[e,n]=t.split("=");pn.set(`--${pe(e,"-")}`,n),pn.set(`-${pe(e,"-")}`,n)}})):pn=qt();return pn})().has(t),Mn=t=>dn(Dn?process.env[t.toUpperCase().replaceAll("-","_")]:xn.getItem(t)),Nn=t=>Tn("--"+t)||null!==Mn(t),Rn=Nn("production"),zn=Dn&&(fn=process.env.FORCE_COLOR,gn=["true","1","2"],gn.includes(fn)),Pn=(zn||!Tn("--no-colors")&&!Nn("no-color")&&(!Dn||process.stdout.isTTY)&&(!Dn||Tn("--color")||null!==Mn("COLORTERM")||(Mn("TERM")||"").includes("color")),On?t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=he(t[n]);return btoa(e)}:t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64")),Bn=t=>(t=>{const e=ye();return t(e),be(e)})(e=>Te(e,t)),Ln=class{constructor(t,e){this.left=t,this.right=e}},Un=(t,e)=>new Ln(t,e),Fn=t=>t.next()>=.5,$n=(t,e,n)=>ne(t.next()*(n+1-e)+e),Hn=(t,e,n)=>ne(t.next()*(n+1-e)+e),Vn=(t,e,n)=>Hn(t,e,n),qn=t=>he(Vn(t,97,122)),Jn=(t,e)=>e[Vn(t,0,e.length-1)],Kn=Symbol("0schema"),Wn=class{constructor(){this._rerrs=[]}extend(t,e,n,r=null){this._rerrs.push({path:t,expected:e,has:n,message:r})}toString(){const t=[];for(let e=this._rerrs.length-1;e>0;e--){const n=this._rerrs[e];t.push(xe(" ",2*(this._rerrs.length-e))+`${null!=n.path?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return t.join("\n")}},Gn=(t,e)=>t===e||null!=t&&null!=e&&t.constructor===e.constructor&&(t[wn]?yn(t,e):te(t)?Zt(t,t=>Qt(e,e=>Gn(t,e))):"object"==typeof t&&kn(t,(t,n)=>Gn(t,e[n]))),Xn=class{static _dilutes=!1;extends(t){let[e,n]=[this.shape,t.shape];return this.constructor._dilutes&&([n,e]=[e,n]),Gn(e,n)}equals(t){return this.constructor===t.constructor&&jn(this.shape,t.shape)}[Kn](){return!0}[wn](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){Ue()}get nullable(){return _r(this,Fr)}get optional(){return new lr(this)}cast(t){return qr(t,this),t}expect(t){return qr(t,this),t}},Yn=class extends Xn{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e=void 0){const n=t?.constructor===this.shape&&(null==this._c||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}},Zn=(t,e=null)=>new Yn(t,e),Qn=(Zn(Yn),class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=this.shape(t);return!n&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),n}}),tr=t=>new Qn(t),er=(Zn(Qn),class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=this.shape.some(e=>e===t);return!n&&e?.extend(null,this.shape.join(" | "),t.toString()),n}}),nr=(...t)=>new er(t),rr=Zn(er),ir=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),sr=t=>zr.check(t)?[ir(t)]:rr.check(t)?t.shape.map(t=>t+""):Rr.check(t)?["[+-]?\\d+.?\\d*"]:Pr.check(t)?[".*"]:Ar.check(t)?t.shape.map(sr).flat(1):void Fe(),or=(Zn(class extends Xn{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(sr).map(t=>`(${t.join("|")})`).join("")+"$")}check(t,e){const n=null!=this._r.exec(t);return!n&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}),Symbol("optional")),lr=class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=void 0===t||this.shape.check(t);return!n&&e?.extend(null,"undefined (optional)","()"),n}get[or](){return!0}},cr=Zn(lr),ar=class extends Xn{check(t,e){return e?.extend(null,"never",typeof t),!1}},hr=(new ar,Zn(ar),class t extends Xn{constructor(t,e=!1){super(),this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new t(this.shape,!0)}check(t,e){return null==t?(e?.extend(null,"object","null"),!1):kn(this.shape,(n,r)=>{const i=this._isPartial&&!Cn(t,r)||n.check(t[r],e);return!i&&e?.extend(r.toString(),n.toString(),typeof t[r],"Object property does not match"),i})}}),dr=Zn(hr),ur=tr(t=>null!=t&&(t.constructor===Object||null==t.constructor)),pr=class extends Xn{constructor(t,e){super(),this.shape={keys:t,values:e}}check(t,e){return null!=t&&kn(t,(n,r)=>{const i=this.shape.keys.check(r,e);return!i&&e?.extend(r+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(n,e)})}},fr=(t,e)=>new pr(t,e),gr=Zn(pr),mr=class extends Xn{constructor(t){super(),this.shape=t}check(t,e){return null!=t&&kn(this.shape,(n,r)=>{const i=n.check(t[r],e);return!i&&e?.extend(r.toString(),"Tuple",typeof n),i})}},xr=(Zn(mr),class extends Xn{constructor(t){super(),this.shape=1===t.length?t[0]:new Er(t)}check(t,e){const n=te(t)&&Zt(t,t=>this.shape.check(t));return!n&&e?.extend(null,"Array",""),n}}),wr=(...t)=>new xr(t),yr=Zn(xr),br=tr(t=>te(t)),vr=class extends Xn{constructor(t,e){super(),this.shape=t,this._c=e}check(t,e){const n=t instanceof this.shape&&(null==this._c||this._c(t));return!n&&e?.extend(null,this.shape.name,t?.constructor.name),n}},Sr=(Zn(vr),((t,e=null)=>new vr(t,e))(Xn)),kr=Zn(class extends Xn{constructor(t){super(),this.len=t.length-1,this.args=((...t)=>new mr(t))(...t.slice(-1)),this.res=t[this.len]}check(t,e){const n=t.constructor===Function&&t.length<=this.len;return!n&&e?.extend(null,"function",typeof t),n}}),Cr=tr(t=>"function"==typeof t),Er=(Zn(class extends Xn{constructor(t){super(),this.shape=t}check(t,e){const n=Zt(this.shape,n=>n.check(t,e));return!n&&e?.extend(null,"Intersectinon",typeof t),n}},t=>t.shape.length>0),class extends Xn{static _dilutes=!0;constructor(t){super(),this.shape=t}check(t,e){const n=Qt(this.shape,n=>n.check(t,e));return e?.extend(null,"Union",typeof t),n}}),_r=(...t)=>t.findIndex(t=>Ar.check(t))>=0?_r(...t.map(t=>Vr(t)).map(t=>Ar.check(t)?t.shape:[t]).flat(1)):1===t.length?t[0]:new Er(t),Ar=Zn(Er),jr=()=>!0,Dr=tr(jr),Or=Zn(Qn,t=>t.shape===jr),Ir=tr(t=>"bigint"==typeof t),Tr=tr(t=>t===Ir),Mr=tr(t=>"symbol"==typeof t),Nr=(tr(t=>t===Mr),tr(t=>"number"==typeof t)),Rr=tr(t=>t===Nr),zr=tr(t=>"string"==typeof t),Pr=tr(t=>t===zr),Br=tr(t=>"boolean"==typeof t),Lr=tr(t=>t===Br),Ur=nr(void 0),Fr=(Zn(er,t=>1===t.shape.length&&void 0===t.shape[0]),nr(void 0),nr(null)),$r=Zn(er,t=>1===t.shape.length&&null===t.shape[0]),Hr=(Zn(Uint8Array),Zn(Yn,t=>t.shape===Uint8Array),_r(Nr,zr,Fr,Ur,Ir,Br,Mr)),Vr=((()=>{const t=wr(Dr),e=fr(zr,Dr),n=_r(Nr,zr,Fr,Br,t,e);t.shape=n,e.shape.values=n})(),t=>{if(Sr.check(t))return t;if(ur.check(t)){const e={};for(const n in t)e[n]=Vr(t[n]);return new hr(e)}return br.check(t)?_r(...t.map(Vr)):Hr.check(t)?nr(t):Cr.check(t)?Zn(t):void Fe()}),qr=Rn?()=>{}:(t,e)=>{const n=new Wn;if(!e.check(t,n))throw Le(`Expected value to be of type ${e.constructor.name}.\n${n.toString()}`)},Jr=(mn=Dr,new class{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Vr(t),h:e}),this}else(t){return this.if(Dr,t)}done(){return(t,e)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(t))return r.h(t,e)}throw Le("Unhandled pattern")}}}(mn)).if(Rr,(t,e)=>$n(e,ce,le)).if(Pr,(t,e)=>((t,e=0,n=20)=>{const r=Vn(t,e,n);let i="";for(let s=0;s<r;s++)i+=qn(t);return i})(e)).if(Lr,(t,e)=>Fn(e)).if(Tr,(t,e)=>BigInt($n(e,ce,le))).if(Ar,(t,e)=>Kr(e,Jn(e,t.shape))).if(dr,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(cr.check(i)){if(Fn(e))continue;i=i.shape}n[r]=Jr(i,e)}return n}).if(yr,(t,e)=>{const n=[],r=Hn(e,0,42);for(let i=0;i<r;i++)n.push(Kr(e,t.shape));return n}).if(rr,(t,e)=>Jn(e,t.shape)).if($r,(t,e)=>null).if(kr,(t,e)=>{const n=Kr(e,t.res);return()=>n}).if(Or,(t,e)=>Kr(e,Jn(e,[Nr,zr,Fr,Ur,Ir,Br,wr(Nr),fr(_r("a","b","c"),Nr)]))).if(gr,(t,e)=>{const n={},r=$n(e,0,3);for(let i=0;i<r;i++){n[Kr(e,t.shape.keys)]=Kr(e,t.shape.values)}return n}).done(),Kr=(t,e)=>Jr(Vr(e),t),Wr="undefined"!=typeof document?document:{},Gr=(tr(t=>t.nodeType===Zr),"undefined"!=typeof DOMParser&&new DOMParser,tr(t=>t.nodeType===Gr),tr(t=>t.nodeType===Xr),Wr.ELEMENT_NODE),Xr=Wr.TEXT_NODE,Yr=(Wr.CDATA_SECTION_NODE,Wr.COMMENT_NODE,Wr.DOCUMENT_NODE),Zr=(Wr.DOCUMENT_TYPE_NODE,Wr.DOCUMENT_FRAGMENT_NODE),Qr=(tr(t=>t.nodeType===Yr),t=>class{constructor(t){this._=t}destroy(){t(this._)}}),ti=Qr(clearTimeout),ei=(t,e)=>new ti(setTimeout(e,t)),ni=(Qr(clearInterval),Qr(t=>"undefined"!=typeof requestAnimationFrame&&cancelAnimationFrame(t)),Qr(t=>"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(t)),Symbol),ri=ni(),ii=ni(),si=ni(),oi=ni(),li=ni(),ci=ni(),ai=ni(),hi=ni(),di=ni(),ui=(an(),Un("font-weight","bold"),Un("font-weight","normal"),Un("color","blue"),Un("color","green"),Un("color","grey"),Un("color","red"),Un("color","purple"),Un("color","orange"),Un("color","black"),(...t)=>{t.unshift(hi),pi.forEach(e=>e.print(t))}),pi=Wt(),fi=t=>({[Symbol.iterator](){return this},next:t}),gi=(t,e)=>fi(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}}),mi=class{constructor(t,e){this.clock=t,this.len=e}},xi=class{constructor(){this.clients=new Map}},wi=(t,e,n)=>e.clients.forEach((e,r)=>{const i=t.doc.store.clients.get(r);if(null!=i){const r=i[i.length-1],s=r.id.clock+r.length;for(let o=0,l=e[o];o<e.length&&l.clock<s;l=e[++o])us(t,i,l.clock,l.len,n)}}),yi=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=ne((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;n=i+1}else r=i-1}return null})(n,e.clock)},bi=t=>{t.clients.forEach(t=>{let e,n;for(t.sort((t,e)=>t.clock-e.clock),e=1,n=1;e<t.length;e++){const r=t[n-1],i=t[e];r.clock+r.len>=i.clock?t[n-1]=new mi(r.clock,se(r.len,i.clock+i.len-r.clock)):(n<e&&(t[n]=i),n++)}t.length=n})},vi=t=>{const e=new xi;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let e=n+1;e<t.length;e++)Xt(s,t[e].clients.get(i)||[]);e.clients.set(i,s)}});return bi(e),e},Si=(t,e,n,r)=>{Kt(t.clients,e,()=>[]).push(new mi(n,r))},ki=()=>new xi,Ci=(t,e)=>{ke(t.restEncoder,e.clients.size),Yt(e.clients.entries()).sort((t,e)=>e[0]-t[0]).forEach(([e,n])=>{t.resetDsCurVal(),ke(t.restEncoder,e);const r=n.length;ke(t.restEncoder,r);for(let i=0;i<r;i++){const e=n[i];t.writeDsClock(e.clock),t.writeDsLen(e.len)}})},Ei=(t,e,n)=>{const r=new xi,i=We(t.restDecoder);for(let s=0;s<i;s++){t.resetDsCurVal();const i=We(t.restDecoder),s=We(t.restDecoder),o=n.clients.get(i)||[],l=ss(n,i);for(let n=0;n<s;n++){const n=t.readDsClock(),s=n+t.readDsLen();if(n<l){l<s&&Si(r,i,l,s-l);let t=ls(o,n),c=o[t];for(!c.deleted&&c.id.clock<n&&(o.splice(t+1,0,tl(e,c,n-c.id.clock)),t++);t<o.length&&(c=o[t++],c.id.clock<s);)c.deleted||(s<c.id.clock+c.length&&o.splice(t,0,tl(e,c,s-c.id.clock)),c.delete(e))}else Si(r,i,n,s-n)}}if(r.clients.size>0){const t=new Mi;return ke(t.restEncoder,0),Ci(t,r),t.toUint8Array()}return null},_i=ln,Ai=class t extends ee{constructor({guid:t=cn(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:s=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=_i(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new rs,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=hn(t=>{this.on("load",()=>{this.isLoaded=!0,t(this)})});const l=()=>hn(t=>{const e=n=>{void 0!==n&&!0!==n||(this.off("sync",e),t())};this.on("sync",e)});this.on("sync",t=>{!1===t&&this.isSynced&&(this.whenSynced=l()),this.isSynced=void 0===t||!0===t,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;null===t||this.shouldLoad||ws(t.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Yt(this.subdocs).map(t=>t.guid))}transact(t,e=null){return ws(this,t,e)}get(t,e=Us){const n=Kt(this.share,t,()=>{const t=new e;return t._integrate(this,null),t}),r=n.constructor;if(e!==Us&&r!==e){if(r===Us){const r=new e;r._map=n._map,n._map.forEach(t=>{for(;null!==t;t=t.left)t.parent=r}),r._start=n._start;for(let t=r._start;null!==t;t=t.right)t.parent=r;return r._length=n._length,this.share.set(t,r),r._integrate(this,null),r}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return n}getArray(t=""){return this.get(t,so)}getText(t=""){return this.get(t,Co)}getMap(t=""){return this.get(t,lo)}getXmlElement(t=""){return this.get(t,Ao)}getXmlFragment(t=""){return this.get(t,_o)}toJSON(){const t={};return this.share.forEach((e,n)=>{t[n]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,Yt(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(null!==e){this._item=null;const n=e.content;n.doc=new t({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ws(e.parent.doc,t=>{const r=n.doc;e.deleted||t.subdocsAdded.add(r),t.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},ji=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const t=We(this.restDecoder)+1;return this.dsCurrVal+=t,t}},Di=class extends ji{constructor(t){super(t),this.keys=[],We(t),this.keyClockDecoder=new nn(Je(t)),this.clientDecoder=new en(Je(t)),this.leftClockDecoder=new nn(Je(t)),this.rightClockDecoder=new nn(Je(t)),this.infoDecoder=new tn(Je(t),Ke),this.stringDecoder=new rn(Je(t)),this.parentInfoDecoder=new tn(Je(t),Ke),this.typeRefDecoder=new en(Je(t)),this.lenDecoder=new en(Je(t))}readLeftID(){return new $i(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new $i(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Qe(this.restDecoder)}readBuf(){return Je(this.restDecoder)}readJSON(){return Qe(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const t=this.stringDecoder.read();return this.keys.push(t),t}}},Oi=class{constructor(){this.restEncoder=ye()}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){ke(this.restEncoder,t)}writeDsLen(t){ke(this.restEncoder,t)}},Ii=class extends Oi{writeLeftID(t){ke(this.restEncoder,t.client),ke(this.restEncoder,t.clock)}writeRightID(t){ke(this.restEncoder,t.client),ke(this.restEncoder,t.clock)}writeClient(t){ke(this.restEncoder,t)}writeInfo(t){Se(this.restEncoder,t)}writeString(t){Ae(this.restEncoder,t)}writeParentInfo(t){ke(this.restEncoder,t?1:0)}writeTypeRef(t){ke(this.restEncoder,t)}writeLen(t){ke(this.restEncoder,t)}writeAny(t){Te(this.restEncoder,t)}writeBuf(t){De(this.restEncoder,t)}writeJSON(t){Ae(this.restEncoder,JSON.stringify(t))}writeKey(t){Ae(this.restEncoder,t)}},Ti=class{constructor(){this.restEncoder=ye(),this.dsCurrVal=0}toUint8Array(){return be(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,ke(this.restEncoder,e)}writeDsLen(t){0===t&&Fe(),ke(this.restEncoder,t-1),this.dsCurrVal+=t}},Mi=class extends Ti{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pe,this.clientEncoder=new Re,this.leftClockEncoder=new Pe,this.rightClockEncoder=new Pe,this.infoEncoder=new Me(Se),this.stringEncoder=new Be,this.parentInfoEncoder=new Me(Se),this.typeRefEncoder=new Re,this.lenEncoder=new Re}toUint8Array(){const t=ye();return ke(t,0),De(t,this.keyClockEncoder.toUint8Array()),De(t,this.clientEncoder.toUint8Array()),De(t,this.leftClockEncoder.toUint8Array()),De(t,this.rightClockEncoder.toUint8Array()),De(t,be(this.infoEncoder)),De(t,this.stringEncoder.toUint8Array()),De(t,be(this.parentInfoEncoder)),De(t,this.typeRefEncoder.toUint8Array()),De(t,this.lenEncoder.toUint8Array()),je(t,be(this.restEncoder)),be(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Te(this.restEncoder,t)}writeBuf(t){De(this.restEncoder,t)}writeJSON(t){Te(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);void 0===e?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}},Ni=(t,e,n)=>{const r=new Map;n.forEach((t,n)=>{ss(e,n)>t&&r.set(n,t)}),is(e).forEach((t,e)=>{n.has(e)||r.set(e,0)}),ke(t.restEncoder,r.size),Yt(r.entries()).sort((t,e)=>e[0]-t[0]).forEach(([n,r])=>{((t,e,n,r)=>{r=se(r,e[0].id.clock);const i=ls(e,r);ke(t.restEncoder,e.length-i),t.writeClient(n),ke(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(t,0)})(t,e.clients.get(n),n,r)})},Ri=(t,e,n,r=new Di(t))=>ws(e,t=>{t.local=!1;let e=!1;const n=t.doc,i=n.store,s=((t,e)=>{const n=qt(),r=We(t.restDecoder);for(let i=0;i<r;i++){const r=We(t.restDecoder),i=new Array(r),s=t.readClient();let o=We(t.restDecoder);n.set(s,{i:0,refs:i});for(let n=0;n<r;n++){const r=t.readInfo();switch(31&r){case 0:{const e=t.readLen();i[n]=new To(Vi(s,o),e),o+=e;break}case 10:{const e=We(t.restDecoder);i[n]=new ol(Vi(s,o),e),o+=e;break}default:{const l=!(192&r),c=new rl(Vi(s,o),null,128&~r?null:t.readLeftID(),null,64&~r?null:t.readRightID(),l?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,!l||32&~r?null:t.readString(),il(t,r));i[n]=c,o+=c.length}}}}return n})(r,n),o=((t,e,n)=>{const r=[];let i=Yt(n.keys()).sort((t,e)=>t-e);if(0===i.length)return null;const s=()=>{if(0===i.length)return null;let t=n.get(i[i.length-1]);for(;t.refs.length===t.i;){if(i.pop(),!(i.length>0))return null;t=n.get(i[i.length-1])}return t};let o=s();if(null===o)return null;const l=new rs,c=new Map,a=(t,e)=>{const n=c.get(t);(null==n||n>e)&&c.set(t,e)};let h=o.refs[o.i++];const d=new Map,u=()=>{for(const t of r){const e=t.id.client,r=n.get(e);r?(r.i--,l.clients.set(e,r.refs.slice(r.i)),n.delete(e),r.i=0,r.refs=[]):l.clients.set(e,[t]),i=i.filter(t=>t!==e)}r.length=0};for(;;){if(h.constructor!==ol){const i=Kt(d,h.id.client,()=>ss(e,h.id.client))-h.id.clock;if(i<0)r.push(h),a(h.id.client,h.id.clock-1),u();else{const s=h.getMissing(t,e);if(null!==s){r.push(h);const t=n.get(s)||{refs:[],i:0};if(t.refs.length!==t.i){h=t.refs[t.i++];continue}a(s,ss(e,s)),u()}else(0===i||i<h.length)&&(h.integrate(t,i),d.set(h.id.client,h.id.clock+h.length))}}if(r.length>0)h=r.pop();else if(null!==o&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=s(),null===o)break;h=o.refs[o.i++]}}if(l.clients.size>0){const t=new Mi;return Ni(t,l,new Map),ke(t.restEncoder,0),{missing:c,update:t.toUint8Array()}}return null})(t,i,s),l=i.pendingStructs;if(l){for(const[t,n]of l.missing)if(n<ss(i,t)){e=!0;break}if(o){for(const[t,e]of o.missing){const n=l.missing.get(t);(null==n||n>e)&&l.missing.set(t,e)}l.update=_s([l.update,o.update])}}else i.pendingStructs=o;const c=Ei(r,t,i);if(i.pendingDs){const e=new Di(qe(i.pendingDs));We(e.restDecoder);const n=Ei(e,t,i);i.pendingDs=c&&n?_s([c,n]):c||n}else i.pendingDs=c;if(e){const e=i.pendingStructs.update;i.pendingStructs=null,zi(t.doc,e)}},n,!1),zi=(t,e,n,r=Di)=>{const i=qe(e);Ri(i,t,n,new r(i))},Pi=class{constructor(){this.l=[]}},Bi=()=>new Pi,Li=(t,e)=>t.l.push(e),Ui=(t,e)=>{const n=t.l;n.length;t.l=n.filter(t=>e!==t),t.l.length},Fi=(t,e,n)=>An(t.l,[e,n]),$i=class{constructor(t,e){this.client=t,this.clock=e}},Hi=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,Vi=(t,e)=>new $i(t,e),qi=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Fe()},Ji=(t,e)=>{for(;null!==e;){if(e.parent===t)return!0;e=e.parent._item}return!1},Ki=class{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}},Wi=class{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}},Gi=(t,e,n)=>{let r=null,i=null;return null===t._item?i=qi(t):r=Vi(t._item.id.client,t._item.id.clock),new Ki(r,i,e,n)},Xi=(t,e,n=0)=>{let r=t._start;if(n<0){if(0===e)return Gi(t,null,n);e--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>e)return Gi(t,Vi(r.id.client,r.id.clock+e),n);e-=r.length}if(null===r.right&&n<0)return Gi(t,r.lastId,n);r=r.right}return Gi(t,null,n)},Yi=(t,e,n=!0)=>{const r=e.store,i=t.item,s=t.type,o=t.tname,l=t.assoc;let c=null,a=0;if(null!==i){if(ss(r,i.client)<=i.clock)return null;const t=n?Zo(r,i):((t,e)=>{const n=cs(t,e);return{item:n,diff:e.clock-n.id.clock}})(r,i),e=t.item;if(!(e instanceof rl))return null;if(c=e.parent,null===c._item||!c._item.deleted){a=e.deleted||!e.countable?0:t.diff+(l>=0?0:1);let n=e.left;for(;null!==n;)!n.deleted&&n.countable&&(a+=n.length),n=n.left}}else{if(null!==o)c=e.get(o);else{if(null===s)throw Fe();{if(ss(r,s.client)<=s.clock)return null;const{item:t}=n?Zo(r,s):{item:cs(r,s)};if(!(t instanceof rl&&t.content instanceof Yo))return null;c=t.content.type}}a=l>=0?c._length:0}return((t,e,n=0)=>new Wi(t,e,n))(c,a,t.assoc)},Zi=class{constructor(t,e){this.ds=t,this.sv=e}},Qi=(t,e)=>new Zi(t,e),ts=(Qi(ki(),new Map),t=>Qi((t=>{const e=ki();return t.clients.forEach((t,n)=>{const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.deleted){const i=n.id.clock;let s=n.length;if(e+1<t.length)for(let n=t[e+1];e+1<t.length&&n.deleted;n=t[1+ ++e])s+=n.length;r.push(new mi(i,s))}}r.length>0&&e.clients.set(n,r)}),e})(t.store),is(t.store))),es=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!yi(e.ds,t.id),ns=(t,e)=>{const n=Kt(t.meta,ns,Wt),r=t.doc.store;n.has(e)||(e.sv.forEach((e,n)=>{e<ss(r,n)&&hs(t,Vi(n,e))}),wi(t,e.ds,t=>{}),n.add(e))},rs=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},is=t=>{const e=new Map;return t.clients.forEach((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)}),e},ss=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},os=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw Fe()}n.push(e)},ls=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=ne(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;n=o+1}else r=o-1;o=ne((n+r)/2)}throw Fe()},cs=(t,e)=>{const n=t.clients.get(e.client);return n[ls(n,e.clock)]},as=(t,e,n)=>{const r=ls(e,n),i=e[r];return i.id.clock<n&&i instanceof rl?(e.splice(r+1,0,tl(t,i,n-i.id.clock)),r+1):r},hs=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[as(t,n,e.clock)]},ds=(t,e,n)=>{const r=e.clients.get(n.client),i=ls(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==To&&r.splice(i+1,0,tl(t,s,n.clock-s.id.clock+1)),s},us=(t,e,n,r,i)=>{if(0===r)return;const s=n+r;let o,l=as(t,e,n);do{o=e[l++],s<o.id.clock+o.length&&as(t,e,s),i(o)}while(l<e.length&&e[l].id.clock<s)},ps=class{constructor(t,e,n){this.doc=t,this.deleteSet=new xi,this.beforeState=is(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},fs=(t,e)=>!(0===e.deleteSet.clients.size&&!((t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1})(e.afterState,(t,n)=>e.beforeState.get(n)!==t))&&(bi(e.deleteSet),((t,e)=>{Ni(t,e.doc.store,e.beforeState)})(t,e),Ci(t,e.deleteSet),!0),gs=(t,e,n)=>{const r=e._item;(null===r||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Kt(t.changed,e,Wt).add(n)},ms=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=t[--i-1])n instanceof rl&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const s=e-i;return s&&t.splice(e+1-s,s),s},xs=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,s=n.deleteSet,o=n._mergeStructs;try{bi(s),n.afterState=is(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const t=[];n.changed.forEach((e,r)=>t.push(()=>{null!==r._item&&r._item.deleted||r._callObserver(n,e)})),t.push(()=>{n.changedParentTypes.forEach((e,r)=>{r._dEH.l.length>0&&(null===r._item||!r._item.deleted)&&((e=e.filter(t=>null===t.target._item||!t.target._item.deleted)).forEach(t=>{t.currentTarget=r,t._path=null}),e.sort((t,e)=>t.path.length-e.path.length),t.push(()=>{Fi(r._dEH,e,n)}))}),t.push(()=>r.emit("afterTransaction",[n,r])),t.push(()=>{n._needFormattingCleanup&&vo(n)})}),An(t,[])}finally{r.gc&&((t,e,n)=>{for(const[r,i]of t.clients.entries()){const t=e.clients.get(r);for(let r=i.length-1;r>=0;r--){const s=i[r],o=s.clock+s.len;for(let r=ls(t,s.clock),i=t[r];r<t.length&&i.id.clock<o;i=t[++r]){const i=t[r];if(s.clock+s.len<=i.id.clock)break;i instanceof rl&&i.deleted&&!i.keep&&n(i)&&i.gc(e,!1)}}}})(s,i,r.gcFilter),((t,e)=>{t.clients.forEach((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=ie(r.length-1,1+ls(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[t])t-=1+ms(r,t)}})})(s,i),n.afterState.forEach((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=i.clients.get(e),n=se(ls(t,r),1);for(let e=t.length-1;e>=n;)e-=1+ms(t,e)}});for(let t=o.length-1;t>=0;t--){const{client:e,clock:n}=o[t].id,r=i.clients.get(e),s=ls(r,n);s+1<r.length&&ms(r,s+1)>1||s>0&&ms(r,s)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(((...t)=>{pi.forEach(e=>e.print(t))})(hi,ri,"[yjs] ",ii,ci,"Changed the client-id because another client seems to be using it."),r.clientID=_i()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new Ii;fs(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new Mi;fs(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=n;(l.size>0||a.size>0||c.size>0)&&(l.forEach(t=>{t.clientID=r.clientID,null==t.collectionid&&(t.collectionid=r.collectionid),r.subdocs.add(t)}),a.forEach(t=>r.subdocs.delete(t)),r.emit("subdocs",[{loaded:c,added:l,removed:a},r,n]),a.forEach(t=>t.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):xs(t,e+1)}}},ws=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;null===t._transaction&&(s=!0,t._transaction=new ps(t,n,r),i.push(t._transaction),1===i.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const e=t._transaction===i[0];t._transaction=null,e&&xs(i,0)}}return o},ys=class{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}},bs=(t,e,n)=>{wi(t,n.deletions,n=>{n instanceof rl&&e.scope.some(e=>e===t.doc||Ji(e,n))&&Qo(n,!1)})},vs=(t,e,n)=>{let r=null;const i=t.doc,s=t.scope;ws(i,n=>{for(;e.length>0&&null===t.currStackItem;){const r=i.store,o=e.pop(),l=new Set,c=[];let a=!1;wi(n,o.insertions,t=>{if(t instanceof rl){if(null!==t.redone){let{item:e,diff:i}=Zo(r,t.id);i>0&&(e=hs(n,Vi(e.id.client,e.id.clock+i))),t=e}!t.deleted&&s.some(e=>e===n.doc||Ji(e,t))&&c.push(t)}}),wi(n,o.deletions,t=>{t instanceof rl&&s.some(e=>e===n.doc||Ji(e,t))&&!yi(o.insertions,t.id)&&l.add(t)}),l.forEach(e=>{a=null!==nl(n,e,l,o.insertions,t.ignoreRemoteMapChanges,t)||a});for(let e=c.length-1;e>=0;e--){const r=c[e];t.deleteFilter(r)&&(r.delete(n),a=!0)}t.currStackItem=a?o:null}n.changed.forEach((t,e)=>{t.has(null)&&e._searchMarker&&(e._searchMarker.length=0)}),r=n},t);const o=t.currStackItem;if(null!=o){const e=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:e,origin:t},t]),t.currStackItem=null}return o},Ss=class extends ee{constructor(t,{captureTimeout:e=500,captureTransaction:n=t=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:o=(te(t)?t[0].doc:t instanceof Ai?t:t.doc)}={}){super(),this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=e,this.afterTransactionHandler=t=>{if(!(this.captureTransaction(t)&&this.scope.some(e=>t.changedParentTypes.has(e)||e===this.doc)&&(this.trackedOrigins.has(t.origin)||t.origin&&this.trackedOrigins.has(t.origin.constructor))))return;const e=this.undoing,n=this.redoing,r=e?this.redoStack:this.undoStack;e?this.stopCapturing():n||this.clear(!1,!0);const i=new xi;t.afterState.forEach((e,n)=>{const r=t.beforeState.get(n)||0,s=e-r;s>0&&Si(i,n,r,s)});const s=an();let o=!1;if(this.lastChange>0&&s-this.lastChange<this.captureTimeout&&r.length>0&&!e&&!n){const e=r[r.length-1];e.deletions=vi([e.deletions,t.deleteSet]),e.insertions=vi([e.insertions,i])}else r.push(new ys(t.deleteSet,i)),o=!0;e||n||(this.lastChange=s),wi(t,t.deleteSet,e=>{e instanceof rl&&this.scope.some(n=>n===t.doc||Ji(n,e))&&Qo(e,!0)});const l=[{stackItem:r[r.length-1],origin:t.origin,type:e?"redo":"undo",changedParentTypes:t.changedParentTypes},this];o?this.emit("stack-item-added",l):this.emit("stack-item-updated",l)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const e=new Set(this.scope);(t=te(t)?t:[t]).forEach(t=>{e.has(t)||(e.add(t),(t instanceof Us?t.doc!==this.doc:t!==this.doc)&&ui("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(n=>{t&&(this.undoStack.forEach(t=>bs(n,this,t)),this.undoStack=[]),e&&(this.redoStack.forEach(t=>bs(n,this,t)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){let t;this.undoing=!0;try{t=vs(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){let t;this.redoing=!0;try{t=vs(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};var ks=class{constructor(t,e){this.gen=function*(t){const e=We(t.restDecoder);for(let n=0;n<e;n++){const e=We(t.restDecoder),n=t.readClient();let r=We(t.restDecoder);for(let i=0;i<e;i++){const e=t.readInfo();if(10===e){const e=We(t.restDecoder);yield new ol(Vi(n,r),e),r+=e}else if(31&e){const i=!(192&e),s=new rl(Vi(n,r),null,128&~e?null:t.readLeftID(),null,64&~e?null:t.readRightID(),i?t.readParentInfo()?t.readString():t.readLeftID():null,!i||32&~e?null:t.readString(),il(t,e));yield s,r+=s.length}else{const e=t.readLen();yield new To(Vi(n,r),e),r+=e}}}}(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===ol);return this.curr}},Cs=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Es=(t,e)=>{if(t.constructor===To){const{client:n,clock:r}=t.id;return new To(Vi(n,r+e),t.length-e)}if(t.constructor===ol){const{client:n,clock:r}=t.id;return new ol(Vi(n,r+e),t.length-e)}{const n=t,{client:r,clock:i}=n.id;return new rl(Vi(r,i+e),null,Vi(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},_s=(t,e=Di,n=Mi)=>{if(1===t.length)return t[0];const r=t.map(t=>new e(qe(t)));let i=r.map(t=>new ks(t,!0)),s=null;const o=new n,l=new Cs(o);for(;i=i.filter(t=>null!==t.curr),i.sort((t,e)=>{if(t.curr.id.client===e.curr.id.client){const n=t.curr.id.clock-e.curr.id.clock;return 0===n?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===ol?1:-1:n}return e.curr.id.client-t.curr.id.client}),0!==i.length;){const t=i[0],e=t.curr.id.client;if(null!==s){let n=t.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=s.struct.id.clock+s.struct.length&&n.id.client>=s.struct.id.client;)n=t.next(),r=!0;if(null===n||n.id.client!==e||r&&n.id.clock>s.struct.id.clock+s.struct.length)continue;if(e!==s.struct.id.client)js(l,s.struct,s.offset),s={struct:n,offset:0},t.next();else if(s.struct.id.clock+s.struct.length<n.id.clock)if(s.struct.constructor===ol)s.struct.length=n.id.clock+n.length-s.struct.id.clock;else{js(l,s.struct,s.offset);const t=n.id.clock-s.struct.id.clock-s.struct.length;s={struct:new ol(Vi(e,s.struct.id.clock+s.struct.length),t),offset:0}}else{const e=s.struct.id.clock+s.struct.length-n.id.clock;e>0&&(s.struct.constructor===ol?s.struct.length-=e:n=Es(n,e)),s.struct.mergeWith(n)||(js(l,s.struct,s.offset),s={struct:n,offset:0},t.next())}}else s={struct:t.curr,offset:0},t.next();for(let n=t.curr;null!==n&&n.id.client===e&&n.id.clock===s.struct.id.clock+s.struct.length&&n.constructor!==ol;n=t.next())js(l,s.struct,s.offset),s={struct:n,offset:0}}null!==s&&(js(l,s.struct,s.offset),s=null),Ds(l);const c=r.map(t=>(t=>{const e=new xi,n=We(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const n=We(t.restDecoder),r=We(t.restDecoder);if(r>0){const i=Kt(e.clients,n,()=>[]);for(let e=0;e<r;e++)i.push(new mi(t.readDsClock(),t.readDsLen()))}}return e})(t)),a=vi(c);return Ci(o,a),o.toUint8Array()},As=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:be(t.encoder.restEncoder)}),t.encoder.restEncoder=ye(),t.written=0)},js=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&As(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ke(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Ds=t=>{As(t);const e=t.encoder.restEncoder;ke(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ke(e,r.written),je(e,r.restEncoder)}},Os="You must not compute changes after the event-handler fired.",Is=class{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Ts(this.currentTarget,this.target))}deletes(t){return yi(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw Le(Os);const t=new Map,e=this.target;this.transaction.changed.get(e).forEach(n=>{if(null!==n){const r=e._map.get(n);let i,s;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;i="delete",s=Gt(t.content.getContent())}else null!==t&&this.deletes(t)?(i="update",s=Gt(t.content.getContent())):(i="add",s=void 0)}else{if(!this.deletes(r))return;i="delete",s=Gt(r.content.getContent())}t.set(n,{action:i,oldValue:s})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){if(0===this.transaction.doc._transactionCleanups.length)throw Le(Os);const e=this.target,n=Wt(),r=Wt(),i=[];if(t={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let t=null;const s=()=>{t&&i.push(t)};for(let i=e._start;null!==i;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&(null!==t&&void 0!==t.delete||(s(),t={delete:0}),t.delete+=i.length,r.add(i)):this.adds(i)?(null!==t&&void 0!==t.insert||(s(),t={insert:[]}),t.insert=t.insert.concat(i.content.getContent()),n.add(i)):(null!==t&&void 0!==t.retain||(s(),t={retain:0}),t.retain+=i.length);null!==t&&void 0===t.retain&&s()}this._changes=t}return t}},Ts=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)!r.deleted&&r.countable&&(t+=r.length),r=r.right;n.unshift(t)}e=e._item.parent}return n},Ms=()=>{ui("Invalid access: Add Yjs type to a document before reading data.")},Ns=0,Rs=class{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Ns++}},zs=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ns++},Ps=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce((t,n)=>re(e-t.index)<re(e-n.index)?t:n);let r=t._start,i=0;for(null!==n&&(r=n.p,i=n.index,(t=>{t.timestamp=Ns++})(n));null!==r.right&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;null!==r.left&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return null!==n&&re(n.index-i)<r.parent.length/80?(zs(n,r,i),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce((t,e)=>t.timestamp<e.timestamp?t:e);return zs(r,e,n),r}{const r=new Rs(e,n);return t.push(r),r}})(t._searchMarker,r,i)},Bs=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let e=i.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(i.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}i.p=e,e.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=se(e,i.index+n))}},Ls=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Kt(i,t,()=>[]).push(n),null!==t._item;)t=t._item.parent;Fi(r._eH,n,e)},Us=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Bi(),this._dEH=Bi(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw Ue()}clone(){throw Ue()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Li(this._eH,t)}observeDeep(t){Li(this._dEH,t)}unobserve(t){Ui(this._eH,t)}unobserveDeep(t){Ui(this._dEH,t)}toJSON(){}},Fs=(t,e,n)=>{t.doc??Ms(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;null!==s&&r>0;){if(s.countable&&!s.deleted){const t=s.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)i.push(t[n]),r--;e=0}}s=s.right}return i},$s=t=>{t.doc??Ms();const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},Hs=(t,e)=>{const n=[];let r=t._start;for(;null!==r;){if(r.countable&&es(r,e)){const t=r.content.getContent();for(let e=0;e<t.length;e++)n.push(t[e])}r=r.right}return n},Vs=(t,e)=>{let n=0,r=t._start;for(t.doc??Ms();null!==r;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let r=0;r<i.length;r++)e(i[r],n++,t)}r=r.right}},qs=(t,e)=>{const n=[];return Vs(t,(r,i)=>{n.push(e(r,i,t))}),n},Js=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},Ks=(t,e)=>{t.doc??Ms();const n=Ps(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Ws=(t,e,n,r)=>{let i=n;const s=t.doc,o=s.clientID,l=s.store,c=null===n?e._start:n.right;let a=[];const h=()=>{a.length>0&&(i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Fo(a)),i.integrate(t,0),a=[])};r.forEach(n=>{if(null===n)a.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(n);break;default:switch(h(),n.constructor){case Uint8Array:case ArrayBuffer:i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Mo(new Uint8Array(n))),i.integrate(t,0);break;case Ai:i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new zo(n)),i.integrate(t,0);break;default:if(!(n instanceof Us))throw new Error("Unexpected content type in insert operation");i=new rl(Vi(o,ss(l,o)),i,i&&i.lastId,c,c&&c.id,e,null,new Yo(n)),i.integrate(t,0)}}}),h()},Gs=()=>Le("Length exceeded!"),Xs=(t,e,n,r)=>{if(n>e._length)throw Gs();if(0===n)return e._searchMarker&&Bs(e._searchMarker,n,r.length),Ws(t,e,null,r);const i=n,s=Ps(e,n);let o=e._start;for(null!==s&&(o=s.p,0===(n-=s.index)&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));null!==o;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&hs(t,Vi(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Bs(e._searchMarker,i,r.length),Ws(t,e,o,r)},Ys=(t,e,n,r)=>{if(0===r)return;const i=n,s=r,o=Ps(e,n);let l=e._start;for(null!==o&&(l=o.p,n-=o.index);null!==l&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&hs(t,Vi(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&null!==l;)l.deleted||(r<l.length&&hs(t,Vi(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Gs();e._searchMarker&&Bs(e._searchMarker,i,-s+r)},Zs=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},Qs=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(null==r)l=new Fo([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Fo([r]);break;case Uint8Array:l=new Mo(r);break;case Ai:l=new zo(r);break;default:if(!(r instanceof Us))throw new Error("Unexpected content type");l=new Yo(r)}new rl(Vi(o,ss(s.store,o)),i,i&&i.lastId,null,null,e,n,l).integrate(t,0)},to=(t,e)=>{t.doc??Ms();const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},eo=t=>{const e={};return t.doc??Ms(),t._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},no=(t,e)=>{t.doc??Ms();const n=t._map.get(e);return void 0!==n&&!n.deleted},ro=t=>{return t.doc??Ms(),e=t._map.entries(),n=t=>!t[1].deleted,fi(()=>{let t;do{t=e.next()}while(!t.done&&!n(t.value));return t});var e,n},io=class extends Is{},so=class t extends Us{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new t;return n.push(e),n}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}get length(){return this.doc??Ms(),this._length}_callObserver(t,e){super._callObserver(t,e),Ls(this,t,new io(this,t))}insert(t,e){null!==this.doc?ws(this.doc,n=>{Xs(n,this,t,e)}):this._prelimContent.splice(t,0,...e)}push(t){null!==this.doc?ws(this.doc,e=>{((t,e,n)=>{let r=(e._searchMarker||[]).reduce((t,e)=>e.index>t.index?e:t,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;Ws(t,e,r,n)})(e,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?ws(this.doc,n=>{Ys(n,this,t,e)}):this._prelimContent.splice(t,e)}get(t){return Ks(this,t)}toArray(){return $s(this)}slice(t=0,e=this.length){return Fs(this,t,e)}toJSON(){return this.map(t=>t instanceof Us?t.toJSON():t)}map(t){return qs(this,t)}forEach(t){Vs(this,t)}[Symbol.iterator](){return Js(this)}_write(t){t.writeTypeRef(Vo)}},oo=class extends Is{constructor(t,e,n){super(t,e),this.keysChanged=n}},lo=class t extends Us{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((t,e)=>{this.set(e,t)}),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return this.forEach((t,n)=>{e.set(n,t instanceof Us?t.clone():t)}),e}_callObserver(t,e){Ls(this,t,new oo(this,t,e))}toJSON(){this.doc??Ms();const t={};return this._map.forEach((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof Us?r.toJSON():r}}),t}get size(){return[...ro(this)].length}keys(){return gi(ro(this),t=>t[0])}values(){return gi(ro(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return gi(ro(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??Ms(),this._map.forEach((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._prelimContent.set(t,e),e}get(t){return to(this,t)}has(t){return no(this,t)}clear(){null!==this.doc?ws(this.doc,t=>{this.forEach(function(e,n,r){Zs(t,r,n)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(qo)}},co=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&((t,e)=>t===e||Sn(t)===Sn(e)&&kn(t,(t,n)=>(void 0!==t||Cn(e,n))&&yn(e[n],t)))(t,e),ao=class{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&Fe(),this.right.content.constructor===Bo)this.right.deleted||fo(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}},ho=(t,e,n)=>{for(;null!==e.right&&n>0;){if(e.right.content.constructor===Bo)e.right.deleted||fo(e.currentAttributes,e.right.content);else e.right.deleted||(n<e.right.length&&hs(t,Vi(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);e.left=e.right,e.right=e.right.right}return e},uo=(t,e,n,r)=>{const i=new Map,s=r?Ps(e,n):null;if(s){const e=new ao(s.p.left,s.p,s.index,i);return ho(t,e,n-s.index)}{const r=new ao(null,e._start,0,i);return ho(t,r,n)}},po=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===Bo&&co(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((r,o)=>{const l=n.left,c=n.right,a=new rl(Vi(s,ss(i.store,s)),l,l&&l.lastId,c,c&&c.id,e,null,new Bo(o,r));a.integrate(t,0),n.right=a,n.forward()})},fo=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},go=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===Bo&&co(e[t.right.content.key]??null,t.right.content.value));)t.forward()},mo=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const l in r){const c=r[l],a=n.currentAttributes.get(l)??null;if(!co(a,c)){o.set(l,a);const{left:r,right:h}=n;n.right=new rl(Vi(s,ss(i.store,s)),r,r&&r.lastId,h,h&&h.id,e,null,new Bo(l,c)),n.right.integrate(t,0),n.forward()}}return o},xo=(t,e,n,r,i)=>{n.currentAttributes.forEach((t,e)=>{void 0===i[e]&&(i[e]=null)});const s=t.doc,o=s.clientID;go(n,i);const l=mo(t,e,n,i),c=r.constructor===String?new $o(r):r instanceof Us?new Yo(r):new Po(r);let{left:a,right:h,index:d}=n;e._searchMarker&&Bs(e._searchMarker,n.index,c.getLength()),h=new rl(Vi(o,ss(s.store,o)),a,a&&a.lastId,h,h&&h.id,e,null,c),h.integrate(t,0),n.right=h,n.index=d,n.forward(),po(t,e,n,l)},wo=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;go(n,i);const l=mo(t,e,n,i);t:for(;null!==n.right&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Bo));){if(!n.right.deleted)switch(n.right.content.constructor){case Bo:{const{key:e,value:s}=n.right.content,o=i[e];if(void 0!==o){if(co(o,s))l.delete(e);else{if(0===r)break t;l.set(e,s)}n.right.delete(t)}else n.currentAttributes.set(e,s);break}default:r<n.right.length&&hs(t,Vi(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i="";for(;r>0;r--)i+="\n";n.right=new rl(Vi(o,ss(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new $o(i)),n.right.integrate(t,0),n.forward()}po(t,e,n,l)},yo=(t,e,n,r,i)=>{let s=e;const o=qt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Bo){const t=s.content;o.set(t.key,t)}s=s.right}let l=0,c=!1;for(;e!==s;){if(n===e&&(c=!0),!e.deleted){const n=e.content;switch(n.constructor){case Bo:{const{key:s,value:a}=n,h=r.get(s)??null;o.get(s)===n&&h!==a||(e.delete(t),l++,c||(i.get(s)??null)!==a||h===a||(null===h?i.delete(s):i.set(s,h))),c||e.deleted||fo(i,n);break}}}e=e.right}return l},bo=t=>{let e=0;return ws(t.doc,n=>{let r=t._start,i=t._start,s=qt();const o=Jt(s);for(;i;){if(!1===i.deleted)if(i.content.constructor===Bo)fo(o,i.content);else e+=yo(n,r,i,s,o),s=Jt(o),r=i;i=i.right}}),e},vo=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const s=t.beforeState.get(r)||0;i!==s&&us(t,n.store.clients.get(r),s,i,t=>{t.deleted||t.content.constructor!==Bo||t.constructor===To||e.add(t.parent)})}ws(n,n=>{wi(t,t.deleteSet,t=>{if(t instanceof To||!t.parent._hasFormatting||e.has(t.parent))return;const r=t.parent;t.content.constructor===Bo?e.add(r):((t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Bo){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(n,t)});for(const t of e)bo(t)})},So=(t,e,n)=>{const r=n,i=Jt(e.currentAttributes),s=e.right;for(;n>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case Yo:case Po:case $o:n<e.right.length&&hs(t,Vi(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t)}e.forward()}s&&yo(t,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Bs(o._searchMarker,e.index,-r+n),e},ko=class extends Is{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)})}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];ws(t,t=>{const n=new Map,r=new Map;let i=this.target._start,s=null;const o={};let l="",c=0,a=0;const h=()=>{if(null!==s){let t=null;switch(s){case"delete":a>0&&(t={delete:a}),a=0;break;case"insert":("object"==typeof l||l.length>0)&&(t={insert:l},n.size>0&&(t.attributes={},n.forEach((e,n)=>{null!==e&&(t.attributes[n]=e)}))),l="";break;case"retain":c>0&&(t={retain:c},(t=>{for(const e in t)return!1;return!0})(o)||(t.attributes=bn({},o))),c=0}t&&e.push(t),s=null}};for(;null!==i;){switch(i.content.constructor){case Yo:case Po:this.adds(i)?this.deletes(i)||(h(),s="insert",l=i.content.getContent()[0],h()):this.deletes(i)?("delete"!==s&&(h(),s="delete"),a+=1):i.deleted||("retain"!==s&&(h(),s="retain"),c+=1);break;case $o:this.adds(i)?this.deletes(i)||("insert"!==s&&(h(),s="insert"),l+=i.content.str):this.deletes(i)?("delete"!==s&&(h(),s="delete"),a+=i.length):i.deleted||("retain"!==s&&(h(),s="retain"),c+=i.length);break;case Bo:{const{key:e,value:l}=i.content;if(this.adds(i)){if(!this.deletes(i)){const c=n.get(e)??null;co(c,l)?null!==l&&i.delete(t):("retain"===s&&h(),co(l,r.get(e)??null)?delete o[e]:o[e]=l)}}else if(this.deletes(i)){r.set(e,l);const t=n.get(e)??null;co(t,l)||("retain"===s&&h(),o[e]=t)}else if(!i.deleted){r.set(e,l);const n=o[e];void 0!==n&&(co(n,l)?null!==n&&i.delete(t):("retain"===s&&h(),null===l?delete o[e]:o[e]=l))}i.deleted||("insert"===s&&h(),fo(n,i.content));break}}i=i.right}for(h();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}}),this._delta=e}return this._delta}},Co=class t extends Us{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ms(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach(t=>t())}catch(Xa){}this._pending=null}_copy(){return new t}clone(){const e=new t;return e.applyDelta(this.toDelta()),e}_callObserver(t,e){super._callObserver(t,e);const n=new ko(this,t,e);Ls(this,t,n),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??Ms();let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===$o&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?ws(this.doc,n=>{const r=new ao(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const s=t[i];if(void 0!==s.insert){const o=e||"string"!=typeof s.insert||i!==t.length-1||null!==r.right||"\n"!==s.insert.slice(-1)?s.insert:s.insert.slice(0,-1);("string"!=typeof o||o.length>0)&&xo(n,this,r,o,s.attributes||{})}else void 0!==s.retain?wo(n,this,r,s.retain,s.attributes||{}):void 0!==s.delete&&So(n,r,s.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,n){this.doc??Ms();const r=[],i=new Map,s=this.doc;let o="",l=this._start;function c(){if(o.length>0){const t={};let e=!1;i.forEach((n,r)=>{e=!0,t[r]=n});const n={insert:o};e&&(n.attributes=t),r.push(n),o=""}}const a=()=>{for(;null!==l;){if(es(l,t)||void 0!==e&&es(l,e))switch(l.content.constructor){case $o:{const r=i.get("ychange");void 0===t||es(l,t)?void 0===e||es(l,e)?void 0!==r&&(c(),i.delete("ychange")):void 0!==r&&r.user===l.id.client&&"added"===r.type||(c(),i.set("ychange",n?n("added",l.id):{type:"added"})):void 0!==r&&r.user===l.id.client&&"removed"===r.type||(c(),i.set("ychange",n?n("removed",l.id):{type:"removed"})),o+=l.content.str;break}case Yo:case Po:{c();const t={insert:l.content.getContent()[0]};if(i.size>0){const e={};t.attributes=e,i.forEach((t,n)=>{e[n]=t})}r.push(t);break}case Bo:es(l,t)&&(c(),fo(i,l.content))}l=l.right}c()};return t||e?ws(s,n=>{t&&ns(n,t),e&&ns(n,e),a()},"cleanup"):a(),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!n);n||(n={},i.currentAttributes.forEach((t,e)=>{n[e]=t})),xo(r,this,i,e,n)}):this._pending.push(()=>this.insert(t,e,n))}insertEmbed(t,e,n){const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!n);xo(r,this,i,e,n||{})}):this._pending.push(()=>this.insertEmbed(t,e,n||{}))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?ws(n,n=>{So(n,uo(n,this,t,!0),e)}):this._pending.push(()=>this.delete(t,e))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?ws(r,r=>{const i=uo(r,this,t,!1);null!==i.right&&wo(r,this,i,e,n)}):this._pending.push(()=>this.format(t,e,n))}removeAttribute(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return to(this,t)}getAttributes(){return eo(this)}_write(t){t.writeTypeRef(Jo)}},Eo=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??Ms()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==Ao&&e.constructor!==_o||null===e._start)for(;null!==t;){const e=t.next;if(null!==e){t=e;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},_o=class t extends Us{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){const e=new t;return e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}get length(){return this.doc??Ms(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new Eo(this,t)}querySelector(t){t=t.toUpperCase();const e=new Eo(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Yt(new Eo(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){Ls(this,t,new jo(this,e,t))}toString(){return qs(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Vs(this,i=>{r.insertBefore(i.toDOM(t,e,n),null)}),r}insert(t,e){null!==this.doc?ws(this.doc,n=>{Xs(n,this,t,e)}):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)ws(this.doc,n=>{const r=t&&t instanceof Us?t._item:t;Ws(n,this,r,e)});else{const n=this._prelimContent,r=null===t?0:n.findIndex(e=>e===t)+1;if(0===r&&null!==t)throw Le("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?ws(this.doc,n=>{Ys(n,this,t,e)}):this._prelimContent.splice(t,e)}toArray(){return $s(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Ks(this,t)}slice(t=0,e=this.length){return Fs(this,t,e)}forEach(t){Vs(this,t)}_write(t){t.writeTypeRef(Wo)}},Ao=class t extends _o{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((t,e)=>{this.setAttribute(e,t)}),this._prelimAttrs=null}_copy(){return new t(this.nodeName)}clone(){const e=new t(this.nodeName);return((t,e)=>{for(const n in t)e(t[n],n)})(this.getAttributes(),(t,n)=>{e.setAttribute(n,t)}),e.insert(0,this.toArray().map(t=>t instanceof Us?t.clone():t)),e}toString(){const t=this.getAttributes(),e=[],n=[];for(const s in t)n.push(s);n.sort();const r=n.length;for(let s=0;s<r;s++){const r=n[s];e.push(r+'="'+t[r]+'"')}const i=this.nodeName.toLocaleLowerCase();return`<${i}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${i}>`}removeAttribute(t){null!==this.doc?ws(this.doc,e=>{Zs(e,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?ws(this.doc,n=>{Qs(n,this,t,e)}):this._prelimAttrs.set(t,e)}getAttribute(t){return to(this,t)}hasAttribute(t){return no(this,t)}getAttributes(t){return t?((t,e)=>{const n={};return t._map.forEach((t,r)=>{let i=t;for(;null!==i&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;null!==i&&es(i,e)&&(n[r]=i.content.getContent()[i.length-1])}),n})(this,t):eo(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const s in i){const t=i[s];"string"==typeof t&&r.setAttribute(s,t)}return Vs(this,i=>{r.appendChild(i.toDOM(t,e,n))}),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(Ko),t.writeKey(this.nodeName)}},jo=class extends Is{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)})}},Do=class t extends lo{constructor(t){super(),this.hookName=t}_copy(){return new t(this.hookName)}clone(){const e=new t(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(t=document,e={},n){const r=e[this.hookName];let i;return i=void 0!==r?r.createDom(this):document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(i,this),i}_write(t){t.writeTypeRef(Go),t.writeKey(this.hookName)}},Oo=class t extends Co{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new t}clone(){const e=new t;return e.applyDelta(this.toDelta()),e}toDOM(t=document,e,n){const r=t.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const e=[];for(const r in t.attributes){const n=[];for(const e in t.attributes[r])n.push({key:e,value:t.attributes[r][e]});n.sort((t,e)=>t.key<e.key?-1:1),e.push({nodeName:r,attrs:n})}e.sort((t,e)=>t.nodeName<e.nodeName?-1:1);let n="";for(let r=0;r<e.length;r++){const t=e[r];n+=`<${t.nodeName}`;for(let e=0;e<t.attrs.length;e++){const r=t.attrs[e];n+=` ${r.key}="${r.value}"`}n+=">"}n+=t.insert;for(let r=e.length-1;r>=0;r--)n+=`</${e[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Xo)}},Io=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw Ue()}mergeWith(t){return!1}write(t,e,n){throw Ue()}integrate(t,e){throw Ue()}},To=class extends Io{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),os(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}},Mo=class t{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new t(this.content)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}},No=class t{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.len)}splice(e){const n=new t(this.len-e);return this.len=e,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){Si(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}},Ro=(t,e)=>new Ai({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),zo=class t{constructor(t){t._item,this.doc=t;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new t(Ro(this.doc.guid,this.opts))}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},Po=class t{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new t(this.embed)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}},Bo=class t{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.key,this.value)}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){const n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},Lo=class t{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){const n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeString(void 0===e?"undefined":JSON.stringify(e))}}getRef(){return 2}},Uo="development"===Mn("node_env"),Fo=class t{constructor(t){this.arr=t,Uo&&_n(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){const n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}},$o=class t{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new t(this.str)}splice(e){const n=new t(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}},Ho=[t=>new so,t=>new lo,t=>new Co,t=>new Ao(t.readKey()),t=>new _o,t=>new Do(t.readKey()),t=>new Oo],Vo=0,qo=1,Jo=2,Ko=3,Wo=4,Go=5,Xo=6,Yo=class t{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new t(this.type._copy())}splice(t){throw Ue()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach(e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach(e=>{for(;null!==e;)e.gc(t,!0),e=e.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}},Zo=(t,e)=>{let n,r=e,i=0;do{i>0&&(r=Vi(r.client,r.clock+i)),n=cs(t,r),i=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof rl);return{item:n,diff:i}},Qo=(t,e)=>{for(;null!==t&&t.keep!==e;)t.keep=e,t=t.parent._item},tl=(t,e,n)=>{const{client:r,clock:i}=e.id,s=new rl(Vi(r,i+n),e,Vi(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),null!==e.redone&&(s.redone=Vi(e.redone.client,e.redone.clock+n)),e.right=s,null!==s.right&&(s.right.left=s),t._mergeStructs.push(s),null!==s.parentSub&&null===s.right&&s.parent._map.set(s.parentSub,s),e.length=n,s},el=(t,e)=>Qt(t,t=>yi(t.deletions,e)),nl=(t,e,n,r,i,s)=>{const o=t.doc,l=o.store,c=o.clientID,a=e.redone;if(null!==a)return hs(t,a);let h,d=e.parent._item,u=null;if(null!==d&&!0===d.deleted){if(null===d.redone&&(!n.has(d)||null===nl(t,d,n,r,i,s)))return null;for(;null!==d.redone;)d=hs(t,d.redone)}const p=null===d?e.parent:d.content.type;if(null===e.parentSub){for(u=e.left,h=e;null!==u;){let e=u;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:hs(t,e.redone);if(null!==e&&e.parent._item===d){u=e;break}u=u.left}for(;null!==h;){let e=h;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:hs(t,e.redone);if(null!==e&&e.parent._item===d){h=e;break}h=h.right}}else{if(h=null,e.right&&!i){for(u=e;null!==u&&null!==u.right&&(u.right.redone||yi(r,u.right.id)||el(s.undoStack,u.right.id)||el(s.redoStack,u.right.id));)for(u=u.right;u.redone;)u=hs(t,u.redone);if(u&&null!==u.right)return null}else u=p._map.get(e.parentSub)||null;null!==u&&u.parent._item!==d&&(u=p._map.get(e.parentSub)||null)}const f=ss(l,c),g=Vi(c,f),m=new rl(g,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=g,Qo(m,!0),m.integrate(t,0),m},rl=class t extends Io{constructor(t,e,n,r,i,s,o,l){super(t,l.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=i,this.parent=s,this.parentSub=o,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(8&this.info)>0!==t&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ss(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ss(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$i&&this.id.client!==this.parent.client&&this.parent.clock>=ss(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ds(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=hs(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===To||this.right&&this.right.constructor===To)this.parent=null;else if(this.parent){if(this.parent.constructor===$i){const t=cs(n,this.parent);t.constructor===To?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===t?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===t&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=ds(t,t.doc.store,Vi(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,i=new Set;for(;null!==e&&e!==this.right;){if(i.add(e),r.add(e),Hi(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(Hi(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!i.has(cs(t.doc.store,e.origin)))break;r.has(cs(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),os(t.doc.store,this),this.content.integrate(t,this),gs(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new To(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:Vi(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Hi(t.origin,this.lastId)&&this.right===t&&Hi(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach(e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),Si(t.deleteSet,this.id.client,this.id.clock,this.length),gs(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw Fe();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[ls(r,e.id.clock)]=n})(t,this,new To(this.id,this.length)):this.content=new No(this.length)}write(t,e){const n=e>0?Vi(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,i=this.parentSub,s=31&this.content.getRef()|(null===n?0:128)|(null===r?0:64)|(null===i?0:32);if(t.writeInfo(s),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=qi(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===$i?(t.writeParentInfo(!1),t.writeLeftID(e)):Fe();null!==i&&t.writeString(i)}this.content.write(t,e)}},il=(t,e)=>sl[31&e](t),sl=[()=>{Fe()},t=>new No(t.readLen()),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const e=t.readString();"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return new Lo(n)},t=>new Mo(t.readBuf()),t=>new $o(t.readString()),t=>new Po(t.readJSON()),t=>new Bo(t.readKey(),t.readJSON()),t=>new Yo(Ho[t.readTypeRef()](t)),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Fo(n)},t=>new zo(Ro(t.readString(),t.readAny())),()=>{Fe()}],ol=class extends Io{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){Fe()}write(t,e){t.writeInfo(10),ke(t.restEncoder,this.length-e)}getMissing(t,e){return null}},ll="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},cl="__ $YJS$ __";function al(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let t=i.text,e=s.text,r=0;for(;t[r]==e[r];r++)n++;return r&&r<t.length&&r<e.length&&ul(t.charCodeAt(r-1))&&dl(t.charCodeAt(r))&&n--,n}if(i.content.size||s.content.size){let t=al(i.content,s.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function hl(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),c=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let t=o.text,e=l.text,i=t.length,s=e.length;for(;i>0&&s>0&&t[i-1]==e[s-1];)i--,s--,n--,r--;return i&&s&&i<t.length&&ul(t.charCodeAt(i-1))&&dl(t.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let t=hl(o.content,l.content,n-1,r-1);if(t)return t}n-=c,r-=c}else n-=c,r-=c}}function dl(t){return t>=56320&&t<57344}function ul(t){return t>=55296&&t<56320}ll[cl],ll[cl]=!0;var pl=class t{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let n=0;n<t.length;n++)this.size+=t[n].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],c=o+l.nodeSize;if(c>t&&!1!==n(l,r+o,i||null,s)&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),n,r+i)}o=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,(o,l)=>{let c=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(s?s=!1:i+=n),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new t(i,this.size+e.size)}cut(e,n=this.size){if(0==e&&n==this.size)return this;let r=[],i=0;if(n>e)for(let t=0,s=0;s<n;t++){let o=this.content[t],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new t(r,i)}cutByIndex(e,n){return e==n?t.empty:0==e&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new t(i,s)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return al(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return hl(this,t,e,n)}findIndex(t){if(0==t)return gl(0,t);if(t==this.size)return gl(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=n+this.child(e).nodeSize;if(r>=t)return r==t?gl(e+1,r):gl(e,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let t=0;t<e.length;t++){let i=e[t];r+=i.nodeSize,t&&i.isText&&e[t-1].sameMarkup(i)?(n||(n=e.slice(0,t)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};pl.empty=new pl([],0);var fl={index:0,offset:0};function gl(t,e){return fl.index=t,fl.offset=e,fl}function ml(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!ml(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!ml(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}var xl=class t{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&ml(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((t,e)=>t.type.rank-e.type.rank),n}};xl.none=[];var wl=class extends Error{},yl=class t{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=vl(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(bl(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,i=n.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new t(pl.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let t=e.firstChild;t&&!t.isLeaf&&(n||!t.type.spec.isolating);t=t.firstChild)r++;for(let t=e.lastChild;t&&!t.isLeaf&&(n||!t.type.spec.isolating);t=t.lastChild)i++;return new t(e,r,i)}};function bl(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(bl(s.content,e-i-1,n-i-1)))}function vl(t,e,n,r,i,s){let{index:o,offset:l}=t.findIndex(e),c=t.maybeChild(o);if(l==e||c.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=vl(c.content,e-l-1,n,0==o?r-1:0,o==t.childCount-1?i-1:0,c);return a&&t.replaceChild(o,c.copy(a))}yl.empty=new yl(pl.empty,0,0);Object.create(null);var Sl=class t{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new kl(e,n);if(null==r.next)return t.empty;let i=Cl(r);r.next&&r.err("Unexpected trailing text");let s=Il(function(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach(t=>t.to=e)}function s(t,e){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(s(n,e)),[]);if("seq"!=t.type){if("star"==t.type){let o=n();return r(e,o),i(s(t.expr,o),o),[r(o)]}if("plus"==t.type){let o=n();return i(s(t.expr,e),o),i(s(t.expr,o),o),[r(o)]}if("opt"==t.type)return[r(e)].concat(s(t.expr,e));if("range"==t.type){let o=e;for(let e=0;e<t.min;e++){let e=n();i(s(t.expr,o),e),o=e}if(-1==t.max)i(s(t.expr,o),o);else for(let e=t.min;e<t.max;e++){let e=n();r(o,e),i(s(t.expr,o),e),o=e}return[r(o)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=s(t.exprs[r],e);if(r==t.exprs.length-1)return o;i(o,e=n())}}}(i));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,r),s}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let l=s.matchFragment(t,n);if(l&&(!e||l.validEnd))return pl.from(o.map(t=>t.createAndFill()));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==t)return this.wrapCache[n+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r}).join("\n")}};Sl.empty=new Sl(!0);var kl=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function Cl(t){let e=[];do{e.push(El(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function El(t){let e=[];do{e.push(_l(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function _l(t){let e=function(t){if(t.eat("(")){let e=Cl(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let t=n[s];t.isInGroup(e)&&i.push(t)}0==i.length&&t.err("No node type or group '"+e+"' found");return i}(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=jl(t,e)}return e}function Al(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function jl(t,e){let n=Al(t),r=n;return t.eat(",")&&(r="}"!=t.next?Al(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Dl(t,e){return e-t}function Ol(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort(Dl)}function Il(t){let e=Object.create(null);return function n(r){let i=[];r.forEach(e=>{t[e].forEach(({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);Ol(t,n).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})})});let s=e[r.join(",")]=new Sl(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(Dl);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}(Ol(t,0))}var Tl=Math.pow(2,16);function Ml(t,e){return t+e*Tl}function Nl(t){return 65535&t}var Rl=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}},zl=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(t){let e=0,n=Nl(t);if(!this.inverted)for(let r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/Tl}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>t)break;let c=this.ranges[o+i],a=this.ranges[o+s],h=l+c;if(t<=h){let i=l+r+((c?t==l?-1:t==h?1:e:e)<0?0:a);if(n)return i;let s=t==(e<0?l:h)?null:Ml(o/3,t-l),d=t==l?2:t==h?1:4;return(e<0?t!=l:t!=h)&&(d|=8),new Rl(i,d,s)}r+=a-c}return n?t+r:new Rl(t+r,0,null)}touches(t,e){let n=0,r=Nl(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let e=this.ranges[o]-(this.inverted?n:0);if(e>t)break;let l=this.ranges[o+i];if(t<=e+l&&o==3*r)return!0;n+=this.ranges[o+s]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),c=this.ranges[r+e],a=this.ranges[r+n];t(o,o+c,l,l+a),i+=a-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};zl.empty=new zl([]);var Pl=Object.create(null),Bl=class{getMap(){return zl.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Pl[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Pl)throw new RangeError("Duplicate use of step JSON ID "+t);return Pl[t]=e,e.prototype.jsonID=t,e}},Ll=class t{constructor(t,e){this.doc=t,this.failed=e}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,i){try{return t.ok(e.replace(n,r,i))}catch(Xa){if(Xa instanceof wl)return t.fail(Xa.message);throw Xa}}};function Ul(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Ul(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pl.fromArray(r)}var Fl=class t extends Bl{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new yl(Ul(e.content,(t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t,r),e.openStart,e.openEnd);return Ll.fromReplace(t,this.from,this.to,i)}invert(){return new $l(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Bl.jsonID("addMark",Fl);var $l=class t extends Bl{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new yl(Ul(e.content,t=>t.mark(this.mark.removeFromSet(t.marks)),t),e.openStart,e.openEnd);return Ll.fromReplace(t,this.from,this.to,n)}invert(){return new Fl(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Bl.jsonID("removeMark",$l);var Hl=class t extends Bl{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(n),0,e.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let e=this.mark.addToSet(n.marks);if(e.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(e))return new t(this.pos,n.marks[r]);return new t(this.pos,this.mark)}}return new Vl(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Bl.jsonID("addNodeMark",Hl);var Vl=class t extends Bl{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Hl(this.pos,this.mark):this}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};Bl.jsonID("removeNodeMark",Vl);var ql=class t extends Bl{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&Kl(t,this.from,this.to)?Ll.fail("Structure replace would overwrite content"):Ll.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new zl([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let n=this.slice.size+e.slice.size==0?yl.empty:new yl(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}}{let n=this.slice.size+e.slice.size==0?yl.empty:new yl(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,yl.fromJSON(e,n.slice),!!n.structure)}};ql.MAP_BIAS=1,Bl.jsonID("replace",ql);var Jl=class t extends Bl{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Kl(t,this.from,this.gapFrom)||Kl(t,this.gapTo,this.to)))return Ll.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Ll.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?Ll.fromReplace(t,this.from,this.to,n):Ll.fail("Content does not fit in gap")}getMap(){return new zl([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new t(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,yl.fromJSON(e,n.slice),n.insert,!!n.structure)}};function Kl(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}Bl.jsonID("replaceAround",Jl);Bl.jsonID("attr",class t extends Bl{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return Ll.fail("No node at attribute step's position");let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return Ll.fromReplace(t,this.pos,this.pos+1,new yl(pl.from(r),0,e.isLeaf?0:1))}getMap(){return zl.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}});Bl.jsonID("docAttr",class t extends Bl{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return Ll.ok(n)}getMap(){return zl.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}});var Wl=Error;((Wl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n}).prototype=Object.create(Error.prototype)).constructor=Wl,Wl.prototype.name="TransformError";var Gl=Object.create(null),Xl=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Yl(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=yl.empty){let n=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:c}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(c.pos),o?yl.empty:e),0==o&&lc(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],l=t.mapping.slice(n),c=l.map(s.pos),a=l.map(o.pos);i?t.deleteRange(c,a):(t.replaceRangeWith(c,a,e),lc(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new tc(t):oc(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let i=t.depth-1;i>=0;i--){let r=e<0?oc(t.node(0),t.node(i),t.before(i+1),t.index(i),e,n):oc(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ic(t.node(0))}static atStart(t){return oc(t,t,0,0,1)||new ic(t)}static atEnd(t){return oc(t,t,t.content.size,t.childCount,-1)||new ic(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Gl[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Gl)throw new RangeError("Duplicate use of selection JSON ID "+t);return Gl[t]=e,e.prototype.jsonID=t,e}getBookmark(){return tc.between(this.$anchor,this.$head).getBookmark()}};Xl.prototype.visible=!0;var Yl=class{constructor(t,e){this.$from=t,this.$to=e}},Zl=!1;function Ql(t){Zl||t.parent.inlineContent||(Zl=!0)}var tc=class t extends Xl{constructor(t,e=t){Ql(t),Ql(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Xl.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(t,e=yl.empty){if(super.replace(t,e),e==yl.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ec(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(e,n,r){let i=e.pos-n.pos;if(r&&!i||(r=i>=0?1:-1),!n.parent.inlineContent){let t=Xl.findFrom(n,r,!0)||Xl.findFrom(n,-r,!0);if(!t)return Xl.near(n,r);n=t.$head}return e.parent.inlineContent||(0==i||(e=(Xl.findFrom(e,-r,!0)||Xl.findFrom(e,r,!0)).$anchor).pos<n.pos!=i<0)&&(e=n),new t(e,n)}};Xl.jsonID("text",tc);var ec=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){return tc.between(t.resolve(this.anchor),t.resolve(this.head))}},nc=class t extends Xl{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?Xl.near(s):new t(s)}content(){return new yl(pl.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new rc(this.anchor)}static fromJSON(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}};nc.prototype.visible=!1,Xl.jsonID("node",nc);var rc=class t{constructor(t){this.anchor=t}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ec(r,r):new t(r)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&nc.isSelectable(n)?new nc(e):Xl.near(e)}},ic=class t extends Xl{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=yl.empty){if(e==yl.empty){t.delete(0,t.doc.content.size);let e=Xl.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return sc}};Xl.jsonID("all",ic);var sc={map(){return this},resolve:t=>new ic(t)};function oc(t,e,n,r,i,s=!1){if(e.inlineContent)return tc.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&nc.isSelectable(r))return nc.create(t,n-(i<0?r.nodeSize:0))}else{let e=oc(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function lc(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof ql||s instanceof Jl)&&(t.mapping.maps[r].forEach((t,e,n,r)=>{null==i&&(i=r)}),t.setSelection(Xl.near(t.doc.resolve(i),n)))}function cc(t,e){return e&&t?t.bind(e):t}var ac=class{constructor(t,e,n){this.name=t,this.init=cc(e.init,n),this.apply=cc(e.apply,n)}};new ac("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ac("selection",{init:(t,e)=>t.selection||Xl.atStart(e.doc),apply:t=>t.selection}),new ac("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new ac("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e});function hc(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=hc(i,e,{})),n[r]=i}return n}var dc=class{constructor(t){this.spec=t,this.props={},t.props&&hc(t.props,this,this.props),this.key=t.key?t.key.key:pc("plugin")}getState(t){return t[this.key]}},uc=Object.create(null);function pc(t){return t in uc?t+"$"+ ++uc[t]:(uc[t]=0,t+"$")}var fc=class{constructor(t="key"){this.key=pc(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}},gc=/[\uD800-\uDBFF]/,mc=/[\uDC00-\uDFFF]/,xc=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&gc.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&mc.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},wc=(t,e)=>t>>>e|t<<32-e,yc=t=>wc(t,2)^wc(t,13)^wc(t,22),bc=t=>wc(t,6)^wc(t,11)^wc(t,25),vc=t=>wc(t,7)^wc(t,18)^t>>>3,Sc=t=>wc(t,17)^wc(t,19)^t>>>10,kc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Cc=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ec=class{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(Cc),this._W=new Uint32Array(t,64,64)}_updateHash(){const t=this._H,e=this._W;for(let h=16;h<64;h++)e[h]=Sc(e[h-2])+e[h-7]+vc(e[h-15])+e[h-16];let n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],l=t[5],c=t[6],a=t[7];for(let h,d,u=0;u<64;u++)h=a+bc(o)+(o&l^~o&c)+kc[u]+e[u]>>>0,d=yc(n)+(n&r^n&i^r&i)>>>0,a=c,c=l,l=o,o=s+h>>>0,s=i,i=r,r=n,n=h+d>>>0;t[0]+=n,t[1]+=r,t[2]+=i,t[3]+=s,t[4]+=o,t[5]+=l,t[6]+=c,t[7]+=a}digest(t){let e=0;for(;e+56<=t.length;){let n=0;for(;n<16&&e+3<t.length;n++)this._W[n]=t[e++]<<24|t[e++]<<16|t[e++]<<8|t[e++];if(e%64!=0){for(this._W.fill(0,n,16);e<t.length;)this._W[n]|=t[e]<<8*(3-e%4),e++;this._W[n]|=128<<8*(3-e%4)}this._updateHash()}const n=e%64!=0;this._W.fill(0,0,16);let r=0;for(;e<t.length;r++)for(let n=3;n>=0&&e<t.length;n--)this._W[r]|=t[e++]<<8*n;n||(this._W[r-(e%4==0?0:1)]|=128<<8*(3-e%4)),this._W[14]=t.byteLength/536870912,this._W[15]=8*t.byteLength,this._updateHash();const i=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let t=0;t<4;t++)i[4*s+t]=this._H[s]>>>8*(3-t);return i}},_c=new fc("y-sync"),Ac=new fc("y-undo"),jc=(new fc("yjs-cursor"),t=>{return Pn((t=>{for(let e=6;e<t.length;e++)t[e%6]=t[e%6]^t[e];return t.slice(0,6)})((e=Bn(t),(new Ec).digest(e))));var e}),Dc=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!yi(e.ds,t.id),Oc=[{light:"#ecd44433",dark:"#ecd444"}],Ic=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const n=Wt();t.forEach(t=>n.add(t)),e=e.filter(t=>!n.has(t))}t.set(n,(r=e)[ne(on()*r.length)])}var r;return t.get(n)},Tc=(t,{colors:e=Oc,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1;const l=new Pc(t,s),c=new dc({props:{editable:t=>{const e=_c.getState(t);return null==e.snapshot&&null==e.prevSnapshot}},key:_c,state:{init:(i,s)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(t,e)=>{const n=t.getMeta(_c);if(void 0!==n){e=Object.assign({},e);for(const t in n)e[t]=n[t]}return e.addToHistory=!1!==t.getMeta("addToHistory"),e.isChangeOrigin=void 0!==n&&!!n.isChangeOrigin,e.isUndoRedoOperation=void 0!==n&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,null!==l.prosemirrorView&&(void 0===n||null==n.snapshot&&null==n.prevSnapshot||ei(0,()=>{null!=l.prosemirrorView&&(null==n.restore?l._renderSnapshot(n.snapshot,n.prevSnapshot,e):(l._renderSnapshot(n.snapshot,n.snapshot,e),delete e.restore,delete e.snapshot,delete e.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))})),e}},view:t=>(l.initView(t),null==s&&l._forceRerender(),i(),{update:()=>{const e=c.getState(t.state);if(null==e.snapshot&&null==e.prevSnapshot&&(o||null!==t.state.doc.content.findDiffStart(t.state.doc.type.createAndFill().content))){if(o=!0,!1===e.addToHistory&&!e.isChangeOrigin){const e=Ac.getState(t.state),n=e&&e.undoManager;n&&n.stopCapturing()}l.mux(()=>{e.doc.transact(n=>{n.meta.set("addToHistory",e.addToHistory),l._prosemirrorChanged(t.state.doc)},_c)})}},destroy:()=>{l.destroy()}})});return c},Mc=(t,e,n,r)=>{if(null==n)return r;if(!(null===r||n>1&&r<=1||ua(e,t,n,r)))return r;const i=da(e,t,n);return null!==i?i:r},Nc=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?nc.create(t.doc,e):tc.near(n)},Rc=(t,e,n,r)=>{if(null===e||null===n)return null;const i=Math.min(Math.max(e,0),t.doc.content.size),s=Math.min(Math.max(n,0),t.doc.content.size);try{const e=Xl.fromJSON(t.doc,{type:"nodeRange",anchor:i,head:s,depth:r});return e.ranges.length?e:tc.near(t.doc.resolve(i))}catch(Xa){return tc.near(t.doc.resolve(i))}},zc=(t,e)=>{const n=e.selection.jsonID;return{type:n,depth:"nodeRange"===n?e.selection.depth:void 0,anchor:la(e.selection.anchor,t.type,t.mapping),head:la(e.selection.head,t.type,t.mapping),absAnchor:e.selection.anchor,absHead:e.selection.head}},Pc=class{constructor(t,e=new Map){this.type=t,this.prosemirrorView=null,this.mux=(()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else void 0!==n&&n()}})(),this.mapping=e,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=t.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{null===this.beforeTransactionSelection&&null!=this.prosemirrorView&&(this.beforeTransactionSelection=zc(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return!!this.prosemirrorView.hasFocus()&&(On&&null===this._domSelectionInView&&(ei(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView)}_isDomSelectionInView(){const t=this.prosemirrorView._root.getSelection();if(null==t||null==t.anchorNode)return!1;const e=this.prosemirrorView._root.createRange();e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),0===e.getClientRects().length&&e.startContainer&&e.collapsed&&e.selectNodeContents(e.startContainer);const n=e.getBoundingClientRect(),r=Wr.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(t,e){e||(e=Qi(ki(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(_c,{snapshot:t,prevSnapshot:e}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const t=this.type.toArray().map(t=>Lc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),e=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(t),0,0));e.setMeta(_c,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(e)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const t=null!==this.beforeTransactionSelection?null:this.prosemirrorView.state.selection,e=this.type.toArray().map(t=>Lc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(e),0,0));if(t){const e=ie(se(t.anchor,0),n.doc.content.size),r=ie(se(t.head,0),n.doc.content.size);n.setSelection(tc.create(n.doc,e,r))}this.prosemirrorView.dispatch(n.setMeta(_c,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(t,e,n){let r=this.doc,i=this.type;if(t||(t=ts(this.doc)),t instanceof Uint8Array||e instanceof Uint8Array)if(t instanceof Uint8Array&&e instanceof Uint8Array||Fe(),r=new Ai({gc:!1}),zi(r,e),e=ts(r),zi(r,t),t=ts(r),null===i._item){const t=Array.from(this.doc.share.keys()).find(t=>this.doc.share.get(t)===this.type);i=r.getXmlFragment(t)}else{const t=r.store.clients.get(i._item.id.client)??[];i=t[ls(t,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{const s=n.permanentUserData;s&&s.dss.forEach(t=>{wi(r,t,t=>{})});const o=(t,e)=>{const r="added"===t?s.getUserByClientId(e.client):s.getUserByDeletedId(e);return{user:r,type:t,color:Ic(n.colorMapping,n.colors,r)}},l=Hs(i,new Zi(e.ds,t.sv)).map(n=>!n._item.deleted||Dc(n._item,t)||Dc(n._item,e)?Lc(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},t,e,o):null).filter(t=>null!==t),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(l),0,0));this.prosemirrorView.dispatch(c.setMeta(_c,{isChangeOrigin:!0}))},_c)})}_typeChanged(t,e){if(null==this.prosemirrorView)return;const n=_c.getState(this.prosemirrorView.state);0!==t.length&&null==n.snapshot&&null==n.prevSnapshot?this.mux(()=>{const t=(t,e)=>this.mapping.delete(e);wi(e,e.deleteSet,t=>{if(t.constructor===rl){const e=t.content.type;e&&this.mapping.delete(e)}}),e.changed.forEach(t),e.changedParentTypes.forEach(t),this.mapping.clear();const n=this.type.toArray().map(t=>Bc(t,this.prosemirrorView.state.schema,this)).filter(t=>null!==t),r=this.prosemirrorView.state.doc;let i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new yl(pl.from(n),0,0));((t,e,n,r)=>{if(null!==e&&null!==e.anchor&&null!==e.head)if("all"===e.type)t.setSelection(new ic(t.doc));else if("node"===e.type){const r=aa(n.doc,n.type,e.anchor,n.mapping);null!==r&&t.setSelection(Nc(t,r))}else if("nodeRange"===e.type){const r=aa(n.doc,n.type,e.anchor,n.mapping),i=aa(n.doc,n.type,e.head,n.mapping),s=Rc(t,r,i,e.depth);null!==s&&t.setSelection(s)}else{let i=aa(n.doc,n.type,e.anchor,n.mapping),s=aa(n.doc,n.type,e.head,n.mapping);null!=r&&(i=Mc(t.doc,r,e.absAnchor,i),s=Mc(t.doc,r,e.absHead,s)),null===i&&(i=s),null===s&&(s=i),null!==i&&null!==s&&t.setSelection(tc.between(t.doc.resolve(i),t.doc.resolve(s)))}})(i,this.beforeTransactionSelection,this,r),i=i.setMeta(_c,{isChangeOrigin:!0,isUndoRedoOperation:e.origin instanceof Ss}),null!==this.beforeTransactionSelection&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)}):this.renderSnapshot(n.snapshot,n.prevSnapshot)}_prosemirrorChanged(t){this.doc.transact(()=>{sa(this.doc,this.type,t,this),this.beforeTransactionSelection=zc(this,this.prosemirrorView.state)},_c)}initView(t){null!=this.prosemirrorView&&this.destroy(),this.prosemirrorView=t,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){null!=this.prosemirrorView&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}},Bc=(t,e,n,r,i,s)=>{const o=n.mapping.get(t);if(void 0===o){if(t instanceof Ao)return Lc(t,e,n,r,i,s);throw Ue()}return o},Lc=(t,e,n,r,i,s)=>{const o=[],l=t=>{if(t instanceof Ao){const l=Bc(t,e,n,r,i,s);null!==l&&o.push(l)}else{const l=(t._item.right?.content)?.type;l instanceof Co&&!l._item.deleted&&l._item.id.client===l.doc.clientID&&(t.applyDelta([{retain:t.length},...l.toDelta()]),l.doc.transact(t=>{l._item.delete(t)}));const c=Uc(t,e,n,r,i,s);null!==c&&c.forEach(t=>{null!==t&&o.push(t)})}};void 0===r||void 0===i?t.toArray().forEach(l):Hs(t,new Zi(i.ds,r.sv)).forEach(l);try{const l=t.getAttributes(r);void 0!==r&&(Dc(t._item,r)?Dc(t._item,i)||(l.ychange=s?s("added",t._item.id):{type:"added"}):l.ychange=s?s("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,o);return n.mapping.set(t,c),c}catch(Xa){return t.doc.transact(e=>{t._item.delete(e)},_c),n.mapping.delete(t),null}},Uc=(t,e,n,r,i,s)=>{const o=[],l=t.toDelta(r,i,s);try{for(let t=0;t<l.length;t++){const n=l[t];o.push(e.text(n.insert,ra(n.attributes,e)))}}catch(Xa){return t.doc.transact(e=>{t._item.delete(e)},_c),null}return o},Fc=(t,e)=>t instanceof Array?((t,e)=>{const n=new Oo,r=t.map(t=>({insert:t.text,attributes:ia(t.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n})(t,e):((t,e)=>{const n=new Ao(t.type.name);for(const r in t.attrs){const e=t.attrs[r];null!==e&&"ychange"!==r&&n.setAttribute(r,e)}return n.insert(0,Vc(t).map(t=>Fc(t,e))),e.mapping.set(n,t),n})(t,e),$c=t=>"object"==typeof t&&null!==t,Hc=(t,e)=>{const n=Object.keys(t).filter(e=>null!==t[e]);let r=n.length===Object.keys(e).filter(t=>null!==e[t]).length;for(let i=0;i<n.length&&r;i++){const s=n[i],o=t[s],l=e[s];r="ychange"===s||o===l||$c(o)&&$c(l)&&Hc(o,l)}return r},Vc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const t=e[r];if(t.isText){const t=[];for(let n=e[r];r<e.length&&n.isText;n=e[++r])t.push(n);r--,n.push(t)}else n.push(t)}return n},qc=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((t,n)=>t.insert===e[n].text&&vn(t.attributes||{}).length===e[n].marks.length&&kn(t.attributes,(t,r)=>{const i=na(r),s=e[n].marks;return!!s.find(t=>t.type.name===i)&&Hc(t,s.find(t=>t.type.name===i)?.attrs)}))},Jc=(t,e)=>{if(t instanceof Ao&&!(e instanceof Array)&&oa(t,e)){const n=Vc(e);return t._length===n.length&&Hc(t.getAttributes(),e.attrs)&&t.toArray().every((t,e)=>Jc(t,n[e]))}return t instanceof Oo&&e instanceof Array&&qc(t,e)},Kc=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((t,n)=>e[n]===t),Wc=(t,e,n,r)=>{n>0&&(t.slice(e,e+n).forEach(t=>r.mapping.delete(t)),t.delete(e,n))},Gc=(t,e,n,r,i,s)=>{if(r<i){const o=[];for(let t=r;t<i;t++)o.push(Fc(n[t],s));t.insert(e,o)}},Xc=(t,e,n,r)=>e instanceof Oo&&n instanceof Array?(qc(e,n)?r.mapping.set(e,n):ta(e,n,r),!0):!(!(e instanceof Ao)||n instanceof Array||!oa(e,n))&&(Jc(e,n)?r.mapping.set(e,n):sa(t,e,n,r),!0),Yc=(t,e,n,r,i,s,o,l,c)=>{const a=ie(s-i,l-o);for(let h=0;h<a;h++){const s=r[i+h],l=n[o+h];Xc(t,s,l,c)||(Wc(e,o+h,1,c),Gc(e,o+h,n,o+h,o+h+1,c))}Wc(e,o+a,s-i-a,c),Gc(e,o+a,n,o+a,l,c)},Zc=(t,e,n,r,i)=>{const s=((t,e,n)=>{const r=new Map;e.forEach((t,e)=>{r.has(t)||r.set(t,e)});const i=[];if(t.forEach((t,s)=>{const o=n.mapping.get(t),l=r.get(o);void 0!==l&&Kc(o,e[l])&&i.push({yIndex:s,pIndex:l,yChild:t})}),0===i.length)return[];const s=new Array(i.length),o=[];for(let c=0;c<i.length;c++){let t=0,e=o.length;for(;t<e;){const n=t+e>>1;i[o[n]].pIndex<i[c].pIndex?t=n+1:e=n}s[c]=t>0?o[t-1]:-1,o[t]=c}const l=[];for(let c=o[o.length-1];-1!==c;c=s[c])l.push(i[c]);return l.reverse()})(r,n,i);if(s.length<2||!s.some(t=>t.yIndex!==t.pIndex)||s.some(t=>{const e=n[t.pIndex];return!(t.yChild instanceof Oo&&e instanceof Array||t.yChild instanceof Ao&&!(e instanceof Array))}))return!1;let o=0,l=0;for(const c of s){Yc(t,e,n,r,o,c.yIndex,l,c.pIndex,i);const s=n[c.pIndex];Xc(t,c.yChild,s,i),o=c.yIndex+1,l=c.pIndex+1}return Yc(t,e,n,r,o,r.length,l,n.length,i),!0},Qc=(t,e,n)=>{const r=t.toArray(),i=Vc(e),s=i.length,o=r.length,l=ie(o,s);let c=0,a=0,h=!1;for(;c<l;c++){const t=r[c],e=i[c];if(Kc(n.mapping.get(t),e))h=!0;else if(!Jc(t,e))break}for(;c+a<l;a++){const t=r[o-a-1],e=i[s-a-1];if(Kc(n.mapping.get(t),e))h=!0;else if(!Jc(t,e))break}return{equalityFactor:c+a,foundMappedChild:h}},ta=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=(t=>{let e="",n=t._start;const r={};for(;null!==n;)n.deleted||(n.countable&&n.content instanceof $o?e+=n.content.str:n.content instanceof Bo&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}})(t),s=e.map(t=>({insert:t.text,attributes:Object.assign({},r,ia(t.marks,n))})),{insert:o,remove:l,index:c}=xc(i,s.map(t=>t.insert).join(""));t.delete(c,l),t.insert(c,o),t.applyDelta(s.map(t=>({retain:t.insert.length,attributes:t.attributes})))},ea=/(.*)(--[a-zA-Z0-9+/=]{8})$/,na=t=>ea.exec(t)?.[1]??t,ra=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(na(r),t[r]));return n},ia=(t,e)=>{const n={};return t.forEach(t=>{if("ychange"!==t.type.name){const r=Kt(e.isOMark,t.type,()=>!t.type.excludes(t.type));n[r?`${t.type.name}--${jc(t.toJSON())}`:t.type.name]=t.attrs}}),n},sa=(t,e,n,r)=>{if(e instanceof Ao&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof Ao){const t=e.getAttributes(),r=n.attrs;for(const n in r)null!==r[n]?t[n]!==r[n]&&"ychange"!==n&&e.setAttribute(n,r[n]):e.removeAttribute(n);for(const n in t)void 0===r[n]&&e.removeAttribute(n)}const i=Vc(n),s=i.length,o=e.toArray(),l=o.length,c=ie(s,l);if(Zc(t,e,i,o,r))return;let a=0,h=0;for(;a<c;a++){const t=o[a],e=i[a];if(!Kc(r.mapping.get(t),e)){if(!Jc(t,e))break;r.mapping.set(t,e)}}for(;h+a+1<c;h++){const t=o[l-h-1],e=i[s-h-1];if(!Kc(r.mapping.get(t),e)){if(!Jc(t,e))break;r.mapping.set(t,e)}}t.transact(()=>{for(;l-a-h>0&&s-a-h>0;){const n=o[a],c=i[a],d=o[l-h-1],u=i[s-h-1];if(n instanceof Oo&&c instanceof Array)qc(n,c)||ta(n,c,r),a+=1;else{let i=n instanceof Ao&&oa(n,c),s=d instanceof Ao&&oa(d,u);if(i&&s){const t=Qc(n,c,r),e=Qc(d,u,r);t.foundMappedChild&&!e.foundMappedChild?s=!1:!t.foundMappedChild&&e.foundMappedChild||t.equalityFactor<e.equalityFactor?i=!1:s=!1}i?(sa(t,n,c,r),a+=1):s?(sa(t,d,u,r),h+=1):(r.mapping.delete(e.get(a)),e.delete(a,1),e.insert(a,[Fc(c,r)]),a+=1)}}const n=l-a-h;if(1===l&&0===s&&o[0]instanceof Oo?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(e.slice(a,a+n).forEach(t=>r.mapping.delete(t)),e.delete(a,n)),a+h<s){const t=[];for(let e=a;e<s-h;e++)t.push(Fc(i[e],r));e.insert(a,t)}},_c)},oa=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,la=(t,e,n)=>{if(0===t)return Xi(e,0,-1);let r=null===e._first?null:e._first.content.type;for(;null!==r&&e!==r;){if(r instanceof Oo){if(r._length>=t)return Xi(r,t,-1);if(t-=r._length,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{do{r=null===r._item?null:r._item.parent,t--}while(r!==e&&null!==r&&null!==r._item&&null===r._item.next);null!==r&&r!==e&&(r=null===r._item?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(null!==r._first&&t<i)r=r._first.content.type,t--;else{if(1===t&&0===r._length&&i>1)return new Ki(null===r._item?null:r._item.id,null===r._item?qi(r):null,null);if(t-=i,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{if(0===t)return r=null===r._item?r:r._item.parent,new Ki(null===r._item?null:r._item.id,null===r._item?qi(r):null,null);do{r=r._item.parent,t--}while(r!==e&&null===r._item.next);r!==e&&(r=r._item.next.content.type)}}}if(null===r)throw Fe();if(0===t&&r.constructor!==Oo&&r!==e)return ca(r._item.parent,r._item)}return Xi(e,e._length,-1)},ca=(t,e)=>{let n=null,r=null;return null===t._item?r=qi(t):n=Vi(t._item.id.client,t._item.id.clock),new Ki(n,r,e.id)},aa=(t,e,n,r)=>{const i=Yi(n,t);if(null===i||i.type!==e&&!Ji(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Oo)o=i.index;else if(null===s._item||!s._item.deleted){let t=s._first,e=0;for(;e<s._length&&e<i.index&&null!==t;){if(!t.deleted){const n=t.content.type;if(e++,n instanceof Oo)o+=n._length;else{const t=r.get(n);if(null==t)return null;o+=t.nodeSize}}t=t.right}o+=1}for(;s!==e&&null!==s._item;){const t=s._item.parent;if(null===t._item||!t._item.deleted){o+=1;let e=t._first;for(;null!==e;){const t=e.content.type;if(t===s)break;if(!e.deleted)if(t instanceof Oo)o+=t._length;else{const e=r.get(t);if(null==e)return null;o+=e.nodeSize}e=e.right}}s=t}const l=o-1;return((t,e,n)=>{if(null===n)return!1;const r=Yi(e,t);return null!==r&&r.type instanceof Oo&&null!==e.item&&n<=1})(t,n,l)?null:l},ha=(t,e)=>{if(t===e)return!0;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>t[n]===e[n])},da=(t,e,n)=>{let r=0,i=0;for(;i<t.childCount;i++){const e=t.child(i);if(r+e.nodeSize>n)break;r+=e.nodeSize}if(i>=t.childCount)return null;const s=t.child(i),o=t.resolve(n),l=(t,e)=>{if(0===o.depth){const i=t+(n-r),s=t+1,o=t+e.nodeSize-1;return Math.max(s,Math.min(i,o))}return((t,e,n)=>{let r=e+1,i=n;for(let s=1;s<t.depth;s++){const e=t.index(s);if(e>=i.childCount)return null;for(let t=0;t<e;t++)r+=i.child(t).nodeSize;if(r+=1,i=i.child(e),i.type!==t.node(s+1).type)return null}return i.isTextblock?r+Math.min(t.parentOffset,i.content.size):null})(o,t,e)},c=(n,r=!1)=>{let s=0;for(let e=0;e<=i;e++)n(t.child(e))&&s++;let o=0,c=-1,a=null,h=0;for(let t=0;t<e.childCount;t++){const r=e.child(t);n(r)&&(o++,o===s&&(c=h,a=r)),h+=r.nodeSize}return null===a||r&&(1!==s||1!==o)?null:l(c,a)},a=t=>t.type===s.type&&ha(t.attrs,s.attrs),h=s.textContent,d=c(t=>a(t)&&t.textContent===h);if(null!==d)return d;const u=c(t=>t.type===s.type&&t.textContent===h);if(null!==u)return u;if((t=>{const e=t.type.spec.attrs||{};return Object.keys(t.attrs).some(n=>{const r=e[n];return null==r||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==t.attrs[n]})})(s)){const t=c(a,!0);if(null!==t)return t}return c(t=>a(t)&&""!==h&&""!==t.textContent&&(h.startsWith(t.textContent)||t.textContent.startsWith(h)),!0)},ua=(t,e,n,r)=>{if(null===r)return!1;const i=t.resolve(n),s=e.resolve(r);if(!i.parent.isTextblock)return!1;if(!s.parent.isTextblock)return!0;if(i.parent.textContent!==s.parent.textContent)return!0;if(0!==i.parentOffset&&0===s.parentOffset)return!0;const o=0===i.parentOffset&&0===s.parentOffset,l=i.parentOffset!==s.parentOffset||i.parent.type!==s.parent.type||!ha(i.parent.attrs,s.parent.attrs);if(o||l){const i=da(t,e,n);return null!==i&&i!==r}return!1},pa=new Set(["paragraph"]),fa=({protectedNodes:t=pa,trackedOrigins:e=[],undoManager:n=null}={})=>new dc({key:Ac,state:{init:(r,i)=>{const s=_c.getState(i);let o=n;if(!o){const n=s.doc,r=new Set(n?n._observers.get("destroy"):[]);o=new Ss(s.type,{trackedOrigins:new Set([_c].concat(e)),deleteFilter:e=>((t,e)=>!(t instanceof rl&&t.content instanceof Yo&&(t.content.type instanceof Co||t.content.type instanceof Ao&&e.has(t.content.type.nodeName))&&0!==t.content.type._length))(e,t),captureTransaction:t=>!1!==t.meta.get("addToHistory")});const i=n?n._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(i||[]).filter(t=>!r.has(t))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(t,e,n,r)=>{const i=_c.getState(r).binding,s=e.undoManager,o=s.undoStack.length>0,l=s.redoStack.length>0;return i?{undoManager:s,prevSel:zc(i,n),hasUndoOps:o,hasRedoOps:l}:o!==e.hasUndoOps||l!==e.hasRedoOps?Object.assign({},e,{hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}):e}},view:t=>{const e=_c.getState(t.state),n=Ac.getState(t.state).undoManager;return n.on("stack-item-added",({stackItem:n})=>{const r=e.binding;r&&n.meta.set(r,Ac.getState(t.state).prevSel)}),n.on("stack-item-popped",({stackItem:t})=>{const n=e.binding;n&&(n.beforeTransactionSelection=t.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy();const t=n._yTiptapDocDestroyListeners;t&&n.doc&&(t.forEach(t=>n.doc.off("destroy",t)),n._yTiptapDocDestroyListeners=null)}}}});function ga(t){return!!t.getMeta(_c)}function ma(t,e){const n=_c.getState(t);return aa(n.doc,n.type,e,n.binding.mapping)||0}function xa(t,e){const n=_c.getState(t);return la(e,n.type,n.binding.mapping)}var wa=class t extends K.MappablePosition{constructor(t,e){super(t),this.yRelativePosition=e}static fromJSON(e){return new t(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};K.Extension.create({name:"collaboration",priority:1e3,addOptions:()=>({document:null,field:"default",fragment:null,provider:null}),addStorage:()=>({isDisabled:!1}),onCreate(){this.editor.extensionManager.extensions.find(t=>"undoRedo"===t.name)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>function(t,e,n){const r=t instanceof wa?t.yRelativePosition:null;if(ga(e)&&r)return{position:new wa(ma(n,r),r),mapResult:null};const i=(0,K.getUpdatedPosition)(t,e),s=i.position.position;return{position:new wa(s,null!=r?r:xa(n,s)),mapResult:i.mapResult}}(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>function(t,e){return new wa(t,xa(e,t))}(t,this.editor.state)},addCommands:()=>({undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),0!==Ac.getState(e).undoManager.undoStack.length&&(!n||(t=>{const e=Ac.getState(t).undoManager;if(null!=e)return e.undo(),!0})(e))),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),0!==Ac.getState(e).undoManager.redoStack.length&&(!n||(t=>{const e=Ac.getState(t).undoManager;if(null!=e)return e.redo(),!0})(e)))}),addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=fa(this.options.yUndoOptions),n=e.spec.view;e.spec.view=t=>{const{undoManager:e}=Ac.getState(t.state);e.restore&&(e.restore(),e.restore=()=>{});const r=n?n(t):void 0;return{destroy:()=>{const t=e.trackedOrigins.has(e),n=e._observers;e.restore=()=>{t&&e.trackedOrigins.add(e),e.doc.on("afterTransaction",e.afterTransactionHandler),e._observers=n},(null==r?void 0:r.destroy)&&r.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[Tc(t,r),e,this.editor.options.enableContentCheck&&new W.Plugin({key:new W.PluginKey("filterInvalidContent"),filterTransaction:e=>{if(!ga(e))return!0;if(this.storage.isDisabled)return!1;if(!e.docChanged)return!0;try{return e.doc.check(),!0}catch(n){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:n,editor:this.editor,disableCollaboration:()=>{var e;null==(e=t.doc)||e.destroy()}}),!0}}})].filter(Boolean)}});function ya(t){if(!t.length)return G.DecorationSet.empty;const e=[],n=t[0].$from.node(0);return t.forEach(t=>{const n=t.$from.pos,r=t.$from.nodeAfter;r&&e.push(G.Decoration.node(n,n+r.nodeSize,{class:"ProseMirror-selectednoderange"}))}),G.DecorationSet.create(n,e)}function ba(t,e,n,r={}){const i=[],s=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;"number"==typeof n&&n>=0||(n=t.sameParent(e)?Math.max(0,t.sharedDepth(e.pos)-1):t.sharedDepth(e.pos));const l=new X.NodeRange(t,e,n),c=0===l.depth?0:s.resolve(l.start).posAtIndex(0);return l.parent.forEach((n,r)=>{const a=c+r,h=a+n.nodeSize,d=function(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}(a,n.nodeSize,n),u=o?e.pos>=d.start&&t.pos<=d.end:e.pos>d.start&&t.pos<d.end;if(a<l.start||a>=l.end)return;if(!u)return;const p=new W.SelectionRange(s.resolve(a),s.resolve(h));i.push(p)}),i}var va=class t{constructor(t,e,n){this.anchor=t,this.head=e,this.depth=null!=n?n:0}map(e){return new t(e.map(this.anchor),e.map(this.head),this.depth)}resolve(t){return new Sa(t.resolve(this.anchor),t.resolve(this.head),this.depth)}},Sa=class t extends W.Selection{constructor(t,e,n,r=1){const{doc:i}=t,s=t===e,o=t.pos===i.content.size&&e.pos===i.content.size,l=s&&!o?i.resolve(e.pos+(r>0?1:-1)):e,c=s&&o?i.resolve(t.pos-(r>0?1:-1)):t,a=ba(c.min(l),c.max(l),n);super(l.pos>=t.pos?a[0].$from:a[a.length-1].$to,l.pos>=t.pos?a[a.length-1].$to:a[0].$from,a),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof t&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),i=e.resolve(n.map(this.head));return new t(r,i,this.depth)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head,depth:this.depth}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const e=this.ranges.slice(0,-1),n=e[0].$from,r=e[e.length-1].$to;return new t(n,r,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new t(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const e=this.ranges.slice(1),n=e[0].$from,r=e[e.length-1].$to;return new t(r,n,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new t(this.$anchor,r,this.depth)}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head),n.depth)}static create(t,e,n,r,i=1){return new this(t.resolve(e),t.resolve(n),r,i)}getBookmark(){return new va(this.anchor,this.head,this.depth)}};Sa.prototype.visible=!1;try{W.Selection.jsonID("nodeRange",Sa)}catch{}function ka(t){return t instanceof Sa}K.Extension.create({name:"nodeRange",addOptions:()=>({depth:void 0,key:"Mod"}),addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:s,tr:o}=r,{anchor:l,head:c}=s;if(!ka(s)){const t=Sa.create(i,l,c,e,-1);return o.setSelection(t),n.dispatch(o),!0}const a=s.extendBackwards();return o.setSelection(a),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:s,tr:o}=r,{anchor:l,head:c}=s;if(!ka(s)){const t=Sa.create(i,l,c,e);return o.setSelection(t),n.dispatch(o),!0}const a=s.extendForwards();return o.setSelection(a),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,tr:s}=r,o=Sa.create(i,0,i.content.size,e);return s.setSelection(o),n.dispatch(s),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;ka(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new W.Plugin({key:new W.PluginKey("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(t,n)=>{const{key:r}=this.options,i=/Mac/.test(navigator.platform),s=!!n.shiftKey,o=!!n.ctrlKey,l=!!n.altKey,c=!!n.metaKey;return(null==r||"Shift"===r&&s||"Control"===r&&o||"Alt"===r&&l||"Meta"===r&&c||"Mod"===r&&(i?c:o))&&(e=!0),!!e&&(document.addEventListener("mouseup",()=>{e=!1;const{state:n}=t,{doc:r,selection:i,tr:s}=n,{$anchor:o,$head:l}=i;if(o.sameParent(l))return;const c=Sa.create(r,o.pos,l.pos,this.options.depth);s.setSelection(c),t.dispatch(s)},{once:!0}),!1)}},decorations:n=>{const{selection:r}=n,i=ka(r);if(t=!1,!e)return i?(t=!0,ya(r.ranges)):null;const{$from:s,$to:o}=r;if(!i&&s.sameParent(o))return null;const l=ba(s,o,this.options.depth);return l.length?(t=!0,ya(l)):null}}})]}});function Ca(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],i=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((t,n)=>{i[n].style.cssText=function(t,e){const n=getComputedStyle(t);if(e)return e.map(t=>t.trim()).filter(t=>t.length>0).map(t=>`${t}:${n.getPropertyValue(t)};`).join("");let r="";for(let i=0;i<n.length;i+=1)r+=`${n[i]}:${n.getPropertyValue(n[i])};`;return r}(t,e)}),n}var Ea=[{id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},{id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=t.firstChild;return e&&["listItem","taskItem"].includes(e.type.name)?1e3:0}},{id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&"tableHeader"===e.type.name?1e3:0},{id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0}],_a={edges:["left","top"],threshold:12,strength:500};function Aa(t){return void 0===t||"left"===t?{..._a}:"right"===t?{edges:["right","top"],threshold:12,strength:500}:"both"===t?{edges:["left","right","top"],threshold:12,strength:500}:"none"===t?{edges:[],threshold:0,strength:0}:{..._a,...t}}function ja(t,e,n,r){let i=1e3,s=!1;if(e.every(e=>{const n=e.evaluate(t);return i-=n,!(i<=0)||(s=!0,!1)}),s)return-1;const o=t.view.nodeDOM(t.pos);return i-=function(t,e,n,r){return e&&0!==n.edges.length&&function(t,e,n){if(0===n.edges.length)return!1;const r=e.getBoundingClientRect(),{threshold:i,edges:s}=n;return s.some(e=>"left"===e?t.x-r.left<i:"right"===e?r.right-t.x<i:"top"===e?t.y-r.top<i:"bottom"===e&&r.bottom-t.y<i)}(t,e,n)?n.strength*r:0}(r,o,n,t.depth),i<=0?-1:i}function Da(t,e,n){return Array.from({length:e},(t,n)=>e-1-n).some(e=>n.includes(t.node(e).type.name))}function Oa(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function Ia(t,e){let n="first"===e?t.firstElementChild:t.lastElementChild;for(;n;){const t=n.getBoundingClientRect();if(Oa(t))return t;n="first"===e?n.nextElementSibling:n.previousElementSibling}return null}var Ta=t=>{const{x:e,y:n,editor:r,nestedOptions:i}=t,{view:s,state:o}=r,l=function(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const i=t.dom,s=Ia(i,"first"),o=Ia(i,"last");if(!s||!o)return null;const l=Math.min(Math.max(s.top+r,n),o.bottom-r),c=Math.abs(s.left-o.left)<.5,a=Math.abs(s.right-o.right)<.5;let h=s;c&&a&&(h=s);const d=Math.min(Math.max(h.left+r,e),h.right-r);return Number.isFinite(d)&&Number.isFinite(l)?{x:d,y:l}:null}(s,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:c,y:a}=l;if(null==i?void 0:i.enabled){const t=function(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:i}=t.state,s=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...Ea),o.push(...n.rules);const l=Array.from({length:s.depth},(t,e)=>s.depth-e).map(r=>{const i=s.node(r),l=s.before(r);if(n.allowedContainers&&r>0&&!Da(s,r,n.allowedContainers))return null;const c=r>0?s.node(r-1):null,a=r>0?s.index(r-1):0,h=ja({node:i,pos:l,depth:r,parent:c,index:a,isFirst:0===a,isLast:a===(c?c.childCount:1)-1,$pos:s,view:t},o,n.edgeDetection,e);return h<0?null:{node:i,pos:l,depth:r,score:h,dom:t.nodeDOM(l)}}).filter(t=>null!==t),c=s.nodeAfter;if(c&&c.isAtom&&!c.isInline){const i=r.pos,a=s.depth+1,h=s.parent,d=s.index(),u=h.childCount;let p=!0;if(n.allowedContainers&&(p=Da(s,a,n.allowedContainers)),p){const r=ja({node:c,pos:i,depth:a,parent:h,index:d,isFirst:0===d,isLast:d===u-1,$pos:s,view:t},o,n.edgeDetection,e);if(r>=0){const e=t.nodeDOM(i);e&&l.push({node:c,pos:i,depth:a,score:r,dom:e})}}}if(0===l.length)return null;l.sort((t,e)=>e.score!==t.score?e.score-t.score:e.depth-t.depth);const a=l[0];return a.dom?{node:a.node,pos:a.pos,dom:a.dom}:null}(s,{x:c,y:a},i);return t?{resultElement:t.dom,resultNode:t.node,pos:t.pos}:{resultElement:null,resultNode:null,pos:null}}const h=s.root.elementsFromPoint(c,a);let d,u;if(Array.prototype.some.call(h,t=>{if(!s.dom.contains(t))return!1;const e=function(t,e){var n;let r=t;for(;(null==r?void 0:r.parentElement)&&r.parentElement!==e.dom;)r=r.parentElement;if((null==r?void 0:r.parentElement)===e.dom&&(null==(n=r.pmViewDesc)?void 0:n.node))return r}(t,s);return!!e&&(d=e,!0)}),!d){const t=s.posAtCoords({left:c,top:a});if(t){const e=o.doc.resolve(t.pos),n=Math.min(e.depth,1),r=n>0?e.before(n):e.pos,i=o.doc.nodeAt(r);if(i){const t=s.nodeDOM(r);return{resultElement:t instanceof HTMLElement?t:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}try{u=s.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const p=o.doc.nodeAt(u);if(!p){const t=o.doc.resolve(u),e=t.parent;return{resultElement:d,resultNode:e,pos:t.start()}}return{resultElement:d,resultNode:p,pos:u}};function Ma(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:i}=t.domAtPos(e),s=r.childNodes[i];return s instanceof Element?s:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function Na(t){var e;null==(e=t.parentNode)||e.removeChild(t)}function Ra(t,e,n,r,i){const{view:s}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:c}=s.state.selection,a=function(t,e,n,r){const{doc:i}=e.view.state;if((null==n?void 0:n.enabled)&&(null==r?void 0:r.node)&&r.pos>=0){const t=r.pos,e=r.pos+r.node.nodeSize;return[{$from:i.resolve(t),$to:i.resolve(e)}]}const s=Ta({editor:e,x:t.clientX,y:t.clientY,direction:"right",nestedOptions:n});if(!s.resultNode||null===s.pos)return[];const o=s.resultNode.isText||s.resultNode.isAtom?0:-1;return ba(i.resolve(s.pos),i.resolve(s.pos+s.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}(t,e,n,r),h=ba(l,c,0,{extendOnBoundaryOverlap:!1}),d=h.some(t=>a.find(e=>e.$from===t.$from&&e.$to===t.$to)),u=o||!d?a:h;if(!u.length)return;const{tr:p}=s.state,f=document.createElement("div"),g=u[0].$from.pos,m=u[u.length-1].$to.pos,x=function(t,e){const n=Ma(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}(s,g);f.setAttribute("dir",x);const w=(null==n?void 0:n.enabled)&&(null==r?void 0:r.node),y=1===u.length;let b,v;w&&y?(b=s.state.doc.slice(g,m),v=W.NodeSelection.create(s.state.doc,g)):(v=Sa.create(s.state.doc,g,m),b=v.content());const S=function(t){return!t||!t.some(t=>{const e=t.trim().toLowerCase();return"margin"===e||e.startsWith("margin-")})}(i);u.forEach(t=>{const e=Ma(s,t.$from.pos);if(!e)return;const n=Ca(e,i);S&&(n.style.margin="0"),f.append(n)}),f.style.position="absolute",f.style.top="-10000px",document.body.append(f),t.dataTransfer.clearData();const k=function(t,e){return"rtl"===t?e:0}(x,f.getBoundingClientRect().width);t.dataTransfer.setDragImage(f,k,0);let C=!1;const E=()=>{C||(C=!0,Na(f),document.removeEventListener("drop",E),document.removeEventListener("dragend",E))},_=v instanceof W.NodeSelection?v:void 0;s.dragging={slice:b,move:!0,node:_},p.setSelection(v),s.dispatch(p),document.addEventListener("drop",E),document.addEventListener("dragend",E)}var za=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return 0===r?e:n.pos-n.parentOffset-1},Pa=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:i}=r,s=n;for(;i>0;){const t=r.node(i);i-=1,0===i&&(s=t)}return s};function Ba(t,e,n){let r=0;for(let i=e;i<n;i+=1)r+=t.child(i).nodeSize;return r}function La(t,e,n,r){try{const i=function(t,e,n,r){const i=t.resolve(e),s=i.node(r);let o=i.index(r);o>=s.childCount&&(o=Math.max(0,s.childCount-n));const l=Math.min(n,s.childCount-o);if(l<=0)return null;const c=i.start(r)+Ba(s,0,o);return{anchor:c,head:c+Ba(s,o,o+l),count:l}}(t,e,n,r);if(!i)return null;const s=Sa.create(t,i.anchor,i.head,r);return s.ranges.length===n?s:null}catch{return null}}var Ua=(t,e)=>{const n=_c.getState(t);return n?la(e,n.type,n.binding.mapping):null},Fa=(t,e)=>{const n=_c.getState(t);return n?aa(n.doc,n.type,e,n.binding.mapping)||0:-1},$a=(t,e)=>{let n=e;for(;(null==n?void 0:n.parentNode)&&n.parentNode!==t.dom;)n=n.parentNode;return n},Ha=new W.PluginKey("dragHandle"),Va=({pluginKey:t=Ha,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:s,onElementDragStart:l,onElementDragEnd:c,nestedOptions:a,dragImageProperties:h})=>{const d=document.createElement("div");let u,p=!1,f=null,g=-1,m=null,x=null,w=null,y=null;function b(){w=null,y=null}function v(t,e){y&&(y=function(t,e,n){if(!e.docChanged)return t;if(n.isChangeOrigin&&null!=t.relativeAnchorPos){const e=n.getAbsolutePos(t.relativeAnchorPos);return!Number.isFinite(e)||e<=0?null:{...t,anchorPos:e}}const r=e.mapping.mapResult(t.anchorPos,1);return r.deleted?null:{...t,anchorPos:r.pos}}(y,t,{isChangeOrigin:ga(t),getAbsolutePos:t=>Fa(e,t)}))}function S(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function k(t){const n=(null==i?void 0:i())||{getBoundingClientRect:()=>t.getBoundingClientRect()};o.computePosition(n,e,r).then(t=>{Object.assign(e.style,{position:t.strategy,left:`${t.x}px`,top:`${t.y}px`})})}function C(t){var r,i;l?.(t),Ra(t,n,a,{node:f,pos:g},h),r=n.state.selection,w=ka(r)?{anchorPos:r.from,nodeCount:r.ranges.length,depth:null!=(i=r.depth)?i:0}:null,e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function E(t){c?.(t),w=null,S(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function _(t){if(!t.target||!n.view.dom.contains(t.target))return;if((0,K.isFirefox)()){const t=n.view.dom;requestAnimationFrame(()=>{t.isContentEditable&&(t.contentEditable="false",t.contentEditable="true")})}if(!w||n.view.state.selection.empty)return;const e=n.state.selection.from,r=Ua(n.state,e);y={...w,anchorPos:e,relativeAnchorPos:null!=r?r:void 0},n.view.dispatch(n.state.tr.setMeta("addToHistory",!1))}function A(){e.removeEventListener("dragstart",C),e.removeEventListener("dragend",E),document.removeEventListener("drop",_),m&&(cancelAnimationFrame(m),m=null,x=null),b()}return d.appendChild(e),{unbind(){A()},plugin:new W.Plugin({key:"string"==typeof t?new W.PluginKey(t):t,state:{init:()=>({locked:!1}),apply(t,r,i,o){v(t,o);const l=t.getMeta("lockDragHandle"),c=t.getMeta("hideDragHandle");if(void 0!==l&&(p=l),c)return S(),p=!1,f=null,g=-1,s?.({editor:n,node:null,pos:-1}),r;if(t.docChanged&&-1!==g&&e)if(ga(t)){const t=Fa(o,u);t!==g&&(g=t)}else{const e=t.mapping.map(g);e!==g&&(g=e,u=Ua(o,g))}return r}},appendTransaction:(t,e,n)=>function(t){if(!y)return null;const e=La(t.doc,y.anchorPos,y.nodeCount,y.depth);return e?(b(),t.tr.setSelection(e)):(y=null,w=null,null)}(n),view:t=>{var r;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",null==(r=n.view.dom.parentElement)||r.appendChild(d),d.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.left="0",d.style.zIndex="10",e.addEventListener("dragstart",C),e.addEventListener("dragend",E),document.addEventListener("drop",_),{update(r,i){if(!e)return;if(!n.isEditable)return void S();if(e.draggable=!p,t.state.doc.eq(i.doc)||-1===g)return;let o=t.nodeDOM(g);if(o=$a(t,o),o===t.dom)return;if(1!==(null==o?void 0:o.nodeType))return;const l=t.posAtDOM(o,0),c=Pa(n.state.doc,l),a=za(n.state.doc,l);f=c,g=a,u=Ua(t.state,g),s?.({editor:n,node:f,pos:g}),k(o)},destroy(){A(),e&&Na(d)}}},props:{handleDOMEvents:{keydown:t=>!(!e||p)&&(!!t.hasFocus()&&(S(),f=null,g=-1,s?.({editor:n,node:null,pos:-1}),!1)),mouseleave:(t,e)=>(p||e.target&&!d.contains(e.relatedTarget)&&(S(),f=null,g=-1,s?.({editor:n,node:null,pos:-1})),!1),mousemove:(t,r)=>!(!e||p)&&(x={x:r.clientX,y:r.clientY},m||(m=requestAnimationFrame(()=>{if(m=null,!x)return;const{x:r,y:i}=x;x=null;const o=Ta({x:r,y:i,direction:"right",editor:n,nestedOptions:a});if(!o.resultElement)return;let l=o.resultElement,c=o.resultNode,h=o.pos;if(!(null==a?void 0:a.enabled)){if(l=$a(t,l),l===t.dom)return;if(1!==(null==l?void 0:l.nodeType))return;const e=t.posAtDOM(l,0);c=Pa(n.state.doc,e),h=za(n.state.doc,e)}c!==f&&(f=c,g=null!=h?h:-1,u=Ua(t.state,g),s?.({editor:n,node:f,pos:g}),k(l),e&&(n.isEditable?(e.style.visibility="",e.style.pointerEvents="auto"):S()))})),!1)}}})}};function qa(t){var e,n;return!1===t||void 0===t?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Aa("none")}:!0===t?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Aa("left")}:{enabled:!0,rules:null!=(e=t.rules)?e:[],defaultRules:null==(n=t.defaultRules)||n,allowedContainers:t.allowedContainers,edgeDetection:Aa(t.edgeDetection)}}var Ja={placement:"left-start",strategy:"absolute"},Ka=(K.Extension.create({name:"dragHandle",addOptions:()=>({render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}),addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=qa(this.options.nested);return[Va({computePositionConfig:{...Ja,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}}),t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:i=Ha,onNodeChange:s,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:c,computePositionConfig:a=Ja,nested:h=!1}=t,d=(0,H.useRef)(null);null===d.current&&"undefined"!=typeof document&&(d.current=document.createElement("div"));const u=(0,H.useMemo)(()=>qa(h),[JSON.stringify(h)]);(0,H.useEffect)(()=>{const t=d.current;t&&(t.className=e)},[e]),(0,H.useEffect)(()=>{if("undefined"==typeof document)return;if(r.isDestroyed)return;const t=d.current;if(!t)return;t.style.visibility="hidden",t.style.position="absolute",t.dataset.dragging="false";const{plugin:e,unbind:n}=Va({editor:r,element:t,pluginKey:i,computePositionConfig:{...Ja,...a},onElementDragStart:o,onElementDragEnd:l,onNodeChange:s,getReferencedVirtualElement:c,nestedOptions:u});return r.registerPlugin(e),()=>{r.isDestroyed||r.unregisterPlugin(i),n()}},[r,s,c,i,a,o,l,u]);const p=d.current;return p?(0,J.createPortal)(n,p):null});var Wa={plaintext:"Plain Text",js:"JavaScript",ts:"TypeScript",css:"CSS",html:"HTML",python:"Python",bash:"Bash"};function Ga({listLanguages:t}){const{t:n}=r.useLocale(),[s,o]=(0,H.useState)(!1),l=m.useEditorInstance(),c=(0,H.useMemo)(()=>{const{selection:t}=l.state,e=t.$from.parent;if("codeBlock"===e.type.name){const t=e.attrs.language||"plaintext";return Wa[t]||t}},[l.state,t]),a=(0,H.useMemo)(()=>{let e=t||[];return t?.includes("plaintext")||(e=["plaintext",...e]),e.map(t=>({label:Wa[t]||t,value:t}))},[t]);return(0,V.jsxs)(d.Popover,{modal:!0,onOpenChange:o,open:s,children:[(0,V.jsx)(d.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:(0,V.jsxs)(e.ActionButton,{dataState:!!c,children:[c?(0,V.jsx)(V.Fragment,{children:c}):(0,V.jsx)(V.Fragment,{children:n("editor.paragraph.tooltip")}),(0,V.jsx)(i.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})]})}),(0,V.jsx)(d.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:a?.map(t=>(0,V.jsxs)("div",{className:"richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",onClick:e=>{e.preventDefault(),l.chain().focus().setCodeBlock({language:t.value}).run(),o(!1)},children:[(0,V.jsx)("div",{className:"!richtext-min-w-[20px]",children:c===t.value&&(0,V.jsx)(q.Check,{size:16})}),(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:t.label})]},t.value))})]})}exports.RichTextBubbleCallout=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{type:o,title:c,body:d}=b.useAttributes(n,u.Callout.name,{type:"note",title:"",body:""}),[p,f]=(0,H.useState)(!1),[g,x]=(0,H.useState)("note"),[w,y]=(0,H.useState)(""),[v,S]=(0,H.useState)("");(0,H.useEffect)(()=>{p&&(x(o||"note"),y(c||""),S(d||""))},[p,o,c,d]);const k=(0,H.useCallback)(()=>{n&&(n.chain().updateAttributes(u.Callout.name,{type:g,title:w,body:v}).focus().run(),f(!1))},[n,g,w,v]),C=(0,H.useCallback)(()=>{f(!1)},[]),E=(0,H.useCallback)(()=>{St(u.Callout.name,n)},[n]),_=(0,H.useCallback)(()=>n.isActive(u.Callout.name),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:_,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsxs)(l.Dialog,{onOpenChange:f,open:p,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:i("editor.callout.edit.title")})}),(0,V.jsxs)(l.DialogContent,{children:[(0,V.jsx)(l.DialogTitle,{children:i("editor.callout.edit.title")}),(0,V.jsxs)("div",{className:"richtext-space-y-4 richtext-py-4",children:[(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.type")}),(0,V.jsxs)(u.Select,{onValueChange:x,value:g,children:[(0,V.jsx)(u.SelectTrigger,{children:(0,V.jsx)(u.SelectValue,{className:"richtext-text-accent",placeholder:i("editor.callout.dialog.type.placeholder")})}),(0,V.jsx)(u.SelectContent,{children:kt.map(t=>(0,V.jsx)(u.SelectItem,{value:t.value,children:i(`editor.callout.type.${t.value}`)},t.value))})]})]}),(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.title.label")}),(0,V.jsx)(a.Input,{onChange:t=>y(t.target.value),placeholder:i("editor.callout.dialog.title.placeholder"),type:"text",value:w})]}),(0,V.jsxs)("div",{className:"richtext-space-y-2",children:[(0,V.jsx)(h.Label,{children:i("editor.callout.dialog.body.label")}),(0,V.jsx)(a.Input,{onChange:t=>S(t.target.value),placeholder:i("editor.callout.dialog.body.placeholder"),type:"text",value:v})]})]}),(0,V.jsxs)(l.DialogFooter,{children:[(0,V.jsx)(s.Button,{onClick:C,variant:"outline",children:i("editor.callout.dialog.button.cancel")}),(0,V.jsx)(s.Button,{onClick:k,children:i("editor.callout.dialog.button.apply")})]})]})]}),(0,V.jsx)(e.ActionButton,{action:E,icon:"Trash2",tooltip:i("editor.delete")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleCodeBlock=function(){const t=m.useEditableEditor(),r=m.useEditorInstance(),i=m.useExtension(F.CodeBlock.name),s=(0,H.useCallback)(({editor:t})=>t.isActive(F.CodeBlock.name),[]),o=(0,H.useMemo)(()=>i?i.options?.lowlight?.listLanguages?.()||["plaintext","html","css","js","ts"]:[],[i]),l=(0,H.useCallback)(()=>St(F.CodeBlock.name,r),[r]);return t?(0,V.jsx)(vt,{editor:r,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleCodeBlock",shouldShow:s,getReferencedVirtualElement:()=>{const{from:t}=r.state.selection,e=r.view.domAtPos(t).node.parentElement;return e?{getBoundingClientRect:()=>e.getBoundingClientRect()}:null},children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(Ga,{listLanguages:o}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(e.ActionButton,{action:()=>{const t=(()=>{const{from:t}=r.state.selection,e=r.state.doc.resolve(t);for(let n=e.depth;n>=0;n--){const t=e.node(n);if("codeBlock"===t.type.name)return t.textContent}return""})();navigator.clipboard.writeText(t)},tooltip:"Copy",children:(0,V.jsx)(q.Copy,{size:16})}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),(0,V.jsx)(e.ActionButton,{action:l,tooltip:"Delete",children:(0,V.jsx)(q.Trash2,{size:16})})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleColumns=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),s=(0,H.useCallback)(()=>n.isActive(v.MultipleColumnNode.name),[n]),o=(0,H.useCallback)(()=>St(v.MultipleColumnNode.name,n),[n]),l=(0,H.useCallback)(()=>n.chain().focus().addColBefore().run(),[n]),c=(0,H.useCallback)(()=>n.chain().focus().addColAfter().run(),[n]),a=(0,H.useCallback)(()=>n.chain().focus().deleteCol().run(),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleColumns",shouldShow:s,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:l,icon:"ColumnAddLeft",tooltip:i("editor.table.menu.insertColumnBefore")}),(0,V.jsx)(e.ActionButton,{action:c,icon:"ColumnAddRight",tooltip:i("editor.table.menu.insertColumnAfter")}),(0,V.jsx)(e.ActionButton,{action:a,icon:"DeleteColumn",tooltip:i("editor.table.menu.deleteColumn")}),(0,V.jsx)(e.ActionButton,{action:o,icon:"Trash2",tooltip:i("editor.table.menu.delete_column")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleDrawer=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=b.useAttributes(s,S.Drawer.name),l=m.useExtension(S.Drawer.name),c=(0,H.useMemo)(()=>function(t,n){return[...Dt(t,n),{type:"edit",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawer",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(t.type.name===S.Drawer.name)return i=!0,!1}),i},children:c?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:c?.map((t,e)=>"edit"===t.type&&o?.src?(0,V.jsx)(Mt,{attrs:o,editor:s,extension:l},`bubbleMenu-drawer-${e}`):(0,V.jsx)(Nt,{editor:s,item:t},`bubbleMenu-drawer-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleDrawio=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{width:s}=function(t){const e=t.options.element;zt.has("width")||zt.set("width",e.clientWidth),zt.has("width")&&zt.get("width")<=0&&zt.set("width",e.clientWidth);const n=new MutationObserver(function(){zt.set("width",e.clientWidth)});return n.observe(e,{attributes:!0,childList:!0,subtree:!0}),t.on("destroy",()=>{n.disconnect()}),{width:zt.get("width")}}(n),o=b.useAttributes(n,y.Drawio.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:l,createUser:c,width:a,height:h}=o,d=(0,H.useCallback)(t=>{n.chain().updateAttributes(y.Drawio.name,t).setNodeSelection(n.state.selection.from).focus().run()},[n]),u=(0,H.useCallback)(()=>{const t=g.EVENTS.DRAWIO?.(n.id)||`drawio-${n.id}`;g.emit(t,o)},[n,o]),p=(0,H.useCallback)(()=>n.isActive(y.Drawio.name),[n]),f=(0,H.useCallback)(()=>St(y.Drawio.name,n),[n]);return(0,H.useEffect)(()=>{l&&(u(),n.chain().updateAttributes(y.Drawio.name,{defaultShowPicker:!1}).focus().run())},[c,l,n,u]),t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawio",shouldShow:p,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:u,icon:"Pencil",tooltip:i("editor.edit")}),(0,V.jsx)(Rt,{height:h,maxWidth:s,onOk:d,width:a,children:(0,V.jsx)(e.ActionButton,{icon:"Settings",tooltip:i("editor.settings")})}),(0,V.jsx)(e.ActionButton,{action:f,icon:"Trash2",tooltip:i("editor.delete")})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleIframe=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),{t:i}=r.useLocale(),{width:o,height:c,src:h}=b.useAttributes(n,C.Iframe.name,{width:0,height:0,src:"",defaultShowPicker:!1}),[d,u]=(0,H.useState)(!1),[p,f]=(0,H.useState)(""),g=(0,H.useCallback)(t=>{t?.preventDefault?.(),u(!1)},[u]);(0,H.useEffect)(()=>{d&&f(h)},[d,h]);const x=(0,H.useCallback)(t=>{t?.preventDefault?.();const e=C.getServiceSrc(p);n.chain().updateAttributes(C.Iframe.name,{src:e?.src||p}).setNodeSelection(n.state.selection.from).focus().run(),u(!1)},[n,p,u]),w=(0,H.useCallback)(()=>{window.open(h,"_blank")},[h]),y=(0,H.useCallback)(t=>{n.chain().updateAttributes(C.Iframe.name,t).setNodeSelection(n.state.selection.from).focus().run()},[n]),v=(0,H.useCallback)(()=>n.isActive(C.Iframe.name)&&!h,[n,h]),S=(0,H.useCallback)(()=>St(C.Iframe.name,n),[n]);return t?(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleIframe",shouldShow:v,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{action:w,icon:"Eye",tooltip:"Visit Link"}),(0,V.jsxs)(l.Dialog,{onOpenChange:u,open:d,children:[(0,V.jsx)(l.DialogTrigger,{asChild:!0,children:(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:"Open Edit Link"})}),(0,V.jsxs)(l.DialogContent,{children:[(0,V.jsx)(l.DialogHeader,{children:(0,V.jsx)(l.DialogTitle,{children:"Edit Link Iframe"})}),(0,V.jsx)(a.Input,{autoFocus:!0,onInput:t=>f(t.target.value),placeholder:"Enter link",type:"url",value:p}),(0,V.jsxs)(l.DialogFooter,{children:[(0,V.jsx)(s.Button,{onClick:g,type:"button",children:"Cancel"}),(0,V.jsx)(s.Button,{onClick:x,type:"button",children:"OK"})]})]})]}),(0,V.jsx)(Rt,{height:c,onOk:y,width:o,children:(0,V.jsx)(e.ActionButton,{icon:"Settings",tooltip:i("editor.settings")})}),(0,V.jsx)(e.ActionButton,{action:S,icon:"Trash2",tooltip:i("editor.delete")})]})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleImage=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=(0,H.useMemo)(()=>function(t,n){return[{type:"flipX",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const{flipX:e}=t.getAttributes("image");t.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!e}).run()}}},{type:"flipY",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const{flipY:e}=t.getAttributes("image");t.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!e}).run()}}},...Ct(t,n),..._t(t,n),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImage",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===f.Image.name}(t))return i=!0,!1}),i},children:o?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:o?.map((t,e)=>(0,V.jsx)(Lt,{editor:s,item:t},`bubbleMenu-image-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleImageGif=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=(0,H.useMemo)(()=>function(t,n){return[...Et(t,n),...At(t,n),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,n,t]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImageGif",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===A.ImageGif.name}(t))return i=!0,!1}),i},children:o?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:o?.map((t,e)=>(0,V.jsx)(Lt,{editor:s,item:t},`bubbleMenu-image-gif-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleKatex=function(){const t=m.useEditableEditor(),n=m.useEditorInstance(),[r,i]=(0,H.useState)(!1),s=(0,H.useCallback)(()=>n.isActive(b.Katex.name),[n]),o=(0,H.useCallback)(()=>St(b.Katex.name,n),[n]);return t?(0,V.jsx)(vt,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleKatex",shouldShow:s,children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(Pt,{toggleVisible:i,visible:r,children:(0,V.jsx)(e.ActionButton,{action:()=>i(!r),tooltip:"Edit",children:(0,V.jsx)(q.Pencil,{size:16})})}),(0,V.jsx)(e.ActionButton,{action:o,tooltip:"Delete",children:(0,V.jsx)(q.Trash2,{size:16})})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleLink=function(){const t=m.useEditableEditor(),e=m.useEditorInstance(),[n,r]=(0,H.useState)(!1),i=b.useAttributes(e,_.Link.name)?.href,s=(0,H.useCallback)(({editor:t})=>t.isActive(_.Link.name),[]),o=(0,H.useCallback)(()=>{e.chain().extendMarkRange("link").unsetLink().focus().run(),r(!1)},[e]);return t?(0,V.jsx)(vt,{editor:e,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleLink",shouldShow:s,children:(0,V.jsx)(V.Fragment,{children:n?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(_.LinkEditBlock,{editor:e,onClose:()=>{r(!1)},onSetLink:(t,n,i)=>{const{from:s}=e.state.selection,o=s+(n?.length??0);e.chain().extendMarkRange("link").insertContent({type:"text",text:n,marks:[{type:"link",attrs:{href:t,target:i?"_blank":""}}]}).setLink({href:t}).setTextSelection({from:s,to:o}).focus().run(),r(!1)}})}):(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(Bt,{editor:e,link:i,onClear:o,onEdit:()=>{r(!0)}})})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleMenuDragHandle=function(){const t=m.useEditorInstance(),n=m.useEditableEditor(),{t:s}=r.useLocale(),[o,l]=(0,H.useState)(null),[a,h]=(0,H.useState)(-1),[d,u]=(0,H.useState)(!1),p=t?.extensionManager?.extensions?.some(t=>t?.name===z.TextAlign.name),f=t?.extensionManager?.extensions?.some(t=>t?.name===U.Indent.name),g=t?.extensionManager?.extensions?.some(t=>t?.name===L.Clear.name);function x(e){t.commands.setTextAlign(e)}const w=(0,H.useCallback)(t=>{t.node&&l(t.node),h(t.pos),requestAnimationFrame(()=>{t.editor.commands.focus()})},[]);(0,H.useEffect)(()=>(d?t.commands.setMeta("lockDragHandle",!0):t.commands.setMeta("lockDragHandle",!1),()=>{t.commands.setMeta("lockDragHandle",!1)}),[d]);const y=t=>{n&&u(t)};return(0,V.jsx)(Ka,{className:"richtext-transition-all richtext-duration-200 richtext-ease-out",editor:t,onNodeChange:w,pluginKey:"RichTextBubbleMenuDragHandle",children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[(0,V.jsx)(e.ActionButton,{disabled:!n,icon:"Grip",tooltip:s("editor.draghandle.grip"),action:t=>{t.preventDefault(),t.stopPropagation(),y(!d)}}),(0,V.jsxs)(c.DropdownMenu,{onOpenChange:y,open:d,children:[(0,V.jsx)(c.DropdownMenuTrigger,{className:"richtext-pointer-events-none"}),(0,V.jsxs)(c.DropdownMenuContent,{align:"start",className:"richtext-w-48",hideWhenDetached:!0,side:"bottom",sideOffset:0,children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3 richtext-bg-opacity-10 hover:richtext-bg-red-400 hover:richtext-bg-opacity-20 focus:richtext-bg-red-400 focus:richtext-bg-opacity-30 focus:richtext-text-red-500 dark:hover:richtext-bg-opacity-20 dark:hover:richtext-text-red-500",onClick:function(){t.chain().setMeta("hideDragHandle",!0).setNodeSelection(a).deleteSelection().run()},children:[(0,V.jsx)(i.IconComponent,{name:"Trash2"}),(0,V.jsx)("span",{children:s("editor.remove")})]}),g?(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:function(){const e=t.chain();e.setNodeSelection(a).unsetAllMarks(),"paragraph"!==o?.type.name&&e.setParagraph(),e.run()},children:[(0,V.jsx)(i.IconComponent,{name:"PaintRoller"}),(0,V.jsx)("span",{children:s("editor.clear.tooltip")})]}):null,(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:function(){t.commands.setNodeSelection(a);const{$anchor:e}=t.state.selection,n=e.node(1)||t.state.selection.node;t.chain().setMeta("hideDragHandle",!0).insertContentAt(a+(o?.nodeSize||0),n.toJSON()).run()},children:[(0,V.jsx)(i.IconComponent,{name:"Copy"}),(0,V.jsx)("span",{children:s("editor.copy")})]}),p||f?(0,V.jsx)(c.DropdownMenuSeparator,{}):null,p?(0,V.jsxs)(c.DropdownMenuSub,{children:[(0,V.jsxs)(c.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[(0,V.jsx)(i.IconComponent,{name:"AlignCenter"}),(0,V.jsx)("span",{children:s("editor.textalign.tooltip")})]}),(0,V.jsx)(c.DropdownMenuPortal,{children:(0,V.jsxs)(c.DropdownMenuSubContent,{children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("left"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignLeft"}),(0,V.jsx)("span",{children:s("editor.textalign.left.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("center"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignCenter"}),(0,V.jsx)("span",{children:s("editor.textalign.center.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("right"),children:[(0,V.jsx)(i.IconComponent,{name:"AlignRight"}),(0,V.jsx)("span",{children:s("editor.textalign.right.tooltip")})]})]})})]}):null,f?(0,V.jsxs)(c.DropdownMenuSub,{children:[(0,V.jsxs)(c.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[(0,V.jsx)(i.IconComponent,{name:"IndentIncrease"}),(0,V.jsx)("span",{children:s("editor.indent")})]}),(0,V.jsx)(c.DropdownMenuPortal,{children:(0,V.jsxs)(c.DropdownMenuSubContent,{children:[(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:o?.attrs?.indent>=U.IndentProps.max,onClick:function(){const e=U.setNodeIndentMarkup(t.state.tr,a,1);e.setMeta("hideDragHandle",!0),t.view.dispatch&&t.view.dispatch(e)},children:[(0,V.jsx)(i.IconComponent,{name:"IndentIncrease"}),(0,V.jsx)("span",{children:s("editor.indent.tooltip")})]}),(0,V.jsxs)(c.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:o?.attrs?.indent<=U.IndentProps.min,onClick:function(){const e=U.setNodeIndentMarkup(t.state.tr,a,-1);t.view.dispatch&&t.view.dispatch(e)},children:[(0,V.jsx)(i.IconComponent,{name:"IndentDecrease"}),(0,V.jsx)("span",{children:s("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})},exports.RichTextBubbleMermaid=function(){const{lang:t,t:n}=r.useLocale(),i=m.useEditableEditor(),s=m.useEditorInstance(),o=b.useAttributes(s,j.Mermaid.name),l=m.useExtension(j.Mermaid.name),c=(0,H.useMemo)(()=>function(t,n){return[...jt(t,n),{type:"edit",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(s,n),[s,t,n]);return i?(0,V.jsx)(vt,{editor:s,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleMermaid",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===j.Mermaid.name}(t))return i=!0,!1}),i},children:c?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:c?.map((t,e)=>"edit"===t.type&&o?.src?(0,V.jsx)(Ft,{attrs:o,editor:s,extension:l},`bubbleMenu-mermaid-${e}`):(0,V.jsx)($t,{editor:s,item:t},`bubbleMenu-mermaid-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleTable=function({hiddenActions:t=[]}){const{t:i}=r.useLocale(),s=m.useEditableEditor(),o=m.useEditorInstance(),l=e=>t.includes(e);return s?(0,V.jsx)(vt,{editor:o,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTable",shouldShow:({editor:t})=>(0,K.isActive)(t.view.state,D.Table.name),children:(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[!l("addColumnBefore")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addColumnBefore().run()},disabled:!o?.can()?.addColumnBefore?.(),icon:"BetweenHorizonalEnd",tooltip:i("editor.table.menu.insertColumnBefore"),tooltipOptions:{sideOffset:15}}),!l("addColumnAfter")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addColumnAfter().run()},disabled:!o?.can()?.addColumnAfter?.(),icon:"BetweenHorizonalStart",tooltip:i("editor.table.menu.insertColumnAfter"),tooltipOptions:{sideOffset:15}}),!l("deleteColumn")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteColumn().run()},disabled:!o?.can().deleteColumn?.(),icon:"DeleteColumn",tooltip:i("editor.table.menu.deleteColumn"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("addRowAbove")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addRowBefore().run()},disabled:!o?.can().addRowBefore?.(),icon:"BetweenVerticalEnd",tooltip:i("editor.table.menu.insertRowAbove"),tooltipOptions:{sideOffset:15}}),!l("addRowBelow")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().addRowAfter().run()},disabled:!o?.can()?.addRowAfter?.(),icon:"BetweenVerticalStart",tooltip:i("editor.table.menu.insertRowBelow"),tooltipOptions:{sideOffset:15}}),!l("deleteRow")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteRow().run()},disabled:!o?.can()?.deleteRow?.(),icon:"DeleteRow",tooltip:i("editor.table.menu.deleteRow"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("mergeCells")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().mergeCells().run()},disabled:!o?.can()?.mergeCells?.(),icon:"TableCellsMerge",tooltip:i("editor.table.menu.mergeCells"),tooltipOptions:{sideOffset:15}}),!l("splitCells")&&(0,V.jsx)(e.ActionButton,{action:function(){o?.chain().focus().splitCell().run()},disabled:!o?.can()?.splitCell?.(),icon:"TableCellsSplit",tooltip:i("editor.table.menu.splitCells"),tooltipOptions:{sideOffset:15}}),(0,V.jsx)(n.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!l("deleteTable")&&(0,V.jsx)(e.ActionButton,{action:function(){o.chain().focus().deleteTable().run()},disabled:!o?.can()?.deleteTable?.(),icon:"Trash2",tooltip:i("editor.table.menu.deleteTable"),tooltipOptions:{sideOffset:15}})]})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleText=function({buttonBubble:t}){const e=m.useEditorInstance();return m.useEditableEditor()?(0,V.jsx)(vt,{editor:e,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleText",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;return!t.isActive("codeBlock")&&(n.pos!==r&&e instanceof W.TextSelection)},children:t?(0,V.jsx)(V.Fragment,{children:t}):(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(Vt,{})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleTwitter=function(){const{t:t}=r.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),[s,o]=(0,H.useState)(!1),l=(0,H.useCallback)(({editor:t})=>t.isActive(B.Twitter.name),[]),c=(0,H.useCallback)(()=>St(B.Twitter.name,i),[i]);return n?(0,V.jsx)(vt,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTwitter",shouldShow:l,children:(0,V.jsx)(V.Fragment,{children:s?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:(0,V.jsx)(B.FormEditLinkTwitter,{editor:i,onSetLink:t=>{i.commands.updateTweet({src:t}),o(!1)}})}):(0,V.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:[(0,V.jsx)(e.ActionButton,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{o(!0)}}),(0,V.jsx)(e.ActionButton,{action:c,icon:"Trash",tooltip:t("editor.delete"),tooltipOptions:{sideOffset:15}})]})})}):(0,V.jsx)(V.Fragment,{})},exports.RichTextBubbleVideo=function(){const{t:t}=r.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=(0,H.useMemo)(()=>function(t,n){return[...It(t,n),...Ot(t),{type:"remove",component:e.ActionButton,componentProps:{editor:t,tooltip:n("editor.remove"),icon:"Trash2",action:()=>{const{state:e,dispatch:n}=t.view;(0,Q.deleteSelection)(e,n)}}}]}(i,t),[i,t]);return n?(0,V.jsx)(vt,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleVideo",shouldShow:({editor:t})=>{const{selection:e}=t.view.state,{$from:n,to:r}=e;let i=!1;return t.view.state.doc.nodesBetween(n.pos,r,t=>{if(function(t){return t.type.name===w.Video.name}(t))return i=!0,!1}),i},children:s?.length?(0,V.jsx)("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",children:s?.map((t,e)=>(0,V.jsx)(Lt,{editor:i,item:t},`bubbleMenu-video-${e}`))}):(0,V.jsx)(V.Fragment,{})}):(0,V.jsx)(V.Fragment,{})};
|