@krainovsd/markdown-editor 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index-Byjf17iv.js +501 -0
- package/lib/cjs/index-Byjf17iv.js.map +1 -0
- package/lib/cjs/index-lPo-3QDL.js +1374 -0
- package/lib/cjs/index-lPo-3QDL.js.map +1 -0
- package/lib/cjs/index.js +14 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/extensions/compartments/index.js +8 -0
- package/lib/esm/extensions/compartments/index.js.map +1 -0
- package/lib/esm/extensions/init-extensions.js +45 -0
- package/lib/esm/extensions/init-extensions.js.map +1 -0
- package/lib/esm/extensions/keymaps/init-key-map.js +91 -0
- package/lib/esm/extensions/keymaps/init-key-map.js.map +1 -0
- package/lib/esm/extensions/listeners/get-change-event.js +14 -0
- package/lib/esm/extensions/listeners/get-change-event.js.map +1 -0
- package/lib/esm/extensions/listeners/get-focus-event.js +16 -0
- package/lib/esm/extensions/listeners/get-focus-event.js.map +1 -0
- package/lib/esm/extensions/listeners/init-listeners.js +9 -0
- package/lib/esm/extensions/listeners/init-listeners.js.map +1 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-constants.js +6 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js +99 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-widget.js +25 -0
- package/lib/esm/extensions/markdown/blockquote/blockquote-widget.js.map +1 -0
- package/lib/esm/extensions/markdown/bold/bold-constants.js +5 -0
- package/lib/esm/extensions/markdown/bold/bold-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/bold/bold-decoration.js +41 -0
- package/lib/esm/extensions/markdown/bold/bold-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/code/code-constants.js +6 -0
- package/lib/esm/extensions/markdown/code/code-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/code/code-decoration.js +109 -0
- package/lib/esm/extensions/markdown/code/code-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/code/code-widget.js +83 -0
- package/lib/esm/extensions/markdown/code/code-widget.js.map +1 -0
- package/lib/esm/extensions/markdown/header/header-constants.js +6 -0
- package/lib/esm/extensions/markdown/header/header-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/header/header-decoration.js +64 -0
- package/lib/esm/extensions/markdown/header/header-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/horizontal/horizontal-constants.js +4 -0
- package/lib/esm/extensions/markdown/horizontal/horizontal-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/horizontal/horizontal-decoration.js +31 -0
- package/lib/esm/extensions/markdown/horizontal/horizontal-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/image/image-constants.js +8 -0
- package/lib/esm/extensions/markdown/image/image-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/image/image-decoration.js +75 -0
- package/lib/esm/extensions/markdown/image/image-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/image/image-widget.js +184 -0
- package/lib/esm/extensions/markdown/image/image-widget.js.map +1 -0
- package/lib/esm/extensions/markdown/index.js +2 -0
- package/lib/esm/extensions/markdown/index.js.map +1 -0
- package/lib/esm/extensions/markdown/init-markdown.js +18 -0
- package/lib/esm/extensions/markdown/init-markdown.js.map +1 -0
- package/lib/esm/extensions/markdown/italic/italic-constants.js +5 -0
- package/lib/esm/extensions/markdown/italic/italic-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/italic/italic-decoration.js +77 -0
- package/lib/esm/extensions/markdown/italic/italic-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/link/auto-link-decoration.js +24 -0
- package/lib/esm/extensions/markdown/link/auto-link-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/link/link-constants.js +10 -0
- package/lib/esm/extensions/markdown/link/link-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/link/link-decoration.js +51 -0
- package/lib/esm/extensions/markdown/link/link-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/link/link-label-decoration.js +22 -0
- package/lib/esm/extensions/markdown/link/link-label-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/link/link-widget.js +144 -0
- package/lib/esm/extensions/markdown/link/link-widget.js.map +1 -0
- package/lib/esm/extensions/markdown/list/list-constants.js +7 -0
- package/lib/esm/extensions/markdown/list/list-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/list/list-decoration.js +38 -0
- package/lib/esm/extensions/markdown/list/list-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/list/list-widget.js +33 -0
- package/lib/esm/extensions/markdown/list/list-widget.js.map +1 -0
- package/lib/esm/extensions/markdown/markdown-decoration.js +105 -0
- package/lib/esm/extensions/markdown/markdown-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/markdown-parser.js +6 -0
- package/lib/esm/extensions/markdown/markdown-parser.js.map +1 -0
- package/lib/esm/extensions/markdown/mention/mention-constants.js +6 -0
- package/lib/esm/extensions/markdown/mention/mention-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/mention/mention-decoration.js +37 -0
- package/lib/esm/extensions/markdown/mention/mention-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/mention/mention-parser.js +25 -0
- package/lib/esm/extensions/markdown/mention/mention-parser.js.map +1 -0
- package/lib/esm/extensions/markdown/strike-through/strike-through-constants.js +4 -0
- package/lib/esm/extensions/markdown/strike-through/strike-through-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js +32 -0
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/styles.module.scss.js +8 -0
- package/lib/esm/extensions/markdown/styles.module.scss.js.map +1 -0
- package/lib/esm/extensions/markdown/todo/todo-constants.js +6 -0
- package/lib/esm/extensions/markdown/todo/todo-constants.js.map +1 -0
- package/lib/esm/extensions/markdown/todo/todo-decoration.js +35 -0
- package/lib/esm/extensions/markdown/todo/todo-decoration.js.map +1 -0
- package/lib/esm/extensions/markdown/todo/todo-widget.js +51 -0
- package/lib/esm/extensions/markdown/todo/todo-widget.js.map +1 -0
- package/lib/esm/extensions/settings/init-settings.js +19 -0
- package/lib/esm/extensions/settings/init-settings.js.map +1 -0
- package/lib/esm/extensions/theme/init-theme.js +15 -0
- package/lib/esm/extensions/theme/init-theme.js.map +1 -0
- package/lib/esm/extensions/theme/theme-constants.js +17 -0
- package/lib/esm/extensions/theme/theme-constants.js.map +1 -0
- package/lib/esm/extensions/theme/themes/get-dark-theme.js +40 -0
- package/lib/esm/extensions/theme/themes/get-dark-theme.js.map +1 -0
- package/lib/esm/extensions/theme/themes/get-highlight-template.js +35 -0
- package/lib/esm/extensions/theme/themes/get-highlight-template.js.map +1 -0
- package/lib/esm/extensions/theme/themes/get-light-theme.js +40 -0
- package/lib/esm/extensions/theme/themes/get-light-theme.js.map +1 -0
- package/lib/esm/extensions/theme/themes/get-theme-template.js +69 -0
- package/lib/esm/extensions/theme/themes/get-theme-template.js.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/lib/utils/copy-to-clipboard.js +35 -0
- package/lib/esm/lib/utils/copy-to-clipboard.js.map +1 -0
- package/lib/esm/lib/utils/get-decoration.js +24 -0
- package/lib/esm/lib/utils/get-decoration.js.map +1 -0
- package/lib/esm/lib/utils/is-in-range.js +8 -0
- package/lib/esm/lib/utils/is-in-range.js.map +1 -0
- package/lib/esm/lib/utils/is-range-overlap.js +6 -0
- package/lib/esm/lib/utils/is-range-overlap.js.map +1 -0
- package/lib/esm/lib/utils/tick.js +22 -0
- package/lib/esm/lib/utils/tick.js.map +1 -0
- package/lib/esm/module/Editor/Editor.js +91 -0
- package/lib/esm/module/Editor/Editor.js.map +1 -0
- package/lib/esm/module/Editor/lib/init-editor-provider.js +32 -0
- package/lib/esm/module/Editor/lib/init-editor-provider.js.map +1 -0
- package/lib/esm/module/Editor/lib/init-editor-state.js +18 -0
- package/lib/esm/module/Editor/lib/init-editor-state.js.map +1 -0
- package/lib/esm/module/Editor/lib/init-editor.js +27 -0
- package/lib/esm/module/Editor/lib/init-editor.js.map +1 -0
- package/lib/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +29 -0
- package/lib/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js.map +1 -0
- package/lib/index.d.ts +137 -0
- package/package.json +30 -23
- package/lib/cjs/editor-qKPDa91b.js +0 -2
- package/lib/cjs/editor-qKPDa91b.js.map +0 -1
- package/lib/cjs/markdown_plugin-IXFRDWyN.js +0 -2
- package/lib/cjs/markdown_plugin-IXFRDWyN.js.map +0 -1
- package/lib/cjs/vendor_vim-BHa51_r7.js +0 -2
- package/lib/cjs/vendor_vim-BHa51_r7.js.map +0 -1
- package/lib/cjs/vendor_y.next-CVyX1ZQB.js +0 -2
- package/lib/cjs/vendor_y.next-CVyX1ZQB.js.map +0 -1
- package/lib/cjs/vendor_y.websocket-Dr9ojjFR.js +0 -2
- package/lib/cjs/vendor_y.websocket-Dr9ojjFR.js.map +0 -1
- package/lib/cjs/vendor_yjs-DXWp84x5.js +0 -2
- package/lib/cjs/vendor_yjs-DXWp84x5.js.map +0 -1
- package/lib/esm/editor-CLyV23xt.js +0 -2
- package/lib/esm/editor-CLyV23xt.js.map +0 -1
- package/lib/esm/markdown_plugin-DdBeaig8.js +0 -2
- package/lib/esm/markdown_plugin-DdBeaig8.js.map +0 -1
- package/lib/esm/vendor_vim-PF2jWG0J.js +0 -2
- package/lib/esm/vendor_vim-PF2jWG0J.js.map +0 -1
- package/lib/esm/vendor_y.next-B9hhKe5T.js +0 -2
- package/lib/esm/vendor_y.next-B9hhKe5T.js.map +0 -1
- package/lib/esm/vendor_y.websocket-gIpX3Cmo.js +0 -2
- package/lib/esm/vendor_y.websocket-gIpX3Cmo.js.map +0 -1
- package/lib/esm/vendor_yjs-otxZW90b.js +0 -2
- package/lib/esm/vendor_yjs-otxZW90b.js.map +0 -1
- package/tmp/app/helpers/common-test.d.ts +0 -1
- package/tmp/app/helpers/full-example.d.ts +0 -1
- package/tmp/app/helpers/index.d.ts +0 -5
- package/tmp/app/helpers/random-color.d.ts +0 -1
- package/tmp/app/helpers/random-string.d.ts +0 -1
- package/tmp/app/helpers/stress-test.d.ts +0 -1
- package/tmp/app/index.d.ts +0 -1
- package/tmp/extensions/compartments/index.d.ts +0 -4
- package/tmp/extensions/index.d.ts +0 -8
- package/tmp/extensions/init-extensions.d.ts +0 -14
- package/tmp/extensions/keymaps/bold-keymap.d.ts +0 -2
- package/tmp/extensions/keymaps/index.d.ts +0 -1
- package/tmp/extensions/keymaps/init-key-map.d.ts +0 -23
- package/tmp/extensions/keymaps/italic-key-map.d.ts +0 -2
- package/tmp/extensions/keymaps/line-through-key-map.d.ts +0 -2
- package/tmp/extensions/keymaps/underline-key-map.d.ts +0 -2
- package/tmp/extensions/listeners/get-change-event.d.ts +0 -6
- package/tmp/extensions/listeners/get-focus-event.d.ts +0 -8
- package/tmp/extensions/listeners/index.d.ts +0 -3
- package/tmp/extensions/listeners/init-listeners.d.ts +0 -4
- package/tmp/extensions/markdown/blockquote/blockquote-constants.d.ts +0 -3
- package/tmp/extensions/markdown/blockquote/blockquote-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/blockquote/blockquote-widget.d.ts +0 -6
- package/tmp/extensions/markdown/blockquote/index.d.ts +0 -1
- package/tmp/extensions/markdown/bold/bold-constants.d.ts +0 -2
- package/tmp/extensions/markdown/bold/bold-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/bold/index.d.ts +0 -1
- package/tmp/extensions/markdown/code/code-constants.d.ts +0 -3
- package/tmp/extensions/markdown/code/code-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/code/code-widget.d.ts +0 -13
- package/tmp/extensions/markdown/code/index.d.ts +0 -1
- package/tmp/extensions/markdown/header/header-constants.d.ts +0 -3
- package/tmp/extensions/markdown/header/header-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/header/index.d.ts +0 -1
- package/tmp/extensions/markdown/horizontal/horizontal-constants.d.ts +0 -1
- package/tmp/extensions/markdown/horizontal/horizontal-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/horizontal/index.d.ts +0 -1
- package/tmp/extensions/markdown/image/image-constants.d.ts +0 -5
- package/tmp/extensions/markdown/image/image-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/image/image-widget.d.ts +0 -14
- package/tmp/extensions/markdown/image/index.d.ts +0 -1
- package/tmp/extensions/markdown/index.d.ts +0 -2
- package/tmp/extensions/markdown/init-markdown.d.ts +0 -3
- package/tmp/extensions/markdown/italic/index.d.ts +0 -1
- package/tmp/extensions/markdown/italic/italic-constants.d.ts +0 -2
- package/tmp/extensions/markdown/italic/italic-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/link/auto-link-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/link/index.d.ts +0 -2
- package/tmp/extensions/markdown/link/link-constants.d.ts +0 -7
- package/tmp/extensions/markdown/link/link-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/link/link-label-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/link/link-widget.d.ts +0 -17
- package/tmp/extensions/markdown/list/index.d.ts +0 -1
- package/tmp/extensions/markdown/list/list-constants.d.ts +0 -4
- package/tmp/extensions/markdown/list/list-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/list/list-widget.d.ts +0 -7
- package/tmp/extensions/markdown/markdown-decoration.d.ts +0 -5
- package/tmp/extensions/markdown/markdown-parser.d.ts +0 -2
- package/tmp/extensions/markdown/markdown-types.d.ts +0 -24
- package/tmp/extensions/markdown/mention/index.d.ts +0 -1
- package/tmp/extensions/markdown/mention/mention-constants.d.ts +0 -3
- package/tmp/extensions/markdown/mention/mention-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/mention/mention-parser.d.ts +0 -2
- package/tmp/extensions/markdown/strike-through/index.d.ts +0 -1
- package/tmp/extensions/markdown/strike-through/strike-through-constants.d.ts +0 -1
- package/tmp/extensions/markdown/strike-through/strike-through-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/todo/index.d.ts +0 -1
- package/tmp/extensions/markdown/todo/todo-constants.d.ts +0 -3
- package/tmp/extensions/markdown/todo/todo-decoration.d.ts +0 -2
- package/tmp/extensions/markdown/todo/todo-widget.d.ts +0 -11
- package/tmp/extensions/settings/index.d.ts +0 -1
- package/tmp/extensions/settings/init-settings.d.ts +0 -6
- package/tmp/extensions/theme/index.d.ts +0 -4
- package/tmp/extensions/theme/init-theme.d.ts +0 -3
- package/tmp/extensions/theme/theme-constants.d.ts +0 -14
- package/tmp/extensions/theme/theme-types.d.ts +0 -39
- package/tmp/extensions/theme/themes/get-dark-theme.d.ts +0 -2
- package/tmp/extensions/theme/themes/get-highlight-template.d.ts +0 -6
- package/tmp/extensions/theme/themes/get-light-theme.d.ts +0 -2
- package/tmp/extensions/theme/themes/get-theme-template.d.ts +0 -2
- package/tmp/extensions/theme/themes/index.d.ts +0 -2
- package/tmp/index.d.ts +0 -3
- package/tmp/lib/index.d.ts +0 -1
- package/tmp/lib/utils/copy-to-clipboard.d.ts +0 -1
- package/tmp/lib/utils/get-decoration.d.ts +0 -26
- package/tmp/lib/utils/index.d.ts +0 -6
- package/tmp/lib/utils/is-in-range.d.ts +0 -2
- package/tmp/lib/utils/is-range-overlap.d.ts +0 -1
- package/tmp/lib/utils/random-string.d.ts +0 -1
- package/tmp/lib/utils/tick.d.ts +0 -10
- package/tmp/module/Editor/Editor.d.ts +0 -18
- package/tmp/module/Editor/Editor.types.d.ts +0 -13
- package/tmp/module/Editor/index.d.ts +0 -3
- package/tmp/module/Editor/lib/index.d.ts +0 -1
- package/tmp/module/Editor/lib/init-editor-provider.d.ts +0 -9
- package/tmp/module/Editor/lib/init-editor-state.d.ts +0 -7
- package/tmp/module/Editor/lib/init-editor.d.ts +0 -7
- package/tmp/module/index.d.ts +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{C as e,D as t,U as o,E as n,F as s,G as r,A as a,H as i,I as c,J as l,K as h}from"./vendor_yjs-otxZW90b.js";import{g as d,H as u,V as f,G as m,d as p,ah as g,D as y,W as b}from"./editor-CLyV23xt.js";class S{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:e(this.yanchor),yhead:e(this.yhead)}}static fromJSON(e){return new S(t(e.yanchor),t(e.yhead))}}class x{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new o(e)}toYPos(e,t=0){return n(this.ytext,e,t)}fromYPos(e){const o=s(t(e),this.ytext.doc);if(null==o||o.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:o.index,assoc:o.assoc}}toYRange(e){const t=e.assoc,o=this.toYPos(e.anchor,t),n=this.toYPos(e.head,t);return new S(o,n)}fromYRange(e){const t=this.fromYPos(e.yanchor),o=this.fromYPos(e.yhead);return t.pos===o.pos?d.cursor(o.pos,o.assoc):d.range(t.pos,o.pos)}}const v=u.define({combine:e=>e[e.length-1]}),w=m.define();const k=f.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(v),this._observer=(t,o)=>{if(o.origin!==this.conf){const o=t.delta,n=[];let s=0;for(let e=0;e<o.length;e++){const t=o[e];null!=t.insert?n.push({from:s,to:s,insert:t.insert}):null!=t.delete?(n.push({from:s,to:s+t.delete,insert:""}),s+=t.delete):s+=t.retain}e.dispatch({changes:n,annotations:[w.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(w)===this.conf)return;const t=this.conf.ytext;t.doc.transact((()=>{let o=0;e.changes.iterChanges(((e,n,s,r,a)=>{const i=a.sliceString(0,a.length,"\n");e!==n&&t.delete(e+o,n-e),i.length>0&&t.insert(e+o,i),o+=i.length-(n-e)}))}),this.conf)}destroy(){this._ytext.unobserve(this._observer)}}),_=p.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),C=m.define();class M extends b{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return c("span",[h("class","cm-ySelectionCaret"),h("style",`background-color: ${this.color}; border-color: ${this.color}`)],[l(""),c("div",[h("class","cm-ySelectionCaretDot")]),l(""),c("div",[h("class","cm-ySelectionInfo")],[l(this.name)]),l("")])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}const I=f.fromClass(class{constructor(e){this.conf=e.state.facet(v),this._listener=({added:t,updated:o,removed:n},s,r)=>{t.concat(o).concat(n).findIndex((e=>e!==this.conf.awareness.doc.clientID))>=0&&e.dispatch({annotations:[C.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=g.of([])}destroy(){this._awareness.off("change",this._listener)}update(e){const o=this.conf.ytext,c=o.doc,l=this.conf.awareness,h=[],d=this.conf.awareness.getLocalState();if(null!=d){const s=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),a=s?e.state.selection.main:null,i=null==d.cursor?null:t(d.cursor.anchor),c=null==d.cursor?null:t(d.cursor.head);if(null!=a){const e=n(o,a.anchor),t=n(o,a.head);null!=d.cursor&&r(i,e)&&r(c,t)||l.setLocalStateField("cursor",{anchor:e,head:t})}else null!=d.cursor&&s&&l.setLocalStateField("cursor",null)}l.getStates().forEach(((t,n)=>{if(n===l.doc.clientID)return;const r=t.cursor;if(null==r||null==r.anchor||null==r.head)return;const d=s(r.anchor,c),u=s(r.head,c);if(null==d||null==u||d.type!==o||u.type!==o)return;const{color:f="#30bced",name:m="Anonymous"}=t.user||{},p=t.user&&t.user.colorLight||f+"33",g=a(d.index,u.index),b=i(d.index,u.index),S=e.view.state.doc.lineAt(g),x=e.view.state.doc.lineAt(b);if(S.number===x.number)h.push({from:g,to:b,value:y.mark({attributes:{style:`background-color: ${p}`},class:"cm-ySelection"})});else{h.push({from:g,to:S.from+S.length,value:y.mark({attributes:{style:`background-color: ${p}`},class:"cm-ySelection"})}),h.push({from:x.from,to:b,value:y.mark({attributes:{style:`background-color: ${p}`},class:"cm-ySelection"})});for(let t=S.number+1;t<x.number;t++){const o=e.view.state.doc.line(t).from;h.push({from:o,to:o,value:y.line({attributes:{style:`background-color: ${p}`,class:"cm-yLineSelection"}})})}}h.push({from:u.index,to:u.index,value:y.widget({side:u.index-d.index>0?-1:1,block:!1,widget:new M(f,m)})})})),this.decorations=y.set(h,!0)}},{decorations:e=>e.decorations});class D{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return null!=this.undoManager.undo()}redo(){return null!=this.undoManager.redo()}}const O=u.define({combine:e=>e[e.length-1]});const T=f.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(O),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(v),this._beforeChangeSelection=null,this._mux=(()=>{let e=!0;return(t,o)=>{if(e){e=!1;try{t()}finally{e=!0}}else void 0!==o&&o()}})(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{const o=t.meta.get(this);if(o){const t=this.syncConf.fromYRange(o);e.dispatch(e.state.update({selection:t,effects:[p.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){!e.selectionSet||0!==e.transactions.length&&e.transactions[0].annotation(w)===this.syncConf||this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}),P=({state:e,dispatch:t})=>e.facet(O).undo()||!0,Y=({state:e,dispatch:t})=>e.facet(O).redo()||!0,L=[{key:"Mod-z",run:P,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Y,preventDefault:!0},{key:"Mod-Shift-z",run:Y,preventDefault:!0}],R=(e,t,{undoManager:n=new o(e)}={})=>{const s=new x(e,t),r=[v.of(s),k];return t&&r.push(_,I),!1!==n&&r.push(O.of(new D(n)),T,p.domEventHandlers({beforeinput:(e,t)=>"historyUndo"===e.inputType?P(t):"historyRedo"===e.inputType&&Y(t)})),r};export{S as YRange,x as YSyncConfig,R as yCollab,I as yRemoteSelections,_ as yRemoteSelectionsTheme,k as ySync,v as ySyncFacet,L as yUndoManagerKeymap};
|
|
2
|
-
//# sourceMappingURL=vendor_y.next-B9hhKe5T.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vendor_y.next-B9hhKe5T.js","sources":["../../node_modules/.pnpm/y-codemirror.next@0.3.5_@codemirror+state@6.5.0_@codemirror+view@6.35.3_yjs@13.6.20/node_modules/y-codemirror.next/src/y-range.js","../../node_modules/.pnpm/y-codemirror.next@0.3.5_@codemirror+state@6.5.0_@codemirror+view@6.35.3_yjs@13.6.20/node_modules/y-codemirror.next/src/y-sync.js","../../node_modules/.pnpm/y-codemirror.next@0.3.5_@codemirror+state@6.5.0_@codemirror+view@6.35.3_yjs@13.6.20/node_modules/y-codemirror.next/src/y-remote-selections.js","../../node_modules/.pnpm/y-codemirror.next@0.3.5_@codemirror+state@6.5.0_@codemirror+view@6.35.3_yjs@13.6.20/node_modules/y-codemirror.next/src/y-undomanager.js","../../node_modules/.pnpm/lib0@0.2.99/node_modules/lib0/mutex.js","../../node_modules/.pnpm/y-codemirror.next@0.3.5_@codemirror+state@6.5.0_@codemirror+view@6.35.3_yjs@13.6.20/node_modules/y-codemirror.next/src/index.js"],"sourcesContent":["import * as Y from 'yjs'\n\n/**\n * Defines a range on text using relative positions that can be transformed back to\n * absolute positions. (https://docs.yjs.dev/api/relative-positions)\n */\nexport class YRange {\n /**\n * @param {Y.RelativePosition} yanchor\n * @param {Y.RelativePosition} yhead\n */\n constructor (yanchor, yhead) {\n this.yanchor = yanchor\n this.yhead = yhead\n }\n\n /**\n * @returns {any}\n */\n toJSON () {\n return {\n yanchor: Y.relativePositionToJSON(this.yanchor),\n yhead: Y.relativePositionToJSON(this.yhead)\n }\n }\n\n /**\n * @param {any} json\n * @return {YRange}\n */\n static fromJSON (json) {\n return new YRange(Y.createRelativePositionFromJSON(json.yanchor), Y.createRelativePositionFromJSON(json.yhead))\n }\n}\n","\nimport * as Y from 'yjs'\nimport * as cmState from '@codemirror/state' // eslint-disable-line\nimport * as cmView from '@codemirror/view' // eslint-disable-line\nimport { YRange } from './y-range.js'\n\nexport class YSyncConfig {\n constructor (ytext, awareness) {\n this.ytext = ytext\n this.awareness = awareness\n this.undoManager = new Y.UndoManager(ytext)\n }\n\n /**\n * Helper function to transform an absolute index position to a Yjs-based relative position\n * (https://docs.yjs.dev/api/relative-positions).\n *\n * A relative position can be transformed back to an absolute position even after the document has changed. The position is\n * automatically adapted. This does not require any position transformations. Relative positions are computed based on\n * the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always\n * synced up when using relatve positions.\n *\n * ```js\n * import { ySyncFacet } from 'y-codemirror'\n *\n * ..\n * const ysync = view.state.facet(ySyncFacet)\n * // transform an absolute index position to a ypos\n * const ypos = ysync.getYPos(3)\n * // transform the ypos back to an absolute position\n * ysync.fromYPos(ypos) // => 3\n * ```\n *\n * It cannot be guaranteed that absolute index positions can be synced up between peers.\n * This might lead to undesired behavior when implementing features that require that all peers see the\n * same marked range (e.g. a comment plugin).\n *\n * @param {number} pos\n * @param {number} [assoc]\n */\n toYPos (pos, assoc = 0) {\n return Y.createRelativePositionFromTypeIndex(this.ytext, pos, assoc)\n }\n\n /**\n * @param {Y.RelativePosition | Object} rpos\n */\n fromYPos (rpos) {\n const pos = Y.createAbsolutePositionFromRelativePosition(Y.createRelativePositionFromJSON(rpos), this.ytext.doc)\n if (pos == null || pos.type !== this.ytext) {\n throw new Error('[y-codemirror] The position you want to retrieve was created by a different document')\n }\n return {\n pos: pos.index,\n assoc: pos.assoc\n }\n }\n\n /**\n * @param {cmState.SelectionRange} range\n * @return {YRange}\n */\n toYRange (range) {\n const assoc = range.assoc\n const yanchor = this.toYPos(range.anchor, assoc)\n const yhead = this.toYPos(range.head, assoc)\n return new YRange(yanchor, yhead)\n }\n\n /**\n * @param {YRange} yrange\n */\n fromYRange (yrange) {\n const anchor = this.fromYPos(yrange.yanchor)\n const head = this.fromYPos(yrange.yhead)\n if (anchor.pos === head.pos) {\n return cmState.EditorSelection.cursor(head.pos, head.assoc)\n }\n return cmState.EditorSelection.range(anchor.pos, head.pos)\n }\n}\n\n/**\n * @type {cmState.Facet<YSyncConfig, YSyncConfig>}\n */\nexport const ySyncFacet = cmState.Facet.define({\n combine (inputs) {\n return inputs[inputs.length - 1]\n }\n})\n\n/**\n * @type {cmState.AnnotationType<YSyncConfig>}\n */\nexport const ySyncAnnotation = cmState.Annotation.define()\n\n/**\n * @extends {PluginValue}\n */\nclass YSyncPluginValue {\n /**\n * @param {cmView.EditorView} view\n */\n constructor (view) {\n this.view = view\n this.conf = view.state.facet(ySyncFacet)\n this._observer = (event, tr) => {\n if (tr.origin !== this.conf) {\n const delta = event.delta\n const changes = []\n let pos = 0\n for (let i = 0; i < delta.length; i++) {\n const d = delta[i]\n if (d.insert != null) {\n changes.push({ from: pos, to: pos, insert: d.insert })\n } else if (d.delete != null) {\n changes.push({ from: pos, to: pos + d.delete, insert: '' })\n pos += d.delete\n } else {\n pos += d.retain\n }\n }\n view.dispatch({ changes, annotations: [ySyncAnnotation.of(this.conf)] })\n }\n }\n this._ytext = this.conf.ytext\n this._ytext.observe(this._observer)\n }\n\n /**\n * @param {cmView.ViewUpdate} update\n */\n update (update) {\n if (!update.docChanged || (update.transactions.length > 0 && update.transactions[0].annotation(ySyncAnnotation) === this.conf)) {\n return\n }\n const ytext = this.conf.ytext\n ytext.doc.transact(() => {\n /**\n * This variable adjusts the fromA position to the current position in the Y.Text type.\n */\n let adj = 0\n update.changes.iterChanges((fromA, toA, fromB, toB, insert) => {\n const insertText = insert.sliceString(0, insert.length, '\\n')\n if (fromA !== toA) {\n ytext.delete(fromA + adj, toA - fromA)\n }\n if (insertText.length > 0) {\n ytext.insert(fromA + adj, insertText)\n }\n adj += insertText.length - (toA - fromA)\n })\n }, this.conf)\n }\n\n destroy () {\n this._ytext.unobserve(this._observer)\n }\n}\n\nexport const ySync = cmView.ViewPlugin.fromClass(YSyncPluginValue)\n","\nimport * as cmView from '@codemirror/view'\n\nimport * as cmState from '@codemirror/state'\nimport * as dom from 'lib0/dom'\nimport * as pair from 'lib0/pair'\nimport * as math from 'lib0/math'\n\nimport * as Y from 'yjs'\nimport { ySyncFacet } from './y-sync.js'\n\nexport const yRemoteSelectionsTheme = cmView.EditorView.baseTheme({\n '.cm-ySelection': {\n },\n '.cm-yLineSelection': {\n padding: 0,\n margin: '0px 2px 0px 4px'\n },\n '.cm-ySelectionCaret': {\n position: 'relative',\n borderLeft: '1px solid black',\n borderRight: '1px solid black',\n marginLeft: '-1px',\n marginRight: '-1px',\n boxSizing: 'border-box',\n display: 'inline'\n },\n '.cm-ySelectionCaretDot': {\n borderRadius: '50%',\n position: 'absolute',\n width: '.4em',\n height: '.4em',\n top: '-.2em',\n left: '-.2em',\n backgroundColor: 'inherit',\n transition: 'transform .3s ease-in-out',\n boxSizing: 'border-box'\n },\n '.cm-ySelectionCaret:hover > .cm-ySelectionCaretDot': {\n transformOrigin: 'bottom center',\n transform: 'scale(0)'\n },\n '.cm-ySelectionInfo': {\n position: 'absolute',\n top: '-1.05em',\n left: '-1px',\n fontSize: '.75em',\n fontFamily: 'serif',\n fontStyle: 'normal',\n fontWeight: 'normal',\n lineHeight: 'normal',\n userSelect: 'none',\n color: 'white',\n paddingLeft: '2px',\n paddingRight: '2px',\n zIndex: 101,\n transition: 'opacity .3s ease-in-out',\n backgroundColor: 'inherit',\n // these should be separate\n opacity: 0,\n transitionDelay: '0s',\n whiteSpace: 'nowrap'\n },\n '.cm-ySelectionCaret:hover > .cm-ySelectionInfo': {\n opacity: 1,\n transitionDelay: '0s'\n }\n})\n\n/**\n * @todo specify the users that actually changed. Currently, we recalculate positions for every user.\n * @type {cmState.AnnotationType<Array<number>>}\n */\nconst yRemoteSelectionsAnnotation = cmState.Annotation.define()\n\nclass YRemoteCaretWidget extends cmView.WidgetType {\n /**\n * @param {string} color\n * @param {string} name\n */\n constructor (color, name) {\n super()\n this.color = color\n this.name = name\n }\n\n toDOM () {\n return /** @type {HTMLElement} */ (dom.element('span', [pair.create('class', 'cm-ySelectionCaret'), pair.create('style', `background-color: ${this.color}; border-color: ${this.color}`)], [\n dom.text('\\u2060'),\n dom.element('div', [\n pair.create('class', 'cm-ySelectionCaretDot')\n ]),\n dom.text('\\u2060'),\n dom.element('div', [\n pair.create('class', 'cm-ySelectionInfo')\n ], [\n dom.text(this.name)\n ]),\n dom.text('\\u2060')\n ]))\n }\n\n eq (widget) {\n return widget.color === this.color\n }\n\n compare (widget) {\n return widget.color === this.color\n }\n\n updateDOM () {\n return false\n }\n\n get estimatedHeight () { return -1 }\n\n ignoreEvent () {\n return true\n }\n}\n\nexport class YRemoteSelectionsPluginValue {\n /**\n * @param {cmView.EditorView} view\n */\n constructor (view) {\n this.conf = view.state.facet(ySyncFacet)\n this._listener = ({ added, updated, removed }, s, t) => {\n const clients = added.concat(updated).concat(removed)\n if (clients.findIndex(id => id !== this.conf.awareness.doc.clientID) >= 0) {\n view.dispatch({ annotations: [yRemoteSelectionsAnnotation.of([])] })\n }\n }\n this._awareness = this.conf.awareness\n this._awareness.on('change', this._listener)\n /**\n * @type {cmView.DecorationSet}\n */\n this.decorations = cmState.RangeSet.of([])\n }\n\n destroy () {\n this._awareness.off('change', this._listener)\n }\n\n /**\n * @param {cmView.ViewUpdate} update\n */\n update (update) {\n const ytext = this.conf.ytext\n const ydoc = /** @type {Y.Doc} */ (ytext.doc)\n const awareness = this.conf.awareness\n /**\n * @type {Array<cmState.Range<cmView.Decoration>>}\n */\n const decorations = []\n const localAwarenessState = this.conf.awareness.getLocalState()\n\n // set local awareness state (update cursors)\n if (localAwarenessState != null) {\n const hasFocus = update.view.hasFocus && update.view.dom.ownerDocument.hasFocus()\n const sel = hasFocus ? update.state.selection.main : null\n const currentAnchor = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.anchor)\n const currentHead = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.head)\n\n if (sel != null) {\n const anchor = Y.createRelativePositionFromTypeIndex(ytext, sel.anchor)\n const head = Y.createRelativePositionFromTypeIndex(ytext, sel.head)\n if (localAwarenessState.cursor == null || !Y.compareRelativePositions(currentAnchor, anchor) || !Y.compareRelativePositions(currentHead, head)) {\n awareness.setLocalStateField('cursor', {\n anchor,\n head\n })\n }\n } else if (localAwarenessState.cursor != null && hasFocus) {\n awareness.setLocalStateField('cursor', null)\n }\n }\n\n // update decorations (remote selections)\n awareness.getStates().forEach((state, clientid) => {\n if (clientid === awareness.doc.clientID) {\n return\n }\n const cursor = state.cursor\n if (cursor == null || cursor.anchor == null || cursor.head == null) {\n return\n }\n const anchor = Y.createAbsolutePositionFromRelativePosition(cursor.anchor, ydoc)\n const head = Y.createAbsolutePositionFromRelativePosition(cursor.head, ydoc)\n if (anchor == null || head == null || anchor.type !== ytext || head.type !== ytext) {\n return\n }\n const { color = '#30bced', name = 'Anonymous' } = state.user || {}\n const colorLight = (state.user && state.user.colorLight) || color + '33'\n const start = math.min(anchor.index, head.index)\n const end = math.max(anchor.index, head.index)\n const startLine = update.view.state.doc.lineAt(start)\n const endLine = update.view.state.doc.lineAt(end)\n if (startLine.number === endLine.number) {\n // selected content in a single line.\n decorations.push({\n from: start,\n to: end,\n value: cmView.Decoration.mark({\n attributes: { style: `background-color: ${colorLight}` },\n class: 'cm-ySelection'\n })\n })\n } else {\n // selected content in multiple lines\n // first, render text-selection in the first line\n decorations.push({\n from: start,\n to: startLine.from + startLine.length,\n value: cmView.Decoration.mark({\n attributes: { style: `background-color: ${colorLight}` },\n class: 'cm-ySelection'\n })\n })\n // render text-selection in the last line\n decorations.push({\n from: endLine.from,\n to: end,\n value: cmView.Decoration.mark({\n attributes: { style: `background-color: ${colorLight}` },\n class: 'cm-ySelection'\n })\n })\n for (let i = startLine.number + 1; i < endLine.number; i++) {\n const linePos = update.view.state.doc.line(i).from\n decorations.push({\n from: linePos,\n to: linePos,\n value: cmView.Decoration.line({\n attributes: { style: `background-color: ${colorLight}`, class: 'cm-yLineSelection' }\n })\n })\n }\n }\n decorations.push({\n from: head.index,\n to: head.index,\n value: cmView.Decoration.widget({\n side: head.index - anchor.index > 0 ? -1 : 1, // the local cursor should be rendered outside the remote selection\n block: false,\n widget: new YRemoteCaretWidget(color, name)\n })\n })\n })\n this.decorations = cmView.Decoration.set(decorations, true)\n }\n}\n\nexport const yRemoteSelections = cmView.ViewPlugin.fromClass(YRemoteSelectionsPluginValue, {\n decorations: v => v.decorations\n})\n","import * as Y from 'yjs' // eslint-disable-line\nimport * as cmState from '@codemirror/state'\n\nimport * as cmView from '@codemirror/view'\nimport { ySyncFacet, ySyncAnnotation } from './y-sync.js'\nimport { YRange } from './y-range.js' // eslint-disable-line\nimport { createMutex } from 'lib0/mutex'\n\nexport class YUndoManagerConfig {\n /**\n * @param {Y.UndoManager} undoManager\n */\n constructor (undoManager) {\n this.undoManager = undoManager\n }\n\n /**\n * @param {any} origin\n */\n addTrackedOrigin (origin) {\n this.undoManager.addTrackedOrigin(origin)\n }\n\n /**\n * @param {any} origin\n */\n removeTrackedOrigin (origin) {\n this.undoManager.removeTrackedOrigin(origin)\n }\n\n /**\n * @return {boolean} Whether a change was undone.\n */\n undo () {\n return this.undoManager.undo() != null\n }\n\n /**\n * @return {boolean} Whether a change was redone.\n */\n redo () {\n return this.undoManager.redo() != null\n }\n}\n\n/**\n * @type {cmState.Facet<YUndoManagerConfig, YUndoManagerConfig>}\n */\nexport const yUndoManagerFacet = cmState.Facet.define({\n combine (inputs) {\n return inputs[inputs.length - 1]\n }\n})\n\n/**\n * @type {cmState.AnnotationType<YUndoManagerConfig>}\n */\nexport const yUndoManagerAnnotation = cmState.Annotation.define()\n\n/**\n * @extends {PluginValue}\n */\nclass YUndoManagerPluginValue {\n /**\n * @param {cmView.EditorView} view\n */\n constructor (view) {\n this.view = view\n this.conf = view.state.facet(yUndoManagerFacet)\n this._undoManager = this.conf.undoManager\n this.syncConf = view.state.facet(ySyncFacet)\n /**\n * @type {null | YRange}\n */\n this._beforeChangeSelection = null\n this._mux = createMutex()\n\n this._onStackItemAdded = ({ stackItem, changedParentTypes }) => {\n // only store metadata if this type was affected\n if (changedParentTypes.has(this.syncConf.ytext) && this._beforeChangeSelection && !stackItem.meta.has(this)) { // do not overwrite previous stored selection\n stackItem.meta.set(this, this._beforeChangeSelection)\n }\n }\n this._onStackItemPopped = ({ stackItem }) => {\n const sel = stackItem.meta.get(this)\n if (sel) {\n const selection = this.syncConf.fromYRange(sel)\n view.dispatch(view.state.update({\n selection,\n effects: [cmView.EditorView.scrollIntoView(selection)]\n }))\n this._storeSelection()\n }\n }\n /**\n * Do this without mutex, simply use the sync annotation\n */\n this._storeSelection = () => {\n // store the selection before the change is applied so we can restore it with the undo manager.\n this._beforeChangeSelection = this.syncConf.toYRange(this.view.state.selection.main)\n }\n this._undoManager.on('stack-item-added', this._onStackItemAdded)\n this._undoManager.on('stack-item-popped', this._onStackItemPopped)\n this._undoManager.addTrackedOrigin(this.syncConf)\n }\n\n /**\n * @param {cmView.ViewUpdate} update\n */\n update (update) {\n if (update.selectionSet && (update.transactions.length === 0 || update.transactions[0].annotation(ySyncAnnotation) !== this.syncConf)) {\n // This only works when YUndoManagerPlugin is included before the sync plugin\n this._storeSelection()\n }\n }\n\n destroy () {\n this._undoManager.off('stack-item-added', this._onStackItemAdded)\n this._undoManager.off('stack-item-popped', this._onStackItemPopped)\n this._undoManager.removeTrackedOrigin(this.syncConf)\n }\n}\nexport const yUndoManager = cmView.ViewPlugin.fromClass(YUndoManagerPluginValue)\n\n/**\n * @type {cmState.StateCommand}\n */\nexport const undo = ({ state, dispatch }) =>\n state.facet(yUndoManagerFacet).undo() || true\n\n/**\n * @type {cmState.StateCommand}\n */\nexport const redo = ({ state, dispatch }) =>\n state.facet(yUndoManagerFacet).redo() || true\n\n/**\n * @param {cmState.EditorState} state\n * @return {number}\n */\nexport const undoDepth = state => state.facet(yUndoManagerFacet).undoManager.undoStack.length\n\n/**\n * @param {cmState.EditorState} state\n * @return {number}\n */\nexport const redoDepth = state => state.facet(yUndoManagerFacet).undoManager.redoStack.length\n\n/**\n * Default key bindigs for the undo manager.\n * @type {Array<cmView.KeyBinding>}\n */\nexport const yUndoManagerKeymap = [\n { key: 'Mod-z', run: undo, preventDefault: true },\n { key: 'Mod-y', mac: 'Mod-Shift-z', run: redo, preventDefault: true },\n { key: 'Mod-Shift-z', run: redo, preventDefault: true }\n]\n","/**\n * Mutual exclude for JavaScript.\n *\n * @module mutex\n */\n\n/**\n * @callback mutex\n * @param {function():void} cb Only executed when this mutex is not in the current stack\n * @param {function():void} [elseCb] Executed when this mutex is in the current stack\n */\n\n/**\n * Creates a mutual exclude function with the following property:\n *\n * ```js\n * const mutex = createMutex()\n * mutex(() => {\n * // This function is immediately executed\n * mutex(() => {\n * // This function is not executed, as the mutex is already active.\n * })\n * })\n * ```\n *\n * @return {mutex} A mutual exclude function\n * @public\n */\nexport const createMutex = () => {\n let token = true\n return (f, g) => {\n if (token) {\n token = false\n try {\n f()\n } finally {\n token = true\n }\n } else if (g !== undefined) {\n g()\n }\n }\n}\n","\nimport * as Y from 'yjs' // eslint-disable-line\nimport * as cmView from '@codemirror/view'\nimport * as cmState from '@codemirror/state' // eslint-disable-line\n\nimport { YRange } from './y-range.js'\nimport { ySync, ySyncFacet, YSyncConfig } from './y-sync.js'\nimport { yRemoteSelections, yRemoteSelectionsTheme } from './y-remote-selections.js'\nimport { yUndoManager, yUndoManagerFacet, YUndoManagerConfig, undo, redo, yUndoManagerKeymap } from './y-undomanager.js'\n\nexport { YRange, yRemoteSelections, yRemoteSelectionsTheme, ySync, ySyncFacet, YSyncConfig, yUndoManagerKeymap }\n\n/**\n * @param {Y.Text} ytext\n * @param {any} awareness\n * @param {Object} [opts]\n * @param {Y.UndoManager | false} [opts.undoManager] Set undoManager to false to disable the undo-redo plugin\n * @return {cmState.Extension}\n */\nexport const yCollab = (ytext, awareness, { undoManager = new Y.UndoManager(ytext) } = {}) => {\n const ySyncConfig = new YSyncConfig(ytext, awareness)\n const plugins = [\n ySyncFacet.of(ySyncConfig),\n ySync\n ]\n if (awareness) {\n plugins.push(\n yRemoteSelectionsTheme,\n yRemoteSelections\n )\n }\n if (undoManager !== false) {\n // By default, only track changes that are produced by the sync plugin (local edits)\n plugins.push(\n yUndoManagerFacet.of(new YUndoManagerConfig(undoManager)),\n yUndoManager,\n cmView.EditorView.domEventHandlers({\n beforeinput (e, view) {\n if (e.inputType === 'historyUndo') return undo(view)\n if (e.inputType === 'historyRedo') return redo(view)\n return false\n }\n })\n )\n }\n return plugins\n}\n"],"names":["YRange","constructor","yanchor","yhead","this","toJSON","Y.relativePositionToJSON","fromJSON","json","Y.createRelativePositionFromJSON","YSyncConfig","ytext","awareness","undoManager","Y.UndoManager","toYPos","pos","assoc","Y.createRelativePositionFromTypeIndex","fromYPos","rpos","Y.createAbsolutePositionFromRelativePosition","doc","type","Error","index","toYRange","range","anchor","head","fromYRange","yrange","cmState.EditorSelection","cursor","ySyncFacet","cmState.Facet","define","combine","inputs","length","ySyncAnnotation","cmState.Annotation","ySync","cmView.ViewPlugin","fromClass","view","conf","state","facet","_observer","event","tr","origin","delta","changes","i","d","insert","push","from","to","delete","retain","dispatch","annotations","of","_ytext","observe","update","docChanged","transactions","annotation","transact","adj","iterChanges","fromA","toA","fromB","toB","insertText","sliceString","destroy","unobserve","yRemoteSelectionsTheme","cmView.EditorView","baseTheme","padding","margin","position","borderLeft","borderRight","marginLeft","marginRight","boxSizing","display","borderRadius","width","height","top","left","backgroundColor","transition","transformOrigin","transform","fontSize","fontFamily","fontStyle","fontWeight","lineHeight","userSelect","color","paddingLeft","paddingRight","zIndex","opacity","transitionDelay","whiteSpace","yRemoteSelectionsAnnotation","YRemoteCaretWidget","cmView.WidgetType","name","super","toDOM","dom.element","pair.create","dom.text","eq","widget","compare","updateDOM","estimatedHeight","ignoreEvent","yRemoteSelections","_listener","added","updated","removed","s","t","concat","findIndex","id","clientID","_awareness","on","decorations","cmState.RangeSet","off","ydoc","localAwarenessState","getLocalState","hasFocus","dom","ownerDocument","sel","selection","main","currentAnchor","currentHead","Y.compareRelativePositions","setLocalStateField","getStates","forEach","clientid","user","colorLight","start","math.min","end","math.max","startLine","lineAt","endLine","number","value","cmView.Decoration","mark","attributes","style","class","linePos","line","side","block","set","v","YUndoManagerConfig","addTrackedOrigin","removeTrackedOrigin","undo","redo","yUndoManagerFacet","yUndoManager","_undoManager","syncConf","_beforeChangeSelection","_mux","token","f","g","undefined","createMutex","_onStackItemAdded","stackItem","changedParentTypes","has","meta","_onStackItemPopped","get","effects","scrollIntoView","_storeSelection","selectionSet","yUndoManagerKeymap","key","run","preventDefault","mac","yCollab","ySyncConfig","plugins","domEventHandlers","beforeinput","e","inputType"],"mappings":"8MAMO,MAAMA,EAKX,WAAAC,CAAaC,EAASC,GACpBC,KAAKF,QAAUA,EACfE,KAAKD,MAAQA,CACd,CAKD,MAAAE,GACE,MAAO,CACLH,QAASI,EAAyBF,KAAKF,SACvCC,MAAOG,EAAyBF,KAAKD,OAExC,CAMD,eAAOI,CAAUC,GACf,OAAO,IAAIR,EAAOS,EAAiCD,EAAKN,SAAUO,EAAiCD,EAAKL,OACzG,EC1BI,MAAMO,EACX,WAAAT,CAAaU,EAAOC,GAClBR,KAAKO,MAAQA,EACbP,KAAKQ,UAAYA,EACjBR,KAAKS,YAAc,IAAIC,EAAcH,EACtC,CA6BD,MAAAI,CAAQC,EAAKC,EAAQ,GACnB,OAAOC,EAAsCd,KAAKO,MAAOK,EAAKC,EAC/D,CAKD,QAAAE,CAAUC,GACR,MAAMJ,EAAMK,EAA6CZ,EAAiCW,GAAOhB,KAAKO,MAAMW,KAC5G,GAAW,MAAPN,GAAeA,EAAIO,OAASnB,KAAKO,MACnC,MAAM,IAAIa,MAAM,wFAElB,MAAO,CACLR,IAAKA,EAAIS,MACTR,MAAOD,EAAIC,MAEd,CAMD,QAAAS,CAAUC,GACR,MAAMV,EAAQU,EAAMV,MACdf,EAAUE,KAAKW,OAAOY,EAAMC,OAAQX,GACpCd,EAAQC,KAAKW,OAAOY,EAAME,KAAMZ,GACtC,OAAO,IAAIjB,EAAOE,EAASC,EAC5B,CAKD,UAAA2B,CAAYC,GACV,MAAMH,EAASxB,KAAKe,SAASY,EAAO7B,SAC9B2B,EAAOzB,KAAKe,SAASY,EAAO5B,OAClC,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3B,gBAAhBkL,EAAEC,WAAoClC,EAAKjJ,MAMhD+K","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{s as e,c as s,f as t,o as n,v as a,t as c,a as o,b as i,w as h,e as l,d,g as r,r as u,h as p,i as m,j as g,O as w,k as f,l as b,m as y,n as v,p as I,q as _,u as S,x as k,y as C,z as U,A as L,B}from"./vendor_yjs-otxZW90b.js";const D=new Map;const x="undefined"==typeof BroadcastChannel?class{constructor(e){this.room=e,this.onmessage=null,this._onChange=s=>s.key===e&&null!==this.onmessage&&this.onmessage({data:t(s.newValue||"")}),n(this._onChange)}postMessage(e){a.setItem(this.room,c(i(e)))}close(){o(this._onChange)}}:BroadcastChannel,H=t=>e(D,t,(()=>{const e=s(),n=new x(t);return n.onmessage=s=>e.forEach((e=>e(s.data,"broadcastchannel"))),{bc:n,subs:e}})),M=(e,s,t=null)=>{const n=H(e);n.bc.postMessage(s),n.subs.forEach((e=>e(s,t)))},R=(e,s)=>{h(e,0);const t=l(s);d(e,t)},E=(e,s,t)=>{h(e,1),d(e,r(s,t))},j=(e,s,t)=>{try{m(s,p(e),t)}catch(e){console.error("Caught error while handling a Yjs update",e)}},A=j,O=(e,s,t,n)=>{const a=u(e);switch(a){case 0:((e,s,t)=>{E(s,t,p(e))})(e,s,t);break;case 1:j(e,t,n);break;case 2:A(e,t,n);break;default:throw new Error("Unknown message type")}return a},T=3e4;class W extends w{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const e=b();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach(((t,n)=>{n!==this.clientID&&T<=e-t.lastUpdated&&this.states.has(n)&&s.push(n)})),s.length>0&&N(this,s,"timeout")}),f(3e3)),e.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const s=this.clientID,t=this.meta.get(s),n=void 0===t?0:t.clock+1,a=this.states.get(s);null===e?this.states.delete(s):this.states.set(s,e),this.meta.set(s,{clock:n,lastUpdated:b()});const c=[],o=[],i=[],h=[];null===e?h.push(s):null==a?null!=e&&c.push(s):(o.push(s),y(a,e)||i.push(s)),(c.length>0||i.length>0||h.length>0)&&this.emit("change",[{added:c,updated:i,removed:h},"local"]),this.emit("update",[{added:c,updated:o,removed:h},"local"])}setLocalStateField(e,s){const t=this.getLocalState();null!==t&&this.setLocalState({...t,[e]:s})}getStates(){return this.states}}const N=(e,s,t)=>{const n=[];for(let t=0;t<s.length;t++){const a=s[t];if(e.states.has(a)){if(e.states.delete(a),a===e.clientID){const s=e.meta.get(a);e.meta.set(a,{clock:s.clock+1,lastUpdated:b()})}n.push(a)}}n.length>0&&(e.emit("change",[{added:[],updated:[],removed:n},t]),e.emit("update",[{added:[],updated:[],removed:n},t]))},P=(e,s,t=e.states)=>{const n=s.length,a=_();h(a,n);for(let c=0;c<n;c++){const n=s[c],o=t.get(n)||null,i=e.meta.get(n).clock;h(a,n),h(a,i),v(a,JSON.stringify(o))}return I(a)},$=0,z=3,J=1,q=2,F=[];F[0]=(e,s,t,n,a)=>{h(e,0);const c=O(s,e,t.doc,t);n&&1===c&&!t.synced&&(t.synced=!0)},F[3]=(e,s,t,n,a)=>{h(e,1),d(e,P(t.awareness,Array.from(t.awareness.getStates().keys())))},F[1]=(e,s,t,n,a)=>{((e,s,t)=>{const n=S(s),a=b(),c=[],o=[],i=[],h=[],l=u(n);for(let s=0;s<l;s++){const s=u(n);let t=u(n);const l=JSON.parse(g(n)),d=e.meta.get(s),r=e.states.get(s),p=void 0===d?0:d.clock;(p<t||p===t&&null===l&&e.states.has(s))&&(null===l?s===e.clientID&&null!=e.getLocalState()?t++:e.states.delete(s):e.states.set(s,l),e.meta.set(s,{clock:t,lastUpdated:a}),void 0===d&&null!==l?c.push(s):void 0!==d&&null===l?h.push(s):null!==l&&(y(l,r)||i.push(s),o.push(s)))}(c.length>0||i.length>0||h.length>0)&&e.emit("change",[{added:c,updated:i,removed:h},t]),(c.length>0||o.length>0||h.length>0)&&e.emit("update",[{added:c,updated:o,removed:h},t])})(t.awareness,p(s),t)},F[2]=(e,s,t,n,a)=>{((e,s,t)=>{0===u(e)&&t(s,g(e))})(s,t.doc,((e,s)=>V(t,s)))};const V=(e,s)=>console.warn(`Permission denied to access ${e.url}.\n${s}`),Y=(e,s,t)=>{const n=S(s),a=_(),c=u(n),o=e.messageHandlers[c];return o?o(a,n,e,t,c):console.error("Unable to compute message"),a},G=e=>{if(e.shouldConnect&&null===e.ws){const s=new e._WS(e.url,e.protocols);s.binaryType="arraybuffer",e.ws=s,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,s.onmessage=t=>{e.wsLastMessageReceived=b();const n=Y(e,new Uint8Array(t.data),!0);C(n)>1&&s.send(I(n))},s.onerror=s=>{e.emit("connection-error",[s,e])},s.onclose=s=>{e.emit("connection-close",[s,e]),e.ws=null,e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,N(e.awareness,Array.from(e.awareness.getStates().keys()).filter((s=>s!==e.doc.clientID)),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(G,L(100*B(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e)},s.onopen=()=>{e.wsLastMessageReceived=b(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const t=_();if(h(t,0),R(t,e.doc),s.send(I(t)),null!==e.awareness.getLocalState()){const t=_();h(t,1),d(t,P(e.awareness,[e.doc.clientID])),s.send(I(t))}},e.emit("status",[{status:"connecting"}])}},K=(e,s)=>{const t=e.ws;e.wsconnected&&t&&t.readyState===t.OPEN&&t.send(s),e.bcconnected&&M(e.bcChannel,s,e)};class Q extends w{constructor(e,s,t,{connect:n=!0,awareness:a=new W(t),params:c={},protocols:o=[],WebSocketPolyfill:i=WebSocket,resyncInterval:l=-1,maxBackoffTime:r=2500,disableBc:u=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+s,this.maxBackoffTime=r,this.params=c,this.protocols=o,this.roomname=s,this.doc=t,this._WS=i,this.awareness=a,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=F.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=n,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval((()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=_();h(e,0),R(e,t),this.ws.send(I(e))}}),l)),this._bcSubscriber=(e,s)=>{if(s!==this){const s=Y(this,new Uint8Array(e),!1);C(s)>1&&M(this.bcChannel,I(s),this)}},this._updateHandler=(e,s)=>{if(s!==this){const s=_();h(s,0),((e,s)=>{h(e,2),d(e,s)})(s,e),K(this,I(s))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:s,removed:t},n)=>{const c=e.concat(s).concat(t),o=_();h(o,1),d(o,P(a,c)),K(this,I(o))},this._exitHandler=()=>{N(this.awareness,[t.clientID],"app closed")},U&&"undefined"!=typeof process&&process.on("exit",this._exitHandler),a.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval((()=>{this.wsconnected&&3e4<b()-this.wsLastMessageReceived&&this.ws.close()}),3e3),n&&this.connect()}get url(){const e=(s=this.params,k(s,((e,s)=>`${encodeURIComponent(s)}=${encodeURIComponent(e)}`)).join("&"));var s;return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),U&&"undefined"!=typeof process&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;var e,s;this.bcconnected||(e=this.bcChannel,s=this._bcSubscriber,H(e).subs.add(s),this.bcconnected=!0);const t=_();h(t,0),R(t,this.doc),M(this.bcChannel,I(t),this);const n=_();h(n,0),E(n,this.doc),M(this.bcChannel,I(n),this);const a=_();h(a,3),M(this.bcChannel,I(a),this);const c=_();h(c,1),d(c,P(this.awareness,[this.doc.clientID])),M(this.bcChannel,I(c),this)}disconnectBc(){const e=_();h(e,1),d(e,P(this.awareness,[this.doc.clientID],new Map)),K(this,I(e)),this.bcconnected&&(((e,s)=>{const t=H(e),n=t.subs.delete(s);n&&0===t.subs.size&&(t.bc.close(),D.delete(e))})(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&this.ws.close()}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(G(this),this.connectBc())}}export{Q as WebsocketProvider,q as messageAuth,J as messageAwareness,z as messageQueryAwareness,$ as messageSync};
|
|
2
|
-
//# sourceMappingURL=vendor_y.websocket-gIpX3Cmo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vendor_y.websocket-gIpX3Cmo.js","sources":["../../node_modules/.pnpm/lib0@0.2.99/node_modules/lib0/broadcastchannel.js","../../node_modules/.pnpm/y-protocols@1.0.6_yjs@13.6.20/node_modules/y-protocols/sync.js","../../node_modules/.pnpm/y-protocols@1.0.6_yjs@13.6.20/node_modules/y-protocols/awareness.js","../../node_modules/.pnpm/y-websocket@2.0.4_yjs@13.6.20/node_modules/y-websocket/src/y-websocket.js","../../node_modules/.pnpm/y-protocols@1.0.6_yjs@13.6.20/node_modules/y-protocols/auth.js","../../node_modules/.pnpm/lib0@0.2.99/node_modules/lib0/url.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.\n *\n * ```js\n * // In browser window A:\n * broadcastchannel.subscribe('my events', data => console.log(data))\n * broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab\n *\n * // In browser window B:\n * broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'\n * ```\n *\n * @module broadcastchannel\n */\n\n// @todo before next major: use Uint8Array instead as buffer object\n\nimport * as map from './map.js'\nimport * as set from './set.js'\nimport * as buffer from './buffer.js'\nimport * as storage from './storage.js'\n\n/**\n * @typedef {Object} Channel\n * @property {Set<function(any, any):any>} Channel.subs\n * @property {any} Channel.bc\n */\n\n/**\n * @type {Map<string, Channel>}\n */\nconst channels = new Map()\n\n/* c8 ignore start */\nclass LocalStoragePolyfill {\n /**\n * @param {string} room\n */\n constructor (room) {\n this.room = room\n /**\n * @type {null|function({data:ArrayBuffer}):void}\n */\n this.onmessage = null\n /**\n * @param {any} e\n */\n this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') })\n storage.onChange(this._onChange)\n }\n\n /**\n * @param {ArrayBuffer} buf\n */\n postMessage (buf) {\n storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))\n }\n\n close () {\n storage.offChange(this._onChange)\n }\n}\n/* c8 ignore stop */\n\n// Use BroadcastChannel or Polyfill\n/* c8 ignore next */\nconst BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel\n\n/**\n * @param {string} room\n * @return {Channel}\n */\nconst getChannel = room =>\n map.setIfUndefined(channels, room, () => {\n const subs = set.create()\n const bc = new BC(room)\n /**\n * @param {{data:ArrayBuffer}} e\n */\n /* c8 ignore next */\n bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'))\n return {\n bc, subs\n }\n })\n\n/**\n * Subscribe to global `publish` events.\n *\n * @function\n * @param {string} room\n * @param {function(any, any):any} f\n */\nexport const subscribe = (room, f) => {\n getChannel(room).subs.add(f)\n return f\n}\n\n/**\n * Unsubscribe from `publish` global events.\n *\n * @function\n * @param {string} room\n * @param {function(any, any):any} f\n */\nexport const unsubscribe = (room, f) => {\n const channel = getChannel(room)\n const unsubscribed = channel.subs.delete(f)\n if (unsubscribed && channel.subs.size === 0) {\n channel.bc.close()\n channels.delete(room)\n }\n return unsubscribed\n}\n\n/**\n * Publish data to all subscribers (including subscribers on this tab)\n *\n * @function\n * @param {string} room\n * @param {any} data\n * @param {any} [origin]\n */\nexport const publish = (room, data, origin = null) => {\n const c = getChannel(room)\n c.bc.postMessage(data)\n c.subs.forEach(sub => sub(data, origin))\n}\n","/**\n * @module sync-protocol\n */\n\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\nimport * as Y from 'yjs'\n\n/**\n * @typedef {Map<number, number>} StateMap\n */\n\n/**\n * Core Yjs defines two message types:\n * • YjsSyncStep1: Includes the State Set of the sending client. When received, the client should reply with YjsSyncStep2.\n * • YjsSyncStep2: Includes all missing structs and the complete delete set. When received, the client is assured that it\n * received all information from the remote client.\n *\n * In a peer-to-peer network, you may want to introduce a SyncDone message type. Both parties should initiate the connection\n * with SyncStep1. When a client received SyncStep2, it should reply with SyncDone. When the local client received both\n * SyncStep2 and SyncDone, it is assured that it is synced to the remote client.\n *\n * In a client-server model, you want to handle this differently: The client should initiate the connection with SyncStep1.\n * When the server receives SyncStep1, it should reply with SyncStep2 immediately followed by SyncStep1. The client replies\n * with SyncStep2 when it receives SyncStep1. Optionally the server may send a SyncDone after it received SyncStep2, so the\n * client knows that the sync is finished. There are two reasons for this more elaborated sync model: 1. This protocol can\n * easily be implemented on top of http and websockets. 2. The server should only reply to requests, and not initiate them.\n * Therefore it is necessary that the client initiates the sync.\n *\n * Construction of a message:\n * [messageType : varUint, message definition..]\n *\n * Note: A message does not include information about the room name. This must to be handled by the upper layer protocol!\n *\n * stringify[messageType] stringifies a message definition (messageType is already read from the bufffer)\n */\n\nexport const messageYjsSyncStep1 = 0\nexport const messageYjsSyncStep2 = 1\nexport const messageYjsUpdate = 2\n\n/**\n * Create a sync step 1 message based on the state of the current shared document.\n *\n * @param {encoding.Encoder} encoder\n * @param {Y.Doc} doc\n */\nexport const writeSyncStep1 = (encoder, doc) => {\n encoding.writeVarUint(encoder, messageYjsSyncStep1)\n const sv = Y.encodeStateVector(doc)\n encoding.writeVarUint8Array(encoder, sv)\n}\n\n/**\n * @param {encoding.Encoder} encoder\n * @param {Y.Doc} doc\n * @param {Uint8Array} [encodedStateVector]\n */\nexport const writeSyncStep2 = (encoder, doc, encodedStateVector) => {\n encoding.writeVarUint(encoder, messageYjsSyncStep2)\n encoding.writeVarUint8Array(encoder, Y.encodeStateAsUpdate(doc, encodedStateVector))\n}\n\n/**\n * Read SyncStep1 message and reply with SyncStep2.\n *\n * @param {decoding.Decoder} decoder The reply to the received message\n * @param {encoding.Encoder} encoder The received message\n * @param {Y.Doc} doc\n */\nexport const readSyncStep1 = (decoder, encoder, doc) =>\n writeSyncStep2(encoder, doc, decoding.readVarUint8Array(decoder))\n\n/**\n * Read and apply Structs and then DeleteStore to a y instance.\n *\n * @param {decoding.Decoder} decoder\n * @param {Y.Doc} doc\n * @param {any} transactionOrigin\n */\nexport const readSyncStep2 = (decoder, doc, transactionOrigin) => {\n try {\n Y.applyUpdate(doc, decoding.readVarUint8Array(decoder), transactionOrigin)\n } catch (error) {\n // This catches errors that are thrown by event handlers\n console.error('Caught error while handling a Yjs update', error)\n }\n}\n\n/**\n * @param {encoding.Encoder} encoder\n * @param {Uint8Array} update\n */\nexport const writeUpdate = (encoder, update) => {\n encoding.writeVarUint(encoder, messageYjsUpdate)\n encoding.writeVarUint8Array(encoder, update)\n}\n\n/**\n * Read and apply Structs and then DeleteStore to a y instance.\n *\n * @param {decoding.Decoder} decoder\n * @param {Y.Doc} doc\n * @param {any} transactionOrigin\n */\nexport const readUpdate = readSyncStep2\n\n/**\n * @param {decoding.Decoder} decoder A message received from another client\n * @param {encoding.Encoder} encoder The reply message. Does not need to be sent if empty.\n * @param {Y.Doc} doc\n * @param {any} transactionOrigin\n */\nexport const readSyncMessage = (decoder, encoder, doc, transactionOrigin) => {\n const messageType = decoding.readVarUint(decoder)\n switch (messageType) {\n case messageYjsSyncStep1:\n readSyncStep1(decoder, encoder, doc)\n break\n case messageYjsSyncStep2:\n readSyncStep2(decoder, doc, transactionOrigin)\n break\n case messageYjsUpdate:\n readUpdate(decoder, doc, transactionOrigin)\n break\n default:\n throw new Error('Unknown message type')\n }\n return messageType\n}\n","/**\n * @module awareness-protocol\n */\n\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\nimport * as time from 'lib0/time'\nimport * as math from 'lib0/math'\nimport { Observable } from 'lib0/observable'\nimport * as f from 'lib0/function'\nimport * as Y from 'yjs' // eslint-disable-line\n\nexport const outdatedTimeout = 30000\n\n/**\n * @typedef {Object} MetaClientState\n * @property {number} MetaClientState.clock\n * @property {number} MetaClientState.lastUpdated unix timestamp\n */\n\n/**\n * The Awareness class implements a simple shared state protocol that can be used for non-persistent data like awareness information\n * (cursor, username, status, ..). Each client can update its own local state and listen to state changes of\n * remote clients. Every client may set a state of a remote peer to `null` to mark the client as offline.\n *\n * Each client is identified by a unique client id (something we borrow from `doc.clientID`). A client can override\n * its own state by propagating a message with an increasing timestamp (`clock`). If such a message is received, it is\n * applied if the known state of that client is older than the new state (`clock < newClock`). If a client thinks that\n * a remote client is offline, it may propagate a message with\n * `{ clock: currentClientClock, state: null, client: remoteClient }`. If such a\n * message is received, and the known clock of that client equals the received clock, it will override the state with `null`.\n *\n * Before a client disconnects, it should propagate a `null` state with an updated clock.\n *\n * Awareness states must be updated every 30 seconds. Otherwise the Awareness instance will delete the client state.\n *\n * @extends {Observable<string>}\n */\nexport class Awareness extends Observable {\n /**\n * @param {Y.Doc} doc\n */\n constructor (doc) {\n super()\n this.doc = doc\n /**\n * @type {number}\n */\n this.clientID = doc.clientID\n /**\n * Maps from client id to client state\n * @type {Map<number, Object<string, any>>}\n */\n this.states = new Map()\n /**\n * @type {Map<number, MetaClientState>}\n */\n this.meta = new Map()\n this._checkInterval = /** @type {any} */ (setInterval(() => {\n const now = time.getUnixTime()\n if (this.getLocalState() !== null && (outdatedTimeout / 2 <= now - /** @type {{lastUpdated:number}} */ (this.meta.get(this.clientID)).lastUpdated)) {\n // renew local clock\n this.setLocalState(this.getLocalState())\n }\n /**\n * @type {Array<number>}\n */\n const remove = []\n this.meta.forEach((meta, clientid) => {\n if (clientid !== this.clientID && outdatedTimeout <= now - meta.lastUpdated && this.states.has(clientid)) {\n remove.push(clientid)\n }\n })\n if (remove.length > 0) {\n removeAwarenessStates(this, remove, 'timeout')\n }\n }, math.floor(outdatedTimeout / 10)))\n doc.on('destroy', () => {\n this.destroy()\n })\n this.setLocalState({})\n }\n\n destroy () {\n this.emit('destroy', [this])\n this.setLocalState(null)\n super.destroy()\n clearInterval(this._checkInterval)\n }\n\n /**\n * @return {Object<string,any>|null}\n */\n getLocalState () {\n return this.states.get(this.clientID) || null\n }\n\n /**\n * @param {Object<string,any>|null} state\n */\n setLocalState (state) {\n const clientID = this.clientID\n const currLocalMeta = this.meta.get(clientID)\n const clock = currLocalMeta === undefined ? 0 : currLocalMeta.clock + 1\n const prevState = this.states.get(clientID)\n if (state === null) {\n this.states.delete(clientID)\n } else {\n this.states.set(clientID, state)\n }\n this.meta.set(clientID, {\n clock,\n lastUpdated: time.getUnixTime()\n })\n const added = []\n const updated = []\n const filteredUpdated = []\n const removed = []\n if (state === null) {\n removed.push(clientID)\n } else if (prevState == null) {\n if (state != null) {\n added.push(clientID)\n }\n } else {\n updated.push(clientID)\n if (!f.equalityDeep(prevState, state)) {\n filteredUpdated.push(clientID)\n }\n }\n if (added.length > 0 || filteredUpdated.length > 0 || removed.length > 0) {\n this.emit('change', [{ added, updated: filteredUpdated, removed }, 'local'])\n }\n this.emit('update', [{ added, updated, removed }, 'local'])\n }\n\n /**\n * @param {string} field\n * @param {any} value\n */\n setLocalStateField (field, value) {\n const state = this.getLocalState()\n if (state !== null) {\n this.setLocalState({\n ...state,\n [field]: value\n })\n }\n }\n\n /**\n * @return {Map<number,Object<string,any>>}\n */\n getStates () {\n return this.states\n }\n}\n\n/**\n * Mark (remote) clients as inactive and remove them from the list of active peers.\n * This change will be propagated to remote clients.\n *\n * @param {Awareness} awareness\n * @param {Array<number>} clients\n * @param {any} origin\n */\nexport const removeAwarenessStates = (awareness, clients, origin) => {\n const removed = []\n for (let i = 0; i < clients.length; i++) {\n const clientID = clients[i]\n if (awareness.states.has(clientID)) {\n awareness.states.delete(clientID)\n if (clientID === awareness.clientID) {\n const curMeta = /** @type {MetaClientState} */ (awareness.meta.get(clientID))\n awareness.meta.set(clientID, {\n clock: curMeta.clock + 1,\n lastUpdated: time.getUnixTime()\n })\n }\n removed.push(clientID)\n }\n }\n if (removed.length > 0) {\n awareness.emit('change', [{ added: [], updated: [], removed }, origin])\n awareness.emit('update', [{ added: [], updated: [], removed }, origin])\n }\n}\n\n/**\n * @param {Awareness} awareness\n * @param {Array<number>} clients\n * @return {Uint8Array}\n */\nexport const encodeAwarenessUpdate = (awareness, clients, states = awareness.states) => {\n const len = clients.length\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, len)\n for (let i = 0; i < len; i++) {\n const clientID = clients[i]\n const state = states.get(clientID) || null\n const clock = /** @type {MetaClientState} */ (awareness.meta.get(clientID)).clock\n encoding.writeVarUint(encoder, clientID)\n encoding.writeVarUint(encoder, clock)\n encoding.writeVarString(encoder, JSON.stringify(state))\n }\n return encoding.toUint8Array(encoder)\n}\n\n/**\n * Modify the content of an awareness update before re-encoding it to an awareness update.\n *\n * This might be useful when you have a central server that wants to ensure that clients\n * cant hijack somebody elses identity.\n *\n * @param {Uint8Array} update\n * @param {function(any):any} modify\n * @return {Uint8Array}\n */\nexport const modifyAwarenessUpdate = (update, modify) => {\n const decoder = decoding.createDecoder(update)\n const encoder = encoding.createEncoder()\n const len = decoding.readVarUint(decoder)\n encoding.writeVarUint(encoder, len)\n for (let i = 0; i < len; i++) {\n const clientID = decoding.readVarUint(decoder)\n const clock = decoding.readVarUint(decoder)\n const state = JSON.parse(decoding.readVarString(decoder))\n const modifiedState = modify(state)\n encoding.writeVarUint(encoder, clientID)\n encoding.writeVarUint(encoder, clock)\n encoding.writeVarString(encoder, JSON.stringify(modifiedState))\n }\n return encoding.toUint8Array(encoder)\n}\n\n/**\n * @param {Awareness} awareness\n * @param {Uint8Array} update\n * @param {any} origin This will be added to the emitted change event\n */\nexport const applyAwarenessUpdate = (awareness, update, origin) => {\n const decoder = decoding.createDecoder(update)\n const timestamp = time.getUnixTime()\n const added = []\n const updated = []\n const filteredUpdated = []\n const removed = []\n const len = decoding.readVarUint(decoder)\n for (let i = 0; i < len; i++) {\n const clientID = decoding.readVarUint(decoder)\n let clock = decoding.readVarUint(decoder)\n const state = JSON.parse(decoding.readVarString(decoder))\n const clientMeta = awareness.meta.get(clientID)\n const prevState = awareness.states.get(clientID)\n const currClock = clientMeta === undefined ? 0 : clientMeta.clock\n if (currClock < clock || (currClock === clock && state === null && awareness.states.has(clientID))) {\n if (state === null) {\n // never let a remote client remove this local state\n if (clientID === awareness.clientID && awareness.getLocalState() != null) {\n // remote client removed the local state. Do not remote state. Broadcast a message indicating\n // that this client still exists by increasing the clock\n clock++\n } else {\n awareness.states.delete(clientID)\n }\n } else {\n awareness.states.set(clientID, state)\n }\n awareness.meta.set(clientID, {\n clock,\n lastUpdated: timestamp\n })\n if (clientMeta === undefined && state !== null) {\n added.push(clientID)\n } else if (clientMeta !== undefined && state === null) {\n removed.push(clientID)\n } else if (state !== null) {\n if (!f.equalityDeep(state, prevState)) {\n filteredUpdated.push(clientID)\n }\n updated.push(clientID)\n }\n }\n }\n if (added.length > 0 || filteredUpdated.length > 0 || removed.length > 0) {\n awareness.emit('change', [{\n added, updated: filteredUpdated, removed\n }, origin])\n }\n if (added.length > 0 || updated.length > 0 || removed.length > 0) {\n awareness.emit('update', [{\n added, updated, removed\n }, origin])\n }\n}\n","/**\n * @module provider/websocket\n */\n\n/* eslint-env browser */\n\nimport * as Y from 'yjs' // eslint-disable-line\nimport * as bc from 'lib0/broadcastchannel'\nimport * as time from 'lib0/time'\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\nimport * as syncProtocol from 'y-protocols/sync'\nimport * as authProtocol from 'y-protocols/auth'\nimport * as awarenessProtocol from 'y-protocols/awareness'\nimport { Observable } from 'lib0/observable'\nimport * as math from 'lib0/math'\nimport * as url from 'lib0/url'\nimport * as env from 'lib0/environment'\n\nexport const messageSync = 0\nexport const messageQueryAwareness = 3\nexport const messageAwareness = 1\nexport const messageAuth = 2\n\n/**\n * encoder, decoder, provider, emitSynced, messageType\n * @type {Array<function(encoding.Encoder, decoding.Decoder, WebsocketProvider, boolean, number):void>}\n */\nconst messageHandlers = []\n\nmessageHandlers[messageSync] = (\n encoder,\n decoder,\n provider,\n emitSynced,\n _messageType\n) => {\n encoding.writeVarUint(encoder, messageSync)\n const syncMessageType = syncProtocol.readSyncMessage(\n decoder,\n encoder,\n provider.doc,\n provider\n )\n if (\n emitSynced && syncMessageType === syncProtocol.messageYjsSyncStep2 &&\n !provider.synced\n ) {\n provider.synced = true\n }\n}\n\nmessageHandlers[messageQueryAwareness] = (\n encoder,\n _decoder,\n provider,\n _emitSynced,\n _messageType\n) => {\n encoding.writeVarUint(encoder, messageAwareness)\n encoding.writeVarUint8Array(\n encoder,\n awarenessProtocol.encodeAwarenessUpdate(\n provider.awareness,\n Array.from(provider.awareness.getStates().keys())\n )\n )\n}\n\nmessageHandlers[messageAwareness] = (\n _encoder,\n decoder,\n provider,\n _emitSynced,\n _messageType\n) => {\n awarenessProtocol.applyAwarenessUpdate(\n provider.awareness,\n decoding.readVarUint8Array(decoder),\n provider\n )\n}\n\nmessageHandlers[messageAuth] = (\n _encoder,\n decoder,\n provider,\n _emitSynced,\n _messageType\n) => {\n authProtocol.readAuthMessage(\n decoder,\n provider.doc,\n (_ydoc, reason) => permissionDeniedHandler(provider, reason)\n )\n}\n\n// @todo - this should depend on awareness.outdatedTime\nconst messageReconnectTimeout = 30000\n\n/**\n * @param {WebsocketProvider} provider\n * @param {string} reason\n */\nconst permissionDeniedHandler = (provider, reason) =>\n console.warn(`Permission denied to access ${provider.url}.\\n${reason}`)\n\n/**\n * @param {WebsocketProvider} provider\n * @param {Uint8Array} buf\n * @param {boolean} emitSynced\n * @return {encoding.Encoder}\n */\nconst readMessage = (provider, buf, emitSynced) => {\n const decoder = decoding.createDecoder(buf)\n const encoder = encoding.createEncoder()\n const messageType = decoding.readVarUint(decoder)\n const messageHandler = provider.messageHandlers[messageType]\n if (/** @type {any} */ (messageHandler)) {\n messageHandler(encoder, decoder, provider, emitSynced, messageType)\n } else {\n console.error('Unable to compute message')\n }\n return encoder\n}\n\n/**\n * @param {WebsocketProvider} provider\n */\nconst setupWS = (provider) => {\n if (provider.shouldConnect && provider.ws === null) {\n const websocket = new provider._WS(provider.url, provider.protocols)\n websocket.binaryType = 'arraybuffer'\n provider.ws = websocket\n provider.wsconnecting = true\n provider.wsconnected = false\n provider.synced = false\n\n websocket.onmessage = (event) => {\n provider.wsLastMessageReceived = time.getUnixTime()\n const encoder = readMessage(provider, new Uint8Array(event.data), true)\n if (encoding.length(encoder) > 1) {\n websocket.send(encoding.toUint8Array(encoder))\n }\n }\n websocket.onerror = (event) => {\n provider.emit('connection-error', [event, provider])\n }\n websocket.onclose = (event) => {\n provider.emit('connection-close', [event, provider])\n provider.ws = null\n provider.wsconnecting = false\n if (provider.wsconnected) {\n provider.wsconnected = false\n provider.synced = false\n // update awareness (all users except local left)\n awarenessProtocol.removeAwarenessStates(\n provider.awareness,\n Array.from(provider.awareness.getStates().keys()).filter((client) =>\n client !== provider.doc.clientID\n ),\n provider\n )\n provider.emit('status', [{\n status: 'disconnected'\n }])\n } else {\n provider.wsUnsuccessfulReconnects++\n }\n // Start with no reconnect timeout and increase timeout by\n // using exponential backoff starting with 100ms\n setTimeout(\n setupWS,\n math.min(\n math.pow(2, provider.wsUnsuccessfulReconnects) * 100,\n provider.maxBackoffTime\n ),\n provider\n )\n }\n websocket.onopen = () => {\n provider.wsLastMessageReceived = time.getUnixTime()\n provider.wsconnecting = false\n provider.wsconnected = true\n provider.wsUnsuccessfulReconnects = 0\n provider.emit('status', [{\n status: 'connected'\n }])\n // always send sync step 1 when connected\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, messageSync)\n syncProtocol.writeSyncStep1(encoder, provider.doc)\n websocket.send(encoding.toUint8Array(encoder))\n // broadcast local awareness state\n if (provider.awareness.getLocalState() !== null) {\n const encoderAwarenessState = encoding.createEncoder()\n encoding.writeVarUint(encoderAwarenessState, messageAwareness)\n encoding.writeVarUint8Array(\n encoderAwarenessState,\n awarenessProtocol.encodeAwarenessUpdate(provider.awareness, [\n provider.doc.clientID\n ])\n )\n websocket.send(encoding.toUint8Array(encoderAwarenessState))\n }\n }\n provider.emit('status', [{\n status: 'connecting'\n }])\n }\n}\n\n/**\n * @param {WebsocketProvider} provider\n * @param {ArrayBuffer} buf\n */\nconst broadcastMessage = (provider, buf) => {\n const ws = provider.ws\n if (provider.wsconnected && ws && ws.readyState === ws.OPEN) {\n ws.send(buf)\n }\n if (provider.bcconnected) {\n bc.publish(provider.bcChannel, buf, provider)\n }\n}\n\n/**\n * Websocket Provider for Yjs. Creates a websocket connection to sync the shared document.\n * The document name is attached to the provided url. I.e. the following example\n * creates a websocket connection to http://localhost:1234/my-document-name\n *\n * @example\n * import * as Y from 'yjs'\n * import { WebsocketProvider } from 'y-websocket'\n * const doc = new Y.Doc()\n * const provider = new WebsocketProvider('http://localhost:1234', 'my-document-name', doc)\n *\n * @extends {Observable<string>}\n */\nexport class WebsocketProvider extends Observable {\n /**\n * @param {string} serverUrl\n * @param {string} roomname\n * @param {Y.Doc} doc\n * @param {object} opts\n * @param {boolean} [opts.connect]\n * @param {awarenessProtocol.Awareness} [opts.awareness]\n * @param {Object<string,string>} [opts.params] specify url parameters\n * @param {Array<string>} [opts.protocols] specify websocket protocols\n * @param {typeof WebSocket} [opts.WebSocketPolyfill] Optionall provide a WebSocket polyfill\n * @param {number} [opts.resyncInterval] Request server state every `resyncInterval` milliseconds\n * @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)\n * @param {boolean} [opts.disableBc] Disable cross-tab BroadcastChannel communication\n */\n constructor (serverUrl, roomname, doc, {\n connect = true,\n awareness = new awarenessProtocol.Awareness(doc),\n params = {},\n protocols = [],\n WebSocketPolyfill = WebSocket,\n resyncInterval = -1,\n maxBackoffTime = 2500,\n disableBc = false\n } = {}) {\n super()\n // ensure that url is always ends with /\n while (serverUrl[serverUrl.length - 1] === '/') {\n serverUrl = serverUrl.slice(0, serverUrl.length - 1)\n }\n this.serverUrl = serverUrl\n this.bcChannel = serverUrl + '/' + roomname\n this.maxBackoffTime = maxBackoffTime\n /**\n * The specified url parameters. This can be safely updated. The changed parameters will be used\n * when a new connection is established.\n * @type {Object<string,string>}\n */\n this.params = params\n this.protocols = protocols\n this.roomname = roomname\n this.doc = doc\n this._WS = WebSocketPolyfill\n this.awareness = awareness\n this.wsconnected = false\n this.wsconnecting = false\n this.bcconnected = false\n this.disableBc = disableBc\n this.wsUnsuccessfulReconnects = 0\n this.messageHandlers = messageHandlers.slice()\n /**\n * @type {boolean}\n */\n this._synced = false\n /**\n * @type {WebSocket?}\n */\n this.ws = null\n this.wsLastMessageReceived = 0\n /**\n * Whether to connect to other peers or not\n * @type {boolean}\n */\n this.shouldConnect = connect\n\n /**\n * @type {number}\n */\n this._resyncInterval = 0\n if (resyncInterval > 0) {\n this._resyncInterval = /** @type {any} */ (setInterval(() => {\n if (this.ws && this.ws.readyState === WebSocket.OPEN) {\n // resend sync step 1\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, messageSync)\n syncProtocol.writeSyncStep1(encoder, doc)\n this.ws.send(encoding.toUint8Array(encoder))\n }\n }, resyncInterval))\n }\n\n /**\n * @param {ArrayBuffer} data\n * @param {any} origin\n */\n this._bcSubscriber = (data, origin) => {\n if (origin !== this) {\n const encoder = readMessage(this, new Uint8Array(data), false)\n if (encoding.length(encoder) > 1) {\n bc.publish(this.bcChannel, encoding.toUint8Array(encoder), this)\n }\n }\n }\n /**\n * Listens to Yjs updates and sends them to remote peers (ws and broadcastchannel)\n * @param {Uint8Array} update\n * @param {any} origin\n */\n this._updateHandler = (update, origin) => {\n if (origin !== this) {\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, messageSync)\n syncProtocol.writeUpdate(encoder, update)\n broadcastMessage(this, encoding.toUint8Array(encoder))\n }\n }\n this.doc.on('update', this._updateHandler)\n /**\n * @param {any} changed\n * @param {any} _origin\n */\n this._awarenessUpdateHandler = ({ added, updated, removed }, _origin) => {\n const changedClients = added.concat(updated).concat(removed)\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, messageAwareness)\n encoding.writeVarUint8Array(\n encoder,\n awarenessProtocol.encodeAwarenessUpdate(awareness, changedClients)\n )\n broadcastMessage(this, encoding.toUint8Array(encoder))\n }\n this._exitHandler = () => {\n awarenessProtocol.removeAwarenessStates(\n this.awareness,\n [doc.clientID],\n 'app closed'\n )\n }\n if (env.isNode && typeof process !== 'undefined') {\n process.on('exit', this._exitHandler)\n }\n awareness.on('update', this._awarenessUpdateHandler)\n this._checkInterval = /** @type {any} */ (setInterval(() => {\n if (\n this.wsconnected &&\n messageReconnectTimeout <\n time.getUnixTime() - this.wsLastMessageReceived\n ) {\n // no message received in a long time - not even your own awareness\n // updates (which are updated every 15 seconds)\n /** @type {WebSocket} */ (this.ws).close()\n }\n }, messageReconnectTimeout / 10))\n if (connect) {\n this.connect()\n }\n }\n\n get url () {\n const encodedParams = url.encodeQueryParams(this.params)\n return this.serverUrl + '/' + this.roomname +\n (encodedParams.length === 0 ? '' : '?' + encodedParams)\n }\n\n /**\n * @type {boolean}\n */\n get synced () {\n return this._synced\n }\n\n set synced (state) {\n if (this._synced !== state) {\n this._synced = state\n this.emit('synced', [state])\n this.emit('sync', [state])\n }\n }\n\n destroy () {\n if (this._resyncInterval !== 0) {\n clearInterval(this._resyncInterval)\n }\n clearInterval(this._checkInterval)\n this.disconnect()\n if (env.isNode && typeof process !== 'undefined') {\n process.off('exit', this._exitHandler)\n }\n this.awareness.off('update', this._awarenessUpdateHandler)\n this.doc.off('update', this._updateHandler)\n super.destroy()\n }\n\n connectBc () {\n if (this.disableBc) {\n return\n }\n if (!this.bcconnected) {\n bc.subscribe(this.bcChannel, this._bcSubscriber)\n this.bcconnected = true\n }\n // send sync step1 to bc\n // write sync step 1\n const encoderSync = encoding.createEncoder()\n encoding.writeVarUint(encoderSync, messageSync)\n syncProtocol.writeSyncStep1(encoderSync, this.doc)\n bc.publish(this.bcChannel, encoding.toUint8Array(encoderSync), this)\n // broadcast local state\n const encoderState = encoding.createEncoder()\n encoding.writeVarUint(encoderState, messageSync)\n syncProtocol.writeSyncStep2(encoderState, this.doc)\n bc.publish(this.bcChannel, encoding.toUint8Array(encoderState), this)\n // write queryAwareness\n const encoderAwarenessQuery = encoding.createEncoder()\n encoding.writeVarUint(encoderAwarenessQuery, messageQueryAwareness)\n bc.publish(\n this.bcChannel,\n encoding.toUint8Array(encoderAwarenessQuery),\n this\n )\n // broadcast local awareness state\n const encoderAwarenessState = encoding.createEncoder()\n encoding.writeVarUint(encoderAwarenessState, messageAwareness)\n encoding.writeVarUint8Array(\n encoderAwarenessState,\n awarenessProtocol.encodeAwarenessUpdate(this.awareness, [\n this.doc.clientID\n ])\n )\n bc.publish(\n this.bcChannel,\n encoding.toUint8Array(encoderAwarenessState),\n this\n )\n }\n\n disconnectBc () {\n // broadcast message with local awareness state set to null (indicating disconnect)\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, messageAwareness)\n encoding.writeVarUint8Array(\n encoder,\n awarenessProtocol.encodeAwarenessUpdate(this.awareness, [\n this.doc.clientID\n ], new Map())\n )\n broadcastMessage(this, encoding.toUint8Array(encoder))\n if (this.bcconnected) {\n bc.unsubscribe(this.bcChannel, this._bcSubscriber)\n this.bcconnected = false\n }\n }\n\n disconnect () {\n this.shouldConnect = false\n this.disconnectBc()\n if (this.ws !== null) {\n this.ws.close()\n }\n }\n\n connect () {\n this.shouldConnect = true\n if (!this.wsconnected && this.ws === null) {\n setupWS(this)\n this.connectBc()\n }\n }\n}\n","\nimport * as Y from 'yjs' // eslint-disable-line\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\n\nexport const messagePermissionDenied = 0\n\n/**\n * @param {encoding.Encoder} encoder\n * @param {string} reason\n */\nexport const writePermissionDenied = (encoder, reason) => {\n encoding.writeVarUint(encoder, messagePermissionDenied)\n encoding.writeVarString(encoder, reason)\n}\n\n/**\n * @callback PermissionDeniedHandler\n * @param {any} y\n * @param {string} reason\n */\n\n/**\n *\n * @param {decoding.Decoder} decoder\n * @param {Y.Doc} y\n * @param {PermissionDeniedHandler} permissionDeniedHandler\n */\nexport const readAuthMessage = (decoder, y, permissionDeniedHandler) => {\n switch (decoding.readVarUint(decoder)) {\n case messagePermissionDenied: permissionDeniedHandler(y, decoding.readVarString(decoder))\n }\n}\n","/**\n * Utility module to work with urls.\n *\n * @module url\n */\n\nimport * as object from './object.js'\n\n/**\n * Parse query parameters from an url.\n *\n * @param {string} url\n * @return {Object<string,string>}\n */\nexport const decodeQueryParams = url => {\n /**\n * @type {Object<string,string>}\n */\n const query = {}\n const urlQuerySplit = url.split('?')\n const pairs = urlQuerySplit[urlQuerySplit.length - 1].split('&')\n for (let i = 0; i < pairs.length; i++) {\n const item = pairs[i]\n if (item.length > 0) {\n const pair = item.split('=')\n query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '')\n }\n }\n return query\n}\n\n/**\n * @param {Object<string,string>} params\n * @return {string}\n */\nexport const encodeQueryParams = params =>\n object.map(params, (val, key) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`).join('&')\n"],"names":["channels","Map","BC","BroadcastChannel","constructor","room","this","onmessage","_onChange","e","key","data","buffer.fromBase64","newValue","storage.onChange","postMessage","buf","storage.varStorage","setItem","buffer.toBase64","buffer.createUint8ArrayFromArrayBuffer","close","storage.offChange","getChannel","map.setIfUndefined","subs","set.create","bc","forEach","sub","publish","origin","c","writeSyncStep1","encoder","doc","encoding.writeVarUint","sv","Y.encodeStateVector","encoding.writeVarUint8Array","writeSyncStep2","encodedStateVector","Y.encodeStateAsUpdate","readSyncStep2","decoder","transactionOrigin","Y.applyUpdate","decoding.readVarUint8Array","error","console","readUpdate","readSyncMessage","messageType","decoding.readVarUint","readSyncStep1","Error","outdatedTimeout","Awareness","Observable","super","clientID","states","meta","_checkInterval","setInterval","now","time.getUnixTime","getLocalState","get","lastUpdated","setLocalState","remove","clientid","has","push","length","removeAwarenessStates","math.floor","on","destroy","emit","clearInterval","state","currLocalMeta","clock","undefined","prevState","delete","set","added","updated","filteredUpdated","removed","f.equalityDeep","setLocalStateField","field","value","getStates","awareness","clients","i","curMeta","encodeAwarenessUpdate","len","encoding.createEncoder","encoding.writeVarString","JSON","stringify","encoding.toUint8Array","messageSync","messageQueryAwareness","messageAwareness","messageAuth","messageHandlers","provider","emitSynced","_messageType","syncMessageType","syncProtocol.readSyncMessage","synced","_decoder","_emitSynced","awarenessProtocol.encodeAwarenessUpdate","Array","from","keys","_encoder","update","decoding.createDecoder","timestamp","parse","decoding.readVarString","clientMeta","currClock","awarenessProtocol.applyAwarenessUpdate","y","permissionDeniedHandler","authProtocol.readAuthMessage","_ydoc","reason","warn","url","readMessage","messageHandler","setupWS","shouldConnect","ws","websocket","_WS","protocols","binaryType","wsconnecting","wsconnected","event","wsLastMessageReceived","Uint8Array","encoding.length","send","onerror","onclose","awarenessProtocol.removeAwarenessStates","filter","client","status","wsUnsuccessfulReconnects","setTimeout","math.min","math.pow","maxBackoffTime","onopen","syncProtocol.writeSyncStep1","encoderAwarenessState","broadcastMessage","readyState","OPEN","bcconnected","bc.publish","bcChannel","WebsocketProvider","serverUrl","roomname","connect","awarenessProtocol.Awareness","params","WebSocketPolyfill","WebSocket","resyncInterval","disableBc","slice","_synced","_resyncInterval","_bcSubscriber","_updateHandler","syncProtocol.writeUpdate","_awarenessUpdateHandler","_origin","changedClients","concat","_exitHandler","env.isNode","process","messageReconnectTimeout","encodedParams","object.map","val","encodeURIComponent","join","disconnect","off","connectBc","f","add","encoderSync","encoderState","syncProtocol.writeSyncStep2","encoderAwarenessQuery","disconnectBc","channel","unsubscribed","size","bc.unsubscribe"],"mappings":"uOAiCA,MAAMA,EAAW,IAAIC,IAmCrB,MAAMC,EAAiC,oBAArBC,iBAhClB,MAIE,WAAAC,CAAaC,GACXC,KAAKD,KAAOA,EAIZC,KAAKC,UAAY,KAIjBD,KAAKE,UAAYC,GAAKA,EAAEC,MAAQL,GAA2B,OAAnBC,KAAKC,WAAsBD,KAAKC,UAAU,CAAEI,KAAMC,EAAkBH,EAAEI,UAAY,MAC1HC,EAAiBR,KAAKE,UACvB,CAKD,WAAAO,CAAaC,GACXC,EAAmBC,QAAQZ,KAAKD,KAAMc,EAAgBC,EAAuCJ,IAC9F,CAED,KAAAK,GACEC,EAAkBhB,KAAKE,UACxB,GAMyEL,iBAMtEoB,EAAalB,GACjBmB,EAAmBxB,EAAUK,GAAM,KACjC,MAAMoB,EAAOC,IACPC,EAAK,IAAIzB,EAAGG,GAMlB,OADAsB,EAAGpB,UAAYE,GAAKgB,EAAKG,SAAQC,GAAOA,EAAIpB,EAAEE,KAAM,sBAC7C,CACLgB,KAAIF,OACL,IAwCQK,EAAU,CAACzB,EAAMM,EAAMoB,EAAS,QAC3C,MAAMC,EAAIT,EAAWlB,GACrB2B,EAAEL,GAAGZ,YAAYJ,GACjBqB,EAAEP,KAAKG,SAAQC,GAAOA,EAAIlB,EAAMoB,IAAQ,ECjF7BE,EAAiB,CAACC,EAASC,KACtCC,EAAsBF,EAXW,GAYjC,MAA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,GACtBjN,MAGF,MAAMqK,EAAwBnE,IAC9BpE,EAAsBuI,EA9aM,GA+a5BpI,EACEoI,EACAjD,EAAwCpH,KAAK4F,UAAW,CACtD5F,KAAK6B,IAAIyB,YAGboH,EACE1K,KAAK2K,UACLrE,EAAsB+D,GACtBrK,KAEH,CAED,YAAAkN,GAEE,MAAMtL,EAAUsE,IAChBpE,EAAsBF,EA/bM,GAgc5BK,EACEL,EACAwF,EAAwCpH,KAAK4F,UAAW,CACtD5F,KAAK6B,IAAIyB,UACR,IAAI3D,MAET2K,EAAiBtK,KAAMsG,EAAsB1E,IACzC5B,KAAKyK,cHjXc,EAAC1K,EAAM6M,KAChC,MAAMO,EAAUlM,EAAWlB,GACrBqN,EAAeD,EAAQhM,KAAK8D,OAAO2H,GACrCQ,GAAsC,IAAtBD,EAAQhM,KAAKkM,OAC/BF,EAAQ9L,GAAGN,QACXrB,EAASuF,OAAOlF,GAEXqN,EG2WHE,CAAetN,KAAK2K,UAAW3K,KAAKyL,eACpCzL,KAAKyK,aAAc,EAEtB,CAED,UAAAgC,GACEzM,KAAK2I,eAAgB,EACrB3I,KAAKkN,eACW,OAAZlN,KAAK4I,IACP5I,KAAK4I,GAAG7H,OAEX,CAED,OAAAgK,GACE/K,KAAK2I,eAAgB,EAChB3I,KAAKkJ,aAA2B,OAAZlJ,KAAK4I,KAC5BF,EAAQ1I,MACRA,KAAK2M,YAER","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const t=()=>new Map,e=e=>{const n=t();return e.forEach(((t,e)=>{n.set(e,t)})),n},n=(t,e,n)=>{let r=t.get(e);return void 0===r&&t.set(e,r=n()),r},r=()=>new Set,s=t=>t[t.length-1],i=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},o=Array.from,c=Array.isArray;class l{constructor(){this._observers=t()}on(t,e){return n(this._observers,t,r).add(e),e}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(e,n){return o((this._observers.get(e)||t()).values()).forEach((t=>t(...n)))}destroy(){this._observers=t()}}class h{constructor(){this._observers=t()}on(t,e){n(this._observers,t,r).add(e)}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(e,n){return o((this._observers.get(e)||t()).values()).forEach((t=>t(...n)))}destroy(){this._observers=t()}}const a=Math.floor,d=Math.abs,u=(t,e)=>t<e?t:e,g=(t,e)=>t>e?t:e,f=Math.pow,p=t=>0!==t?t<0:1/t<0,w=64,m=128,y=127,k=Number.MAX_SAFE_INTEGER,b=Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&a(t)===t),_=String.fromCharCode,S=/^\s*/g,E=/([A-Z])/g,C=(t,e)=>(t=>t.replace(S,""))(t.replace(E,(t=>`${e}${(t=>t.toLowerCase())(t)}`))),D="undefined"!=typeof TextEncoder?new TextEncoder:null,v=D?t=>D.encode(t):t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.codePointAt(t);return r};let A="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});A&&1===A.decode(new Uint8Array).length&&(A=null);const x=(t,e)=>((t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n})(e,(()=>t)).join("");class U{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const I=()=>new U,M=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},O=t=>{const e=new Uint8Array(M(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},T=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},L=T,N=(t,e)=>{for(;e>y;)T(t,m|y&e),e=a(e/128);T(t,y&e)},R=(t,e)=>{const n=p(e);for(n&&(e=-e),T(t,(e>63?m:0)|(n?w:0)|63&e),e=a(e/64);e>0;)T(t,(e>y?m:0)|y&e),e=a(e/128)},V=new Uint8Array(3e4),F=V.length/3,P=D&&D.encodeInto?(t,e)=>{if(e.length<F){const n=D.encodeInto(e,V).written||0;N(t,n);for(let e=0;e<n;e++)T(t,V[e])}else z(t,v(e))}:(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;N(t,r);for(let e=0;e<r;e++)T(t,n.codePointAt(e))},j=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=u(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(g(2*n,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},z=(t,e)=>{N(t,e.byteLength),j(t,e)},J=(t,e)=>{((t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(2*g(n,e)),t.cpos=0)})(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},B=new DataView(new ArrayBuffer(4)),W=(t,e)=>{switch(typeof e){case"string":T(t,119),P(t,e);break;case"number":b(e)&&d(e)<=2147483647?(T(t,125),R(t,e)):(n=e,B.setFloat32(0,n),B.getFloat32(0)===n?(T(t,124),((t,e)=>{J(t,4).setFloat32(0,e,!1)})(t,e)):(T(t,123),((t,e)=>{J(t,8).setFloat64(0,e,!1)})(t,e)));break;case"bigint":T(t,122),((t,e)=>{J(t,8).setBigInt64(0,e,!1)})(t,e);break;case"object":if(null===e)T(t,126);else if(c(e)){T(t,117),N(t,e.length);for(let n=0;n<e.length;n++)W(t,e[n])}else if(e instanceof Uint8Array)T(t,116),z(t,e);else{T(t,118);const n=Object.keys(e);N(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];P(t,s),W(t,e[s])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}var n};class $ extends U{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&N(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const H=t=>{t.count>0&&(R(t.encoder,1===t.count?t.s:-t.s),t.count>1&&N(t.encoder,t.count-2))};class Y{constructor(){this.encoder=new U,this.s=0,this.count=0}write(t){this.s===t?this.count++:(H(this),this.count=1,this.s=t)}toUint8Array(){return H(this),O(this.encoder)}}const K=t=>{if(t.count>0){const e=2*t.diff+(1===t.count?0:1);R(t.encoder,e),t.count>1&&N(t.encoder,t.count-2)}};class G{constructor(){this.encoder=new U,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(K(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return K(this),O(this.encoder)}}class X{constructor(){this.sarr=[],this.s="",this.lensE=new Y}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 U;return this.sarr.push(this.s),this.s="",P(t,this.sarr.join("")),j(t,this.lensE.toUint8Array()),O(t)}}const q=t=>new Error(t),Z=()=>{throw q("Method unimplemented")},Q=()=>{throw q("Unexpected case")},tt=q("Unexpected end of array"),et=q("Integer out of Range");class nt{constructor(t){this.arr=t,this.pos=0}}const rt=t=>new nt(t),st=t=>t.pos!==t.arr.length,it=t=>((t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n})(t,ct(t)),ot=t=>t.arr[t.pos++],ct=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const r=t.arr[t.pos++];if(e+=(r&y)*n,n*=128,r<m)return e;if(e>k)throw et}throw tt},lt=t=>{let e=t.arr[t.pos++],n=63&e,r=64;const s=(e&w)>0?-1:1;if(!(e&m))return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n+=(e&y)*r,r*=128,e<m)return s*n;if(n>k)throw et}throw tt},ht=A?t=>A.decode(it(t)):t=>{let e=ct(t);if(0===e)return"";{let n=String.fromCodePoint(ot(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(ot(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},at=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},dt=[t=>{},t=>null,lt,t=>at(t,4).getFloat32(0,!1),t=>at(t,8).getFloat64(0,!1),t=>at(t,8).getBigInt64(0,!1),t=>!1,t=>!0,ht,t=>{const e=ct(t),n={};for(let r=0;r<e;r++){n[ht(t)]=ut(t)}return n},t=>{const e=ct(t),n=[];for(let r=0;r<e;r++)n.push(ut(t));return n},it],ut=t=>dt[127-ot(t)](t);class gt extends nt{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return 0===this.count&&(this.s=this.reader(this),st(this)?this.count=ct(this)+1:this.count=-1),this.count--,this.s}}class ft extends nt{constructor(t){super(t),this.s=0,this.count=0}read(){if(0===this.count){this.s=lt(this);const t=p(this.s);this.count=1,t&&(this.s=-this.s,this.count=ct(this)+2)}return this.count--,this.s}}class pt extends nt{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const t=lt(this),e=1&t;this.diff=a(t/2),this.count=1,e&&(this.count=ct(this)+2)}return this.s+=this.diff,this.count--,this.s}}class wt{constructor(t){this.decoder=new ft(t),this.str=ht(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}const mt=crypto.getRandomValues.bind(crypto),yt=()=>mt(new Uint32Array(1))[0],kt=[1e7]+-1e3+-4e3+-8e3+-1e11,bt=()=>kt.replace(/[018]/g,(t=>(t^yt()&15>>t/4).toString(16))),_t=Date.now,St=t=>new Promise(t);Promise.all.bind(Promise);const Et=t=>void 0===t?null:t;let Ct=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}},Dt=!0;try{"undefined"!=typeof localStorage&&localStorage&&(Ct=localStorage,Dt=!1)}catch(t){}const vt=Ct,At=t=>Dt||addEventListener("storage",t),xt=t=>Dt||removeEventListener("storage",t),Ut=Object.assign,It=Object.keys,Mt=(t,e)=>{const n=[];for(const r in t)n.push(e(t[r],r));return n},Ot=t=>It(t).length,Tt=t=>It(t).length,Lt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Nt=Object.freeze,Rt=t=>{for(const e in t){const n=t[e];"object"!=typeof n&&"function"!=typeof n||Rt(t[e])}return Nt(t)},Vt=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Vt(t,e,n+1)}},Ft=t=>t,Pt=(t,e)=>{if(null==t||null==e)return((t,e)=>t===e)(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break;case Set:if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break;case Map:if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Pt(t.get(n),e.get(n)))return!1;break;case Object:if(Ot(t)!==Ot(e))return!1;for(const n in t)if(!Lt(t,n)||!Pt(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Pt(t[n],e[n]))return!1;break;default:return!1}return!0},jt="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),zt="undefined"!=typeof window&&"undefined"!=typeof document&&!jt;let Jt;const Bt=e=>(()=>{if(void 0===Jt)if(jt){Jt=t();const e=process.argv;let n=null;for(let t=0;t<e.length;t++){const r=e[t];"-"===r[0]?(null!==n&&Jt.set(n,""),n=r):null!==n&&(Jt.set(n,r),n=null)}null!==n&&Jt.set(n,"")}else"object"==typeof location?(Jt=t(),(location.search||"?").slice(1).split("&").forEach((t=>{if(0!==t.length){const[e,n]=t.split("=");Jt.set(`--${C(e,"-")}`,n),Jt.set(`-${C(e,"-")}`,n)}}))):Jt=t();return Jt})().has(e),Wt=t=>Et(jt?process.env[t.toUpperCase().replaceAll("-","_")]:vt.getItem(t)),$t=t=>Bt("--"+t)||null!==Wt(t);$t("production");var Ht;const Yt=jt&&(Ht=process.env.FORCE_COLOR,["true","1","2"].includes(Ht))||!Bt("--no-colors")&&!$t("no-color")&&(!jt||process.stdout.isTTY)&&(!jt||Bt("--color")||null!==Wt("COLORTERM")||(Wt("TERM")||"").includes("color")),Kt=t=>new Uint8Array(t),Gt=t=>new Uint8Array(t),Xt=zt?t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=_(t[n]);return btoa(e)}:t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),qt=zt?t=>{const e=atob(t),n=Kt(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}:t=>{const e=Buffer.from(t,"base64");return((t,e,n)=>new Uint8Array(t,e,n))(e.buffer,e.byteOffset,e.byteLength)};class Zt{constructor(t,e){this.left=t,this.right=e}}const Qt=(t,e)=>new Zt(t,e),te="undefined"!=typeof document?document:{};"undefined"!=typeof DOMParser&&new DOMParser;const ee=t=>{const e=te.createDocumentFragment();for(let n=0;n<t.length;n++)se(e,t[n]);return e},ne=(t,e=[],n=[])=>{return r=((t,e)=>{var n;return n=(e,n)=>{!1===n?t.removeAttribute(e):!0===n?t.setAttribute(e,""):t.setAttribute(e,n)},e.forEach((t=>n(t.left,t.right))),t})((t=>te.createElement(t))(t),e),se(r,ee(n)),r;var r},re=t=>te.createTextNode(t),se=(t,e)=>t.appendChild(e);te.ELEMENT_NODE,te.TEXT_NODE,te.CDATA_SECTION_NODE,te.COMMENT_NODE,te.DOCUMENT_NODE,te.DOCUMENT_TYPE_NODE,te.DOCUMENT_FRAGMENT_NODE;const ie=Symbol,oe=ie(),ce=ie(),le=ie(),he=ie(),ae=ie(),de=ie(),ue=ie(),ge=ie(),fe=ie(),pe={[oe]:Qt("font-weight","bold"),[ce]:Qt("font-weight","normal"),[le]:Qt("color","blue"),[ae]:Qt("color","green"),[he]:Qt("color","grey"),[de]:Qt("color","red"),[ue]:Qt("color","purple"),[ge]:Qt("color","orange"),[fe]:Qt("color","black")},we=Yt?e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());const n=[],r=[],s=t();let i=[],o=0;for(;o<e.length;o++){const t=e[o],i=pe[t];if(void 0!==i)s.set(i.left,i.right);else{if(void 0===t)break;if(t.constructor!==String&&t.constructor!==Number)break;{const e=((t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n})(s,((t,e)=>`${e}:${t};`)).join("");o>0||e.length>0?(n.push("%c"+t),r.push(e)):n.push(t)}}}for(o>0&&(i=r,i.unshift(n.join("")));o<e.length;o++){const t=e[o];t instanceof Symbol||i.push(t)}return i}:t=>{1===t.length&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const n=t[r];if(void 0===n)break;if(n.constructor===String||n.constructor===Number)e.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const e=t[r];e instanceof Symbol||n.push(e)}return n},me=(...t)=>{console.log(...we(t)),ke.forEach((e=>e.print(t)))},ye=(...t)=>{console.warn(...we(t)),t.unshift(ge),ke.forEach((e=>e.print(t)))},ke=r(),be=t=>({[Symbol.iterator](){return this},next:t}),_e=(t,e)=>be((()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}}));class Se{constructor(t,e){this.clock=t,this.len=e}}class Ee{constructor(){this.clients=new Map}}const Ce=(t,e,n)=>e.clients.forEach(((e,r)=>{const s=t.doc.store.clients.get(r);for(let r=0;r<e.length;r++){const i=e[r];Pn(t,s,i.clock,i.len,n)}})),De=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=a((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null})(n,e.clock)},ve=t=>{t.clients.forEach((t=>{let e,n;for(t.sort(((t,e)=>t.clock-e.clock)),e=1,n=1;e<t.length;e++){const r=t[n-1],s=t[e];r.clock+r.len>=s.clock?r.len=g(r.len,s.clock+s.len-r.clock):(n<e&&(t[n]=s),n++)}t.length=n}))},Ae=t=>{const e=new Ee;for(let n=0;n<t.length;n++)t[n].clients.forEach(((r,s)=>{if(!e.clients.has(s)){const o=r.slice();for(let e=n+1;e<t.length;e++)i(o,t[e].clients.get(s)||[]);e.clients.set(s,o)}}));return ve(e),e},xe=(t,e,r,s)=>{n(t.clients,e,(()=>[])).push(new Se(r,s))},Ue=()=>new Ee,Ie=t=>{const e=Ue();return t.clients.forEach(((t,n)=>{const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.deleted){const s=n.id.clock;let i=n.length;if(e+1<t.length)for(let n=t[e+1];e+1<t.length&&n.deleted;n=t[1+ ++e])i+=n.length;r.push(new Se(s,i))}}r.length>0&&e.clients.set(n,r)})),e},Me=(t,e)=>{N(t.restEncoder,e.clients.size),o(e.clients.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,n])=>{t.resetDsCurVal(),N(t.restEncoder,e);const r=n.length;N(t.restEncoder,r);for(let e=0;e<r;e++){const r=n[e];t.writeDsClock(r.clock),t.writeDsLen(r.len)}}))},Oe=t=>{const e=new Ee,r=ct(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();const r=ct(t.restDecoder),s=ct(t.restDecoder);if(s>0){const i=n(e.clients,r,(()=>[]));for(let e=0;e<s;e++)i.push(new Se(t.readDsClock(),t.readDsLen()))}}return e},Te=(t,e,n)=>{const r=new Ee,s=ct(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const s=ct(t.restDecoder),i=ct(t.restDecoder),o=n.clients.get(s)||[],c=On(n,s);for(let n=0;n<i;n++){const n=t.readDsClock(),i=n+t.readDsLen();if(n<c){c<i&&xe(r,s,c,i-c);let t=Ln(o,n),l=o[t];for(!l.deleted&&l.id.clock<n&&(o.splice(t+1,0,Vs(e,l,n-l.id.clock)),t++);t<o.length&&(l=o[t++],l.id.clock<i);)l.deleted||(i<l.id.clock+l.length&&o.splice(t,0,Vs(e,l,i-l.id.clock)),l.delete(e))}else xe(r,s,n,i-n)}}if(r.clients.size>0){const t=new We;return N(t.restEncoder,0),Me(t,r),t.toUint8Array()}return null},Le=(t,e)=>{if(t.clients.size!==e.clients.size)return!1;for(const[n,r]of t.clients.entries()){const t=e.clients.get(n);if(void 0===t||r.length!==t.length)return!1;for(let e=0;e<r.length;e++){const n=r[e],s=t[e];if(n.clock!==s.clock||n.len!==s.len)return!1}}return!0},Ne=yt;class Re extends l{constructor({guid:t=bt(),collectionid:e=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:i=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Ne(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new In,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=St((t=>{this.on("load",(()=>{this.isLoaded=!0,t(this)}))}));const c=()=>St((t=>{const e=n=>{void 0!==n&&!0!==n||(this.off("sync",e),t())};this.on("sync",e)}));this.on("sync",(t=>{!1===t&&this.isSynced&&(this.whenSynced=c()),this.isSynced=void 0===t||!0===t,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=c()}load(){const t=this._item;null===t||this.shouldLoad||Yn(t.parent.doc,(t=>{t.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(o(this.subdocs).map((t=>t.guid)))}transact(t,e=null){return Yn(this,t,e)}get(t,e=Cr){const r=n(this.share,t,(()=>{const t=new e;return t._integrate(this,null),t})),s=r.constructor;if(e!==Cr&&s!==e){if(s===Cr){const n=new e;n._map=r._map,r._map.forEach((t=>{for(;null!==t;t=t.left)t.parent=n})),n._start=r._start;for(let t=n._start;null!==t;t=t.right)t.parent=n;return n._length=r._length,this.share.set(t,n),n._integrate(this,null),n}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return r}getArray(t=""){return this.get(t,Br)}getText(t=""){return this.get(t,cs)}getMap(t=""){return this.get(t,$r)}getXmlElement(t=""){return this.get(t,as)}getXmlFragment(t=""){return this.get(t,hs)}toJSON(){const t={};return this.share.forEach(((e,n)=>{t[n]=e.toJSON()})),t}destroy(){this.isDestroyed=!0,o(this.subdocs).forEach((t=>t.destroy()));const t=this._item;if(null!==t){this._item=null;const e=t.content;e.doc=new Re({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,Yn(t.parent.doc,(n=>{const r=e.doc;t.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Ve{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return ct(this.restDecoder)}readDsLen(){return ct(this.restDecoder)}}class Fe extends Ve{readLeftID(){return an(ct(this.restDecoder),ct(this.restDecoder))}readRightID(){return an(ct(this.restDecoder),ct(this.restDecoder))}readClient(){return ct(this.restDecoder)}readInfo(){return ot(this.restDecoder)}readString(){return ht(this.restDecoder)}readParentInfo(){return 1===ct(this.restDecoder)}readTypeRef(){return ct(this.restDecoder)}readLen(){return ct(this.restDecoder)}readAny(){return ut(this.restDecoder)}readBuf(){return(t=>{const e=Kt(t.byteLength);return e.set(t),e})(it(this.restDecoder))}readJSON(){return JSON.parse(ht(this.restDecoder))}readKey(){return ht(this.restDecoder)}}class Pe{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=ct(this.restDecoder),this.dsCurrVal}readDsLen(){const t=ct(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class je extends Pe{constructor(t){super(t),this.keys=[],ct(t),this.keyClockDecoder=new pt(it(t)),this.clientDecoder=new ft(it(t)),this.leftClockDecoder=new pt(it(t)),this.rightClockDecoder=new pt(it(t)),this.infoDecoder=new gt(it(t),ot),this.stringDecoder=new wt(it(t)),this.parentInfoDecoder=new gt(it(t),ot),this.typeRefDecoder=new ft(it(t)),this.lenDecoder=new ft(it(t))}readLeftID(){return new ln(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ln(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ut(this.restDecoder)}readBuf(){return it(this.restDecoder)}readJSON(){return ut(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class ze{constructor(){this.restEncoder=I()}toUint8Array(){return O(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){N(this.restEncoder,t)}writeDsLen(t){N(this.restEncoder,t)}}class Je extends ze{writeLeftID(t){N(this.restEncoder,t.client),N(this.restEncoder,t.clock)}writeRightID(t){N(this.restEncoder,t.client),N(this.restEncoder,t.clock)}writeClient(t){N(this.restEncoder,t)}writeInfo(t){L(this.restEncoder,t)}writeString(t){P(this.restEncoder,t)}writeParentInfo(t){N(this.restEncoder,t?1:0)}writeTypeRef(t){N(this.restEncoder,t)}writeLen(t){N(this.restEncoder,t)}writeAny(t){W(this.restEncoder,t)}writeBuf(t){z(this.restEncoder,t)}writeJSON(t){P(this.restEncoder,JSON.stringify(t))}writeKey(t){P(this.restEncoder,t)}}class Be{constructor(){this.restEncoder=I(),this.dsCurrVal=0}toUint8Array(){return O(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,N(this.restEncoder,e)}writeDsLen(t){0===t&&Q(),N(this.restEncoder,t-1),this.dsCurrVal+=t}}class We extends Be{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new G,this.clientEncoder=new Y,this.leftClockEncoder=new G,this.rightClockEncoder=new G,this.infoEncoder=new $(L),this.stringEncoder=new X,this.parentInfoEncoder=new $(L),this.typeRefEncoder=new Y,this.lenEncoder=new Y}toUint8Array(){const t=I();return N(t,0),z(t,this.keyClockEncoder.toUint8Array()),z(t,this.clientEncoder.toUint8Array()),z(t,this.leftClockEncoder.toUint8Array()),z(t,this.rightClockEncoder.toUint8Array()),z(t,O(this.infoEncoder)),z(t,this.stringEncoder.toUint8Array()),z(t,O(this.parentInfoEncoder)),z(t,this.typeRefEncoder.toUint8Array()),z(t,this.lenEncoder.toUint8Array()),j(t,O(this.restEncoder)),O(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){W(this.restEncoder,t)}writeBuf(t){z(this.restEncoder,t)}writeJSON(t){W(this.restEncoder,t)}writeKey(t){const e=this.keyMap.get(t);void 0===e?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}}const $e=(t,e,n)=>{const r=new Map;n.forEach(((t,n)=>{On(e,n)>t&&r.set(n,t)})),Mn(e).forEach(((t,e)=>{n.has(e)||r.set(e,0)})),N(t.restEncoder,r.size),o(r.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([n,r])=>{((t,e,n,r)=>{r=g(r,e[0].id.clock);const s=Ln(e,r);N(t.restEncoder,e.length-s),t.writeClient(n),N(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let n=s+1;n<e.length;n++)e[n].write(t,0)})(t,e.clients.get(n),n,r)}))},He=(e,r,s,i=new je(e))=>Yn(r,(e=>{e.local=!1;let r=!1;const s=e.doc,c=s.store,l=((e,n)=>{const r=t(),s=ct(e.restDecoder);for(let t=0;t<s;t++){const t=ct(e.restDecoder),s=new Array(t),i=e.readClient();let o=ct(e.restDecoder);r.set(i,{i:0,refs:s});for(let r=0;r<t;r++){const t=e.readInfo();switch(31&t){case 0:{const t=e.readLen();s[r]=new ps(an(i,o),t),o+=t;break}case 10:{const t=ct(e.restDecoder);s[r]=new Bs(an(i,o),t),o+=t;break}default:{const c=!(192&t),l=new js(an(i,o),null,(t&m)===m?e.readLeftID():null,null,(t&w)===w?e.readRightID():null,c?e.readParentInfo()?n.get(e.readString()):e.readLeftID():null,!c||32&~t?null:e.readString(),zs(e,t));s[r]=l,o+=l.length}}}}return r})(i,s),h=((t,e,r)=>{const s=[];let i=o(r.keys()).sort(((t,e)=>t-e));if(0===i.length)return null;const c=()=>{if(0===i.length)return null;let t=r.get(i[i.length-1]);for(;t.refs.length===t.i;){if(i.pop(),!(i.length>0))return null;t=r.get(i[i.length-1])}return t};let l=c();if(null===l)return null;const h=new In,a=new Map,d=(t,e)=>{const n=a.get(t);(null==n||n>e)&&a.set(t,e)};let u=l.refs[l.i++];const g=new Map,f=()=>{for(const t of s){const e=t.id.client,n=r.get(e);n?(n.i--,h.clients.set(e,n.refs.slice(n.i)),r.delete(e),n.i=0,n.refs=[]):h.clients.set(e,[t]),i=i.filter((t=>t!==e))}s.length=0};for(;;){if(u.constructor!==Bs){const i=n(g,u.id.client,(()=>On(e,u.id.client)))-u.id.clock;if(i<0)s.push(u),d(u.id.client,u.id.clock-1),f();else{const n=u.getMissing(t,e);if(null!==n){s.push(u);const t=r.get(n)||{refs:[],i:0};if(t.refs.length!==t.i){u=t.refs[t.i++];continue}d(n,On(e,n)),f()}else(0===i||i<u.length)&&(u.integrate(t,i),g.set(u.id.client,u.id.clock+u.length))}}if(s.length>0)u=s.pop();else if(null!==l&&l.i<l.refs.length)u=l.refs[l.i++];else{if(l=c(),null===l)break;u=l.refs[l.i++]}}if(h.clients.size>0){const t=new We;return $e(t,h,new Map),N(t.restEncoder,0),{missing:a,update:t.toUint8Array()}}return null})(e,c,l),a=c.pendingStructs;if(a){for(const[t,e]of a.missing)if(e<On(c,t)){r=!0;break}if(h){for(const[t,e]of h.missing){const n=a.missing.get(t);(null==n||n>e)&&a.missing.set(t,e)}a.update=or([a.update,h.update])}}else c.pendingStructs=h;const d=Te(i,e,c);if(c.pendingDs){const t=new je(rt(c.pendingDs));ct(t.restDecoder);const n=Te(t,e,c);c.pendingDs=d&&n?or([d,n]):d||n}else c.pendingDs=d;if(r){const t=c.pendingStructs.update;c.pendingStructs=null,Ye(e.doc,t)}}),s,!1),Ye=(t,e,n,r=je)=>{const s=rt(e);He(s,t,n,new r(s))},Ke=(t,e,n)=>Ye(t,e,n,Fe),Ge=(t,e=new Uint8Array([0]),n=new We)=>{((t,e,n=new Map)=>{$e(t,e.store,n),Me(t,Ie(e.store))})(n,t,Ze(e));const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(cr(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===Je)return nr(r.map(((t,e)=>0===e?t:gr(t))));if(n.constructor===We)return or(r)}return r[0]},Xe=(t,e)=>Ge(t,e,new Je),qe=t=>{const e=new Map,n=ct(t.restDecoder);for(let r=0;r<n;r++){const n=ct(t.restDecoder),r=ct(t.restDecoder);e.set(n,r)}return e},Ze=t=>qe(new Ve(rt(t))),Qe=(t,e)=>(N(t.restEncoder,e.size),o(e.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([e,n])=>{N(t.restEncoder,e),N(t.restEncoder,n)})),t),tn=(t,e=new Be)=>(t instanceof Map?Qe(e,t):((t,e)=>{Qe(t,Mn(e.store))})(e,t),e.toUint8Array()),en=t=>tn(t,new ze);class nn{constructor(){this.l=[]}}const rn=()=>new nn,sn=(t,e)=>t.l.push(e),on=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter((t=>e!==t)),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},cn=(t,e,n)=>Vt(t.l,[e,n]);class ln{constructor(t,e){this.client=t,this.clock=e}}const hn=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,an=(t,e)=>new ln(t,e),dn=(t,e)=>{N(t,e.client),N(t,e.clock)},un=t=>an(ct(t),ct(t)),gn=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Q()},fn=(t,e)=>{for(;null!==e;){if(e.parent===t)return!0;e=e.parent._item}return!1};class pn{constructor(t,e,n,r=0){this.type=t,this.tname=e,this.item=n,this.assoc=r}}const wn=t=>{const e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),null!=t.assoc&&(e.assoc=t.assoc),e},mn=t=>new pn(null==t.type?null:an(t.type.client,t.type.clock),t.tname??null,null==t.item?null:an(t.item.client,t.item.clock),null==t.assoc?0:t.assoc);class yn{constructor(t,e,n=0){this.type=t,this.index=e,this.assoc=n}}const kn=(t,e,n)=>{let r=null,s=null;return null===t._item?s=gn(t):r=an(t._item.id.client,t._item.id.clock),new pn(r,s,e,n)},bn=(t,e,n=0)=>{let r=t._start;if(n<0){if(0===e)return kn(t,null,n);e--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>e)return kn(t,an(r.id.client,r.id.clock+e),n);e-=r.length}if(null===r.right&&n<0)return kn(t,r.lastId,n);r=r.right}return kn(t,null,n)},_n=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,c=t.assoc;let l=null,h=0;if(null!==s){if(On(r,s.client)<=s.clock)return null;const t=n?Ns(r,s):{item:Nn(r,s),diff:0},e=t.item;if(!(e instanceof js))return null;if(l=e.parent,null===l._item||!l._item.deleted){h=e.deleted||!e.countable?0:t.diff+(c>=0?0:1);let n=e.left;for(;null!==n;)!n.deleted&&n.countable&&(h+=n.length),n=n.left}}else{if(null!==o)l=e.get(o);else{if(null===i)throw Q();{if(On(r,i.client)<=i.clock)return null;const{item:t}=n?Ns(r,i):{item:Nn(r,i)};if(!(t instanceof js&&t.content instanceof Ls))return null;l=t.content.type}}h=c>=0?l._length:0}return((t,e,n=0)=>new yn(t,e,n))(l,h,t.assoc)},Sn=(t,e)=>t===e||null!==t&&null!==e&&t.tname===e.tname&&hn(t.item,e.item)&&hn(t.type,e.type)&&t.assoc===e.assoc;class En{constructor(t,e){this.ds=t,this.sv=e}}const Cn=(t,e=new Be)=>(Me(e,t.ds),Qe(e,t.sv),e.toUint8Array()),Dn=(t,e=new Pe(rt(t)))=>new En(Oe(e),qe(e)),vn=(t,e)=>new En(t,e),An=vn(Ue(),new Map),xn=(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!De(e.ds,t.id),Un=(t,e)=>{const s=n(t.meta,Un,r),i=t.doc.store;s.has(e)||(e.sv.forEach(((e,n)=>{e<On(i,n)&&Vn(t,an(n,e))})),Ce(t,e.ds,(t=>{})),s.add(e))};class In{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Mn=t=>{const e=new Map;return t.clients.forEach(((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)})),e},On=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},Tn=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw Q()}n.push(e)},Ln=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=a(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=a((n+r)/2)}throw Q()},Nn=(t,e)=>{const n=t.clients.get(e.client);return n[Ln(n,e.clock)]},Rn=(t,e,n)=>{const r=Ln(e,n),s=e[r];return s.id.clock<n&&s instanceof js?(e.splice(r+1,0,Vs(t,s,n-s.id.clock)),r+1):r},Vn=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Rn(t,n,e.clock)]},Fn=(t,e,n)=>{const r=e.clients.get(n.client),s=Ln(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==ps&&r.splice(s+1,0,Vs(t,i,n.clock-i.id.clock+1)),i},Pn=(t,e,n,r,s)=>{if(0===r)return;const i=n+r;let o,c=Rn(t,e,n);do{o=e[c++],i<o.id.clock+o.length&&Rn(t,e,i),s(o)}while(c<e.length&&e[c].id.clock<i)};class jn{constructor(t,e,n){this.doc=t,this.deleteSet=new Ee,this.beforeState=Mn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const zn=(t,e)=>!(0===e.deleteSet.clients.size&&!((t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1})(e.afterState,((t,n)=>e.beforeState.get(n)!==t)))&&(ve(e.deleteSet),((t,e)=>{$e(t,e.doc.store,e.beforeState)})(t,e),Me(t,e.deleteSet),!0),Jn=(t,e,s)=>{const i=e._item;(null===i||i.id.clock<(t.beforeState.get(i.id.client)||0)&&!i.deleted)&&n(t.changed,e,r).add(s)},Bn=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=t[--s-1])n instanceof js&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const i=e-s;return i&&t.splice(e+1-i,i),i},Wn=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const t=e.clients.get(r);for(let r=s.length-1;r>=0;r--){const i=s[r],o=i.clock+i.len;for(let r=Ln(t,i.clock),s=t[r];r<t.length&&s.id.clock<o;s=t[++r]){const s=t[r];if(i.clock+i.len<=s.id.clock)break;s instanceof js&&s.deleted&&!s.keep&&n(s)&&s.gc(e,!1)}}}},$n=(t,e)=>{t.clients.forEach(((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=u(r.length-1,1+Ln(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[t])t-=1+Bn(r,t)}}))},Hn=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{ve(i),n.afterState=Mn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const t=[];n.changed.forEach(((e,r)=>t.push((()=>{null!==r._item&&r._item.deleted||r._callObserver(n,e)})))),t.push((()=>{n.changedParentTypes.forEach(((t,e)=>{e._dEH.l.length>0&&(null===e._item||!e._item.deleted)&&((t=t.filter((t=>null===t.target._item||!t.target._item.deleted))).forEach((t=>{t.currentTarget=e,t._path=null})),t.sort(((t,e)=>t.path.length-e.path.length)),cn(e._dEH,t,n))}))})),t.push((()=>r.emit("afterTransaction",[n,r]))),Vt(t,[]),n._needFormattingCleanup&&ss(n)}finally{r.gc&&Wn(i,s,r.gcFilter),$n(i,s),n.afterState.forEach(((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=s.clients.get(e),n=g(Ln(t,r),1);for(let e=t.length-1;e>=n;)e-=1+Bn(t,e)}}));for(let t=o.length-1;t>=0;t--){const{client:e,clock:n}=o[t].id,r=s.clients.get(e),i=Ln(r,n);i+1<r.length&&Bn(r,i+1)>1||i>0&&Bn(r,i)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(me(ge,oe,"[yjs] ",ce,de,"Changed the client-id because another client seems to be using it."),r.clientID=Ne()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new Je;zn(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new We;zn(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:h}=n;(c.size>0||h.size>0||l.size>0)&&(c.forEach((t=>{t.clientID=r.clientID,null==t.collectionid&&(t.collectionid=r.collectionid),r.subdocs.add(t)})),h.forEach((t=>r.subdocs.delete(t))),r.emit("subdocs",[{loaded:l,added:c,removed:h},r,n]),h.forEach((t=>t.destroy()))),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):Hn(t,e+1)}}},Yn=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;null===t._transaction&&(i=!0,t._transaction=new jn(t,n,r),s.push(t._transaction),1===s.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const e=t._transaction===s[0];t._transaction=null,e&&Hn(s,0)}}return o};class Kn{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}const Gn=(t,e,n)=>{Ce(t,n.deletions,(t=>{t instanceof js&&e.scope.some((e=>fn(e,t)))&&Rs(t,!1)}))},Xn=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Yn(s,(n=>{for(;e.length>0&&null===t.currStackItem;){const r=s.store,o=e.pop(),c=new Set,l=[];let h=!1;Ce(n,o.insertions,(t=>{if(t instanceof js){if(null!==t.redone){let{item:e,diff:s}=Ns(r,t.id);s>0&&(e=Vn(n,an(e.id.client,e.id.clock+s))),t=e}!t.deleted&&i.some((e=>fn(e,t)))&&l.push(t)}})),Ce(n,o.deletions,(t=>{t instanceof js&&i.some((e=>fn(e,t)))&&!De(o.insertions,t.id)&&c.add(t)})),c.forEach((e=>{h=null!==Ps(n,e,c,o.insertions,t.ignoreRemoteMapChanges,t)||h}));for(let e=l.length-1;e>=0;e--){const r=l[e];t.deleteFilter(r)&&(r.delete(n),h=!0)}t.currStackItem=h?o:null}n.changed.forEach(((t,e)=>{t.has(null)&&e._searchMarker&&(e._searchMarker.length=0)})),r=n}),t);const o=t.currStackItem;if(null!=o){const e=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:e,origin:t},t]),t.currStackItem=null}return o};class qn extends l{constructor(t,{captureTimeout:e=500,captureTransaction:n=t=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:o=(c(t)?t[0].doc:t.doc)}={}){super(),this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=e,this.afterTransactionHandler=t=>{if(!(this.captureTransaction(t)&&this.scope.some((e=>t.changedParentTypes.has(e)))&&(this.trackedOrigins.has(t.origin)||t.origin&&this.trackedOrigins.has(t.origin.constructor))))return;const e=this.undoing,n=this.redoing,r=e?this.redoStack:this.undoStack;e?this.stopCapturing():n||this.clear(!1,!0);const s=new Ee;t.afterState.forEach(((e,n)=>{const r=t.beforeState.get(n)||0,i=e-r;i>0&&xe(s,n,r,i)}));const i=_t();let o=!1;if(this.lastChange>0&&i-this.lastChange<this.captureTimeout&&r.length>0&&!e&&!n){const e=r[r.length-1];e.deletions=Ae([e.deletions,t.deleteSet]),e.insertions=Ae([e.insertions,s])}else r.push(new Kn(t.deleteSet,s)),o=!0;e||n||(this.lastChange=i),Ce(t,t.deleteSet,(t=>{t instanceof js&&this.scope.some((e=>fn(e,t)))&&Rs(t,!0)}));const c=[{stackItem:r[r.length-1],origin:t.origin,type:e?"redo":"undo",changedParentTypes:t.changedParentTypes},this];o?this.emit("stack-item-added",c):this.emit("stack-item-updated",c)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",(()=>{this.destroy()}))}addToScope(t){(t=c(t)?t:[t]).forEach((t=>{this.scope.every((e=>e!==t))&&(t.doc!==this.doc&&ye("[yjs#509] Not same Y.Doc"),this.scope.push(t))}))}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact((n=>{t&&(this.undoStack.forEach((t=>Gn(n,this,t))),this.undoStack=[]),e&&(this.redoStack.forEach((t=>Gn(n,this,t))),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])}))}stopCapturing(){this.lastChange=0}undo(){let t;this.undoing=!0;try{t=Xn(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){let t;this.redoing=!0;try{t=Xn(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()}}class Zn{constructor(t,e){this.gen=function*(t){const e=ct(t.restDecoder);for(let n=0;n<e;n++){const e=ct(t.restDecoder),n=t.readClient();let r=ct(t.restDecoder);for(let s=0;s<e;s++){const e=t.readInfo();if(10===e){const e=ct(t.restDecoder);yield new Bs(an(n,r),e),r+=e}else if(31&e){const s=!(192&e),i=new js(an(n,r),null,(e&m)===m?t.readLeftID():null,null,(e&w)===w?t.readRightID():null,s?t.readParentInfo()?t.readString():t.readLeftID():null,!s||32&~e?null:t.readString(),zs(t,e));yield i,r+=i.length}else{const e=t.readLen();yield new ps(an(n,r),e),r+=e}}}}(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===Bs);return this.curr}}const Qn=(t,e=je)=>{const n=[],r=new e(rt(t)),s=new Zn(r,!1);for(let t=s.curr;null!==t;t=s.next())n.push(t);me("Structs: ",n);const i=Oe(r);me("DeleteSet: ",i)},tr=(t,e=je)=>{const n=[],r=new e(rt(t)),s=new Zn(r,!1);for(let t=s.curr;null!==t;t=s.next())n.push(t);return{structs:n,ds:Oe(r)}};class er{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const nr=t=>or(t,Fe,Je),rr=(t,e=Be,n=je)=>{const r=new e,s=new Zn(new n(rt(t)),!1);let i=s.curr;if(null!==i){let t=0,e=i.id.client,n=0!==i.id.clock,o=n?0:i.id.clock+i.length;for(;null!==i;i=s.next())e!==i.id.client&&(0!==o&&(t++,N(r.restEncoder,e),N(r.restEncoder,o)),e=i.id.client,o=0,n=0!==i.id.clock),i.constructor===Bs&&(n=!0),n||(o=i.id.clock+i.length);0!==o&&(t++,N(r.restEncoder,e),N(r.restEncoder,o));const c=I();return N(c,t),((t,e)=>{j(t,O(e))})(c,r.restEncoder),r.restEncoder=c,r.toUint8Array()}return N(r.restEncoder,0),r.toUint8Array()},sr=(t,e=je)=>{const n=new Map,r=new Map,s=new Zn(new e(rt(t)),!1);let i=s.curr;if(null!==i){let t=i.id.client,e=i.id.clock;for(n.set(t,e);null!==i;i=s.next())t!==i.id.client&&(r.set(t,e),n.set(i.id.client,i.id.clock),t=i.id.client),e=i.id.clock+i.length;r.set(t,e)}return{from:n,to:r}},ir=(t,e)=>{if(t.constructor===ps){const{client:n,clock:r}=t.id;return new ps(an(n,r+e),t.length-e)}if(t.constructor===Bs){const{client:n,clock:r}=t.id;return new Bs(an(n,r+e),t.length-e)}{const n=t,{client:r,clock:s}=n.id;return new js(an(r,s+e),null,an(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},or=(t,e=je,n=We)=>{if(1===t.length)return t[0];const r=t.map((t=>new e(rt(t))));let s=r.map((t=>new Zn(t,!0))),i=null;const o=new n,c=new er(o);for(;s=s.filter((t=>null!==t.curr)),s.sort(((t,e)=>{if(t.curr.id.client===e.curr.id.client){const n=t.curr.id.clock-e.curr.id.clock;return 0===n?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===Bs?1:-1:n}return e.curr.id.client-t.curr.id.client})),0!==s.length;){const t=s[0],e=t.curr.id.client;if(null!==i){let n=t.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=i.struct.id.clock+i.struct.length&&n.id.client>=i.struct.id.client;)n=t.next(),r=!0;if(null===n||n.id.client!==e||r&&n.id.clock>i.struct.id.clock+i.struct.length)continue;if(e!==i.struct.id.client)hr(c,i.struct,i.offset),i={struct:n,offset:0},t.next();else if(i.struct.id.clock+i.struct.length<n.id.clock)if(i.struct.constructor===Bs)i.struct.length=n.id.clock+n.length-i.struct.id.clock;else{hr(c,i.struct,i.offset);const t=n.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Bs(an(e,i.struct.id.clock+i.struct.length),t),offset:0}}else{const e=i.struct.id.clock+i.struct.length-n.id.clock;e>0&&(i.struct.constructor===Bs?i.struct.length-=e:n=ir(n,e)),i.struct.mergeWith(n)||(hr(c,i.struct,i.offset),i={struct:n,offset:0},t.next())}}else i={struct:t.curr,offset:0},t.next();for(let n=t.curr;null!==n&&n.id.client===e&&n.id.clock===i.struct.id.clock+i.struct.length&&n.constructor!==Bs;n=t.next())hr(c,i.struct,i.offset),i={struct:n,offset:0}}null!==i&&(hr(c,i.struct,i.offset),i=null),ar(c);const l=r.map((t=>Oe(t))),h=Ae(l);return Me(o,h),o.toUint8Array()},cr=(t,e,n=je,r=We)=>{const s=Ze(e),i=new r,o=new er(i),c=new n(rt(t)),l=new Zn(c,!1);for(;l.curr;){const t=l.curr,e=t.id.client,n=s.get(e)||0;if(l.curr.constructor!==Bs)if(t.id.clock+t.length>n)for(hr(o,t,g(n-t.id.clock,0)),l.next();l.curr&&l.curr.id.client===e;)hr(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===e&&l.curr.id.clock+l.curr.length<=n;)l.next();else l.next()}ar(o);const h=Oe(c);return Me(i,h),i.toUint8Array()},lr=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:O(t.encoder.restEncoder)}),t.encoder.restEncoder=I(),t.written=0)},hr=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&lr(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),N(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},ar=t=>{lr(t);const e=t.encoder.restEncoder;N(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];N(e,r.written),j(e,r.restEncoder)}},dr=(t,e,n,r)=>{const s=new n(rt(t)),i=new Zn(s,!1),o=new r,c=new er(o);for(let t=i.curr;null!==t;t=i.next())hr(c,e(t),0);ar(c);const l=Oe(s);return Me(o,l),o.toUint8Array()},ur=({formatting:e=!0,subdocs:r=!0,yxml:s=!0}={})=>{let i=0;const o=t(),c=t(),l=t(),h=t();return h.set(null,null),t=>{switch(t.constructor){case ps:case Bs:return t;case js:{const a=t,d=a.content;switch(d.constructor){case ms:break;case Ls:if(s){const t=d.type;t instanceof as&&(t.nodeName=n(c,t.nodeName,(()=>"node-"+i))),t instanceof us&&(t.hookName=n(c,t.hookName,(()=>"hook-"+i)))}break;case Cs:{const t=d;t.arr=t.arr.map((()=>i));break}case ws:d.content=new Uint8Array([i]);break;case ks:{const t=d;r&&(t.opts={},t.doc.guid=i+"");break}case bs:d.embed={};break;case _s:{const t=d;e&&(t.key=n(l,t.key,(()=>i+"")),t.value=n(h,t.value,(()=>({i:i}))));break}case Ss:{const t=d;t.arr=t.arr.map((()=>i));break}case Ds:{const t=d;t.str=x(i%10+"",t.str.length);break}default:Q()}return a.parentSub&&(a.parentSub=n(o,a.parentSub,(()=>i+""))),i++,t}default:Q()}}},gr=t=>dr(t,Ft,je,Je),fr="You must not compute changes after the event-handler fired.";class pr{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=wr(this.currentTarget,this.target))}deletes(t){return De(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw q(fr);const t=new Map,e=this.target;this.transaction.changed.get(e).forEach((n=>{if(null!==n){const r=e._map.get(n);let i,o;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;i="delete",o=s(t.content.getContent())}else null!==t&&this.deletes(t)?(i="update",o=s(t.content.getContent())):(i="add",o=void 0)}else{if(!this.deletes(r))return;i="delete",o=s(r.content.getContent())}t.set(n,{action:i,oldValue:o})}})),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){if(0===this.transaction.doc._transactionCleanups.length)throw q(fr);const e=this.target,n=r(),s=r(),i=[];t={added:n,deleted:s,delta:i,keys:this.keys};if(this.transaction.changed.get(e).has(null)){let t=null;const r=()=>{t&&i.push(t)};for(let i=e._start;null!==i;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&(null!==t&&void 0!==t.delete||(r(),t={delete:0}),t.delete+=i.length,s.add(i)):this.adds(i)?(null!==t&&void 0!==t.insert||(r(),t={insert:[]}),t.insert=t.insert.concat(i.content.getContent()),n.add(i)):(null!==t&&void 0!==t.retain||(r(),t={retain:0}),t.retain+=i.length);null!==t&&void 0===t.retain&&r()}this._changes=t}return t}}const wr=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)!r.deleted&&r.countable&&(t+=r.length),r=r.right;n.unshift(t)}e=e._item.parent}return n},mr=()=>{ye("Invalid access: Add Yjs type to a document before reading data.")};let yr=0;class kr{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=yr++}}const br=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=yr++},_r=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce(((t,n)=>d(e-t.index)<d(e-n.index)?t:n));let r=t._start,s=0;for(null!==n&&(r=n.p,s=n.index,(t=>{t.timestamp=yr++})(n));null!==r.right&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;null!==r.left&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return null!==n&&d(n.index-s)<r.parent.length/80?(br(n,r,s),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce(((t,e)=>t.timestamp<e.timestamp?t:e));return br(r,e,n),r}{const r=new kr(e,n);return t.push(r),r}})(t._searchMarker,r,s)},Sr=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let e=s.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(s.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}s.p=e,e.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=g(e,s.index+n))}},Er=(t,e,r)=>{const s=t,i=e.changedParentTypes;for(;n(i,t,(()=>[])).push(r),null!==t._item;)t=t._item.parent;cn(s._eH,r,e)};class Cr{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=rn(),this._dEH=rn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw Z()}clone(){throw Z()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){sn(this._eH,t)}observeDeep(t){sn(this._dEH,t)}unobserve(t){on(this._eH,t)}unobserveDeep(t){on(this._dEH,t)}toJSON(){}}const Dr=(t,e,n)=>{t.doc??mr(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;null!==i&&r>0;){if(i.countable&&!i.deleted){const t=i.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)s.push(t[n]),r--;e=0}}i=i.right}return s},vr=t=>{t.doc??mr();const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},Ar=(t,e)=>{let n=0,r=t._start;for(t.doc??mr();null!==r;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let r=0;r<s.length;r++)e(s[r],n++,t)}r=r.right}},xr=(t,e)=>{const n=[];return Ar(t,((r,s)=>{n.push(e(r,s,t))})),n},Ur=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},Ir=(t,e)=>{t.doc??mr();const n=_r(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Mr=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,c=i.store,l=null===n?e._start:n.right;let h=[];const a=()=>{h.length>0&&(s=new js(an(o,On(c,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Cs(h)),s.integrate(t,0),h=[])};r.forEach((n=>{if(null===n)h.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(n);break;default:switch(a(),n.constructor){case Uint8Array:case ArrayBuffer:s=new js(an(o,On(c,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ws(new Uint8Array(n))),s.integrate(t,0);break;case Re:s=new js(an(o,On(c,o)),s,s&&s.lastId,l,l&&l.id,e,null,new ks(n)),s.integrate(t,0);break;default:if(!(n instanceof Cr))throw new Error("Unexpected content type in insert operation");s=new js(an(o,On(c,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Ls(n)),s.integrate(t,0)}}})),a()},Or=()=>q("Length exceeded!"),Tr=(t,e,n,r)=>{if(n>e._length)throw Or();if(0===n)return e._searchMarker&&Sr(e._searchMarker,n,r.length),Mr(t,e,null,r);const s=n,i=_r(e,n);let o=e._start;for(null!==i&&(o=i.p,0===(n-=i.index)&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));null!==o;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Vn(t,an(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Sr(e._searchMarker,s,r.length),Mr(t,e,o,r)},Lr=(t,e,n,r)=>{if(0===r)return;const s=n,i=r,o=_r(e,n);let c=e._start;for(null!==o&&(c=o.p,n-=o.index);null!==c&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&Vn(t,an(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&null!==c;)c.deleted||(r<c.length&&Vn(t,an(c.id.client,c.id.clock+r)),c.delete(t),r-=c.length),c=c.right;if(r>0)throw Or();e._searchMarker&&Sr(e._searchMarker,s,-i+r)},Nr=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},Rr=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let c;if(null==r)c=new Cs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:c=new Cs([r]);break;case Uint8Array:c=new ws(r);break;case Re:c=new ks(r);break;default:if(!(r instanceof Cr))throw new Error("Unexpected content type");c=new Ls(r)}new js(an(o,On(i.store,o)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},Vr=(t,e)=>{t.doc??mr();const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},Fr=t=>{const e={};return t.doc??mr(),t._map.forEach(((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])})),e},Pr=(t,e)=>{t.doc??mr();const n=t._map.get(e);return void 0!==n&&!n.deleted},jr=(t,e)=>{const n={};return t._map.forEach(((t,r)=>{let s=t;for(;null!==s&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;null!==s&&xn(s,e)&&(n[r]=s.content.getContent()[s.length-1])})),n},zr=t=>{return t.doc??mr(),e=t._map.entries(),n=t=>!t[1].deleted,be((()=>{let t;do{t=e.next()}while(!t.done&&!n(t.value));return t}));var e,n};class Jr extends pr{}class Br extends Cr{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const e=new Br;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Br}clone(){const t=new Br;return t.insert(0,this.toArray().map((t=>t instanceof Cr?t.clone():t))),t}get length(){return this.doc??mr(),this._length}_callObserver(t,e){super._callObserver(t,e),Er(this,t,new Jr(this,t))}insert(t,e){null!==this.doc?Yn(this.doc,(n=>{Tr(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}push(t){null!==this.doc?Yn(this.doc,(e=>{((t,e,n)=>{let r=(e._searchMarker||[]).reduce(((t,e)=>e.index>t.index?e:t),{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;Mr(t,e,r,n)})(e,this,t)})):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?Yn(this.doc,(n=>{Lr(n,this,t,e)})):this._prelimContent.splice(t,e)}get(t){return Ir(this,t)}toArray(){return vr(this)}slice(t=0,e=this.length){return Dr(this,t,e)}toJSON(){return this.map((t=>t instanceof Cr?t.toJSON():t))}map(t){return xr(this,t)}forEach(t){Ar(this,t)}[Symbol.iterator](){return Ur(this)}_write(t){t.writeTypeRef(As)}}class Wr extends pr{constructor(t,e,n){super(t,e),this.keysChanged=n}}class $r extends Cr{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach(((t,e)=>{this.set(e,t)})),this._prelimContent=null}_copy(){return new $r}clone(){const t=new $r;return this.forEach(((e,n)=>{t.set(n,e instanceof Cr?e.clone():e)})),t}_callObserver(t,e){Er(this,t,new Wr(this,t,e))}toJSON(){this.doc??mr();const t={};return this._map.forEach(((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof Cr?r.toJSON():r}})),t}get size(){return[...zr(this)].length}keys(){return _e(zr(this),(t=>t[0]))}values(){return _e(zr(this),(t=>t[1].content.getContent()[t[1].length-1]))}entries(){return _e(zr(this),(t=>[t[0],t[1].content.getContent()[t[1].length-1]]))}forEach(t){this.doc??mr(),this._map.forEach(((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)}))}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?Yn(this.doc,(e=>{Nr(e,this,t)})):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?Yn(this.doc,(n=>{Rr(n,this,t,e)})):this._prelimContent.set(t,e),e}get(t){return Vr(this,t)}has(t){return Pr(this,t)}clear(){null!==this.doc?Yn(this.doc,(t=>{this.forEach((function(e,n,r){Nr(t,r,n)}))})):this._prelimContent.clear()}_write(t){t.writeTypeRef(xs)}}const Hr=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&((t,e)=>t===e||Tt(t)===Tt(e)&&((t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0})(t,((t,n)=>(void 0!==t||Lt(e,n))&&e[n]===t)))(t,e);class Yr{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&Q(),this.right.content.constructor===_s)this.right.deleted||qr(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const Kr=(t,e,n)=>{for(;null!==e.right&&n>0;){if(e.right.content.constructor===_s)e.right.deleted||qr(e.currentAttributes,e.right.content);else e.right.deleted||(n<e.right.length&&Vn(t,an(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);e.left=e.right,e.right=e.right.right}return e},Gr=(t,e,n,r)=>{const s=new Map,i=r?_r(e,n):null;if(i){const e=new Yr(i.p.left,i.p,i.index,s);return Kr(t,e,n-i.index)}{const r=new Yr(null,e._start,0,s);return Kr(t,r,n)}},Xr=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===_s&&Hr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach(((r,o)=>{const c=n.left,l=n.right,h=new js(an(i,On(s.store,i)),c,c&&c.lastId,l,l&&l.id,e,null,new _s(o,r));h.integrate(t,0),n.right=h,n.forward()}))},qr=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},Zr=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===_s&&Hr(e[t.right.content.key]??null,t.right.content.value));)t.forward()},Qr=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const c in r){const l=r[c],h=n.currentAttributes.get(c)??null;if(!Hr(h,l)){o.set(c,h);const{left:r,right:a}=n;n.right=new js(an(i,On(s.store,i)),r,r&&r.lastId,a,a&&a.id,e,null,new _s(c,l)),n.right.integrate(t,0),n.forward()}}return o},ts=(t,e,n,r,s)=>{n.currentAttributes.forEach(((t,e)=>{void 0===s[e]&&(s[e]=null)}));const i=t.doc,o=i.clientID;Zr(n,s);const c=Qr(t,e,n,s),l=r.constructor===String?new Ds(r):r instanceof Cr?new Ls(r):new bs(r);let{left:h,right:a,index:d}=n;e._searchMarker&&Sr(e._searchMarker,n.index,l.getLength()),a=new js(an(o,On(i.store,o)),h,h&&h.lastId,a,a&&a.id,e,null,l),a.integrate(t,0),n.right=a,n.index=d,n.forward(),Xr(t,e,n,c)},es=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;Zr(n,s);const c=Qr(t,e,n,s);t:for(;null!==n.right&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===_s));){if(!n.right.deleted)switch(n.right.content.constructor){case _s:{const{key:e,value:i}=n.right.content,o=s[e];if(void 0!==o){if(Hr(o,i))c.delete(e);else{if(0===r)break t;c.set(e,i)}n.right.delete(t)}else n.currentAttributes.set(e,i);break}default:r<n.right.length&&Vn(t,an(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let s="";for(;r>0;r--)s+="\n";n.right=new js(an(o,On(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ds(s)),n.right.integrate(t,0),n.forward()}Xr(t,e,n,c)},ns=(e,n,r,s,i)=>{let o=n;const c=t();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===_s){const t=o.content;c.set(t.key,t)}o=o.right}let l=0,h=!1;for(;n!==o;){if(r===n&&(h=!0),!n.deleted){const t=n.content;switch(t.constructor){case _s:{const{key:r,value:o}=t,a=s.get(r)??null;c.get(r)===t&&a!==o||(n.delete(e),l++,h||(i.get(r)??null)!==o||a===o||(null===a?i.delete(r):i.set(r,a))),h||n.deleted||qr(i,t);break}}}n=n.right}return l},rs=n=>{let r=0;return Yn(n.doc,(s=>{let i=n._start,o=n._start,c=t();const l=e(c);for(;o;){if(!1===o.deleted)if(o.content.constructor===_s)qr(l,o.content);else r+=ns(s,i,o,c,l),c=e(l),i=o;o=o.right}})),r},ss=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&Pn(t,n.store.clients.get(r),i,s,(t=>{t.deleted||t.content.constructor!==_s||t.constructor===ps||e.add(t.parent)}))}Yn(n,(n=>{Ce(t,t.deleteSet,(t=>{if(t instanceof ps||!t.parent._hasFormatting||e.has(t.parent))return;const r=t.parent;t.content.constructor===_s?e.add(r):((t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===_s){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(n,t)}));for(const t of e)rs(t)}))},is=(t,n,r)=>{const s=r,i=e(n.currentAttributes),o=n.right;for(;r>0&&null!==n.right;){if(!1===n.right.deleted)switch(n.right.content.constructor){case Ls:case bs:case Ds:r<n.right.length&&Vn(t,an(n.right.id.client,n.right.id.clock+r)),r-=n.right.length,n.right.delete(t)}n.forward()}o&&ns(t,o,n.right,i,n.currentAttributes);const c=(n.left||n.right).parent;return c._searchMarker&&Sr(c._searchMarker,n.index,-s+r),n};class os extends pr{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)}))}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];Yn(t,(t=>{const n=new Map,r=new Map;let s=this.target._start,i=null;const o={};let c="",l=0,h=0;const a=()=>{if(null!==i){let t=null;switch(i){case"delete":h>0&&(t={delete:h}),h=0;break;case"insert":("object"==typeof c||c.length>0)&&(t={insert:c},n.size>0&&(t.attributes={},n.forEach(((e,n)=>{null!==e&&(t.attributes[n]=e)})))),c="";break;case"retain":l>0&&(t={retain:l},(t=>{for(const e in t)return!1;return!0})(o)||(t.attributes=Ut({},o))),l=0}t&&e.push(t),i=null}};for(;null!==s;){switch(s.content.constructor){case Ls:case bs:this.adds(s)?this.deletes(s)||(a(),i="insert",c=s.content.getContent()[0],a()):this.deletes(s)?("delete"!==i&&(a(),i="delete"),h+=1):s.deleted||("retain"!==i&&(a(),i="retain"),l+=1);break;case Ds:this.adds(s)?this.deletes(s)||("insert"!==i&&(a(),i="insert"),c+=s.content.str):this.deletes(s)?("delete"!==i&&(a(),i="delete"),h+=s.length):s.deleted||("retain"!==i&&(a(),i="retain"),l+=s.length);break;case _s:{const{key:e,value:c}=s.content;if(this.adds(s)){if(!this.deletes(s)){const l=n.get(e)??null;Hr(l,c)?null!==c&&s.delete(t):("retain"===i&&a(),Hr(c,r.get(e)??null)?delete o[e]:o[e]=c)}}else if(this.deletes(s)){r.set(e,c);const t=n.get(e)??null;Hr(t,c)||("retain"===i&&a(),o[e]=t)}else if(!s.deleted){r.set(e,c);const n=o[e];void 0!==n&&(Hr(n,c)?null!==n&&s.delete(t):("retain"===i&&a(),null===c?delete o[e]:o[e]=c))}s.deleted||("insert"===i&&a(),qr(n,s.content));break}}s=s.right}for(a();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}})),this._delta=e}return this._delta}}class cs extends Cr{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??mr(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((t=>t()))}catch(t){console.error(t)}this._pending=null}_copy(){return new cs}clone(){const t=new cs;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);const n=new os(this,t,e);Er(this,t,n),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??mr();let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===Ds&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?Yn(this.doc,(n=>{const r=new Yr(null,this._start,0,new Map);for(let s=0;s<t.length;s++){const i=t[s];if(void 0!==i.insert){const o=e||"string"!=typeof i.insert||s!==t.length-1||null!==r.right||"\n"!==i.insert.slice(-1)?i.insert:i.insert.slice(0,-1);("string"!=typeof o||o.length>0)&&ts(n,this,r,o,i.attributes||{})}else void 0!==i.retain?es(n,this,r,i.retain,i.attributes||{}):void 0!==i.delete&&is(n,r,i.delete)}})):this._pending.push((()=>this.applyDelta(t)))}toDelta(t,e,n){this.doc??mr();const r=[],s=new Map,i=this.doc;let o="",c=this._start;function l(){if(o.length>0){const t={};let e=!1;s.forEach(((n,r)=>{e=!0,t[r]=n}));const n={insert:o};e&&(n.attributes=t),r.push(n),o=""}}const h=()=>{for(;null!==c;){if(xn(c,t)||void 0!==e&&xn(c,e))switch(c.content.constructor){case Ds:{const r=s.get("ychange");void 0===t||xn(c,t)?void 0===e||xn(c,e)?void 0!==r&&(l(),s.delete("ychange")):void 0!==r&&r.user===c.id.client&&"added"===r.type||(l(),s.set("ychange",n?n("added",c.id):{type:"added"})):void 0!==r&&r.user===c.id.client&&"removed"===r.type||(l(),s.set("ychange",n?n("removed",c.id):{type:"removed"})),o+=c.content.str;break}case Ls:case bs:{l();const t={insert:c.content.getContent()[0]};if(s.size>0){const e={};t.attributes=e,s.forEach(((t,n)=>{e[n]=t}))}r.push(t);break}case _s:xn(c,t)&&(l(),qr(s,c.content))}c=c.right}l()};return t||e?Yn(i,(n=>{t&&Un(n,t),e&&Un(n,e),h()}),"cleanup"):h(),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?Yn(r,(r=>{const s=Gr(r,this,t,!n);n||(n={},s.currentAttributes.forEach(((t,e)=>{n[e]=t}))),ts(r,this,s,e,n)})):this._pending.push((()=>this.insert(t,e,n)))}insertEmbed(t,e,n){const r=this.doc;null!==r?Yn(r,(r=>{const s=Gr(r,this,t,!n);ts(r,this,s,e,n||{})})):this._pending.push((()=>this.insertEmbed(t,e,n||{})))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?Yn(n,(n=>{is(n,Gr(n,this,t,!0),e)})):this._pending.push((()=>this.delete(t,e)))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?Yn(r,(r=>{const s=Gr(r,this,t,!1);null!==s.right&&es(r,this,s,e,n)})):this._pending.push((()=>this.format(t,e,n)))}removeAttribute(t){null!==this.doc?Yn(this.doc,(e=>{Nr(e,this,t)})):this._pending.push((()=>this.removeAttribute(t)))}setAttribute(t,e){null!==this.doc?Yn(this.doc,(n=>{Rr(n,this,t,e)})):this._pending.push((()=>this.setAttribute(t,e)))}getAttribute(t){return Vr(this,t)}getAttributes(){return Fr(this)}_write(t){t.writeTypeRef(Us)}}class ls{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??mr()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==as&&e.constructor!==hs||null===e._start)for(;null!==t;){if(null!==t.right){t=t.right;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class hs extends Cr{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new hs}clone(){const t=new hs;return t.insert(0,this.toArray().map((t=>t instanceof Cr?t.clone():t))),t}get length(){return this.doc??mr(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new ls(this,t)}querySelector(t){t=t.toUpperCase();const e=new ls(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)),n=e.next();return n.done?null:n.value}querySelectorAll(t){return t=t.toUpperCase(),o(new ls(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)))}_callObserver(t,e){Er(this,t,new ds(this,e,t))}toString(){return xr(this,(t=>t.toString())).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Ar(this,(s=>{r.insertBefore(s.toDOM(t,e,n),null)})),r}insert(t,e){null!==this.doc?Yn(this.doc,(n=>{Tr(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)Yn(this.doc,(n=>{const r=t&&t instanceof Cr?t._item:t;Mr(n,this,r,e)}));else{const n=this._prelimContent,r=null===t?0:n.findIndex((e=>e===t))+1;if(0===r&&null!==t)throw q("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?Yn(this.doc,(n=>{Lr(n,this,t,e)})):this._prelimContent.splice(t,e)}toArray(){return vr(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Ir(this,t)}slice(t=0,e=this.length){return Dr(this,t,e)}forEach(t){Ar(this,t)}_write(t){t.writeTypeRef(Ms)}}class as extends hs{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach(((t,e)=>{this.setAttribute(e,t)})),this._prelimAttrs=null}_copy(){return new as(this.nodeName)}clone(){const t=new as(this.nodeName);return((t,e)=>{for(const n in t)e(t[n],n)})(this.getAttributes(),((e,n)=>{"string"==typeof e&&t.setAttribute(n,e)})),t.insert(0,this.toArray().map((t=>t instanceof Cr?t.clone():t))),t}toString(){const t=this.getAttributes(),e=[],n=[];for(const e in t)n.push(e);n.sort();const r=n.length;for(let s=0;s<r;s++){const r=n[s];e.push(r+'="'+t[r]+'"')}const s=this.nodeName.toLocaleLowerCase();return`<${s}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${s}>`}removeAttribute(t){null!==this.doc?Yn(this.doc,(e=>{Nr(e,this,t)})):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?Yn(this.doc,(n=>{Rr(n,this,t,e)})):this._prelimAttrs.set(t,e)}getAttribute(t){return Vr(this,t)}hasAttribute(t){return Pr(this,t)}getAttributes(t){return t?jr(this,t):Fr(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),s=this.getAttributes();for(const t in s){const e=s[t];"string"==typeof e&&r.setAttribute(t,e)}return Ar(this,(s=>{r.appendChild(s.toDOM(t,e,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(Is),t.writeKey(this.nodeName)}}class ds extends pr{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)}))}}class us extends $r{constructor(t){super(),this.hookName=t}_copy(){return new us(this.hookName)}clone(){const t=new us(this.hookName);return this.forEach(((e,n)=>{t.set(n,e)})),t}toDOM(t=document,e={},n){const r=e[this.hookName];let s;return s=void 0!==r?r.createDom(this):document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(s,this),s}_write(t){t.writeTypeRef(Os),t.writeKey(this.hookName)}}class gs extends cs{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 gs}clone(){const t=new gs;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){const r=t.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map((t=>{const e=[];for(const n in t.attributes){const r=[];for(const e in t.attributes[n])r.push({key:e,value:t.attributes[n][e]});r.sort(((t,e)=>t.key<e.key?-1:1)),e.push({nodeName:n,attrs:r})}e.sort(((t,e)=>t.nodeName<e.nodeName?-1:1));let n="";for(let t=0;t<e.length;t++){const r=e[t];n+=`<${r.nodeName}`;for(let t=0;t<r.attrs.length;t++){const e=r.attrs[t];n+=` ${e.key}="${e.value}"`}n+=">"}n+=t.insert;for(let t=e.length-1;t>=0;t--)n+=`</${e[t].nodeName}>`;return n})).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Ts)}}class fs{constructor(t,e){this.id=t,this.length=e}get deleted(){throw Z()}mergeWith(t){return!1}write(t,e,n){throw Z()}integrate(t,e){throw Z()}}class ps extends fs{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),Tn(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ws{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ws(this.content)}splice(t){throw Z()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}class ms{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ms(this.len)}splice(t){const e=new ms(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){xe(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}const ys=(t,e)=>new Re({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ks{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 e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ks(ys(this.doc.guid,this.opts))}splice(t){throw Z()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class bs{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new bs(this.embed)}splice(t){throw Z()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}class _s{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new _s(this.key,this.value)}splice(t){throw Z()}mergeWith(t){return!1}integrate(t,e){const n=e.parent;n._searchMarker=null,n._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}class Ss{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ss(this.arr)}splice(t){const e=new Ss(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeString(void 0===e?"undefined":JSON.stringify(e))}}getRef(){return 2}}const Es="development"===Wt("node_env");class Cs{constructor(t){this.arr=t,Es&&Rt(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Cs(this.arr)}splice(t){const e=new Cs(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}}class Ds{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ds(this.str)}splice(t){const e=new Ds(this.str.slice(t));this.str=this.str.slice(0,t);const n=this.str.charCodeAt(t-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}}const vs=[t=>new Br,t=>new $r,t=>new cs,t=>new as(t.readKey()),t=>new hs,t=>new us(t.readKey()),t=>new gs],As=0,xs=1,Us=2,Is=3,Ms=4,Os=5,Ts=6;class Ls{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Ls(this.type._copy())}splice(t){throw Z()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach((e=>{e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t)})),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((e=>{for(;null!==e;)e.gc(t,!0),e=e.left})),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const Ns=(t,e)=>{let n,r=e,s=0;do{s>0&&(r=an(r.client,r.clock+s)),n=Nn(t,r),s=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof js);return{item:n,diff:s}},Rs=(t,e)=>{for(;null!==t&&t.keep!==e;)t.keep=e,t=t.parent._item},Vs=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new js(an(r,s+n),e,an(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),null!==e.redone&&(i.redone=an(e.redone.client,e.redone.clock+n)),e.right=i,null!==i.right&&(i.right.left=i),t._mergeStructs.push(i),null!==i.parentSub&&null===i.right&&i.parent._map.set(i.parentSub,i),e.length=n,i},Fs=(t,e)=>((t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1})(t,(t=>De(t.deletions,e))),Ps=(t,e,n,r,s,i)=>{const o=t.doc,c=o.store,l=o.clientID,h=e.redone;if(null!==h)return Vn(t,h);let a,d=e.parent._item,u=null;if(null!==d&&!0===d.deleted){if(null===d.redone&&(!n.has(d)||null===Ps(t,d,n,r,s,i)))return null;for(;null!==d.redone;)d=Vn(t,d.redone)}const g=null===d?e.parent:d.content.type;if(null===e.parentSub){for(u=e.left,a=e;null!==u;){let e=u;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:Vn(t,e.redone);if(null!==e&&e.parent._item===d){u=e;break}u=u.left}for(;null!==a;){let e=a;for(;null!==e&&e.parent._item!==d;)e=null===e.redone?null:Vn(t,e.redone);if(null!==e&&e.parent._item===d){a=e;break}a=a.right}}else if(a=null,e.right&&!s){for(u=e;null!==u&&null!==u.right&&(u.right.redone||De(r,u.right.id)||Fs(i.undoStack,u.right.id)||Fs(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=Vn(t,u.redone);if(u&&null!==u.right)return null}else u=g._map.get(e.parentSub)||null;const f=On(c,l),p=an(l,f),w=new js(p,u,u&&u.lastId,a,a&&a.id,g,e.parentSub,e.content.copy());return e.redone=p,Rs(w,!0),w.integrate(t,0),w};class js extends fs{constructor(t,e,n,r,s,i,o,c){super(t,c.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=s,this.parent=i,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(t){(8&this.info)>0!==t&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=On(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=On(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ln&&this.id.client!==this.parent.client&&this.parent.clock>=On(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Fn(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Vn(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ps||this.right&&this.right.constructor===ps)this.parent=null;else if(this.parent){if(this.parent.constructor===ln){const t=Nn(e,this.parent);t.constructor===ps?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===js&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===js&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=Fn(t,t.doc.store,an(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,s=new Set;for(;null!==e&&e!==this.right;){if(s.add(e),r.add(e),hn(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(hn(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!s.has(Nn(t.doc.store,e.origin)))break;r.has(Nn(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Tn(t.doc.store,this),this.content.integrate(t,this),Jn(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new ps(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:an(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&hn(t.origin,this.lastId)&&this.right===t&&hn(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach((e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))})),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),xe(t.deleteSet,this.id.client,this.id.clock,this.length),Jn(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw Q();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[Ln(r,e.id.clock)]=n})(t,this,new ps(this.id,this.length)):this.content=new ms(this.length)}write(t,e){const n=e>0?an(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,s=this.parentSub,i=31&this.content.getRef()|(null===n?0:m)|(null===r?0:w)|(null===s?0:32);if(t.writeInfo(i),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=gn(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===ln?(t.writeParentInfo(!1),t.writeLeftID(e)):Q();null!==s&&t.writeString(s)}this.content.write(t,e)}}const zs=(t,e)=>Js[31&e](t),Js=[()=>{Q()},t=>new ms(t.readLen()),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const e=t.readString();"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return new Ss(n)},t=>new ws(t.readBuf()),t=>new Ds(t.readString()),t=>new bs(t.readJSON()),t=>new _s(t.readKey(),t.readJSON()),t=>new Ls(vs[t.readTypeRef()](t)),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Cs(n)},t=>new ks(ys(t.readString(),t.readAny())),()=>{Q()}];class Bs extends fs{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){Q()}write(t,e){t.writeInfo(10),N(t.restEncoder,this.length-e)}getMissing(t,e){return null}}const Ws="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$s="__ $YJS$ __";!0===Ws[$s]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ws[$s]=!0;var Hs=Object.freeze({__proto__:null,AbsolutePosition:yn,AbstractConnector:class extends l{constructor(t,e){super(),this.doc=t,this.awareness=e}},AbstractStruct:fs,AbstractType:Cr,Array:Br,ContentAny:Cs,ContentBinary:ws,ContentDeleted:ms,ContentDoc:ks,ContentEmbed:bs,ContentFormat:_s,ContentJSON:Ss,ContentString:Ds,ContentType:Ls,Doc:Re,GC:ps,ID:ln,Item:js,Map:$r,PermanentUserData:class{constructor(t,e=t.getMap("users")){const n=new Map;this.yusers=e,this.doc=t,this.clients=new Map,this.dss=n;const r=(t,e)=>{const n=t.get("ds"),r=t.get("ids"),s=t=>this.clients.set(t,e);n.observe((t=>{t.changes.added.forEach((t=>{t.content.getContent().forEach((t=>{t instanceof Uint8Array&&this.dss.set(e,Ae([this.dss.get(e)||Ue(),Oe(new Ve(rt(t)))]))}))}))})),this.dss.set(e,Ae(n.map((t=>Oe(new Ve(rt(t))))))),r.observe((t=>t.changes.added.forEach((t=>t.content.getContent().forEach(s))))),r.forEach(s)};e.observe((t=>{t.keysChanged.forEach((t=>r(e.get(t),t)))})),e.forEach(r)}setUserMapping(t,e,n,{filter:r=()=>!0}={}){const s=this.yusers;let i=s.get(n);i||(i=new $r,i.set("ids",new Br),i.set("ds",new Br),s.set(n,i)),i.get("ids").push([e]),s.observe((t=>{setTimeout((()=>{const t=s.get(n);if(t!==i){i=t,this.clients.forEach(((t,e)=>{n===t&&i.get("ids").push([e])}));const e=new ze,r=this.dss.get(n);r&&(Me(e,r),i.get("ds").push([e.toUint8Array()]))}}),0)})),t.on("afterTransaction",(t=>{setTimeout((()=>{const e=i.get("ds"),n=t.deleteSet;if(t.local&&n.clients.size>0&&r(t,n)){const t=new ze;Me(t,n),e.push([t.toUint8Array()])}}))}))}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(const[e,n]of this.dss.entries())if(De(n,t))return e;return null}},RelativePosition:pn,Skip:Bs,Snapshot:En,Text:cs,Transaction:jn,UndoManager:qn,UpdateDecoderV1:Fe,UpdateDecoderV2:je,UpdateEncoderV1:Je,UpdateEncoderV2:We,XmlElement:as,XmlFragment:hs,XmlHook:us,XmlText:gs,YArrayEvent:Jr,YEvent:pr,YMapEvent:Wr,YTextEvent:os,YXmlEvent:ds,applyUpdate:Ke,applyUpdateV2:Ye,cleanupYTextFormatting:rs,compareIDs:hn,compareRelativePositions:Sn,convertUpdateFormatV1ToV2:t=>dr(t,Ft,Fe,We),convertUpdateFormatV2ToV1:gr,createAbsolutePositionFromRelativePosition:_n,createDeleteSet:Ue,createDeleteSetFromStructStore:Ie,createDocFromSnapshot:(t,e,n=new Re)=>{if(t.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");const{sv:r,ds:s}=e,i=new We;return t.transact((e=>{let n=0;r.forEach((t=>{t>0&&n++})),N(i.restEncoder,n);for(const[n,s]of r){if(0===s)continue;s<On(t.store,n)&&Vn(e,an(n,s));const r=t.store.clients.get(n)||[],o=Ln(r,s-1);N(i.restEncoder,o+1),i.writeClient(n),N(i.restEncoder,0);for(let t=0;t<=o;t++)r[t].write(i,0)}Me(i,s)})),Ye(n,i.toUint8Array(),"snapshot"),n},createID:an,createRelativePositionFromJSON:mn,createRelativePositionFromTypeIndex:bn,createSnapshot:vn,decodeRelativePosition:t=>(t=>{let e=null,n=null,r=null;switch(ct(t)){case 0:r=un(t);break;case 1:n=ht(t);break;case 2:e=un(t)}const s=st(t)?lt(t):0;return new pn(e,n,r,s)})(rt(t)),decodeSnapshot:t=>Dn(t,new Ve(rt(t))),decodeSnapshotV2:Dn,decodeStateVector:Ze,decodeUpdate:t=>tr(t,Fe),decodeUpdateV2:tr,diffUpdate:(t,e)=>cr(t,e,Fe,Je),diffUpdateV2:cr,emptySnapshot:An,encodeRelativePosition:t=>{const e=I();return((t,e)=>{const{type:n,tname:r,item:s,assoc:i}=e;if(null!==s)N(t,0),dn(t,s);else if(null!==r)L(t,1),P(t,r);else{if(null===n)throw Q();L(t,2),dn(t,n)}R(t,i)})(e,t),O(e)},encodeSnapshot:t=>Cn(t,new ze),encodeSnapshotV2:Cn,encodeStateAsUpdate:Xe,encodeStateAsUpdateV2:Ge,encodeStateVector:en,encodeStateVectorFromUpdate:t=>rr(t,ze,Fe),encodeStateVectorFromUpdateV2:rr,equalDeleteSets:Le,equalSnapshots:(t,e)=>{const n=t.ds.clients,r=e.ds.clients,s=t.sv,i=e.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(const[t,e]of s.entries())if(i.get(t)!==e)return!1;for(const[t,e]of n.entries()){const n=r.get(t)||[];if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++){const r=e[t],s=n[t];if(r.clock!==s.clock||r.len!==s.len)return!1}}return!0},findIndexSS:Ln,findRootTypeKey:gn,getItem:Nn,getState:On,getTypeChildren:t=>{t.doc??mr();let e=t._start;const n=[];for(;e;)n.push(e),e=e.right;return n},isDeleted:De,isParentOf:fn,iterateDeletedStructs:Ce,logType:t=>{const e=[];let n=t._start;for(;n;)e.push(n),n=n.right;console.log("Children: ",e),console.log("Children content: ",e.filter((t=>!t.deleted)).map((t=>t.content)))},logUpdate:t=>Qn(t,Fe),logUpdateV2:Qn,mergeDeleteSets:Ae,mergeUpdates:nr,mergeUpdatesV2:or,obfuscateUpdate:(t,e)=>dr(t,ur(e),Fe,Je),obfuscateUpdateV2:(t,e)=>dr(t,ur(e),je,We),parseUpdateMeta:t=>sr(t,Fe),parseUpdateMetaV2:sr,readUpdate:(t,e,n)=>He(t,e,n,new Fe(t)),readUpdateV2:He,relativePositionToJSON:wn,snapshot:t=>vn(Ie(t.store),Mn(t.store)),snapshotContainsUpdate:(t,e)=>((t,e,n=je)=>{const r=new n(rt(e)),s=new Zn(r,!1);for(let e=s.curr;null!==e;e=s.next())if((t.sv.get(e.id.client)||0)<e.id.clock+e.length)return!1;const i=Ae([t.ds,Oe(r)]);return Le(t.ds,i)})(t,e,Fe),transact:Yn,tryGc:(t,e,n)=>{Wn(t,e,n),$n(t,e)},typeListToArraySnapshot:(t,e)=>{const n=[];let r=t._start;for(;null!==r;){if(r.countable&&xn(r,e)){const t=r.content.getContent();for(let e=0;e<t.length;e++)n.push(t[e])}r=r.right}return n},typeMapGetAllSnapshot:jr,typeMapGetSnapshot:(t,e,n)=>{let r=t._map.get(e)||null;for(;null!==r&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return null!==r&&xn(r,n)?r.content.getContent()[r.length-1]:void 0}});export{u as A,f as B,wn as C,mn as D,bn as E,_n as F,Sn as G,g as H,ne as I,re as J,Qt as K,Hs as L,h as O,qn as U,xt as a,Gt as b,r as c,z as d,en as e,qt as f,Xe as g,it as h,Ke as i,ht as j,a as k,_t as l,Pt as m,P as n,At as o,O as p,I as q,ct as r,n as s,Xt as t,rt as u,vt as v,N as w,Mt as x,M as y,jt as z};
|
|
2
|
-
//# sourceMappingURL=vendor_yjs-otxZW90b.js.map
|