reactjs-tiptap-editor 1.0.18 → 1.0.19
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/lib/{ActionMenuButton-BOjCHFTA.js → ActionMenuButton-B1Nfn5Hm.js} +1 -1
- package/lib/{ActionMenuButton-Df077oOH.cjs → ActionMenuButton-D3b_bcin.cjs} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +23 -23
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.js +33 -28
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +16 -10
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +21 -22
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +37 -37
- package/lib/CodeBlock.js +15 -16
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-DxOoRiGQ.js → Drawer-B1-7Y4HB.js} +3 -3
- package/lib/{Drawer-DwrlY_lY.cjs → Drawer-kEO7KzzC.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +12 -12
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +17 -17
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +4 -4
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +9 -9
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +1 -1
- package/lib/History.js +5 -3
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-C6pBw-AF.cjs → Iframe-Bk5OIlvy.cjs} +1 -1
- package/lib/{Iframe-AhNV5WH5.js → Iframe-XlAb03_r.js} +7 -7
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +6 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +36 -36
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +13 -13
- package/lib/{Indent-Do-X0AsY.cjs → Indent-XaZNTsOk.cjs} +1 -1
- package/lib/{Indent-DZ5PcJA4.js → Indent-ruPuj5xn.js} +2 -2
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +24 -18
- package/lib/Katex-BFIYLrwm.cjs +4 -0
- package/lib/{Katex-bIgoenn_.js → Katex-DKspCn-p.js} +5 -6
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +3 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-D_cF9fnc.js → LinkEditBlock-BWm2Ypt2.js} +26 -26
- package/lib/{LinkEditBlock-B0ZaACZO.cjs → LinkEditBlock-DhesHreq.cjs} +1 -1
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +4 -4
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +41 -42
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +8 -8
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/{SlashCommandNodeView-Ba03hlVZ.cjs → SlashCommandNodeView-CojfS61Q.cjs} +1 -1
- package/lib/{SlashCommandNodeView-cg0x3NRF.js → SlashCommandNodeView-Hf2DX4km.js} +6 -6
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-KqLiT5wG.js → Table-BTkFUATL.js} +4 -4
- package/lib/{Table-ddU2LSc6.cjs → Table-C1_xLqV0.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-BIiR78Jh.cjs → Twitter-Cj-0yyQQ.cjs} +1 -1
- package/lib/{Twitter-C1Lzqc7u.js → Twitter-D5mUTILj.js} +9 -9
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +4 -4
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +1835 -1634
- package/lib/{clsx-BWE7vnna.cjs → clsx-BSBE1eoY.cjs} +1 -1
- package/lib/{clsx-eGVyq7ot.js → clsx-OumA9x-8.js} +1 -1
- package/lib/{dropdown-menu-CexIkt_V.js → dropdown-menu-Bragdu5m.js} +1 -1
- package/lib/{dropdown-menu-oSKIntXM.cjs → dropdown-menu-CUeq1boX.cjs} +1 -1
- package/lib/extensions/Image/Image.d.ts +1 -0
- package/lib/{index-D_8P0LE5.js → index-B-7eHzaO.js} +1 -1
- package/lib/{index-RIXs7STX.js → index-BKlbc8Qo.js} +1 -1
- package/lib/index-BLrMslr7.cjs +1 -0
- package/lib/{index-mfGK4pFo.js → index-BVRHx_ha.js} +94 -90
- package/lib/{index-DHUN85fV.js → index-CDFAs4RT.js} +1149 -1019
- package/lib/{index-CJ9pyCM4.cjs → index-CMLwKzI0.cjs} +1 -1
- package/lib/index-COCTP78Y.cjs +12 -0
- package/lib/{index-BnW6t8z6.js → index-CZ1_8JQQ.js} +1 -1
- package/lib/{index-D0lc95kr.cjs → index-CnePcUeF.cjs} +1 -1
- package/lib/{index-DUpSE1Gb.cjs → index-D7wfvzJg.cjs} +1 -1
- package/lib/{index-zig3Dj7A.cjs → index-DwSnESy-.cjs} +7 -5
- package/lib/{index-C6xmkxrQ.js → index-cPEuL4Zr.js} +140 -138
- package/lib/index.cjs +1 -1
- package/lib/index.js +12 -12
- package/lib/{popover-BYSZ3zBi.js → popover-C2BbhsXH.js} +1 -1
- package/lib/{popover-BcHDZqBt.cjs → popover-DCJpsZx0.cjs} +1 -1
- package/lib/{renderNodeView-BrM5kUj_.js → renderNodeView-CmnUEfby.js} +2 -2
- package/lib/{renderNodeView-D1zydtli.cjs → renderNodeView-DQjWzXDA.cjs} +1 -1
- package/lib/{separator-BmixLrnJ.cjs → separator-BuG1zwKa.cjs} +1 -1
- package/lib/{separator-CFKVxAea.js → separator-lkMWuUvf.js} +14 -14
- package/lib/{updatePosition-CfmY5Trk.cjs → updatePosition-D6AScA-1.cjs} +1 -1
- package/lib/{updatePosition-CBRjbQMH.js → updatePosition-DYuAiqx-.js} +2 -2
- package/package.json +1 -1
- package/lib/Katex-CIC9ygbL.cjs +0 -4
- package/lib/index-BUTn2LY6.cjs +0 -1
- package/lib/index-BtxvYLJ1.cjs +0 -12
- package/lib/select-C5SHDLFj.js +0 -120
- package/lib/select-DHjzKkcu.cjs +0 -1
- package/lib/textarea-CasDcv3u.cjs +0 -1
- package/lib/textarea-DNLrJoRl.js +0 -20
package/lib/bubble.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var fr=Object.create;var jn=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,xr=Object.prototype.hasOwnProperty;var br=(e,t,n)=>t in e?jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of gr(t))!xr.call(e,s)&&s!==n&&jn(e,s,{get:()=>t[s],enumerable:!(i=pr(t,s))||i.enumerable});return e};var yr=(e,t,n)=>(n=e!=null?fr(mr(e)):{},wr(t||!e||!e.__esModule?jn(n,"default",{value:e,enumerable:!0}):n,e));var Re=(e,t,n)=>br(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),T=require("./index-zig3Dj7A.cjs"),H=require("./index-DUpSE1Gb.cjs"),Y=require("@tiptap/pm/state"),Os=require("./Table-ddU2LSc6.cjs"),js=require("./clsx-BWE7vnna.cjs"),b=require("react"),Rs=require("react-dom"),m=require("./index-BUTn2LY6.cjs"),ae=require("./select-DHjzKkcu.cjs"),Ne=require("./Callout.cjs"),ut=require("./Katex-CIC9ygbL.cjs"),B=require("./index-BqL4vAWE.cjs"),ie=require("./delete-node-CosiBes5.cjs"),qi=require("./Column.cjs");require("./theme.cjs");const Fe=require("./Drawer-DwrlY_lY.cjs"),Ki=require("easydrawer"),Je=require("./shortId-Bfj8TyNr.cjs"),It=require("./separator-BmixLrnJ.cjs"),qt=require("./popover-BcHDZqBt.cjs"),he=require("./Excalidraw.cjs"),Ht=require("./Iframe-C6pBw-AF.cjs"),Sr=require("./ImageGif.cjs"),vr=require("katex"),Xe=require("lucide-react"),Jn=require("./textarea-CasDcv3u.cjs"),Ve=require("./LinkEditBlock-B0ZaACZO.cjs"),Rn=require("@tiptap/pm/view"),kr=require("@tiptap/pm/model"),Cr=require("./Clear.cjs"),ue=require("./Indent-Do-X0AsY.cjs"),Ns=require("./TextAlign.cjs"),L=require("./dropdown-menu-oSKIntXM.cjs"),Xn=require("./Mermaid.cjs"),Er=require("./Bold.cjs"),_r=require("./Code.cjs");require("./index-CJ9pyCM4.cjs");const Tr=require("./Color.cjs"),Dr=require("./Highlight.cjs"),Ir=require("./Italic.cjs"),Ar=require("./SlashCommandNodeView-Ba03hlVZ.cjs"),Mr=require("./Strike.cjs"),Or=require("./TextUnderline.cjs"),Nn=require("./Twitter-BIiR78Jh.cjs");function jr(e,t){const n=Math.min(e.top,t.top),i=Math.max(e.bottom,t.bottom),s=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-s,l=i-n,c=s,a=n;return new DOMRect(c,a,r,l)}var Rr=class{constructor({editor:e,element:t,view:n,pluginKey:i="bubbleMenu",updateDelay:s=250,resizeDelay:o=60,shouldShow:r,appendTo:l,getReferencedVirtualElement:c,options:a}){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:h,state:f,from:p,to:g})=>{const{doc:x,selection:w}=f,{empty:y}=w,v=!x.textBetween(p,g).length&&T.isTextSelection(f.selection),C=this.element.contains(document.activeElement);return!(!(h.hasFocus()||C)||y||v||!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:h})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(h,f)=>{const p=!(f!=null&&f.selection.eq(h.state.selection)),g=!(f!=null&&f.doc.eq(h.state.doc));!p&&!g||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(h,p,g,f)},this.updateDelay))},this.updateHandler=(h,f,p,g)=>{const{composing:x}=h;if(x||!f&&!p)return;if(!this.getShouldShow(g)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:h})=>{const f=h.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"&&this.updateOptions(f.options)};var u;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=(u=a==null?void 0:a.scrollTarget)!=null?u:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,r&&(this.shouldShow=r),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 e=[];return this.floatingUIOptions.flip&&e.push(H.flip(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(H.shift(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(H.offset(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(H.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(H.size(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(H.autoPlacement(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(H.hide(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(H.inline(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,n;const{selection:i}=this.editor.state,s=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(s)return s;if(!((n=(t=this.view)==null?void 0:t.dom)!=null&&n.parentNode))return;const o=T.posToDOMRect(this.view,i.from,i.to);let r={getBoundingClientRect:()=>o,getClientRects:()=>[o]};if(i instanceof Y.NodeSelection){let l=this.view.nodeDOM(i.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(r={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(i instanceof Os.CellSelection){const{$anchorCell:l,$headCell:c}=i,a=l?l.pos:c.pos,u=c?c.pos:l.pos,h=this.view.nodeDOM(a),f=this.view.nodeDOM(u);if(!h||!f)return;const p=h===f?h.getBoundingClientRect():jr(h.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&H.computePosition(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:i,middlewareData:s})=>{var o,r;if((o=s.hide)!=null&&o.referenceHidden||(r=s.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:n}=e,i=n.selection.from!==n.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,o=Math.min(...s.map(c=>c.$from.pos)),r=Math.max(...s.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:o,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.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(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.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()}},Bs=e=>new Y.Plugin({key:typeof e.pluginKey=="string"?new Y.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Rr({view:t,...e})});T.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Bs({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})]:[]}});var Nr=class{constructor({editor:e,element:t,view:n,pluginKey:i="floatingMenu",updateDelay:s=250,resizeDelay:o=60,options:r,appendTo:l,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:h})=>{const{selection:f}=h,{$anchor:p,empty:g}=f,x=p.depth===1,w=p.parent.isTextblock&&!p.parent.type.spec.code&&!p.parent.textContent&&p.parent.childCount===0&&!this.getTextContent(p.parent);return!(!u.hasFocus()||!g||!x||!w||!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=(u,h,f,p)=>{const{composing:g}=u;if(g||!h&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var h;if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((h=this.element.parentNode)!=null&&h.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const h=u.getMeta(this.pluginKey);h==="updatePosition"?this.updatePosition():h&&typeof h=="object"&&h.type==="updateOptions"&&this.updateOptions(h.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var a;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=(a=r==null?void 0:r.scrollTarget)!=null?a:window,this.floatingUIOptions={...this.floatingUIOptions,...r},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(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(H.flip(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(H.shift(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(H.offset(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(H.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(H.size(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(H.autoPlacement(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(H.hide(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(H.inline(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,o=Math.min(...s.map(c=>c.$from.pos)),r=Math.max(...s.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:o,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to),n={getBoundingClientRect:()=>t,getClientRects:()=>[t]};H.computePosition(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:s,strategy:o,middlewareData:r})=>{var l,c;if((l=r.hide)!=null&&l.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${i}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!(t!=null&&t.selection.eq(e.state.selection)),i=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,n,i,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.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()}},Ls=e=>new Y.Plugin({key:typeof e.pluginKey=="string"?new Y.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Nr({view:t,...e})});T.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[Ls({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})]:[]}});var it=b.forwardRef(({pluginKey:e="bubbleMenu",editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:o=null,getReferencedVirtualElement:r,options:l,children:c,...a},u)=>{const h=b.useRef(document.createElement("div"));typeof u=="function"?u(h.current):u&&(u.current=h.current);const{editor:f}=js.useCurrentEditor(),p=t||f,g={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:e,shouldShow:o,getReferencedVirtualElement:r,options:l},x=b.useRef(g);x.current=g;const[w,y]=b.useState(!1),v=b.useRef(!0);return b.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const C=h.current;C.style.visibility="hidden",C.style.position="absolute";const M=Bs({...x.current,editor:p,element:C});p.registerPlugin(M);const P=x.current.pluginKey;return v.current=!0,y(!0),()=>{y(!1),p.unregisterPlugin(P),window.requestAnimationFrame(()=>{C.parentNode&&C.parentNode.removeChild(C)})}},[p]),b.useEffect(()=>{if(!(!w||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(e,{type:"updateOptions",options:x.current}))}},[w,p,n,i,o,l,s,r]),Rs.createPortal(d.jsx("div",{...a,children:c}),h.current)});b.forwardRef(({pluginKey:e="floatingMenu",editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:o=null,options:r,children:l,...c},a)=>{const u=b.useRef(document.createElement("div"));typeof a=="function"?a(u.current):a&&(a.current=u.current);const{editor:h}=js.useCurrentEditor(),f=t||h,p={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:e,shouldShow:o,options:r},g=b.useRef(p);g.current=p;const[x,w]=b.useState(!1),y=b.useRef(!0);return b.useEffect(()=>{if(f!=null&&f.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const v=u.current;v.style.visibility="hidden",v.style.position="absolute";const C=Ls({...g.current,editor:f,element:v});f.registerPlugin(C);const M=g.current.pluginKey;return y.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(M),window.requestAnimationFrame(()=>{v.parentNode&&v.parentNode.removeChild(v)})}},[f]),b.useEffect(()=>{if(!(!x||!f||f.isDestroyed)){if(y.current){y.current=!1;return}f.view.dispatch(f.state.tr.setMeta(e,{type:"updateOptions",options:g.current}))}},[x,f,n,i,o,r,s]),Rs.createPortal(d.jsx("div",{...c,children:l}),u.current)});const Br=[{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 Lr(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{type:i,title:s,body:o}=ut.useAttributes(t,Ne.Callout.name,{type:"note",title:"",body:""}),[r,l]=b.useState(!1),[c,a]=b.useState("note"),[u,h]=b.useState(""),[f,p]=b.useState("");b.useEffect(()=>{r&&(a(i||"note"),h(s||""),p(o||""))},[r,i,s,o]);const g=b.useCallback(()=>{t&&(t.chain().updateAttributes(Ne.Callout.name,{type:c,title:u,body:f}).focus().run(),l(!1))},[t,c,u,f]),x=b.useCallback(()=>{l(!1)},[]),w=b.useCallback(()=>{ie.deleteNode(Ne.Callout.name,t)},[t]),y=b.useCallback(()=>t.isActive(Ne.Callout.name),[t]);return e?d.jsx(it,{editor:t,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:y,children:d.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:[d.jsxs(m.Dialog,{onOpenChange:l,open:r,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{icon:"Pencil",tooltip:n("editor.callout.edit.title")})}),d.jsxs(m.DialogContent,{children:[d.jsx(m.DialogTitle,{children:n("editor.callout.edit.title")}),d.jsxs("div",{className:"richtext-space-y-4 richtext-py-4",children:[d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.type")}),d.jsxs(ae.Select,{onValueChange:a,value:c,children:[d.jsx(ae.SelectTrigger,{children:d.jsx(ae.SelectValue,{className:"richtext-text-accent",placeholder:n("editor.callout.dialog.type.placeholder")})}),d.jsx(ae.SelectContent,{children:Br.map(v=>d.jsx(ae.SelectItem,{value:v.value,children:n(`editor.callout.type.${v.value}`)},v.value))})]})]}),d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.title.label")}),d.jsx(m.Input,{onChange:v=>h(v.target.value),placeholder:n("editor.callout.dialog.title.placeholder"),type:"text",value:u})]}),d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.body.label")}),d.jsx(m.Input,{onChange:v=>p(v.target.value),placeholder:n("editor.callout.dialog.body.placeholder"),type:"text",value:f})]})]}),d.jsxs(m.DialogFooter,{children:[d.jsx(m.Button,{onClick:x,variant:"outline",children:n("editor.callout.dialog.button.cancel")}),d.jsx(m.Button,{onClick:g,children:n("editor.callout.dialog.button.apply")})]})]})]}),d.jsx(m.ActionButton,{action:w,icon:"Trash2",tooltip:n("editor.delete")})]})}):d.jsx(d.Fragment,{})}function Ur(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),i=b.useCallback(()=>t.isActive(qi.MultipleColumnNode.name),[t]),s=b.useCallback(()=>ie.deleteNode(qi.MultipleColumnNode.name,t),[t]),o=b.useCallback(()=>t.chain().focus().addColBefore().run(),[t]),r=b.useCallback(()=>t.chain().focus().addColAfter().run(),[t]),l=b.useCallback(()=>t.chain().focus().deleteCol().run(),[t]);return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleColumns",shouldShow:i,children:d.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:[d.jsx(m.ActionButton,{action:o,icon:"ColumnAddLeft",tooltip:n("editor.table.menu.insertColumnBefore")}),d.jsx(m.ActionButton,{action:r,icon:"ColumnAddRight",tooltip:n("editor.table.menu.insertColumnAfter")}),d.jsx(m.ActionButton,{action:l,icon:"DeleteColumn",tooltip:n("editor.table.menu.deleteColumn")}),d.jsx(m.ActionButton,{action:s,icon:"Trash2",tooltip:n("editor.table.menu.delete_column")})]})}):d.jsx(d.Fragment,{})}function Pr(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,o)=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>e.commands.updateImage({width:B.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:B.IMAGE_SIZE[s]})}}))}function $r(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,o)=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>e.commands.updateImageGif({width:B.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:B.IMAGE_SIZE[s]})}}))}function Fr(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var o,r;return(r=(o=e.commands)==null?void 0:o.setAlignImage)==null?void 0:r.call(o,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Vr(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var o,r;return(r=(o=e.commands)==null?void 0:o.setAlignImageGif)==null?void 0:r.call(o,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Hr(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var o,r;return(r=(o=e.commands)==null?void 0:o.setAlignImageMermaid)==null?void 0:r.call(o,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function zr(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var o,r;return(r=(o=e.commands)==null?void 0:o.setAlignImageDrawer)==null?void 0:r.call(o,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function qr(e){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:m.ActionButton,componentProps:{tooltip:n.tooltip,icon:n.icon,action:()=>e.commands.updateVideo({align:n.type}),isActive:()=>e.getAttributes("video").align===n.type}}))}function Kr(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,o)=>({type:`video-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[o],action:()=>e.commands.updateVideo({width:B.VIDEO_SIZE[s]}),isActive:()=>e.isActive("video",{width:B.VIDEO_SIZE[s]})}}))}function Wr(e,t){return[{type:"flipX",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const n=e.getAttributes("image"),{flipX:i}=n;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!i}).run()}}},{type:"flipY",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const n=e.getAttributes("image"),{flipY:i}=n;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!i}).run()}}},...Pr(e,t),...Fr(e,t),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function Gr(e,t){return[...$r(e,t),...Vr(e,t),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function Yr(e,t){return[...Hr(e,t),{type:"edit",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function Jr(e,t){return[...zr(e,t),{type:"edit",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function Xr(e,t){return[...Kr(e,t),...qr(e),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}let de=!1;function Zr({editor:e,attrs:t,extension:n}){const[i,s]=b.useState(!1),o=b.useRef(null),r=b.useRef(null),{alt:l,align:c}=t,a=n==null?void 0:n.options.upload,u=()=>{(async()=>{const k=document.querySelector("#easydrawer");k&&(o.current=new Ki.Editor(k,{wheelEventsEnabled:!1,disableZoom:!0}),r.current=Ki.makeDropdownToolbar(o.current),r.current.addDefaultToolWidgets(),o.current.loadFromSVG(decodeURIComponent(l)))})()};b.useEffect(()=>{i&&setTimeout(()=>{u()},200)},[i]);const h=async()=>{if(o.current){const S=o.current.toSVG(),k=S.outerHTML,D=`drawer-${Je.shortId()}.svg`;let z=Je.i(S.outerHTML);if(a){const N=m.dataURLtoFile(z,D);z=await a(N)}e==null||e.chain().focus().setDrawer({type:"drawer",src:z,alt:encodeURIComponent(k),width:426,height:212},!!k).run(),e==null||e.commands.setAlignImageDrawer(c)}s(!1)},f=S=>{const k=o.current.toolController.getPrimaryTools()[2],D=r.current.getWidgetById("pen-1");k&&D&&(k.setColor(S),D.serializeState())},p=S=>{const k=o.current.toolController.getPrimaryTools()[2],D=r.current.getWidgetById("pen-1");k&&D&&(k.setThickness(S),D.serializeState())},g=S=>{const k=o.current.toolController.getPrimaryTools()[3],D=r.current.getWidgetById("pen-2");k&&D&&(k.setColor(S),D.serializeState())},x=S=>{const k=r.current.getWidgetById("shape");k&&k.setShapeType(S)},w=S=>{const k=o.current.toolController.getPrimaryTools()[5],D=r.current.getWidgetById("shape");k&&D&&(k.setColor(S),D.serializeState())},y=S=>{const k=o.current.toolController.getPrimaryTools()[5],D=r.current.getWidgetById("shape");k&&D&&(k.setThickness(S),D.serializeState())},v=S=>{const k=o.current.toolController.getPrimaryTools()[5],D=r.current.getWidgetById("shape");k&&D&&(k.setBorderColor(S),D.serializeState())},C=()=>{if(de){for(;o.current.history.redoStackSize>0;)o.current.history.redo();de=!1;return}o.current.history.undo()},M=()=>{de||o.current.history.redo()},P=()=>{if(!de){for(;o.current.history.undoStackSize>0;)C();de=!0}};return d.jsxs(m.Dialog,{onOpenChange:s,open:i,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{action:()=>s(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:"Edit Drawer"}),d.jsxs("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[d.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),d.jsx(Fe.ControlDrawer,{changeBorderColorShape:v,changeColorShape:w,changeShape:x,onClear:P,onRedo:M,onThicknessChange:y,onUndo:C,refEditor:o,setColorHighlight:g,setColorPen:f,setThicknessPen:p})]}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:h,type:"button",children:"Save changes"})})]})]})}function Qr({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):d.jsx(d.Fragment,{})}function tl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=ut.useAttributes(i,Fe.Drawer.name),o=m.useExtension(Fe.Drawer.name),r=({editor:c})=>{const{selection:a}=c.view.state,{$from:u,to:h}=a;let f=!1;return c.view.state.doc.nodesBetween(u.pos,h,p=>{if(p.type.name===Fe.Drawer.name)return f=!0,!1}),f},l=b.useMemo(()=>Jr(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawer",shouldShow:r,children:l!=null&&l.length?d.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:l==null?void 0:l.map((c,a)=>c.type==="edit"&&(s!=null&&s.src)?d.jsx(Zr,{attrs:s,editor:i,extension:o},`bubbleMenu-drawer-${a}`):d.jsx(Qr,{editor:i,item:c},`bubbleMenu-drawer-${a}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}const Us=({width:e,maxWidth:t,height:n,onOk:i,children:s})=>{const{t:o}=B.useLocale(),[r,l]=b.useState({width:"",height:"",maxWidth:""});b.useEffect(()=>{l({width:e,height:n,maxWidth:t})},[n,t,e]);function c(a){a.preventDefault(),a.stopPropagation(),i(r)}return d.jsxs(qt.Popover,{modal:!0,children:[d.jsx(qt.PopoverTrigger,{asChild:!0,children:s}),d.jsx(qt.PopoverContent,{children:d.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:c,children:[d.jsx(m.Label,{className:"mb-[6px]",children:"Width"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...r,width:a.target.value}),required:!0,type:"number",value:r.width})})}),d.jsx(m.Label,{className:"mb-[6px]",children:"Max Width"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...r,maxWidth:a.target.value}),required:!0,type:"number",value:r.maxWidth})})}),d.jsx(m.Label,{className:"mb-[6px]",children:"Height"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...r,height:a.target.value}),required:!0,type:"number",value:r.height})})}),d.jsx(m.Button,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:o("editor.link.dialog.button.apply")})]})})]})},jt=new Map;function el(e){const t=e.options.element;jt.has("width")||jt.set("width",t.clientWidth),jt.has("width")&&jt.get("width")<=0&&jt.set("width",t.clientWidth);const n={attributes:!0,childList:!0,subtree:!0},i=function(){jt.set("width",t.clientWidth)},s=new MutationObserver(i);return s.observe(t,n),e.on("destroy",()=>{s.disconnect()}),{width:jt.get("width")}}function nl(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{width:i}=el(t),s=ut.useAttributes(t,he.Excalidraw.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:o,createUser:r,width:l,height:c}=s,a=b.useCallback(p=>{t.chain().updateAttributes(he.Excalidraw.name,p).setNodeSelection(t.state.selection.from).focus().run()},[t]),u=b.useCallback(()=>{const p=m.EVENTS.EXCALIDRAW(t.id);m.emit(p,s)},[t,s]),h=b.useCallback(()=>t.isActive(he.Excalidraw.name),[t]),f=b.useCallback(()=>ie.deleteNode(he.Excalidraw.name,t),[t]);return b.useEffect(()=>{o&&(u(),t.chain().updateAttributes(he.Excalidraw.name,{defaultShowPicker:!1}).focus().run())},[r,o,t,u]),e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleExcalidraw",shouldShow:h,children:d.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:[d.jsx(m.ActionButton,{action:u,icon:"Pencil",tooltip:n("editor.edit")}),d.jsx(Us,{height:c,maxWidth:i,onOk:a,width:l,children:d.jsx(m.ActionButton,{icon:"Settings",tooltip:n("editor.settings")})}),d.jsx(m.ActionButton,{action:f,icon:"Trash2",tooltip:n("editor.delete")})]})}):d.jsx(d.Fragment,{})}function il(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{width:i,height:s,src:o}=ut.useAttributes(t,Ht.Iframe.name,{width:0,height:0,src:"",defaultShowPicker:!1}),[r,l]=b.useState(!1),[c,a]=b.useState(""),u=b.useCallback(w=>{var y;(y=w==null?void 0:w.preventDefault)==null||y.call(w),l(!1)},[l]);b.useEffect(()=>{r&&a(o)},[r,o]);const h=b.useCallback(w=>{var v;(v=w==null?void 0:w.preventDefault)==null||v.call(w);const y=Ht.getServiceSrc(c);t.chain().updateAttributes(Ht.Iframe.name,{src:(y==null?void 0:y.src)||c}).setNodeSelection(t.state.selection.from).focus().run(),l(!1)},[t,c,l]),f=b.useCallback(()=>{window.open(o,"_blank")},[o]),p=b.useCallback(w=>{t.chain().updateAttributes(Ht.Iframe.name,w).setNodeSelection(t.state.selection.from).focus().run()},[t]),g=b.useCallback(()=>t.isActive(Ht.Iframe.name)&&!o,[t,o]),x=b.useCallback(()=>ie.deleteNode(Ht.Iframe.name,t),[t]);return e?d.jsx(d.Fragment,{children:d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleIframe",shouldShow:g,children:d.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:[d.jsx(m.ActionButton,{action:f,icon:"Eye",tooltip:"Visit Link"}),d.jsxs(m.Dialog,{onOpenChange:l,open:r,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{icon:"Pencil",tooltip:"Open Edit Link"})}),d.jsxs(m.DialogContent,{children:[d.jsx(m.DialogHeader,{children:d.jsx(m.DialogTitle,{children:"Edit Link Iframe"})}),d.jsx(m.Input,{autoFocus:!0,onInput:w=>a(w.target.value),placeholder:"Enter link",type:"url",value:c}),d.jsxs(m.DialogFooter,{children:[d.jsx(m.Button,{onClick:u,type:"button",children:"Cancel"}),d.jsx(m.Button,{onClick:h,type:"button",children:"OK"})]})]})]}),d.jsx(Us,{height:s,onOk:p,width:i,children:d.jsx(m.ActionButton,{icon:"Settings",tooltip:n("editor.settings")})}),d.jsx(m.ActionButton,{action:x,icon:"Trash2",tooltip:n("editor.delete")})]})})}):d.jsx(d.Fragment,{})}function sl({children:e,visible:t,toggleVisible:n}){const{t:i}=B.useLocale(),s=m.useEditorInstance(),o=ut.useAttributes(s,ut.Katex.name,{text:"",macros:""}),{text:r,macros:l}=o,[c,a]=b.useState(decodeURIComponent(r||"")),[u,h]=b.useState(decodeURIComponent(l||""));b.useEffect(()=>{t&&(a(decodeURIComponent(r||"")),h(decodeURIComponent(l||"")))},[t]);const f=b.useCallback(()=>{s.chain().focus().setKatex({text:encodeURIComponent(c),macros:encodeURIComponent(u)}).run(),a(""),h(""),n(!1)},[s,c,u,n]),p=b.useMemo(()=>{try{return vr.renderToString(c,{macros:ut.safeJSONParse(u||"")})}catch{return c}},[c,u]),g=b.useMemo(()=>`${c}`.trim()?p:null,[c,p]);return d.jsxs(m.Dialog,{onOpenChange:n,open:t,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:e}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:i("editor.formula.dialog.text")}),d.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:d.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[d.jsxs("div",{className:"richtext-flex-1",children:[d.jsx(m.Label,{className:"mb-[6px]",children:"Expression"}),d.jsx(Jn.Textarea,{autoFocus:!0,className:"richtext-mb-[10px]",onChange:x=>a(x.target.value),placeholder:"Text",required:!0,rows:10,value:c,style:{color:"hsl(var(--foreground))"}}),d.jsx(m.Label,{className:"mb-[6px]",children:"Macros"}),d.jsx(Jn.Textarea,{onChange:x=>h(x.target.value),placeholder:"Macros",rows:10,value:u,style:{color:"hsl(var(--foreground))"}})]}),d.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:g||""},style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:f,type:"button",children:"Save changes"})})]})]})}function ol(){const e=m.useEditableEditor(),t=m.useEditorInstance(),[n,i]=b.useState(!1),s=b.useCallback(()=>t.isActive(ut.Katex.name),[t]),o=b.useCallback(()=>ie.deleteNode(ut.Katex.name,t),[t]);return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleKatex",shouldShow:s,children:d.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:[d.jsx(sl,{toggleVisible:i,visible:n,children:d.jsx(m.ActionButton,{action:()=>i(!n),tooltip:"Edit",children:d.jsx(Xe.Pencil,{size:16})})}),d.jsx(m.ActionButton,{action:o,tooltip:"Delete",children:d.jsx(Xe.Trash2,{size:16})})]})}):d.jsx(d.Fragment,{})}function rl(e){const{t}=B.useLocale();return d.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[d.jsx(m.ActionButton,{disabled:!(e!=null&&e.link),icon:"ExternalLink",tooltip:t("editor.link.open.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{window.open(e==null?void 0:e.link,"_blank")}}),d.jsx(m.ActionButton,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e==null||e.onEdit()}}),d.jsx(m.ActionButton,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e==null||e.onClear()}})]})}function ll(){const e=m.useEditableEditor(),t=m.useEditorInstance(),[n,i]=b.useState(!1),s=ut.useAttributes(t,Ve.Link.name),o=s==null?void 0:s.href,r=b.useCallback(({editor:u})=>u.isActive(Ve.Link.name),[]),l=(u,h,f)=>{const p=t.state.selection,{from:g}=p,x=(h==null?void 0:h.length)??0,w=g+x;t.chain().extendMarkRange("link").insertContent({type:"text",text:h,marks:[{type:"link",attrs:{href:u,target:f?"_blank":""}}]}).setLink({href:u}).setTextSelection({from:g,to:w}).focus().run(),i(!1)},c=b.useCallback(()=>{t.chain().extendMarkRange("link").unsetLink().focus().run(),i(!1)},[t]),a=()=>{i(!1)};return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleLink",shouldShow:r,children:d.jsx(d.Fragment,{children:n?d.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:d.jsx(Ve.LinkEditBlock,{editor:t,onClose:a,onSetLink:l})}):d.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:d.jsx(rl,{editor:t,link:o,onClear:c,onEdit:()=>{i(!0)}})})})}):d.jsx(d.Fragment,{})}function mi({item:e,disabled:t,editor:n}){const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||(e==null?void 0:e.componentdisabled),editor:n})}):d.jsx(d.Fragment,{})}function cl(e){return e.type.name===m.Image.name}function al(e){return e.type.name===Sr.ImageGif.name}function hl(e){return e.type.name===m.Video.name}function ul(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:r})=>{const{selection:l}=r.view.state,{$from:c,to:a}=l;let u=!1;return r.view.state.doc.nodesBetween(c.pos,a,h=>{if(cl(h))return u=!0,!1}),u},o=b.useMemo(()=>Wr(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImage",shouldShow:s,children:o!=null&&o.length?d.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==null?void 0:o.map((r,l)=>d.jsx(mi,{editor:i,item:r},`bubbleMenu-image-${l}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function dl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:r})=>{const{selection:l}=r.view.state,{$from:c,to:a}=l;let u=!1;return r.view.state.doc.nodesBetween(c.pos,a,h=>{if(al(h))return u=!0,!1}),u},o=b.useMemo(()=>Gr(i,t),[i,t,e]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImageGif",shouldShow:s,children:o!=null&&o.length?d.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==null?void 0:o.map((r,l)=>d.jsx(mi,{editor:i,item:r},`bubbleMenu-image-gif-${l}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function fl(){const{t:e}=B.useLocale(),t=m.useEditableEditor(),n=m.useEditorInstance(),i=({editor:o})=>{const{selection:r}=o.view.state,{$from:l,to:c}=r;let a=!1;return o.view.state.doc.nodesBetween(l.pos,c,u=>{if(hl(u))return a=!0,!1}),a},s=b.useMemo(()=>Xr(n,e),[n,e]);return t?d.jsx(it,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleVideo",shouldShow:i,children:s!=null&&s.length?d.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==null?void 0:s.map((o,r)=>d.jsx(mi,{editor:n,item:o},`bubbleMenu-video-${r}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}const Wi=`graph TB
|
|
2
|
-
a-->b`,pl=({editor:e,attrs:t,extension:n})=>{const{alt:i,align:s}=t,[o,r]=b.useState(decodeURIComponent(i??Wi)),[l,c]=b.useState(""),[a,u]=b.useState(!1),h=b.useRef(null),[f,p]=b.useState(null),g=n==null?void 0:n.options.upload,x=b.useCallback(C=>{C&&import("mermaid").then(M=>{p(M.default)})},[]),w=async C=>{try{const{svg:M}=await f.render("mermaid-svg",C);c(M)}catch{c("")}},y=()=>{f.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),w(o)};b.useEffect(()=>{f&&a&&y()},[f,a]),b.useEffect(()=>{f&&a&&w(o)},[f,o]);const v=async()=>{if(o!==""){if(o){const C=h.current.querySelector("svg"),{width:M,height:P}=C.getBoundingClientRect(),S=`mermaid-${Je.shortId()}.svg`;let k=Je.i(C.outerHTML);if(g){const D=m.dataURLtoFile(k,S);k=await g(D)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:k,alt:encodeURIComponent(o),width:M,height:P},!!o).run(),e==null||e.commands.setAlignImageMermaid(s)}u(!1)}};return d.jsxs(m.Dialog,{onOpenChange:u,open:a,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{action:()=>u(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:"Edit Mermaid"}),d.jsx("div",{ref:x,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:d.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[d.jsx(Jn.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Wi,onChange:C=>r(C.target.value),placeholder:"Text",required:!0,rows:10,value:o,style:{color:"hsl(var(--foreground))"}}),d.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:l},ref:h,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500}})]})}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:v,type:"button",children:"Save changes"})})]})]})};function gl({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):d.jsx(d.Fragment,{})}function ml(e){return e.type.name===Xn.Mermaid.name}function xl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=ut.useAttributes(i,Xn.Mermaid.name),o=m.useExtension(Xn.Mermaid.name),r=({editor:c})=>{const{selection:a}=c.view.state,{$from:u,to:h}=a;let f=!1;return c.view.state.doc.nodesBetween(u.pos,h,p=>{if(ml(p))return f=!0,!1}),f},l=b.useMemo(()=>Yr(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleMermaid",shouldShow:r,children:l!=null&&l.length?d.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:l==null?void 0:l.map((c,a)=>c.type==="edit"&&(s!=null&&s.src)?d.jsx(pl,{attrs:s,editor:i,extension:o},`bubbleMenu-mermaid-${a}`):d.jsx(gl,{editor:i,item:c},`bubbleMenu-mermaid-${a}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function bl({hiddenActions:e=[]}){var x,w,y,v,C,M,P,S,k,D,z,N,$,G,st,E,yt,je;const{t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:Vt})=>T.isActive(Vt.view.state,Os.Table.name),o=Vt=>e.includes(Vt);function r(){i.chain().focus().addColumnBefore().run()}function l(){i.chain().focus().addColumnAfter().run()}function c(){i.chain().focus().deleteColumn().run()}function a(){i.chain().focus().addRowBefore().run()}function u(){i.chain().focus().addRowAfter().run()}function h(){i.chain().focus().deleteRow().run()}function f(){i.chain().focus().mergeCells().run()}function p(){i==null||i.chain().focus().splitCell().run()}function g(){i.chain().focus().deleteTable().run()}return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTable",shouldShow:s,children:d.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:[!o("addColumnBefore")&&d.jsx(m.ActionButton,{action:r,disabled:!((w=(x=i==null?void 0:i.can())==null?void 0:x.addColumnBefore)!=null&&w.call(x)),icon:"BetweenHorizonalEnd",tooltip:t("editor.table.menu.insertColumnBefore"),tooltipOptions:{sideOffset:15}}),!o("addColumnAfter")&&d.jsx(m.ActionButton,{action:l,disabled:!((v=(y=i==null?void 0:i.can())==null?void 0:y.addColumnAfter)!=null&&v.call(y)),icon:"BetweenHorizonalStart",tooltip:t("editor.table.menu.insertColumnAfter"),tooltipOptions:{sideOffset:15}}),!o("deleteColumn")&&d.jsx(m.ActionButton,{action:c,disabled:!((M=i==null?void 0:(C=i.can()).deleteColumn)!=null&&M.call(C)),icon:"DeleteColumn",tooltip:t("editor.table.menu.deleteColumn"),tooltipOptions:{sideOffset:15}}),d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!o("addRowAbove")&&d.jsx(m.ActionButton,{action:a,disabled:!((S=i==null?void 0:(P=i.can()).addRowBefore)!=null&&S.call(P)),icon:"BetweenVerticalEnd",tooltip:t("editor.table.menu.insertRowAbove"),tooltipOptions:{sideOffset:15}}),!o("addRowBelow")&&d.jsx(m.ActionButton,{action:u,disabled:!((D=(k=i==null?void 0:i.can())==null?void 0:k.addRowAfter)!=null&&D.call(k)),icon:"BetweenVerticalStart",tooltip:t("editor.table.menu.insertRowBelow"),tooltipOptions:{sideOffset:15}}),!o("deleteRow")&&d.jsx(m.ActionButton,{action:h,disabled:!((N=(z=i==null?void 0:i.can())==null?void 0:z.deleteRow)!=null&&N.call(z)),icon:"DeleteRow",tooltip:t("editor.table.menu.deleteRow"),tooltipOptions:{sideOffset:15}}),d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!o("mergeCells")&&d.jsx(m.ActionButton,{action:f,disabled:!((G=($=i==null?void 0:i.can())==null?void 0:$.mergeCells)!=null&&G.call($)),icon:"TableCellsMerge",tooltip:t("editor.table.menu.mergeCells"),tooltipOptions:{sideOffset:15}}),!o("splitCells")&&d.jsx(m.ActionButton,{action:p,disabled:!((E=(st=i==null?void 0:i.can())==null?void 0:st.splitCell)!=null&&E.call(st)),icon:"TableCellsSplit",tooltip:t("editor.table.menu.splitCells"),tooltipOptions:{sideOffset:15}}),d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!o("deleteTable")&&d.jsx(m.ActionButton,{action:g,disabled:!((je=(yt=i==null?void 0:i.can())==null?void 0:yt.deleteTable)!=null&&je.call(yt)),icon:"Trash2",tooltip:t("editor.table.menu.deleteTable"),tooltipOptions:{sideOffset:15}})]})}):d.jsx(d.Fragment,{})}function wl(){const{t:e}=B.useLocale(),[t,n]=b.useState(!1),i=m.useEditorInstance(),s=b.useMemo(()=>{var r,l;return(l=(r=Ar.renderCommandListDefault({t:e}))==null?void 0:r[0])==null?void 0:l.commands},[e]),o=b.useMemo(()=>{var l;return(l=s==null?void 0:s.find(c=>{var a;return(a=c==null?void 0:c.isActive)==null?void 0:a.call(c,i)}))==null?void 0:l.label},[i.state.selection.ranges,t,i,s,e]);return d.jsxs(qt.Popover,{modal:!0,onOpenChange:n,open:t,children:[d.jsx(qt.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:d.jsxs(m.ActionButton,{dataState:!!o,children:[o?d.jsx(d.Fragment,{children:o}):d.jsx(d.Fragment,{children:e("editor.paragraph.tooltip")}),d.jsx(m.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})]})}),d.jsx(qt.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:s==null?void 0:s.map(r=>{var c;const l=(c=r==null?void 0:r.isActive)==null?void 0:c.call(r,i);return d.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:a=>{a.preventDefault(),r.action({editor:i,range:i.state.selection.ranges}),n(!1)},children:[d.jsxs("div",{className:"!richtext-min-w-[20px]",children:[l&&d.jsx(Xe.Check,{size:16}),!o&&r.label===e("editor.paragraph.tooltip")&&!l&&d.jsx(Xe.Check,{size:16})]}),d.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:[r.iconName&&d.jsx(m.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:r.iconName}),r.label]})]},r.name)})})]})}function yl(){return d.jsxs(d.Fragment,{children:[d.jsx(wl,{}),d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),d.jsx(Er.RichTextBold,{}),d.jsx(Ir.RichTextItalic,{}),d.jsx(Or.RichTextUnderline,{}),d.jsx(Mr.RichTextStrike,{}),d.jsx(_r.RichTextCode,{}),d.jsx(Ve.RichTextLink,{}),d.jsx(It.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),d.jsx(Tr.RichTextColor,{}),d.jsx(Dr.RichTextHighlight,{}),d.jsx(Ns.RichTextAlign,{})]})}function Sl({buttonBubble:e}){const t=m.useEditorInstance(),n=m.useEditableEditor(),i=({editor:s})=>{const{selection:o}=s.view.state,{$from:r,to:l}=o;return r.pos===l?!1:o instanceof Y.TextSelection};return n?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleText",shouldShow:i,children:e?d.jsx(d.Fragment,{children:e}):d.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:d.jsx(yl,{})})}):d.jsx(d.Fragment,{})}function vl(){const{t:e}=B.useLocale(),t=m.useEditableEditor(),n=m.useEditorInstance(),[i,s]=b.useState(!1),o=b.useCallback(({editor:c})=>c.isActive(Nn.Twitter.name),[]),r=c=>{n.commands.updateTweet({src:c}),s(!1)},l=b.useCallback(()=>ie.deleteNode(Nn.Twitter.name,n),[n]);return t?d.jsx(it,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTwitter",shouldShow:o,children:d.jsx(d.Fragment,{children:i?d.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:d.jsx(Nn.FormEditLinkTwitter,{editor:n,onSetLink:r})}):d.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:[d.jsx(m.ActionButton,{icon:"Pencil",tooltip:e("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{s(!0)}}),d.jsx(m.ActionButton,{action:l,icon:"Trash",tooltip:e("editor.delete"),tooltipOptions:{sideOffset:15}})]})})}):d.jsx(d.Fragment,{})}const dt=()=>new Map,Zn=e=>{const t=dt();return e.forEach((n,i)=>{t.set(i,n)}),t},Ct=(e,t,n)=>{let i=e.get(t);return i===void 0&&e.set(t,i=n()),i},kl=(e,t)=>{const n=[];for(const[i,s]of e)n.push(t(s,i));return n},Cl=(e,t)=>{for(const[n,i]of e)if(t(i,n))return!0;return!1},Bt=()=>new Set,Bn=e=>e[e.length-1],El=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Lt=Array.from,xi=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},bi=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},_l=(e,t)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t(i,n);return n},Xt=Array.isArray;class Ps{constructor(){this._observers=dt()}on(t,n){return Ct(this._observers,t,Bt).add(n),n}once(t,n){const i=(...s)=>{this.off(t,i),n(...s)};this.on(t,i)}off(t,n){const i=this._observers.get(t);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(t))}emit(t,n){return Lt((this._observers.get(t)||dt()).values()).forEach(i=>i(...n))}destroy(){this._observers=dt()}}const ft=Math.floor,He=Math.abs,Zt=(e,t)=>e<t?e:t,At=(e,t)=>e>t?e:t,$s=e=>e!==0?e<0:1/e<0,Gi=1,Yi=2,Ln=4,Un=8,me=32,vt=64,tt=128,Tl=1<<29,xn=31,Qn=63,Nt=127,Dl=2147483647,Ze=Number.MAX_SAFE_INTEGER,Ji=Number.MIN_SAFE_INTEGER,Il=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&ft(e)===e),Fs=String.fromCharCode,Al=e=>e.toLowerCase(),Ml=/^\s*/g,Ol=e=>e.replace(Ml,""),jl=/([A-Z])/g,Xi=(e,t)=>Ol(e.replace(jl,n=>`${t}${Al(n)}`)),Rl=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,i=new Uint8Array(n);for(let s=0;s<n;s++)i[s]=t.codePointAt(s);return i},xe=typeof TextEncoder<"u"?new TextEncoder:null,Nl=e=>xe.encode(e),Bl=xe?Nl:Rl;let pe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});pe&&pe.decode(new Uint8Array).length===1&&(pe=null);const Ll=(e,t)=>_l(t,()=>e).join("");class De{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ie=()=>new De,Ul=e=>{const t=Ie();return e(t),ht(t)},Pl=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},ht=e=>{const t=new Uint8Array(Pl(e));let n=0;for(let i=0;i<e.bufs.length;i++){const s=e.bufs[i];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},$l=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(At(n,t)*2),e.cpos=0)},q=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},ti=q,I=(e,t)=>{for(;t>Nt;)q(e,tt|Nt&t),t=ft(t/128);q(e,Nt&t)},wi=(e,t)=>{const n=$s(t);for(n&&(t=-t),q(e,(t>Qn?tt:0)|(n?vt:0)|Qn&t),t=ft(t/64);t>0;)q(e,(t>Nt?tt:0)|Nt&t),t=ft(t/128)},ei=new Uint8Array(3e4),Fl=ei.length/3,Vl=(e,t)=>{if(t.length<Fl){const n=xe.encodeInto(t,ei).written||0;I(e,n);for(let i=0;i<n;i++)q(e,ei[i])}else ot(e,Bl(t))},Hl=(e,t)=>{const n=unescape(encodeURIComponent(t)),i=n.length;I(e,i);for(let s=0;s<i;s++)q(e,n.codePointAt(s))},Kt=xe&&xe.encodeInto?Vl:Hl,bn=(e,t)=>{const n=e.cbuf.length,i=e.cpos,s=Zt(n-i,t.length),o=t.length-s;e.cbuf.set(t.subarray(0,s),i),e.cpos+=s,o>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(At(n*2,o)),e.cbuf.set(t.subarray(s)),e.cpos=o)},ot=(e,t)=>{I(e,t.byteLength),bn(e,t)},yi=(e,t)=>{$l(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},zl=(e,t)=>yi(e,4).setFloat32(0,t,!1),ql=(e,t)=>yi(e,8).setFloat64(0,t,!1),Kl=(e,t)=>yi(e,8).setBigInt64(0,t,!1),Zi=new DataView(new ArrayBuffer(4)),Wl=e=>(Zi.setFloat32(0,e),Zi.getFloat32(0)===e),Qt=(e,t)=>{switch(typeof t){case"string":q(e,119),Kt(e,t);break;case"number":Il(t)&&He(t)<=Dl?(q(e,125),wi(e,t)):Wl(t)?(q(e,124),zl(e,t)):(q(e,123),ql(e,t));break;case"bigint":q(e,122),Kl(e,t);break;case"object":if(t===null)q(e,126);else if(Xt(t)){q(e,117),I(e,t.length);for(let n=0;n<t.length;n++)Qt(e,t[n])}else if(t instanceof Uint8Array)q(e,116),ot(e,t);else{q(e,118);const n=Object.keys(t);I(e,n.length);for(let i=0;i<n.length;i++){const s=n[i];Kt(e,s),Qt(e,t[s])}}break;case"boolean":q(e,t?120:121);break;default:q(e,127)}};class Qi extends De{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&I(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const ts=e=>{e.count>0&&(wi(e.encoder,e.count===1?e.s:-e.s),e.count>1&&I(e.encoder,e.count-2))};class ze{constructor(){this.encoder=new De,this.s=0,this.count=0}write(t){this.s===t?this.count++:(ts(this),this.count=1,this.s=t)}toUint8Array(){return ts(this),ht(this.encoder)}}const es=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);wi(e.encoder,t),e.count>1&&I(e.encoder,e.count-2)}};class Pn{constructor(){this.encoder=new De,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(es(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return es(this),ht(this.encoder)}}class Gl{constructor(){this.sarr=[],this.s="",this.lensE=new ze}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 De;return this.sarr.push(this.s),this.s="",Kt(t,this.sarr.join("")),bn(t,this.lensE.toUint8Array()),ht(t)}}const wt=e=>new Error(e),ct=()=>{throw wt("Method unimplemented")},Z=()=>{throw wt("Unexpected case")},Vs=wt("Unexpected end of array"),Hs=wt("Integer out of Range");class wn{constructor(t){this.arr=t,this.pos=0}}const Si=e=>new wn(e),Yl=e=>e.pos!==e.arr.length,Jl=(e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},rt=e=>Jl(e,j(e)),be=e=>e.arr[e.pos++],j=e=>{let t=0,n=1;const i=e.arr.length;for(;e.pos<i;){const s=e.arr[e.pos++];if(t=t+(s&Nt)*n,n*=128,s<tt)return t;if(t>Ze)throw Hs}throw Vs},vi=e=>{let t=e.arr[e.pos++],n=t&Qn,i=64;const s=(t&vt)>0?-1:1;if((t&tt)===0)return s*n;const o=e.arr.length;for(;e.pos<o;){if(t=e.arr[e.pos++],n=n+(t&Nt)*i,i*=128,t<tt)return s*n;if(n>Ze)throw Hs}throw Vs},Xl=e=>{let t=j(e);if(t===0)return"";{let n=String.fromCodePoint(be(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(be(e));else for(;t>0;){const i=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+i);e.pos+=i,n+=String.fromCodePoint.apply(null,s),t-=i}return decodeURIComponent(escape(n))}},Zl=e=>pe.decode(rt(e)),ni=pe?Zl:Xl,ki=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ql=e=>ki(e,4).getFloat32(0,!1),tc=e=>ki(e,8).getFloat64(0,!1),ec=e=>ki(e,8).getBigInt64(0,!1),nc=[e=>{},e=>null,vi,Ql,tc,ec,e=>!1,e=>!0,ni,e=>{const t=j(e),n={};for(let i=0;i<t;i++){const s=ni(e);n[s]=Qe(e)}return n},e=>{const t=j(e),n=[];for(let i=0;i<t;i++)n.push(Qe(e));return n},rt],Qe=e=>nc[127-be(e)](e);class ns extends wn{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Yl(this)?this.count=j(this)+1:this.count=-1),this.count--,this.s}}class qe extends wn{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=vi(this);const t=$s(this.s);this.count=1,t&&(this.s=-this.s,this.count=j(this)+2)}return this.count--,this.s}}class $n extends wn{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=vi(this),n=t&1;this.diff=ft(t/2),this.count=1,n&&(this.count=j(this)+2)}return this.s+=this.diff,this.count--,this.s}}class ic{constructor(t){this.decoder=new qe(t),this.str=ni(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}}const sc=crypto.getRandomValues.bind(crypto),oc=Math.random,zs=()=>sc(new Uint32Array(1))[0],rc=e=>e[ft(oc()*e.length)],lc="10000000-1000-4000-8000"+-1e11,cc=()=>lc.replace(/[018]/g,e=>(e^zs()&15>>e/4).toString(16)),ac=Date.now,is=e=>new Promise(e);Promise.all.bind(Promise);const ss=e=>e===void 0?null:e;class hc{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}}let qs=new hc,uc=!0;try{typeof localStorage<"u"&&localStorage&&(qs=localStorage,uc=!1)}catch{}const dc=qs,we=Symbol("Equality"),Ks=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[we])!=null&&n.call(e,t))||!1},fc=e=>typeof e=="object",pc=Object.assign,Ws=Object.keys,gc=(e,t)=>{for(const n in e)t(e[n],n)},tn=e=>Ws(e).length,mc=e=>{for(const t in e)return!1;return!0},se=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},Ci=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),xc=(e,t)=>e===t||tn(e)===tn(t)&&se(e,(n,i)=>(n!==void 0||Ci(t,i))&&Ks(t[i],n)),bc=Object.freeze,Gs=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&Gs(e[t])}return bc(e)},Ei=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ei(e,t,n+1)}},Ke=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[we]!=null)return e[we](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!Ke(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(tn(e)!==tn(t))return!1;for(const n in e)if(!Ci(e,n)||!Ke(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ke(e[n],t[n]))return!1;break;default:return!1}return!0},wc=(e,t)=>t.includes(e),te=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Ys=typeof window<"u"&&typeof document<"u"&&!te;let xt;const yc=()=>{if(xt===void 0)if(te){xt=dt();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const i=e[n];i[0]==="-"?(t!==null&&xt.set(t,""),t=i):t!==null&&(xt.set(t,i),t=null)}t!==null&&xt.set(t,"")}else typeof location=="object"?(xt=dt(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");xt.set(`--${Xi(t,"-")}`,n),xt.set(`-${Xi(t,"-")}`,n)}})):xt=dt();return xt},ii=e=>yc().has(e),en=e=>ss(te?process.env[e.toUpperCase().replaceAll("-","_")]:dc.getItem(e)),Js=e=>ii("--"+e)||en(e)!==null,Sc=Js("production"),vc=te&&wc(process.env.FORCE_COLOR,["true","1","2"]),kc=vc||!ii("--no-colors")&&!Js("no-color")&&(!te||process.stdout.isTTY)&&(!te||ii("--color")||en("COLORTERM")!==null||(en("TERM")||"").includes("color")),Cc=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=Fs(e[n]);return btoa(t)},Ec=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),_c=Ys?Cc:Ec,Tc=e=>Ul(t=>Qt(t,e));class Dc{constructor(t,n){this.left=t,this.right=n}}const St=(e,t)=>new Dc(e,t),os=e=>e.next()>=.5,Fn=(e,t,n)=>ft(e.next()*(n+1-t)+t),Xs=(e,t,n)=>ft(e.next()*(n+1-t)+t),_i=(e,t,n)=>Xs(e,t,n),Ic=e=>Fs(_i(e,97,122)),Ac=(e,t=0,n=20)=>{const i=_i(e,t,n);let s="";for(let o=0;o<i;o++)s+=Ic(e);return s},Vn=(e,t)=>t[_i(e,0,t.length-1)],Mc=Symbol("0schema");class Oc{constructor(){this._rerrs=[]}extend(t,n,i,s=null){this._rerrs.push({path:t,expected:n,has:i,message:s})}toString(){const t=[];for(let n=this._rerrs.length-1;n>0;n--){const i=this._rerrs[n];t.push(Ll(" ",(this._rerrs.length-n)*2)+`${i.path!=null?`[${i.path}] `:""}${i.has} doesn't match ${i.expected}. ${i.message}`)}return t.join(`
|
|
3
|
-
`)}}const
|
|
4
|
-
${n.toString()}`)};class na{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:ye(t),h:n}),this}else(t){return this.if(on,t)}done(){return(t,n)=>{for(let i=0;i<this.patterns.length;i++){const s=this.patterns[i];if(s.if.check(t))return s.h(t,n)}throw wt("Unhandled pattern")}}}const ia=e=>new na(e),fo=ia(on).if(ao,(e,t)=>Fn(t,Ji,Ze)).if(ho,(e,t)=>Ac(t)).if(Qc,(e,t)=>os(t)).if(Zc,(e,t)=>BigInt(Fn(t,Ji,Ze))).if(sn,(e,t)=>zt(t,Vn(t,e.shape))).if(Pc,(e,t)=>{const n={};for(const i in e.shape){let s=e.shape[i];if(Bc.check(s)){if(os(t))continue;s=s.shape}n[i]=fo(s,t)}return n}).if(Hc,(e,t)=>{const n=[],i=Xs(t,0,42);for(let s=0;s<i;s++)n.push(zt(t,e.shape));return n}).if(Zs,(e,t)=>Vn(t,e.shape)).if(ta,(e,t)=>null).if(Gc,(e,t)=>{const n=zt(t,e.res);return()=>n}).if(Xc,(e,t)=>zt(t,Vn(t,[Wt,ee,Cn,uo,Ii,kn,oo(Wt),no(oe("a","b","c"),Wt)]))).if(Fc,(e,t)=>{const n={},i=Fn(t,0,3);for(let s=0;s<i;s++){const o=zt(t,e.shape.keys),r=zt(t,e.shape.values);n[o]=r}return n}).done(),zt=(e,t)=>fo(ye(t),e),Ae=typeof document<"u"?document:{};W(e=>e.nodeType===ca);typeof DOMParser<"u"&&new DOMParser;W(e=>e.nodeType===oa);W(e=>e.nodeType===ra);const sa=e=>kl(e,(t,n)=>`${n}:${t};`).join(""),oa=Ae.ELEMENT_NODE,ra=Ae.TEXT_NODE,la=Ae.DOCUMENT_NODE,ca=Ae.DOCUMENT_FRAGMENT_NODE;W(e=>e.nodeType===la);const aa=e=>class{constructor(n){this._=n}destroy(){e(this._)}},ha=aa(clearTimeout),po=(e,t)=>new ha(setTimeout(t,e)),Et=Symbol,go=Et(),mo=Et(),ua=Et(),da=Et(),fa=Et(),xo=Et(),pa=Et(),Ai=Et(),ga=Et(),ma=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());const t=[],n=[];let i=0;for(;i<e.length;i++){const o=e[i];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}for(i>0&&n.push(t.join(""));i<e.length;i++){const o=e[i];o instanceof Symbol||n.push(o)}return n},xa={[go]:St("font-weight","bold"),[mo]:St("font-weight","normal"),[ua]:St("color","blue"),[fa]:St("color","green"),[da]:St("color","grey"),[xo]:St("color","red"),[pa]:St("color","purple"),[Ai]:St("color","orange"),[ga]:St("color","black")},ba=e=>{var r;e.length===1&&((r=e[0])==null?void 0:r.constructor)===Function&&(e=e[0]());const t=[],n=[],i=dt();let s=[],o=0;for(;o<e.length;o++){const l=e[o],c=xa[l];if(c!==void 0)i.set(c.left,c.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const a=sa(i);o>0||a.length>0?(t.push("%c"+l),n.push(a)):t.push(l)}else break}}for(o>0&&(s=n,s.unshift(t.join("")));o<e.length;o++){const l=e[o];l instanceof Symbol||s.push(l)}return s},bo=kc?ba:ma,wa=(...e)=>{console.log(...bo(e)),yo.forEach(t=>t.print(e))},wo=(...e)=>{console.warn(...bo(e)),e.unshift(Ai),yo.forEach(t=>t.print(e))},yo=Bt(),So=e=>({[Symbol.iterator](){return this},next:e}),ya=(e,t)=>So(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Hn=(e,t)=>So(()=>{const{done:n,value:i}=e.next();return{done:n,value:n?void 0:t(i)}});class Mi{constructor(t,n){this.clock=t,this.len=n}}class re{constructor(){this.clients=new Map}}const Mt=(e,t,n)=>t.clients.forEach((i,s)=>{const o=e.doc.store.clients.get(s);if(o!=null){const r=o[o.length-1],l=r.id.clock+r.length;for(let c=0,a=i[c];c<i.length&&a.clock<l;a=i[++c])Io(e,o,a.clock,a.len,n)}}),Sa=(e,t)=>{let n=0,i=e.length-1;for(;n<=i;){const s=ft((n+i)/2),o=e[s],r=o.clock;if(r<=t){if(t<r+o.len)return s;n=s+1}else i=s-1}return null},le=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&Sa(n,t.clock)!==null},Oi=e=>{e.clients.forEach(t=>{t.sort((s,o)=>s.clock-o.clock);let n,i;for(n=1,i=1;n<t.length;n++){const s=t[i-1],o=t[n];s.clock+s.len>=o.clock?s.len=At(s.len,o.clock+o.len-s.clock):(i<n&&(t[i]=o),i++)}t.length=i})},oi=e=>{const t=new re;for(let n=0;n<e.length;n++)e[n].clients.forEach((i,s)=>{if(!t.clients.has(s)){const o=i.slice();for(let r=n+1;r<e.length;r++)El(o,e[r].clients.get(s)||[]);t.clients.set(s,o)}});return Oi(t),t},Se=(e,t,n,i)=>{Ct(e.clients,t,()=>[]).push(new Mi(n,i))},vo=()=>new re,va=e=>{const t=vo();return e.clients.forEach((n,i)=>{const s=[];for(let o=0;o<n.length;o++){const r=n[o];if(r.deleted){const l=r.id.clock;let c=r.length;if(o+1<n.length)for(let a=n[o+1];o+1<n.length&&a.deleted;a=n[++o+1])c+=a.length;s.push(new Mi(l,c))}}s.length>0&&t.clients.set(i,s)}),t},ji=(e,t)=>{I(e.restEncoder,t.clients.size),Lt(t.clients.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{e.resetDsCurVal(),I(e.restEncoder,n);const s=i.length;I(e.restEncoder,s);for(let o=0;o<s;o++){const r=i[o];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},ka=e=>{const t=new re,n=j(e.restDecoder);for(let i=0;i<n;i++){e.resetDsCurVal();const s=j(e.restDecoder),o=j(e.restDecoder);if(o>0){const r=Ct(t.clients,s,()=>[]);for(let l=0;l<o;l++)r.push(new Mi(e.readDsClock(),e.readDsLen()))}}return t},ls=(e,t,n)=>{const i=new re,s=j(e.restDecoder);for(let o=0;o<s;o++){e.resetDsCurVal();const r=j(e.restDecoder),l=j(e.restDecoder),c=n.clients.get(r)||[],a=U(n,r);for(let u=0;u<l;u++){const h=e.readDsClock(),f=h+e.readDsLen();if(h<a){a<f&&Se(i,r,a,f-a);let p=pt(c,h),g=c[p];for(!g.deleted&&g.id.clock<h&&(c.splice(p+1,0,dn(t,g,h-g.id.clock)),p++);p<c.length&&(g=c[p++],g.id.clock<f);)g.deleted||(f<g.id.clock+g.length&&c.splice(p,0,dn(t,g,f-g.id.clock)),g.delete(t))}else Se(i,r,h,f-h)}}if(i.clients.size>0){const o=new En;return I(o.restEncoder,0),ji(o,i),o.toUint8Array()}return null},ko=zs;class $t extends Ps{constructor({guid:t=cc(),collectionid:n=null,gc:i=!0,gcFilter:s=()=>!0,meta:o=null,autoLoad:r=!1,shouldLoad:l=!0}={}){super(),this.gc=i,this.gcFilter=s,this.clientID=ko(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new To,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=r,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=is(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const c=()=>is(a=>{const u=h=>{(h===void 0||h===!0)&&(this.off("sync",u),a())};this.on("sync",u)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){const t=this._item;t!==null&&!this.shouldLoad&&O(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Lt(this.subdocs).map(t=>t.guid))}transact(t,n=null){return O(this,t,n)}get(t,n=K){const i=Ct(this.share,t,()=>{const o=new n;return o._integrate(this,null),o}),s=i.constructor;if(n!==K&&s!==n)if(s===K){const o=new n;o._map=i._map,i._map.forEach(r=>{for(;r!==null;r=r.left)r.parent=o}),o._start=i._start;for(let r=o._start;r!==null;r=r.right)r.parent=o;return o._length=i._length,this.share.set(t,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return i}getArray(t=""){return this.get(t,Jt)}getText(t=""){return this.get(t,Ot)}getMap(t=""){return this.get(t,ne)}getXmlElement(t=""){return this.get(t,J)}getXmlFragment(t=""){return this.get(t,Ut)}toJSON(){const t={};return this.share.forEach((n,i)=>{t[i]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,Lt(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new $t({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,O(t.parent.doc,i=>{const s=n.doc;t.deleted||i.subdocsAdded.add(s),i.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Ca{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=j(this.restDecoder),this.dsCurrVal}readDsLen(){const t=j(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class rn extends Ca{constructor(t){super(t),this.keys=[],j(t),this.keyClockDecoder=new $n(rt(t)),this.clientDecoder=new qe(rt(t)),this.leftClockDecoder=new $n(rt(t)),this.rightClockDecoder=new $n(rt(t)),this.infoDecoder=new ns(rt(t),be),this.stringDecoder=new ic(rt(t)),this.parentInfoDecoder=new ns(rt(t),be),this.typeRefDecoder=new qe(rt(t)),this.lenDecoder=new qe(rt(t))}readLeftID(){return new Gt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Gt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Qe(this.restDecoder)}readBuf(){return rt(this.restDecoder)}readJSON(){return Qe(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class Ea{constructor(){this.restEncoder=Ie()}toUint8Array(){return ht(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){I(this.restEncoder,t)}writeDsLen(t){I(this.restEncoder,t)}}class _a extends Ea{writeLeftID(t){I(this.restEncoder,t.client),I(this.restEncoder,t.clock)}writeRightID(t){I(this.restEncoder,t.client),I(this.restEncoder,t.clock)}writeClient(t){I(this.restEncoder,t)}writeInfo(t){ti(this.restEncoder,t)}writeString(t){Kt(this.restEncoder,t)}writeParentInfo(t){I(this.restEncoder,t?1:0)}writeTypeRef(t){I(this.restEncoder,t)}writeLen(t){I(this.restEncoder,t)}writeAny(t){Qt(this.restEncoder,t)}writeBuf(t){ot(this.restEncoder,t)}writeJSON(t){Kt(this.restEncoder,JSON.stringify(t))}writeKey(t){Kt(this.restEncoder,t)}}class Ta{constructor(){this.restEncoder=Ie(),this.dsCurrVal=0}toUint8Array(){return ht(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,I(this.restEncoder,n)}writeDsLen(t){t===0&&Z(),I(this.restEncoder,t-1),this.dsCurrVal+=t}}class En extends Ta{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pn,this.clientEncoder=new ze,this.leftClockEncoder=new Pn,this.rightClockEncoder=new Pn,this.infoEncoder=new Qi(ti),this.stringEncoder=new Gl,this.parentInfoEncoder=new Qi(ti),this.typeRefEncoder=new ze,this.lenEncoder=new ze}toUint8Array(){const t=Ie();return I(t,0),ot(t,this.keyClockEncoder.toUint8Array()),ot(t,this.clientEncoder.toUint8Array()),ot(t,this.leftClockEncoder.toUint8Array()),ot(t,this.rightClockEncoder.toUint8Array()),ot(t,ht(this.infoEncoder)),ot(t,this.stringEncoder.toUint8Array()),ot(t,ht(this.parentInfoEncoder)),ot(t,this.typeRefEncoder.toUint8Array()),ot(t,this.lenEncoder.toUint8Array()),bn(t,ht(this.restEncoder)),ht(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){Qt(this.restEncoder,t)}writeBuf(t){ot(this.restEncoder,t)}writeJSON(t){Qt(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}}const Da=(e,t,n,i)=>{i=At(i,t[0].id.clock);const s=pt(t,i);I(e.restEncoder,t.length-s),e.writeClient(n),I(e.restEncoder,i);const o=t[s];o.write(e,i-o.id.clock);for(let r=s+1;r<t.length;r++)t[r].write(e,0)},Co=(e,t,n)=>{const i=new Map;n.forEach((s,o)=>{U(t,o)>s&&i.set(o,s)}),_n(t).forEach((s,o)=>{n.has(o)||i.set(o,0)}),I(e.restEncoder,i.size),Lt(i.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{Da(e,t.clients.get(s),s,o)})},Ia=(e,t)=>{const n=dt(),i=j(e.restDecoder);for(let s=0;s<i;s++){const o=j(e.restDecoder),r=new Array(o),l=e.readClient();let c=j(e.restDecoder);n.set(l,{i:0,refs:r});for(let a=0;a<o;a++){const u=e.readInfo();switch(xn&u){case 0:{const h=e.readLen();r[a]=new lt(_(l,c),h),c+=h;break}case 10:{const h=j(e.restDecoder);r[a]=new at(_(l,c),h),c+=h;break}default:{const h=(u&(vt|tt))===0,f=new A(_(l,c),null,(u&tt)===tt?e.readLeftID():null,null,(u&vt)===vt?e.readRightID():null,h?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,h&&(u&me)===me?e.readString():null,Xo(e,u));r[a]=f,c+=f.length}}}}return n},Aa=(e,t,n)=>{const i=[];let s=Lt(n.keys()).sort((p,g)=>p-g);if(s.length===0)return null;const o=()=>{if(s.length===0)return null;let p=n.get(s[s.length-1]);for(;p.refs.length===p.i;)if(s.pop(),s.length>0)p=n.get(s[s.length-1]);else return null;return p};let r=o();if(r===null)return null;const l=new To,c=new Map,a=(p,g)=>{const x=c.get(p);(x==null||x>g)&&c.set(p,g)};let u=r.refs[r.i++];const h=new Map,f=()=>{for(const p of i){const g=p.id.client,x=n.get(g);x?(x.i--,l.clients.set(g,x.refs.slice(x.i)),n.delete(g),x.i=0,x.refs=[]):l.clients.set(g,[p]),s=s.filter(w=>w!==g)}i.length=0};for(;;){if(u.constructor!==at){const g=Ct(h,u.id.client,()=>U(t,u.id.client))-u.id.clock;if(g<0)i.push(u),a(u.id.client,u.id.clock-1),f();else{const x=u.getMissing(e,t);if(x!==null){i.push(u);const w=n.get(x)||{refs:[],i:0};if(w.refs.length===w.i)a(x,U(t,x)),f();else{u=w.refs[w.i++];continue}}else(g===0||g<u.length)&&(u.integrate(e,g),h.set(u.id.client,u.id.clock+u.length))}}if(i.length>0)u=i.pop();else if(r!==null&&r.i<r.refs.length)u=r.refs[r.i++];else{if(r=o(),r===null)break;u=r.refs[r.i++]}}if(l.clients.size>0){const p=new En;return Co(p,l,new Map),I(p.restEncoder,0),{missing:c,update:p.toUint8Array()}}return null},Ma=(e,t)=>Co(e,t.doc.store,t.beforeState),Oa=(e,t,n,i=new rn(e))=>O(t,s=>{s.local=!1;let o=!1;const r=s.doc,l=r.store,c=Ia(i,r),a=Aa(s,l,c),u=l.pendingStructs;if(u){for(const[f,p]of u.missing)if(p<U(l,f)){o=!0;break}if(a){for(const[f,p]of a.missing){const g=u.missing.get(f);(g==null||g>p)&&u.missing.set(f,p)}u.update=ms([u.update,a.update])}}else l.pendingStructs=a;const h=ls(i,s,l);if(l.pendingDs){const f=new rn(Si(l.pendingDs));j(f.restDecoder);const p=ls(f,s,l);h&&p?l.pendingDs=ms([h,p]):l.pendingDs=h||p}else l.pendingDs=h;if(o){const f=l.pendingStructs.update;l.pendingStructs=null,ri(s.doc,f)}},n,!1),ri=(e,t,n,i=rn)=>{const s=Si(t);Oa(s,e,n,new i(s))};class ja{constructor(){this.l=[]}}const cs=()=>new ja,as=(e,t)=>e.l.push(t),hs=(e,t)=>{const n=e.l,i=n.length;e.l=n.filter(s=>t!==s),i===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Eo=(e,t,n)=>Ei(e.l,[t,n]);class Gt{constructor(t,n){this.client=t,this.clock=n}}const Be=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,_=(e,t)=>new Gt(e,t),ve=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw Z()},ke=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};class ln{constructor(t,n,i,s=0){this.type=t,this.tname=n,this.item=i,this.assoc=s}}class Ra{constructor(t,n,i=0){this.type=t,this.index=n,this.assoc=i}}const Na=(e,t,n=0)=>new Ra(e,t,n),Le=(e,t,n)=>{let i=null,s=null;return e._item===null?s=ve(e):i=_(e._item.id.client,e._item.id.clock),new ln(i,s,t,n)},zn=(e,t,n=0)=>{let i=e._start;if(n<0){if(t===0)return Le(e,null,n);t--}for(;i!==null;){if(!i.deleted&&i.countable){if(i.length>t)return Le(e,_(i.id.client,i.id.clock+t),n);t-=i.length}if(i.right===null&&n<0)return Le(e,i.lastId,n);i=i.right}return Le(e,null,n)},Ba=(e,t)=>{const n=Yt(e,t),i=t.clock-n.id.clock;return{item:n,diff:i}},La=(e,t,n=!0)=>{const i=t.store,s=e.item,o=e.type,r=e.tname,l=e.assoc;let c=null,a=0;if(s!==null){if(U(i,s.client)<=s.clock)return null;const u=n?hi(i,s):Ba(i,s),h=u.item;if(!(h instanceof A))return null;if(c=h.parent,c._item===null||!c._item.deleted){a=h.deleted||!h.countable?0:u.diff+(l>=0?0:1);let f=h.left;for(;f!==null;)!f.deleted&&f.countable&&(a+=f.length),f=f.left}}else{if(r!==null)c=t.get(r);else if(o!==null){if(U(i,o.client)<=o.clock)return null;const{item:u}=n?hi(i,o):{item:Yt(i,o)};if(u instanceof A&&u.content instanceof mt)c=u.content.type;else return null}else throw Z();l>=0?a=c._length:a=0}return Na(c,a,e.assoc)};class Ri{constructor(t,n){this.ds=t,this.sv=n}}const _o=(e,t)=>new Ri(e,t),qn=e=>_o(va(e.store),_n(e.store)),Rt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!le(t.ds,e.id),li=(e,t)=>{const n=Ct(e.meta,li,Bt),i=e.doc.store;n.has(t)||(t.sv.forEach((s,o)=>{s<U(i,o)&&et(e,_(o,s))}),Mt(e,t.ds,s=>{}),n.add(t))};class To{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const _n=e=>{const t=new Map;return e.clients.forEach((n,i)=>{const s=n[n.length-1];t.set(i,s.id.clock+s.length)}),t},U=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const i=n[n.length-1];return i.id.clock+i.length},Do=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const i=n[n.length-1];if(i.id.clock+i.length!==t.id.clock)throw Z()}n.push(t)},pt=(e,t)=>{let n=0,i=e.length-1,s=e[i],o=s.id.clock;if(o===t)return i;let r=ft(t/(o+s.length-1)*i);for(;n<=i;){if(s=e[r],o=s.id.clock,o<=t){if(t<o+s.length)return r;n=r+1}else i=r-1;r=ft((n+i)/2)}throw Z()},Ua=(e,t)=>{const n=e.clients.get(t.client);return n[pt(n,t.clock)]},Yt=Ua,ci=(e,t,n)=>{const i=pt(t,n),s=t[i];return s.id.clock<n&&s instanceof A?(t.splice(i+1,0,dn(e,s,n-s.id.clock)),i+1):i},et=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[ci(e,n,t.clock)]},us=(e,t,n)=>{const i=t.clients.get(n.client),s=pt(i,n.clock),o=i[s];return n.clock!==o.id.clock+o.length-1&&o.constructor!==lt&&i.splice(s+1,0,dn(e,o,n.clock-o.id.clock+1)),o},Pa=(e,t,n)=>{const i=e.clients.get(t.id.client);i[pt(i,t.id.clock)]=n},Io=(e,t,n,i,s)=>{if(i===0)return;const o=n+i;let r=ci(e,t,n),l;do l=t[r++],o<l.id.clock+l.length&&ci(e,t,o),s(l);while(r<t.length&&t[r].id.clock<o)};class $a{constructor(t,n,i){this.doc=t,this.deleteSet=new re,this.beforeState=_n(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=i,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const ds=(e,t)=>t.deleteSet.clients.size===0&&!Cl(t.afterState,(n,i)=>t.beforeState.get(i)!==n)?!1:(Oi(t.deleteSet),Ma(e,t),ji(e,t.deleteSet),!0),fs=(e,t,n)=>{const i=t._item;(i===null||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&Ct(e.changed,t,Bt).add(n)},We=(e,t)=>{let n=e[t],i=e[t-1],s=t;for(;s>0;n=i,i=e[--s-1]){if(i.deleted===n.deleted&&i.constructor===n.constructor&&i.mergeWith(n)){n instanceof A&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,i);continue}break}const o=t-s;return o&&e.splice(t+1-o,o),o},Fa=(e,t,n)=>{for(const[i,s]of e.clients.entries()){const o=t.clients.get(i);for(let r=s.length-1;r>=0;r--){const l=s[r],c=l.clock+l.len;for(let a=pt(o,l.clock),u=o[a];a<o.length&&u.id.clock<c;u=o[++a]){const h=o[a];if(l.clock+l.len<=h.id.clock)break;h instanceof A&&h.deleted&&!h.keep&&n(h)&&h.gc(t,!1)}}}},Va=(e,t)=>{e.clients.forEach((n,i)=>{const s=t.clients.get(i);for(let o=n.length-1;o>=0;o--){const r=n[o],l=Zt(s.length-1,1+pt(s,r.clock+r.len-1));for(let c=l,a=s[c];c>0&&a.id.clock>=r.clock;a=s[c])c-=1+We(s,c)}})},Ao=(e,t)=>{if(t<e.length){const n=e[t],i=n.doc,s=i.store,o=n.deleteSet,r=n._mergeStructs;try{Oi(o),n.afterState=_n(n.doc.store),i.emit("beforeObserverCalls",[n,i]);const l=[];n.changed.forEach((c,a)=>l.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,c)})),l.push(()=>{n.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(u=>u.target._item===null||!u.target._item.deleted),c.forEach(u=>{u.currentTarget=a,u._path=null}),c.sort((u,h)=>u.path.length-h.path.length),l.push(()=>{Eo(a._dEH,c,n)}))}),l.push(()=>i.emit("afterTransaction",[n,i])),l.push(()=>{n._needFormattingCleanup&&ch(n)})}),Ei(l,[])}finally{i.gc&&Fa(o,s,i.gcFilter),Va(o,s),n.afterState.forEach((u,h)=>{const f=n.beforeState.get(h)||0;if(f!==u){const p=s.clients.get(h),g=At(pt(p,f),1);for(let x=p.length-1;x>=g;)x-=1+We(p,x)}});for(let u=r.length-1;u>=0;u--){const{client:h,clock:f}=r[u].id,p=s.clients.get(h),g=pt(p,f);g+1<p.length&&We(p,g+1)>1||g>0&&We(p,g)}if(!n.local&&n.afterState.get(i.clientID)!==n.beforeState.get(i.clientID)&&(wa(Ai,go,"[yjs] ",mo,xo,"Changed the client-id because another client seems to be using it."),i.clientID=ko()),i.emit("afterTransactionCleanup",[n,i]),i._observers.has("update")){const u=new _a;ds(u,n)&&i.emit("update",[u.toUint8Array(),n.origin,i,n])}if(i._observers.has("updateV2")){const u=new En;ds(u,n)&&i.emit("updateV2",[u.toUint8Array(),n.origin,i,n])}const{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=n;(l.size>0||a.size>0||c.size>0)&&(l.forEach(u=>{u.clientID=i.clientID,u.collectionid==null&&(u.collectionid=i.collectionid),i.subdocs.add(u)}),a.forEach(u=>i.subdocs.delete(u)),i.emit("subdocs",[{loaded:c,added:l,removed:a},i,n]),a.forEach(u=>u.destroy())),e.length<=t+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,e])):Ao(e,t+1)}}},O=(e,t,n=null,i=!0)=>{const s=e._transactionCleanups;let o=!1,r=null;e._transaction===null&&(o=!0,e._transaction=new $a(e,n,i),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{r=t(e._transaction)}finally{if(o){const l=e._transaction===s[0];e._transaction=null,l&&Ao(s,0)}}return r};class Ha{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const ps=(e,t,n)=>{Mt(e,n.deletions,i=>{i instanceof A&&t.scope.some(s=>s===e.doc||ke(s,i))&&Pi(i,!1)})},gs=(e,t,n)=>{let i=null;const s=e.doc,o=e.scope;O(s,l=>{for(;t.length>0&&e.currStackItem===null;){const c=s.store,a=t.pop(),u=new Set,h=[];let f=!1;Mt(l,a.insertions,p=>{if(p instanceof A){if(p.redone!==null){let{item:g,diff:x}=hi(c,p.id);x>0&&(g=et(l,_(g.id.client,g.id.clock+x))),p=g}!p.deleted&&o.some(g=>g===l.doc||ke(g,p))&&h.push(p)}}),Mt(l,a.deletions,p=>{p instanceof A&&o.some(g=>g===l.doc||ke(g,p))&&!le(a.insertions,p.id)&&u.add(p)}),u.forEach(p=>{f=Jo(l,p,u,a.insertions,e.ignoreRemoteMapChanges,e)!==null||f});for(let p=h.length-1;p>=0;p--){const g=h[p];e.deleteFilter(g)&&(g.delete(l),f=!0)}e.currStackItem=f?a:null}l.changed.forEach((c,a)=>{c.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),i=l},e);const r=e.currStackItem;if(r!=null){const l=i.changedParentTypes;e.emit("stack-item-popped",[{stackItem:r,type:n,changedParentTypes:l,origin:e},e]),e.currStackItem=null}return r};class Mo extends Ps{constructor(t,{captureTimeout:n=500,captureTransaction:i=c=>!0,deleteFilter:s=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:r=!1,doc:l=Xt(t)?t[0].doc:t instanceof $t?t:t.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(t),this.deleteFilter=s,o.add(this),this.trackedOrigins=o,this.captureTransaction=i,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=r,this.captureTimeout=n,this.afterTransactionHandler=c=>{if(!this.captureTransaction(c)||!this.scope.some(w=>c.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;const a=this.undoing,u=this.redoing,h=a?this.redoStack:this.undoStack;a?this.stopCapturing():u||this.clear(!1,!0);const f=new re;c.afterState.forEach((w,y)=>{const v=c.beforeState.get(y)||0,C=w-v;C>0&&Se(f,y,v,C)});const p=ac();let g=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&h.length>0&&!a&&!u){const w=h[h.length-1];w.deletions=oi([w.deletions,c.deleteSet]),w.insertions=oi([w.insertions,f])}else h.push(new Ha(c.deleteSet,f)),g=!0;!a&&!u&&(this.lastChange=p),Mt(c,c.deleteSet,w=>{w instanceof A&&this.scope.some(y=>y===c.doc||ke(y,w))&&Pi(w,!0)});const x=[{stackItem:h[h.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];g?this.emit("stack-item-added",x):this.emit("stack-item-updated",x)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const n=new Set(this.scope);t=Xt(t)?t:[t],t.forEach(i=>{n.has(i)||(n.add(i),(i instanceof K?i.doc!==this.doc:i!==this.doc)&&wo("[yjs#509] Not same Y.Doc"),this.scope.push(i))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(i=>{t&&(this.undoStack.forEach(s=>ps(i,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>ps(i,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=gs(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=gs(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()}}function*za(e){const t=j(e.restDecoder);for(let n=0;n<t;n++){const i=j(e.restDecoder),s=e.readClient();let o=j(e.restDecoder);for(let r=0;r<i;r++){const l=e.readInfo();if(l===10){const c=j(e.restDecoder);yield new at(_(s,o),c),o+=c}else if((xn&l)!==0){const c=(l&(vt|tt))===0,a=new A(_(s,o),null,(l&tt)===tt?e.readLeftID():null,null,(l&vt)===vt?e.readRightID():null,c?e.readParentInfo()?e.readString():e.readLeftID():null,c&&(l&me)===me?e.readString():null,Xo(e,l));yield a,o+=a.length}else{const c=e.readLen();yield new lt(_(s,o),c),o+=c}}}}class qa{constructor(t,n){this.gen=za(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===at);return this.curr}}class Ka{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const Wa=(e,t)=>{if(e.constructor===lt){const{client:n,clock:i}=e.id;return new lt(_(n,i+t),e.length-t)}else if(e.constructor===at){const{client:n,clock:i}=e.id;return new at(_(n,i+t),e.length-t)}else{const n=e,{client:i,clock:s}=n.id;return new A(_(i,s+t),null,_(i,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},ms=(e,t=rn,n=En)=>{if(e.length===1)return e[0];const i=e.map(u=>new t(Si(u)));let s=i.map(u=>new qa(u,!0)),o=null;const r=new n,l=new Ka(r);for(;s=s.filter(f=>f.curr!==null),s.sort((f,p)=>{if(f.curr.id.client===p.curr.id.client){const g=f.curr.id.clock-p.curr.id.clock;return g===0?f.curr.constructor===p.curr.constructor?0:f.curr.constructor===at?1:-1:g}else return p.curr.id.client-f.curr.id.client}),s.length!==0;){const u=s[0],h=u.curr.id.client;if(o!==null){let f=u.curr,p=!1;for(;f!==null&&f.id.clock+f.length<=o.struct.id.clock+o.struct.length&&f.id.client>=o.struct.id.client;)f=u.next(),p=!0;if(f===null||f.id.client!==h||p&&f.id.clock>o.struct.id.clock+o.struct.length)continue;if(h!==o.struct.id.client)fe(l,o.struct,o.offset),o={struct:f,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<f.id.clock)if(o.struct.constructor===at)o.struct.length=f.id.clock+f.length-o.struct.id.clock;else{fe(l,o.struct,o.offset);const g=f.id.clock-o.struct.id.clock-o.struct.length;o={struct:new at(_(h,o.struct.id.clock+o.struct.length),g),offset:0}}else{const g=o.struct.id.clock+o.struct.length-f.id.clock;g>0&&(o.struct.constructor===at?o.struct.length-=g:f=Wa(f,g)),o.struct.mergeWith(f)||(fe(l,o.struct,o.offset),o={struct:f,offset:0},u.next())}}else o={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===h&&f.id.clock===o.struct.id.clock+o.struct.length&&f.constructor!==at;f=u.next())fe(l,o.struct,o.offset),o={struct:f,offset:0}}o!==null&&(fe(l,o.struct,o.offset),o=null),Ga(l);const c=i.map(u=>ka(u)),a=oi(c);return ji(r,a),r.toUint8Array()},Oo=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:ht(e.encoder.restEncoder)}),e.encoder.restEncoder=Ie(),e.written=0)},fe=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Oo(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),I(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Ga=e=>{Oo(e);const t=e.encoder.restEncoder;I(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const i=e.clientStructs[n];I(t,i.written),bn(t,i.restEncoder)}},xs="You must not compute changes after the event-handler fired.";class Tn{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Ya(this.currentTarget,this.target))}deletes(t){return le(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw wt(xs);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const o=n._map.get(s);let r,l;if(this.adds(o)){let c=o.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(o))if(c!==null&&this.deletes(c))r="delete",l=Bn(c.content.getContent());else return;else c!==null&&this.deletes(c)?(r="update",l=Bn(c.content.getContent())):(r="add",l=void 0)}else if(this.deletes(o))r="delete",l=Bn(o.content.getContent());else return;t.set(s,{action:r,oldValue:l})}}),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(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw wt(xs);const n=this.target,i=Bt(),s=Bt(),o=[];if(t={added:i,deleted:s,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const c=()=>{l&&o.push(l)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((l===null||l.delete===void 0)&&(c(),l={delete:0}),l.delete+=a.length,s.add(a)):this.adds(a)?((l===null||l.insert===void 0)&&(c(),l={insert:[]}),l.insert=l.insert.concat(a.content.getContent()),i.add(a)):((l===null||l.retain===void 0)&&(c(),l={retain:0}),l.retain+=a.length);l!==null&&l.retain===void 0&&c()}this._changes=t}return t}}const Ya=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let i=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(i+=s.length),s=s.right;n.unshift(i)}t=t._item.parent}return n},X=()=>{wo("Invalid access: Add Yjs type to a document before reading data.")},jo=80;let Ni=0;class Ja{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Ni++}}const Xa=e=>{e.timestamp=Ni++},Ro=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Ni++},Za=(e,t,n)=>{if(e.length>=jo){const i=e.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return Ro(i,t,n),i}else{const i=new Ja(t,n);return e.push(i),i}},Dn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,r)=>He(t-o.index)<He(t-r.index)?o:r);let i=e._start,s=0;for(n!==null&&(i=n.p,s=n.index,Xa(n));i.right!==null&&s<t;){if(!i.deleted&&i.countable){if(t<s+i.length)break;s+=i.length}i=i.right}for(;i.left!==null&&s>t;)i=i.left,!i.deleted&&i.countable&&(s-=i.length);for(;i.left!==null&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(s-=i.length);return n!==null&&He(n.index-s)<i.parent.length/jo?(Ro(n,i,s),n):Za(e._searchMarker,i,s)},Ce=(e,t,n)=>{for(let i=e.length-1;i>=0;i--){const s=e[i];if(n>0){let o=s.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(s.index-=o.length);if(o===null||o.marker===!0){e.splice(i,1);continue}s.p=o,o.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=At(t,s.index+n))}},In=(e,t,n)=>{const i=e,s=t.changedParentTypes;for(;Ct(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Eo(i._eH,n,t)};class K{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=cs(),this._dEH=cs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw ct()}clone(){throw ct()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){as(this._eH,t)}observeDeep(t){as(this._dEH,t)}unobserve(t){hs(this._eH,t)}unobserveDeep(t){hs(this._dEH,t)}toJSON(){}}const No=(e,t,n)=>{e.doc??X(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let i=n-t;const s=[];let o=e._start;for(;o!==null&&i>0;){if(o.countable&&!o.deleted){const r=o.content.getContent();if(r.length<=t)t-=r.length;else{for(let l=t;l<r.length&&i>0;l++)s.push(r[l]),i--;t=0}}o=o.right}return s},Bo=e=>{e.doc??X();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}n=n.right}return t},Lo=(e,t)=>{const n=[];let i=e._start;for(;i!==null;){if(i.countable&&Rt(i,t)){const s=i.content.getContent();for(let o=0;o<s.length;o++)n.push(s[o])}i=i.right}return n},Ee=(e,t)=>{let n=0,i=e._start;for(e.doc??X();i!==null;){if(i.countable&&!i.deleted){const s=i.content.getContent();for(let o=0;o<s.length;o++)t(s[o],n++,e)}i=i.right}},Uo=(e,t)=>{const n=[];return Ee(e,(i,s)=>{n.push(t(i,s,e))}),n},Qa=e=>{let t=e._start,n=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),i=0,t=t.right}const s=n[i++];return n.length<=i&&(n=null),{done:!1,value:s}}}},Po=(e,t)=>{e.doc??X();const n=Dn(e,t);let i=e._start;for(n!==null&&(i=n.p,t-=n.index);i!==null;i=i.right)if(!i.deleted&&i.countable){if(t<i.length)return i.content.getContent()[t];t-=i.length}},cn=(e,t,n,i)=>{let s=n;const o=e.doc,r=o.clientID,l=o.store,c=n===null?t._start:n.right;let a=[];const u=()=>{a.length>0&&(s=new A(_(r,U(l,r)),s,s&&s.lastId,c,c&&c.id,t,null,new Pt(a)),s.integrate(e,0),a=[])};i.forEach(h=>{if(h===null)a.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(h);break;default:switch(u(),h.constructor){case Uint8Array:case ArrayBuffer:s=new A(_(r,U(l,r)),s,s&&s.lastId,c,c&&c.id,t,null,new Me(new Uint8Array(h))),s.integrate(e,0);break;case $t:s=new A(_(r,U(l,r)),s,s&&s.lastId,c,c&&c.id,t,null,new Oe(h)),s.integrate(e,0);break;default:if(h instanceof K)s=new A(_(r,U(l,r)),s,s&&s.lastId,c,c&&c.id,t,null,new mt(h)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},$o=()=>wt("Length exceeded!"),Fo=(e,t,n,i)=>{if(n>t._length)throw $o();if(n===0)return t._searchMarker&&Ce(t._searchMarker,n,i.length),cn(e,t,null,i);const s=n,o=Dn(t,n);let r=t._start;for(o!==null&&(r=o.p,n-=o.index,n===0&&(r=r.prev,n+=r&&r.countable&&!r.deleted?r.length:0));r!==null;r=r.right)if(!r.deleted&&r.countable){if(n<=r.length){n<r.length&&et(e,_(r.id.client,r.id.clock+n));break}n-=r.length}return t._searchMarker&&Ce(t._searchMarker,s,i.length),cn(e,t,r,i)},th=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((o,r)=>r.index>o.index?r:o,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return cn(e,t,s,n)},Vo=(e,t,n,i)=>{if(i===0)return;const s=n,o=i,r=Dn(t,n);let l=t._start;for(r!==null&&(l=r.p,n-=r.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&et(e,_(l.id.client,l.id.clock+n)),n-=l.length);for(;i>0&&l!==null;)l.deleted||(i<l.length&&et(e,_(l.id.client,l.id.clock+i)),l.delete(e),i-=l.length),l=l.right;if(i>0)throw $o();t._searchMarker&&Ce(t._searchMarker,s,-o+i)},an=(e,t,n)=>{const i=t._map.get(n);i!==void 0&&i.delete(e)},Bi=(e,t,n,i)=>{const s=t._map.get(n)||null,o=e.doc,r=o.clientID;let l;if(i==null)l=new Pt([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Pt([i]);break;case Uint8Array:l=new Me(i);break;case $t:l=new Oe(i);break;default:if(i instanceof K)l=new mt(i);else throw new Error("Unexpected content type")}new A(_(r,U(o.store,r)),s,s&&s.lastId,null,null,t,n,l).integrate(e,0)},Li=(e,t)=>{e.doc??X();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ho=e=>{const t={};return e.doc??X(),e._map.forEach((n,i)=>{n.deleted||(t[i]=n.content.getContent()[n.length-1])}),t},zo=(e,t)=>{e.doc??X();const n=e._map.get(t);return n!==void 0&&!n.deleted},eh=(e,t)=>{const n={};return e._map.forEach((i,s)=>{let o=i;for(;o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;o!==null&&Rt(o,t)&&(n[s]=o.content.getContent()[o.length-1])}),n},Ue=e=>(e.doc??X(),ya(e._map.entries(),t=>!t[1].deleted));class nh extends Tn{}class Jt extends K{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new Jt;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Jt}clone(){const t=new Jt;return t.insert(0,this.toArray().map(n=>n instanceof K?n.clone():n)),t}get length(){return this.doc??X(),this._length}_callObserver(t,n){super._callObserver(t,n),In(this,t,new nh(this,t))}insert(t,n){this.doc!==null?O(this.doc,i=>{Fo(i,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?O(this.doc,n=>{th(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?O(this.doc,i=>{Vo(i,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Po(this,t)}toArray(){return Bo(this)}slice(t=0,n=this.length){return No(this,t,n)}toJSON(){return this.map(t=>t instanceof K?t.toJSON():t)}map(t){return Uo(this,t)}forEach(t){Ee(this,t)}[Symbol.iterator](){return Qa(this)}_write(t){t.writeTypeRef(Th)}}const ih=e=>new Jt;class sh extends Tn{constructor(t,n,i){super(t,n),this.keysChanged=i}}class ne extends K{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((i,s)=>{this.set(s,i)}),this._prelimContent=null}_copy(){return new ne}clone(){const t=new ne;return this.forEach((n,i)=>{t.set(i,n instanceof K?n.clone():n)}),t}_callObserver(t,n){In(this,t,new sh(this,t,n))}toJSON(){this.doc??X();const t={};return this._map.forEach((n,i)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];t[i]=s instanceof K?s.toJSON():s}}),t}get size(){return[...Ue(this)].length}keys(){return Hn(Ue(this),t=>t[0])}values(){return Hn(Ue(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Hn(Ue(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??X(),this._map.forEach((n,i)=>{n.deleted||t(n.content.getContent()[n.length-1],i,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?O(this.doc,n=>{an(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?O(this.doc,i=>{Bi(i,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Li(this,t)}has(t){return zo(this,t)}clear(){this.doc!==null?O(this.doc,t=>{this.forEach(function(n,i,s){an(t,s,i)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Dh)}}const oh=e=>new ne,Tt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&xc(e,t);class ai{constructor(t,n,i,s){this.left=t,this.right=n,this.index=i,this.currentAttributes=s}forward(){switch(this.right===null&&Z(),this.right.content.constructor){case F:this.right.deleted||ce(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const bs=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case F:t.right.deleted||ce(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&et(e,_(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Pe=(e,t,n,i)=>{const s=new Map,o=i?Dn(t,n):null;if(o){const r=new ai(o.p.left,o.p,o.index,s);return bs(e,r,n-o.index)}else{const r=new ai(null,t._start,0,s);return bs(e,r,n)}},qo=(e,t,n,i)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===F&&Tt(i.get(n.right.content.key),n.right.content.value));)n.right.deleted||i.delete(n.right.content.key),n.forward();const s=e.doc,o=s.clientID;i.forEach((r,l)=>{const c=n.left,a=n.right,u=new A(_(o,U(s.store,o)),c,c&&c.lastId,a,a&&a.id,t,null,new F(l,r));u.integrate(e,0),n.right=u,n.forward()})},ce=(e,t)=>{const{key:n,value:i}=t;i===null?e.delete(n):e.set(n,i)},Ko=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===F&&Tt(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Wo=(e,t,n,i)=>{const s=e.doc,o=s.clientID,r=new Map;for(const l in i){const c=i[l],a=n.currentAttributes.get(l)??null;if(!Tt(a,c)){r.set(l,a);const{left:u,right:h}=n;n.right=new A(_(o,U(s.store,o)),u,u&&u.lastId,h,h&&h.id,t,null,new F(l,c)),n.right.integrate(e,0),n.forward()}}return r},Kn=(e,t,n,i,s)=>{n.currentAttributes.forEach((f,p)=>{s[p]===void 0&&(s[p]=null)});const o=e.doc,r=o.clientID;Ko(n,s);const l=Wo(e,t,n,s),c=i.constructor===String?new gt(i):i instanceof K?new mt(i):new Ft(i);let{left:a,right:u,index:h}=n;t._searchMarker&&Ce(t._searchMarker,n.index,c.getLength()),u=new A(_(r,U(o.store,r)),a,a&&a.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=h,n.forward(),qo(e,t,n,l)},ws=(e,t,n,i,s)=>{const o=e.doc,r=o.clientID;Ko(n,s);const l=Wo(e,t,n,s);t:for(;n.right!==null&&(i>0||l.size>0&&(n.right.deleted||n.right.content.constructor===F));){if(!n.right.deleted)switch(n.right.content.constructor){case F:{const{key:c,value:a}=n.right.content,u=s[c];if(u!==void 0){if(Tt(u,a))l.delete(c);else{if(i===0)break t;l.set(c,a)}n.right.delete(e)}else n.currentAttributes.set(c,a);break}default:i<n.right.length&&et(e,_(n.right.id.client,n.right.id.clock+i)),i-=n.right.length;break}n.forward()}if(i>0){let c="";for(;i>0;i--)c+=`
|
|
5
|
-
`;n.right=new
|
|
6
|
-
`?r.insert.slice(0,-1):r.insert;(typeof l!="string"||l.length>0)&&Kn(i,this,s,l,r.attributes||{})}else r.retain!==void 0?ws(i,this,s,r.retain,r.attributes||{}):r.delete!==void 0&&ys(i,s,r.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,i){this.doc??X();const s=[],o=new Map,r=this.doc;let l="",c=this._start;function a(){if(l.length>0){const h={};let f=!1;o.forEach((g,x)=>{f=!0,h[x]=g});const p={insert:l};f&&(p.attributes=h),s.push(p),l=""}}const u=()=>{for(;c!==null;){if(Rt(c,t)||n!==void 0&&Rt(c,n))switch(c.content.constructor){case gt:{const h=o.get("ychange");t!==void 0&&!Rt(c,t)?(h===void 0||h.user!==c.id.client||h.type!=="removed")&&(a(),o.set("ychange",i?i("removed",c.id):{type:"removed"})):n!==void 0&&!Rt(c,n)?(h===void 0||h.user!==c.id.client||h.type!=="added")&&(a(),o.set("ychange",i?i("added",c.id):{type:"added"})):h!==void 0&&(a(),o.delete("ychange")),l+=c.content.str;break}case mt:case Ft:{a();const h={insert:c.content.getContent()[0]};if(o.size>0){const f={};h.attributes=f,o.forEach((p,g)=>{f[g]=p})}s.push(h);break}case F:Rt(c,t)&&(a(),ce(o,c.content));break}c=c.right}a()};return t||n?O(r,h=>{t&&li(h,t),n&&li(h,n),u()},"cleanup"):u(),s}insert(t,n,i){if(n.length<=0)return;const s=this.doc;s!==null?O(s,o=>{const r=Pe(o,this,t,!i);i||(i={},r.currentAttributes.forEach((l,c)=>{i[c]=l})),Kn(o,this,r,n,i)}):this._pending.push(()=>this.insert(t,n,i))}insertEmbed(t,n,i){const s=this.doc;s!==null?O(s,o=>{const r=Pe(o,this,t,!i);Kn(o,this,r,n,i||{})}):this._pending.push(()=>this.insertEmbed(t,n,i||{}))}delete(t,n){if(n===0)return;const i=this.doc;i!==null?O(i,s=>{ys(s,Pe(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,i){if(n===0)return;const s=this.doc;s!==null?O(s,o=>{const r=Pe(o,this,t,!1);r.right!==null&&ws(o,this,r,n,i)}):this._pending.push(()=>this.format(t,n,i))}removeAttribute(t){this.doc!==null?O(this.doc,n=>{an(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?O(this.doc,i=>{Bi(i,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Li(this,t)}getAttributes(){return Ho(this)}_write(t){t.writeTypeRef(Ih)}}const hh=e=>new Ot;class Wn{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??X()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===J||n.constructor===Ut)&&n._start!==null)t=n._start;else for(;t!==null;){const i=t.next;if(i!==null){t=i;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class Ut extends K{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ut}clone(){const t=new Ut;return t.insert(0,this.toArray().map(n=>n instanceof K?n.clone():n)),t}get length(){return this.doc??X(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Wn(this,t)}querySelector(t){t=t.toUpperCase();const i=new Wn(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return i.done?null:i.value}querySelectorAll(t){return t=t.toUpperCase(),Lt(new Wn(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){In(this,t,new fh(this,n,t))}toString(){return Uo(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},i){const s=t.createDocumentFragment();return i!==void 0&&i._createAssociation(s,this),Ee(this,o=>{s.insertBefore(o.toDOM(t,n,i),null)}),s}insert(t,n){this.doc!==null?O(this.doc,i=>{Fo(i,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)O(this.doc,i=>{const s=t&&t instanceof K?t._item:t;cn(i,this,s,n)});else{const i=this._prelimContent,s=t===null?0:i.findIndex(o=>o===t)+1;if(s===0&&t!==null)throw wt("Reference item not found");i.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?O(this.doc,i=>{Vo(i,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Bo(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Po(this,t)}slice(t=0,n=this.length){return No(this,t,n)}forEach(t){Ee(this,t)}_write(t){t.writeTypeRef(Mh)}}const uh=e=>new Ut;class J extends Ut{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,n){super._integrate(t,n),this._prelimAttrs.forEach((i,s)=>{this.setAttribute(s,i)}),this._prelimAttrs=null}_copy(){return new J(this.nodeName)}clone(){const t=new J(this.nodeName),n=this.getAttributes();return gc(n,(i,s)=>{t.setAttribute(s,i)}),t.insert(0,this.toArray().map(i=>i instanceof K?i.clone():i)),t}toString(){const t=this.getAttributes(),n=[],i=[];for(const l in t)i.push(l);i.sort();const s=i.length;for(let l=0;l<s;l++){const c=i[l];n.push(c+'="'+t[c]+'"')}const o=this.nodeName.toLocaleLowerCase(),r=n.length>0?" "+n.join(" "):"";return`<${o}${r}>${super.toString()}</${o}>`}removeAttribute(t){this.doc!==null?O(this.doc,n=>{an(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?O(this.doc,i=>{Bi(i,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Li(this,t)}hasAttribute(t){return zo(this,t)}getAttributes(t){return t?eh(this,t):Ho(this)}toDOM(t=document,n={},i){const s=t.createElement(this.nodeName),o=this.getAttributes();for(const r in o){const l=o[r];typeof l=="string"&&s.setAttribute(r,l)}return Ee(this,r=>{s.appendChild(r.toDOM(t,n,i))}),i!==void 0&&i._createAssociation(s,this),s}_write(t){t.writeTypeRef(Ah),t.writeKey(this.nodeName)}}const dh=e=>new J(e.readKey());class fh extends Tn{constructor(t,n,i){super(t,i),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class hn extends ne{constructor(t){super(),this.hookName=t}_copy(){return new hn(this.hookName)}clone(){const t=new hn(this.hookName);return this.forEach((n,i)=>{t.set(i,n)}),t}toDOM(t=document,n={},i){const s=n[this.hookName];let o;return s!==void 0?o=s.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),i!==void 0&&i._createAssociation(o,this),o}_write(t){t.writeTypeRef(Oh),t.writeKey(this.hookName)}}const ph=e=>new hn(e.readKey());class nt extends Ot{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 nt}clone(){const t=new nt;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,i){const s=t.createTextNode(this.toString());return i!==void 0&&i._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{const n=[];for(const s in t.attributes){const o=[];for(const r in t.attributes[s])o.push({key:r,value:t.attributes[s][r]});o.sort((r,l)=>r.key<l.key?-1:1),n.push({nodeName:s,attrs:o})}n.sort((s,o)=>s.nodeName<o.nodeName?-1:1);let i="";for(let s=0;s<n.length;s++){const o=n[s];i+=`<${o.nodeName}`;for(let r=0;r<o.attrs.length;r++){const l=o.attrs[r];i+=` ${l.key}="${l.value}"`}i+=">"}i+=t.insert;for(let s=n.length-1;s>=0;s--)i+=`</${n[s].nodeName}>`;return i}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(jh)}}const gh=e=>new nt;class Ui{constructor(t,n){this.id=t,this.length=n}get deleted(){throw ct()}mergeWith(t){return!1}write(t,n,i){throw ct()}integrate(t,n){throw ct()}}const mh=0;class lt extends Ui{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Do(t.doc.store,this)}write(t,n){t.writeInfo(mh),t.writeLen(this.length-n)}getMissing(t,n){return null}}class Me{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Me(this.content)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const xh=e=>new Me(e.readBuf());class _e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new _e(this.len)}splice(t){const n=new _e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Se(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const bh=e=>new _e(e.readLen()),Yo=(e,t)=>new $t({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Oe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Oe(Yo(this.doc.guid,this.opts))}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,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,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const wh=e=>new Oe(Yo(e.readString(),e.readAny()));class Ft{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ft(this.embed)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const yh=e=>new Ft(e.readJSON());class F{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new F(this.key,this.value)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){const i=n.parent;i._searchMarker=null,i._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const Sh=e=>new F(e.readKey(),e.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){const n=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const i=this.arr.length;t.writeLen(i-n);for(let s=n;s<i;s++){const o=this.arr[s];t.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const vh=e=>{const t=e.readLen(),n=[];for(let i=0;i<t;i++){const s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new un(n)},kh=en("node_env")==="development";class Pt{constructor(t){this.arr=t,kh&&Gs(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Pt(this.arr)}splice(t){const n=new Pt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const i=this.arr.length;t.writeLen(i-n);for(let s=n;s<i;s++){const o=this.arr[s];t.writeAny(o)}}getRef(){return 8}}const Ch=e=>{const t=e.readLen(),n=[];for(let i=0;i<t;i++)n.push(e.readAny());return new Pt(n)};class gt{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new gt(this.str)}splice(t){const n=new gt(this.str.slice(t));this.str=this.str.slice(0,t);const i=this.str.charCodeAt(t-1);return i>=55296&&i<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Eh=e=>new gt(e.readString()),_h=[ih,oh,hh,dh,uh,ph,gh],Th=0,Dh=1,Ih=2,Ah=3,Mh=4,Oh=5,jh=6;class mt{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new mt(this.type._copy())}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(i=>{i.deleted?i.id.clock<(t.beforeState.get(i.id.client)||0)&&t._mergeStructs.push(i):i.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(i=>{for(;i!==null;)i.gc(t,!0),i=i.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const Rh=e=>new mt(_h[e.readTypeRef()](e)),hi=(e,t)=>{let n=t,i=0,s;do i>0&&(n=_(n.client,n.clock+i)),s=Yt(e,n),i=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof A);return{item:s,diff:i}},Pi=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},dn=(e,t,n)=>{const{client:i,clock:s}=t.id,o=new A(_(i,s+n),t,_(i,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&o.markDeleted(),t.keep&&(o.keep=!0),t.redone!==null&&(o.redone=_(t.redone.client,t.redone.clock+n)),t.right=o,o.right!==null&&(o.right.left=o),e._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),t.length=n,o},Ss=(e,t)=>bi(e,n=>le(n.deletions,t)),Jo=(e,t,n,i,s,o)=>{const r=e.doc,l=r.store,c=r.clientID,a=t.redone;if(a!==null)return et(e,a);let u=t.parent._item,h=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Jo(e,u,n,i,s,o)===null))return null;for(;u.redone!==null;)u=et(e,u.redone)}const p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(h=t.left,f=t;h!==null;){let y=h;for(;y!==null&&y.parent._item!==u;)y=y.redone===null?null:et(e,y.redone);if(y!==null&&y.parent._item===u){h=y;break}h=h.left}for(;f!==null;){let y=f;for(;y!==null&&y.parent._item!==u;)y=y.redone===null?null:et(e,y.redone);if(y!==null&&y.parent._item===u){f=y;break}f=f.right}}else if(f=null,t.right&&!s){for(h=t;h!==null&&h.right!==null&&(h.right.redone||le(i,h.right.id)||Ss(o.undoStack,h.right.id)||Ss(o.redoStack,h.right.id));)for(h=h.right;h.redone;)h=et(e,h.redone);if(h&&h.right!==null)return null}else h=p._map.get(t.parentSub)||null;const g=U(l,c),x=_(c,g),w=new A(x,h,h&&h.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=x,Pi(w,!0),w.integrate(e,0),w};class A extends Ui{constructor(t,n,i,s,o,r,l,c){super(t,c.getLength()),this.origin=i,this.left=n,this.right=s,this.rightOrigin=o,this.parent=r,this.parentSub=l,this.redone=null,this.content=c,this.info=this.content.isCountable()?Yi:0}set marker(t){(this.info&Un)>0!==t&&(this.info^=Un)}get marker(){return(this.info&Un)>0}get keep(){return(this.info&Gi)>0}set keep(t){this.keep!==t&&(this.info^=Gi)}get countable(){return(this.info&Yi)>0}get deleted(){return(this.info&Ln)>0}set deleted(t){this.deleted!==t&&(this.info^=Ln)}markDeleted(){this.info|=Ln}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Gt&&this.id.client!==this.parent.client&&this.parent.clock>=U(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=us(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=et(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===lt||this.right&&this.right.constructor===lt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===A?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===A&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Gt){const i=Yt(n,this.parent);i.constructor===lt?this.parent=null:this.parent=i.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=us(t,t.doc.store,_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let i=this.left,s;if(i!==null)s=i.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const o=new Set,r=new Set;for(;s!==null&&s!==this.right;){if(r.add(s),o.add(s),Be(this.origin,s.origin)){if(s.id.client<this.id.client)i=s,o.clear();else if(Be(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&r.has(Yt(t.doc.store,s.origin)))o.has(Yt(t.doc.store,s.origin))||(i=s,o.clear());else break;s=s.right}this.left=i}if(this.left!==null){const i=this.left.right;this.right=i,this.left.right=this}else{let i;if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start,this.parent._start=this;this.right=i}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Do(t.doc.store,this),this.content.integrate(t,this),fs(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new lt(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:_(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Be(t.origin,this.lastId)&&this.right===t&&Be(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(i=>{i.p===t&&(i.p=this,!this.deleted&&this.countable&&(i.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Se(t.deleteSet,this.id.client,this.id.clock,this.length),fs(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Z();this.content.gc(t),n?Pa(t,this,new lt(this.id,this.length)):this.content=new _e(this.length)}write(t,n){const i=n>0?_(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,o=this.parentSub,r=this.content.getRef()&xn|(i===null?0:tt)|(s===null?0:vt)|(o===null?0:me);if(t.writeInfo(r),i!==null&&t.writeLeftID(i),s!==null&&t.writeRightID(s),i===null&&s===null){const l=this.parent;if(l._item!==void 0){const c=l._item;if(c===null){const a=ve(l);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else l.constructor===String?(t.writeParentInfo(!0),t.writeString(l)):l.constructor===Gt?(t.writeParentInfo(!1),t.writeLeftID(l)):Z();o!==null&&t.writeString(o)}this.content.write(t,n)}}const Xo=(e,t)=>Nh[t&xn](e),Nh=[()=>{Z()},bh,vh,xh,Eh,yh,Sh,Rh,Ch,wh,()=>{Z()}],Bh=10;class at extends Ui{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){Z()}write(t,n){t.writeInfo(Bh),I(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Zo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Qo="__ $YJS$ __";Zo[Qo]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Zo[Qo]=!0;const Lh=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},Uh=/[\uD800-\uDBFF]/,Ph=/[\uDC00-\uDFFF]/,$h=(e,t)=>{let n=0,i=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&Uh.test(e[n-1])&&n--;i+n<e.length&&i+n<t.length&&e[e.length-i-1]===t[t.length-i-1];)i++;return i>0&&Ph.test(e[e.length-i])&&i--,{index:n,remove:e.length-n-i,insert:t.slice(n,t.length-i)}},Fh=$h,bt=(e,t)=>e>>>t|e<<32-t,Vh=e=>bt(e,2)^bt(e,13)^bt(e,22),Hh=e=>bt(e,6)^bt(e,11)^bt(e,25),zh=e=>bt(e,7)^bt(e,18)^e>>>3,qh=e=>bt(e,17)^bt(e,19)^e>>>10,Kh=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]),Wh=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class Gh{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(Wh),this._W=new Uint32Array(t,64,64)}_updateHash(){const t=this._H,n=this._W;for(let h=16;h<64;h++)n[h]=qh(n[h-2])+n[h-7]+zh(n[h-15])+n[h-16];let i=t[0],s=t[1],o=t[2],r=t[3],l=t[4],c=t[5],a=t[6],u=t[7];for(let h=0,f,p;h<64;h++)f=u+Hh(l)+(l&c^~l&a)+Kh[h]+n[h]>>>0,p=Vh(i)+(i&s^i&o^s&o)>>>0,u=a,a=c,c=l,l=r+f>>>0,r=o,o=s,s=i,i=f+p>>>0;t[0]+=i,t[1]+=s,t[2]+=o,t[3]+=r,t[4]+=l,t[5]+=c,t[6]+=a,t[7]+=u}digest(t){let n=0;for(;n+56<=t.length;){let r=0;for(;r<16&&n+3<t.length;r++)this._W[r]=t[n++]<<24|t[n++]<<16|t[n++]<<8|t[n++];if(n%64!==0){for(this._W.fill(0,r,16);n<t.length;)this._W[r]|=t[n]<<(3-n%4)*8,n++;this._W[r]|=tt<<(3-n%4)*8}this._updateHash()}const i=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<t.length;s++)for(let r=3;r>=0&&n<t.length;r--)this._W[s]|=t[n++]<<r*8;i||(this._W[s-(n%4===0?0:1)]|=tt<<(3-n%4)*8),this._W[14]=t.byteLength/Tl,this._W[15]=t.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let r=0;r<this._H.length;r++)for(let l=0;l<4;l++)o[r*4+l]=this._H[r]>>>(3-l)*8;return o}}const Yh=e=>new Gh().digest(e),R=new T.PluginKey("y-sync"),kt=new T.PluginKey("y-undo");new T.PluginKey("yjs-cursor");const Jh=e=>{for(let n=6;n<e.length;n++)e[n%6]=e[n%6]^e[n];return e.slice(0,6)},Xh=e=>_c(Jh(Yh(Tc(e)))),fn=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!le(t.ds,e.id),Zh=[{light:"#ecd44433",dark:"#ecd444"}],Qh=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){const i=Bt();e.forEach(s=>i.add(s)),t=t.filter(s=>!i.has(s))}e.set(n,rc(t))}return e.get(n)},tu=(e,{colors:t=Zh,colorMapping:n=new Map,permanentUserData:i=null,onFirstRender:s=()=>{},mapping:o}={})=>{let r=!1;const l=new iu(e,o),c=new T.Plugin({props:{editable:a=>{const u=R.getState(a);return u.snapshot==null&&u.prevSnapshot==null}},key:R,state:{init:(a,u)=>({type:e,doc:e.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:i}),apply:(a,u)=>{const h=a.getMeta(R);if(h!==void 0){u=Object.assign({},u);for(const f in h)u[f]=h[f]}return u.addToHistory=a.getMeta("addToHistory")!==!1,u.isChangeOrigin=h!==void 0&&!!h.isChangeOrigin,u.isUndoRedoOperation=h!==void 0&&!!h.isChangeOrigin&&!!h.isUndoRedoOperation,l.prosemirrorView!==null&&h!==void 0&&(h.snapshot!=null||h.prevSnapshot!=null)&&po(0,()=>{l.prosemirrorView!=null&&(h.restore==null?l._renderSnapshot(h.snapshot,h.prevSnapshot,u):(l._renderSnapshot(h.snapshot,h.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:a=>(l.initView(a),o==null&&l._forceRerender(),s(),{update:()=>{const u=c.getState(a.state);if(u.snapshot==null&&u.prevSnapshot==null&&(r||a.state.doc.content.findDiffStart(a.state.doc.type.createAndFill().content)!==null)){if(r=!0,u.addToHistory===!1&&!u.isChangeOrigin){const h=kt.getState(a.state),f=h&&h.undoManager;f&&f.stopCapturing()}l.mux(()=>{u.doc.transact(h=>{h.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(a.state.doc)},R)})}},destroy:()=>{l.destroy()}})});return c},eu=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type==="all")e.setSelection(new T.AllSelection(e.doc));else if(t.type==="node"){const i=ge(n.doc,n.type,t.anchor,n.mapping);e.setSelection(nu(e,i))}else{const i=ge(n.doc,n.type,t.anchor,n.mapping),s=ge(n.doc,n.type,t.head,n.mapping);i!==null&&s!==null&&e.setSelection(T.TextSelection.between(e.doc.resolve(i),e.doc.resolve(s)))}},nu=(e,t)=>{const n=e.doc.resolve(t);return n.nodeAfter?T.NodeSelection.create(e.doc,t):T.TextSelection.near(n)},ui=(e,t)=>({type:t.selection.jsonID,anchor:gn(t.selection.anchor,e.type,e.mapping),head:gn(t.selection.head,e.type,e.mapping)});class iu{constructor(t,n=new Map){this.type=t,this.prosemirrorView=null,this.mux=Lh(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=t.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=ui(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()?(Ys&&this._domSelectionInView===null&&(po(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const t=this.prosemirrorView._root.getSelection();if(t==null||t.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),o=Ae.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||o.clientWidth||0)&&s.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(t,n){n||(n=_o(vo(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(R,{snapshot:t,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const t=this.type.toArray().map(i=>Ge(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(t),0,0));n.setMeta(R,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const t=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Ge(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(n),0,0));if(t){const s=Zt(At(t.anchor,0),i.doc.content.size),o=Zt(At(t.head,0),i.doc.content.size);i.setSelection(T.TextSelection.create(i.doc,s,o))}this.prosemirrorView.dispatch(i.setMeta(R,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(t,n,i){let s=this.doc,o=this.type;if(t||(t=qn(this.doc)),t instanceof Uint8Array||n instanceof Uint8Array)if((!(t instanceof Uint8Array)||!(n instanceof Uint8Array))&&Z(),s=new $t({gc:!1}),ri(s,n),n=qn(s),ri(s,t),t=qn(s),o._item===null){const r=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);o=s.getXmlFragment(r)}else{const r=s.store.clients.get(o._item.id.client)??[],l=pt(r,o._item.id.clock);o=r[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(r=>{const l=i.permanentUserData;l&&l.dss.forEach(h=>{Mt(r,h,f=>{})});const c=(h,f)=>{const p=h==="added"?l.getUserByClientId(f.client):l.getUserByDeletedId(f);return{user:p,type:h,color:Qh(i.colorMapping,i.colors,p)}},a=Lo(o,new Ri(n.ds,t.sv)).map(h=>!h._item.deleted||fn(h._item,t)||fn(h._item,n)?Ge(h,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},t,n,c):null).filter(h=>h!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(a),0,0));this.prosemirrorView.dispatch(u.setMeta(R,{isChangeOrigin:!0}))},R)})}_typeChanged(t,n){if(this.prosemirrorView==null)return;const i=R.getState(this.prosemirrorView.state);if(t.length===0||i.snapshot!=null||i.prevSnapshot!=null){this.renderSnapshot(i.snapshot,i.prevSnapshot);return}this.mux(()=>{const s=(l,c)=>this.mapping.delete(c);Mt(n,n.deleteSet,l=>{if(l.constructor===A){const c=l.content.type;c&&this.mapping.delete(c)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const o=this.type.toArray().map(l=>tr(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(o),0,0));eu(r,this.beforeTransactionSelection,this),r=r.setMeta(R,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Mo}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(t){this.doc.transact(()=>{fi(this.doc,this.type,t,this),this.beforeTransactionSelection=ui(this,this.prosemirrorView.state)},R)}initView(t){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=t,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const tr=(e,t,n,i,s,o)=>{const r=n.mapping.get(e);if(r===void 0){if(e instanceof J)return Ge(e,t,n,i,s,o);throw ct()}return r},Ge=(e,t,n,i,s,o)=>{const r=[],l=c=>{var a,u;if(c instanceof J){const h=tr(c,t,n,i,s,o);h!==null&&r.push(h)}else{const h=(u=(a=c._item.right)==null?void 0:a.content)==null?void 0:u.type;h instanceof Ot&&!h._item.deleted&&h._item.id.client===h.doc.clientID&&(c.applyDelta([{retain:c.length},...h.toDelta()]),h.doc.transact(p=>{h._item.delete(p)}));const f=su(c,t,n,i,s,o);f!==null&&f.forEach(p=>{p!==null&&r.push(p)})}};i===void 0||s===void 0?e.toArray().forEach(l):Lo(e,new Ri(s.ds,i.sv)).forEach(l);try{const c=e.getAttributes(i);i!==void 0&&(fn(e._item,i)?fn(e._item,s)||(c.ychange=o?o("added",e._item.id):{type:"added"}):c.ychange=o?o("removed",e._item.id):{type:"removed"});const a=t.node(e.nodeName,c,r);return n.mapping.set(e,a),a}catch{return e.doc.transact(a=>{e._item.delete(a)},R),n.mapping.delete(e),null}},su=(e,t,n,i,s,o)=>{const r=[],l=e.toDelta(i,s,o);try{for(let c=0;c<l.length;c++){const a=l[c];r.push(t.text(a.insert,hu(a.attributes,t)))}}catch{return e.doc.transact(a=>{e._item.delete(a)},R),null}return r},ou=(e,t)=>{const n=new nt,i=e.map(s=>({insert:s.text,attributes:nr(s.marks,t)}));return n.applyDelta(i),t.mapping.set(n,e),n},ru=(e,t)=>{const n=new J(e.type.name);for(const i in e.attrs){const s=e.attrs[i];s!==null&&i!=="ychange"&&n.setAttribute(i,s)}return n.insert(0,An(e).map(i=>di(i,t))),t.mapping.set(n,e),n},di=(e,t)=>e instanceof Array?ou(e,t):ru(e,t),vs=e=>typeof e=="object"&&e!==null,$i=(e,t)=>{const n=Object.keys(e).filter(s=>e[s]!==null);let i=n.length===Object.keys(t).filter(s=>t[s]!==null).length;for(let s=0;s<n.length&&i;s++){const o=n[s],r=e[o],l=t[o];i=o==="ychange"||r===l||vs(r)&&vs(l)&&$i(r,l)}return i},An=e=>{const t=e.content.content,n=[];for(let i=0;i<t.length;i++){const s=t[i];if(s.isText){const o=[];for(let r=t[i];i<t.length&&r.isText;r=t[++i])o.push(r);i--,n.push(o)}else n.push(s)}return n},er=(e,t)=>{const n=e.toDelta();return n.length===t.length&&n.every((i,s)=>i.insert===t[s].text&&Ws(i.attributes||{}).length===t[s].marks.length&&se(i.attributes,(o,r)=>{var u;const l=Fi(r),c=t[s].marks;return c.find(h=>h.type.name===l)?$i(o,(u=c.find(h=>h.type.name===l))==null?void 0:u.attrs):!1}))},Te=(e,t)=>{if(e instanceof J&&!(t instanceof Array)&&pi(e,t)){const n=An(t);return e._length===n.length&&$i(e.getAttributes(),t.attrs)&&e.toArray().every((i,s)=>Te(i,n[s]))}return e instanceof nt&&t instanceof Array&&er(e,t)},pn=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((n,i)=>t[i]===n),ks=(e,t,n)=>{const i=e.toArray(),s=An(t),o=s.length,r=i.length,l=Zt(r,o);let c=0,a=0,u=!1;for(;c<l;c++){const h=i[c],f=s[c];if(pn(n.mapping.get(h),f))u=!0;else if(!Te(h,f))break}for(;c+a<l;a++){const h=i[r-a-1],f=s[o-a-1];if(pn(n.mapping.get(h),f))u=!0;else if(!Te(h,f))break}return{equalityFactor:c+a,foundMappedChild:u}},lu=e=>{let t="",n=e._start;const i={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof gt?t+=n.content.str:n.content instanceof F&&(i[n.content.key]=null)),n=n.right;return{str:t,nAttrs:i}},cu=(e,t,n)=>{n.mapping.set(e,t);const{nAttrs:i,str:s}=lu(e),o=t.map(a=>({insert:a.text,attributes:Object.assign({},i,nr(a.marks,n))})),{insert:r,remove:l,index:c}=Fh(s,o.map(a=>a.insert).join(""));e.delete(c,l),e.insert(c,r),e.applyDelta(o.map(a=>({retain:a.insert.length,attributes:a.attributes})))},au=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Fi=e=>{var t;return((t=au.exec(e))==null?void 0:t[1])??e},hu=(e,t)=>{const n=[];for(const i in e)n.push(t.mark(Fi(i),e[i]));return n},nr=(e,t)=>{const n={};return e.forEach(i=>{if(i.type.name!=="ychange"){const s=Ct(t.isOMark,i.type,()=>!i.type.excludes(i.type));n[s?`${i.type.name}--${Xh(i.toJSON())}`:i.type.name]=i.attrs}}),n},fi=(e,t,n,i)=>{if(t instanceof J&&t.nodeName!==n.type.name)throw new Error("node name mismatch!");if(i.mapping.set(t,n),t instanceof J){const h=t.getAttributes(),f=n.attrs;for(const p in f)f[p]!==null?h[p]!==f[p]&&p!=="ychange"&&t.setAttribute(p,f[p]):t.removeAttribute(p);for(const p in h)f[p]===void 0&&t.removeAttribute(p)}const s=An(n),o=s.length,r=t.toArray(),l=r.length,c=Zt(o,l);let a=0,u=0;for(;a<c;a++){const h=r[a],f=s[a];if(!pn(i.mapping.get(h),f))if(Te(h,f))i.mapping.set(h,f);else break}for(;u+a+1<c;u++){const h=r[l-u-1],f=s[o-u-1];if(!pn(i.mapping.get(h),f))if(Te(h,f))i.mapping.set(h,f);else break}e.transact(()=>{for(;l-a-u>0&&o-a-u>0;){const f=r[a],p=s[a],g=r[l-u-1],x=s[o-u-1];if(f instanceof nt&&p instanceof Array)er(f,p)||cu(f,p,i),a+=1;else{let w=f instanceof J&&pi(f,p),y=g instanceof J&&pi(g,x);if(w&&y){const v=ks(f,p,i),C=ks(g,x,i);v.foundMappedChild&&!C.foundMappedChild?y=!1:!v.foundMappedChild&&C.foundMappedChild||v.equalityFactor<C.equalityFactor?w=!1:y=!1}w?(fi(e,f,p,i),a+=1):y?(fi(e,g,x,i),u+=1):(i.mapping.delete(t.get(a)),t.delete(a,1),t.insert(a,[di(p,i)]),a+=1)}}const h=l-a-u;if(l===1&&o===0&&r[0]instanceof nt?(i.mapping.delete(r[0]),r[0].delete(0,r[0].length)):h>0&&(t.slice(a,a+h).forEach(f=>i.mapping.delete(f)),t.delete(a,h)),a+u<o){const f=[];for(let p=a;p<o-u;p++)f.push(di(s[p],i));t.insert(a,f)}},R)},pi=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,gn=(e,t,n)=>{if(e===0)return zn(t,0,-1);let i=t._first===null?null:t._first.content.type;for(;i!==null&&t!==i;){if(i instanceof nt){if(i._length>=e)return zn(i,e,-1);if(e-=i._length,i._item!==null&&i._item.next!==null)i=i._item.next.content.type;else{do i=i._item===null?null:i._item.parent,e--;while(i!==t&&i!==null&&i._item!==null&&i._item.next===null);i!==null&&i!==t&&(i=i._item===null?null:i._item.next.content.type)}}else{const s=(n.get(i)||{nodeSize:0}).nodeSize;if(i._first!==null&&e<s)i=i._first.content.type,e--;else{if(e===1&&i._length===0&&s>1)return new ln(i._item===null?null:i._item.id,i._item===null?ve(i):null,null);if(e-=s,i._item!==null&&i._item.next!==null)i=i._item.next.content.type;else{if(e===0)return i=i._item===null?i:i._item.parent,new ln(i._item===null?null:i._item.id,i._item===null?ve(i):null,null);do i=i._item.parent,e--;while(i!==t&&i._item.next===null);i!==t&&(i=i._item.next.content.type)}}}if(i===null)throw Z();if(e===0&&i.constructor!==nt&&i!==t)return uu(i._item.parent,i._item)}return zn(t,t._length,-1)},uu=(e,t)=>{let n=null,i=null;return e._item===null?i=ve(e):n=_(e._item.id.client,e._item.id.clock),new ln(n,i,t.id)},ge=(e,t,n,i)=>{const s=La(n,e);if(s===null||s.type!==t&&!ke(t,s.type._item))return null;let o=s.type,r=0;if(o.constructor===nt)r=s.index;else if(o._item===null||!o._item.deleted){let l=o._first,c=0;for(;c<o._length&&c<s.index&&l!==null;){if(!l.deleted){const a=l.content.type;c++,a instanceof nt?r+=a._length:r+=i.get(a).nodeSize}l=l.right}r+=1}for(;o!==t&&o._item!==null;){const l=o._item.parent;if(l._item===null||!l._item.deleted){r+=1;let c=l._first;for(;c!==null;){const a=c.content.type;if(a===o)break;c.deleted||(a instanceof nt?r+=a._length:r+=i.get(a).nodeSize),c=c.right}}o=l}return r-1};function du(e){const t=e.toArray(),n=i=>{let s;if(i instanceof nt)s=i.toDelta().map(r=>{const l={type:"text",text:r.insert};return r.attributes&&(l.marks=Object.keys(r.attributes).map(c=>{const a=r.attributes[c],h={type:Fi(c)};return Object.keys(a)&&(h.attrs=a),h})),l});else if(i instanceof J){s={type:i.nodeName};const o=i.getAttributes();Object.keys(o).length&&(s.attrs=o);const r=i.toArray();r.length&&(s.content=r.map(n).flat())}else Z();return s};return{type:"doc",content:t.map(n)}}const fu=e=>{const t=kt.getState(e).undoManager;if(t!=null)return t.undo(),!0},pu=e=>{const t=kt.getState(e).undoManager;if(t!=null)return t.redo(),!0},gu=new Set(["paragraph"]),mu=(e,t)=>!(e instanceof A)||!(e.content instanceof mt)||!(e.content.type instanceof Ot||e.content.type instanceof J&&t.has(e.content.type.nodeName))||e.content.type._length===0,xu=({protectedNodes:e=gu,trackedOrigins:t=[],undoManager:n=null}={})=>new T.Plugin({key:kt,state:{init:(i,s)=>{const o=R.getState(s),r=n||new Mo(o.type,{trackedOrigins:new Set([R].concat(t)),deleteFilter:l=>mu(l,e),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:r,prevSel:null,hasUndoOps:r.undoStack.length>0,hasRedoOps:r.redoStack.length>0}},apply:(i,s,o,r)=>{const l=R.getState(r).binding,c=s.undoManager,a=c.undoStack.length>0,u=c.redoStack.length>0;return l?{undoManager:c,prevSel:ui(l,o),hasUndoOps:a,hasRedoOps:u}:a!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:c.undoStack.length>0,hasRedoOps:c.redoStack.length>0}):s}},view:i=>{const s=R.getState(i.state),o=kt.getState(i.state).undoManager;return o.on("stack-item-added",({stackItem:r})=>{const l=s.binding;l&&r.meta.set(l,kt.getState(i.state).prevSel)}),o.on("stack-item-popped",({stackItem:r})=>{const l=s.binding;l&&(l.beforeTransactionSelection=r.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});function ir(e){return!!e.getMeta(R)}function bu(e,t){const n=R.getState(e);return ge(n.doc,n.type,t,n.binding.mapping)||0}function sr(e,t){const n=R.getState(e);return gn(t,n.type,n.binding.mapping)}var Ye=class or extends T.MappablePosition{constructor(t,n){super(t),this.yRelativePosition=n}static fromJSON(t){return new or(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function wu(e,t){const n=sr(t,e);return new Ye(e,n)}function yu(e,t,n){const i=e instanceof Ye?e.yRelativePosition:null;if(ir(t)&&i){const r=bu(n,i);return{position:new Ye(r,i),mapResult:null}}const s=T.getUpdatedPosition(e,t),o=s.position.position;return{position:new Ye(o,i??sr(n,o)),mapResult:s.mapResult}}T.Extension.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>yu(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>wu(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),kt.getState(t).undoManager.undoStack.length===0?!1:n?fu(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),kt.getState(t).undoManager.redoStack.length===0?!1:n?pu(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=xu(this.options.yUndoOptions),i=n.spec.view;n.spec.view=r=>{const{undoManager:l}=kt.getState(r.state);l.restore&&(l.restore(),l.restore=()=>{});const c=i?i(r):void 0;return{destroy:()=>{const a=l.trackedOrigins.has(l),u=l._observers;l.restore=()=>{a&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=u},c!=null&&c.destroy&&c.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=tu(t,s);return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on("beforeTransaction",()=>{try{const r=du(t);if(r.content.length===0)return;this.editor.schema.nodeFromJSON(r).check()}catch(r){return this.editor.emit("contentError",{error:r,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new Y.Plugin({key:new Y.PluginKey("filterInvalidContent"),filterTransaction:()=>{var r;return this.storage.isDisabled!==!1&&((r=t.doc)==null||r.destroy()),!0}})].filter(Boolean)}});function Cs(e){if(!e.length)return Rn.DecorationSet.empty;const t=[],n=e[0].$from.node(0);return e.forEach(i=>{const s=i.$from.pos,o=i.$from.nodeAfter;o&&t.push(Rn.Decoration.node(s,s+o.nodeSize,{class:"ProseMirror-selectednoderange"}))}),Rn.DecorationSet.create(n,t)}function Mn(e,t,n){const i=[],s=e.node(0);typeof n=="number"&&n>=0||(e.sameParent(t)?n=Math.max(0,e.sharedDepth(t.pos)-1):n=e.sharedDepth(t.pos));const o=new kr.NodeRange(e,t,n),r=o.depth===0?0:s.resolve(o.start).posAtIndex(0);return o.parent.forEach((l,c)=>{const a=r+c,u=a+l.nodeSize;if(a<o.start||a>=o.end)return;const h=new Y.SelectionRange(s.resolve(a),s.resolve(u));i.push(h)}),i}var Su=class rr{constructor(t,n){this.anchor=t,this.head=n}map(t){return new rr(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),i=t.resolve(this.head);return new Dt(n,i)}},Dt=class _t extends Y.Selection{constructor(t,n,i,s=1){const{doc:o}=t,r=t===n,l=t.pos===o.content.size&&n.pos===o.content.size,c=r&&!l?o.resolve(n.pos+(s>0?1:-1)):n,a=r&&l?o.resolve(t.pos-(s>0?1:-1)):t,u=Mn(a.min(c),a.max(c),i),h=c.pos>=t.pos?u[0].$from:u[u.length-1].$to,f=c.pos>=t.pos?u[u.length-1].$to:u[0].$from;super(h,f,u),this.depth=i}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof _t&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){const i=t.resolve(n.map(this.anchor)),s=t.resolve(n.map(this.head));return new _t(i,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),o=s[0].$from,r=s[s.length-1].$to;return new _t(o,r,this.depth)}const n=this.ranges[0],i=t.resolve(Math.max(0,n.$from.pos-1));return new _t(this.$anchor,i,this.depth)}extendForwards(){const{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),o=s[0].$from,r=s[s.length-1].$to;return new _t(r,o,this.depth)}const n=this.ranges[this.ranges.length-1],i=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new _t(this.$anchor,i,this.depth)}static fromJSON(t,n){return new _t(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,i,s,o=1){return new this(t.resolve(n),t.resolve(i),s,o)}getBookmark(){return new Su(this.anchor,this.head)}};Dt.prototype.visible=!1;function $e(e){return e instanceof Dt}T.Extension.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,selection:o,tr:r}=i,{anchor:l,head:c}=o;if(!$e(o)){const u=Dt.create(s,l,c,t,-1);return r.setSelection(u),n.dispatch(r),!0}const a=o.extendBackwards();return r.setSelection(a),n.dispatch(r),!0},"Shift-ArrowDown":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,selection:o,tr:r}=i,{anchor:l,head:c}=o;if(!$e(o)){const u=Dt.create(s,l,c,t);return r.setSelection(u),n.dispatch(r),!0}const a=o.extendForwards();return r.setSelection(a),n.dispatch(r),!0},"Mod-a":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,tr:o}=i,r=Dt.create(s,0,s.content.size,t);return o.setSelection(r),n.dispatch(o),!0}}},onSelectionUpdate(){const{selection:e}=this.editor.state;$e(e)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let e=!1,t=!1;return[new Y.Plugin({key:new Y.PluginKey("nodeRange"),props:{attributes:()=>e?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,i)=>{const{key:s}=this.options,o=/Mac/.test(navigator.platform),r=!!i.shiftKey,l=!!i.ctrlKey,c=!!i.altKey,a=!!i.metaKey,u=o?a:l;return(s==null||s==="Shift"&&r||s==="Control"&&l||s==="Alt"&&c||s==="Meta"&&a||s==="Mod"&&u)&&(t=!0),t&&document.addEventListener("mouseup",()=>{t=!1;const{state:h}=n,{doc:f,selection:p,tr:g}=h,{$anchor:x,$head:w}=p;if(x.sameParent(w))return;const y=Dt.create(f,x.pos,w.pos,this.options.depth);g.setSelection(y),n.dispatch(g)},{once:!0}),!1}},decorations:n=>{const{selection:i}=n,s=$e(i);if(e=!1,!t)return s?(e=!0,Cs(i.ranges)):null;const{$from:o,$to:r}=i;if(!s&&o.sameParent(r))return null;const l=Mn(o,r,this.options.depth);return l.length?(e=!0,Cs(l)):null}}})]}});function vu(e){let t="";const n=getComputedStyle(e);for(let i=0;i<n.length;i+=1)t+=`${n[i]}:${n.getPropertyValue(n[i])};`;return t}function ku(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],i=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((s,o)=>{i[o].style.cssText=vu(s)}),t}var Cu={id:"listItemFirstChild",evaluate:({parent:e,isFirst:t})=>t&&e&&["listItem","taskItem"].includes(e.type.name)?1e3:0},Eu={id:"listWrapperDeprioritize",evaluate:({node:e})=>{const t=["listItem","taskItem"],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},_u={id:"tableStructure",evaluate:({node:e,parent:t})=>["tableRow","tableCell","tableHeader"].includes(e.type.name)||t&&t.type.name==="tableHeader"?1e3:0},Tu={id:"inlineContent",evaluate:({node:e})=>e.isInline||e.isText?1e3:0},Du=[Cu,Eu,_u,Tu],Es={edges:["left","top"],threshold:12,strength:500};function Gn(e){return e===void 0||e==="left"?{...Es}:e==="right"?{edges:["right","top"],threshold:12,strength:500}:e==="both"?{edges:["left","right","top"],threshold:12,strength:500}:e==="none"?{edges:[],threshold:0,strength:0}:{...Es,...e}}function Iu(e,t,n){if(n.edges.length===0)return!1;const i=t.getBoundingClientRect(),{threshold:s,edges:o}=n;return o.some(r=>r==="left"?e.x-i.left<s:r==="right"?i.right-e.x<s:r==="top"?e.y-i.top<s:r==="bottom"?i.bottom-e.y<s:!1)}function Au(e,t,n,i){return!t||n.edges.length===0?0:Iu(e,t,n)?n.strength*i:0}var Mu=1e3;function _s(e,t,n,i){let s=Mu,o=!1;if(t.every(l=>{const c=l.evaluate(e);return s-=c,s<=0?(o=!0,!1):!0}),o)return-1;const r=e.view.nodeDOM(e.pos);return s-=Au(i,r,n,e.depth),s<=0?-1:s}function Ts(e,t,n){return Array.from({length:t},(s,o)=>t-1-o).some(s=>n.includes(e.node(s).type.name))}function Ou(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;const i=e.posAtCoords({left:t.x,top:t.y});if(!i)return null;const{doc:s}=e.state,o=s.resolve(i.pos),r=[];n.defaultRules&&r.push(...Du),r.push(...n.rules);const c=Array.from({length:o.depth},(h,f)=>o.depth-f).map(h=>{const f=o.node(h),p=o.before(h);if(n.allowedContainers&&h>0&&!Ts(o,h,n.allowedContainers))return null;const g=h>0?o.node(h-1):null,x=h>0?o.index(h-1):0,w=g?g.childCount:1,y={node:f,pos:p,depth:h,parent:g,index:x,isFirst:x===0,isLast:x===w-1,$pos:o,view:e},v=_s(y,r,n.edgeDetection,t);if(v<0)return null;const C=e.nodeDOM(p);return{node:f,pos:p,depth:h,score:v,dom:C}}).filter(h=>h!==null),a=o.nodeAfter;if(a&&a.isAtom&&!a.isInline){const h=i.pos,f=o.depth+1,p=o.parent,g=o.index(),x=p.childCount;let w=!0;if(n.allowedContainers&&(w=Ts(o,f,n.allowedContainers)),w){const y={node:a,pos:h,depth:f,parent:p,index:g,isFirst:g===0,isLast:g===x-1,$pos:o,view:e},v=_s(y,r,n.edgeDetection,t);if(v>=0){const C=e.nodeDOM(h);C&&c.push({node:a,pos:h,depth:f,score:v,dom:C})}}}if(c.length===0)return null;c.sort((h,f)=>f.score!==h.score?f.score-h.score:f.depth-h.depth);const u=c[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function ju(e,t){let n=e;for(;n!=null&&n.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return(n==null?void 0:n.parentElement)===t.dom?n:void 0}function Ds(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function Ru(e,t,n,i=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;const s=e.dom,o=s.firstElementChild,r=s.lastElementChild;if(!o||!r)return null;const l=o.getBoundingClientRect(),c=r.getBoundingClientRect();if(!Ds(l)||!Ds(c))return null;const a=Math.min(Math.max(l.top+i,n),c.bottom-i),u=.5,h=Math.abs(l.left-c.left)<u,f=Math.abs(l.right-c.right)<u;let p=l;h&&f&&(p=l);const g=Math.min(Math.max(p.left+i,t),p.right-i);return!Number.isFinite(g)||!Number.isFinite(a)?null:{x:g,y:a}}var lr=e=>{const{x:t,y:n,editor:i,nestedOptions:s}=e,{view:o,state:r}=i,l=Ru(o,t,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:c,y:a}=l;if(s!=null&&s.enabled){const g=Ou(o,{x:c,y:a},s);return g?{resultElement:g.dom,resultNode:g.node,pos:g.pos}:{resultElement:null,resultNode:null,pos:null}}const u=o.root.elementsFromPoint(c,a);let h;if(Array.prototype.some.call(u,g=>{if(!o.dom.contains(g))return!1;const x=ju(g,o);return x?(h=x,!0):!1}),!h)return{resultElement:null,resultNode:null,pos:null};let f;try{f=o.posAtDOM(h,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const p=r.doc.nodeAt(f);if(!p){const g=r.doc.resolve(f),x=g.parent;return{resultElement:h,resultNode:x,pos:g.start()}}return{resultElement:h,resultNode:p,pos:f}};function cr(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function Nu(e,t,n,i){const{doc:s}=t.view.state;if(n!=null&&n.enabled&&(i!=null&&i.node)&&i.pos>=0){const a=i.pos,u=i.pos+i.node.nodeSize;return[{$from:s.resolve(a),$to:s.resolve(u)}]}const o=lr({editor:t,x:e.clientX,y:e.clientY,nestedOptions:n});if(!o.resultNode||o.pos===null)return[];const r=o.resultNode.isText||o.resultNode.isAtom?0:-1,l=s.resolve(o.pos),c=s.resolve(o.pos+o.resultNode.nodeSize+r);return Mn(l,c,0)}function Bu(e,t,n,i){const{view:s}=t;if(!e.dataTransfer)return;const{empty:o,$from:r,$to:l}=s.state.selection,c=Nu(e,t,n,i),a=Mn(r,l,0),u=a.some(M=>c.find(P=>P.$from===M.$from&&P.$to===M.$to)),h=o||!u?c:a;if(!h.length)return;const{tr:f}=s.state,p=document.createElement("div"),g=h[0].$from.pos,x=h[h.length-1].$to.pos,w=(n==null?void 0:n.enabled)&&(i==null?void 0:i.node);let y,v;w?(y=s.state.doc.slice(g,x),v=Y.NodeSelection.create(s.state.doc,g)):(v=Dt.create(s.state.doc,g,x),y=v.content()),h.forEach(M=>{const P=s.nodeDOM(M.$from.pos),S=ku(P);p.append(S)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),e.dataTransfer.clearData(),e.dataTransfer.setDragImage(p,0,0);const C=v instanceof Y.NodeSelection?v:void 0;s.dragging={slice:y,move:!0,node:C},f.setSelection(v),s.dispatch(f),document.addEventListener("drop",()=>cr(p),{once:!0})}var Is=(e,t)=>{const n=e.resolve(t),{depth:i}=n;return i===0?t:n.pos-n.parentOffset-1},As=(e,t)=>{const n=e.nodeAt(t),i=e.resolve(t);let{depth:s}=i,o=n;for(;s>0;){const r=i.node(s);s-=1,s===0&&(o=r)}return o},Yn=(e,t)=>{const n=R.getState(e);return n?gn(t,n.type,n.binding.mapping):null},Lu=(e,t)=>{const n=R.getState(e);return n?ge(n.doc,n.type,t,n.binding.mapping)||0:-1},Ms=(e,t)=>{let n=t;for(;n!=null&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},ar=new Y.PluginKey("dragHandle"),hr=({pluginKey:e=ar,element:t,editor:n,computePositionConfig:i,getReferencedVirtualElement:s,onNodeChange:o,onElementDragStart:r,onElementDragEnd:l,nestedOptions:c})=>{const a=document.createElement("div");let u=!1,h=null,f=-1,p,g=null,x=null;function w(){t&&(t.style.visibility="hidden",t.style.pointerEvents="none")}function y(){if(t){if(!n.isEditable){w();return}t.style.visibility="",t.style.pointerEvents="auto"}}function v(S){const k=(s==null?void 0:s())||{getBoundingClientRect:()=>S.getBoundingClientRect()};H.computePosition(k,t,i).then(D=>{Object.assign(t.style,{position:D.strategy,left:`${D.x}px`,top:`${D.y}px`})})}function C(S){r==null||r(S),Bu(S,n,c,{node:h,pos:f}),t&&(t.dataset.dragging="true"),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}function M(S){l==null||l(S),w(),t&&(t.style.pointerEvents="auto",t.dataset.dragging="false")}function P(){if(T.isFirefox()){const S=n.view.dom;requestAnimationFrame(()=>{S.isContentEditable&&(S.contentEditable="false",S.contentEditable="true")})}}return a.appendChild(t),{unbind(){t.removeEventListener("dragstart",C),t.removeEventListener("dragend",M),document.removeEventListener("drop",P),g&&(cancelAnimationFrame(g),g=null,x=null)},plugin:new Y.Plugin({key:typeof e=="string"?new Y.PluginKey(e):e,state:{init(){return{locked:!1}},apply(S,k,D,z){const N=S.getMeta("lockDragHandle"),$=S.getMeta("hideDragHandle");if(N!==void 0&&(u=N),$)return w(),u=!1,h=null,f=-1,o==null||o({editor:n,node:null,pos:-1}),k;if(S.docChanged&&f!==-1&&t)if(ir(S)){const G=Lu(z,p);G!==f&&(f=G)}else{const G=S.mapping.map(f);G!==f&&(f=G,p=Yn(z,f))}return k}},view:S=>{var k;return t.draggable=!0,t.style.pointerEvents="auto",t.dataset.dragging="false",(k=n.view.dom.parentElement)==null||k.appendChild(a),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",t.addEventListener("dragstart",C),t.addEventListener("dragend",M),document.addEventListener("drop",P),{update(D,z){if(!t)return;if(!n.isEditable){w();return}if(u?t.draggable=!1:t.draggable=!0,S.state.doc.eq(z.doc)||f===-1)return;let N=S.nodeDOM(f);if(N=Ms(S,N),N===S.dom||(N==null?void 0:N.nodeType)!==1)return;const $=S.posAtDOM(N,0),G=As(n.state.doc,$),st=Is(n.state.doc,$);h=G,f=st,p=Yn(S.state,f),o==null||o({editor:n,node:h,pos:f}),v(N)},destroy(){t.removeEventListener("dragstart",C),t.removeEventListener("dragend",M),document.removeEventListener("drop",P),g&&(cancelAnimationFrame(g),g=null,x=null),t&&cr(a)}}},props:{handleDOMEvents:{keydown(S){return!t||u||S.hasFocus()&&(w(),h=null,f=-1,o==null||o({editor:n,node:null,pos:-1})),!1},mouseleave(S,k){return u||k.target&&!a.contains(k.relatedTarget)&&(w(),h=null,f=-1,o==null||o({editor:n,node:null,pos:-1})),!1},mousemove(S,k){return!t||u||(x={x:k.clientX,y:k.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!x)return;const{x:D,y:z}=x;x=null;const N=lr({x:D,y:z,editor:n,nestedOptions:c});if(!N.resultElement)return;let $=N.resultElement,G=N.resultNode,st=N.pos;if(!(c!=null&&c.enabled)){if($=Ms(S,$),$===S.dom||($==null?void 0:$.nodeType)!==1)return;const E=S.posAtDOM($,0);G=As(n.state.doc,E),st=Is(n.state.doc,E)}G!==h&&(h=G,f=st??-1,p=Yn(S.state,f),o==null||o({editor:n,node:h,pos:f}),v($),y())})),!1}}}})}};function ur(e){var t,n;return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Gn("none")}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Gn("left")}:{enabled:!0,rules:(t=e.rules)!=null?t:[],defaultRules:(n=e.defaultRules)!=null?n:!0,allowedContainers:e.allowedContainers,edgeDetection:Gn(e.edgeDetection)}}var gi={placement:"left-start",strategy:"absolute"};T.Extension.create({name:"dragHandle",addOptions(){return{render(){const e=document.createElement("div");return e.classList.add("drag-handle"),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const e=this.options.render(),t=ur(this.options.nested);return[hr({computePositionConfig:{...gi,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var Uu=e=>{const{className:t="drag-handle",children:n,editor:i,pluginKey:s=ar,onNodeChange:o,onElementDragStart:r,onElementDragEnd:l,computePositionConfig:c=gi,nested:a=!1}=e,[u,h]=b.useState(null),f=b.useRef(null),p=b.useMemo(()=>ur(a),[JSON.stringify(a)]);return b.useEffect(()=>{let g=null;return u?i.isDestroyed?()=>{f.current=null}:(f.current||(g=hr({editor:i,element:u,pluginKey:s,computePositionConfig:{...gi,...c},onElementDragStart:r,onElementDragEnd:l,onNodeChange:o,nestedOptions:p}),f.current=g.plugin,i.registerPlugin(f.current)),()=>{i.unregisterPlugin(s),f.current=null,g&&(g.unbind(),g=null)}):()=>{f.current=null}},[u,i,o,s,c,r,l,p]),d.jsx("div",{className:t,style:{visibility:"hidden",position:"absolute"},"data-dragging":"false",ref:h,children:n})},Pu=Uu;function $u(){var S,k,D,z,N,$,G,st;const e=m.useEditorInstance(),t=m.useEditableEditor(),{t:n}=B.useLocale(),[i,s]=b.useState(null),[o,r]=b.useState(-1),[l,c]=b.useState(!1),a=(k=(S=e==null?void 0:e.extensionManager)==null?void 0:S.extensions)==null?void 0:k.some(E=>(E==null?void 0:E.name)===Ns.TextAlign.name),u=(z=(D=e==null?void 0:e.extensionManager)==null?void 0:D.extensions)==null?void 0:z.some(E=>(E==null?void 0:E.name)===ue.Indent.name),h=($=(N=e==null?void 0:e.extensionManager)==null?void 0:N.extensions)==null?void 0:$.some(E=>(E==null?void 0:E.name)===Cr.Clear.name);function f(){const E=e.chain();E.setNodeSelection(o).unsetAllMarks(),(i==null?void 0:i.type.name)!=="paragraph"&&E.setParagraph(),E.run()}function p(){e.chain().focus().setNodeSelection(o).run(),document.execCommand("copy")}function g(){e.commands.setNodeSelection(o);const{$anchor:E}=e.state.selection,yt=E.node(1)||e.state.selection.node;e.chain().setMeta("hideDragHandle",!0).insertContentAt(o+((i==null?void 0:i.nodeSize)||0),yt.toJSON()).run()}function x(E){e.commands.setTextAlign(E)}function w(){const E=ue.setNodeIndentMarkup(e.state.tr,o,1);E.setMeta("hideDragHandle",!0),e.view.dispatch&&e.view.dispatch(E)}function y(){const E=ue.setNodeIndentMarkup(e.state.tr,o,-1);e.view.dispatch&&e.view.dispatch(E)}function v(){e.chain().setMeta("hideDragHandle",!0).setNodeSelection(o).deleteSelection().run()}const C=b.useCallback(E=>{E.node&&s(E.node),r(E.pos),requestAnimationFrame(()=>{E.editor.commands.focus()})},[]),M=E=>{var yt;if(E.preventDefault(),o!==-1){const je=(i==null?void 0:i.nodeSize)||0,Vt=o+je,Vi=(i==null?void 0:i.type.name)==="paragraph"&&((yt=i==null?void 0:i.content)==null?void 0:yt.size)===0,dr=Vi?o+2:Vt+2;e.chain().command(({dispatch:Hi,tr:On,state:zi})=>Hi?(Vi?On.insertText("/",o,o+1):On.insert(Vt,zi.schema.nodes.paragraph.create(null,[zi.schema.text("/")])),Hi(On)):!0).focus(dr).run()}};b.useEffect(()=>(l?e.commands.setMeta("lockDragHandle",!0):e.commands.setMeta("lockDragHandle",!1),()=>{e.commands.setMeta("lockDragHandle",!1)}),[l]);const P=E=>{t&&c(E)};return d.jsx(Pu,{className:"richtext-transition-all richtext-duration-200 richtext-ease-out",editor:e,onNodeChange:C,pluginKey:"RichTextBubbleMenuDragHandle",children:d.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[d.jsx(m.ActionButton,{action:M,disabled:!t,icon:"Plus",tooltip:"Insert block"}),d.jsx(m.ActionButton,{disabled:!t,icon:"Grip",tooltip:"Click for options, Hold for drag",action:E=>{E.preventDefault(),E.stopPropagation(),P(!l)}}),d.jsxs(L.DropdownMenu,{onOpenChange:P,open:l,children:[d.jsx(L.DropdownMenuTrigger,{className:"richtext-pointer-events-none"}),d.jsxs(L.DropdownMenuContent,{align:"start",className:"richtext-w-48",hideWhenDetached:!0,side:"bottom",sideOffset:0,children:[d.jsxs(L.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:v,children:[d.jsx(m.IconComponent,{name:"Trash2"}),d.jsx("span",{children:n("editor.remove")})]}),h?d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:f,children:[d.jsx(m.IconComponent,{name:"PaintRoller"}),d.jsx("span",{children:n("editor.clear.tooltip")})]}):null,d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:p,children:[d.jsx(m.IconComponent,{name:"Clipboard"}),d.jsx("span",{children:n("editor.copyToClipboard")})]}),d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:g,children:[d.jsx(m.IconComponent,{name:"Copy"}),d.jsx("span",{children:n("editor.copy")})]}),a||u?d.jsx(L.DropdownMenuSeparator,{}):null,a?d.jsxs(L.DropdownMenuSub,{children:[d.jsxs(L.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[d.jsx(m.IconComponent,{name:"AlignCenter"}),d.jsx("span",{children:n("editor.textalign.tooltip")})]}),d.jsx(L.DropdownMenuPortal,{children:d.jsxs(L.DropdownMenuSubContent,{children:[d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("left"),children:[d.jsx(m.IconComponent,{name:"AlignLeft"}),d.jsx("span",{children:n("editor.textalign.left.tooltip")})]}),d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("center"),children:[d.jsx(m.IconComponent,{name:"AlignCenter"}),d.jsx("span",{children:n("editor.textalign.center.tooltip")})]}),d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("right"),children:[d.jsx(m.IconComponent,{name:"AlignRight"}),d.jsx("span",{children:n("editor.textalign.right.tooltip")})]})]})})]}):null,u?d.jsxs(L.DropdownMenuSub,{children:[d.jsxs(L.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[d.jsx(m.IconComponent,{name:"IndentIncrease"}),d.jsx("span",{children:n("editor.indent")})]}),d.jsx(L.DropdownMenuPortal,{children:d.jsxs(L.DropdownMenuSubContent,{children:[d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:((G=i==null?void 0:i.attrs)==null?void 0:G.indent)>=ue.IndentProps.max,onClick:w,children:[d.jsx(m.IconComponent,{name:"IndentIncrease"}),d.jsx("span",{children:n("editor.indent.tooltip")})]}),d.jsxs(L.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:((st=i==null?void 0:i.attrs)==null?void 0:st.indent)<=ue.IndentProps.min,onClick:y,children:[d.jsx(m.IconComponent,{name:"IndentDecrease"}),d.jsx("span",{children:n("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}exports.RichTextBubbleCallout=Lr;exports.RichTextBubbleColumns=Ur;exports.RichTextBubbleDrawer=tl;exports.RichTextBubbleExcalidraw=nl;exports.RichTextBubbleIframe=il;exports.RichTextBubbleImage=ul;exports.RichTextBubbleImageGif=dl;exports.RichTextBubbleKatex=ol;exports.RichTextBubbleLink=ll;exports.RichTextBubbleMenuDragHandle=$u;exports.RichTextBubbleMermaid=xl;exports.RichTextBubbleTable=bl;exports.RichTextBubbleText=Sl;exports.RichTextBubbleTwitter=vl;exports.RichTextBubbleVideo=fl;
|
|
1
|
+
"use strict";var bo=Object.create;var Rn=Object.defineProperty;var wo=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var So=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty;var Co=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ko=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yo(t))!vo.call(e,s)&&s!==n&&Rn(e,s,{get:()=>t[s],enumerable:!(i=wo(t,s))||i.enumerable});return e};var Eo=(e,t,n)=>(n=e!=null?bo(So(e)):{},ko(t||!e||!e.__esModule?Rn(n,"default",{value:e,enumerable:!0}):n,e));var Re=(e,t,n)=>Co(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),T=require("./index-DwSnESy-.cjs"),H=require("./index-D7wfvzJg.cjs"),W=require("@tiptap/pm/state"),Rs=require("./Table-C1_xLqV0.cjs"),js=require("./clsx-BSBE1eoY.cjs"),b=require("react"),Ns=require("react-dom"),m=require("./index-BLrMslr7.cjs"),je=require("./Callout.cjs"),ht=require("./Katex-BFIYLrwm.cjs"),B=require("./index-BqL4vAWE.cjs"),ie=require("./delete-node-CosiBes5.cjs"),Ki=require("./Column.cjs");require("./theme.cjs");const Dt=require("./separator-BuG1zwKa.cjs"),$e=require("./Drawer-kEO7KzzC.cjs"),qi=require("easydrawer"),Ye=require("./shortId-Bfj8TyNr.cjs"),Kt=require("./popover-DCJpsZx0.cjs"),ae=require("./Excalidraw.cjs"),Ht=require("./Iframe-Bk5OIlvy.cjs"),_o=require("./ImageGif.cjs"),To=require("katex"),Je=require("lucide-react"),Fe=require("./LinkEditBlock-DhesHreq.cjs"),jn=require("@tiptap/pm/view"),Io=require("@tiptap/pm/model"),U=require("./dropdown-menu-CUeq1boX.cjs"),Do=require("./Clear.cjs"),ue=require("./Indent-XaZNTsOk.cjs"),Ls=require("./TextAlign.cjs"),Xn=require("./Mermaid.cjs"),Ao=require("./Bold.cjs"),Oo=require("./Code.cjs");require("./index-CMLwKzI0.cjs");const Mo=require("./Color.cjs"),Ro=require("./Highlight.cjs"),jo=require("./Italic.cjs"),No=require("./SlashCommandNodeView-CojfS61Q.cjs"),Lo=require("./Strike.cjs"),Bo=require("./TextUnderline.cjs"),Nn=require("./Twitter-Cj-0yyQQ.cjs");function Uo(e,t){const n=Math.min(e.top,t.top),i=Math.max(e.bottom,t.bottom),s=Math.min(e.left,t.left),o=Math.max(e.right,t.right)-s,l=i-n,c=s,a=n;return new DOMRect(c,a,o,l)}var Po=class{constructor({editor:e,element:t,view:n,pluginKey:i="bubbleMenu",updateDelay:s=250,resizeDelay:r=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:c,options:a}){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:u,state:f,from:p,to:g})=>{const{doc:x,selection:w}=f,{empty:y}=w,C=!x.textBetween(p,g).length&&T.isTextSelection(f.selection),k=this.element.contains(document.activeElement);return!(!(u.hasFocus()||k)||y||C||!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:u})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((f=this.element.parentNode)!=null&&f.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,f)=>{const p=!(f!=null&&f.selection.eq(u.state.selection)),g=!(f!=null&&f.doc.eq(u.state.doc));!p&&!g||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,p,g,f)},this.updateDelay))},this.updateHandler=(u,f,p,g)=>{const{composing:x}=u;if(x||!f&&!p)return;if(!this.getShouldShow(g)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const f=u.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"&&this.updateOptions(f.options)};var h;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=r,this.appendTo=l,this.scrollTarget=(h=a==null?void 0:a.scrollTarget)!=null?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 e=[];return this.floatingUIOptions.flip&&e.push(H.flip(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(H.shift(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(H.offset(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(H.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(H.size(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(H.autoPlacement(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(H.hide(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(H.inline(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,n;const{selection:i}=this.editor.state,s=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(s)return s;if(!((n=(t=this.view)==null?void 0:t.dom)!=null&&n.parentNode))return;const r=T.posToDOMRect(this.view,i.from,i.to);let o={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(i instanceof W.NodeSelection){let l=this.view.nodeDOM(i.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(o={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(i instanceof Rs.CellSelection){const{$anchorCell:l,$headCell:c}=i,a=l?l.pos:c.pos,h=c?c.pos:l.pos,u=this.view.nodeDOM(a),f=this.view.nodeDOM(h);if(!u||!f)return;const p=u===f?u.getBoundingClientRect():Uo(u.getBoundingClientRect(),f.getBoundingClientRect());o={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return o}updatePosition(){const e=this.virtualElement;e&&H.computePosition(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:i,middlewareData:s})=>{var r,o;if((r=s.hide)!=null&&r.referenceHidden||(o=s.hide)!=null&&o.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:n}=e,i=n.selection.from!==n.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),r=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,r,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,r=Math.min(...s.map(c=>c.$from.pos)),o=Math.max(...s.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:r,to:o}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.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(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.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()}},Bs=e=>new W.Plugin({key:typeof e.pluginKey=="string"?new W.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Po({view:t,...e})});T.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Bs({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})]:[]}});var $o=class{constructor({editor:e,element:t,view:n,pluginKey:i="floatingMenu",updateDelay:s=250,resizeDelay:r=60,options:o,appendTo:l,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:f}=u,{$anchor:p,empty:g}=f,x=p.depth===1,w=p.parent.isTextblock&&!p.parent.type.spec.code&&!p.parent.textContent&&p.parent.childCount===0&&!this.getTextContent(p.parent);return!(!h.hasFocus()||!g||!x||!w||!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=(h,u,f,p)=>{const{composing:g}=h;if(g||!u&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta(this.pluginKey);u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var a;this.editor=e,this.element=t,this.view=n,this.pluginKey=i,this.updateDelay=s,this.resizeDelay=r,this.appendTo=l,this.scrollTarget=(a=o==null?void 0:o.scrollTarget)!=null?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(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(H.flip(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(H.shift(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(H.offset(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(H.arrow(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(H.size(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(H.autoPlacement(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(H.hide(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(H.inline(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:n}=this.view,{selection:i}=n,{ranges:s}=i,r=Math.min(...s.map(c=>c.$from.pos)),o=Math.max(...s.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:r,to:o})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const n=(t=e.options.scrollTarget)!=null?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to),n={getBoundingClientRect:()=>t,getClientRects:()=>[t]};H.computePosition(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:i,y:s,strategy:r,middlewareData:o})=>{var l,c;if((l=o.hide)!=null&&l.referenceHidden||(c=o.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${i}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!(t!=null&&t.selection.eq(e.state.selection)),i=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,n,i,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.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()}},Us=e=>new W.Plugin({key:typeof e.pluginKey=="string"?new W.PluginKey(e.pluginKey):e.pluginKey,view:t=>new $o({view:t,...e})});T.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[Us({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 Ps(e,t){return e??new W.PluginKey(t)}var Fo=typeof window<"u"?b.useLayoutEffect:b.useEffect,$s=new Set(["left","opacity","position","top","visibility","width"]),Vo=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"]),Ho=new Set(["children","className","style"]),zo=new Set(["tabIndex"]),Ko=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),qo={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Zn(e,t){return/^on[A-Z]/.test(e)&&typeof t=="function"}function Wo(e){return e.startsWith("aria-")||e.startsWith("data-"),e}function Go(e){return e.startsWith("aria-")||e.startsWith("data-")||Ko.has(e)}function Fs(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Yo(e){var t;const n=e.endsWith("Capture"),s=(n?e.slice(0,-7):e).slice(2);return{eventName:(t=qo[s])!=null?t:s.toLowerCase(),options:n?{capture:!0}:void 0}}function Jo(e,t){let n=t.defaultPrevented,i=!1;const s=Object.create(t);return Object.defineProperties(s,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>i},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{i=!0,t.stopPropagation()}}}),s}function Ln(e){return zo.has(e)}function Wi(e,t,n){if(t==="tabIndex"){e.tabIndex=Number(n);return}e[t]=n}function Xo(e,t){if(t==="tabIndex"){e.removeAttribute("tabindex");return}const n=e[t];if(typeof n=="boolean"){e[t]=!1;return}if(typeof n=="number"){e[t]=0;return}e[t]=""}function Zo(e,t){return typeof t!="number"||t===0||e.startsWith("--")||Vo.has(e)?String(t):`${t}px`}function Qo(e,t){$s.has(t)||e.style.removeProperty(Fs(t))}function tl(e,t,n){$s.has(t)||e.style.setProperty(Fs(t),Zo(t,n))}function el(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(s=>{if(Ho.has(s)||!Go(s)||Zn(s,t[s])||Zn(s,n[s]))return;const r=t[s],o=n[s];if(r===o)return;const l=Wo(s);if(o==null||o===!1){Ln(s)&&Xo(e,s),e.removeAttribute(l);return}if(o===!0){Ln(s)&&Wi(e,s,!0),e.setAttribute(l,"");return}if(Ln(s)){Wi(e,s,o);return}e.setAttribute(l,String(o))})}function nl(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}function il(e,t,n){const i=t??{},s=n??{};new Set([...Object.keys(i),...Object.keys(s)]).forEach(o=>{const l=i[o],c=s[o];if(l!==c){if(c==null){Qo(e,o);return}tl(e,o,c)}})}function sl(e,t,n){t.forEach(({eventName:s,listener:r,options:o})=>{e.removeEventListener(s,r,o)});const i=[];return Object.entries(n).forEach(([s,r])=>{if(!Zn(s,r))return;const{eventName:o,options:l}=Yo(s),c=a=>{r(Jo(e,a))};e.addEventListener(o,c,l),i.push({eventName:o,listener:c,options:l})}),i}function Vs(e,t){const n=b.useRef({}),i=b.useRef([]);Fo(()=>{const s=n.current;return nl(e,s.className,t.className),il(e,s.style,t.style),el(e,s,t),i.current=sl(e,i.current,t),n.current=t,()=>{i.current.forEach(({eventName:r,listener:o,options:l})=>{e.removeEventListener(r,o,l)}),i.current=[]}},[e,t])}var it=b.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:r=null,getReferencedVirtualElement:o,options:l,children:c,...a},h)=>{const u=b.useRef(document.createElement("div")),f=b.useRef(Ps(e,"bubbleMenu")).current;Vs(u.current,a),typeof h=="function"?h(u.current):h&&(h.current=u.current);const{editor:p}=js.useCurrentEditor(),g=t||p,x={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:f,shouldShow:r,getReferencedVirtualElement:o,options:l},w=b.useRef(x);w.current=x;const[y,C]=b.useState(!1),k=b.useRef(!0);return b.useEffect(()=>{if(g!=null&&g.isDestroyed)return;if(!g){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const A=u.current;A.style.visibility="hidden",A.style.position="absolute";const L=Bs({...w.current,editor:g,element:A});g.registerPlugin(L);const S=w.current.pluginKey;return k.current=!0,C(!0),()=>{C(!1),g.unregisterPlugin(S),window.requestAnimationFrame(()=>{A.parentNode&&A.parentNode.removeChild(A)})}},[g]),b.useEffect(()=>{if(!(!y||!g||g.isDestroyed)){if(k.current){k.current=!1;return}g.view.dispatch(g.state.tr.setMeta(f,{type:"updateOptions",options:w.current}))}},[y,g,n,i,r,l,s,o,f]),Ns.createPortal(c,u.current)});b.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:i,appendTo:s,shouldShow:r=null,options:o,children:l,...c},a)=>{const h=b.useRef(document.createElement("div")),u=b.useRef(Ps(e,"floatingMenu")).current;Vs(h.current,c),typeof a=="function"?a(h.current):a&&(a.current=h.current);const{editor:f}=js.useCurrentEditor(),p=t||f,g={updateDelay:n,resizeDelay:i,appendTo:s,pluginKey:u,shouldShow:r,options:o},x=b.useRef(g);x.current=g;const[w,y]=b.useState(!1),C=b.useRef(!0);return b.useEffect(()=>{if(p!=null&&p.isDestroyed)return;if(!p){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const k=h.current;k.style.visibility="hidden",k.style.position="absolute";const A=Us({...x.current,editor:p,element:k});p.registerPlugin(A);const L=x.current.pluginKey;return C.current=!0,y(!0),()=>{y(!1),p.unregisterPlugin(L),window.requestAnimationFrame(()=>{k.parentNode&&k.parentNode.removeChild(k)})}},[p]),b.useEffect(()=>{if(!(!w||!p||p.isDestroyed)){if(C.current){C.current=!1;return}p.view.dispatch(p.state.tr.setMeta(u,{type:"updateOptions",options:x.current}))}},[w,p,n,i,r,o,s,u]),Ns.createPortal(l,h.current)});const rl=[{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 ol(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{type:i,title:s,body:r}=ht.useAttributes(t,je.Callout.name,{type:"note",title:"",body:""}),[o,l]=b.useState(!1),[c,a]=b.useState("note"),[h,u]=b.useState(""),[f,p]=b.useState("");b.useEffect(()=>{o&&(a(i||"note"),u(s||""),p(r||""))},[o,i,s,r]);const g=b.useCallback(()=>{t&&(t.chain().updateAttributes(je.Callout.name,{type:c,title:h,body:f}).focus().run(),l(!1))},[t,c,h,f]),x=b.useCallback(()=>{l(!1)},[]),w=b.useCallback(()=>{ie.deleteNode(je.Callout.name,t)},[t]),y=b.useCallback(()=>t.isActive(je.Callout.name),[t]);return e?d.jsx(it,{editor:t,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:y,children:d.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:[d.jsxs(m.Dialog,{onOpenChange:l,open:o,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{icon:"Pencil",tooltip:n("editor.callout.edit.title")})}),d.jsxs(m.DialogContent,{children:[d.jsx(m.DialogTitle,{children:n("editor.callout.edit.title")}),d.jsxs("div",{className:"richtext-space-y-4 richtext-py-4",children:[d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.type")}),d.jsxs(m.Select,{onValueChange:a,value:c,children:[d.jsx(m.SelectTrigger,{children:d.jsx(m.SelectValue,{className:"richtext-text-accent",placeholder:n("editor.callout.dialog.type.placeholder")})}),d.jsx(m.SelectContent,{children:rl.map(C=>d.jsx(m.SelectItem,{value:C.value,children:n(`editor.callout.type.${C.value}`)},C.value))})]})]}),d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.title.label")}),d.jsx(m.Input,{onChange:C=>u(C.target.value),placeholder:n("editor.callout.dialog.title.placeholder"),type:"text",value:h})]}),d.jsxs("div",{className:"richtext-space-y-2",children:[d.jsx(m.Label,{children:n("editor.callout.dialog.body.label")}),d.jsx(m.Input,{onChange:C=>p(C.target.value),placeholder:n("editor.callout.dialog.body.placeholder"),type:"text",value:f})]})]}),d.jsxs(m.DialogFooter,{children:[d.jsx(m.Button,{onClick:x,variant:"outline",children:n("editor.callout.dialog.button.cancel")}),d.jsx(m.Button,{onClick:g,children:n("editor.callout.dialog.button.apply")})]})]})]}),d.jsx(m.ActionButton,{action:w,icon:"Trash2",tooltip:n("editor.delete")})]})}):d.jsx(d.Fragment,{})}function ll(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),i=b.useCallback(()=>t.isActive(Ki.MultipleColumnNode.name),[t]),s=b.useCallback(()=>ie.deleteNode(Ki.MultipleColumnNode.name,t),[t]),r=b.useCallback(()=>t.chain().focus().addColBefore().run(),[t]),o=b.useCallback(()=>t.chain().focus().addColAfter().run(),[t]),l=b.useCallback(()=>t.chain().focus().deleteCol().run(),[t]);return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleColumns",shouldShow:i,children:d.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:[d.jsx(m.ActionButton,{action:r,icon:"ColumnAddLeft",tooltip:n("editor.table.menu.insertColumnBefore")}),d.jsx(m.ActionButton,{action:o,icon:"ColumnAddRight",tooltip:n("editor.table.menu.insertColumnAfter")}),d.jsx(m.ActionButton,{action:l,icon:"DeleteColumn",tooltip:n("editor.table.menu.deleteColumn")}),d.jsx(m.ActionButton,{action:s,icon:"Trash2",tooltip:n("editor.table.menu.delete_column")})]})}):d.jsx(d.Fragment,{})}function cl(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,r)=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[r],action:()=>e.commands.updateImage({width:B.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:B.IMAGE_SIZE[s]})}}))}function al(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,r)=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[r],action:()=>e.commands.updateImageGif({width:B.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:B.IMAGE_SIZE[s]})}}))}function ul(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var r,o;return(o=(r=e.commands)==null?void 0:r.setAlignImage)==null?void 0:o.call(r,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function hl(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var r,o;return(o=(r=e.commands)==null?void 0:r.setAlignImageGif)==null?void 0:o.call(r,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function dl(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var r,o;return(o=(r=e.commands)==null?void 0:r.setAlignImageMermaid)==null?void 0:o.call(r,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function fl(e,t){const n=["left","center","right"],i={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return n.map(s=>({type:`image-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.textalign.${s}.tooltip`),icon:i[s],action:()=>{var r,o;return(o=(r=e.commands)==null?void 0:r.setAlignImageDrawer)==null?void 0:o.call(r,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function pl(e){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:m.ActionButton,componentProps:{tooltip:n.tooltip,icon:n.icon,action:()=>e.commands.updateVideo({align:n.type}),isActive:()=>e.getAttributes("video").align===n.type}}))}function gl(e,t){const n=["size-small","size-medium","size-large"],i=["SizeS","SizeM","SizeL"];return n.map((s,r)=>({type:`video-${s}`,component:m.ActionButton,componentProps:{tooltip:t(`editor.${s.replace("-",".")}.tooltip`),icon:i[r],action:()=>e.commands.updateVideo({width:B.VIDEO_SIZE[s]}),isActive:()=>e.isActive("video",{width:B.VIDEO_SIZE[s]})}}))}function ml(e,t){return[{type:"flipX",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const n=e.getAttributes("image"),{flipX:i}=n;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!i}).run()}}},{type:"flipY",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const n=e.getAttributes("image"),{flipY:i}=n;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!i}).run()}}},...cl(e,t),...ul(e,t),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function xl(e,t){return[...al(e,t),...hl(e,t),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function bl(e,t){return[...dl(e,t),{type:"edit",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function wl(e,t){return[...fl(e,t),{type:"edit",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}function yl(e,t){return[...gl(e,t),...pl(e),{type:"remove",component:m.ActionButton,componentProps:{editor:e,tooltip:t("editor.remove"),icon:"Trash2",action:()=>{const{state:n,dispatch:i}=e.view;T.deleteSelection(n,i)}}}]}let he=!1;function Sl({editor:e,attrs:t,extension:n}){const[i,s]=b.useState(!1),r=b.useRef(null),o=b.useRef(null),{alt:l,align:c}=t,a=n==null?void 0:n.options.upload,h=()=>{(async()=>{const v=document.querySelector("#easydrawer");v&&(r.current=new qi.Editor(v,{wheelEventsEnabled:!1,disableZoom:!0}),o.current=qi.makeDropdownToolbar(r.current),o.current.addDefaultToolWidgets(),r.current.loadFromSVG(decodeURIComponent(l)))})()};b.useEffect(()=>{i&&setTimeout(()=>{h()},200)},[i]);const u=async()=>{if(r.current){const S=r.current.toSVG(),v=S.outerHTML,I=`drawer-${Ye.shortId()}.svg`;let z=Ye.i(S.outerHTML);if(a){const N=m.dataURLtoFile(z,I);z=await a(N)}e==null||e.chain().focus().setDrawer({type:"drawer",src:z,alt:encodeURIComponent(v),width:426,height:212},!!v).run(),e==null||e.commands.setAlignImageDrawer(c)}s(!1)},f=S=>{const v=r.current.toolController.getPrimaryTools()[2],I=o.current.getWidgetById("pen-1");v&&I&&(v.setColor(S),I.serializeState())},p=S=>{const v=r.current.toolController.getPrimaryTools()[2],I=o.current.getWidgetById("pen-1");v&&I&&(v.setThickness(S),I.serializeState())},g=S=>{const v=r.current.toolController.getPrimaryTools()[3],I=o.current.getWidgetById("pen-2");v&&I&&(v.setColor(S),I.serializeState())},x=S=>{const v=o.current.getWidgetById("shape");v&&v.setShapeType(S)},w=S=>{const v=r.current.toolController.getPrimaryTools()[5],I=o.current.getWidgetById("shape");v&&I&&(v.setColor(S),I.serializeState())},y=S=>{const v=r.current.toolController.getPrimaryTools()[5],I=o.current.getWidgetById("shape");v&&I&&(v.setThickness(S),I.serializeState())},C=S=>{const v=r.current.toolController.getPrimaryTools()[5],I=o.current.getWidgetById("shape");v&&I&&(v.setBorderColor(S),I.serializeState())},k=()=>{if(he){for(;r.current.history.redoStackSize>0;)r.current.history.redo();he=!1;return}r.current.history.undo()},A=()=>{he||r.current.history.redo()},L=()=>{if(!he){for(;r.current.history.undoStackSize>0;)k();he=!0}};return d.jsxs(m.Dialog,{onOpenChange:s,open:i,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{action:()=>s(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:"Edit Drawer"}),d.jsxs("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[d.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),d.jsx($e.ControlDrawer,{changeBorderColorShape:C,changeColorShape:w,changeShape:x,onClear:L,onRedo:A,onThicknessChange:y,onUndo:k,refEditor:r,setColorHighlight:g,setColorPen:f,setThicknessPen:p})]}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:u,type:"button",children:"Save changes"})})]})]})}function vl({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):d.jsx(d.Fragment,{})}function Cl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=ht.useAttributes(i,$e.Drawer.name),r=m.useExtension($e.Drawer.name),o=({editor:c})=>{const{selection:a}=c.view.state,{$from:h,to:u}=a;let f=!1;return c.view.state.doc.nodesBetween(h.pos,u,p=>{if(p.type.name===$e.Drawer.name)return f=!0,!1}),f},l=b.useMemo(()=>wl(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleDrawer",shouldShow:o,children:l!=null&&l.length?d.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:l==null?void 0:l.map((c,a)=>c.type==="edit"&&(s!=null&&s.src)?d.jsx(Sl,{attrs:s,editor:i,extension:r},`bubbleMenu-drawer-${a}`):d.jsx(vl,{editor:i,item:c},`bubbleMenu-drawer-${a}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}const Hs=({width:e,maxWidth:t,height:n,onOk:i,children:s})=>{const{t:r}=B.useLocale(),[o,l]=b.useState({width:"",height:"",maxWidth:""});b.useEffect(()=>{l({width:e,height:n,maxWidth:t})},[n,t,e]);function c(a){a.preventDefault(),a.stopPropagation(),i(o)}return d.jsxs(Kt.Popover,{modal:!0,children:[d.jsx(Kt.PopoverTrigger,{asChild:!0,children:s}),d.jsx(Kt.PopoverContent,{children:d.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:c,children:[d.jsx(m.Label,{className:"mb-[6px]",children:"Width"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...o,width:a.target.value}),required:!0,type:"number",value:o.width})})}),d.jsx(m.Label,{className:"mb-[6px]",children:"Max Width"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...o,maxWidth:a.target.value}),required:!0,type:"number",value:o.maxWidth})})}),d.jsx(m.Label,{className:"mb-[6px]",children:"Height"}),d.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:d.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:d.jsx(m.Input,{onChange:a=>l({...o,height:a.target.value}),required:!0,type:"number",value:o.height})})}),d.jsx(m.Button,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:r("editor.link.dialog.button.apply")})]})})]})},Rt=new Map;function kl(e){const t=e.options.element;Rt.has("width")||Rt.set("width",t.clientWidth),Rt.has("width")&&Rt.get("width")<=0&&Rt.set("width",t.clientWidth);const n={attributes:!0,childList:!0,subtree:!0},i=function(){Rt.set("width",t.clientWidth)},s=new MutationObserver(i);return s.observe(t,n),e.on("destroy",()=>{s.disconnect()}),{width:Rt.get("width")}}function El(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{width:i}=kl(t),s=ht.useAttributes(t,ae.Excalidraw.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:r,createUser:o,width:l,height:c}=s,a=b.useCallback(p=>{t.chain().updateAttributes(ae.Excalidraw.name,p).setNodeSelection(t.state.selection.from).focus().run()},[t]),h=b.useCallback(()=>{const p=m.EVENTS.EXCALIDRAW(t.id);m.emit(p,s)},[t,s]),u=b.useCallback(()=>t.isActive(ae.Excalidraw.name),[t]),f=b.useCallback(()=>ie.deleteNode(ae.Excalidraw.name,t),[t]);return b.useEffect(()=>{r&&(h(),t.chain().updateAttributes(ae.Excalidraw.name,{defaultShowPicker:!1}).focus().run())},[o,r,t,h]),e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleExcalidraw",shouldShow:u,children:d.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:[d.jsx(m.ActionButton,{action:h,icon:"Pencil",tooltip:n("editor.edit")}),d.jsx(Hs,{height:c,maxWidth:i,onOk:a,width:l,children:d.jsx(m.ActionButton,{icon:"Settings",tooltip:n("editor.settings")})}),d.jsx(m.ActionButton,{action:f,icon:"Trash2",tooltip:n("editor.delete")})]})}):d.jsx(d.Fragment,{})}function _l(){const e=m.useEditableEditor(),t=m.useEditorInstance(),{t:n}=B.useLocale(),{width:i,height:s,src:r}=ht.useAttributes(t,Ht.Iframe.name,{width:0,height:0,src:"",defaultShowPicker:!1}),[o,l]=b.useState(!1),[c,a]=b.useState(""),h=b.useCallback(w=>{var y;(y=w==null?void 0:w.preventDefault)==null||y.call(w),l(!1)},[l]);b.useEffect(()=>{o&&a(r)},[o,r]);const u=b.useCallback(w=>{var C;(C=w==null?void 0:w.preventDefault)==null||C.call(w);const y=Ht.getServiceSrc(c);t.chain().updateAttributes(Ht.Iframe.name,{src:(y==null?void 0:y.src)||c}).setNodeSelection(t.state.selection.from).focus().run(),l(!1)},[t,c,l]),f=b.useCallback(()=>{window.open(r,"_blank")},[r]),p=b.useCallback(w=>{t.chain().updateAttributes(Ht.Iframe.name,w).setNodeSelection(t.state.selection.from).focus().run()},[t]),g=b.useCallback(()=>t.isActive(Ht.Iframe.name)&&!r,[t,r]),x=b.useCallback(()=>ie.deleteNode(Ht.Iframe.name,t),[t]);return e?d.jsx(d.Fragment,{children:d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleIframe",shouldShow:g,children:d.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:[d.jsx(m.ActionButton,{action:f,icon:"Eye",tooltip:"Visit Link"}),d.jsxs(m.Dialog,{onOpenChange:l,open:o,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{icon:"Pencil",tooltip:"Open Edit Link"})}),d.jsxs(m.DialogContent,{children:[d.jsx(m.DialogHeader,{children:d.jsx(m.DialogTitle,{children:"Edit Link Iframe"})}),d.jsx(m.Input,{autoFocus:!0,onInput:w=>a(w.target.value),placeholder:"Enter link",type:"url",value:c}),d.jsxs(m.DialogFooter,{children:[d.jsx(m.Button,{onClick:h,type:"button",children:"Cancel"}),d.jsx(m.Button,{onClick:u,type:"button",children:"OK"})]})]})]}),d.jsx(Hs,{height:s,onOk:p,width:i,children:d.jsx(m.ActionButton,{icon:"Settings",tooltip:n("editor.settings")})}),d.jsx(m.ActionButton,{action:x,icon:"Trash2",tooltip:n("editor.delete")})]})})}):d.jsx(d.Fragment,{})}function Tl({children:e,visible:t,toggleVisible:n}){const{t:i}=B.useLocale(),s=m.useEditorInstance(),r=ht.useAttributes(s,ht.Katex.name,{text:"",macros:""}),{text:o,macros:l}=r,[c,a]=b.useState(decodeURIComponent(o||"")),[h,u]=b.useState(decodeURIComponent(l||""));b.useEffect(()=>{t&&(a(decodeURIComponent(o||"")),u(decodeURIComponent(l||"")))},[t]);const f=b.useCallback(()=>{s.chain().focus().setKatex({text:encodeURIComponent(c),macros:encodeURIComponent(h)}).run(),a(""),u(""),n(!1)},[s,c,h,n]),p=b.useMemo(()=>{try{return To.renderToString(c,{macros:ht.safeJSONParse(h||"")})}catch{return c}},[c,h]),g=b.useMemo(()=>`${c}`.trim()?p:null,[c,p]);return d.jsxs(m.Dialog,{onOpenChange:n,open:t,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:e}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:i("editor.formula.dialog.text")}),d.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:d.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[d.jsxs("div",{className:"richtext-flex-1",children:[d.jsx(m.Label,{className:"mb-[6px]",children:"Expression"}),d.jsx(m.Textarea,{autoFocus:!0,className:"richtext-mb-[10px]",onChange:x=>a(x.target.value),placeholder:"Text",required:!0,rows:10,value:c,style:{color:"hsl(var(--foreground))"}}),d.jsx(m.Label,{className:"mb-[6px]",children:"Macros"}),d.jsx(m.Textarea,{onChange:x=>u(x.target.value),placeholder:"Macros",rows:10,value:h,style:{color:"hsl(var(--foreground))"}})]}),d.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:g||""},style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:f,type:"button",children:"Save changes"})})]})]})}function Il(){const e=m.useEditableEditor(),t=m.useEditorInstance(),[n,i]=b.useState(!1),s=b.useCallback(()=>t.isActive(ht.Katex.name),[t]),r=b.useCallback(()=>ie.deleteNode(ht.Katex.name,t),[t]);return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleKatex",shouldShow:s,children:d.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:[d.jsx(Tl,{toggleVisible:i,visible:n,children:d.jsx(m.ActionButton,{action:()=>i(!n),tooltip:"Edit",children:d.jsx(Je.Pencil,{size:16})})}),d.jsx(m.ActionButton,{action:r,tooltip:"Delete",children:d.jsx(Je.Trash2,{size:16})})]})}):d.jsx(d.Fragment,{})}function Dl(e){const{t}=B.useLocale();return d.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[d.jsx(m.ActionButton,{disabled:!(e!=null&&e.link),icon:"ExternalLink",tooltip:t("editor.link.open.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{window.open(e==null?void 0:e.link,"_blank")}}),d.jsx(m.ActionButton,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e==null||e.onEdit()}}),d.jsx(m.ActionButton,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{e==null||e.onClear()}})]})}function Al(){const e=m.useEditableEditor(),t=m.useEditorInstance(),[n,i]=b.useState(!1),s=ht.useAttributes(t,Fe.Link.name),r=s==null?void 0:s.href,o=b.useCallback(({editor:h})=>h.isActive(Fe.Link.name),[]),l=(h,u,f)=>{const p=t.state.selection,{from:g}=p,x=(u==null?void 0:u.length)??0,w=g+x;t.chain().extendMarkRange("link").insertContent({type:"text",text:u,marks:[{type:"link",attrs:{href:h,target:f?"_blank":""}}]}).setLink({href:h}).setTextSelection({from:g,to:w}).focus().run(),i(!1)},c=b.useCallback(()=>{t.chain().extendMarkRange("link").unsetLink().focus().run(),i(!1)},[t]),a=()=>{i(!1)};return e?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleLink",shouldShow:o,children:d.jsx(d.Fragment,{children:n?d.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:d.jsx(Fe.LinkEditBlock,{editor:t,onClose:a,onSetLink:l})}):d.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:d.jsx(Dl,{editor:t,link:r,onClear:c,onEdit:()=>{i(!0)}})})})}):d.jsx(d.Fragment,{})}function xi({item:e,disabled:t,editor:n}){const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||(e==null?void 0:e.componentdisabled),editor:n})}):d.jsx(d.Fragment,{})}function Ol(e){return e.type.name===m.Image.name}function Ml(e){return e.type.name===_o.ImageGif.name}function Rl(e){return e.type.name===m.Video.name}function jl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:o})=>{const{selection:l}=o.view.state,{$from:c,to:a}=l;let h=!1;return o.view.state.doc.nodesBetween(c.pos,a,u=>{if(Ol(u))return h=!0,!1}),h},r=b.useMemo(()=>ml(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImage",shouldShow:s,children:r!=null&&r.length?d.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:r==null?void 0:r.map((o,l)=>d.jsx(xi,{editor:i,item:o},`bubbleMenu-image-${l}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function Nl(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:o})=>{const{selection:l}=o.view.state,{$from:c,to:a}=l;let h=!1;return o.view.state.doc.nodesBetween(c.pos,a,u=>{if(Ml(u))return h=!0,!1}),h},r=b.useMemo(()=>xl(i,t),[i,t,e]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleImageGif",shouldShow:s,children:r!=null&&r.length?d.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:r==null?void 0:r.map((o,l)=>d.jsx(xi,{editor:i,item:o},`bubbleMenu-image-gif-${l}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function Ll(){const{t:e}=B.useLocale(),t=m.useEditableEditor(),n=m.useEditorInstance(),i=({editor:r})=>{const{selection:o}=r.view.state,{$from:l,to:c}=o;let a=!1;return r.view.state.doc.nodesBetween(l.pos,c,h=>{if(Rl(h))return a=!0,!1}),a},s=b.useMemo(()=>yl(n,e),[n,e]);return t?d.jsx(it,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleVideo",shouldShow:i,children:s!=null&&s.length?d.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==null?void 0:s.map((r,o)=>d.jsx(xi,{editor:n,item:r},`bubbleMenu-video-${o}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}const Gi=`graph TB
|
|
2
|
+
a-->b`,Bl=({editor:e,attrs:t,extension:n})=>{const{alt:i,align:s}=t,[r,o]=b.useState(decodeURIComponent(i??Gi)),[l,c]=b.useState(""),[a,h]=b.useState(!1),u=b.useRef(null),[f,p]=b.useState(null),g=n==null?void 0:n.options.upload,x=b.useCallback(k=>{k&&import("mermaid").then(A=>{p(A.default)})},[]),w=async k=>{try{const{svg:A}=await f.render("mermaid-svg",k);c(A)}catch{c("")}},y=()=>{f.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),w(r)};b.useEffect(()=>{f&&a&&y()},[f,a]),b.useEffect(()=>{f&&a&&w(r)},[f,r]);const C=async()=>{if(r!==""){if(r){const k=u.current.querySelector("svg"),{width:A,height:L}=k.getBoundingClientRect(),S=`mermaid-${Ye.shortId()}.svg`;let v=Ye.i(k.outerHTML);if(g){const I=m.dataURLtoFile(v,S);v=await g(I)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:v,alt:encodeURIComponent(r),width:A,height:L},!!r).run(),e==null||e.commands.setAlignImageMermaid(s)}h(!1)}};return d.jsxs(m.Dialog,{onOpenChange:h,open:a,children:[d.jsx(m.DialogTrigger,{asChild:!0,children:d.jsx(m.ActionButton,{action:()=>h(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),d.jsxs(m.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[d.jsx(m.DialogTitle,{children:"Edit Mermaid"}),d.jsx("div",{ref:x,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:d.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[d.jsx(m.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Gi,onChange:k=>o(k.target.value),placeholder:"Text",required:!0,rows:10,value:r,style:{color:"hsl(var(--foreground))"}}),d.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:l},ref:u,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500}})]})}),d.jsx(m.DialogFooter,{children:d.jsx(m.Button,{onClick:C,type:"button",children:"Save changes"})})]})]})};function Ul({item:e,disabled:t,editor:n}){var s;const i=e.component;return i?d.jsx(b.Fragment,{children:e.type==="divider"?d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):d.jsx(i,{...e.componentProps,disabled:t||((s=e==null?void 0:e.componentProps)==null?void 0:s.disabled),editor:n})}):d.jsx(d.Fragment,{})}function Pl(e){return e.type.name===Xn.Mermaid.name}function $l(){const{lang:e,t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=ht.useAttributes(i,Xn.Mermaid.name),r=m.useExtension(Xn.Mermaid.name),o=({editor:c})=>{const{selection:a}=c.view.state,{$from:h,to:u}=a;let f=!1;return c.view.state.doc.nodesBetween(h.pos,u,p=>{if(Pl(p))return f=!0,!1}),f},l=b.useMemo(()=>bl(i,t),[i,e,t]);return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleMermaid",shouldShow:o,children:l!=null&&l.length?d.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:l==null?void 0:l.map((c,a)=>c.type==="edit"&&(s!=null&&s.src)?d.jsx(Bl,{attrs:s,editor:i,extension:r},`bubbleMenu-mermaid-${a}`):d.jsx(Ul,{editor:i,item:c},`bubbleMenu-mermaid-${a}`))}):d.jsx(d.Fragment,{})}):d.jsx(d.Fragment,{})}function Fl({hiddenActions:e=[]}){var x,w,y,C,k,A,L,S,v,I,z,N,$,Y,st,E,yt,Me;const{t}=B.useLocale(),n=m.useEditableEditor(),i=m.useEditorInstance(),s=({editor:Vt})=>T.isActive(Vt.view.state,Rs.Table.name),r=Vt=>e.includes(Vt);function o(){i.chain().focus().addColumnBefore().run()}function l(){i.chain().focus().addColumnAfter().run()}function c(){i.chain().focus().deleteColumn().run()}function a(){i.chain().focus().addRowBefore().run()}function h(){i.chain().focus().addRowAfter().run()}function u(){i.chain().focus().deleteRow().run()}function f(){i.chain().focus().mergeCells().run()}function p(){i==null||i.chain().focus().splitCell().run()}function g(){i.chain().focus().deleteTable().run()}return n?d.jsx(it,{editor:i,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTable",shouldShow:s,children:d.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:[!r("addColumnBefore")&&d.jsx(m.ActionButton,{action:o,disabled:!((w=(x=i==null?void 0:i.can())==null?void 0:x.addColumnBefore)!=null&&w.call(x)),icon:"BetweenHorizonalEnd",tooltip:t("editor.table.menu.insertColumnBefore"),tooltipOptions:{sideOffset:15}}),!r("addColumnAfter")&&d.jsx(m.ActionButton,{action:l,disabled:!((C=(y=i==null?void 0:i.can())==null?void 0:y.addColumnAfter)!=null&&C.call(y)),icon:"BetweenHorizonalStart",tooltip:t("editor.table.menu.insertColumnAfter"),tooltipOptions:{sideOffset:15}}),!r("deleteColumn")&&d.jsx(m.ActionButton,{action:c,disabled:!((A=i==null?void 0:(k=i.can()).deleteColumn)!=null&&A.call(k)),icon:"DeleteColumn",tooltip:t("editor.table.menu.deleteColumn"),tooltipOptions:{sideOffset:15}}),d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!r("addRowAbove")&&d.jsx(m.ActionButton,{action:a,disabled:!((S=i==null?void 0:(L=i.can()).addRowBefore)!=null&&S.call(L)),icon:"BetweenVerticalEnd",tooltip:t("editor.table.menu.insertRowAbove"),tooltipOptions:{sideOffset:15}}),!r("addRowBelow")&&d.jsx(m.ActionButton,{action:h,disabled:!((I=(v=i==null?void 0:i.can())==null?void 0:v.addRowAfter)!=null&&I.call(v)),icon:"BetweenVerticalStart",tooltip:t("editor.table.menu.insertRowBelow"),tooltipOptions:{sideOffset:15}}),!r("deleteRow")&&d.jsx(m.ActionButton,{action:u,disabled:!((N=(z=i==null?void 0:i.can())==null?void 0:z.deleteRow)!=null&&N.call(z)),icon:"DeleteRow",tooltip:t("editor.table.menu.deleteRow"),tooltipOptions:{sideOffset:15}}),d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!r("mergeCells")&&d.jsx(m.ActionButton,{action:f,disabled:!((Y=($=i==null?void 0:i.can())==null?void 0:$.mergeCells)!=null&&Y.call($)),icon:"TableCellsMerge",tooltip:t("editor.table.menu.mergeCells"),tooltipOptions:{sideOffset:15}}),!r("splitCells")&&d.jsx(m.ActionButton,{action:p,disabled:!((E=(st=i==null?void 0:i.can())==null?void 0:st.splitCell)!=null&&E.call(st)),icon:"TableCellsSplit",tooltip:t("editor.table.menu.splitCells"),tooltipOptions:{sideOffset:15}}),d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),!r("deleteTable")&&d.jsx(m.ActionButton,{action:g,disabled:!((Me=(yt=i==null?void 0:i.can())==null?void 0:yt.deleteTable)!=null&&Me.call(yt)),icon:"Trash2",tooltip:t("editor.table.menu.deleteTable"),tooltipOptions:{sideOffset:15}})]})}):d.jsx(d.Fragment,{})}function Vl(){const{t:e}=B.useLocale(),[t,n]=b.useState(!1),i=m.useEditorInstance(),s=b.useMemo(()=>{var o,l;return(l=(o=No.renderCommandListDefault({t:e}))==null?void 0:o[0])==null?void 0:l.commands},[e]),r=b.useMemo(()=>{var l;return(l=s==null?void 0:s.find(c=>{var a;return(a=c==null?void 0:c.isActive)==null?void 0:a.call(c,i)}))==null?void 0:l.label},[i.state.selection.ranges,t,i,s,e]);return d.jsxs(Kt.Popover,{modal:!0,onOpenChange:n,open:t,children:[d.jsx(Kt.PopoverTrigger,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent",children:d.jsxs(m.ActionButton,{dataState:!!r,children:[r?d.jsx(d.Fragment,{children:r}):d.jsx(d.Fragment,{children:e("editor.paragraph.tooltip")}),d.jsx(m.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})]})}),d.jsx(Kt.PopoverContent,{align:"start",className:"!richtext-w-[initial] !richtext-p-[4px]",hideWhenDetached:!0,side:"bottom",children:s==null?void 0:s.map(o=>{var c;const l=(c=o==null?void 0:o.isActive)==null?void 0:c.call(o,i);return d.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:a=>{a.preventDefault(),o.action({editor:i,range:i.state.selection.ranges}),n(!1)},children:[d.jsxs("div",{className:"!richtext-min-w-[20px]",children:[l&&d.jsx(Je.Check,{size:16}),!r&&o.label===e("editor.paragraph.tooltip")&&!l&&d.jsx(Je.Check,{size:16})]}),d.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-1",children:[o.iconName&&d.jsx(m.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:o.iconName}),o.label]})]},o.name)})})]})}function Hl(){return d.jsxs(d.Fragment,{children:[d.jsx(Vl,{}),d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),d.jsx(Ao.RichTextBold,{}),d.jsx(jo.RichTextItalic,{}),d.jsx(Bo.RichTextUnderline,{}),d.jsx(Lo.RichTextStrike,{}),d.jsx(Oo.RichTextCode,{}),d.jsx(Fe.RichTextLink,{}),d.jsx(Dt.Separator,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),d.jsx(Mo.RichTextColor,{}),d.jsx(Ro.RichTextHighlight,{}),d.jsx(Ls.RichTextAlign,{})]})}function zl({buttonBubble:e}){const t=m.useEditorInstance(),n=m.useEditableEditor(),i=({editor:s})=>{const{selection:r}=s.view.state,{$from:o,to:l}=r;return o.pos===l?!1:r instanceof W.TextSelection};return n?d.jsx(it,{editor:t,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleText",shouldShow:i,children:e?d.jsx(d.Fragment,{children:e}):d.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:d.jsx(Hl,{})})}):d.jsx(d.Fragment,{})}function Kl(){const{t:e}=B.useLocale(),t=m.useEditableEditor(),n=m.useEditorInstance(),[i,s]=b.useState(!1),r=b.useCallback(({editor:c})=>c.isActive(Nn.Twitter.name),[]),o=c=>{n.commands.updateTweet({src:c}),s(!1)},l=b.useCallback(()=>ie.deleteNode(Nn.Twitter.name,n),[n]);return t?d.jsx(it,{editor:n,options:{placement:"bottom",offset:8,flip:!0},pluginKey:"RichTextBubbleTwitter",shouldShow:r,children:d.jsx(d.Fragment,{children:i?d.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:d.jsx(Nn.FormEditLinkTwitter,{editor:n,onSetLink:o})}):d.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:[d.jsx(m.ActionButton,{icon:"Pencil",tooltip:e("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{s(!0)}}),d.jsx(m.ActionButton,{action:l,icon:"Trash",tooltip:e("editor.delete"),tooltipOptions:{sideOffset:15}})]})})}):d.jsx(d.Fragment,{})}const dt=()=>new Map,Qn=e=>{const t=dt();return e.forEach((n,i)=>{t.set(i,n)}),t},kt=(e,t,n)=>{let i=e.get(t);return i===void 0&&e.set(t,i=n()),i},ql=(e,t)=>{const n=[];for(const[i,s]of e)n.push(t(s,i));return n},Wl=(e,t)=>{for(const[n,i]of e)if(t(i,n))return!0;return!1},Lt=()=>new Set,Bn=e=>e[e.length-1],Gl=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Bt=Array.from,bi=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},wi=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Yl=(e,t)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t(i,n);return n},Xt=Array.isArray;class zs{constructor(){this._observers=dt()}on(t,n){return kt(this._observers,t,Lt).add(n),n}once(t,n){const i=(...s)=>{this.off(t,i),n(...s)};this.on(t,i)}off(t,n){const i=this._observers.get(t);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(t))}emit(t,n){return Bt((this._observers.get(t)||dt()).values()).forEach(i=>i(...n))}destroy(){this._observers=dt()}}const ft=Math.floor,Ve=Math.abs,Zt=(e,t)=>e<t?e:t,At=(e,t)=>e>t?e:t,Ks=e=>e!==0?e<0:1/e<0,Yi=1,Ji=2,Un=4,Pn=8,ge=32,vt=64,tt=128,Jl=1<<29,mn=31,ti=63,Nt=127,Xl=2147483647,Xe=Number.MAX_SAFE_INTEGER,Xi=Number.MIN_SAFE_INTEGER,Zl=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&ft(e)===e),qs=String.fromCharCode,Ql=e=>e.toLowerCase(),tc=/^\s*/g,ec=e=>e.replace(tc,""),nc=/([A-Z])/g,Zi=(e,t)=>ec(e.replace(nc,n=>`${t}${Ql(n)}`)),ic=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,i=new Uint8Array(n);for(let s=0;s<n;s++)i[s]=t.codePointAt(s);return i},me=typeof TextEncoder<"u"?new TextEncoder:null,sc=e=>me.encode(e),rc=me?sc:ic;let fe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});fe&&fe.decode(new Uint8Array).length===1&&(fe=null);const oc=(e,t)=>Yl(t,()=>e).join("");class Te{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ie=()=>new Te,lc=e=>{const t=Ie();return e(t),ut(t)},cc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},ut=e=>{const t=new Uint8Array(cc(e));let n=0;for(let i=0;i<e.bufs.length;i++){const s=e.bufs[i];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ac=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(At(n,t)*2),e.cpos=0)},K=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},ei=K,D=(e,t)=>{for(;t>Nt;)K(e,tt|Nt&t),t=ft(t/128);K(e,Nt&t)},yi=(e,t)=>{const n=Ks(t);for(n&&(t=-t),K(e,(t>ti?tt:0)|(n?vt:0)|ti&t),t=ft(t/64);t>0;)K(e,(t>Nt?tt:0)|Nt&t),t=ft(t/128)},ni=new Uint8Array(3e4),uc=ni.length/3,hc=(e,t)=>{if(t.length<uc){const n=me.encodeInto(t,ni).written||0;D(e,n);for(let i=0;i<n;i++)K(e,ni[i])}else rt(e,rc(t))},dc=(e,t)=>{const n=unescape(encodeURIComponent(t)),i=n.length;D(e,i);for(let s=0;s<i;s++)K(e,n.codePointAt(s))},qt=me&&me.encodeInto?hc:dc,xn=(e,t)=>{const n=e.cbuf.length,i=e.cpos,s=Zt(n-i,t.length),r=t.length-s;e.cbuf.set(t.subarray(0,s),i),e.cpos+=s,r>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(At(n*2,r)),e.cbuf.set(t.subarray(s)),e.cpos=r)},rt=(e,t)=>{D(e,t.byteLength),xn(e,t)},Si=(e,t)=>{ac(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fc=(e,t)=>Si(e,4).setFloat32(0,t,!1),pc=(e,t)=>Si(e,8).setFloat64(0,t,!1),gc=(e,t)=>Si(e,8).setBigInt64(0,t,!1),Qi=new DataView(new ArrayBuffer(4)),mc=e=>(Qi.setFloat32(0,e),Qi.getFloat32(0)===e),Qt=(e,t)=>{switch(typeof t){case"string":K(e,119),qt(e,t);break;case"number":Zl(t)&&Ve(t)<=Xl?(K(e,125),yi(e,t)):mc(t)?(K(e,124),fc(e,t)):(K(e,123),pc(e,t));break;case"bigint":K(e,122),gc(e,t);break;case"object":if(t===null)K(e,126);else if(Xt(t)){K(e,117),D(e,t.length);for(let n=0;n<t.length;n++)Qt(e,t[n])}else if(t instanceof Uint8Array)K(e,116),rt(e,t);else{K(e,118);const n=Object.keys(t);D(e,n.length);for(let i=0;i<n.length;i++){const s=n[i];qt(e,s),Qt(e,t[s])}}break;case"boolean":K(e,t?120:121);break;default:K(e,127)}};class ts extends Te{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&D(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const es=e=>{e.count>0&&(yi(e.encoder,e.count===1?e.s:-e.s),e.count>1&&D(e.encoder,e.count-2))};class He{constructor(){this.encoder=new Te,this.s=0,this.count=0}write(t){this.s===t?this.count++:(es(this),this.count=1,this.s=t)}toUint8Array(){return es(this),ut(this.encoder)}}const ns=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);yi(e.encoder,t),e.count>1&&D(e.encoder,e.count-2)}};class $n{constructor(){this.encoder=new Te,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(ns(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return ns(this),ut(this.encoder)}}class xc{constructor(){this.sarr=[],this.s="",this.lensE=new He}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 Te;return this.sarr.push(this.s),this.s="",qt(t,this.sarr.join("")),xn(t,this.lensE.toUint8Array()),ut(t)}}const wt=e=>new Error(e),ct=()=>{throw wt("Method unimplemented")},Z=()=>{throw wt("Unexpected case")},Ws=wt("Unexpected end of array"),Gs=wt("Integer out of Range");class bn{constructor(t){this.arr=t,this.pos=0}}const vi=e=>new bn(e),bc=e=>e.pos!==e.arr.length,wc=(e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},ot=e=>wc(e,R(e)),xe=e=>e.arr[e.pos++],R=e=>{let t=0,n=1;const i=e.arr.length;for(;e.pos<i;){const s=e.arr[e.pos++];if(t=t+(s&Nt)*n,n*=128,s<tt)return t;if(t>Xe)throw Gs}throw Ws},Ci=e=>{let t=e.arr[e.pos++],n=t&ti,i=64;const s=(t&vt)>0?-1:1;if((t&tt)===0)return s*n;const r=e.arr.length;for(;e.pos<r;){if(t=e.arr[e.pos++],n=n+(t&Nt)*i,i*=128,t<tt)return s*n;if(n>Xe)throw Gs}throw Ws},yc=e=>{let t=R(e);if(t===0)return"";{let n=String.fromCodePoint(xe(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(xe(e));else for(;t>0;){const i=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+i);e.pos+=i,n+=String.fromCodePoint.apply(null,s),t-=i}return decodeURIComponent(escape(n))}},Sc=e=>fe.decode(ot(e)),ii=fe?Sc:yc,ki=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},vc=e=>ki(e,4).getFloat32(0,!1),Cc=e=>ki(e,8).getFloat64(0,!1),kc=e=>ki(e,8).getBigInt64(0,!1),Ec=[e=>{},e=>null,Ci,vc,Cc,kc,e=>!1,e=>!0,ii,e=>{const t=R(e),n={};for(let i=0;i<t;i++){const s=ii(e);n[s]=Ze(e)}return n},e=>{const t=R(e),n=[];for(let i=0;i<t;i++)n.push(Ze(e));return n},ot],Ze=e=>Ec[127-xe(e)](e);class is extends bn{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),bc(this)?this.count=R(this)+1:this.count=-1),this.count--,this.s}}class ze extends bn{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ci(this);const t=Ks(this.s);this.count=1,t&&(this.s=-this.s,this.count=R(this)+2)}return this.count--,this.s}}class Fn extends bn{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=Ci(this),n=t&1;this.diff=ft(t/2),this.count=1,n&&(this.count=R(this)+2)}return this.s+=this.diff,this.count--,this.s}}class _c{constructor(t){this.decoder=new ze(t),this.str=ii(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}}const Tc=crypto.getRandomValues.bind(crypto),Ic=Math.random,Ys=()=>Tc(new Uint32Array(1))[0],Dc=e=>e[ft(Ic()*e.length)],Ac="10000000-1000-4000-8000"+-1e11,Oc=()=>Ac.replace(/[018]/g,e=>(e^Ys()&15>>e/4).toString(16)),Mc=Date.now,ss=e=>new Promise(e);Promise.all.bind(Promise);const rs=e=>e===void 0?null:e;class Rc{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}}let Js=new Rc,jc=!0;try{typeof localStorage<"u"&&localStorage&&(Js=localStorage,jc=!1)}catch{}const Nc=Js,be=Symbol("Equality"),Xs=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[be])!=null&&n.call(e,t))||!1},Lc=e=>typeof e=="object",Bc=Object.assign,Zs=Object.keys,Uc=(e,t)=>{for(const n in e)t(e[n],n)},Qe=e=>Zs(e).length,Pc=e=>{for(const t in e)return!1;return!0},se=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},Ei=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$c=(e,t)=>e===t||Qe(e)===Qe(t)&&se(e,(n,i)=>(n!==void 0||Ei(t,i))&&Xs(t[i],n)),Fc=Object.freeze,Qs=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&Qs(e[t])}return Fc(e)},_i=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&_i(e,t,n+1)}},Ke=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[be]!=null)return e[be](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!Ke(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(Qe(e)!==Qe(t))return!1;for(const n in e)if(!Ei(e,n)||!Ke(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ke(e[n],t[n]))return!1;break;default:return!1}return!0},Vc=(e,t)=>t.includes(e),te=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",tr=typeof window<"u"&&typeof document<"u"&&!te;let xt;const Hc=()=>{if(xt===void 0)if(te){xt=dt();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const i=e[n];i[0]==="-"?(t!==null&&xt.set(t,""),t=i):t!==null&&(xt.set(t,i),t=null)}t!==null&&xt.set(t,"")}else typeof location=="object"?(xt=dt(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");xt.set(`--${Zi(t,"-")}`,n),xt.set(`-${Zi(t,"-")}`,n)}})):xt=dt();return xt},si=e=>Hc().has(e),tn=e=>rs(te?process.env[e.toUpperCase().replaceAll("-","_")]:Nc.getItem(e)),er=e=>si("--"+e)||tn(e)!==null,zc=er("production"),Kc=te&&Vc(process.env.FORCE_COLOR,["true","1","2"]),qc=Kc||!si("--no-colors")&&!er("no-color")&&(!te||process.stdout.isTTY)&&(!te||si("--color")||tn("COLORTERM")!==null||(tn("TERM")||"").includes("color")),Wc=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=qs(e[n]);return btoa(t)},Gc=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),Yc=tr?Wc:Gc,Jc=e=>lc(t=>Qt(t,e));class Xc{constructor(t,n){this.left=t,this.right=n}}const St=(e,t)=>new Xc(e,t),os=e=>e.next()>=.5,Vn=(e,t,n)=>ft(e.next()*(n+1-t)+t),nr=(e,t,n)=>ft(e.next()*(n+1-t)+t),Ti=(e,t,n)=>nr(e,t,n),Zc=e=>qs(Ti(e,97,122)),Qc=(e,t=0,n=20)=>{const i=Ti(e,t,n);let s="";for(let r=0;r<i;r++)s+=Zc(e);return s},Hn=(e,t)=>t[Ti(e,0,t.length-1)],ta=Symbol("0schema");class ea{constructor(){this._rerrs=[]}extend(t,n,i,s=null){this._rerrs.push({path:t,expected:n,has:i,message:s})}toString(){const t=[];for(let n=this._rerrs.length-1;n>0;n--){const i=this._rerrs[n];t.push(oc(" ",(this._rerrs.length-n)*2)+`${i.path!=null?`[${i.path}] `:""}${i.has} doesn't match ${i.expected}. ${i.message}`)}return t.join(`
|
|
3
|
+
`)}}const ri=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[be]?Xs(e,t):Xt(e)?bi(e,n=>wi(t,i=>ri(n,i))):Lc(e)?se(e,(n,i)=>ri(n,t[i])):!1;class Q{extends(t){let[n,i]=[this.shape,t.shape];return this.constructor._dilutes&&([i,n]=[n,i]),ri(n,i)}equals(t){return this.constructor===t.constructor&&Ke(this.shape,t.shape)}[ta](){return!0}[be](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){ct()}get nullable(){return re(this,Cn)}get optional(){return new rr(this)}cast(t){return ls(t,this),t}expect(t){return ls(t,this),t}}Re(Q,"_dilutes",!1);class Ii extends Q{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){const i=(t==null?void 0:t.constructor)===this.shape&&(this._c==null||this._c(t));return!i&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name,(t==null?void 0:t.constructor)!==this.shape?"Constructor match failed":"Check failed")),i}}const V=(e,t=null)=>new Ii(e,t);V(Ii);class Di extends Q{constructor(t){super(),this.shape=t}check(t,n){const i=this.shape(t);return!i&&(n==null||n.extend(null,"custom prop",t==null?void 0:t.constructor.name,"failed to check custom prop")),i}}const G=e=>new Di(e);V(Di);class wn extends Q{constructor(t){super(),this.shape=t}check(t,n){const i=this.shape.some(s=>s===t);return!i&&(n==null||n.extend(null,this.shape.join(" | "),t.toString())),i}}const yn=(...e)=>new wn(e),ir=V(wn),na=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),sr=e=>{if(ee.check(e))return[na(e)];if(ir.check(e))return e.shape.map(t=>t+"");if(pr.check(e))return["[+-]?\\d+.?\\d*"];if(gr.check(e))return[".*"];if(nn.check(e))return e.shape.map(sr).flat(1);Z()};class ia extends Q{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(sr).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){const i=this._r.exec(t)!=null;return!i&&(n==null||n.extend(null,this._r.toString(),t.toString(),"String doesn't match string template.")),i}}V(ia);const sa=Symbol("optional");class rr extends Q{constructor(t){super(),this.shape=t}check(t,n){const i=t===void 0||this.shape.check(t);return!i&&(n==null||n.extend(null,"undefined (optional)","()")),i}get[sa](){return!0}}const ra=V(rr);class oa extends Q{check(t,n){return n==null||n.extend(null,"never",typeof t),!1}}V(oa);const gn=class gn extends Q{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new gn(this.shape,!0)}check(t,n){return t==null?(n==null||n.extend(null,"object","null"),!1):se(this.shape,(i,s)=>{const r=this._isPartial&&!Ei(t,s)||i.check(t[s],n);return!r&&(n==null||n.extend(s.toString(),i.toString(),typeof t[s],"Object property does not match")),r})}};Re(gn,"_dilutes",!0);let en=gn;const la=e=>new en(e),ca=V(en),aa=G(e=>e!=null&&(e.constructor===Object||e.constructor==null));class or extends Q{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&se(t,(i,s)=>{const r=this.shape.keys.check(s,n);return!r&&(n==null||n.extend(s+"","Record",typeof t,r?"Key doesn't match schema":"Value doesn't match value")),r&&this.shape.values.check(i,n)})}}const lr=(e,t)=>new or(e,t),ua=V(or);class cr extends Q{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&se(this.shape,(i,s)=>{const r=i.check(t[s],n);return!r&&(n==null||n.extend(s.toString(),"Tuple",typeof i)),r})}}const ha=(...e)=>new cr(e);V(cr);class ar extends Q{constructor(t){super(),this.shape=t.length===1?t[0]:new Sn(t)}check(t,n){const i=Xt(t)&&bi(t,s=>this.shape.check(s));return!i&&(n==null||n.extend(null,"Array","")),i}}const ur=(...e)=>new ar(e),da=V(ar),fa=G(e=>Xt(e));class hr extends Q{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){const i=t instanceof this.shape&&(this._c==null||this._c(t));return!i&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name)),i}}const pa=(e,t=null)=>new hr(e,t);V(hr);const ga=pa(Q);class ma extends Q{constructor(t){super(),this.len=t.length-1,this.args=ha(...t.slice(-1)),this.res=t[this.len]}check(t,n){const i=t.constructor===Function&&t.length<=this.len;return!i&&(n==null||n.extend(null,"function",typeof t)),i}}const xa=V(ma),ba=G(e=>typeof e=="function");class wa extends Q{constructor(t){super(),this.shape=t}check(t,n){const i=bi(this.shape,s=>s.check(t,n));return!i&&(n==null||n.extend(null,"Intersectinon",typeof t)),i}}V(wa,e=>e.shape.length>0);class Sn extends Q{constructor(t){super(),this.shape=t}check(t,n){const i=wi(this.shape,s=>s.check(t,n));return n==null||n.extend(null,"Union",typeof t),i}}Re(Sn,"_dilutes",!0);const re=(...e)=>e.findIndex(t=>nn.check(t))>=0?re(...e.map(t=>we(t)).map(t=>nn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Sn(e),nn=V(Sn),dr=()=>!0,sn=G(dr),ya=V(Di,e=>e.shape===dr),Ai=G(e=>typeof e=="bigint"),Sa=G(e=>e===Ai),fr=G(e=>typeof e=="symbol");G(e=>e===fr);const Wt=G(e=>typeof e=="number"),pr=G(e=>e===Wt),ee=G(e=>typeof e=="string"),gr=G(e=>e===ee),vn=G(e=>typeof e=="boolean"),va=G(e=>e===vn),mr=yn(void 0);V(wn,e=>e.shape.length===1&&e.shape[0]===void 0);yn(void 0);const Cn=yn(null),Ca=V(wn,e=>e.shape.length===1&&e.shape[0]===null);V(Uint8Array);V(Ii,e=>e.shape===Uint8Array);const ka=re(Wt,ee,Cn,mr,Ai,vn,fr);(()=>{const e=ur(sn),t=lr(ee,sn),n=re(Wt,ee,Cn,vn,e,t);return e.shape=n,t.shape.values=n,n})();const we=e=>{if(ga.check(e))return e;if(aa.check(e)){const t={};for(const n in e)t[n]=we(e[n]);return la(t)}else{if(fa.check(e))return re(...e.map(we));if(ka.check(e))return yn(e);if(ba.check(e))return V(e)}Z()},ls=zc?()=>{}:(e,t)=>{const n=new ea;if(!t.check(e,n))throw wt(`Expected value to be of type ${t.constructor.name}.
|
|
4
|
+
${n.toString()}`)};class Ea{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:we(t),h:n}),this}else(t){return this.if(sn,t)}done(){return(t,n)=>{for(let i=0;i<this.patterns.length;i++){const s=this.patterns[i];if(s.if.check(t))return s.h(t,n)}throw wt("Unhandled pattern")}}}const _a=e=>new Ea(e),xr=_a(sn).if(pr,(e,t)=>Vn(t,Xi,Xe)).if(gr,(e,t)=>Qc(t)).if(va,(e,t)=>os(t)).if(Sa,(e,t)=>BigInt(Vn(t,Xi,Xe))).if(nn,(e,t)=>zt(t,Hn(t,e.shape))).if(ca,(e,t)=>{const n={};for(const i in e.shape){let s=e.shape[i];if(ra.check(s)){if(os(t))continue;s=s.shape}n[i]=xr(s,t)}return n}).if(da,(e,t)=>{const n=[],i=nr(t,0,42);for(let s=0;s<i;s++)n.push(zt(t,e.shape));return n}).if(ir,(e,t)=>Hn(t,e.shape)).if(Ca,(e,t)=>null).if(xa,(e,t)=>{const n=zt(t,e.res);return()=>n}).if(ya,(e,t)=>zt(t,Hn(t,[Wt,ee,Cn,mr,Ai,vn,ur(Wt),lr(re("a","b","c"),Wt)]))).if(ua,(e,t)=>{const n={},i=Vn(t,0,3);for(let s=0;s<i;s++){const r=zt(t,e.shape.keys),o=zt(t,e.shape.values);n[r]=o}return n}).done(),zt=(e,t)=>xr(we(t),e),De=typeof document<"u"?document:{};G(e=>e.nodeType===Oa);typeof DOMParser<"u"&&new DOMParser;G(e=>e.nodeType===Ia);G(e=>e.nodeType===Da);const Ta=e=>ql(e,(t,n)=>`${n}:${t};`).join(""),Ia=De.ELEMENT_NODE,Da=De.TEXT_NODE,Aa=De.DOCUMENT_NODE,Oa=De.DOCUMENT_FRAGMENT_NODE;G(e=>e.nodeType===Aa);const Ma=e=>class{constructor(n){this._=n}destroy(){e(this._)}},Ra=Ma(clearTimeout),br=(e,t)=>new Ra(setTimeout(t,e)),Et=Symbol,wr=Et(),yr=Et(),ja=Et(),Na=Et(),La=Et(),Sr=Et(),Ba=Et(),Oi=Et(),Ua=Et(),Pa=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());const t=[],n=[];let i=0;for(;i<e.length;i++){const r=e[i];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)t.push(r);else if(r.constructor===Object)break}for(i>0&&n.push(t.join(""));i<e.length;i++){const r=e[i];r instanceof Symbol||n.push(r)}return n},$a={[wr]:St("font-weight","bold"),[yr]:St("font-weight","normal"),[ja]:St("color","blue"),[La]:St("color","green"),[Na]:St("color","grey"),[Sr]:St("color","red"),[Ba]:St("color","purple"),[Oi]:St("color","orange"),[Ua]:St("color","black")},Fa=e=>{var o;e.length===1&&((o=e[0])==null?void 0:o.constructor)===Function&&(e=e[0]());const t=[],n=[],i=dt();let s=[],r=0;for(;r<e.length;r++){const l=e[r],c=$a[l];if(c!==void 0)i.set(c.left,c.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const a=Ta(i);r>0||a.length>0?(t.push("%c"+l),n.push(a)):t.push(l)}else break}}for(r>0&&(s=n,s.unshift(t.join("")));r<e.length;r++){const l=e[r];l instanceof Symbol||s.push(l)}return s},vr=qc?Fa:Pa,Va=(...e)=>{console.log(...vr(e)),kr.forEach(t=>t.print(e))},Cr=(...e)=>{console.warn(...vr(e)),e.unshift(Oi),kr.forEach(t=>t.print(e))},kr=Lt(),Er=e=>({[Symbol.iterator](){return this},next:e}),Ha=(e,t)=>Er(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),zn=(e,t)=>Er(()=>{const{done:n,value:i}=e.next();return{done:n,value:n?void 0:t(i)}});class kn{constructor(t,n){this.clock=t,this.len=n}}class oe{constructor(){this.clients=new Map}}const Ot=(e,t,n)=>t.clients.forEach((i,s)=>{const r=e.doc.store.clients.get(s);if(r!=null){const o=r[r.length-1],l=o.id.clock+o.length;for(let c=0,a=i[c];c<i.length&&a.clock<l;a=i[++c])Rr(e,r,a.clock,a.len,n)}}),za=(e,t)=>{let n=0,i=e.length-1;for(;n<=i;){const s=ft((n+i)/2),r=e[s],o=r.clock;if(o<=t){if(t<o+r.len)return s;n=s+1}else i=s-1}return null},le=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&za(n,t.clock)!==null},Mi=e=>{e.clients.forEach(t=>{t.sort((s,r)=>s.clock-r.clock);let n,i;for(n=1,i=1;n<t.length;n++){const s=t[i-1],r=t[n];s.clock+s.len>=r.clock?t[i-1]=new kn(s.clock,At(s.len,r.clock+r.len-s.clock)):(i<n&&(t[i]=r),i++)}t.length=i})},oi=e=>{const t=new oe;for(let n=0;n<e.length;n++)e[n].clients.forEach((i,s)=>{if(!t.clients.has(s)){const r=i.slice();for(let o=n+1;o<e.length;o++)Gl(r,e[o].clients.get(s)||[]);t.clients.set(s,r)}});return Mi(t),t},ye=(e,t,n,i)=>{kt(e.clients,t,()=>[]).push(new kn(n,i))},_r=()=>new oe,Ka=e=>{const t=_r();return e.clients.forEach((n,i)=>{const s=[];for(let r=0;r<n.length;r++){const o=n[r];if(o.deleted){const l=o.id.clock;let c=o.length;if(r+1<n.length)for(let a=n[r+1];r+1<n.length&&a.deleted;a=n[++r+1])c+=a.length;s.push(new kn(l,c))}}s.length>0&&t.clients.set(i,s)}),t},Ri=(e,t)=>{D(e.restEncoder,t.clients.size),Bt(t.clients.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{e.resetDsCurVal(),D(e.restEncoder,n);const s=i.length;D(e.restEncoder,s);for(let r=0;r<s;r++){const o=i[r];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},qa=e=>{const t=new oe,n=R(e.restDecoder);for(let i=0;i<n;i++){e.resetDsCurVal();const s=R(e.restDecoder),r=R(e.restDecoder);if(r>0){const o=kt(t.clients,s,()=>[]);for(let l=0;l<r;l++)o.push(new kn(e.readDsClock(),e.readDsLen()))}}return t},cs=(e,t,n)=>{const i=new oe,s=R(e.restDecoder);for(let r=0;r<s;r++){e.resetDsCurVal();const o=R(e.restDecoder),l=R(e.restDecoder),c=n.clients.get(o)||[],a=P(n,o);for(let h=0;h<l;h++){const u=e.readDsClock(),f=u+e.readDsLen();if(u<a){a<f&&ye(i,o,a,f-a);let p=pt(c,u),g=c[p];for(!g.deleted&&g.id.clock<u&&(c.splice(p+1,0,hn(t,g,u-g.id.clock)),p++);p<c.length&&(g=c[p++],g.id.clock<f);)g.deleted||(f<g.id.clock+g.length&&c.splice(p,0,hn(t,g,f-g.id.clock)),g.delete(t))}else ye(i,o,u,f-u)}}if(i.clients.size>0){const r=new En;return D(r.restEncoder,0),Ri(r,i),r.toUint8Array()}return null},Tr=Ys;class $t extends zs{constructor({guid:t=Oc(),collectionid:n=null,gc:i=!0,gcFilter:s=()=>!0,meta:r=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=i,this.gcFilter=s,this.clientID=Tr(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=ss(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const c=()=>ss(a=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){const t=this._item;t!==null&&!this.shouldLoad&&M(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Bt(this.subdocs).map(t=>t.guid))}transact(t,n=null){return M(this,t,n)}get(t,n=q){const i=kt(this.share,t,()=>{const r=new n;return r._integrate(this,null),r}),s=i.constructor;if(n!==q&&s!==n)if(s===q){const r=new n;r._map=i._map,i._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=r}),r._start=i._start;for(let o=r._start;o!==null;o=o.right)o.parent=r;return r._length=i._length,this.share.set(t,r),r._integrate(this,null),r}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return i}getArray(t=""){return this.get(t,Jt)}getText(t=""){return this.get(t,Mt)}getMap(t=""){return this.get(t,ne)}getXmlElement(t=""){return this.get(t,J)}getXmlFragment(t=""){return this.get(t,Ut)}toJSON(){const t={};return this.share.forEach((n,i)=>{t[i]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,Bt(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new $t({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,M(t.parent.doc,i=>{const s=n.doc;t.deleted||i.subdocsAdded.add(s),i.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Wa{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=R(this.restDecoder),this.dsCurrVal}readDsLen(){const t=R(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class rn extends Wa{constructor(t){super(t),this.keys=[],R(t),this.keyClockDecoder=new Fn(ot(t)),this.clientDecoder=new ze(ot(t)),this.leftClockDecoder=new Fn(ot(t)),this.rightClockDecoder=new Fn(ot(t)),this.infoDecoder=new is(ot(t),xe),this.stringDecoder=new _c(ot(t)),this.parentInfoDecoder=new is(ot(t),xe),this.typeRefDecoder=new ze(ot(t)),this.lenDecoder=new ze(ot(t))}readLeftID(){return new Gt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Gt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ze(this.restDecoder)}readBuf(){return ot(this.restDecoder)}readJSON(){return Ze(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class Ga{constructor(){this.restEncoder=Ie()}toUint8Array(){return ut(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){D(this.restEncoder,t)}writeDsLen(t){D(this.restEncoder,t)}}class Ya extends Ga{writeLeftID(t){D(this.restEncoder,t.client),D(this.restEncoder,t.clock)}writeRightID(t){D(this.restEncoder,t.client),D(this.restEncoder,t.clock)}writeClient(t){D(this.restEncoder,t)}writeInfo(t){ei(this.restEncoder,t)}writeString(t){qt(this.restEncoder,t)}writeParentInfo(t){D(this.restEncoder,t?1:0)}writeTypeRef(t){D(this.restEncoder,t)}writeLen(t){D(this.restEncoder,t)}writeAny(t){Qt(this.restEncoder,t)}writeBuf(t){rt(this.restEncoder,t)}writeJSON(t){qt(this.restEncoder,JSON.stringify(t))}writeKey(t){qt(this.restEncoder,t)}}class Ja{constructor(){this.restEncoder=Ie(),this.dsCurrVal=0}toUint8Array(){return ut(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,D(this.restEncoder,n)}writeDsLen(t){t===0&&Z(),D(this.restEncoder,t-1),this.dsCurrVal+=t}}class En extends Ja{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new $n,this.clientEncoder=new He,this.leftClockEncoder=new $n,this.rightClockEncoder=new $n,this.infoEncoder=new ts(ei),this.stringEncoder=new xc,this.parentInfoEncoder=new ts(ei),this.typeRefEncoder=new He,this.lenEncoder=new He}toUint8Array(){const t=Ie();return D(t,0),rt(t,this.keyClockEncoder.toUint8Array()),rt(t,this.clientEncoder.toUint8Array()),rt(t,this.leftClockEncoder.toUint8Array()),rt(t,this.rightClockEncoder.toUint8Array()),rt(t,ut(this.infoEncoder)),rt(t,this.stringEncoder.toUint8Array()),rt(t,ut(this.parentInfoEncoder)),rt(t,this.typeRefEncoder.toUint8Array()),rt(t,this.lenEncoder.toUint8Array()),xn(t,ut(this.restEncoder)),ut(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){Qt(this.restEncoder,t)}writeBuf(t){rt(this.restEncoder,t)}writeJSON(t){Qt(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}}const Xa=(e,t,n,i)=>{i=At(i,t[0].id.clock);const s=pt(t,i);D(e.restEncoder,t.length-s),e.writeClient(n),D(e.restEncoder,i);const r=t[s];r.write(e,i-r.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)},Ir=(e,t,n)=>{const i=new Map;n.forEach((s,r)=>{P(t,r)>s&&i.set(r,s)}),_n(t).forEach((s,r)=>{n.has(r)||i.set(r,0)}),D(e.restEncoder,i.size),Bt(i.entries()).sort((s,r)=>r[0]-s[0]).forEach(([s,r])=>{Xa(e,t.clients.get(s),s,r)})},Za=(e,t)=>{const n=dt(),i=R(e.restDecoder);for(let s=0;s<i;s++){const r=R(e.restDecoder),o=new Array(r),l=e.readClient();let c=R(e.restDecoder);n.set(l,{i:0,refs:o});for(let a=0;a<r;a++){const h=e.readInfo();switch(mn&h){case 0:{const u=e.readLen();o[a]=new lt(_(l,c),u),c+=u;break}case 10:{const u=R(e.restDecoder);o[a]=new at(_(l,c),u),c+=u;break}default:{const u=(h&(vt|tt))===0,f=new O(_(l,c),null,(h&tt)===tt?e.readLeftID():null,null,(h&vt)===vt?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(h&ge)===ge?e.readString():null,eo(e,h));o[a]=f,c+=f.length}}}}return n},Qa=(e,t,n)=>{const i=[];let s=Bt(n.keys()).sort((p,g)=>p-g);if(s.length===0)return null;const r=()=>{if(s.length===0)return null;let p=n.get(s[s.length-1]);for(;p.refs.length===p.i;)if(s.pop(),s.length>0)p=n.get(s[s.length-1]);else return null;return p};let o=r();if(o===null)return null;const l=new Or,c=new Map,a=(p,g)=>{const x=c.get(p);(x==null||x>g)&&c.set(p,g)};let h=o.refs[o.i++];const u=new Map,f=()=>{for(const p of i){const g=p.id.client,x=n.get(g);x?(x.i--,l.clients.set(g,x.refs.slice(x.i)),n.delete(g),x.i=0,x.refs=[]):l.clients.set(g,[p]),s=s.filter(w=>w!==g)}i.length=0};for(;;){if(h.constructor!==at){const g=kt(u,h.id.client,()=>P(t,h.id.client))-h.id.clock;if(g<0)i.push(h),a(h.id.client,h.id.clock-1),f();else{const x=h.getMissing(e,t);if(x!==null){i.push(h);const w=n.get(x)||{refs:[],i:0};if(w.refs.length===w.i)a(x,P(t,x)),f();else{h=w.refs[w.i++];continue}}else(g===0||g<h.length)&&(h.integrate(e,g),u.set(h.id.client,h.id.clock+h.length))}}if(i.length>0)h=i.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=r(),o===null)break;h=o.refs[o.i++]}}if(l.clients.size>0){const p=new En;return Ir(p,l,new Map),D(p.restEncoder,0),{missing:c,update:p.toUint8Array()}}return null},tu=(e,t)=>Ir(e,t.doc.store,t.beforeState),eu=(e,t,n,i=new rn(e))=>M(t,s=>{s.local=!1;let r=!1;const o=s.doc,l=o.store,c=Za(i,o),a=Qa(s,l,c),h=l.pendingStructs;if(h){for(const[f,p]of h.missing)if(p<P(l,f)){r=!0;break}if(a){for(const[f,p]of a.missing){const g=h.missing.get(f);(g==null||g>p)&&h.missing.set(f,p)}h.update=xs([h.update,a.update])}}else l.pendingStructs=a;const u=cs(i,s,l);if(l.pendingDs){const f=new rn(vi(l.pendingDs));R(f.restDecoder);const p=cs(f,s,l);u&&p?l.pendingDs=xs([u,p]):l.pendingDs=u||p}else l.pendingDs=u;if(r){const f=l.pendingStructs.update;l.pendingStructs=null,li(s.doc,f)}},n,!1),li=(e,t,n,i=rn)=>{const s=vi(t);eu(s,e,n,new i(s))};class nu{constructor(){this.l=[]}}const as=()=>new nu,us=(e,t)=>e.l.push(t),hs=(e,t)=>{const n=e.l,i=n.length;e.l=n.filter(s=>t!==s),i===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Dr=(e,t,n)=>_i(e.l,[t,n]);class Gt{constructor(t,n){this.client=t,this.clock=n}}const Ne=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,_=(e,t)=>new Gt(e,t),Se=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw Z()},ve=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};class on{constructor(t,n,i,s=0){this.type=t,this.tname=n,this.item=i,this.assoc=s}}class iu{constructor(t,n,i=0){this.type=t,this.index=n,this.assoc=i}}const su=(e,t,n=0)=>new iu(e,t,n),Le=(e,t,n)=>{let i=null,s=null;return e._item===null?s=Se(e):i=_(e._item.id.client,e._item.id.clock),new on(i,s,t,n)},Kn=(e,t,n=0)=>{let i=e._start;if(n<0){if(t===0)return Le(e,null,n);t--}for(;i!==null;){if(!i.deleted&&i.countable){if(i.length>t)return Le(e,_(i.id.client,i.id.clock+t),n);t-=i.length}if(i.right===null&&n<0)return Le(e,i.lastId,n);i=i.right}return Le(e,null,n)},ru=(e,t)=>{const n=Yt(e,t),i=t.clock-n.id.clock;return{item:n,diff:i}},ou=(e,t,n=!0)=>{const i=t.store,s=e.item,r=e.type,o=e.tname,l=e.assoc;let c=null,a=0;if(s!==null){if(P(i,s.client)<=s.clock)return null;const h=n?hi(i,s):ru(i,s),u=h.item;if(!(u instanceof O))return null;if(c=u.parent,c._item===null||!c._item.deleted){a=u.deleted||!u.countable?0:h.diff+(l>=0?0:1);let f=u.left;for(;f!==null;)!f.deleted&&f.countable&&(a+=f.length),f=f.left}}else{if(o!==null)c=t.get(o);else if(r!==null){if(P(i,r.client)<=r.clock)return null;const{item:h}=n?hi(i,r):{item:Yt(i,r)};if(h instanceof O&&h.content instanceof mt)c=h.content.type;else return null}else throw Z();l>=0?a=c._length:a=0}return su(c,a,e.assoc)};class ji{constructor(t,n){this.ds=t,this.sv=n}}const Ar=(e,t)=>new ji(e,t),qn=e=>Ar(Ka(e.store),_n(e.store)),jt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!le(t.ds,e.id),ci=(e,t)=>{const n=kt(e.meta,ci,Lt),i=e.doc.store;n.has(t)||(t.sv.forEach((s,r)=>{s<P(i,r)&&et(e,_(r,s))}),Ot(e,t.ds,s=>{}),n.add(t))};class Or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const _n=e=>{const t=new Map;return e.clients.forEach((n,i)=>{const s=n[n.length-1];t.set(i,s.id.clock+s.length)}),t},P=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const i=n[n.length-1];return i.id.clock+i.length},Mr=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const i=n[n.length-1];if(i.id.clock+i.length!==t.id.clock)throw Z()}n.push(t)},pt=(e,t)=>{let n=0,i=e.length-1,s=e[i],r=s.id.clock;if(r===t)return i;let o=ft(t/(r+s.length-1)*i);for(;n<=i;){if(s=e[o],r=s.id.clock,r<=t){if(t<r+s.length)return o;n=o+1}else i=o-1;o=ft((n+i)/2)}throw Z()},lu=(e,t)=>{const n=e.clients.get(t.client);return n[pt(n,t.clock)]},Yt=lu,ai=(e,t,n)=>{const i=pt(t,n),s=t[i];return s.id.clock<n&&s instanceof O?(t.splice(i+1,0,hn(e,s,n-s.id.clock)),i+1):i},et=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[ai(e,n,t.clock)]},ds=(e,t,n)=>{const i=t.clients.get(n.client),s=pt(i,n.clock),r=i[s];return n.clock!==r.id.clock+r.length-1&&r.constructor!==lt&&i.splice(s+1,0,hn(e,r,n.clock-r.id.clock+1)),r},cu=(e,t,n)=>{const i=e.clients.get(t.id.client);i[pt(i,t.id.clock)]=n},Rr=(e,t,n,i,s)=>{if(i===0)return;const r=n+i;let o=ai(e,t,n),l;do l=t[o++],r<l.id.clock+l.length&&ai(e,t,r),s(l);while(o<t.length&&t[o].id.clock<r)};class au{constructor(t,n,i){this.doc=t,this.deleteSet=new oe,this.beforeState=_n(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=i,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const fs=(e,t)=>t.deleteSet.clients.size===0&&!Wl(t.afterState,(n,i)=>t.beforeState.get(i)!==n)?!1:(Mi(t.deleteSet),tu(e,t),Ri(e,t.deleteSet),!0),ps=(e,t,n)=>{const i=t._item;(i===null||i.id.clock<(e.beforeState.get(i.id.client)||0)&&!i.deleted)&&kt(e.changed,t,Lt).add(n)},qe=(e,t)=>{let n=e[t],i=e[t-1],s=t;for(;s>0;n=i,i=e[--s-1]){if(i.deleted===n.deleted&&i.constructor===n.constructor&&i.mergeWith(n)){n instanceof O&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,i);continue}break}const r=t-s;return r&&e.splice(t+1-r,r),r},uu=(e,t,n)=>{for(const[i,s]of e.clients.entries()){const r=t.clients.get(i);for(let o=s.length-1;o>=0;o--){const l=s[o],c=l.clock+l.len;for(let a=pt(r,l.clock),h=r[a];a<r.length&&h.id.clock<c;h=r[++a]){const u=r[a];if(l.clock+l.len<=u.id.clock)break;u instanceof O&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},hu=(e,t)=>{e.clients.forEach((n,i)=>{const s=t.clients.get(i);for(let r=n.length-1;r>=0;r--){const o=n[r],l=Zt(s.length-1,1+pt(s,o.clock+o.len-1));for(let c=l,a=s[c];c>0&&a.id.clock>=o.clock;a=s[c])c-=1+qe(s,c)}})},jr=(e,t)=>{if(t<e.length){const n=e[t],i=n.doc,s=i.store,r=n.deleteSet,o=n._mergeStructs;try{Mi(r),n.afterState=_n(n.doc.store),i.emit("beforeObserverCalls",[n,i]);const l=[];n.changed.forEach((c,a)=>l.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,c)})),l.push(()=>{n.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(h=>h.target._item===null||!h.target._item.deleted),c.forEach(h=>{h.currentTarget=a,h._path=null}),c.sort((h,u)=>h.path.length-u.path.length),l.push(()=>{Dr(a._dEH,c,n)}))}),l.push(()=>i.emit("afterTransaction",[n,i])),l.push(()=>{n._needFormattingCleanup&&Ou(n)})}),_i(l,[])}finally{i.gc&&uu(r,s,i.gcFilter),hu(r,s),n.afterState.forEach((h,u)=>{const f=n.beforeState.get(u)||0;if(f!==h){const p=s.clients.get(u),g=At(pt(p,f),1);for(let x=p.length-1;x>=g;)x-=1+qe(p,x)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:f}=o[h].id,p=s.clients.get(u),g=pt(p,f);g+1<p.length&&qe(p,g+1)>1||g>0&&qe(p,g)}if(!n.local&&n.afterState.get(i.clientID)!==n.beforeState.get(i.clientID)&&(Va(Oi,wr,"[yjs] ",yr,Sr,"Changed the client-id because another client seems to be using it."),i.clientID=Tr()),i.emit("afterTransactionCleanup",[n,i]),i._observers.has("update")){const h=new Ya;fs(h,n)&&i.emit("update",[h.toUint8Array(),n.origin,i,n])}if(i._observers.has("updateV2")){const h=new En;fs(h,n)&&i.emit("updateV2",[h.toUint8Array(),n.origin,i,n])}const{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=n;(l.size>0||a.size>0||c.size>0)&&(l.forEach(h=>{h.clientID=i.clientID,h.collectionid==null&&(h.collectionid=i.collectionid),i.subdocs.add(h)}),a.forEach(h=>i.subdocs.delete(h)),i.emit("subdocs",[{loaded:c,added:l,removed:a},i,n]),a.forEach(h=>h.destroy())),e.length<=t+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,e])):jr(e,t+1)}}},M=(e,t,n=null,i=!0)=>{const s=e._transactionCleanups;let r=!1,o=null;e._transaction===null&&(r=!0,e._transaction=new au(e,n,i),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(r){const l=e._transaction===s[0];e._transaction=null,l&&jr(s,0)}}return o};class du{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const gs=(e,t,n)=>{Ot(e,n.deletions,i=>{i instanceof O&&t.scope.some(s=>s===e.doc||ve(s,i))&&Pi(i,!1)})},ms=(e,t,n)=>{let i=null;const s=e.doc,r=e.scope;M(s,l=>{for(;t.length>0&&e.currStackItem===null;){const c=s.store,a=t.pop(),h=new Set,u=[];let f=!1;Ot(l,a.insertions,p=>{if(p instanceof O){if(p.redone!==null){let{item:g,diff:x}=hi(c,p.id);x>0&&(g=et(l,_(g.id.client,g.id.clock+x))),p=g}!p.deleted&&r.some(g=>g===l.doc||ve(g,p))&&u.push(p)}}),Ot(l,a.deletions,p=>{p instanceof O&&r.some(g=>g===l.doc||ve(g,p))&&!le(a.insertions,p.id)&&h.add(p)}),h.forEach(p=>{f=to(l,p,h,a.insertions,e.ignoreRemoteMapChanges,e)!==null||f});for(let p=u.length-1;p>=0;p--){const g=u[p];e.deleteFilter(g)&&(g.delete(l),f=!0)}e.currStackItem=f?a:null}l.changed.forEach((c,a)=>{c.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),i=l},e);const o=e.currStackItem;if(o!=null){const l=i.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:e},e]),e.currStackItem=null}return o};class Nr extends zs{constructor(t,{captureTimeout:n=500,captureTransaction:i=c=>!0,deleteFilter:s=()=>!0,trackedOrigins:r=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Xt(t)?t[0].doc:t instanceof $t?t:t.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(t),this.deleteFilter=s,r.add(this),this.trackedOrigins=r,this.captureTransaction=i,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=c=>{if(!this.captureTransaction(c)||!this.scope.some(w=>c.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;const a=this.undoing,h=this.redoing,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():h||this.clear(!1,!0);const f=new oe;c.afterState.forEach((w,y)=>{const C=c.beforeState.get(y)||0,k=w-C;k>0&&ye(f,y,C,k)});const p=Mc();let g=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!h){const w=u[u.length-1];w.deletions=oi([w.deletions,c.deleteSet]),w.insertions=oi([w.insertions,f])}else u.push(new du(c.deleteSet,f)),g=!0;!a&&!h&&(this.lastChange=p),Ot(c,c.deleteSet,w=>{w instanceof O&&this.scope.some(y=>y===c.doc||ve(y,w))&&Pi(w,!0)});const x=[{stackItem:u[u.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];g?this.emit("stack-item-added",x):this.emit("stack-item-updated",x)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const n=new Set(this.scope);t=Xt(t)?t:[t],t.forEach(i=>{n.has(i)||(n.add(i),(i instanceof q?i.doc!==this.doc:i!==this.doc)&&Cr("[yjs#509] Not same Y.Doc"),this.scope.push(i))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(i=>{t&&(this.undoStack.forEach(s=>gs(i,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>gs(i,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ms(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ms(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()}}function*fu(e){const t=R(e.restDecoder);for(let n=0;n<t;n++){const i=R(e.restDecoder),s=e.readClient();let r=R(e.restDecoder);for(let o=0;o<i;o++){const l=e.readInfo();if(l===10){const c=R(e.restDecoder);yield new at(_(s,r),c),r+=c}else if((mn&l)!==0){const c=(l&(vt|tt))===0,a=new O(_(s,r),null,(l&tt)===tt?e.readLeftID():null,null,(l&vt)===vt?e.readRightID():null,c?e.readParentInfo()?e.readString():e.readLeftID():null,c&&(l&ge)===ge?e.readString():null,eo(e,l));yield a,r+=a.length}else{const c=e.readLen();yield new lt(_(s,r),c),r+=c}}}}class pu{constructor(t,n){this.gen=fu(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===at);return this.curr}}class gu{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const mu=(e,t)=>{if(e.constructor===lt){const{client:n,clock:i}=e.id;return new lt(_(n,i+t),e.length-t)}else if(e.constructor===at){const{client:n,clock:i}=e.id;return new at(_(n,i+t),e.length-t)}else{const n=e,{client:i,clock:s}=n.id;return new O(_(i,s+t),null,_(i,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},xs=(e,t=rn,n=En)=>{if(e.length===1)return e[0];const i=e.map(h=>new t(vi(h)));let s=i.map(h=>new pu(h,!0)),r=null;const o=new n,l=new gu(o);for(;s=s.filter(f=>f.curr!==null),s.sort((f,p)=>{if(f.curr.id.client===p.curr.id.client){const g=f.curr.id.clock-p.curr.id.clock;return g===0?f.curr.constructor===p.curr.constructor?0:f.curr.constructor===at?1:-1:g}else return p.curr.id.client-f.curr.id.client}),s.length!==0;){const h=s[0],u=h.curr.id.client;if(r!==null){let f=h.curr,p=!1;for(;f!==null&&f.id.clock+f.length<=r.struct.id.clock+r.struct.length&&f.id.client>=r.struct.id.client;)f=h.next(),p=!0;if(f===null||f.id.client!==u||p&&f.id.clock>r.struct.id.clock+r.struct.length)continue;if(u!==r.struct.id.client)de(l,r.struct,r.offset),r={struct:f,offset:0},h.next();else if(r.struct.id.clock+r.struct.length<f.id.clock)if(r.struct.constructor===at)r.struct.length=f.id.clock+f.length-r.struct.id.clock;else{de(l,r.struct,r.offset);const g=f.id.clock-r.struct.id.clock-r.struct.length;r={struct:new at(_(u,r.struct.id.clock+r.struct.length),g),offset:0}}else{const g=r.struct.id.clock+r.struct.length-f.id.clock;g>0&&(r.struct.constructor===at?r.struct.length-=g:f=mu(f,g)),r.struct.mergeWith(f)||(de(l,r.struct,r.offset),r={struct:f,offset:0},h.next())}}else r={struct:h.curr,offset:0},h.next();for(let f=h.curr;f!==null&&f.id.client===u&&f.id.clock===r.struct.id.clock+r.struct.length&&f.constructor!==at;f=h.next())de(l,r.struct,r.offset),r={struct:f,offset:0}}r!==null&&(de(l,r.struct,r.offset),r=null),xu(l);const c=i.map(h=>qa(h)),a=oi(c);return Ri(o,a),o.toUint8Array()},Lr=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:ut(e.encoder.restEncoder)}),e.encoder.restEncoder=Ie(),e.written=0)},de=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Lr(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),D(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},xu=e=>{Lr(e);const t=e.encoder.restEncoder;D(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const i=e.clientStructs[n];D(t,i.written),xn(t,i.restEncoder)}},bs="You must not compute changes after the event-handler fired.";class Tn{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=bu(this.currentTarget,this.target))}deletes(t){return le(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw wt(bs);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const r=n._map.get(s);let o,l;if(this.adds(r)){let c=r.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(r))if(c!==null&&this.deletes(c))o="delete",l=Bn(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",l=Bn(c.content.getContent())):(o="add",l=void 0)}else if(this.deletes(r))o="delete",l=Bn(r.content.getContent());else return;t.set(s,{action:o,oldValue:l})}}),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(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw wt(bs);const n=this.target,i=Lt(),s=Lt(),r=[];if(t={added:i,deleted:s,delta:r,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const c=()=>{l&&r.push(l)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((l===null||l.delete===void 0)&&(c(),l={delete:0}),l.delete+=a.length,s.add(a)):this.adds(a)?((l===null||l.insert===void 0)&&(c(),l={insert:[]}),l.insert=l.insert.concat(a.content.getContent()),i.add(a)):((l===null||l.retain===void 0)&&(c(),l={retain:0}),l.retain+=a.length);l!==null&&l.retain===void 0&&c()}this._changes=t}return t}}const bu=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let i=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(i+=s.length),s=s.right;n.unshift(i)}t=t._item.parent}return n},X=()=>{Cr("Invalid access: Add Yjs type to a document before reading data.")},Br=80;let Ni=0;class wu{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Ni++}}const yu=e=>{e.timestamp=Ni++},Ur=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Ni++},Su=(e,t,n)=>{if(e.length>=Br){const i=e.reduce((s,r)=>s.timestamp<r.timestamp?s:r);return Ur(i,t,n),i}else{const i=new wu(t,n);return e.push(i),i}},In=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((r,o)=>Ve(t-r.index)<Ve(t-o.index)?r:o);let i=e._start,s=0;for(n!==null&&(i=n.p,s=n.index,yu(n));i.right!==null&&s<t;){if(!i.deleted&&i.countable){if(t<s+i.length)break;s+=i.length}i=i.right}for(;i.left!==null&&s>t;)i=i.left,!i.deleted&&i.countable&&(s-=i.length);for(;i.left!==null&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(s-=i.length);return n!==null&&Ve(n.index-s)<i.parent.length/Br?(Ur(n,i,s),n):Su(e._searchMarker,i,s)},Ce=(e,t,n)=>{for(let i=e.length-1;i>=0;i--){const s=e[i];if(n>0){let r=s.p;for(r.marker=!1;r&&(r.deleted||!r.countable);)r=r.left,r&&!r.deleted&&r.countable&&(s.index-=r.length);if(r===null||r.marker===!0){e.splice(i,1);continue}s.p=r,r.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=At(t,s.index+n))}},Dn=(e,t,n)=>{const i=e,s=t.changedParentTypes;for(;kt(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Dr(i._eH,n,t)};class q{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=as(),this._dEH=as(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw ct()}clone(){throw ct()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){us(this._eH,t)}observeDeep(t){us(this._dEH,t)}unobserve(t){hs(this._eH,t)}unobserveDeep(t){hs(this._dEH,t)}toJSON(){}}const Pr=(e,t,n)=>{e.doc??X(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let i=n-t;const s=[];let r=e._start;for(;r!==null&&i>0;){if(r.countable&&!r.deleted){const o=r.content.getContent();if(o.length<=t)t-=o.length;else{for(let l=t;l<o.length&&i>0;l++)s.push(o[l]),i--;t=0}}r=r.right}return s},$r=e=>{e.doc??X();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}n=n.right}return t},Fr=(e,t)=>{const n=[];let i=e._start;for(;i!==null;){if(i.countable&&jt(i,t)){const s=i.content.getContent();for(let r=0;r<s.length;r++)n.push(s[r])}i=i.right}return n},ke=(e,t)=>{let n=0,i=e._start;for(e.doc??X();i!==null;){if(i.countable&&!i.deleted){const s=i.content.getContent();for(let r=0;r<s.length;r++)t(s[r],n++,e)}i=i.right}},Vr=(e,t)=>{const n=[];return ke(e,(i,s)=>{n.push(t(i,s,e))}),n},vu=e=>{let t=e._start,n=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),i=0,t=t.right}const s=n[i++];return n.length<=i&&(n=null),{done:!1,value:s}}}},Hr=(e,t)=>{e.doc??X();const n=In(e,t);let i=e._start;for(n!==null&&(i=n.p,t-=n.index);i!==null;i=i.right)if(!i.deleted&&i.countable){if(t<i.length)return i.content.getContent()[t];t-=i.length}},ln=(e,t,n,i)=>{let s=n;const r=e.doc,o=r.clientID,l=r.store,c=n===null?t._start:n.right;let a=[];const h=()=>{a.length>0&&(s=new O(_(o,P(l,o)),s,s&&s.lastId,c,c&&c.id,t,null,new Pt(a)),s.integrate(e,0),a=[])};i.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:s=new O(_(o,P(l,o)),s,s&&s.lastId,c,c&&c.id,t,null,new Ae(new Uint8Array(u))),s.integrate(e,0);break;case $t:s=new O(_(o,P(l,o)),s,s&&s.lastId,c,c&&c.id,t,null,new Oe(u)),s.integrate(e,0);break;default:if(u instanceof q)s=new O(_(o,P(l,o)),s,s&&s.lastId,c,c&&c.id,t,null,new mt(u)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},zr=()=>wt("Length exceeded!"),Kr=(e,t,n,i)=>{if(n>t._length)throw zr();if(n===0)return t._searchMarker&&Ce(t._searchMarker,n,i.length),ln(e,t,null,i);const s=n,r=In(t,n);let o=t._start;for(r!==null&&(o=r.p,n-=r.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&et(e,_(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Ce(t._searchMarker,s,i.length),ln(e,t,o,i)},Cu=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((r,o)=>o.index>r.index?o:r,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return ln(e,t,s,n)},qr=(e,t,n,i)=>{if(i===0)return;const s=n,r=i,o=In(t,n);let l=t._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&et(e,_(l.id.client,l.id.clock+n)),n-=l.length);for(;i>0&&l!==null;)l.deleted||(i<l.length&&et(e,_(l.id.client,l.id.clock+i)),l.delete(e),i-=l.length),l=l.right;if(i>0)throw zr();t._searchMarker&&Ce(t._searchMarker,s,-r+i)},cn=(e,t,n)=>{const i=t._map.get(n);i!==void 0&&i.delete(e)},Li=(e,t,n,i)=>{const s=t._map.get(n)||null,r=e.doc,o=r.clientID;let l;if(i==null)l=new Pt([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Pt([i]);break;case Uint8Array:l=new Ae(i);break;case $t:l=new Oe(i);break;default:if(i instanceof q)l=new mt(i);else throw new Error("Unexpected content type")}new O(_(o,P(r.store,o)),s,s&&s.lastId,null,null,t,n,l).integrate(e,0)},Bi=(e,t)=>{e.doc??X();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Wr=e=>{const t={};return e.doc??X(),e._map.forEach((n,i)=>{n.deleted||(t[i]=n.content.getContent()[n.length-1])}),t},Gr=(e,t)=>{e.doc??X();const n=e._map.get(t);return n!==void 0&&!n.deleted},ku=(e,t)=>{const n={};return e._map.forEach((i,s)=>{let r=i;for(;r!==null&&(!t.sv.has(r.id.client)||r.id.clock>=(t.sv.get(r.id.client)||0));)r=r.left;r!==null&&jt(r,t)&&(n[s]=r.content.getContent()[r.length-1])}),n},Be=e=>(e.doc??X(),Ha(e._map.entries(),t=>!t[1].deleted));class Eu extends Tn{}class Jt extends q{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new Jt;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Jt}clone(){const t=new Jt;return t.insert(0,this.toArray().map(n=>n instanceof q?n.clone():n)),t}get length(){return this.doc??X(),this._length}_callObserver(t,n){super._callObserver(t,n),Dn(this,t,new Eu(this,t))}insert(t,n){this.doc!==null?M(this.doc,i=>{Kr(i,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?M(this.doc,n=>{Cu(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?M(this.doc,i=>{qr(i,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Hr(this,t)}toArray(){return $r(this)}slice(t=0,n=this.length){return Pr(this,t,n)}toJSON(){return this.map(t=>t instanceof q?t.toJSON():t)}map(t){return Vr(this,t)}forEach(t){ke(this,t)}[Symbol.iterator](){return vu(this)}_write(t){t.writeTypeRef(Ju)}}const _u=e=>new Jt;class Tu extends Tn{constructor(t,n,i){super(t,n),this.keysChanged=i}}class ne extends q{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((i,s)=>{this.set(s,i)}),this._prelimContent=null}_copy(){return new ne}clone(){const t=new ne;return this.forEach((n,i)=>{t.set(i,n instanceof q?n.clone():n)}),t}_callObserver(t,n){Dn(this,t,new Tu(this,t,n))}toJSON(){this.doc??X();const t={};return this._map.forEach((n,i)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];t[i]=s instanceof q?s.toJSON():s}}),t}get size(){return[...Be(this)].length}keys(){return zn(Be(this),t=>t[0])}values(){return zn(Be(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return zn(Be(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??X(),this._map.forEach((n,i)=>{n.deleted||t(n.content.getContent()[n.length-1],i,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?M(this.doc,n=>{cn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?M(this.doc,i=>{Li(i,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Bi(this,t)}has(t){return Gr(this,t)}clear(){this.doc!==null?M(this.doc,t=>{this.forEach(function(n,i,s){cn(t,s,i)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Xu)}}const Iu=e=>new ne,Tt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&$c(e,t);class ui{constructor(t,n,i,s){this.left=t,this.right=n,this.index=i,this.currentAttributes=s}forward(){switch(this.right===null&&Z(),this.right.content.constructor){case F:this.right.deleted||ce(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const ws=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case F:t.right.deleted||ce(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&et(e,_(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Ue=(e,t,n,i)=>{const s=new Map,r=i?In(t,n):null;if(r){const o=new ui(r.p.left,r.p,r.index,s);return ws(e,o,n-r.index)}else{const o=new ui(null,t._start,0,s);return ws(e,o,n)}},Yr=(e,t,n,i)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===F&&Tt(i.get(n.right.content.key),n.right.content.value));)n.right.deleted||i.delete(n.right.content.key),n.forward();const s=e.doc,r=s.clientID;i.forEach((o,l)=>{const c=n.left,a=n.right,h=new O(_(r,P(s.store,r)),c,c&&c.lastId,a,a&&a.id,t,null,new F(l,o));h.integrate(e,0),n.right=h,n.forward()})},ce=(e,t)=>{const{key:n,value:i}=t;i===null?e.delete(n):e.set(n,i)},Jr=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===F&&Tt(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Xr=(e,t,n,i)=>{const s=e.doc,r=s.clientID,o=new Map;for(const l in i){const c=i[l],a=n.currentAttributes.get(l)??null;if(!Tt(a,c)){o.set(l,a);const{left:h,right:u}=n;n.right=new O(_(r,P(s.store,r)),h,h&&h.lastId,u,u&&u.id,t,null,new F(l,c)),n.right.integrate(e,0),n.forward()}}return o},Wn=(e,t,n,i,s)=>{n.currentAttributes.forEach((f,p)=>{s[p]===void 0&&(s[p]=null)});const r=e.doc,o=r.clientID;Jr(n,s);const l=Xr(e,t,n,s),c=i.constructor===String?new gt(i):i instanceof q?new mt(i):new Ft(i);let{left:a,right:h,index:u}=n;t._searchMarker&&Ce(t._searchMarker,n.index,c.getLength()),h=new O(_(o,P(r.store,o)),a,a&&a.lastId,h,h&&h.id,t,null,c),h.integrate(e,0),n.right=h,n.index=u,n.forward(),Yr(e,t,n,l)},ys=(e,t,n,i,s)=>{const r=e.doc,o=r.clientID;Jr(n,s);const l=Xr(e,t,n,s);t:for(;n.right!==null&&(i>0||l.size>0&&(n.right.deleted||n.right.content.constructor===F));){if(!n.right.deleted)switch(n.right.content.constructor){case F:{const{key:c,value:a}=n.right.content,h=s[c];if(h!==void 0){if(Tt(h,a))l.delete(c);else{if(i===0)break t;l.set(c,a)}n.right.delete(e)}else n.currentAttributes.set(c,a);break}default:i<n.right.length&&et(e,_(n.right.id.client,n.right.id.clock+i)),i-=n.right.length;break}n.forward()}if(i>0){let c="";for(;i>0;i--)c+=`
|
|
5
|
+
`;n.right=new O(_(o,P(r.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new gt(c)),n.right.integrate(e,0),n.forward()}Yr(e,t,n,l)},Zr=(e,t,n,i,s)=>{let r=t;const o=dt();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===F){const a=r.content;o.set(a.key,a)}r=r.right}let l=0,c=!1;for(;t!==r;){if(n===t&&(c=!0),!t.deleted){const a=t.content;switch(a.constructor){case F:{const{key:h,value:u}=a,f=i.get(h)??null;(o.get(h)!==a||f===u)&&(t.delete(e),l++,!c&&(s.get(h)??null)===u&&f!==u&&(f===null?s.delete(h):s.set(h,f))),!c&&!t.deleted&&ce(s,a);break}}}t=t.right}return l},Du=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===F){const i=t.content.key;n.has(i)?t.delete(e):n.add(i)}t=t.left}},Au=e=>{let t=0;return M(e.doc,n=>{let i=e._start,s=e._start,r=dt();const o=Qn(r);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case F:ce(o,s.content);break;default:t+=Zr(n,i,s,r,o),r=Qn(o),i=s;break}s=s.right}}),t},Ou=e=>{const t=new Set,n=e.doc;for(const[i,s]of e.afterState.entries()){const r=e.beforeState.get(i)||0;s!==r&&Rr(e,n.store.clients.get(i),r,s,o=>{!o.deleted&&o.content.constructor===F&&o.constructor!==lt&&t.add(o.parent)})}M(n,i=>{Ot(e,e.deleteSet,s=>{if(s instanceof lt||!s.parent._hasFormatting||t.has(s.parent))return;const r=s.parent;s.content.constructor===F?t.add(r):Du(i,s)});for(const s of t)Au(s)})},Ss=(e,t,n)=>{const i=n,s=Qn(t.currentAttributes),r=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case mt:case Ft:case gt:n<t.right.length&&et(e,_(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}r&&Zr(e,r,t.right,s,t.currentAttributes);const o=(t.left||t.right).parent;return o._searchMarker&&Ce(o._searchMarker,t.index,-i+n),t};class Mu extends Tn{constructor(t,n,i){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,i.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){const t=this.target.doc,n=[];M(t,i=>{const s=new Map,r=new Map;let o=this.target._start,l=null;const c={};let a="",h=0,u=0;const f=()=>{if(l!==null){let p=null;switch(l){case"delete":u>0&&(p={delete:u}),u=0;break;case"insert":(typeof a=="object"||a.length>0)&&(p={insert:a},s.size>0&&(p.attributes={},s.forEach((g,x)=>{g!==null&&(p.attributes[x]=g)}))),a="";break;case"retain":h>0&&(p={retain:h},Pc(c)||(p.attributes=Bc({},c))),h=0;break}p&&n.push(p),l=null}};for(;o!==null;){switch(o.content.constructor){case mt:case Ft:this.adds(o)?this.deletes(o)||(f(),l="insert",a=o.content.getContent()[0],f()):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),u+=1):o.deleted||(l!=="retain"&&(f(),l="retain"),h+=1);break;case gt:this.adds(o)?this.deletes(o)||(l!=="insert"&&(f(),l="insert"),a+=o.content.str):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),u+=o.length):o.deleted||(l!=="retain"&&(f(),l="retain"),h+=o.length);break;case F:{const{key:p,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const x=s.get(p)??null;Tt(x,g)?g!==null&&o.delete(i):(l==="retain"&&f(),Tt(g,r.get(p)??null)?delete c[p]:c[p]=g)}}else if(this.deletes(o)){r.set(p,g);const x=s.get(p)??null;Tt(x,g)||(l==="retain"&&f(),c[p]=x)}else if(!o.deleted){r.set(p,g);const x=c[p];x!==void 0&&(Tt(x,g)?x!==null&&o.delete(i):(l==="retain"&&f(),g===null?delete c[p]:c[p]=g))}o.deleted||(l==="insert"&&f(),ce(s,o.content));break}}o=o.right}for(f();n.length>0;){const p=n[n.length-1];if(p.retain!==void 0&&p.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Mt extends q{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??X(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(i=>i())}catch(i){console.error(i)}this._pending=null}_copy(){return new Mt}clone(){const t=new Mt;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const i=new Mu(this,t,n);Dn(this,t,i),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??X();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===gt&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?M(this.doc,i=>{const s=new ui(null,this._start,0,new Map);for(let r=0;r<t.length;r++){const o=t[r];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&r===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
6
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Wn(i,this,s,l,o.attributes||{})}else o.retain!==void 0?ys(i,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ss(i,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,i){this.doc??X();const s=[],r=new Map,o=this.doc;let l="",c=this._start;function a(){if(l.length>0){const u={};let f=!1;r.forEach((g,x)=>{f=!0,u[x]=g});const p={insert:l};f&&(p.attributes=u),s.push(p),l=""}}const h=()=>{for(;c!==null;){if(jt(c,t)||n!==void 0&&jt(c,n))switch(c.content.constructor){case gt:{const u=r.get("ychange");t!==void 0&&!jt(c,t)?(u===void 0||u.user!==c.id.client||u.type!=="removed")&&(a(),r.set("ychange",i?i("removed",c.id):{type:"removed"})):n!==void 0&&!jt(c,n)?(u===void 0||u.user!==c.id.client||u.type!=="added")&&(a(),r.set("ychange",i?i("added",c.id):{type:"added"})):u!==void 0&&(a(),r.delete("ychange")),l+=c.content.str;break}case mt:case Ft:{a();const u={insert:c.content.getContent()[0]};if(r.size>0){const f={};u.attributes=f,r.forEach((p,g)=>{f[g]=p})}s.push(u);break}case F:jt(c,t)&&(a(),ce(r,c.content));break}c=c.right}a()};return t||n?M(o,u=>{t&&ci(u,t),n&&ci(u,n),h()},"cleanup"):h(),s}insert(t,n,i){if(n.length<=0)return;const s=this.doc;s!==null?M(s,r=>{const o=Ue(r,this,t,!i);i||(i={},o.currentAttributes.forEach((l,c)=>{i[c]=l})),Wn(r,this,o,n,i)}):this._pending.push(()=>this.insert(t,n,i))}insertEmbed(t,n,i){const s=this.doc;s!==null?M(s,r=>{const o=Ue(r,this,t,!i);Wn(r,this,o,n,i||{})}):this._pending.push(()=>this.insertEmbed(t,n,i||{}))}delete(t,n){if(n===0)return;const i=this.doc;i!==null?M(i,s=>{Ss(s,Ue(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,i){if(n===0)return;const s=this.doc;s!==null?M(s,r=>{const o=Ue(r,this,t,!1);o.right!==null&&ys(r,this,o,n,i)}):this._pending.push(()=>this.format(t,n,i))}removeAttribute(t){this.doc!==null?M(this.doc,n=>{cn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?M(this.doc,i=>{Li(i,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Bi(this,t)}getAttributes(){return Wr(this)}_write(t){t.writeTypeRef(Zu)}}const Ru=e=>new Mt;class Gn{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??X()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===J||n.constructor===Ut)&&n._start!==null)t=n._start;else for(;t!==null;){const i=t.next;if(i!==null){t=i;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class Ut extends q{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ut}clone(){const t=new Ut;return t.insert(0,this.toArray().map(n=>n instanceof q?n.clone():n)),t}get length(){return this.doc??X(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Gn(this,t)}querySelector(t){t=t.toUpperCase();const i=new Gn(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return i.done?null:i.value}querySelectorAll(t){return t=t.toUpperCase(),Bt(new Gn(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Dn(this,t,new Lu(this,n,t))}toString(){return Vr(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},i){const s=t.createDocumentFragment();return i!==void 0&&i._createAssociation(s,this),ke(this,r=>{s.insertBefore(r.toDOM(t,n,i),null)}),s}insert(t,n){this.doc!==null?M(this.doc,i=>{Kr(i,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)M(this.doc,i=>{const s=t&&t instanceof q?t._item:t;ln(i,this,s,n)});else{const i=this._prelimContent,s=t===null?0:i.findIndex(r=>r===t)+1;if(s===0&&t!==null)throw wt("Reference item not found");i.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?M(this.doc,i=>{qr(i,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return $r(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Hr(this,t)}slice(t=0,n=this.length){return Pr(this,t,n)}forEach(t){ke(this,t)}_write(t){t.writeTypeRef(th)}}const ju=e=>new Ut;class J extends Ut{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,n){super._integrate(t,n),this._prelimAttrs.forEach((i,s)=>{this.setAttribute(s,i)}),this._prelimAttrs=null}_copy(){return new J(this.nodeName)}clone(){const t=new J(this.nodeName),n=this.getAttributes();return Uc(n,(i,s)=>{t.setAttribute(s,i)}),t.insert(0,this.toArray().map(i=>i instanceof q?i.clone():i)),t}toString(){const t=this.getAttributes(),n=[],i=[];for(const l in t)i.push(l);i.sort();const s=i.length;for(let l=0;l<s;l++){const c=i[l];n.push(c+'="'+t[c]+'"')}const r=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${r}${o}>${super.toString()}</${r}>`}removeAttribute(t){this.doc!==null?M(this.doc,n=>{cn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?M(this.doc,i=>{Li(i,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Bi(this,t)}hasAttribute(t){return Gr(this,t)}getAttributes(t){return t?ku(this,t):Wr(this)}toDOM(t=document,n={},i){const s=t.createElement(this.nodeName),r=this.getAttributes();for(const o in r){const l=r[o];typeof l=="string"&&s.setAttribute(o,l)}return ke(this,o=>{s.appendChild(o.toDOM(t,n,i))}),i!==void 0&&i._createAssociation(s,this),s}_write(t){t.writeTypeRef(Qu),t.writeKey(this.nodeName)}}const Nu=e=>new J(e.readKey());class Lu extends Tn{constructor(t,n,i){super(t,i),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class an extends ne{constructor(t){super(),this.hookName=t}_copy(){return new an(this.hookName)}clone(){const t=new an(this.hookName);return this.forEach((n,i)=>{t.set(i,n)}),t}toDOM(t=document,n={},i){const s=n[this.hookName];let r;return s!==void 0?r=s.createDom(this):r=document.createElement(this.hookName),r.setAttribute("data-yjs-hook",this.hookName),i!==void 0&&i._createAssociation(r,this),r}_write(t){t.writeTypeRef(eh),t.writeKey(this.hookName)}}const Bu=e=>new an(e.readKey());class nt extends Mt{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 nt}clone(){const t=new nt;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,i){const s=t.createTextNode(this.toString());return i!==void 0&&i._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{const n=[];for(const s in t.attributes){const r=[];for(const o in t.attributes[s])r.push({key:o,value:t.attributes[s][o]});r.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:r})}n.sort((s,r)=>s.nodeName<r.nodeName?-1:1);let i="";for(let s=0;s<n.length;s++){const r=n[s];i+=`<${r.nodeName}`;for(let o=0;o<r.attrs.length;o++){const l=r.attrs[o];i+=` ${l.key}="${l.value}"`}i+=">"}i+=t.insert;for(let s=n.length-1;s>=0;s--)i+=`</${n[s].nodeName}>`;return i}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(nh)}}const Uu=e=>new nt;class Ui{constructor(t,n){this.id=t,this.length=n}get deleted(){throw ct()}mergeWith(t){return!1}write(t,n,i){throw ct()}integrate(t,n){throw ct()}}const Pu=0;class lt extends Ui{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Mr(t.doc.store,this)}write(t,n){t.writeInfo(Pu),t.writeLen(this.length-n)}getMissing(t,n){return null}}class Ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ae(this.content)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const $u=e=>new Ae(e.readBuf());class Ee{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ee(this.len)}splice(t){const n=new Ee(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){ye(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const Fu=e=>new Ee(e.readLen()),Qr=(e,t)=>new $t({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Oe{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Oe(Qr(this.doc.guid,this.opts))}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,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,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const Vu=e=>new Oe(Qr(e.readString(),e.readAny()));class Ft{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ft(this.embed)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const Hu=e=>new Ft(e.readJSON());class F{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new F(this.key,this.value)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){const i=n.parent;i._searchMarker=null,i._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const zu=e=>new F(e.readKey(),e.readJSON());class un{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new un(this.arr)}splice(t){const n=new un(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const i=this.arr.length;t.writeLen(i-n);for(let s=n;s<i;s++){const r=this.arr[s];t.writeString(r===void 0?"undefined":JSON.stringify(r))}}getRef(){return 2}}const Ku=e=>{const t=e.readLen(),n=[];for(let i=0;i<t;i++){const s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new un(n)},qu=tn("node_env")==="development";class Pt{constructor(t){this.arr=t,qu&&Qs(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Pt(this.arr)}splice(t){const n=new Pt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const i=this.arr.length;t.writeLen(i-n);for(let s=n;s<i;s++){const r=this.arr[s];t.writeAny(r)}}getRef(){return 8}}const Wu=e=>{const t=e.readLen(),n=[];for(let i=0;i<t;i++)n.push(e.readAny());return new Pt(n)};class gt{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new gt(this.str)}splice(t){const n=new gt(this.str.slice(t));this.str=this.str.slice(0,t);const i=this.str.charCodeAt(t-1);return i>=55296&&i<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Gu=e=>new gt(e.readString()),Yu=[_u,Iu,Ru,Nu,ju,Bu,Uu],Ju=0,Xu=1,Zu=2,Qu=3,th=4,eh=5,nh=6;class mt{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new mt(this.type._copy())}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(i=>{i.deleted?i.id.clock<(t.beforeState.get(i.id.client)||0)&&t._mergeStructs.push(i):i.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(i=>{for(;i!==null;)i.gc(t,!0),i=i.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const ih=e=>new mt(Yu[e.readTypeRef()](e)),hi=(e,t)=>{let n=t,i=0,s;do i>0&&(n=_(n.client,n.clock+i)),s=Yt(e,n),i=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof O);return{item:s,diff:i}},Pi=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},hn=(e,t,n)=>{const{client:i,clock:s}=t.id,r=new O(_(i,s+n),t,_(i,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&r.markDeleted(),t.keep&&(r.keep=!0),t.redone!==null&&(r.redone=_(t.redone.client,t.redone.clock+n)),t.right=r,r.right!==null&&(r.right.left=r),e._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),t.length=n,r},vs=(e,t)=>wi(e,n=>le(n.deletions,t)),to=(e,t,n,i,s,r)=>{const o=e.doc,l=o.store,c=o.clientID,a=t.redone;if(a!==null)return et(e,a);let h=t.parent._item,u=null,f;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||to(e,h,n,i,s,r)===null))return null;for(;h.redone!==null;)h=et(e,h.redone)}const p=h===null?t.parent:h.content.type;if(t.parentSub===null){for(u=t.left,f=t;u!==null;){let y=u;for(;y!==null&&y.parent._item!==h;)y=y.redone===null?null:et(e,y.redone);if(y!==null&&y.parent._item===h){u=y;break}u=u.left}for(;f!==null;){let y=f;for(;y!==null&&y.parent._item!==h;)y=y.redone===null?null:et(e,y.redone);if(y!==null&&y.parent._item===h){f=y;break}f=f.right}}else if(f=null,t.right&&!s){for(u=t;u!==null&&u.right!==null&&(u.right.redone||le(i,u.right.id)||vs(r.undoStack,u.right.id)||vs(r.redoStack,u.right.id));)for(u=u.right;u.redone;)u=et(e,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(t.parentSub)||null;const g=P(l,c),x=_(c,g),w=new O(x,u,u&&u.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=x,Pi(w,!0),w.integrate(e,0),w};class O extends Ui{constructor(t,n,i,s,r,o,l,c){super(t,c.getLength()),this.origin=i,this.left=n,this.right=s,this.rightOrigin=r,this.parent=o,this.parentSub=l,this.redone=null,this.content=c,this.info=this.content.isCountable()?Ji:0}set marker(t){(this.info&Pn)>0!==t&&(this.info^=Pn)}get marker(){return(this.info&Pn)>0}get keep(){return(this.info&Yi)>0}set keep(t){this.keep!==t&&(this.info^=Yi)}get countable(){return(this.info&Ji)>0}get deleted(){return(this.info&Un)>0}set deleted(t){this.deleted!==t&&(this.info^=Un)}markDeleted(){this.info|=Un}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=P(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=P(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Gt&&this.id.client!==this.parent.client&&this.parent.clock>=P(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ds(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=et(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===lt||this.right&&this.right.constructor===lt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===O?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===O&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Gt){const i=Yt(n,this.parent);i.constructor===lt?this.parent=null:this.parent=i.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ds(t,t.doc.store,_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let i=this.left,s;if(i!==null)s=i.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const r=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),r.add(s),Ne(this.origin,s.origin)){if(s.id.client<this.id.client)i=s,r.clear();else if(Ne(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Yt(t.doc.store,s.origin)))r.has(Yt(t.doc.store,s.origin))||(i=s,r.clear());else break;s=s.right}this.left=i}if(this.left!==null){const i=this.left.right;this.right=i,this.left.right=this}else{let i;if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start,this.parent._start=this;this.right=i}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Mr(t.doc.store,this),this.content.integrate(t,this),ps(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new lt(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:_(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Ne(t.origin,this.lastId)&&this.right===t&&Ne(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(i=>{i.p===t&&(i.p=this,!this.deleted&&this.countable&&(i.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ye(t.deleteSet,this.id.client,this.id.clock,this.length),ps(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw Z();this.content.gc(t),n?cu(t,this,new lt(this.id,this.length)):this.content=new Ee(this.length)}write(t,n){const i=n>0?_(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,r=this.parentSub,o=this.content.getRef()&mn|(i===null?0:tt)|(s===null?0:vt)|(r===null?0:ge);if(t.writeInfo(o),i!==null&&t.writeLeftID(i),s!==null&&t.writeRightID(s),i===null&&s===null){const l=this.parent;if(l._item!==void 0){const c=l._item;if(c===null){const a=Se(l);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else l.constructor===String?(t.writeParentInfo(!0),t.writeString(l)):l.constructor===Gt?(t.writeParentInfo(!1),t.writeLeftID(l)):Z();r!==null&&t.writeString(r)}this.content.write(t,n)}}const eo=(e,t)=>sh[t&mn](e),sh=[()=>{Z()},Fu,Ku,$u,Gu,Hu,zu,ih,Wu,Vu,()=>{Z()}],rh=10;class at extends Ui{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){Z()}write(t,n){t.writeInfo(rh),D(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const no=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},io="__ $YJS$ __";no[io]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");no[io]=!0;const oh=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},lh=/[\uD800-\uDBFF]/,ch=/[\uDC00-\uDFFF]/,ah=(e,t)=>{let n=0,i=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&lh.test(e[n-1])&&n--;i+n<e.length&&i+n<t.length&&e[e.length-i-1]===t[t.length-i-1];)i++;return i>0&&ch.test(e[e.length-i])&&i--,{index:n,remove:e.length-n-i,insert:t.slice(n,t.length-i)}},uh=ah,bt=(e,t)=>e>>>t|e<<32-t,hh=e=>bt(e,2)^bt(e,13)^bt(e,22),dh=e=>bt(e,6)^bt(e,11)^bt(e,25),fh=e=>bt(e,7)^bt(e,18)^e>>>3,ph=e=>bt(e,17)^bt(e,19)^e>>>10,gh=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]),mh=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class xh{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(mh),this._W=new Uint32Array(t,64,64)}_updateHash(){const t=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=ph(n[u-2])+n[u-7]+fh(n[u-15])+n[u-16];let i=t[0],s=t[1],r=t[2],o=t[3],l=t[4],c=t[5],a=t[6],h=t[7];for(let u=0,f,p;u<64;u++)f=h+dh(l)+(l&c^~l&a)+gh[u]+n[u]>>>0,p=hh(i)+(i&s^i&r^s&r)>>>0,h=a,a=c,c=l,l=o+f>>>0,o=r,r=s,s=i,i=f+p>>>0;t[0]+=i,t[1]+=s,t[2]+=r,t[3]+=o,t[4]+=l,t[5]+=c,t[6]+=a,t[7]+=h}digest(t){let n=0;for(;n+56<=t.length;){let o=0;for(;o<16&&n+3<t.length;o++)this._W[o]=t[n++]<<24|t[n++]<<16|t[n++]<<8|t[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<t.length;)this._W[o]|=t[n]<<(3-n%4)*8,n++;this._W[o]|=tt<<(3-n%4)*8}this._updateHash()}const i=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<t.length;s++)for(let o=3;o>=0&&n<t.length;o--)this._W[s]|=t[n++]<<o*8;i||(this._W[s-(n%4===0?0:1)]|=tt<<(3-n%4)*8),this._W[14]=t.byteLength/Jl,this._W[15]=t.byteLength*8,this._updateHash();const r=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)r[o*4+l]=this._H[o]>>>(3-l)*8;return r}}const bh=e=>new xh().digest(e),j=new T.PluginKey("y-sync"),Ct=new T.PluginKey("y-undo");new T.PluginKey("yjs-cursor");const wh=e=>{for(let n=6;n<e.length;n++)e[n%6]=e[n%6]^e[n];return e.slice(0,6)},yh=e=>Yc(wh(bh(Jc(e)))),dn=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!le(t.ds,e.id),Sh=[{light:"#ecd44433",dark:"#ecd444"}],vh=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){const i=Lt();e.forEach(s=>i.add(s)),t=t.filter(s=>!i.has(s))}e.set(n,Dc(t))}return e.get(n)},Ch=(e,{colors:t=Sh,colorMapping:n=new Map,permanentUserData:i=null,onFirstRender:s=()=>{},mapping:r}={})=>{let o=!1;const l=new _h(e,r),c=new T.Plugin({props:{editable:a=>{const h=j.getState(a);return h.snapshot==null&&h.prevSnapshot==null}},key:j,state:{init:(a,h)=>({type:e,doc:e.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:i}),apply:(a,h)=>{const u=a.getMeta(j);if(u!==void 0){h=Object.assign({},h);for(const f in u)h[f]=u[f]}return h.addToHistory=a.getMeta("addToHistory")!==!1,h.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,h.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&br(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,h):(l._renderSnapshot(u.snapshot,u.snapshot,h),delete h.restore,delete h.snapshot,delete h.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),h}},view:a=>(l.initView(a),r==null&&l._forceRerender(),s(),{update:()=>{const h=c.getState(a.state);if(h.snapshot==null&&h.prevSnapshot==null&&(o||a.state.doc.content.findDiffStart(a.state.doc.type.createAndFill().content)!==null)){if(o=!0,h.addToHistory===!1&&!h.isChangeOrigin){const u=Ct.getState(a.state),f=u&&u.undoManager;f&&f.stopCapturing()}l.mux(()=>{h.doc.transact(u=>{u.meta.set("addToHistory",h.addToHistory),l._prosemirrorChanged(a.state.doc)},j)})}},destroy:()=>{l.destroy()}})});return c},kh=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type==="all")e.setSelection(new T.AllSelection(e.doc));else if(t.type==="node"){const i=pe(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Eh(e,i))}else{const i=pe(n.doc,n.type,t.anchor,n.mapping),s=pe(n.doc,n.type,t.head,n.mapping);i!==null&&s!==null&&e.setSelection(T.TextSelection.between(e.doc.resolve(i),e.doc.resolve(s)))}},Eh=(e,t)=>{const n=e.doc.resolve(t);return n.nodeAfter?T.NodeSelection.create(e.doc,t):T.TextSelection.near(n)},di=(e,t)=>({type:t.selection.jsonID,anchor:pn(t.selection.anchor,e.type,e.mapping),head:pn(t.selection.head,e.type,e.mapping)});class _h{constructor(t,n=new Map){this.type=t,this.prosemirrorView=null,this.mux=oh(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=t.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=di(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()?(tr&&this._domSelectionInView===null&&(br(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const t=this.prosemirrorView._root.getSelection();if(t==null||t.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),r=De.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||r.clientWidth||0)&&s.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(t,n){n||(n=Ar(_r(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(j,{snapshot:t,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const t=this.type.toArray().map(i=>We(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(t),0,0));n.setMeta(j,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const t=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>We(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(n),0,0));if(t){const s=Zt(At(t.anchor,0),i.doc.content.size),r=Zt(At(t.head,0),i.doc.content.size);i.setSelection(T.TextSelection.create(i.doc,s,r))}this.prosemirrorView.dispatch(i.setMeta(j,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(t,n,i){let s=this.doc,r=this.type;if(t||(t=qn(this.doc)),t instanceof Uint8Array||n instanceof Uint8Array)if((!(t instanceof Uint8Array)||!(n instanceof Uint8Array))&&Z(),s=new $t({gc:!1}),li(s,n),n=qn(s),li(s,t),t=qn(s),r._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);r=s.getXmlFragment(o)}else{const o=s.store.clients.get(r._item.id.client)??[],l=pt(o,r._item.id.clock);r=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=i.permanentUserData;l&&l.dss.forEach(u=>{Ot(o,u,f=>{})});const c=(u,f)=>{const p=u==="added"?l.getUserByClientId(f.client):l.getUserByDeletedId(f);return{user:p,type:u,color:vh(i.colorMapping,i.colors,p)}},a=Fr(r,new ji(n.ds,t.sv)).map(u=>!u._item.deleted||dn(u._item,t)||dn(u._item,n)?We(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},t,n,c):null).filter(u=>u!==null),h=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(a),0,0));this.prosemirrorView.dispatch(h.setMeta(j,{isChangeOrigin:!0}))},j)})}_typeChanged(t,n){if(this.prosemirrorView==null)return;const i=j.getState(this.prosemirrorView.state);if(t.length===0||i.snapshot!=null||i.prevSnapshot!=null){this.renderSnapshot(i.snapshot,i.prevSnapshot);return}this.mux(()=>{const s=(l,c)=>this.mapping.delete(c);Ot(n,n.deleteSet,l=>{if(l.constructor===O){const c=l.content.type;c&&this.mapping.delete(c)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const r=this.type.toArray().map(l=>so(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new T.Slice(T.Fragment.from(r),0,0));kh(o,this.beforeTransactionSelection,this),o=o.setMeta(j,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Nr}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(t){this.doc.transact(()=>{pi(this.doc,this.type,t,this),this.beforeTransactionSelection=di(this,this.prosemirrorView.state)},j)}initView(t){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=t,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const so=(e,t,n,i,s,r)=>{const o=n.mapping.get(e);if(o===void 0){if(e instanceof J)return We(e,t,n,i,s,r);throw ct()}return o},We=(e,t,n,i,s,r)=>{const o=[],l=c=>{var a,h;if(c instanceof J){const u=so(c,t,n,i,s,r);u!==null&&o.push(u)}else{const u=(h=(a=c._item.right)==null?void 0:a.content)==null?void 0:h.type;u instanceof Mt&&!u._item.deleted&&u._item.id.client===u.doc.clientID&&(c.applyDelta([{retain:c.length},...u.toDelta()]),u.doc.transact(p=>{u._item.delete(p)}));const f=Th(c,t,n,i,s,r);f!==null&&f.forEach(p=>{p!==null&&o.push(p)})}};i===void 0||s===void 0?e.toArray().forEach(l):Fr(e,new ji(s.ds,i.sv)).forEach(l);try{const c=e.getAttributes(i);i!==void 0&&(dn(e._item,i)?dn(e._item,s)||(c.ychange=r?r("added",e._item.id):{type:"added"}):c.ychange=r?r("removed",e._item.id):{type:"removed"});const a=t.node(e.nodeName,c,o);return n.mapping.set(e,a),a}catch{return e.doc.transact(a=>{e._item.delete(a)},j),n.mapping.delete(e),null}},Th=(e,t,n,i,s,r)=>{const o=[],l=e.toDelta(i,s,r);try{for(let c=0;c<l.length;c++){const a=l[c];o.push(t.text(a.insert,Rh(a.attributes,t)))}}catch{return e.doc.transact(a=>{e._item.delete(a)},j),null}return o},Ih=(e,t)=>{const n=new nt,i=e.map(s=>({insert:s.text,attributes:oo(s.marks,t)}));return n.applyDelta(i),t.mapping.set(n,e),n},Dh=(e,t)=>{const n=new J(e.type.name);for(const i in e.attrs){const s=e.attrs[i];s!==null&&i!=="ychange"&&n.setAttribute(i,s)}return n.insert(0,An(e).map(i=>fi(i,t))),t.mapping.set(n,e),n},fi=(e,t)=>e instanceof Array?Ih(e,t):Dh(e,t),Cs=e=>typeof e=="object"&&e!==null,$i=(e,t)=>{const n=Object.keys(e).filter(s=>e[s]!==null);let i=n.length===Object.keys(t).filter(s=>t[s]!==null).length;for(let s=0;s<n.length&&i;s++){const r=n[s],o=e[r],l=t[r];i=r==="ychange"||o===l||Cs(o)&&Cs(l)&&$i(o,l)}return i},An=e=>{const t=e.content.content,n=[];for(let i=0;i<t.length;i++){const s=t[i];if(s.isText){const r=[];for(let o=t[i];i<t.length&&o.isText;o=t[++i])r.push(o);i--,n.push(r)}else n.push(s)}return n},ro=(e,t)=>{const n=e.toDelta();return n.length===t.length&&n.every((i,s)=>i.insert===t[s].text&&Zs(i.attributes||{}).length===t[s].marks.length&&se(i.attributes,(r,o)=>{var h;const l=Fi(o),c=t[s].marks;return c.find(u=>u.type.name===l)?$i(r,(h=c.find(u=>u.type.name===l))==null?void 0:h.attrs):!1}))},_e=(e,t)=>{if(e instanceof J&&!(t instanceof Array)&&gi(e,t)){const n=An(t);return e._length===n.length&&$i(e.getAttributes(),t.attrs)&&e.toArray().every((i,s)=>_e(i,n[s]))}return e instanceof nt&&t instanceof Array&&ro(e,t)},fn=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((n,i)=>t[i]===n),ks=(e,t,n)=>{const i=e.toArray(),s=An(t),r=s.length,o=i.length,l=Zt(o,r);let c=0,a=0,h=!1;for(;c<l;c++){const u=i[c],f=s[c];if(fn(n.mapping.get(u),f))h=!0;else if(!_e(u,f))break}for(;c+a<l;a++){const u=i[o-a-1],f=s[r-a-1];if(fn(n.mapping.get(u),f))h=!0;else if(!_e(u,f))break}return{equalityFactor:c+a,foundMappedChild:h}},Ah=e=>{let t="",n=e._start;const i={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof gt?t+=n.content.str:n.content instanceof F&&(i[n.content.key]=null)),n=n.right;return{str:t,nAttrs:i}},Oh=(e,t,n)=>{n.mapping.set(e,t);const{nAttrs:i,str:s}=Ah(e),r=t.map(a=>({insert:a.text,attributes:Object.assign({},i,oo(a.marks,n))})),{insert:o,remove:l,index:c}=uh(s,r.map(a=>a.insert).join(""));e.delete(c,l),e.insert(c,o),e.applyDelta(r.map(a=>({retain:a.insert.length,attributes:a.attributes})))},Mh=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Fi=e=>{var t;return((t=Mh.exec(e))==null?void 0:t[1])??e},Rh=(e,t)=>{const n=[];for(const i in e)n.push(t.mark(Fi(i),e[i]));return n},oo=(e,t)=>{const n={};return e.forEach(i=>{if(i.type.name!=="ychange"){const s=kt(t.isOMark,i.type,()=>!i.type.excludes(i.type));n[s?`${i.type.name}--${yh(i.toJSON())}`:i.type.name]=i.attrs}}),n},pi=(e,t,n,i)=>{if(t instanceof J&&t.nodeName!==n.type.name)throw new Error("node name mismatch!");if(i.mapping.set(t,n),t instanceof J){const u=t.getAttributes(),f=n.attrs;for(const p in f)f[p]!==null?u[p]!==f[p]&&p!=="ychange"&&t.setAttribute(p,f[p]):t.removeAttribute(p);for(const p in u)f[p]===void 0&&t.removeAttribute(p)}const s=An(n),r=s.length,o=t.toArray(),l=o.length,c=Zt(r,l);let a=0,h=0;for(;a<c;a++){const u=o[a],f=s[a];if(!fn(i.mapping.get(u),f))if(_e(u,f))i.mapping.set(u,f);else break}for(;h+a+1<c;h++){const u=o[l-h-1],f=s[r-h-1];if(!fn(i.mapping.get(u),f))if(_e(u,f))i.mapping.set(u,f);else break}e.transact(()=>{for(;l-a-h>0&&r-a-h>0;){const f=o[a],p=s[a],g=o[l-h-1],x=s[r-h-1];if(f instanceof nt&&p instanceof Array)ro(f,p)||Oh(f,p,i),a+=1;else{let w=f instanceof J&&gi(f,p),y=g instanceof J&&gi(g,x);if(w&&y){const C=ks(f,p,i),k=ks(g,x,i);C.foundMappedChild&&!k.foundMappedChild?y=!1:!C.foundMappedChild&&k.foundMappedChild||C.equalityFactor<k.equalityFactor?w=!1:y=!1}w?(pi(e,f,p,i),a+=1):y?(pi(e,g,x,i),h+=1):(i.mapping.delete(t.get(a)),t.delete(a,1),t.insert(a,[fi(p,i)]),a+=1)}}const u=l-a-h;if(l===1&&r===0&&o[0]instanceof nt?(i.mapping.delete(o[0]),o[0].delete(0,o[0].length)):u>0&&(t.slice(a,a+u).forEach(f=>i.mapping.delete(f)),t.delete(a,u)),a+h<r){const f=[];for(let p=a;p<r-h;p++)f.push(fi(s[p],i));t.insert(a,f)}},j)},gi=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,pn=(e,t,n)=>{if(e===0)return Kn(t,0,-1);let i=t._first===null?null:t._first.content.type;for(;i!==null&&t!==i;){if(i instanceof nt){if(i._length>=e)return Kn(i,e,-1);if(e-=i._length,i._item!==null&&i._item.next!==null)i=i._item.next.content.type;else{do i=i._item===null?null:i._item.parent,e--;while(i!==t&&i!==null&&i._item!==null&&i._item.next===null);i!==null&&i!==t&&(i=i._item===null?null:i._item.next.content.type)}}else{const s=(n.get(i)||{nodeSize:0}).nodeSize;if(i._first!==null&&e<s)i=i._first.content.type,e--;else{if(e===1&&i._length===0&&s>1)return new on(i._item===null?null:i._item.id,i._item===null?Se(i):null,null);if(e-=s,i._item!==null&&i._item.next!==null)i=i._item.next.content.type;else{if(e===0)return i=i._item===null?i:i._item.parent,new on(i._item===null?null:i._item.id,i._item===null?Se(i):null,null);do i=i._item.parent,e--;while(i!==t&&i._item.next===null);i!==t&&(i=i._item.next.content.type)}}}if(i===null)throw Z();if(e===0&&i.constructor!==nt&&i!==t)return jh(i._item.parent,i._item)}return Kn(t,t._length,-1)},jh=(e,t)=>{let n=null,i=null;return e._item===null?i=Se(e):n=_(e._item.id.client,e._item.id.clock),new on(n,i,t.id)},pe=(e,t,n,i)=>{const s=ou(n,e);if(s===null||s.type!==t&&!ve(t,s.type._item))return null;let r=s.type,o=0;if(r.constructor===nt)o=s.index;else if(r._item===null||!r._item.deleted){let l=r._first,c=0;for(;c<r._length&&c<s.index&&l!==null;){if(!l.deleted){const a=l.content.type;c++,a instanceof nt?o+=a._length:o+=i.get(a).nodeSize}l=l.right}o+=1}for(;r!==t&&r._item!==null;){const l=r._item.parent;if(l._item===null||!l._item.deleted){o+=1;let c=l._first;for(;c!==null;){const a=c.content.type;if(a===r)break;c.deleted||(a instanceof nt?o+=a._length:o+=i.get(a).nodeSize),c=c.right}}r=l}return o-1};function Nh(e){const t=e.toArray(),n=i=>{let s;if(i instanceof nt)s=i.toDelta().map(o=>{const l={type:"text",text:o.insert};return o.attributes&&(l.marks=Object.keys(o.attributes).map(c=>{const a=o.attributes[c],u={type:Fi(c)};return Object.keys(a)&&(u.attrs=a),u})),l});else if(i instanceof J){s={type:i.nodeName};const r=i.getAttributes();Object.keys(r).length&&(s.attrs=r);const o=i.toArray();o.length&&(s.content=o.map(n).flat())}else Z();return s};return{type:"doc",content:t.map(n)}}const Lh=e=>{const t=Ct.getState(e).undoManager;if(t!=null)return t.undo(),!0},Bh=e=>{const t=Ct.getState(e).undoManager;if(t!=null)return t.redo(),!0},Uh=new Set(["paragraph"]),Ph=(e,t)=>!(e instanceof O)||!(e.content instanceof mt)||!(e.content.type instanceof Mt||e.content.type instanceof J&&t.has(e.content.type.nodeName))||e.content.type._length===0,$h=({protectedNodes:e=Uh,trackedOrigins:t=[],undoManager:n=null}={})=>new T.Plugin({key:Ct,state:{init:(i,s)=>{const r=j.getState(s),o=n||new Nr(r.type,{trackedOrigins:new Set([j].concat(t)),deleteFilter:l=>Ph(l,e),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(i,s,r,o)=>{const l=j.getState(o).binding,c=s.undoManager,a=c.undoStack.length>0,h=c.redoStack.length>0;return l?{undoManager:c,prevSel:di(l,r),hasUndoOps:a,hasRedoOps:h}:a!==s.hasUndoOps||h!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:c.undoStack.length>0,hasRedoOps:c.redoStack.length>0}):s}},view:i=>{const s=j.getState(i.state),r=Ct.getState(i.state).undoManager;return r.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Ct.getState(i.state).prevSel)}),r.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{r.destroy()}}}});function lo(e){return!!e.getMeta(j)}function Fh(e,t){const n=j.getState(e);return pe(n.doc,n.type,t,n.binding.mapping)||0}function co(e,t){const n=j.getState(e);return pn(t,n.type,n.binding.mapping)}var Ge=class ao extends T.MappablePosition{constructor(t,n){super(t),this.yRelativePosition=n}static fromJSON(t){return new ao(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function Vh(e,t){const n=co(t,e);return new Ge(e,n)}function Hh(e,t,n){const i=e instanceof Ge?e.yRelativePosition:null;if(lo(t)&&i){const o=Fh(n,i);return{position:new Ge(o,i),mapResult:null}}const s=T.getUpdatedPosition(e,t),r=s.position.position;return{position:new Ge(r,i??co(n,r)),mapResult:s.mapResult}}T.Extension.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>Hh(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>Vh(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),Ct.getState(t).undoManager.undoStack.length===0?!1:n?Lh(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),Ct.getState(t).undoManager.redoStack.length===0?!1:n?Bh(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=$h(this.options.yUndoOptions),i=n.spec.view;n.spec.view=o=>{const{undoManager:l}=Ct.getState(o.state);l.restore&&(l.restore(),l.restore=()=>{});const c=i?i(o):void 0;return{destroy:()=>{const a=l.trackedOrigins.has(l),h=l._observers;l.restore=()=>{a&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=h},c!=null&&c.destroy&&c.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},r=Ch(t,s);return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on("beforeTransaction",()=>{try{const o=Nh(t);if(o.content.length===0)return;this.editor.schema.nodeFromJSON(o).check()}catch(o){return this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[r,n,this.editor.options.enableContentCheck&&new W.Plugin({key:new W.PluginKey("filterInvalidContent"),filterTransaction:()=>{var o;return this.storage.isDisabled!==!1&&((o=t.doc)==null||o.destroy()),!0}})].filter(Boolean)}});function Es(e){if(!e.length)return jn.DecorationSet.empty;const t=[],n=e[0].$from.node(0);return e.forEach(i=>{const s=i.$from.pos,r=i.$from.nodeAfter;r&&t.push(jn.Decoration.node(s,s+r.nodeSize,{class:"ProseMirror-selectednoderange"}))}),jn.DecorationSet.create(n,t)}function On(e,t,n){const i=[],s=e.node(0);typeof n=="number"&&n>=0||(e.sameParent(t)?n=Math.max(0,e.sharedDepth(t.pos)-1):n=e.sharedDepth(t.pos));const r=new Io.NodeRange(e,t,n),o=r.depth===0?0:s.resolve(r.start).posAtIndex(0);return r.parent.forEach((l,c)=>{const a=o+c,h=a+l.nodeSize;if(a<r.start||a>=r.end)return;const u=new W.SelectionRange(s.resolve(a),s.resolve(h));i.push(u)}),i}var zh=class uo{constructor(t,n){this.anchor=t,this.head=n}map(t){return new uo(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),i=t.resolve(this.head);return new It(n,i)}},It=class _t extends W.Selection{constructor(t,n,i,s=1){const{doc:r}=t,o=t===n,l=t.pos===r.content.size&&n.pos===r.content.size,c=o&&!l?r.resolve(n.pos+(s>0?1:-1)):n,a=o&&l?r.resolve(t.pos-(s>0?1:-1)):t,h=On(a.min(c),a.max(c),i),u=c.pos>=t.pos?h[0].$from:h[h.length-1].$to,f=c.pos>=t.pos?h[h.length-1].$to:h[0].$from;super(u,f,h),this.depth=i}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof _t&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){const i=t.resolve(n.map(this.anchor)),s=t.resolve(n.map(this.head));return new _t(i,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),r=s[0].$from,o=s[s.length-1].$to;return new _t(r,o,this.depth)}const n=this.ranges[0],i=t.resolve(Math.max(0,n.$from.pos-1));return new _t(this.$anchor,i,this.depth)}extendForwards(){const{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),r=s[0].$from,o=s[s.length-1].$to;return new _t(o,r,this.depth)}const n=this.ranges[this.ranges.length-1],i=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new _t(this.$anchor,i,this.depth)}static fromJSON(t,n){return new _t(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,i,s,r=1){return new this(t.resolve(n),t.resolve(i),s,r)}getBookmark(){return new zh(this.anchor,this.head)}};It.prototype.visible=!1;function Pe(e){return e instanceof It}T.Extension.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,selection:r,tr:o}=i,{anchor:l,head:c}=r;if(!Pe(r)){const h=It.create(s,l,c,t,-1);return o.setSelection(h),n.dispatch(o),!0}const a=r.extendBackwards();return o.setSelection(a),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,selection:r,tr:o}=i,{anchor:l,head:c}=r;if(!Pe(r)){const h=It.create(s,l,c,t);return o.setSelection(h),n.dispatch(o),!0}const a=r.extendForwards();return o.setSelection(a),n.dispatch(o),!0},"Mod-a":({editor:e})=>{const{depth:t}=this.options,{view:n,state:i}=e,{doc:s,tr:r}=i,o=It.create(s,0,s.content.size,t);return r.setSelection(o),n.dispatch(r),!0}}},onSelectionUpdate(){const{selection:e}=this.editor.state;Pe(e)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let e=!1,t=!1;return[new W.Plugin({key:new W.PluginKey("nodeRange"),props:{attributes:()=>e?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,i)=>{const{key:s}=this.options,r=/Mac/.test(navigator.platform),o=!!i.shiftKey,l=!!i.ctrlKey,c=!!i.altKey,a=!!i.metaKey,h=r?a:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&c||s==="Meta"&&a||s==="Mod"&&h)&&(t=!0),t&&document.addEventListener("mouseup",()=>{t=!1;const{state:u}=n,{doc:f,selection:p,tr:g}=u,{$anchor:x,$head:w}=p;if(x.sameParent(w))return;const y=It.create(f,x.pos,w.pos,this.options.depth);g.setSelection(y),n.dispatch(g)},{once:!0}),!1}},decorations:n=>{const{selection:i}=n,s=Pe(i);if(e=!1,!t)return s?(e=!0,Es(i.ranges)):null;const{$from:r,$to:o}=i;if(!s&&r.sameParent(o))return null;const l=On(r,o,this.options.depth);return l.length?(e=!0,Es(l)):null}}})]}});function Kh(e){let t="";const n=getComputedStyle(e);for(let i=0;i<n.length;i+=1)t+=`${n[i]}:${n.getPropertyValue(n[i])};`;return t}function qh(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],i=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((s,r)=>{i[r].style.cssText=Kh(s)}),t}var Wh={id:"listItemFirstChild",evaluate:({parent:e,isFirst:t})=>t&&e&&["listItem","taskItem"].includes(e.type.name)?1e3:0},Gh={id:"listWrapperDeprioritize",evaluate:({node:e})=>{const t=["listItem","taskItem"],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},Yh={id:"tableStructure",evaluate:({node:e,parent:t})=>["tableRow","tableCell","tableHeader"].includes(e.type.name)||t&&t.type.name==="tableHeader"?1e3:0},Jh={id:"inlineContent",evaluate:({node:e})=>e.isInline||e.isText?1e3:0},Xh=[Wh,Gh,Yh,Jh],_s={edges:["left","top"],threshold:12,strength:500};function Yn(e){return e===void 0||e==="left"?{..._s}:e==="right"?{edges:["right","top"],threshold:12,strength:500}:e==="both"?{edges:["left","right","top"],threshold:12,strength:500}:e==="none"?{edges:[],threshold:0,strength:0}:{..._s,...e}}function Zh(e,t,n){if(n.edges.length===0)return!1;const i=t.getBoundingClientRect(),{threshold:s,edges:r}=n;return r.some(o=>o==="left"?e.x-i.left<s:o==="right"?i.right-e.x<s:o==="top"?e.y-i.top<s:o==="bottom"?i.bottom-e.y<s:!1)}function Qh(e,t,n,i){return!t||n.edges.length===0?0:Zh(e,t,n)?n.strength*i:0}var td=1e3;function Ts(e,t,n,i){let s=td,r=!1;if(t.every(l=>{const c=l.evaluate(e);return s-=c,s<=0?(r=!0,!1):!0}),r)return-1;const o=e.view.nodeDOM(e.pos);return s-=Qh(i,o,n,e.depth),s<=0?-1:s}function Is(e,t,n){return Array.from({length:t},(s,r)=>t-1-r).some(s=>n.includes(e.node(s).type.name))}function ed(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;const i=e.posAtCoords({left:t.x,top:t.y});if(!i)return null;const{doc:s}=e.state,r=s.resolve(i.pos),o=[];n.defaultRules&&o.push(...Xh),o.push(...n.rules);const c=Array.from({length:r.depth},(u,f)=>r.depth-f).map(u=>{const f=r.node(u),p=r.before(u);if(n.allowedContainers&&u>0&&!Is(r,u,n.allowedContainers))return null;const g=u>0?r.node(u-1):null,x=u>0?r.index(u-1):0,w=g?g.childCount:1,y={node:f,pos:p,depth:u,parent:g,index:x,isFirst:x===0,isLast:x===w-1,$pos:r,view:e},C=Ts(y,o,n.edgeDetection,t);if(C<0)return null;const k=e.nodeDOM(p);return{node:f,pos:p,depth:u,score:C,dom:k}}).filter(u=>u!==null),a=r.nodeAfter;if(a&&a.isAtom&&!a.isInline){const u=i.pos,f=r.depth+1,p=r.parent,g=r.index(),x=p.childCount;let w=!0;if(n.allowedContainers&&(w=Is(r,f,n.allowedContainers)),w){const y={node:a,pos:u,depth:f,parent:p,index:g,isFirst:g===0,isLast:g===x-1,$pos:r,view:e},C=Ts(y,o,n.edgeDetection,t);if(C>=0){const k=e.nodeDOM(u);k&&c.push({node:a,pos:u,depth:f,score:C,dom:k})}}}if(c.length===0)return null;c.sort((u,f)=>f.score!==u.score?f.score-u.score:f.depth-u.depth);const h=c[0];return h.dom?{node:h.node,pos:h.pos,dom:h.dom}:null}function nd(e,t){let n=e;for(;n!=null&&n.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return(n==null?void 0:n.parentElement)===t.dom?n:void 0}function Ds(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function id(e,t,n,i=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;const s=e.dom,r=s.firstElementChild,o=s.lastElementChild;if(!r||!o)return null;const l=r.getBoundingClientRect(),c=o.getBoundingClientRect();if(!Ds(l)||!Ds(c))return null;const a=Math.min(Math.max(l.top+i,n),c.bottom-i),h=.5,u=Math.abs(l.left-c.left)<h,f=Math.abs(l.right-c.right)<h;let p=l;u&&f&&(p=l);const g=Math.min(Math.max(p.left+i,t),p.right-i);return!Number.isFinite(g)||!Number.isFinite(a)?null:{x:g,y:a}}var ho=e=>{const{x:t,y:n,editor:i,nestedOptions:s}=e,{view:r,state:o}=i,l=id(r,t,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:c,y:a}=l;if(s!=null&&s.enabled){const g=ed(r,{x:c,y:a},s);return g?{resultElement:g.dom,resultNode:g.node,pos:g.pos}:{resultElement:null,resultNode:null,pos:null}}const h=r.root.elementsFromPoint(c,a);let u;if(Array.prototype.some.call(h,g=>{if(!r.dom.contains(g))return!1;const x=nd(g,r);return x?(u=x,!0):!1}),!u)return{resultElement:null,resultNode:null,pos:null};let f;try{f=r.posAtDOM(u,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const p=o.doc.nodeAt(f);if(!p){const g=o.doc.resolve(f),x=g.parent;return{resultElement:u,resultNode:x,pos:g.start()}}return{resultElement:u,resultNode:p,pos:f}};function fo(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function sd(e,t,n,i){const{doc:s}=t.view.state;if(n!=null&&n.enabled&&(i!=null&&i.node)&&i.pos>=0){const a=i.pos,h=i.pos+i.node.nodeSize;return[{$from:s.resolve(a),$to:s.resolve(h)}]}const r=ho({editor:t,x:e.clientX,y:e.clientY,nestedOptions:n});if(!r.resultNode||r.pos===null)return[];const o=r.resultNode.isText||r.resultNode.isAtom?0:-1,l=s.resolve(r.pos),c=s.resolve(r.pos+r.resultNode.nodeSize+o);return On(l,c,0)}function rd(e,t,n,i){const{view:s}=t;if(!e.dataTransfer)return;const{empty:r,$from:o,$to:l}=s.state.selection,c=sd(e,t,n,i),a=On(o,l,0),h=a.some(A=>c.find(L=>L.$from===A.$from&&L.$to===A.$to)),u=r||!h?c:a;if(!u.length)return;const{tr:f}=s.state,p=document.createElement("div"),g=u[0].$from.pos,x=u[u.length-1].$to.pos,w=(n==null?void 0:n.enabled)&&(i==null?void 0:i.node);let y,C;w?(y=s.state.doc.slice(g,x),C=W.NodeSelection.create(s.state.doc,g)):(C=It.create(s.state.doc,g,x),y=C.content()),u.forEach(A=>{const L=s.nodeDOM(A.$from.pos),S=qh(L);p.append(S)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),e.dataTransfer.clearData(),e.dataTransfer.setDragImage(p,0,0);const k=C instanceof W.NodeSelection?C:void 0;s.dragging={slice:y,move:!0,node:k},f.setSelection(C),s.dispatch(f),document.addEventListener("drop",()=>fo(p),{once:!0})}var As=(e,t)=>{const n=e.resolve(t),{depth:i}=n;return i===0?t:n.pos-n.parentOffset-1},Os=(e,t)=>{const n=e.nodeAt(t),i=e.resolve(t);let{depth:s}=i,r=n;for(;s>0;){const o=i.node(s);s-=1,s===0&&(r=o)}return r},Jn=(e,t)=>{const n=j.getState(e);return n?pn(t,n.type,n.binding.mapping):null},od=(e,t)=>{const n=j.getState(e);return n?pe(n.doc,n.type,t,n.binding.mapping)||0:-1},Ms=(e,t)=>{let n=t;for(;n!=null&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},po=new W.PluginKey("dragHandle"),go=({pluginKey:e=po,element:t,editor:n,computePositionConfig:i,getReferencedVirtualElement:s,onNodeChange:r,onElementDragStart:o,onElementDragEnd:l,nestedOptions:c})=>{const a=document.createElement("div");let h=!1,u=null,f=-1,p,g=null,x=null;function w(){t&&(t.style.visibility="hidden",t.style.pointerEvents="none")}function y(){if(t){if(!n.isEditable){w();return}t.style.visibility="",t.style.pointerEvents="auto"}}function C(S){const v=(s==null?void 0:s())||{getBoundingClientRect:()=>S.getBoundingClientRect()};H.computePosition(v,t,i).then(I=>{Object.assign(t.style,{position:I.strategy,left:`${I.x}px`,top:`${I.y}px`})})}function k(S){o==null||o(S),rd(S,n,c,{node:u,pos:f}),t&&(t.dataset.dragging="true"),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}function A(S){l==null||l(S),w(),t&&(t.style.pointerEvents="auto",t.dataset.dragging="false")}function L(){if(T.isFirefox()){const S=n.view.dom;requestAnimationFrame(()=>{S.isContentEditable&&(S.contentEditable="false",S.contentEditable="true")})}}return a.appendChild(t),{unbind(){t.removeEventListener("dragstart",k),t.removeEventListener("dragend",A),document.removeEventListener("drop",L),g&&(cancelAnimationFrame(g),g=null,x=null)},plugin:new W.Plugin({key:typeof e=="string"?new W.PluginKey(e):e,state:{init(){return{locked:!1}},apply(S,v,I,z){const N=S.getMeta("lockDragHandle"),$=S.getMeta("hideDragHandle");if(N!==void 0&&(h=N),$)return w(),h=!1,u=null,f=-1,r==null||r({editor:n,node:null,pos:-1}),v;if(S.docChanged&&f!==-1&&t)if(lo(S)){const Y=od(z,p);Y!==f&&(f=Y)}else{const Y=S.mapping.map(f);Y!==f&&(f=Y,p=Jn(z,f))}return v}},view:S=>{var v;return t.draggable=!0,t.style.pointerEvents="auto",t.dataset.dragging="false",(v=n.view.dom.parentElement)==null||v.appendChild(a),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",t.addEventListener("dragstart",k),t.addEventListener("dragend",A),document.addEventListener("drop",L),{update(I,z){if(!t)return;if(!n.isEditable){w();return}if(h?t.draggable=!1:t.draggable=!0,S.state.doc.eq(z.doc)||f===-1)return;let N=S.nodeDOM(f);if(N=Ms(S,N),N===S.dom||(N==null?void 0:N.nodeType)!==1)return;const $=S.posAtDOM(N,0),Y=Os(n.state.doc,$),st=As(n.state.doc,$);u=Y,f=st,p=Jn(S.state,f),r==null||r({editor:n,node:u,pos:f}),C(N)},destroy(){t.removeEventListener("dragstart",k),t.removeEventListener("dragend",A),document.removeEventListener("drop",L),g&&(cancelAnimationFrame(g),g=null,x=null),t&&fo(a)}}},props:{handleDOMEvents:{keydown(S){return!t||h||S.hasFocus()&&(w(),u=null,f=-1,r==null||r({editor:n,node:null,pos:-1})),!1},mouseleave(S,v){return h||v.target&&!a.contains(v.relatedTarget)&&(w(),u=null,f=-1,r==null||r({editor:n,node:null,pos:-1})),!1},mousemove(S,v){return!t||h||(x={x:v.clientX,y:v.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!x)return;const{x:I,y:z}=x;x=null;const N=ho({x:I,y:z,editor:n,nestedOptions:c});if(!N.resultElement)return;let $=N.resultElement,Y=N.resultNode,st=N.pos;if(!(c!=null&&c.enabled)){if($=Ms(S,$),$===S.dom||($==null?void 0:$.nodeType)!==1)return;const E=S.posAtDOM($,0);Y=Os(n.state.doc,E),st=As(n.state.doc,E)}Y!==u&&(u=Y,f=st??-1,p=Jn(S.state,f),r==null||r({editor:n,node:u,pos:f}),C($),y())})),!1}}}})}};function mo(e){var t,n;return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Yn("none")}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Yn("left")}:{enabled:!0,rules:(t=e.rules)!=null?t:[],defaultRules:(n=e.defaultRules)!=null?n:!0,allowedContainers:e.allowedContainers,edgeDetection:Yn(e.edgeDetection)}}var mi={placement:"left-start",strategy:"absolute"};T.Extension.create({name:"dragHandle",addOptions(){return{render(){const e=document.createElement("div");return e.classList.add("drag-handle"),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const e=this.options.render(),t=mo(this.options.nested);return[go({computePositionConfig:{...mi,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var ld=e=>{const{className:t="drag-handle",children:n,editor:i,pluginKey:s=po,onNodeChange:r,onElementDragStart:o,onElementDragEnd:l,computePositionConfig:c=mi,nested:a=!1}=e,[h,u]=b.useState(null),f=b.useRef(null),p=b.useMemo(()=>mo(a),[JSON.stringify(a)]);return b.useEffect(()=>{let g=null;return h?i.isDestroyed?()=>{f.current=null}:(f.current||(g=go({editor:i,element:h,pluginKey:s,computePositionConfig:{...mi,...c},onElementDragStart:o,onElementDragEnd:l,onNodeChange:r,nestedOptions:p}),f.current=g.plugin,i.registerPlugin(f.current)),()=>{i.unregisterPlugin(s),f.current=null,g&&(g.unbind(),g=null)}):()=>{f.current=null}},[h,i,r,s,c,o,l,p]),d.jsx("div",{className:t,style:{visibility:"hidden",position:"absolute"},"data-dragging":"false",ref:u,children:n})},cd=ld;function ad(){var S,v,I,z,N,$,Y,st;const e=m.useEditorInstance(),t=m.useEditableEditor(),{t:n}=B.useLocale(),[i,s]=b.useState(null),[r,o]=b.useState(-1),[l,c]=b.useState(!1),a=(v=(S=e==null?void 0:e.extensionManager)==null?void 0:S.extensions)==null?void 0:v.some(E=>(E==null?void 0:E.name)===Ls.TextAlign.name),h=(z=(I=e==null?void 0:e.extensionManager)==null?void 0:I.extensions)==null?void 0:z.some(E=>(E==null?void 0:E.name)===ue.Indent.name),u=($=(N=e==null?void 0:e.extensionManager)==null?void 0:N.extensions)==null?void 0:$.some(E=>(E==null?void 0:E.name)===Do.Clear.name);function f(){const E=e.chain();E.setNodeSelection(r).unsetAllMarks(),(i==null?void 0:i.type.name)!=="paragraph"&&E.setParagraph(),E.run()}function p(){e.chain().focus().setNodeSelection(r).run(),document.execCommand("copy")}function g(){e.commands.setNodeSelection(r);const{$anchor:E}=e.state.selection,yt=E.node(1)||e.state.selection.node;e.chain().setMeta("hideDragHandle",!0).insertContentAt(r+((i==null?void 0:i.nodeSize)||0),yt.toJSON()).run()}function x(E){e.commands.setTextAlign(E)}function w(){const E=ue.setNodeIndentMarkup(e.state.tr,r,1);E.setMeta("hideDragHandle",!0),e.view.dispatch&&e.view.dispatch(E)}function y(){const E=ue.setNodeIndentMarkup(e.state.tr,r,-1);e.view.dispatch&&e.view.dispatch(E)}function C(){e.chain().setMeta("hideDragHandle",!0).setNodeSelection(r).deleteSelection().run()}const k=b.useCallback(E=>{E.node&&s(E.node),o(E.pos),requestAnimationFrame(()=>{E.editor.commands.focus()})},[]),A=E=>{var yt;if(E.preventDefault(),r!==-1){const Me=(i==null?void 0:i.nodeSize)||0,Vt=r+Me,Vi=(i==null?void 0:i.type.name)==="paragraph"&&((yt=i==null?void 0:i.content)==null?void 0:yt.size)===0,xo=Vi?r+2:Vt+2;e.chain().command(({dispatch:Hi,tr:Mn,state:zi})=>Hi?(Vi?Mn.insertText("/",r,r+1):Mn.insert(Vt,zi.schema.nodes.paragraph.create(null,[zi.schema.text("/")])),Hi(Mn)):!0).focus(xo).run()}};b.useEffect(()=>(l?e.commands.setMeta("lockDragHandle",!0):e.commands.setMeta("lockDragHandle",!1),()=>{e.commands.setMeta("lockDragHandle",!1)}),[l]);const L=E=>{t&&c(E)};return d.jsx(cd,{className:"richtext-transition-all richtext-duration-200 richtext-ease-out",editor:e,onNodeChange:k,pluginKey:"RichTextBubbleMenuDragHandle",children:d.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5",children:[d.jsx(m.ActionButton,{action:A,disabled:!t,icon:"Plus",tooltip:"Insert block"}),d.jsx(m.ActionButton,{disabled:!t,icon:"Grip",tooltip:"Click for options, Hold for drag",action:E=>{E.preventDefault(),E.stopPropagation(),L(!l)}}),d.jsxs(U.DropdownMenu,{onOpenChange:L,open:l,children:[d.jsx(U.DropdownMenuTrigger,{className:"richtext-pointer-events-none"}),d.jsxs(U.DropdownMenuContent,{align:"start",className:"richtext-w-48",hideWhenDetached:!0,side:"bottom",sideOffset:0,children:[d.jsxs(U.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:C,children:[d.jsx(m.IconComponent,{name:"Trash2"}),d.jsx("span",{children:n("editor.remove")})]}),u?d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:f,children:[d.jsx(m.IconComponent,{name:"PaintRoller"}),d.jsx("span",{children:n("editor.clear.tooltip")})]}):null,d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:p,children:[d.jsx(m.IconComponent,{name:"Clipboard"}),d.jsx("span",{children:n("editor.copyToClipboard")})]}),d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:g,children:[d.jsx(m.IconComponent,{name:"Copy"}),d.jsx("span",{children:n("editor.copy")})]}),a||h?d.jsx(U.DropdownMenuSeparator,{}):null,a?d.jsxs(U.DropdownMenuSub,{children:[d.jsxs(U.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[d.jsx(m.IconComponent,{name:"AlignCenter"}),d.jsx("span",{children:n("editor.textalign.tooltip")})]}),d.jsx(U.DropdownMenuPortal,{children:d.jsxs(U.DropdownMenuSubContent,{children:[d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("left"),children:[d.jsx(m.IconComponent,{name:"AlignLeft"}),d.jsx("span",{children:n("editor.textalign.left.tooltip")})]}),d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("center"),children:[d.jsx(m.IconComponent,{name:"AlignCenter"}),d.jsx("span",{children:n("editor.textalign.center.tooltip")})]}),d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",onClick:()=>x("right"),children:[d.jsx(m.IconComponent,{name:"AlignRight"}),d.jsx("span",{children:n("editor.textalign.right.tooltip")})]})]})})]}):null,h?d.jsxs(U.DropdownMenuSub,{children:[d.jsxs(U.DropdownMenuSubTrigger,{className:"richtext-flex richtext-gap-3",children:[d.jsx(m.IconComponent,{name:"IndentIncrease"}),d.jsx("span",{children:n("editor.indent")})]}),d.jsx(U.DropdownMenuPortal,{children:d.jsxs(U.DropdownMenuSubContent,{children:[d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:((Y=i==null?void 0:i.attrs)==null?void 0:Y.indent)>=ue.IndentProps.max,onClick:w,children:[d.jsx(m.IconComponent,{name:"IndentIncrease"}),d.jsx("span",{children:n("editor.indent.tooltip")})]}),d.jsxs(U.DropdownMenuItem,{className:"richtext-flex richtext-gap-3",disabled:((st=i==null?void 0:i.attrs)==null?void 0:st.indent)<=ue.IndentProps.min,onClick:y,children:[d.jsx(m.IconComponent,{name:"IndentDecrease"}),d.jsx("span",{children:n("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}exports.RichTextBubbleCallout=ol;exports.RichTextBubbleColumns=ll;exports.RichTextBubbleDrawer=Cl;exports.RichTextBubbleExcalidraw=El;exports.RichTextBubbleIframe=_l;exports.RichTextBubbleImage=jl;exports.RichTextBubbleImageGif=Nl;exports.RichTextBubbleKatex=Il;exports.RichTextBubbleLink=Al;exports.RichTextBubbleMenuDragHandle=ad;exports.RichTextBubbleMermaid=$l;exports.RichTextBubbleTable=Fl;exports.RichTextBubbleText=zl;exports.RichTextBubbleTwitter=Kl;exports.RichTextBubbleVideo=Ll;
|