@inkeep/open-knowledge 0.26.1-beta.1 → 0.27.0-beta.1

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.
Files changed (73) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +2 -2
  3. package/dist/assets/skills/project/references/preview.md +4 -4
  4. package/dist/assets/skills/write-skill/SKILL.md +1 -1
  5. package/dist/cli.mjs +63 -63
  6. package/dist/constants-FPRBLLHv.mjs +2 -0
  7. package/dist/{dist-D8lHZNr8.mjs → dist-CZ4COUHS.mjs} +1 -1
  8. package/dist/{dist-CUbAo1yS.mjs → dist-CdVqgoPq.mjs} +5 -5
  9. package/dist/{gh-detect-BUJyWvGO.mjs → gh-detect-KLjG6xCR.mjs} +2 -2
  10. package/dist/index.d.mts +16 -3
  11. package/dist/index.mjs +1 -1
  12. package/dist/init-DdgQk34k.mjs +660 -0
  13. package/dist/init-NQBVedkZ.mjs +1 -0
  14. package/dist/loader-B67yXEGv.mjs +1 -0
  15. package/dist/{loader-DLBG2Jf0.mjs → loader-XWkMJYxk.mjs} +2 -2
  16. package/dist/{preview-DMdR22hR.mjs → preview-BLauTAym.mjs} +2 -2
  17. package/dist/preview-BUda_ENP.mjs +1 -0
  18. package/dist/public/assets/{ActivityModeContent-ZV1oiH21.js → ActivityModeContent-Bu-aPWfE.js} +1 -1
  19. package/dist/public/assets/{ConsentDialogBody-ClEtx_H4.js → ConsentDialogBody-u7A2_0jL.js} +1 -1
  20. package/dist/public/assets/{DocumentContext-CNrQKGNw.js → DocumentContext-BNan6rEA.js} +1 -1
  21. package/dist/public/assets/{EnableSyncConfirmDialog-BhMvTv-2.js → EnableSyncConfirmDialog-DLAmAtNx.js} +1 -1
  22. package/dist/public/assets/{GraphPanel-B_Rx6o7k.js → GraphPanel-BXSu0qzO.js} +1 -1
  23. package/dist/public/assets/{ManagedArtifactProperties-CabIneyc.js → ManagedArtifactProperties-DCf7FSvm.js} +1 -1
  24. package/dist/public/assets/{McpConsentDialogBody-DW0Ku8h2.js → McpConsentDialogBody-DHnMMoKv.js} +1 -1
  25. package/dist/public/assets/{PropertyPanel-BGGPGg8z.js → PropertyPanel-CLRxrKmQ.js} +1 -1
  26. package/dist/public/assets/{SettingsDialogBody-D9Spbasa.js → SettingsDialogBody-BU_CWPpQ.js} +1 -1
  27. package/dist/public/assets/{ShareBranchSwitchDialog-MF01jVyK.js → ShareBranchSwitchDialog-DqhVt0LE.js} +1 -1
  28. package/dist/public/assets/{ShareReceiveDialog-BeDLlUWc.js → ShareReceiveDialog-COOji2w1.js} +1 -1
  29. package/dist/public/assets/{ShareReceiveMissDialog-CErdFiaW.js → ShareReceiveMissDialog-BIUsfWwx.js} +1 -1
  30. package/dist/public/assets/{SkillEditorActions--NrMimEw.js → SkillEditorActions-Cwen9r7n.js} +1 -1
  31. package/dist/public/assets/{SourceEditor-DR04Kk-L.js → SourceEditor-B8i0Zuc4.js} +1 -1
  32. package/dist/public/assets/{TerminalPanel-CDlxv5DM.js → TerminalPanel-CFHapL_S.js} +1 -1
  33. package/dist/public/assets/{auth-state-cache-XGzST2ZD.js → auth-state-cache-DbOzyU3U.js} +1 -1
  34. package/dist/public/assets/{config-provider-CNEpgM_S.js → config-provider-Do7HkFaK.js} +1 -1
  35. package/dist/public/assets/{dist-CQyX-suk.js → dist-IJIMi_KI.js} +2 -2
  36. package/dist/public/assets/{doc-hash-DK_ofUpp.js → doc-hash-B9qR3wab.js} +1 -1
  37. package/dist/public/assets/{documents-events-DWU2wzVY.js → documents-events-5sCrqLAB.js} +1 -1
  38. package/dist/public/assets/{file-tree-adapter-Co_rTNFv.js → file-tree-adapter-DeCSzJFc.js} +1 -1
  39. package/dist/public/assets/{index-CyAGZpgf.js → index-CfFNwC-k.js} +7 -7
  40. package/dist/public/assets/{index-CLrcKKoN.css → index-CwH3jLSk.css} +1 -1
  41. package/dist/public/assets/{keyboard-shortcuts-B_CAsza0.js → keyboard-shortcuts-DoqeoYey.js} +1 -1
  42. package/dist/public/assets/{navigation-targets-B88nmSdU.js → navigation-targets-CSLWdrg5.js} +1 -1
  43. package/dist/public/assets/{open-managed-artifact-tab-Bk_tqTdp.js → open-managed-artifact-tab-D6l9ALAm.js} +1 -1
  44. package/dist/public/assets/{pending-receive-nav-store-DpqQxXOd.js → pending-receive-nav-store-OU-qfx40.js} +1 -1
  45. package/dist/public/assets/{prop-types-YLAnoO2T.js → prop-types-Cak_LhNF.js} +1 -1
  46. package/dist/public/assets/{receive-store-BVPHm3DM.js → receive-store-DM0i5Ybb.js} +1 -1
  47. package/dist/public/assets/{selection-context-ythQq0B9.js → selection-context-Br-4VUmJ.js} +1 -1
  48. package/dist/public/assets/skill-actions-C1QaoF_v.js +1 -0
  49. package/dist/public/assets/{skills-api-9bY3Jtgz.js → skills-api-DJJ_LIKc.js} +1 -1
  50. package/dist/public/assets/{target-navigation-intent-CwZkFyaW.js → target-navigation-intent-DksqRbJO.js} +1 -1
  51. package/dist/public/assets/{typing-burst-detector-BwvPMOYl.js → typing-burst-detector-ClZLBemU.js} +1 -1
  52. package/dist/public/index.html +22 -22
  53. package/dist/{repair-launch-json-CWUTx3IW.mjs → repair-launch-json-Bk99TDG5.mjs} +2 -2
  54. package/dist/{repair-mcp-configs-BYRhVChI.mjs → repair-mcp-configs-D3XsTqKa.mjs} +2 -2
  55. package/dist/{repair-skills-B2AtzCSn.mjs → repair-skills-D7TJAZll.mjs} +2 -2
  56. package/dist/repair-skills-DCZqW9al.mjs +1 -0
  57. package/dist/server-lock-GuuouVft-CeF2bXVd.mjs +1 -0
  58. package/dist/{server-lock-iLcBw_q0-BF_u0tGL.mjs → server-lock-iLcBw_q0-CdrK5Xfo.mjs} +2 -2
  59. package/dist/{src-BWAFlazs.mjs → src-D0hiW4nw.mjs} +2 -2
  60. package/dist/{start-CnXUmVrI.mjs → start-B3yMZZZG.mjs} +2 -2
  61. package/dist/start-DAdXMVff.mjs +1 -0
  62. package/dist/write-project-skill-BEzL3S1a.mjs +36 -0
  63. package/package.json +1 -1
  64. package/dist/constants-BfJcirqe.mjs +0 -2
  65. package/dist/init-9d1LNBPj.mjs +0 -1
  66. package/dist/init-Dvj0QJzs.mjs +0 -321
  67. package/dist/loader-z1b3_1sK.mjs +0 -1
  68. package/dist/preview-C9s_wKIU.mjs +0 -1
  69. package/dist/public/assets/skill-actions-CbRk7LAn.js +0 -1
  70. package/dist/repair-skills-B8ePNziA.mjs +0 -1
  71. package/dist/server-lock-GuuouVft-CWlICi2c.mjs +0 -1
  72. package/dist/start-CY3HKbBn.mjs +0 -1
  73. package/dist/write-project-skill-Cjym3mlY.mjs +0 -36
@@ -1,2 +1,2 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{At as i,G as a,M as o,N as s,P as c,Q as l,X as u,jt as d,qt as f}from"./DocumentContext-CNrQKGNw.js";import{n as p}from"./dist-BVOt51sU.js";import{M as m,sn as h,ti as g}from"./dist-CQyX-suk.js";import{B as _,C as v,H as y,P as b,V as x,b as S,et as C,p as w,tt as T,w as E,y as D}from"./config-provider-CNEpgM_S.js";import{n as ee}from"./config-context-CVpOcWSZ.js";import{l as te}from"./keyboard-shortcuts-B_CAsza0.js";import{$ as O,Dt as ne,Et as k,Ft as A,J as j,Ot as M,P as N,Q as P,Tt as F,X as I,jt as L,pt as R,ut as re,xt as z}from"./dist-DLLyJf3c.js";import{a as B,d as ie,f as V,h as ae,i as H,m as oe,t as se,u as ce}from"./typing-burst-detector-BwvPMOYl.js";import{o as U,r as W}from"./selection-context-ythQq0B9.js";var G=e(t(),1),le=r(),K=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:b(this.yanchor),yhead:b(this.yhead)}}static fromJSON(t){return new e(v(t.yanchor),v(t.yhead))}},q=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new w(e)}toYPos(e,t=0){return E(this.ytext,e,t)}fromYPos(e){let t=S(v(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new K(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?k.cursor(n.pos,n.assoc):k.range(t.pos,n.pos)}},J=M.define({combine(e){return e[e.length-1]}}),Y=z.define(),X=class{constructor(e){this.view=e,this.conf=e.state.facet(J),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[Y.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(Y)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{At as i,G as a,M as o,N as s,P as c,Q as l,X as u,jt as d,qt as f}from"./DocumentContext-BNan6rEA.js";import{n as p}from"./dist-BVOt51sU.js";import{M as m,sn as h,ti as g}from"./dist-IJIMi_KI.js";import{B as _,C as v,H as y,P as b,V as x,b as S,et as C,p as w,tt as T,w as E,y as D}from"./config-provider-Do7HkFaK.js";import{n as ee}from"./config-context-CVpOcWSZ.js";import{l as te}from"./keyboard-shortcuts-DoqeoYey.js";import{$ as O,Dt as ne,Et as k,Ft as A,J as j,Ot as M,P as N,Q as P,Tt as F,X as I,jt as L,pt as R,ut as re,xt as z}from"./dist-DLLyJf3c.js";import{a as B,d as ie,f as V,h as ae,i as H,m as oe,t as se,u as ce}from"./typing-burst-detector-ClZLBemU.js";import{o as U,r as W}from"./selection-context-Br-4VUmJ.js";var G=e(t(),1),le=r(),K=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:b(this.yanchor),yhead:b(this.yhead)}}static fromJSON(t){return new e(v(t.yanchor),v(t.yhead))}},q=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new w(e)}toYPos(e,t=0){return E(this.ytext,e,t)}fromYPos(e){let t=S(v(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new K(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?k.cursor(n.pos,n.assoc):k.range(t.pos,n.pos)}},J=M.define({combine(e){return e[e.length-1]}}),Y=z.define(),X=class{constructor(e){this.view=e,this.conf=e.state.facet(J),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[Y.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(Y)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
2
2
  `);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},ue=P.fromClass(X),de=I.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`}}),fe=z.define(),pe=class extends O{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return _(`span`,[y(`class`,`cm-ySelectionCaret`),y(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[x(`⁠`),_(`div`,[y(`class`,`cm-ySelectionCaretDot`)]),x(`⁠`),_(`div`,[y(`class`,`cm-ySelectionInfo`)],[x(this.name)]),x(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},me=class{constructor(e){this.conf=e.state.facet(J),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[fe.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=L.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:v(a.cursor.anchor),s=a.cursor==null?null:v(a.cursor.head);if(i!=null){let e=E(t,i.anchor),n=E(t,i.head);(a.cursor==null||!D(o,e)||!D(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=S(s.anchor,n),l=S(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||u+`33`,p=T(c.index,l.index),m=C(c.index,l.index),h=e.view.state.doc.lineAt(p),g=e.view.state.doc.lineAt(m);if(h.number===g.number)i.push({from:p,to:m,value:j.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:j.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:g.from,to:m,value:j.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<g.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:j.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:j.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new pe(u,d)})})}),this.decorations=j.set(i,!0)}},he=P.fromClass(me,{decorations:e=>e.decorations}),ge=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},Z=M.define({combine(e){return e[e.length-1]}});z.define();var _e=class{constructor(e){this.view=e,this.conf=e.state.facet(Z),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(J),this._beforeChangeSelection=null,this._mux=f(),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})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[I.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&&(e.transactions.length===0||e.transactions[0].annotation(Y)!==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)}},ve=P.fromClass(_e),ye=({state:e,dispatch:t})=>e.facet(Z).undo()||!0,be=({state:e,dispatch:t})=>e.facet(Z).redo()||!0,xe=(e,t,{undoManager:n=new w(e)}={})=>{let r=new q(e,t),i=[J.of(r),ue];return t&&i.push(de,he),n!==!1&&i.push(Z.of(new ge(n)),ve,I.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?ye(t):e.inputType===`historyRedo`?be(t):!1}})),i},Se=j.mark({class:`cm-link-ref-broken`}),Ce=/^\s{0,3}\[([^\]]+)\]:\s/,we=/\[([^\]]*)\]\[([^\]]*)\]/g,Te=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Q(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function Ee(e){let t=[];return N(e).iterate({enter(e){if(Te.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function De(e){let t=new Set,n=[],r=e.doc,i=Ee(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Q(n.from,i))continue;let a=Ce.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Q(t.from,i)&&!Ce.test(t.text))for(we.lastIndex=0;;){let e=we.exec(t.text);if(!e)break;let r=t.from+e.index;if(Q(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(Se.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),j.set(a)}var Oe=A.define({create(e){return De(e)},update(e,t){return t.docChanged?De(t.state):e},provide:e=>I.decorations.from(e)}),ke=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Ae=j.mark({class:`cm-del`}),je=j.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Me=j.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ne(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Pe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!m.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(m.test(r.text))return{from:t.from,to:r.to}}return null}function Fe(e,t){let n=[],r=N(e),i=Pe(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(Ae.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=ke.exec(r.text),a=i?i[1].length:2,o=j.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Ne(r.text),a=j.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(je.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Me.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Me.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),j.set(n)}var Ie=class{decorations;constructor(e){this.decorations=Fe(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||N(e.startState)!==N(e.state))&&(this.decorations=Fe(e.view.state,e.view.visibleRanges))}},Le=P.fromClass(Ie,{decorations:e=>e.decorations});function Re(){return[Le,Oe]}var ze=n(),Be=56;function $(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&m.test(n.line(1).text)){for(let e=2;e<=n.lines;e++)if(m.test(n.line(e).text)){r=e+1;break}}let i=h(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:k.cursor(r.from),effects:I.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Ve(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:k.cursor(r),effects:I.scrollIntoView(r,{y:`center`})}),e.focus()})}function He(e){let t=(0,le.c)(33),{docName:n,ytext:r,provider:a,placeholder:f,isSourceModeActive:m}=e,h=(0,G.useRef)(null),_=(0,G.useRef)(null),[v,y]=(0,G.useState)(null);if(v)throw v;let{resolvedTheme:b}=p(),{merged:x}=ee(),S=(0,G.useRef)(m),C=x?.editor?.wordWrap??!0,w,T;t[0]===m?(w=t[1],T=t[2]):(w=()=>{S.current=m},T=[m],t[0]=m,t[1]=w,t[2]=T),(0,G.useEffect)(w,T);let E=(0,G.useRef)(null),D;t[3]!==f||t[4]!==a||t[5]!==b||t[6]!==C||t[7]!==r?(D=()=>{let e=h.current;if(!e)return;let t=a.configuration.name??``,n,s=Ge;try{n=i({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let n=null,i=l({ydoc:a.document,ytext:r}),c=new F,d=new F,p=new F,m=new I({state:ne.create({doc:r.toString(),extensions:[ce,ie({scrollToMatch:We}),re.of([u]),xe(r,a.awareness),...o({themeCompartment:c,resolvedTheme:b,ydoc:a.document,wordWrapCompartment:d,wordWrap:C,currentDocName:t}),Re(),i,I.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,H(t,`source`,B(e.view)),W(t,`source`,U(e.view,t))},120))}),I.domEventHandlers({keydown:(e,t)=>!S.current||!g()||!te(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),se(),!0)}),p.of(R(f??``)),I.theme({"&":{height:`100%`}}),I.scrollMargins.of(Ue)]}),parent:e});H(t,`source`,B(m)),W(t,`source`,U(m,t));let h=m.contentDOM;return h.addEventListener(`keydown`,s),h.addEventListener(`paste`,s),h.addEventListener(`drop`,s),h.addEventListener(`cut`,s),{view:m,ydoc:a.document,ytext:r,provider:a,themeCompartment:c,wordWrapCompartment:d,placeholderCompartment:p}}}),E.current=n,_.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),E.current=null,_.current=null,y(t instanceof Error?t:Error(String(t)))}return()=>{let e=E.current;e&&d(e),E.current=null,_.current=null}},t[3]=f,t[4]=a,t[5]=b,t[6]=C,t[7]=r,t[8]=D):D=t[8];let O;t[9]!==a||t[10]!==r?(O=[r,a],t[9]=a,t[10]=r,t[11]=O):O=t[11],(0,G.useEffect)(D,O);let k,A;t[12]===n?(k=t[13],A=t[14]):(k=()=>{},A=[n],t[12]=n,t[13]=k,t[14]=A),(0,G.useEffect)(k,A);let j,M;t[15]===b?(j=t[16],M=t[17]):(j=()=>{let e=E.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(b===`dark`?s:c)})},M=[b],t[15]=b,t[16]=j,t[17]=M),(0,G.useEffect)(j,M);let N,P;t[18]===C?(N=t[19],P=t[20]):(P=()=>{let e=E.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(C?I.lineWrapping:[])})},N=[C],t[18]=C,t[19]=N,t[20]=P),(0,G.useEffect)(P,N);let L,z;t[21]===f?(L=t[22],z=t[23]):(L=()=>{let e=E.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(R(f??``))})},z=[f],t[21]=f,t[22]=L,t[23]=z),(0,G.useEffect)(L,z);let K,q;t[24]!==n||t[25]!==m?(K=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!m)return;let r=_.current;r&&($(r,t),oe(n))};return window.addEventListener(V,e),()=>window.removeEventListener(V,e)},q=[n,m],t[24]=n,t[25]=m,t[26]=K,t[27]=q):(K=t[26],q=t[27]),(0,G.useEffect)(K,q);let J,Y;t[28]!==n||t[29]!==m?(J=()=>{if(!m)return;let e=_.current;if(!e)return;let t=ae(n);if(t){if(t.kind===`outline`){$(e,t.detail);return}Ve(e,t.detail)}},Y=[n,m],t[28]=n,t[29]=m,t[30]=J,t[31]=Y):(J=t[30],Y=t[31]),(0,G.useEffect)(J,Y);let X;return t[32]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,ze.jsx)(`div`,{ref:h,className:`source-editor h-full pb-3`}),t[32]=X):X=t[32],X}function Ue(){return{top:Be}}function We(e){return I.scrollIntoView(e,{y:`start`})}function Ge(){return a()}export{He as SourceEditor};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{r as i}from"./dist-CQw2y-s3.js";import{n as a}from"./dist-BVOt51sU.js";import{br as o,wt as s,zt as c}from"./dist-CQyX-suk.js";import{i as l,t as u}from"./button-cneJOVxD.js";import{n as d,r as f}from"./dist-IEs1iCqd.js";import{E as p,f as m,m as h}from"./file-tree-adapter-Co_rTNFv.js";var g=r(),_=2,v=1,y=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(_,Math.floor(u/e.css.cell.width)),rows:Math.max(v,Math.floor(l/e.css.cell.height))}}},b=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],x=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],S;function C(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var w=class{constructor(){if(this.version=`6`,!S){S=new Uint8Array(65536),S.fill(1),S[0]=0,S.fill(0,1,32),S.fill(0,127,160),S.fill(2,4352,4448),S[9001]=2,S[9002]=2,S.fill(2,11904,42192),S[12351]=1,S.fill(2,44032,55204),S.fill(2,63744,64256),S.fill(2,65040,65050),S.fill(2,65072,65136),S.fill(2,65280,65377),S.fill(2,65504,65511);for(let e=0;e<b.length;++e)S.fill(0,b[e][0],b[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?S[e]:C(e,x)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Ke.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Ke.createPropertyValue(0,n,r)}},T=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ne.isErrorNoTelemetry(e)?new ne(e.message+`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{r as i}from"./dist-CQw2y-s3.js";import{n as a}from"./dist-BVOt51sU.js";import{br as o,wt as s,zt as c}from"./dist-IJIMi_KI.js";import{i as l,t as u}from"./button-cneJOVxD.js";import{n as d,r as f}from"./dist-IEs1iCqd.js";import{E as p,f as m,m as h}from"./file-tree-adapter-DeCSzJFc.js";var g=r(),_=2,v=1,y=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(_,Math.floor(u/e.css.cell.width)),rows:Math.max(v,Math.floor(l/e.css.cell.height))}}},b=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],x=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],S;function C(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var w=class{constructor(){if(this.version=`6`,!S){S=new Uint8Array(65536),S.fill(1),S[0]=0,S.fill(0,1,32),S.fill(0,127,160),S.fill(2,4352,4448),S[9001]=2,S[9002]=2,S.fill(2,11904,42192),S[12351]=1,S.fill(2,44032,55204),S.fill(2,63744,64256),S.fill(2,65040,65050),S.fill(2,65072,65136),S.fill(2,65280,65377),S.fill(2,65504,65511);for(let e=0;e<b.length;++e)S.fill(0,b[e][0],b[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?S[e]:C(e,x)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Ke.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Ke.createPropertyValue(0,n,r)}},T=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ne.isErrorNoTelemetry(e)?new ne(e.message+`
2
2
 
3
3
  `+e.stack):Error(e.message+`
4
4
 
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{C as i,E as a,S as o,T as s,_n as c,an as l,ar as u,cn as d,dr as f,n as p,rr as m,sn as h,w as g,x as _}from"./DocumentContext-CNrQKGNw.js";import{n as v,r as y}from"./dist-CQw2y-s3.js";import{Dr as b,Dt as x,Pi as S,Sr as C,_t as w,gt as T,it as E,pt as D,vt as O,yt as k}from"./dist-CQyX-suk.js";import{t as A}from"./trace-api-D6fqC5Nw.js";import{i as j,r as M,t as N,u as P}from"./button-cneJOVxD.js";import{a as F,l as I,n as L,r as R,t as z}from"./EnableSyncConfirmDialog-BhMvTv-2.js";import{t as B}from"./arrow-up-right-DoN2FmSd.js";import{t as V}from"./check-Dqb-7gfx.js";import{l as H}from"./prop-types-YLAnoO2T.js";import{D as U,f as ee,i as te,o as W,p as ne}from"./skill-actions-CbRk7LAn.js";import{c as G,i as re,o as ie,r as ae,s as K,t as oe}from"./skill-scope-Bt2TwqtA.js";import"./config-provider-CNEpgM_S.js";import{n as se}from"./config-context-CVpOcWSZ.js";import{a as ce,n as le,r as ue}from"./open-managed-artifact-tab-Bk_tqTdp.js";import{t as de}from"./loader-circle-CiIO3Fk-.js";import{t as fe}from"./refresh-cw-EVALIeLp.js";import{t as pe}from"./triangle-alert-r1Ou0VrE.js";import{n as me,r as he}from"./dist-IEs1iCqd.js";import{d as ge}from"./dist-D9WIglau.js";import{i as _e,n as ve,t as ye}from"./tooltip-C-qXynAd.js";import{a as be,c as xe,i as Se,n as Ce,o as we,s as Te,t as Ee}from"./dialog-BiB39Lhy.js";import{T as De,_ as Oe,h as ke,l as Ae,p as je}from"./skills-api-9bY3Jtgz.js";import{t as Me}from"./label-hTzLGQhh.js";import{n as Ne,t as Pe}from"./radio-group-G2GVDZug.js";import{t as Fe}from"./input-D0MSkqYi.js";import{n as Ie,t as q}from"./dist-0Zj_lz7j.js";import{c as Le,o as Re}from"./documents-events-DWU2wzVY.js";import{a as ze,m as Be,s as Ve}from"./doc-hash-DK_ofUpp.js";import{c as He,l as Ue}from"./keyboard-shortcuts-B_CAsza0.js";import{t as We}from"./external-link-Do3_Yhal.js";import{t as Ge}from"./textarea-9jwlIkqW.js";var Ke=P(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),qe=P(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Je=P(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Ye=P(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Xe=P(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),Ze=P(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Qe=P(`move-up-right`,[[`path`,{d:`M13 5H19V11`,key:`1n1gyv`}],[`path`,{d:`M19 5L5 19`,key:`72u4yj`}]]),$e=P(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),J=e(t(),1),Y=n(),et=`Separator`,tt=`horizontal`,nt=[`horizontal`,`vertical`],rt=J.forwardRef((e,t)=>{let{decorative:n,orientation:r=tt,...i}=e,a=it(r)?r:tt,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,Y.jsx)(ge.div,{"data-orientation":a,...o,...i,ref:t})});rt.displayName=et;function it(e){return nt.includes(e)}var at=rt,X=r();function ot(e){let t=(0,X.c)(12),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={status:`idle`},t[0]=n):n=t[0];let[r,i]=(0,J.useState)(n),[a,o]=(0,J.useState)(0),s,c;t[1]===e?(s=t[2],c=t[3]):(s=()=>{if(e!==null)return Le(()=>{o(ut)})},c=[e],t[1]=e,t[2]=s,t[3]=c),(0,J.useEffect)(s,c);let l;t[4]===e?l=t[5]:(l=()=>{if(e===null){i({status:`idle`});return}let t=!1;i({status:`loading`});let n=e?`?path=${encodeURIComponent(e)}`:``;return fetch(`/api/folder-config${n}`).then(ct).then(e=>{if(!t){if(!e||typeof e!=`object`||!e.folder){i({status:`error`,message:`Server returned an incomplete folder response.`});return}i({status:`ready`,data:{folder:e.folder,frontmatterLocal:e.frontmatter_local??null}})}}).catch(e=>{t||i({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},t[4]=e,t[5]=l);let u;t[6]!==e||t[7]!==a?(u=[e,a],t[6]=e,t[7]=a,t[8]=u):u=t[8],(0,J.useEffect)(l,u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o(st),t[9]=d):d=t[9];let f;return t[10]===r?f=t[11]:(f={state:r,refresh:d},t[10]=r,t[11]=f),f}function st(e){return e+1}async function ct(e){if(!e.ok){let t=await e.json().catch(lt);throw Error(Ie(t)??`HTTP ${e.status}`)}return e.json()}function lt(){return null}function ut(e){return e+1}function dt(){let e=(0,X.c)(6),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,J.useState)(t),[i,a]=(0,J.useState)(0),o,s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(()=>{a(mt)}),s=[],e[1]=o,e[2]=s):(o=e[1],s=e[2]),(0,J.useEffect)(o,s);let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=!1;return r({status:`loading`}),fetch(`/api/templates`).then(ft).then(t=>{if(e)return;let n=x.safeParse(t);if(!n.success){console.error(`[ok-templates] /api/templates response failed schema validation:`,n.error.issues),r({status:`error`,message:`Server returned an incomplete templates response.`});return}r({status:`ready`,data:n.data.templates})}).catch(t=>{e||r({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},e[3]=c):c=e[3];let l;return e[4]===i?l=e[5]:(l=[i],e[4]=i,e[5]=l),(0,J.useEffect)(c,l),n}async function ft(e){if(!e.ok){let t=await e.json().catch(pt);throw Error(Ie(t)??`HTTP ${e.status}`)}return e.json()}function pt(){return null}function mt(e){return e+1}function ht(e){let t=(0,X.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=j(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,Y.jsx)(at,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}function gt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var _t=M(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function vt(e){let t=(0,X.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=j(_t({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Y.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function yt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(Me,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function St(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`text-left text-1sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ct(e){let t=(0,X.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,errors:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;bb0:{if(n){o=n;break bb0}if(!i?.length){o=null;break bb0}let e;t[5]===i?e=t[6]:(e=[...new Map(i.map(Tt)).values()],t[5]=i,t[6]=e);let r=e;if(r?.length===1){o=r[0]?.message;break bb0}let a;t[7]===r?a=t[8]:(a=(0,Y.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(wt)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=j(`text-sm font-normal text-destructive`,r),t[9]=r,t[10]=c);let l;return t[11]!==s||t[12]!==a||t[13]!==c?(l=(0,Y.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:c,...a,children:s}),t[11]=s,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function wt(e){return e?.message&&(0,Y.jsx)(`li`,{children:e.message},e.message)}function Tt(e){return[e?.message,e]}async function Et(){try{let e=await fetch(`/api/semantic-status`);return e.ok?await e.json():(console.debug(`[semantic-status] probe returned`,e.status),null)}catch(e){return console.debug(`[semantic-status] probe failed`,e),null}}function Dt(e){let t=(0,X.c)(16),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n.enabled??!0,[i,a]=(0,J.useState)(null),o;t[2]===r?o=t[3]:(o=function(){r&&Et().then(e=>{e&&a(e)})},t[2]=r,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=()=>{s()},t[4]=s,t[5]=c);let l;t[6]===r?l=t[7]:(l=[r],t[6]=r,t[7]=l),(0,J.useEffect)(c,l);let u;t[8]!==r||t[9]!==s?(u=()=>{if(r)return Re(e=>{e.includes(`files`)&&s()})},t[8]=r,t[9]=s,t[10]=u):u=t[10];let d;t[11]===r?d=t[12]:(d=[r],t[11]=r,t[12]=d),(0,J.useEffect)(u,d);let f;return t[13]!==s||t[14]!==i?(f={status:i,refresh:s},t[13]=s,t[14]=i,t[15]=f):f=t[15],f}var Ot=`#settings`;function kt(e){return He(e.target)?!1:Ue(e,`settings`)}function At(e){return e.replace(/^#/,``)===`settings`}function jt(){return typeof window>`u`?``:window.location.hash}function Mt(){let e=(0,X.c)(4),[t,n]=(0,J.useState)(Pt),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>{(0,J.startTransition)(()=>{n(At(jt()))})};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,J.useEffect)(r,i);let a=Nt,o;return e[2]===t?o=e[3]:(o={open:t,close:a},e[2]=t,e[3]=o),o}function Nt(){typeof window>`u`||At(jt())&&window.history.back()}function Pt(){return At(jt())}var Ft=`open-knowledge-app`;function It(e){try{A.getTracer(Ft).startSpan(e).end()}catch(e){console.warn(`[terminal-telemetry] span emit failed:`,e instanceof Error?e:String(e))}}function Lt(){It(`ok.desktop.terminalOpened`)}function Rt(){It(`ok.desktop.shellConsentGranted`)}var zt=`github.com`,Bt=new Map;async function Vt(e){try{let t=await e.json(),n=E.safeParse(t);if(n.success)return n.data.title}catch{}}async function Ht(e,t){return fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})})}async function Ut(e){let t=e?.host??zt,n=await Ht(`/api/local-op/auth/status`,e);if(!n.ok)return{authenticated:!1,host:t,error:await Vt(n)};let r=await n.json(),i=typeof r.host==`string`?r.host:t;if(r.authenticated===!0&&typeof r.login==`string`){let e=r.tier===`A`||r.tier===`B`||r.tier===`C`?r.tier:void 0;return{authenticated:!0,host:i,login:r.login,tier:e,name:typeof r.name==`string`?r.name:void 0,email:typeof r.email==`string`?r.email:void 0}}return{authenticated:!1,host:i,error:typeof r.error==`string`?r.error:void 0}}function Wt(e){let t=e?.host??zt,n=Bt.get(t);if(n)return n;let r=Ut(e).finally(()=>{Bt.delete(t)});return Bt.set(t,r),r}function Gt(e){let t=e.split(`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{C as i,E as a,S as o,T as s,_n as c,an as l,ar as u,cn as d,dr as f,n as p,rr as m,sn as h,w as g,x as _}from"./DocumentContext-BNan6rEA.js";import{n as v,r as y}from"./dist-CQw2y-s3.js";import{Dr as b,Dt as x,Pi as S,Sr as C,_t as w,gt as T,it as E,pt as D,vt as O,yt as k}from"./dist-IJIMi_KI.js";import{t as A}from"./trace-api-D6fqC5Nw.js";import{i as j,r as M,t as N,u as P}from"./button-cneJOVxD.js";import{a as F,l as I,n as L,r as R,t as z}from"./EnableSyncConfirmDialog-DLAmAtNx.js";import{t as B}from"./arrow-up-right-DoN2FmSd.js";import{t as V}from"./check-Dqb-7gfx.js";import{l as H}from"./prop-types-Cak_LhNF.js";import{D as U,f as ee,i as te,o as W,p as ne}from"./skill-actions-C1QaoF_v.js";import{c as G,i as re,o as ie,r as ae,s as K,t as oe}from"./skill-scope-Bt2TwqtA.js";import"./config-provider-Do7HkFaK.js";import{n as se}from"./config-context-CVpOcWSZ.js";import{a as ce,n as le,r as ue}from"./open-managed-artifact-tab-D6l9ALAm.js";import{t as de}from"./loader-circle-CiIO3Fk-.js";import{t as fe}from"./refresh-cw-EVALIeLp.js";import{t as pe}from"./triangle-alert-r1Ou0VrE.js";import{n as me,r as he}from"./dist-IEs1iCqd.js";import{d as ge}from"./dist-D9WIglau.js";import{i as _e,n as ve,t as ye}from"./tooltip-C-qXynAd.js";import{a as be,c as xe,i as Se,n as Ce,o as we,s as Te,t as Ee}from"./dialog-BiB39Lhy.js";import{T as De,_ as Oe,h as ke,l as Ae,p as je}from"./skills-api-DJJ_LIKc.js";import{t as Me}from"./label-hTzLGQhh.js";import{n as Ne,t as Pe}from"./radio-group-G2GVDZug.js";import{t as Fe}from"./input-D0MSkqYi.js";import{n as Ie,t as q}from"./dist-0Zj_lz7j.js";import{c as Le,o as Re}from"./documents-events-5sCrqLAB.js";import{a as ze,m as Be,s as Ve}from"./doc-hash-B9qR3wab.js";import{c as He,l as Ue}from"./keyboard-shortcuts-DoqeoYey.js";import{t as We}from"./external-link-Do3_Yhal.js";import{t as Ge}from"./textarea-9jwlIkqW.js";var Ke=P(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),qe=P(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Je=P(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Ye=P(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Xe=P(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),Ze=P(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),Qe=P(`move-up-right`,[[`path`,{d:`M13 5H19V11`,key:`1n1gyv`}],[`path`,{d:`M19 5L5 19`,key:`72u4yj`}]]),$e=P(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),J=e(t(),1),Y=n(),et=`Separator`,tt=`horizontal`,nt=[`horizontal`,`vertical`],rt=J.forwardRef((e,t)=>{let{decorative:n,orientation:r=tt,...i}=e,a=it(r)?r:tt,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,Y.jsx)(ge.div,{"data-orientation":a,...o,...i,ref:t})});rt.displayName=et;function it(e){return nt.includes(e)}var at=rt,X=r();function ot(e){let t=(0,X.c)(12),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={status:`idle`},t[0]=n):n=t[0];let[r,i]=(0,J.useState)(n),[a,o]=(0,J.useState)(0),s,c;t[1]===e?(s=t[2],c=t[3]):(s=()=>{if(e!==null)return Le(()=>{o(ut)})},c=[e],t[1]=e,t[2]=s,t[3]=c),(0,J.useEffect)(s,c);let l;t[4]===e?l=t[5]:(l=()=>{if(e===null){i({status:`idle`});return}let t=!1;i({status:`loading`});let n=e?`?path=${encodeURIComponent(e)}`:``;return fetch(`/api/folder-config${n}`).then(ct).then(e=>{if(!t){if(!e||typeof e!=`object`||!e.folder){i({status:`error`,message:`Server returned an incomplete folder response.`});return}i({status:`ready`,data:{folder:e.folder,frontmatterLocal:e.frontmatter_local??null}})}}).catch(e=>{t||i({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},t[4]=e,t[5]=l);let u;t[6]!==e||t[7]!==a?(u=[e,a],t[6]=e,t[7]=a,t[8]=u):u=t[8],(0,J.useEffect)(l,u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o(st),t[9]=d):d=t[9];let f;return t[10]===r?f=t[11]:(f={state:r,refresh:d},t[10]=r,t[11]=f),f}function st(e){return e+1}async function ct(e){if(!e.ok){let t=await e.json().catch(lt);throw Error(Ie(t)??`HTTP ${e.status}`)}return e.json()}function lt(){return null}function ut(e){return e+1}function dt(){let e=(0,X.c)(6),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,J.useState)(t),[i,a]=(0,J.useState)(0),o,s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(()=>{a(mt)}),s=[],e[1]=o,e[2]=s):(o=e[1],s=e[2]),(0,J.useEffect)(o,s);let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=!1;return r({status:`loading`}),fetch(`/api/templates`).then(ft).then(t=>{if(e)return;let n=x.safeParse(t);if(!n.success){console.error(`[ok-templates] /api/templates response failed schema validation:`,n.error.issues),r({status:`error`,message:`Server returned an incomplete templates response.`});return}r({status:`ready`,data:n.data.templates})}).catch(t=>{e||r({status:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},e[3]=c):c=e[3];let l;return e[4]===i?l=e[5]:(l=[i],e[4]=i,e[5]=l),(0,J.useEffect)(c,l),n}async function ft(e){if(!e.ok){let t=await e.json().catch(pt);throw Error(Ie(t)??`HTTP ${e.status}`)}return e.json()}function pt(){return null}function mt(e){return e+1}function ht(e){let t=(0,X.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=j(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,Y.jsx)(at,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}function gt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var _t=M(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function vt(e){let t=(0,X.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=j(_t({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Y.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function yt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(Me,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xt(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`field-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function St(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`text-left text-1sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ct(e){let t=(0,X.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,errors:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;bb0:{if(n){o=n;break bb0}if(!i?.length){o=null;break bb0}let e;t[5]===i?e=t[6]:(e=[...new Map(i.map(Tt)).values()],t[5]=i,t[6]=e);let r=e;if(r?.length===1){o=r[0]?.message;break bb0}let a;t[7]===r?a=t[8]:(a=(0,Y.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(wt)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=j(`text-sm font-normal text-destructive`,r),t[9]=r,t[10]=c);let l;return t[11]!==s||t[12]!==a||t[13]!==c?(l=(0,Y.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:c,...a,children:s}),t[11]=s,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function wt(e){return e?.message&&(0,Y.jsx)(`li`,{children:e.message},e.message)}function Tt(e){return[e?.message,e]}async function Et(){try{let e=await fetch(`/api/semantic-status`);return e.ok?await e.json():(console.debug(`[semantic-status] probe returned`,e.status),null)}catch(e){return console.debug(`[semantic-status] probe failed`,e),null}}function Dt(e){let t=(0,X.c)(16),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n.enabled??!0,[i,a]=(0,J.useState)(null),o;t[2]===r?o=t[3]:(o=function(){r&&Et().then(e=>{e&&a(e)})},t[2]=r,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=()=>{s()},t[4]=s,t[5]=c);let l;t[6]===r?l=t[7]:(l=[r],t[6]=r,t[7]=l),(0,J.useEffect)(c,l);let u;t[8]!==r||t[9]!==s?(u=()=>{if(r)return Re(e=>{e.includes(`files`)&&s()})},t[8]=r,t[9]=s,t[10]=u):u=t[10];let d;t[11]===r?d=t[12]:(d=[r],t[11]=r,t[12]=d),(0,J.useEffect)(u,d);let f;return t[13]!==s||t[14]!==i?(f={status:i,refresh:s},t[13]=s,t[14]=i,t[15]=f):f=t[15],f}var Ot=`#settings`;function kt(e){return He(e.target)?!1:Ue(e,`settings`)}function At(e){return e.replace(/^#/,``)===`settings`}function jt(){return typeof window>`u`?``:window.location.hash}function Mt(){let e=(0,X.c)(4),[t,n]=(0,J.useState)(Pt),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>{(0,J.startTransition)(()=>{n(At(jt()))})};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,J.useEffect)(r,i);let a=Nt,o;return e[2]===t?o=e[3]:(o={open:t,close:a},e[2]=t,e[3]=o),o}function Nt(){typeof window>`u`||At(jt())&&window.history.back()}function Pt(){return At(jt())}var Ft=`open-knowledge-app`;function It(e){try{A.getTracer(Ft).startSpan(e).end()}catch(e){console.warn(`[terminal-telemetry] span emit failed:`,e instanceof Error?e:String(e))}}function Lt(){It(`ok.desktop.terminalOpened`)}function Rt(){It(`ok.desktop.shellConsentGranted`)}var zt=`github.com`,Bt=new Map;async function Vt(e){try{let t=await e.json(),n=E.safeParse(t);if(n.success)return n.data.title}catch{}}async function Ht(e,t){return fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})})}async function Ut(e){let t=e?.host??zt,n=await Ht(`/api/local-op/auth/status`,e);if(!n.ok)return{authenticated:!1,host:t,error:await Vt(n)};let r=await n.json(),i=typeof r.host==`string`?r.host:t;if(r.authenticated===!0&&typeof r.login==`string`){let e=r.tier===`A`||r.tier===`B`||r.tier===`C`?r.tier:void 0;return{authenticated:!0,host:i,login:r.login,tier:e,name:typeof r.name==`string`?r.name:void 0,email:typeof r.email==`string`?r.email:void 0}}return{authenticated:!1,host:i,error:typeof r.error==`string`?r.error:void 0}}function Wt(e){let t=e?.host??zt,n=Bt.get(t);if(n)return n;let r=Ut(e).finally(()=>{Bt.delete(t)});return Bt.set(t,r),r}function Gt(e){let t=e.split(`
2
2
  `);for(let e=t.length-1;e>=0;e--){let n=t[e]?.trim();if(n)try{let e=JSON.parse(n);if(e&&typeof e==`object`)return e}catch{}}return null}function Kt(){return{status:Wt,async repos(e){let t=e?.host??`github.com`,n=await Ht(`/api/local-op/auth/repos`,e);if(!n.ok)return{ok:!1,error:await Vt(n)??`Failed to fetch repositories`};let r=Gt(await n.text());if(r&&r.type===`error`&&r.problem&&typeof r.problem==`object`){let e=r.problem;return{ok:!1,error:e.detail||e.title||`Failed to fetch repositories`}}if(!r||!Array.isArray(r.repos))return{ok:!1,error:`Failed to fetch repositories`};let i=[];for(let e of r.repos){let t=e;typeof t?.full_name==`string`&&typeof t.clone_url==`string`&&i.push({full_name:t.full_name,clone_url:t.clone_url,private:t.private===!0})}return{ok:!0,host:typeof r.host==`string`?r.host:t,repos:i}},async signout(e){let t=await Ht(`/api/local-op/auth/signout`,e);return t.ok?{ok:!0}:{ok:!1,error:await Vt(t)}}}}function qt(e){return{status:t=>e.localOp.authStatus(t),repos:t=>e.localOp.authRepos(t)}}async function Jt(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:a}=await n.read();if(e)return i+=r.decode(),!!(i.trim()&&t(i)===`terminal`);i+=r.decode(a,{stream:!0});let o=i.split(`
3
3
  `);i=o.pop()??``;for(let e of o)if(e.trim()&&t(e)===`terminal`)return!0}}function Yt(e){let t=[],n=[],r=new AbortController,i=!1,a=()=>{for(let e of n.splice(0))e(null)};return e(e=>{i||(n.length>0?n.shift()?.(e):t.push(e),(e.type===`complete`||e.type===`error`)&&(i=!0,r.abort(),a()))},r.signal),{events:{[Symbol.asyncIterator](){return{async next(){if(t.length>0){let e=t.shift();return e===void 0?{value:void 0,done:!0}:{value:e,done:!1}}return i?{value:void 0,done:!0}:new Promise(e=>{n.push(t=>{e(t===null?{value:void 0,done:!0}:{value:t,done:!1})})})}}}},cancel:()=>{i||(i=!0,r.abort(),a())}}}function Xt(){return{start(){return Yt((e,t)=>{(async()=>{try{let n=await fetch(`/api/local-op/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({json:!0}),signal:t});if(!n.ok){let t=`Failed to start sign-in — try again`;try{let e=await n.json(),r=E.safeParse(e);r.success&&(t=r.data.title)}catch{}e({type:`error`,message:t});return}if(!n.body){e({type:`error`,message:`Failed to start sign-in — try again`});return}!await Jt(n.body,t=>{let n;try{n=JSON.parse(t)}catch{return console.warn(`[auth-transport] Dropped unparseable NDJSON line:`,t.slice(0,100)),`continue`}if(n&&typeof n==`object`&&n.type===`error`&&`problem`in n){let t=n.problem;return e({type:`error`,message:t?.detail||t?.title||`Unknown error`}),`terminal`}let r=n;return e(r),r.type===`complete`||r.type===`error`?`terminal`:`continue`})&&!t.aborted&&e({type:`error`,message:`Sign-in stream ended without confirmation — please try again`})}catch(t){if(t instanceof Error&&t.name===`AbortError`)return;e({type:`error`,message:`Connection error — try again`})}})()})}}}function Zt(e){return{start(){return e.localOp.auth.start()}}}async function Qt(e){try{await navigator.clipboard.writeText(e)}catch{}}var $t=120*1e3;function en(e){let t=(0,X.c)(25),{onSuccess:n,transport:r}=e,{_:i}=y(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(`https://github.com/login/device`),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)($t),h=(0,J.useRef)(null),g=(0,J.useRef)(null),_;t[0]!==i||t[1]!==n||t[2]!==r?(_=async function(){f(null);try{let e=r.start();h.current=e.cancel;let t=e.events[Symbol.asyncIterator](),a=!1,s=await t.next();for(;!s.done;){let e=s.value;if(e.type===`verification`)o(e.user_code),c(e.verification_uri),m(e.expires_in*1e3),Qt(e.user_code).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)});else if(e.type===`complete`){a=!0,n({login:e.login,name:e.name,email:e.email,avatarUrl:e.avatarUrl});break}else if(e.type===`error`){a=!0,f(e.message);break}s=await t.next()}a||f(i({id:`DskIkK`}))}catch(e){let t=e;t instanceof Error&&t.name!==`AbortError`&&f(i({id:`Q5fqMz`}))}},t[0]=i,t[1]=n,t[2]=r,t[3]=_):_=t[3];let b=_,x;t[4]===b?x=t[5]:(x=()=>{let e=!1;return queueMicrotask(()=>{e||b()}),()=>{e=!0,h.current?.(),h.current=null,g.current&&clearInterval(g.current)}},t[4]=b,t[5]=x);let S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[6]=S):S=t[6],(0,J.useEffect)(x,S);let C,w;t[7]!==i||t[8]!==a?(C=()=>{if(!a)return;let e=Date.now();return g.current=setInterval(()=>{let t=$t-(Date.now()-e);t<=0?(m(0),g.current&&clearInterval(g.current),f(i({id:`ve8vEM`}))):m(t)},1e3),()=>{g.current&&clearInterval(g.current)}},w=[a,i],t[7]=i,t[8]=a,t[9]=C,t[10]=w):(C=t[9],w=t[10]),(0,J.useEffect)(C,w);let T=Math.floor(p/6e4),E=Math.floor(p%6e4/1e3),D;t[11]===E?D=t[12]:(D=E.toString().padStart(2,`0`),t[11]=E,t[12]=D);let O=`${T}:${D}`,k;t[13]!==i||t[14]!==l||t[15]!==d||t[16]!==O||t[17]!==a||t[18]!==s?(k=a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(v,{id:`eVPynQ`,values:{verificationUri:s},components:{0:(0,Y.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>We(e,s),onAuxClick:e=>We(e,s),className:`inline-flex items-center gap-0.5 text-foreground hover:text-primary hover:underline`}),1:(0,Y.jsx)(`span`,{}),2:(0,Y.jsx)(B,{className:`inline size-3.5`,"aria-hidden":!0})}})}),(0,Y.jsxs)(N,{type:`button`,variant:`outline`,"aria-label":i({id:`nCzR-G`,values:{userCode:a}}),onClick:()=>void Qt(a).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}),className:`relative h-auto w-full justify-center rounded-md bg-muted px-12 py-3 hover:bg-muted/80`,children:[(0,Y.jsx)(`code`,{className:`font-mono text-2xl font-bold tracking-widest`,children:a}),(0,Y.jsx)(`span`,{className:`absolute right-3 text-muted-foreground`,"aria-hidden":`true`,children:l?(0,Y.jsx)(V,{className:`size-4`}):(0,Y.jsx)(G,{className:`size-4`})})]}),(0,Y.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,children:l?(0,Y.jsx)(v,{id:`80c4-P`}):null}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500 animate-pulse`}),(0,Y.jsx)(v,{id:`5y_9lO`})]}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(v,{id:`gYz2ep`,values:{timeLabel:O}})})]})]}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:d?null:(0,Y.jsx)(v,{id:`aWlJai`})}),t[13]=i,t[14]=l,t[15]=d,t[16]=O,t[17]=a,t[18]=s,t[19]=k):k=t[19];let A;t[20]===d?A=t[21]:(A=d&&(0,Y.jsx)(`p`,{className:`text-1sm text-destructive`,children:d}),t[20]=d,t[21]=A);let j;return t[22]!==k||t[23]!==A?(j=(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24],j}function tn(e){let t=(0,X.c)(30),{login:n,name:r,onNameChange:i,email:a,onEmailChange:o}=e,{_:s}=y(),c;t[0]===n?c=t[1]:(c=(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:(0,Y.jsx)(v,{id:`E_tNGD`,values:{login:n}})}),t[0]=n,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Y.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,Y.jsx)(v,{id:`gp3I7-`})}),t[2]=l):l=t[2];let u;t[3]===s?u=t[4]:(u=s({id:`6YtxFj`}),t[3]=s,t[4]=u);let d;t[5]!==s||t[6]!==n?(d=s({id:`J2Mv98`,values:{login:n}}),t[5]=s,t[6]=n,t[7]=d):d=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==f?(p=(0,Y.jsx)(Fe,{"aria-label":u,placeholder:d,value:r,onChange:f}),t[10]=r,t[11]=u,t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===s?m=t[16]:(m=s({id:`O3oNi5`}),t[15]=s,t[16]=m);let h;t[17]===s?h=t[18]:(h=s({id:`O3oNi5`}),t[17]=s,t[18]=h);let g;t[19]===o?g=t[20]:(g=e=>o(e.target.value),t[19]=o,t[20]=g);let _;t[21]!==a||t[22]!==m||t[23]!==h||t[24]!==g?(_=(0,Y.jsx)(Fe,{type:`email`,"aria-label":m,placeholder:h,value:a,onChange:g}),t[21]=a,t[22]=m,t[23]=h,t[24]=g,t[25]=_):_=t[25];let b;return t[26]!==c||t[27]!==_||t[28]!==p?(b=(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[c,l,p,_]}),t[26]=c,t[27]=_,t[28]=p,t[29]=b):b=t[29],b}var nn=1e4;function rn(e){let t=(0,X.c)(59),{open:n,onOpenChange:r,onSuccess:i,identityPrompt:a,reauth:o,transport:s,queryTransport:c}=e,{_:l}=y(),u;t[0]===s?u=t[1]:(u=s??Xt(),t[0]=s,t[1]=u);let d=u,f;t[2]===c?f=t[3]:(f=c??Kt(),t[2]=c,t[3]=f);let p=f,[m,h]=(0,J.useState)(`auth`),[g,_]=(0,J.useState)(null),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),w,T;t[4]!==a||t[5]!==n?(w=()=>{n&&(_(null),x(``),C(``),h(a?`checking`:`auth`))},T=[n,a],t[4]=a,t[5]=n,t[6]=w,t[7]=T):(w=t[6],T=t[7]),(0,J.useLayoutEffect)(w,T);let E;t[8]!==a||t[9]!==n||t[10]!==p?(E=()=>{if(!n||!a)return;let e=!1,t=t=>{e||(e=!0,h(t))},r=setTimeout(()=>t(`auth`),nn);return p.status().then(n=>{e||(n.authenticated?(_({login:n.login,name:n.name,email:n.email}),x(n.name??``),C(n.email??``),t(`identity`)):t(`auth`))}).catch(()=>{t(`auth`)}),()=>{e=!0,clearTimeout(r)}},t[8]=a,t[9]=n,t[10]=p,t[11]=E):E=t[11];let D;t[12]!==a||t[13]!==n?(D=[n,a],t[12]=a,t[13]=n,t[14]=D):D=t[14],(0,J.useEffect)(E,D);let O;t[15]!==l||t[16]!==a||t[17]!==r||t[18]!==i?(O=function(e){if(_(e),a)x(e.name??``),C(e.email??``),h(`identity`);else{h(`done`),i?.(e),r(!1);let t=e.login;me.success(l({id:`E_tNGD`,values:{login:t}}))}},t[15]=l,t[16]=a,t[17]=r,t[18]=i,t[19]=O):O=t[19];let k=O,A;t[20]!==l||t[21]!==g||t[22]!==r||t[23]!==i?(A=function(e,t){fetch(`/api/local-op/auth/set-identity`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,email:t})}).catch(an);let n={...g??{login:``},name:e,email:t};h(`done`),i?.(n),r(!1);let a=n.login;me.success(l({id:`E_tNGD`,values:{login:a}}))},t[20]=l,t[21]=g,t[22]=r,t[23]=i,t[24]=A):A=t[24];let j=A,M;t[25]!==l||t[26]!==g||t[27]!==r||t[28]!==i?(M=function(){if(!g)return;h(`done`),i?.(g),r(!1);let e=g.login;me.success(l({id:`E_tNGD`,values:{login:e}}))},t[25]=l,t[26]=g,t[27]=r,t[28]=i,t[29]=M):M=t[29];let P=M,F;t[30]===r?F=t[31]:(F=function(){r(!1)},t[30]=r,t[31]=F);let I=F,L;t[32]!==a||t[33]!==o||t[34]!==m?(L=(0,Y.jsx)(Te,{children:(0,Y.jsx)(xe,{children:o?(0,Y.jsx)(v,{id:`X8kjQX`}):a&&m!==`auth`?(0,Y.jsx)(v,{id:`29XZXN`}):(0,Y.jsx)(v,{id:`3jod3l`})})}),t[32]=a,t[33]=o,t[34]=m,t[35]=L):L=t[35];let R;t[36]===m?R=t[37]:(R=m===`checking`&&(0,Y.jsx)(Ce,{children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:(0,Y.jsx)(v,{id:`gBbxn_`})})}),t[36]=m,t[37]=R);let z;t[38]!==k||t[39]!==I||t[40]!==d||t[41]!==m?(z=m===`auth`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ce,{children:(0,Y.jsx)(en,{onSuccess:k,transport:d})}),(0,Y.jsx)(we,{children:(0,Y.jsx)(N,{variant:`outline`,className:`font-mono uppercase`,onClick:I,children:(0,Y.jsx)(v,{id:`dEgA5A`})})})]}),t[38]=k,t[39]=I,t[40]=d,t[41]=m,t[42]=z):z=t[42];let B;t[43]!==g||t[44]!==j||t[45]!==P||t[46]!==S||t[47]!==b||t[48]!==m?(B=m===`identity`&&g&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ce,{children:(0,Y.jsx)(tn,{login:g.login,name:b,onNameChange:x,email:S,onEmailChange:C})}),(0,Y.jsxs)(we,{children:[(0,Y.jsx)(N,{variant:`ghost`,onClick:P,children:(0,Y.jsx)(v,{id:`6Uau97`})}),(0,Y.jsx)(N,{onClick:()=>j(b.trim(),S.trim()),disabled:!b.trim()||!S.trim(),children:(0,Y.jsx)(v,{id:`tfDRzk`})})]})]}),t[43]=g,t[44]=j,t[45]=P,t[46]=S,t[47]=b,t[48]=m,t[49]=B):B=t[49];let V;t[50]!==L||t[51]!==R||t[52]!==z||t[53]!==B?(V=(0,Y.jsxs)(Se,{className:`sm:max-w-md`,children:[L,R,z,B]}),t[50]=L,t[51]=R,t[52]=z,t[53]=B,t[54]=V):V=t[54];let H;return t[55]!==r||t[56]!==n||t[57]!==V?(H=(0,Y.jsx)(Ee,{open:n,onOpenChange:r,children:V}),t[55]=r,t[56]=n,t[57]=V,t[58]=H):H=t[58],H}function an(){}function on(e){let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(`div`,{"data-slot":`skeleton`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sn(e){let t=(0,X.c)(16),{value:n,onChange:r,disabled:i,placeholder:a,rows:o}=e,s=i===void 0?!1:i,c=o===void 0?12:o,l=(0,J.useId)(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Y.jsx)(v,{id:`3o3tur`}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Y.jsx)(bt,{htmlFor:l,children:u}),t[1]=l,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Y.jsx)(St,{children:(0,Y.jsx)(v,{id:`5gr_ev`,values:{dateToken:`{{date}}`,userToken:`{{user}}`},components:{0:(0,Y.jsx)(`code`,{className:`font-mono`}),1:(0,Y.jsx)(`code`,{className:`font-mono`})}})}),t[3]=f):f=t[3];let p;t[4]===r?p=t[5]:(p=e=>r(e.target.value),t[4]=r,t[5]=p);let m;t[6]!==s||t[7]!==l||t[8]!==a||t[9]!==c||t[10]!==p||t[11]!==n?(m=(0,Y.jsx)(Ge,{id:l,value:n,onChange:p,disabled:s,rows:c,spellCheck:!1,placeholder:a,className:`font-mono text-xs leading-relaxed min-h-72`}),t[6]=s,t[7]=l,t[8]=a,t[9]=c,t[10]=p,t[11]=n,t[12]=m):m=t[12];let h;return t[13]!==d||t[14]!==m?(h=(0,Y.jsxs)(vt,{children:[d,f,m]}),t[13]=d,t[14]=m,t[15]=h):h=t[15],h}var cn=/^[A-Za-z0-9_-]+$/;function ln(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function un(e){let t={},n=e.title.trim();n&&(t.title=n);let r=e.description.trim();return r&&(t.description=r),t}var dn=0;function fn(){return dn+=1,`prop-${dn}`}function pn(e){let{frontmatter:t,body:n}=C(e);if(t===``)return{type:``,properties:[],markdown:e};let r=[];for(let e of b(t).split(`
4
4
  `)){if(e.trim()===``)continue;let t=e.indexOf(`:`);if((/^\s/.test(e)||t===-1)&&r.length>0){let t=r[r.length-1];t&&(t.value+=`\n${e}`);continue}t!==-1&&r.push({key:e.slice(0,t).trim(),value:e.slice(t+1).replace(/^ /,``)})}let i=``,a=[];for(let e of r){if(e.key===`type`&&i===``){i=e.value.trim();continue}a.push({id:fn(),key:e.key,value:e.value})}return{type:i,properties:a,markdown:n}}function mn(e){let t=[],n=e.type.trim();n&&t.push(`type: ${n}`);for(let n of e.properties){let e=n.key.trim();e===``||e===`type`||t.push(n.value===``?`${e}:`:`${e}: ${n.value}`)}if(t.length===0)return e.markdown.replace(/^\n+/,``);let r=e.markdown.startsWith(`
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i}from"./dist-BVOt51sU.js";import{Ft as a,Jt as o,Lt as s,Yt as c,_ as l,g as u,h as d,m as f,tr as ee}from"./dist-CQyX-suk.js";import{u as te}from"./button-cneJOVxD.js";import{t as ne}from"./config-context-CVpOcWSZ.js";var re=te(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ie=r(),p=e(t(),1),ae=null,oe=new Set;function se(){return ae}function ce(e){let t=e!==null&&e.length>0?e:null;if(t!==ae){ae=t;for(let e of oe)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function le(e){return oe.add(e),()=>{oe.delete(e)}}function ue(){return(0,p.useSyncExternalStore)(le,se,se)}var m=()=>new Map,de=e=>{let t=m();return e.forEach((e,n)=>{t.set(n,e)}),t},h=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},fe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},pe=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},g=()=>new Set,me=e=>e[e.length-1],he=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,ge=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},_e=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ve=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},v=Array.isArray,ye=class{constructor(){this._observers=m()}on(e,t){return h(this._observers,e,g).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},be=class{constructor(){this._observers=m()}on(e,t){h(this._observers,e,g).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},y=Math.floor,xe=Math.abs,Se=(e,t)=>e<t?e:t,Ce=(e,t)=>e>t?e:t;Number.isNaN;var we=e=>e===0?1/e<0:e<0,Te=1<<17,Ee=1<<18,De=1<<19,Oe=1<<20,ke=1<<21,Ae=1<<22,je=1<<23,Me=1<<24,Ne=1<<25,Pe=1<<26,Fe=1<<27,Ie=1<<28,Le=1<<29;Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1,Ie-1,Le-1;var Re=2**53-1,ze=-(2**53-1),Be=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&y(e)===e);Number.isNaN,Number.parseInt;var Ve=String.fromCharCode;String.fromCodePoint,Ve(65535);var He=e=>e.toLowerCase(),Ue=/^\s*/g,We=e=>e.replace(Ue,``),Ge=/([A-Z])/g,Ke=(e,t)=>We(e.replace(Ge,e=>`${t}${He(e)}`)),qe=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Je=typeof TextEncoder<`u`?new TextEncoder:null,Ye=Je?e=>Je.encode(e):qe,Xe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Xe&&Xe.decode(new Uint8Array).length===1&&(Xe=null);var Ze=(e,t)=>ve(t,()=>e).join(``),Qe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},$e=()=>new Qe,et=e=>{let t=$e();return e(t),b(t)},tt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},b=e=>{let t=new Uint8Array(tt(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},nt=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Ce(n,t)*2),e.cpos=0)},x=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},rt=x,S=(e,t)=>{for(;t>127;)x(e,128|127&t),t=y(t/128);x(e,127&t)},it=(e,t)=>{let n=we(t);for(n&&(t=-t),x(e,(t>63?128:0)|(n?64:0)|63&t),t=y(t/64);t>0;)x(e,(t>127?128:0)|127&t),t=y(t/128)},at=new Uint8Array(3e4),ot=at.length/3,st=Je&&Je.encodeInto?(e,t)=>{if(t.length<ot){let n=Je.encodeInto(t,at).written||0;S(e,n);for(let t=0;t<n;t++)x(e,at[t])}else C(e,Ye(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;S(e,r);for(let t=0;t<r;t++)x(e,n.codePointAt(t))},ct=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Se(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Ce(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},C=(e,t)=>{S(e,t.byteLength),ct(e,t)},lt=(e,t)=>{nt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ut=(e,t)=>lt(e,4).setFloat32(0,t,!1),dt=(e,t)=>lt(e,8).setFloat64(0,t,!1),ft=(e,t)=>lt(e,8).setBigInt64(0,t,!1),pt=new DataView(new ArrayBuffer(4)),mt=e=>(pt.setFloat32(0,e),pt.getFloat32(0)===e),ht=(e,t)=>{switch(typeof t){case`string`:x(e,119),st(e,t);break;case`number`:Be(t)&&xe(t)<=2147483647?(x(e,125),it(e,t)):mt(t)?(x(e,124),ut(e,t)):(x(e,123),dt(e,t));break;case`bigint`:x(e,122),ft(e,t);break;case`object`:if(t===null)x(e,126);else if(v(t)){x(e,117),S(e,t.length);for(let n=0;n<t.length;n++)ht(e,t[n])}else if(t instanceof Uint8Array)x(e,116),C(e,t);else{x(e,118);let n=Object.keys(t);S(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];st(e,i),ht(e,t[i])}}break;case`boolean`:x(e,t?120:121);break;default:x(e,127)}},gt=class extends Qe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&S(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},_t=e=>{e.count>0&&(it(e.encoder,e.count===1?e.s:-e.s),e.count>1&&S(e.encoder,e.count-2))},vt=class{constructor(){this.encoder=new Qe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_t(this),this.count=1,this.s=e)}toUint8Array(){return _t(this),b(this.encoder)}},yt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);it(e.encoder,t),e.count>1&&S(e.encoder,e.count-2)}},bt=class{constructor(){this.encoder=new Qe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(yt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return yt(this),b(this.encoder)}},xt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new vt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Qe;return this.sarr.push(this.s),this.s=``,st(e,this.sarr.join(``)),ct(e,this.lensE.toUint8Array()),b(e)}},w=e=>Error(e),T=()=>{throw w(`Method unimplemented`)},E=()=>{throw w(`Unexpected case`)},St=w(`Unexpected end of array`),Ct=w(`Integer out of Range`),wt=class{constructor(e){this.arr=e,this.pos=0}},Tt=e=>new wt(e),Et=e=>e.pos!==e.arr.length,Dt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},D=e=>Dt(e,O(e)),Ot=e=>e.arr[e.pos++],O=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Re)throw Ct}throw St},kt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Re)throw Ct}throw St},At=Xe?e=>Xe.decode(D(e)):e=>{let t=O(e);if(t===0)return``;{let n=String.fromCodePoint(Ot(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ot(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},jt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Mt=[e=>void 0,e=>null,kt,e=>jt(e,4).getFloat32(0,!1),e=>jt(e,8).getFloat64(0,!1),e=>jt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,At,e=>{let t=O(e),n={};for(let r=0;r<t;r++){let t=At(e);n[t]=Nt(e)}return n},e=>{let t=O(e),n=[];for(let r=0;r<t;r++)n.push(Nt(e));return n},D],Nt=e=>Mt[127-Ot(e)](e),Pt=class extends wt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Et(this)?this.count=O(this)+1:this.count=-1),this.count--,this.s}},Ft=class extends wt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=kt(this);let e=we(this.s);this.count=1,e&&(this.s=-this.s,this.count=O(this)+2)}return this.count--,this.s}},It=class extends wt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=kt(this),t=e&1;this.diff=y(e/2),this.count=1,t&&(this.count=O(this)+2)}return this.s+=this.diff,this.count--,this.s}},Lt=class{constructor(e){this.decoder=new Ft(e),this.str=At(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Rt=crypto.getRandomValues.bind(crypto),zt=Math.random,Bt=()=>Rt(new Uint32Array(1))[0],Vt=e=>e[y(zt()*e.length)],Ht=`10000000-1000-4000-8000-100000000000`,Ut=()=>Ht.replace(/[018]/g,e=>(e^Bt()&15>>e/4).toString(16)),Wt=Date.now,Gt=e=>new Promise(e);Promise.all.bind(Promise);var Kt=e=>e===void 0?null:e,qt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(qt=localStorage)}catch{}var Jt=qt,Yt=Symbol(`Equality`),Xt=(e,t)=>e===t||!!e?.[Yt]?.(t)||!1,Zt=e=>typeof e==`object`,Qt=Object.assign,$t=Object.keys,en=(e,t)=>{for(let n in e)t(e[n],n)},tn=e=>$t(e).length,nn=e=>{for(let t in e)return!1;return!0},rn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},an=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),on=(e,t)=>e===t||tn(e)===tn(t)&&rn(e,(e,n)=>(e!==void 0||an(t,n))&&Xt(t[n],e)),sn=Object.freeze,cn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&cn(e[t])}return sn(e)},ln=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&ln(e,t,n+1)}},un=e=>e,dn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Yt]!=null)return e[Yt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!dn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(tn(e)!==tn(t))return!1;for(let n in e)if(!an(e,n)||!dn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dn(e[n],t[n]))return!1;break;default:return!1}return!0},fn=(e,t)=>t.includes(e),pn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,mn=typeof window<`u`&&typeof document<`u`&&!pn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var k,hn=[],gn=()=>{if(k===void 0)if(pn){k=m();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&k.set(t,``),t=r):t===null?hn.push(r):(k.set(t,r),t=null)}t!==null&&k.set(t,``)}else typeof location==`object`?(k=m(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);k.set(`--${Ke(t,`-`)}`,n),k.set(`-${Ke(t,`-`)}`,n)}})):k=m();return k},_n=e=>gn().has(e),vn=e=>Kt(pn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Jt.getItem(e)),yn=e=>_n(`--`+e)||vn(e)!==null,bn=yn(`production`),xn=pn&&fn({}.FORCE_COLOR,[`true`,`1`,`2`])||!_n(`--no-colors`)&&!yn(`no-color`)&&(!pn||process.stdout.isTTY)&&(!pn||_n(`--color`)||vn(`COLORTERM`)!==null||(vn(`TERM`)||``).includes(`color`)),Sn=e=>new Uint8Array(e),Cn=mn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ve(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),wn=e=>{let t=Sn(e.byteLength);return t.set(e),t},Tn=e=>et(t=>ht(t,e)),En=class{constructor(e,t){this.left=e,this.right=t}},A=(e,t)=>new En(e,t),Dn=(e,t)=>e.forEach(e=>t(e.left,e.right)),On=e=>e.next()>=.5,kn=(e,t,n)=>y(e.next()*(n+1-t)+t),An=(e,t,n)=>y(e.next()*(n+1-t)+t),jn=(e,t,n)=>An(e,t,n),Mn=e=>Ve(jn(e,97,122)),Nn=(e,t=0,n=20)=>{let r=jn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Mn(e);return i},Pn=(e,t)=>t[jn(e,0,t.length-1)],Fn=Symbol(`0schema`),In=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ze(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{n as i}from"./dist-BVOt51sU.js";import{Ft as a,Jt as o,Lt as s,Yt as c,_ as l,g as u,h as d,m as f,tr as ee}from"./dist-IJIMi_KI.js";import{u as te}from"./button-cneJOVxD.js";import{t as ne}from"./config-context-CVpOcWSZ.js";var re=te(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ie=r(),p=e(t(),1),ae=null,oe=new Set;function se(){return ae}function ce(e){let t=e!==null&&e.length>0?e:null;if(t!==ae){ae=t;for(let e of oe)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function le(e){return oe.add(e),()=>{oe.delete(e)}}function ue(){return(0,p.useSyncExternalStore)(le,se,se)}var m=()=>new Map,de=e=>{let t=m();return e.forEach((e,n)=>{t.set(n,e)}),t},h=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},fe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},pe=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},g=()=>new Set,me=e=>e[e.length-1],he=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,ge=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},_e=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ve=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},v=Array.isArray,ye=class{constructor(){this._observers=m()}on(e,t){return h(this._observers,e,g).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},be=class{constructor(){this._observers=m()}on(e,t){h(this._observers,e,g).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||m()).values()).forEach(e=>e(...t))}destroy(){this._observers=m()}},y=Math.floor,xe=Math.abs,Se=(e,t)=>e<t?e:t,Ce=(e,t)=>e>t?e:t;Number.isNaN;var we=e=>e===0?1/e<0:e<0,Te=1<<17,Ee=1<<18,De=1<<19,Oe=1<<20,ke=1<<21,Ae=1<<22,je=1<<23,Me=1<<24,Ne=1<<25,Pe=1<<26,Fe=1<<27,Ie=1<<28,Le=1<<29;Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1,Ie-1,Le-1;var Re=2**53-1,ze=-(2**53-1),Be=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&y(e)===e);Number.isNaN,Number.parseInt;var Ve=String.fromCharCode;String.fromCodePoint,Ve(65535);var He=e=>e.toLowerCase(),Ue=/^\s*/g,We=e=>e.replace(Ue,``),Ge=/([A-Z])/g,Ke=(e,t)=>We(e.replace(Ge,e=>`${t}${He(e)}`)),qe=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Je=typeof TextEncoder<`u`?new TextEncoder:null,Ye=Je?e=>Je.encode(e):qe,Xe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Xe&&Xe.decode(new Uint8Array).length===1&&(Xe=null);var Ze=(e,t)=>ve(t,()=>e).join(``),Qe=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},$e=()=>new Qe,et=e=>{let t=$e();return e(t),b(t)},tt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},b=e=>{let t=new Uint8Array(tt(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},nt=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Ce(n,t)*2),e.cpos=0)},x=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},rt=x,S=(e,t)=>{for(;t>127;)x(e,128|127&t),t=y(t/128);x(e,127&t)},it=(e,t)=>{let n=we(t);for(n&&(t=-t),x(e,(t>63?128:0)|(n?64:0)|63&t),t=y(t/64);t>0;)x(e,(t>127?128:0)|127&t),t=y(t/128)},at=new Uint8Array(3e4),ot=at.length/3,st=Je&&Je.encodeInto?(e,t)=>{if(t.length<ot){let n=Je.encodeInto(t,at).written||0;S(e,n);for(let t=0;t<n;t++)x(e,at[t])}else C(e,Ye(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;S(e,r);for(let t=0;t<r;t++)x(e,n.codePointAt(t))},ct=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Se(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Ce(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},C=(e,t)=>{S(e,t.byteLength),ct(e,t)},lt=(e,t)=>{nt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ut=(e,t)=>lt(e,4).setFloat32(0,t,!1),dt=(e,t)=>lt(e,8).setFloat64(0,t,!1),ft=(e,t)=>lt(e,8).setBigInt64(0,t,!1),pt=new DataView(new ArrayBuffer(4)),mt=e=>(pt.setFloat32(0,e),pt.getFloat32(0)===e),ht=(e,t)=>{switch(typeof t){case`string`:x(e,119),st(e,t);break;case`number`:Be(t)&&xe(t)<=2147483647?(x(e,125),it(e,t)):mt(t)?(x(e,124),ut(e,t)):(x(e,123),dt(e,t));break;case`bigint`:x(e,122),ft(e,t);break;case`object`:if(t===null)x(e,126);else if(v(t)){x(e,117),S(e,t.length);for(let n=0;n<t.length;n++)ht(e,t[n])}else if(t instanceof Uint8Array)x(e,116),C(e,t);else{x(e,118);let n=Object.keys(t);S(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];st(e,i),ht(e,t[i])}}break;case`boolean`:x(e,t?120:121);break;default:x(e,127)}},gt=class extends Qe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&S(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},_t=e=>{e.count>0&&(it(e.encoder,e.count===1?e.s:-e.s),e.count>1&&S(e.encoder,e.count-2))},vt=class{constructor(){this.encoder=new Qe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(_t(this),this.count=1,this.s=e)}toUint8Array(){return _t(this),b(this.encoder)}},yt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);it(e.encoder,t),e.count>1&&S(e.encoder,e.count-2)}},bt=class{constructor(){this.encoder=new Qe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(yt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return yt(this),b(this.encoder)}},xt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new vt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Qe;return this.sarr.push(this.s),this.s=``,st(e,this.sarr.join(``)),ct(e,this.lensE.toUint8Array()),b(e)}},w=e=>Error(e),T=()=>{throw w(`Method unimplemented`)},E=()=>{throw w(`Unexpected case`)},St=w(`Unexpected end of array`),Ct=w(`Integer out of Range`),wt=class{constructor(e){this.arr=e,this.pos=0}},Tt=e=>new wt(e),Et=e=>e.pos!==e.arr.length,Dt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},D=e=>Dt(e,O(e)),Ot=e=>e.arr[e.pos++],O=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Re)throw Ct}throw St},kt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Re)throw Ct}throw St},At=Xe?e=>Xe.decode(D(e)):e=>{let t=O(e);if(t===0)return``;{let n=String.fromCodePoint(Ot(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ot(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},jt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Mt=[e=>void 0,e=>null,kt,e=>jt(e,4).getFloat32(0,!1),e=>jt(e,8).getFloat64(0,!1),e=>jt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,At,e=>{let t=O(e),n={};for(let r=0;r<t;r++){let t=At(e);n[t]=Nt(e)}return n},e=>{let t=O(e),n=[];for(let r=0;r<t;r++)n.push(Nt(e));return n},D],Nt=e=>Mt[127-Ot(e)](e),Pt=class extends wt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Et(this)?this.count=O(this)+1:this.count=-1),this.count--,this.s}},Ft=class extends wt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=kt(this);let e=we(this.s);this.count=1,e&&(this.s=-this.s,this.count=O(this)+2)}return this.count--,this.s}},It=class extends wt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=kt(this),t=e&1;this.diff=y(e/2),this.count=1,t&&(this.count=O(this)+2)}return this.s+=this.diff,this.count--,this.s}},Lt=class{constructor(e){this.decoder=new Ft(e),this.str=At(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Rt=crypto.getRandomValues.bind(crypto),zt=Math.random,Bt=()=>Rt(new Uint32Array(1))[0],Vt=e=>e[y(zt()*e.length)],Ht=`10000000-1000-4000-8000-100000000000`,Ut=()=>Ht.replace(/[018]/g,e=>(e^Bt()&15>>e/4).toString(16)),Wt=Date.now,Gt=e=>new Promise(e);Promise.all.bind(Promise);var Kt=e=>e===void 0?null:e,qt=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(qt=localStorage)}catch{}var Jt=qt,Yt=Symbol(`Equality`),Xt=(e,t)=>e===t||!!e?.[Yt]?.(t)||!1,Zt=e=>typeof e==`object`,Qt=Object.assign,$t=Object.keys,en=(e,t)=>{for(let n in e)t(e[n],n)},tn=e=>$t(e).length,nn=e=>{for(let t in e)return!1;return!0},rn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},an=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),on=(e,t)=>e===t||tn(e)===tn(t)&&rn(e,(e,n)=>(e!==void 0||an(t,n))&&Xt(t[n],e)),sn=Object.freeze,cn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&cn(e[t])}return sn(e)},ln=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&ln(e,t,n+1)}},un=e=>e,dn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Yt]!=null)return e[Yt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!dn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(tn(e)!==tn(t))return!1;for(let n in e)if(!an(e,n)||!dn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dn(e[n],t[n]))return!1;break;default:return!1}return!0},fn=(e,t)=>t.includes(e),pn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,mn=typeof window<`u`&&typeof document<`u`&&!pn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var k,hn=[],gn=()=>{if(k===void 0)if(pn){k=m();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&k.set(t,``),t=r):t===null?hn.push(r):(k.set(t,r),t=null)}t!==null&&k.set(t,``)}else typeof location==`object`?(k=m(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);k.set(`--${Ke(t,`-`)}`,n),k.set(`-${Ke(t,`-`)}`,n)}})):k=m();return k},_n=e=>gn().has(e),vn=e=>Kt(pn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Jt.getItem(e)),yn=e=>_n(`--`+e)||vn(e)!==null,bn=yn(`production`),xn=pn&&fn({}.FORCE_COLOR,[`true`,`1`,`2`])||!_n(`--no-colors`)&&!yn(`no-color`)&&(!pn||process.stdout.isTTY)&&(!pn||_n(`--color`)||vn(`COLORTERM`)!==null||(vn(`TERM`)||``).includes(`color`)),Sn=e=>new Uint8Array(e),Cn=mn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ve(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),wn=e=>{let t=Sn(e.byteLength);return t.set(e),t},Tn=e=>et(t=>ht(t,e)),En=class{constructor(e,t){this.left=e,this.right=t}},A=(e,t)=>new En(e,t),Dn=(e,t)=>e.forEach(e=>t(e.left,e.right)),On=e=>e.next()>=.5,kn=(e,t,n)=>y(e.next()*(n+1-t)+t),An=(e,t,n)=>y(e.next()*(n+1-t)+t),jn=(e,t,n)=>An(e,t,n),Mn=e=>Ve(jn(e,97,122)),Nn=(e,t=0,n=20)=>{let r=jn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Mn(e);return i},Pn=(e,t)=>t[jn(e,0,t.length-1)],Fn=Symbol(`0schema`),In=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ze(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
2
2
  `)}},Ln=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Yt]?Xt(e,t):v(e)?ge(e,e=>_e(t,t=>Ln(e,t))):Zt(e)?rn(e,(e,n)=>Ln(e,t[n])):!1,j=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Ln(t,n)}equals(e){return this.constructor===e.constructor&&dn(this.shape,e.shape)}[Fn](){return!0}[Yt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){T()}get nullable(){return mr(this,kr)}get optional(){return new Kn(this)}cast(e){return Nr(e,this),e}expect(e){return Nr(e,this),e}},Rn=class extends j{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},M=(e,t=null)=>new Rn(e,t);M(Rn);var zn=class extends j{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},N=e=>new zn(e);M(zn);var Bn=class extends j{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Vn=(...e)=>new Bn(e),Hn=M(Bn),Un=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Wn=e=>{if(wr.check(e))return[Un(e)];if(Hn.check(e))return e.shape.map(e=>e+``);if(Cr.check(e))return[`[+-]?\\d+.?\\d*`];if(Tr.check(e))return[`.*`];if(hr.check(e))return e.shape.map(Wn).flat(1);E()};M(class extends j{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Wn).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Gn=Symbol(`optional`),Kn=class extends j{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Gn](){return!0}},qn=M(Kn),Jn=class extends j{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Jn,M(Jn);var Yn=class e extends j{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):rn(this.shape,(n,r)=>{let i=this._isPartial&&!an(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Xn=e=>new Yn(e),Zn=M(Yn),Qn=N(e=>e!=null&&(e.constructor===Object||e.constructor==null)),$n=class extends j{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&rn(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},er=(e,t)=>new $n(e,t),tr=M($n),nr=class extends j{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&rn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},rr=(...e)=>new nr(e);M(nr);var ir=class extends j{constructor(e){super(),this.shape=e.length===1?e[0]:new pr(e)}check(e,t){let n=v(e)&&ge(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},ar=(...e)=>new ir(e),or=M(ir),sr=N(e=>v(e)),cr=class extends j{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},lr=(e,t=null)=>new cr(e,t);M(cr);var ur=lr(j),dr=M(class extends j{constructor(e){super(),this.len=e.length-1,this.args=rr(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),fr=N(e=>typeof e==`function`);M(class extends j{constructor(e){super(),this.shape=e}check(e,t){let n=ge(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var pr=class extends j{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=_e(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},mr=(...e)=>e.findIndex(e=>hr.check(e))>=0?mr(...e.map(e=>Mr(e)).map(e=>hr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new pr(e),hr=M(pr),gr=()=>!0,_r=N(gr),vr=M(zn,e=>e.shape===gr),yr=N(e=>typeof e==`bigint`),br=N(e=>e===yr),xr=N(e=>typeof e==`symbol`);N(e=>e===xr);var Sr=N(e=>typeof e==`number`),Cr=N(e=>e===Sr),wr=N(e=>typeof e==`string`),Tr=N(e=>e===wr),Er=N(e=>typeof e==`boolean`),Dr=N(e=>e===Er),Or=Vn(void 0);M(Bn,e=>e.shape.length===1&&e.shape[0]===void 0),Vn(void 0);var kr=Vn(null),Ar=M(Bn,e=>e.shape.length===1&&e.shape[0]===null);M(Uint8Array),M(Rn,e=>e.shape===Uint8Array);var jr=mr(Sr,wr,kr,Or,yr,Er,xr);(()=>{let e=ar(_r),t=er(wr,_r),n=mr(Sr,wr,kr,Er,e,t);return e.shape=n,t.shape.values=n,n})();var Mr=e=>{if(ur.check(e))return e;if(Qn.check(e)){let t={};for(let n in e)t[n]=Mr(e[n]);return Xn(t)}else if(sr.check(e))return mr(...e.map(Mr));else if(jr.check(e))return Vn(e);else if(fr.check(e))return M(e);E()},Nr=bn?()=>{}:(e,t)=>{let n=new In;if(!t.check(e,n))throw w(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Pr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Mr(e),h:t}),this}else(e){return this.if(_r,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw w(`Unhandled pattern`)}}},Fr=(e=>new Pr(e))(_r).if(Cr,(e,t)=>kn(t,ze,Re)).if(Tr,(e,t)=>Nn(t)).if(Dr,(e,t)=>On(t)).if(br,(e,t)=>BigInt(kn(t,ze,Re))).if(hr,(e,t)=>Ir(t,Pn(t,e.shape))).if(Zn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(qn.check(i)){if(On(t))continue;i=i.shape}n[r]=Fr(i,t)}return n}).if(or,(e,t)=>{let n=[],r=An(t,0,42);for(let i=0;i<r;i++)n.push(Ir(t,e.shape));return n}).if(Hn,(e,t)=>Pn(t,e.shape)).if(Ar,(e,t)=>null).if(dr,(e,t)=>{let n=Ir(t,e.res);return()=>n}).if(vr,(e,t)=>Ir(t,Pn(t,[Sr,wr,kr,Or,yr,Er,ar(Sr),er(mr(`a`,`b`,`c`),Sr)]))).if(tr,(e,t)=>{let n={},r=kn(t,0,3);for(let i=0;i<r;i++){let r=Ir(t,e.shape.keys);n[r]=Ir(t,e.shape.values)}return n}).done(),Ir=(e,t)=>Fr(Mr(t),e),P=typeof document<`u`?document:{},Lr=e=>P.createElement(e),Rr=()=>P.createDocumentFragment();N(e=>e.nodeType===Xr);var zr=e=>P.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Br=(e,t)=>(Dn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Vr=e=>{let t=Rr();for(let n=0;n<e.length;n++)Kr(t,e[n]);return t},Hr=(e,t)=>(Kr(e,Vr(t)),e),Ur=(e,t=[],n=[])=>Hr(Br(Lr(e),t),n);N(e=>e.nodeType===qr);var Wr=zr;N(e=>e.nodeType===Jr);var Gr=e=>fe(e,(e,t)=>`${t}:${e};`).join(``),Kr=(e,t)=>e.appendChild(t),qr=P.ELEMENT_NODE,Jr=P.TEXT_NODE;P.CDATA_SECTION_NODE,P.COMMENT_NODE;var Yr=P.DOCUMENT_NODE;P.DOCUMENT_TYPE_NODE;var Xr=P.DOCUMENT_FRAGMENT_NODE;N(e=>e.nodeType===Yr);var Zr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Qr=(e,t)=>new Zr(setTimeout(t,e)),F=Symbol,$r=F(),ei=F(),ti=F(),ni=F(),ri=F(),ii=F(),ai=F(),oi=F(),si=F(),ci=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Wt();var li={[$r]:A(`font-weight`,`bold`),[ei]:A(`font-weight`,`normal`),[ti]:A(`color`,`blue`),[ri]:A(`color`,`green`),[ni]:A(`color`,`grey`),[ii]:A(`color`,`red`),[ai]:A(`color`,`purple`),[oi]:A(`color`,`orange`),[si]:A(`color`,`black`)},ui=xn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=m(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=li[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Gr(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:ci,di=(...e)=>{console.log(...ui(e)),pi.forEach(t=>t.print(e))},fi=(...e)=>{console.warn(...ui(e)),e.unshift(oi),pi.forEach(t=>t.print(e))},pi=g(),mi=e=>({[Symbol.iterator](){return this},next:e}),hi=(e,t)=>mi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),gi=(e,t)=>mi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),_i=class{constructor(e,t){this.clock=e,this.len=t}},vi=class{constructor(){this.clients=new Map}},yi=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Na(e,i,o.clock,o.len,n)}}),bi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=y((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},xi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&bi(n,t.clock)!==null},Si=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new _i(r.clock,Ce(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Ci=e=>{let t=new vi;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)he(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Si(t),t},wi=(e,t,n,r)=>{h(e.clients,t,()=>[]).push(new _i(n,r))},Ti=()=>new vi,Ei=e=>{let t=Ti();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new _i(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Di=(e,t)=>{S(e.restEncoder,t.clients.size),_(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),S(e.restEncoder,t);let r=n.length;S(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Oi=e=>{let t=new vi,n=O(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=O(e.restDecoder),r=O(e.restDecoder);if(r>0){let i=h(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new _i(e.readDsClock(),e.readDsLen()))}}return t},ki=(e,t,n)=>{let r=new vi,i=O(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=O(e.restDecoder),a=O(e.restDecoder),o=n.clients.get(i)||[],s=R(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&wi(r,i,s,a-s);let e=z(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Ws(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Ws(t,c,a-c.id.clock)),c.delete(t))}else wi(r,i,n,a-n)}}if(r.clients.size>0){let e=new Ri;return S(e.restEncoder,0),Di(e,r),e.toUint8Array()}return null},Ai=Bt,I=class e extends ye{constructor({guid:e=Ut(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Ai(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ea,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Gt(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Gt(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&V(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_(this.subdocs).map(e=>e.guid))}transact(e,t=null){return V(this,e,t)}get(e,t=U){let n=h(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==U&&r!==t)if(r===U){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,Io)}getText(e=``){return this.get(e,rs)}getMap(e=``){return this.get(e,zo)}getXmlElement(e=``){return this.get(e,cs)}getXmlFragment(e=``){return this.get(e,os)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,_(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,V(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},ji=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return O(this.restDecoder)}readDsLen(){return O(this.restDecoder)}},Mi=class extends ji{readLeftID(){return L(O(this.restDecoder),O(this.restDecoder))}readRightID(){return L(O(this.restDecoder),O(this.restDecoder))}readClient(){return O(this.restDecoder)}readInfo(){return Ot(this.restDecoder)}readString(){return At(this.restDecoder)}readParentInfo(){return O(this.restDecoder)===1}readTypeRef(){return O(this.restDecoder)}readLen(){return O(this.restDecoder)}readAny(){return Nt(this.restDecoder)}readBuf(){return wn(D(this.restDecoder))}readJSON(){return JSON.parse(At(this.restDecoder))}readKey(){return At(this.restDecoder)}},Ni=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=O(this.restDecoder),this.dsCurrVal}readDsLen(){let e=O(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Pi=class extends Ni{constructor(e){super(e),this.keys=[],O(e),this.keyClockDecoder=new It(D(e)),this.clientDecoder=new Ft(D(e)),this.leftClockDecoder=new It(D(e)),this.rightClockDecoder=new It(D(e)),this.infoDecoder=new Pt(D(e),Ot),this.stringDecoder=new Lt(D(e)),this.parentInfoDecoder=new Pt(D(e),Ot),this.typeRefDecoder=new Ft(D(e)),this.lenDecoder=new Ft(D(e))}readLeftID(){return new sa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new sa(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Nt(this.restDecoder)}readBuf(){return D(this.restDecoder)}readJSON(){return Nt(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Fi=class{constructor(){this.restEncoder=$e()}toUint8Array(){return b(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){S(this.restEncoder,e)}writeDsLen(e){S(this.restEncoder,e)}},Ii=class extends Fi{writeLeftID(e){S(this.restEncoder,e.client),S(this.restEncoder,e.clock)}writeRightID(e){S(this.restEncoder,e.client),S(this.restEncoder,e.clock)}writeClient(e){S(this.restEncoder,e)}writeInfo(e){rt(this.restEncoder,e)}writeString(e){st(this.restEncoder,e)}writeParentInfo(e){S(this.restEncoder,+!!e)}writeTypeRef(e){S(this.restEncoder,e)}writeLen(e){S(this.restEncoder,e)}writeAny(e){ht(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){st(this.restEncoder,JSON.stringify(e))}writeKey(e){st(this.restEncoder,e)}},Li=class{constructor(){this.restEncoder=$e(),this.dsCurrVal=0}toUint8Array(){return b(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,S(this.restEncoder,t)}writeDsLen(e){e===0&&E(),S(this.restEncoder,e-1),this.dsCurrVal+=e}},Ri=class extends Li{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new bt,this.clientEncoder=new vt,this.leftClockEncoder=new bt,this.rightClockEncoder=new bt,this.infoEncoder=new gt(rt),this.stringEncoder=new xt,this.parentInfoEncoder=new gt(rt),this.typeRefEncoder=new vt,this.lenEncoder=new vt}toUint8Array(){let e=$e();return S(e,0),C(e,this.keyClockEncoder.toUint8Array()),C(e,this.clientEncoder.toUint8Array()),C(e,this.leftClockEncoder.toUint8Array()),C(e,this.rightClockEncoder.toUint8Array()),C(e,b(this.infoEncoder)),C(e,this.stringEncoder.toUint8Array()),C(e,b(this.parentInfoEncoder)),C(e,this.typeRefEncoder.toUint8Array()),C(e,this.lenEncoder.toUint8Array()),ct(e,b(this.restEncoder)),b(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ht(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){ht(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},zi=(e,t,n,r)=>{r=Ce(r,t[0].id.clock);let i=z(t,r);S(e.restEncoder,t.length-i),e.writeClient(n),S(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},Bi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{R(t,n)>e&&r.set(n,e)}),Da(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),S(e.restEncoder,r.size),_(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{zi(e,t.clients.get(n),n,r)})},Vi=(e,t)=>{let n=m(),r=O(e.restDecoder);for(let i=0;i<r;i++){let r=O(e.restDecoder),i=Array(r),a=e.readClient(),o=O(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new W(L(a,o),t),o+=t;break}case 10:{let t=O(e.restDecoder);i[n]=new Y(L(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(L(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,qs(e,r));i[n]=c,o+=c.length}}}}return n},Hi=(e,t,n)=>{let r=[],i=_(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Ea,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Y){let i=h(d,u.id.client,()=>R(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,R(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Ri;return Bi(e,s,new Map),S(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Ui=(e,t)=>Bi(e,t.doc.store,t.beforeState),Wi=(e,t,n,r=new Pi(e))=>V(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Hi(e,i,Vi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<R(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Xa([o.update,a.update])}}else i.pendingStructs=a;let s=ki(r,e,i);if(i.pendingDs){let t=new Pi(Tt(i.pendingDs));O(t.restDecoder);let n=ki(t,e,i);s&&n?i.pendingDs=Xa([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Gi(e.doc,t)}},n,!1),Gi=(e,t,n,r=Pi)=>{let i=Tt(t);Wi(i,e,n,new r(i))},Ki=(e,t,n)=>Gi(e,t,n,Mi),qi=(e,t,n=new Map)=>{Bi(e,t.store,n),Di(e,Ei(t.store))},Ji=(e,t=new Uint8Array([0]),n=new Ri)=>{qi(n,e,Zi(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Za(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Ii)return Ja(r.map((e,t)=>t===0?e:no(e)));if(n.constructor===Ri)return Xa(r)}return r[0]},Yi=(e,t)=>Ji(e,t,new Ii),Xi=e=>{let t=new Map,n=O(e.restDecoder);for(let r=0;r<n;r++){let n=O(e.restDecoder),r=O(e.restDecoder);t.set(n,r)}return t},Zi=e=>Xi(new ji(Tt(e))),Qi=(e,t)=>(S(e.restEncoder,t.size),_(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{S(e.restEncoder,t),S(e.restEncoder,n)}),e),$i=(e,t)=>Qi(e,Da(t.store)),ea=(e,t=new Li)=>(e instanceof Map?Qi(t,e):$i(t,e),t.toUint8Array()),ta=e=>ea(e,new Fi),na=class{constructor(){this.l=[]}},ra=()=>new na,ia=(e,t)=>e.l.push(t),aa=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},oa=(e,t,n)=>ln(e.l,[t,n]),sa=class{constructor(e,t){this.client=e,this.clock=t}},ca=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,L=(e,t)=>new sa(e,t),la=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw E()},ua=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},da=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},fa=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},pa=e=>new da(e.type==null?null:L(e.type.client,e.type.clock),e.tname??null,e.item==null?null:L(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),ma=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ha=(e,t,n=0)=>new ma(e,t,n),ga=(e,t,n)=>{let r=null,i=null;return e._item===null?i=la(e):r=L(e._item.id.client,e._item.id.clock),new da(r,i,t,n)},_a=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ga(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ga(e,L(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ga(e,r.lastId,n);r=r.right}return ga(e,null,n)},va=(e,t)=>{let n=ka(e,t);return{item:n,diff:t.clock-n.id.clock}},ya=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(R(r,i.client)<=i.clock)return null;let e=n?Hs(r,i):va(r,i),t=e.item;if(!(t instanceof J))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(R(r,a.client)<=a.clock)return null;let{item:e}=n?Hs(r,a):{item:ka(r,a)};if(e instanceof J&&e.content instanceof q)c=e.content.type;else return null}else throw E();l=s>=0?c._length:0}return ha(c,l,e.assoc)},ba=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&ca(e.item,t.item)&&ca(e.type,t.type)&&e.assoc===t.assoc,xa=class{constructor(e,t){this.ds=e,this.sv=t}},Sa=(e,t)=>new xa(e,t);Sa(Ti(),new Map);var Ca=e=>Sa(Ei(e.store),Da(e.store)),wa=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!xi(t.ds,e.id),Ta=(e,t)=>{let n=h(e.meta,Ta,g),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<R(r,n)&&B(e,L(n,t))}),yi(e,t.ds,e=>{}),n.add(t))},Ea=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Da=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},R=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Oa=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw E()}n.push(t)},z=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=y(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=y((n+r)/2)}throw E()},ka=(e,t)=>{let n=e.clients.get(t.client);return n[z(n,t.clock)]},Aa=(e,t,n)=>{let r=z(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,Ws(e,i,n-i.id.clock)),r+1):r},B=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Aa(e,n,t.clock)]},ja=(e,t,n)=>{let r=t.clients.get(n.client),i=z(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==W&&r.splice(i+1,0,Ws(e,a,n.clock-a.id.clock+1)),a},Ma=(e,t,n)=>{let r=e.clients.get(t.id.client);r[z(r,t.id.clock)]=n},Na=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Aa(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Aa(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Pa=class{constructor(e,t,n){this.doc=e,this.deleteSet=new vi,this.beforeState=Da(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Fa=(e,t)=>t.deleteSet.clients.size===0&&!pe(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Si(t.deleteSet),Ui(e,t),Di(e,t.deleteSet),!0),Ia=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&h(e.changed,t,g).add(n)},La=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Ra=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=z(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},za=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=Se(r.length-1,1+z(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+La(r,e)}})},Ba=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Si(a),n.afterState=Da(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{oa(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&es(n)})}),ln(e,[])}finally{r.gc&&Ra(a,i,r.gcFilter),za(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Ce(z(e,r),1);for(let t=e.length-1;t>=n;)t-=1+La(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=z(r,n);a+1<r.length&&La(r,a+1)>1||a>0&&La(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(di(oi,$r,`[yjs] `,ei,ii,`Changed the client-id because another client seems to be using it.`),r.clientID=Ai()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Ii;Fa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Ri;Fa(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Ba(e,t+1)}}},V=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Pa(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Ba(i,0)}}return o},Va=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ha=(e,t,n)=>{yi(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||ua(t,n))&&Us(n,!1)})},Ua=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;V(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;yi(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Hs(r,e.id);i>0&&(t=B(n,L(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ua(t,e))&&c.push(e)}}),yi(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||ua(t,e))&&!xi(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Ks(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Wa=class extends ye{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=v(e)?e[0].doc:e instanceof I?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new vi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&wi(i,n,r,a)});let a=Wt(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Ci([t.deletions,e.deleteSet]),t.insertions=Ci([t.insertions,i])}else r.push(new Va(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),yi(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||ua(n,t))&&Us(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=v(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof U?e.doc!==this.doc:e!==this.doc)&&fi(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ha(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ha(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Ua(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ua(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*Ga(e){let t=O(e.restDecoder);for(let n=0;n<t;n++){let t=O(e.restDecoder),n=e.readClient(),r=O(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=O(e.restDecoder);yield new Y(L(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(L(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,qs(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new W(L(n,r),t),r+=t}}}}var Ka=class{constructor(e,t){this.gen=Ga(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Y);return this.curr}},qa=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Ja=e=>Xa(e,Mi,Ii),Ya=(e,t)=>{if(e.constructor===W){let{client:n,clock:r}=e.id;return new W(L(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(L(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(L(r,i+t),null,L(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Xa=(e,t=Pi,n=Ri)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Tt(e))),i=r.map(e=>new Ka(e,!0)),a=null,o=new n,s=new qa(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Y?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)$a(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{$a(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(L(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Y?a.struct.length-=t:n=Ya(n,t)),a.struct.mergeWith(n)||($a(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Y;n=e.next())$a(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&($a(s,a.struct,a.offset),a=null),eo(s),Di(o,Ci(r.map(e=>Oi(e)))),o.toUint8Array()},Za=(e,t,n=Pi,r=Ri)=>{let i=Zi(t),a=new r,o=new qa(a),s=new n(Tt(e)),c=new Ka(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for($a(o,e,Ce(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)$a(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return eo(o),Di(a,Oi(s)),a.toUint8Array()},Qa=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:b(e.encoder.restEncoder)}),e.encoder.restEncoder=$e(),e.written=0)},$a=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Qa(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),S(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},eo=e=>{Qa(e);let t=e.encoder.restEncoder;S(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];S(t,r.written),ct(t,r.restEncoder)}},to=(e,t,n,r)=>{let i=new n(Tt(e)),a=new Ka(i,!1),o=new r,s=new qa(o);for(let e=a.curr;e!==null;e=a.next())$a(s,t(e),0);return eo(s),Di(o,Oi(i)),o.toUint8Array()},no=e=>to(e,un,Pi,Ii),ro=`You must not compute changes after the event-handler fired.`,io=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=ao(this.currentTarget,this.target)}deletes(e){return xi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw w(ro);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=me(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=me(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=me(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw w(ro);let t=this.target,n=g(),r=g(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},ao=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},H=()=>{fi(`Invalid access: Add Yjs type to a document before reading data.`)},oo=80,so=0,co=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=so++}},lo=e=>{e.timestamp=so++},uo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=so++},fo=(e,t,n)=>{if(e.length>=oo){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return uo(r,t,n),r}else{let r=new co(t,n);return e.push(r),r}},po=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>xe(t-e.index)<xe(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,lo(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&xe(n.index-i)<r.parent.length/oo?(uo(n,r,i),n):fo(e._searchMarker,r,i)},mo=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Ce(t,i.index+n))}},ho=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;h(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;oa(r._eH,n,t)},U=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ra(),this._dEH=ra(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw T()}clone(){throw T()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ia(this._eH,e)}observeDeep(e){ia(this._dEH,e)}unobserve(e){aa(this._eH,e)}unobserveDeep(e){aa(this._dEH,e)}toJSON(){}},go=(e,t,n)=>{e.doc??H(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},_o=e=>{e.doc??H();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},vo=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&wa(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},yo=(e,t)=>{let n=0,r=e._start;for(e.doc??H();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},bo=(e,t)=>{let n=[];return yo(e,(r,i)=>{n.push(t(r,i,e))}),n},xo=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},So=(e,t)=>{e.doc??H();let n=po(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Co=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new As(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new _s(new Uint8Array(n))),i.integrate(e,0);break;case I:i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ss(n)),i.integrate(e,0);break;default:if(n instanceof U)i=new J(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new q(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},wo=()=>w(`Length exceeded!`),To=(e,t,n,r)=>{if(n>t._length)throw wo();if(n===0)return t._searchMarker&&mo(t._searchMarker,n,r.length),Co(e,t,null,r);let i=n,a=po(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&B(e,L(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&mo(t._searchMarker,i,r.length),Co(e,t,o,r)},Eo=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Co(e,t,r,n)},Do=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=po(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&B(e,L(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&B(e,L(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw wo();t._searchMarker&&mo(t._searchMarker,i,-a+r)},Oo=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},ko=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new As([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new As([r]);break;case Uint8Array:s=new _s(r);break;case I:s=new Ss(r);break;default:if(r instanceof U)s=new q(r);else throw Error(`Unexpected content type`)}new J(L(o,R(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Ao=(e,t)=>{e.doc??H();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},jo=e=>{let t={};return e.doc??H(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Mo=(e,t)=>{e.doc??H();let n=e._map.get(t);return n!==void 0&&!n.deleted},No=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&wa(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Po=e=>(e.doc??H(),hi(e._map.entries(),e=>!e[1].deleted)),Fo=class extends io{},Io=class e extends U{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof U?e.clone():e)),t}get length(){return this.doc??H(),this._length}_callObserver(e,t){super._callObserver(e,t),ho(this,e,new Fo(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):V(this.doc,n=>{To(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):V(this.doc,t=>{Eo(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):V(this.doc,n=>{Do(n,this,e,t)})}get(e){return So(this,e)}toArray(){return _o(this)}slice(e=0,t=this.length){return go(this,e,t)}toJSON(){return this.map(e=>e instanceof U?e.toJSON():e)}map(e){return bo(this,e)}forEach(e){yo(this,e)}[Symbol.iterator](){return xo(this)}_write(e){e.writeTypeRef(Ps)}},Lo=e=>new Io,Ro=class extends io{constructor(e,t,n){super(e,t),this.keysChanged=n}},zo=class e extends U{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof U?e.clone():e)}),t}_callObserver(e,t){ho(this,e,new Ro(this,e,t))}toJSON(){this.doc??H();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof U?r.toJSON():r}}),e}get size(){return[...Po(this)].length}keys(){return gi(Po(this),e=>e[0])}values(){return gi(Po(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return gi(Po(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??H(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):V(this.doc,t=>{Oo(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):V(this.doc,n=>{ko(n,this,e,t)}),t}get(e){return Ao(this,e)}has(e){return Mo(this,e)}clear(){this.doc===null?this._prelimContent.clear():V(this.doc,e=>{this.forEach(function(t,n,r){Oo(e,r,n)})})}_write(e){e.writeTypeRef(Fs)}},Bo=e=>new zo,Vo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&on(e,t),Ho=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&E(),this.right.content.constructor){case G:this.right.deleted||Ko(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},Uo=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case G:t.right.deleted||Ko(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&B(e,L(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Wo=(e,t,n,r)=>{let i=new Map,a=r?po(t,n):null;return a?Uo(e,new Ho(a.p.left,a.p,a.index,i),n-a.index):Uo(e,new Ho(null,t._start,0,i),n)},Go=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===G&&Vo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J(L(a,R(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new G(o,r));l.integrate(e,0),n.right=l,n.forward()})},Ko=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},qo=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===G&&Vo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Jo=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Vo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(L(a,R(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new G(s,c)),n.right.integrate(e,0),n.forward()}}return o},Yo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;qo(n,i);let s=Jo(e,t,n,i),c=r.constructor===String?new K(r):r instanceof U?new q(r):new ws(r),{left:l,right:u,index:d}=n;t._searchMarker&&mo(t._searchMarker,n.index,c.getLength()),u=new J(L(o,R(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Go(e,t,n,s)},Xo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;qo(n,i);let s=Jo(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===G));){if(!n.right.deleted)switch(n.right.content.constructor){case G:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Vo(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&B(e,L(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
3
3
  `;n.right=new J(L(o,R(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new K(i)),n.right.integrate(e,0),n.forward()}Go(e,t,n,s)},Zo=(e,t,n,r,i)=>{let a=t,o=m();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===G){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case G:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Ko(i,n);break}}}t=t.right}return s},Qo=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===G){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},$o=e=>{let t=0;return V(e.doc,n=>{let r=e._start,i=e._start,a=m(),o=de(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case G:Ko(o,i.content);break;default:t+=Zo(n,r,i,a,o),a=de(o),r=i;break}i=i.right}}),t},es=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Na(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===G&&e.constructor!==W&&t.add(e.parent)})}V(n,n=>{yi(e,e.deleteSet,e=>{if(e instanceof W||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===G?t.add(r):Qo(n,e)});for(let e of t)$o(e)})},ts=(e,t,n)=>{let r=n,i=de(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case ws:case K:n<t.right.length&&B(e,L(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Zo(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&mo(o._searchMarker,t.index,-r+n),t},ns=class extends io{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];V(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},nn(o)||(e.attributes=Qt({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case q:case ws:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case K:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case G:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Vo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Vo(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Vo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Vo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Ko(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},rs=class e extends U{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??H(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new ns(this,e,t);ho(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??H();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===K&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):V(this.doc,n=>{let r=new Ho(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
4
4
  `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Yo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&ts(n,r,a.delete):Xo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??H();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(wa(s,e)||t!==void 0&&wa(s,t))switch(s.content.constructor){case K:{let r=i.get(`ychange`);e!==void 0&&!wa(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!wa(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case q:case ws:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case G:wa(s,e)&&(c(),Ko(i,s.content));break}s=s.right}c()};return e||t?V(a,n=>{e&&Ta(n,e),t&&Ta(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):V(r,r=>{let i=Wo(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Yo(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):V(r,r=>{let i=Wo(r,this,e,!n);Yo(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):V(n,n=>{ts(n,Wo(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):V(r,r=>{let i=Wo(r,this,e,!1);i.right!==null&&Xo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):V(this.doc,t=>{Oo(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):V(this.doc,n=>{ko(n,this,e,t)})}getAttribute(e){return Ao(this,e)}getAttributes(){return jo(this)}_write(e){e.writeTypeRef(Is)}},is=e=>new rs,as=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??H()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===cs||t.constructor===os)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},os=class e extends U{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof U?e.clone():e)),t}get length(){return this.doc??H(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new as(this,e)}querySelector(e){e=e.toUpperCase();let t=new as(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),_(new as(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ho(this,e,new us(this,t,e))}toString(){return bo(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),yo(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):V(this.doc,n=>{To(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)V(this.doc,n=>{let r=e&&e instanceof U?e._item:e;Co(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw w(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):V(this.doc,n=>{Do(n,this,e,t)})}toArray(){return _o(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return So(this,e)}slice(e=0,t=this.length){return go(this,e,t)}forEach(e){yo(this,e)}_write(e){e.writeTypeRef(Rs)}},ss=e=>new os,cs=class e extends os{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return en(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof U?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):V(this.doc,t=>{Oo(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):V(this.doc,n=>{ko(n,this,e,t)})}getAttribute(e){return Ao(this,e)}hasAttribute(e){return Mo(this,e)}getAttributes(e){return e?No(this,e):jo(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return yo(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ls),e.writeKey(this.nodeName)}},ls=e=>new cs(e.readKey()),us=class extends io{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},ds=class e extends zo{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(zs),e.writeKey(this.hookName)}},fs=e=>new ds(e.readKey()),ps=class e extends rs{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Bs)}},ms=e=>new ps,hs=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw T()}mergeWith(e){return!1}write(e,t,n){throw T()}integrate(e,t){throw T()}},gs=0,W=class extends hs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Oa(e.doc.store,this)}write(e,t){e.writeInfo(gs),e.writeLen(this.length-t)}getMissing(e,t){return null}},_s=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw T()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},vs=e=>new _s(e.readBuf()),ys=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){wi(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},bs=e=>new ys(e.readLen()),xs=(e,t)=>new I({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Ss=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(xs(this.doc.guid,this.opts))}splice(e){throw T()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Cs=e=>new Ss(xs(e.readString(),e.readAny())),ws=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw T()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Ts=e=>new ws(e.readJSON()),G=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw T()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Es=e=>new G(e.readKey(),e.readJSON()),Ds=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Os=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Ds(n)},ks=vn(`node_env`)===`development`,As=class e{constructor(e){this.arr=e,ks&&cn(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},js=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new As(n)},K=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Ms=e=>new K(e.readString()),Ns=[Lo,Bo,is,ls,ss,fs,ms],Ps=0,Fs=1,Is=2,Ls=3,Rs=4,zs=5,Bs=6,q=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw T()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Vs=e=>new q(Ns[e.readTypeRef()](e)),Hs=(e,t)=>{let n=t,r=0,i;do r>0&&(n=L(n.client,n.clock+r)),i=ka(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Us=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Ws=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(L(r,i+n),t,L(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=L(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Gs=(e,t)=>_e(e,e=>xi(e.deletions,t)),Ks=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return B(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ks(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=B(e,u.redone)}let ee=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:B(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:B(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||xi(r,d.right.id)||Gs(a.undoStack,d.right.id)||Gs(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=B(e,d.redone);if(d&&d.right!==null)return null}else d=ee._map.get(t.parentSub)||null;let te=L(c,R(s,c)),ne=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,Us(ne,!0),ne.integrate(e,0),ne},J=class e extends hs{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=R(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=R(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===sa&&this.id.client!==this.parent.client&&this.parent.clock>=R(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=ja(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=B(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===W||this.right&&this.right.constructor===W)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===sa){let e=ka(n,this.parent);e.constructor===W?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ja(e,e.doc.store,L(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),ca(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ca(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(ka(e.doc.store,n.origin)))r.has(ka(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Oa(e.doc.store,this),this.content.integrate(e,this),Ia(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new W(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:L(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ca(e.origin,this.lastId)&&this.right===e&&ca(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),wi(e.deleteSet,this.id.client,this.id.clock,this.length),Ia(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw E();this.content.gc(e),t?Ma(e,this,new W(this.id,this.length)):this.content=new ys(this.length)}write(e,t){let n=t>0?L(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=la(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===sa?(e.writeParentInfo(!1),e.writeLeftID(t)):E();i!==null&&e.writeString(i)}this.content.write(e,t)}},qs=(e,t)=>Js[t&31](e),Js=[()=>{E()},bs,Os,vs,Ms,Ts,Es,Vs,js,Cs,()=>{E()}],Ys=10,Y=class extends hs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){E()}write(e,t){e.writeInfo(Ys),S(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Xs=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Zs=`__ $YJS$ __`;Xs[Zs]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Xs[Zs]=!0;var Qs=Math.floor,$s=(e,t)=>e<t?e:t,ec=(e,t)=>e>t?e:t;Number.isNaN;var tc=128,nc=1<<17,rc=1<<18,ic=1<<19,ac=1<<20,oc=1<<21,sc=1<<22,cc=1<<23,lc=1<<24,uc=1<<25,dc=1<<26,fc=1<<27,pc=1<<28,mc=1<<29,hc=1<<30,gc=127;nc-1,rc-1,ic-1,ac-1,oc-1,sc-1,cc-1,lc-1,uc-1,dc-1,fc-1,pc-1,mc-1,hc-1;var _c=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var vc=String.fromCharCode;String.fromCodePoint,vc(65535);var yc=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},bc=typeof TextEncoder<`u`?new TextEncoder:null,xc=bc?e=>bc.encode(e):yc,Sc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Sc&&Sc.decode(new Uint8Array).length===1&&(Sc=null);var Cc=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},wc=(e,t)=>{for(;t>gc;)Cc(e,tc|gc&t),t=Qs(t/128);Cc(e,gc&t)},Tc=new Uint8Array(3e4),Ec=Tc.length/3,Dc=bc&&bc.encodeInto?(e,t)=>{if(t.length<Ec){let n=bc.encodeInto(t,Tc).written||0;wc(e,n);for(let t=0;t<n;t++)Cc(e,Tc[t])}else kc(e,xc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;wc(e,r);for(let t=0;t<r;t++)Cc(e,n.codePointAt(t))},Oc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=$s(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ec(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},kc=(e,t)=>{wc(e,t.byteLength),Oc(e,t)},Ac=e=>Error(e),jc=Ac(`Unexpected end of array`),Mc=Ac(`Integer out of Range`),Nc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Pc=e=>Nc(e,Ic(e)),Fc=e=>e.arr[e.pos++],Ic=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&gc)*n,n*=128,r<tc)return t;if(t>_c)throw Mc}throw jc},Lc=Sc?e=>Sc.decode(Pc(e)):e=>{let t=Ic(e);if(t===0)return``;{let n=String.fromCodePoint(Fc(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Fc(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Rc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),zc=(e,t)=>{wc(e,Rc.Token),Dc(e,t)},Bc=(e,t,n,r)=>{switch(Ic(e)){case Rc.Token:t();break;case Rc.PermissionDenied:n(Lc(e));break;case Rc.Authenticated:r(Lc(e));break;default:}},Vc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Hc=`\0`;function Uc(e,t){return e+Hc+t}function Wc(e){let t=e.indexOf(Hc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Gc=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function Kc(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function qc(e){return new Promise(t=>setTimeout(t,e))}function Jc(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function Yc(e,t){let n=Kc(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Jc;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await qc(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await qc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await qc(e)}return a()}var Xc=Math.floor,Zc=(e,t)=>e<t?e:t,Qc=(e,t)=>e>t?e:t;Number.isNaN;var $c=64,el=128,tl=1<<17,nl=1<<18,rl=1<<19,il=1<<20,al=1<<21,ol=1<<22,sl=1<<23,cl=1<<24,ll=1<<25,ul=1<<26,dl=1<<27,fl=1<<28,pl=1<<29,ml=1<<30,hl=63,gl=127;tl-1,nl-1,rl-1,il-1,al-1,ol-1,sl-1,cl-1,ll-1,ul-1,dl-1,fl-1,pl-1,ml-1;var _l=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var vl=()=>new Set,yl=Array.from;Array.isArray;var bl=String.fromCharCode;String.fromCodePoint,bl(65535);var xl=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Sl=typeof TextEncoder<`u`?new TextEncoder:null,Cl=Sl?e=>Sl.encode(e):xl,wl=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});wl&&wl.decode(new Uint8Array).length===1&&(wl=null);var Tl=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},El=()=>new Tl,Dl=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Ol=e=>{let t=new Uint8Array(Dl(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},kl=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},X=(e,t)=>{for(;t>gl;)kl(e,el|gl&t),t=Xc(t/128);kl(e,gl&t)},Al=new Uint8Array(3e4),jl=Al.length/3,Z=Sl&&Sl.encodeInto?(e,t)=>{if(t.length<jl){let n=Sl.encodeInto(t,Al).written||0;X(e,n);for(let t=0;t<n;t++)kl(e,Al[t])}else Nl(e,Cl(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)kl(e,n.codePointAt(t))},Ml=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Zc(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Qc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Nl=(e,t)=>{X(e,t.byteLength),Ml(e,t)},Pl=e=>Error(e),Fl=Pl(`Unexpected end of array`),Il=Pl(`Integer out of Range`),Ll=class{constructor(e){this.arr=e,this.pos=0}},Rl=e=>new Ll(e),zl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Bl=e=>zl(e,Hl(e)),Vl=e=>e.arr[e.pos++],Hl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&gl)*n,n*=128,r<el)return t;if(t>_l)throw Il}throw Fl},Ul=e=>{let t=e.arr[e.pos++],n=t&hl,r=64,i=(t&$c)>0?-1:1;if((t&el)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&gl)*r,r*=128,t<el)return i*n;if(n>_l)throw Il}throw Fl},Wl=wl?e=>wl.decode(Bl(e)):e=>{let t=Hl(e);if(t===0)return``;{let n=String.fromCodePoint(Vl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Vl(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Gl=e=>{let t=e.pos,n=Wl(e);return e.pos=t,n},Kl=Date.now,ql=()=>new Map,Jl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Yl=class{constructor(){this._observers=ql()}on(e,t){Jl(this._observers,e,vl).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return yl((this._observers.get(e)||ql()).values()).forEach(e=>e(...t))}destroy(){this._observers=ql()}},Xl=Symbol(`Equality`),Zl=Object.keys,Ql=e=>Zl(e).length,$l=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),eu=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Xl]!=null)return e[Xl](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!eu(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Ql(e)!==Ql(t))return!1;for(let n in e)if(!$l(e,n)||!eu(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!eu(e[n],t[n]))return!1;break;default:return!1}return!0},tu=3e4,nu=class extends Yl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Kl();this.getLocalState()!==null&&tu/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&tu<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&ru(this,t,`timeout`)},Xc(tu/10)),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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Kl()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),eu(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},ru=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Kl()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},iu=(e,t,n=e.states)=>{let r=t.length,i=El();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return Ol(i)},au=(e,t,n)=>{let r=Rl(t),i=Kl(),a=[],o=[],s=[],c=[],l=Hl(r);for(let t=0;t<l;t++){let t=Hl(r),n=Hl(r),l=JSON.parse(Wl(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(eu(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},ou=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},su=class{constructor(e){this.data=e,this.encoder=El(),this.decoder=Rl(new Uint8Array(this.data))}peekVarString(){return Gl(this.decoder)}readVarUint(){return Hl(this.decoder)}readVarString(){return Wl(this.decoder)}readVarUint8Array(){return Bl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return Nl(this.encoder,e)}length(){return Dl(this.encoder)}},Q=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),$=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),cu=class{constructor(){this.encoder=El()}get(e){return e.encoder}toUint8Array(){return Ol(this.encoder)}},lu=class extends cu{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),this.encoder}},uu=class e extends ou{static{this.DEDUPLICATABLE_TYPES=new Set([Q.Awareness,Q.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=$.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===$.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===$.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(lu,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===$.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:Yc(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=$.Connecting,this.emit(`status`,{status:$.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Kl();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new su(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=El();X(e,Q.Pong),this.send(Ol(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===$.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Kl()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=Rl(e);return{documentName:Wl(t),messageType:Hl(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===Gc.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},du=0,fu=1,pu=2,mu=(e,t)=>{X(e,du),Nl(e,ta(t))},hu=(e,t,n)=>{X(e,fu),Nl(e,Yi(t,n))},gu=(e,t,n)=>hu(t,n,Bl(e)),_u=(e,t,n,r)=>{try{Ki(t,Bl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},vu=(e,t)=>{X(e,pu),Nl(e,t)},yu=_u,bu=(e,t,n,r,i)=>{let a=Hl(e);switch(a){case du:gu(e,t,n);break;case fu:_u(e,n,r,i);break;case pu:yu(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},xu=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Q.Sync:this.applySyncMessage(e,t);break;case Q.Awareness:this.applyAwarenessMessage(e);break;case Q.Auth:this.applyAuthMessage(e);break;case Q.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Q.Stateless:e.receiveStateless(Wl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,Ul(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:Wl(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(cu,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=bu(n.decoder,n.encoder,e.document,e);t&&r===fu&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;au(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Bc(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(Q.Awareness),t.writeVarUint8Array(iu(e.awareness,Array.from(e.awareness.getStates().keys())))}},Su=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Ol(this.encoder)}send(e){e?.send(this.create())}},Cu=`4.0.0-rc.1`,wu=class extends cu{constructor(...e){super(...e),this.type=Q.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Z(this.encoder,e.documentName),X(this.encoder,this.type),zc(this.encoder,e.token),Z(this.encoder,Cu),this.encoder}},Tu=class extends cu{constructor(...e){super(...e),this.type=Q.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?iu(e.awareness,e.clients):iu(e.awareness,e.clients,e.states),Nl(this.encoder,t),this.encoder}},Eu=class extends cu{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(this.encoder,e.payload??``),this.encoder}},Du=class extends cu{constructor(...e){super(...e),this.type=Q.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return Z(this.encoder,e.documentName),X(this.encoder,this.type),mu(this.encoder,e.document),this.encoder}},Ou=class extends cu{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),vu(this.encoder,e.update),this.encoder}},ku=class extends Error{constructor(...e){super(...e),this.code=1001}},Au=class extends ou{get effectiveName(){return this.configuration.sessionAwareness?Uc(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new I,this.configuration.awareness=e.awareness===void 0?new nu(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:Vc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Vc(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new uu(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(Du,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&ru(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Eu,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(wu,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Ou,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Tu,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(Du,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Tu,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new Su(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new su(e.data),{documentName:n}=Wc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new su(e.data)}),new xu(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ru(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(ru(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new ku(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},ju={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.26.0`}?.VITE_APP_VERSION??`0.0.0-unknown`;function Mu(){return o({kind:`web`,runtimeVersion:ju})}function Nu(){return c({kind:`web`,runtimeVersion:ju})}function Pu(e,t,n=null,r=null){let i={...Nu()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}function Fu(e,t){let n=(0,ie.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,p.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,p.useEffect)(a,o)}function Iu(e){let t=(0,ie.c)(5),{setTheme:n}=i(),r;t[0]!==n||t[1]!==e?(r=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=r):r=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,p.useEffect)(r,a)}var Lu=n();function Ru(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function zu(e,t,n,r){let i=new I,o=new Au({url:e,name:t,document:i,token:Pu(null,r,null),onDisconnect:({event:e})=>Ru(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Ru(`config-provider`,t,`close`,e)}),s=a(o,n);return{binding:s,config:s.current(),cleanup:()=>{s.dispose(),o.destroy(),i.destroy()}}}function Bu(e,t){let n=new I,r=new Au({url:e,name:f,document:n,token:Pu(null,t,null),onDisconnect:({event:e})=>Ru(`okignore-provider`,f,`disconnect`,e),onClose:({event:e})=>Ru(`okignore-provider`,f,`close`,e)}),i=s(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function Vu(e){let t=(0,ie.c)(24),{collabUrl:n,children:r}=e,i=ue(),[a,o]=(0,p.useState)(null),[s,c]=(0,p.useState)(null),[f,te]=(0,p.useState)(null),[re,ae]=(0,p.useState)(null),oe,se;t[0]!==n||t[1]!==i?(oe=()=>{if(n===null)return;let e=zu(n,l,`user`,i),t=zu(n,d,`project`,i),r=zu(n,u,`project-local`,i),a=Bu(n,i);o({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),c({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),te({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),ae({binding:a.binding,synced:!1});let s=e.binding.subscribe(t=>{o(n=>n?.binding===e.binding?{...n,config:t}:n)}),f=e.binding.subscribeSynced(()=>{o(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),ee=t.binding.subscribe(e=>{c(n=>n?.binding===t.binding?{...n,config:e}:n)}),ne=t.binding.subscribeSynced(()=>{c(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),re=r.binding.subscribe(e=>{te(t=>t?.binding===r.binding?{...t,config:e}:t)}),ie=r.binding.subscribeSynced(()=>{te(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),p=()=>{ae(e=>e?.binding===a.binding?{...e,synced:!0}:e)};return a.provider.on(`synced`,p),()=>{s(),f(),ee(),ne(),re(),ie(),a.provider.off(`synced`,p);for(let n of[e,t,r,a])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}o(t=>t?.binding===e.binding?null:t),c(e=>e?.binding===t.binding?null:e),te(e=>e?.binding===r.binding?null:e),ae(e=>e?.binding===a.binding?null:e)}},se=[n,i],t[0]=n,t[1]=i,t[2]=oe,t[3]=se):(oe=t[2],se=t[3]),(0,p.useEffect)(oe,se);let ce;t[4]!==f?.config||t[5]!==s||t[6]!==a?(ce=a&&s?ee(a.config,s.config,f?.config):null,t[4]=f?.config,t[5]=s,t[6]=a,t[7]=ce):ce=t[7];let le=ce,m=le?.appearance?.theme;Iu(m),Fu(typeof window<`u`?window.okDesktop:void 0,m??`system`);let de=a?.binding??null,h=a?.synced??!1,fe=s?.binding??null,pe=f?.binding??null,g=re?.binding??null,me=re?.synced??!1,he=a?.config??null,_=s?.config??null,ge=s?.synced??!1,_e=f?.config??null,ve=f?.synced??!1,v;t[8]!==le||t[9]!==he||t[10]!==_||t[11]!==ge||t[12]!==_e||t[13]!==ve||t[14]!==de||t[15]!==h||t[16]!==fe||t[17]!==pe||t[18]!==g||t[19]!==me?(v={userBinding:de,userSynced:h,projectBinding:fe,projectLocalBinding:pe,okignoreBinding:g,okignoreSynced:me,userConfig:he,projectConfig:_,projectSynced:ge,projectLocalConfig:_e,projectLocalSynced:ve,merged:le},t[8]=le,t[9]=he,t[10]=_,t[11]=ge,t[12]=_e,t[13]=ve,t[14]=de,t[15]=h,t[16]=fe,t[17]=pe,t[18]=g,t[19]=me,t[20]=v):v=t[20];let ye=v,be;return t[21]!==r||t[22]!==ye?(be=(0,Lu.jsx)(ne,{value:ye,children:r}),t[21]=r,t[22]=ye,t[23]=be):be=t[23],be}export{Le as $,la as A,Ur as B,pa as C,Yi as D,Zi as E,Ca as F,mn as G,A as H,V as I,Gt as J,rn as K,vo as L,ua as M,yi as N,ta as O,fa as P,E as Q,Qr as R,L as S,Sa as T,Tn as U,Wr as V,Cn as W,w as X,Vt as Y,T as Z,Ki as _,Au as a,h as at,ya as b,q as c,da as d,Ce as et,xa as f,ps as g,cs as h,Mu as i,m as it,xi as j,z as k,I as l,rs as m,Fu as n,be as nt,G as o,ce as ot,Wa as p,$t as q,Pu as r,g as rt,K as s,re as st,Vu as t,Se as tt,J as u,Gi as v,_a as w,Ti as x,ba as y,P as z};