@inkeep/open-knowledge 0.50.0-beta.0 → 0.50.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-LTFljjjT.mjs → acp-harness-probe-B2O8b7vV.mjs} +2 -2
- package/dist/cli.mjs +62 -62
- package/dist/constants-DSWWdx8p.mjs +2 -0
- package/dist/git-handle-Bit5ywOl.mjs +1 -0
- package/dist/{git-handle-B9WUn7B2.mjs → git-handle-Dxwd5VZx.mjs} +2 -2
- package/dist/index.d.mts +37 -6
- package/dist/index.mjs +117 -117
- package/dist/init-0d3ew4vm.mjs +1 -0
- package/dist/{init-DoE9fKH8.mjs → init-4ofrk0JJ.mjs} +3 -3
- package/dist/{launch-json-removal--afgb0jV.mjs → launch-json-removal-C9nV7D7y.mjs} +2 -2
- package/dist/loader-AtToxX4x.mjs +1 -0
- package/dist/{loader-C00kGDZz.mjs → loader-CPqAK5Ri.mjs} +2 -2
- package/dist/md-manager-DAm5uhV1.mjs +2 -0
- package/dist/{open-browser-BuOrhXvS.mjs → open-browser-BeG-Qyr0.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-CMjft0ek.mjs → preview-D8ff_aYG.mjs} +2 -2
- package/dist/preview-nbLafS3W.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-HRSmxB9_.js → ActivityModeContent-tZoww6TE.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-BGYo5UN6.js → AgentDiffPane-RQKV9x4r.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-0uU00Tq4.js → AgentThreadClientBinder-DcMbo1L-.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-CG45zoCT.js → ChangedOutsideBadge-DDfgk0eX.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-B__Dqs8P.js → CodeMirrorPropInput-CdGGv03H.js} +2 -2
- package/dist/public/assets/{DocumentContext-Dxzqsjf0.js → DocumentContext-D4iAETgy.js} +9 -9
- package/dist/public/assets/{EditorModeToggle-OACqdrIA.js → EditorModeToggle-Dz5xVGpy.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DBMws9uC.js → EnableSyncConfirmDialog-CLmAu8o9.js} +1 -1
- package/dist/public/assets/FeedbackForm-DnQ1QxLQ.js +1 -0
- package/dist/public/assets/{GraphPanel-BlBOG-me.js → GraphPanel-D0ikjJ7b.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-CgeVAxXn.js → ImportSkillDialog-BjcIqYkh.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-v0oqzBfd.js → LintConfigEditor-Yk4196ji.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-D4_7P1io.js +2 -0
- package/dist/public/assets/ManagedArtifactProperties-wYo67QNN.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-DcaMMYmf.js → McpConsentDialogBody-CnYmnzCt.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-YEj8k0Fj.js → MermaidDocEditor-BimLfRlC.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-f7fl9dVO.js → ReportBugDialogBody-C-PxBPo3.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-C_BBar0x.js → SchemaConfigEditor-PBcainDT.js} +1 -1
- package/dist/public/assets/{SessionsHost-DPObQsYR.js → SessionsHost-BgdbnOid.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-C53PpDiP.js → SettingsDialogBody-5ydE1HAX.js} +4 -4
- package/dist/public/assets/{ShareBranchSwitchDialog-DMbjNni-.js → ShareBranchSwitchDialog-E4sJceRx.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-DMLSpBoi.js → ShareReceiveDialog-CZ8wF8EG.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-TTjnDvC9.js → ShareReceiveMissDialog-Ff2iKkDU.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-Dmsi4hSW.js → SkillEditBanner-LZDhvyzV.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-BoGssBkU.js → SkillOriginInline-CfZfwviY.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-C8yypIJ3.js → SkillToolbarControls-BwnWrxnA.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-CWIkYgNX.js → SlidesToolbarControls-B_tRlqt3.js} +1 -1
- package/dist/public/assets/SourceEditor-DU-zzoJo.js +1 -0
- package/dist/public/assets/{TerminalPanel-D_OODFVz.js → TerminalPanel-DnS0vsLe.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-Dwoah4yb.js → TerminalWindowApp-B2fvTB6m.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DzdzVGmP.js → TextDocEditor-CbIK48pc.js} +1 -1
- package/dist/public/assets/{ThreadView-DJxvdzfd.js → ThreadView-C8wyEp28.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-D5U46urB.js → TimelineDiffPane-CDc4yUVO.js} +1 -1
- package/dist/public/assets/{agent-diff-store-DmpkFUx3.js → agent-diff-store-C8dyF7LO.js} +1 -1
- package/dist/public/assets/{auth-state-cache-Dm1J9vyz.js → auth-state-cache-C5lSklJm.js} +4 -4
- package/dist/public/assets/{client-version-BbTOZkhQ.js → client-version-Brtmi6Tl.js} +1 -1
- package/dist/public/assets/{comment-chips-CNh6cTT4.js → comment-chips-CE2VnZuT.js} +1 -1
- package/dist/public/assets/config-provider-zCjx6lVk.js +5 -0
- package/dist/public/assets/{dist-TVrIGknK2.js → dist-BBh-Rx_62.js} +93 -93
- package/dist/public/assets/{doc-paths-BKAhPn1c.js → doc-paths-PNMXyOQj.js} +1 -1
- package/dist/public/assets/{documents-events-B6nWdFan.js → documents-events-C930MM9G.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-Dhf8gmFi.js → file-tree-adapter-D0uVE8rS.js} +1 -1
- package/dist/public/assets/{file-tree-utils-Cx1c51Ql.js → file-tree-utils-D9c8Kaxh.js} +1 -1
- package/dist/public/assets/{folder-config-api-CKhPo3Lt.js → folder-config-api-DnXS5Q8-.js} +1 -1
- package/dist/public/assets/{follow-file-BRGwJuKy.js → follow-file-DAC-ZC3M.js} +1 -1
- package/dist/public/assets/i18n-CGL69Msh.js +1 -0
- package/dist/public/assets/{index-Dask65mE.js → index-B9U39Y87.js} +108 -108
- package/dist/public/assets/{lint-config-client-KRlZx1_T.js → lint-config-client-Dnm7kl-A.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BAnqBevm.js → markdownlint-rule-browser-DjTNNqKF.js} +1 -1
- package/dist/public/assets/navigation-targets-hMP35CWp.js +1 -0
- package/dist/public/assets/{open-managed-artifact-tab-CgUiYJiR.js → open-managed-artifact-tab-BXbv1vZH.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-Crda7hlg.js → pending-receive-nav-store-BBGIBWy4.js} +1 -1
- package/dist/public/assets/prop-types-C8xSIHU7.js +1 -0
- package/dist/public/assets/{receive-store--Bc0z-E4.js → receive-store-Dy9Hb1sU.js} +1 -1
- package/dist/public/assets/{selection-context-CsRnyGFj.js → selection-context-CPtyx9WW.js} +1 -1
- package/dist/public/assets/{skill-actions-B7Cmxryy.js → skill-actions-mpV_nPtR.js} +2 -2
- package/dist/public/assets/{skill-scope-CwmLPgmT.js → skill-scope-q42erPyI.js} +1 -1
- package/dist/public/assets/{skills-api-DDfyPLwg.js → skills-api-DxH6BgPG.js} +1 -1
- package/dist/public/assets/{src-DfI4uz3u.js → src-hzPGvn2R.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DnM-Fz1E.js → tag-pill-input-KrIJOPkF.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-D8zAsaUV.js → target-navigation-intent-BPFSqMEn.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-Djf7X5gE.js → terminal-cli-display-BCPlwXFC.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-B76nHQ-9.js → terminal-launch-events-BDizFas3.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-CynEAJPS.js → terminal-telemetry-DGeT-gdl.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DzIKrNKg.js → typing-burst-detector-CFUTEwX8.js} +2 -2
- package/dist/public/assets/{uninstall-DT91VYMe.js → uninstall-DSQiimxB.js} +1 -1
- package/dist/public/assets/{use-activity-panel-CbIsW8Oq.js → use-activity-panel-4WV0PNPB.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-Cd_bVm8F.js → use-apply-config-color-theme-BT2P9Cg6.js} +1 -1
- package/dist/public/assets/{use-collab-url-DESxkkaS.js → use-collab-url-ByKwzGpm.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-D9HFWiME.js → use-live-xterm-theme-O1QzvrK2.js} +1 -1
- package/dist/public/assets/{use-open-skill-DyTRfvTr.js → use-open-skill-CqyjlzbO.js} +1 -1
- package/dist/public/assets/{use-settings-route-BXWhuQbZ.js → use-settings-route-BvOZe32W.js} +1 -1
- package/dist/public/assets/{use-skill-directory-BaP9hj7C.js → use-skill-directory-CL-lJ_fc.js} +1 -1
- package/dist/public/assets/{use-skill-origin-DBXnPKZS.js → use-skill-origin-BWwJ-V8H.js} +1 -1
- package/dist/public/assets/{use-skills-CVci-eTA.js → use-skills-CCrPufi9.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DDthawVX.js → use-terminal-enabled-CPGBEBb0.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BC2rFPLm.js → use-timeline-entry-diff-BjX3mxut.js} +1 -1
- package/dist/public/assets/{use-workspace-CAcWHNxj.js → use-workspace-B4DagT1C.js} +1 -1
- package/dist/public/index.html +44 -44
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-DWyYbCft.mjs → repair-launch-json-D51ljyuu.mjs} +2 -2
- package/dist/{repair-mcp-configs-IqhFyLaP.mjs → repair-mcp-configs-DayNzsuC.mjs} +2 -2
- package/dist/{repair-skills-DwcUYwoH.mjs → repair-skills-Dz6gjuVz.mjs} +2 -2
- package/dist/repair-skills-kKrHm4Sp.mjs +1 -0
- package/dist/server-lock-DLY6qJ31.mjs +1 -0
- package/dist/server-lock-_SrmIVon.mjs +2 -0
- package/dist/{skill-teardown-DzuNnHSF.mjs → skill-teardown-N2at_ImB.mjs} +2 -2
- package/dist/{src-Cb3i1kcm.mjs → src-BgYGdjBz.mjs} +123 -123
- package/dist/src-DDAV9cNj.mjs +1 -0
- package/dist/src-DJHJJDlb.mjs +1 -0
- package/dist/{src-BmsPBIN0.mjs → src-DVIrkd60.mjs} +4 -4
- package/dist/src-DexEZ0uX.mjs +2032 -0
- package/dist/start-Rl1Y20eU.mjs +1 -0
- package/dist/{start-CB1ruR88.mjs → start-Rw1sV-cl.mjs} +3 -3
- package/dist/{write-project-skill-DfjjNq9T.mjs → write-project-skill-DirISflr.mjs} +2 -2
- package/package.json +5 -5
- package/dist/constants-DKkdtsrQ.mjs +0 -2
- package/dist/git-handle-BfyNyc1q.mjs +0 -1
- package/dist/init-CUlzbSqG.mjs +0 -1
- package/dist/loader-Dd0F_wFU.mjs +0 -1
- package/dist/md-manager-DGG55-uN.mjs +0 -2
- package/dist/preview-D-x1bfxi.mjs +0 -1
- package/dist/public/assets/FeedbackForm-YQbdmBFL.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-BfO4jYnj.js +0 -2
- package/dist/public/assets/ManagedArtifactProperties-Dmjq1ugS.js +0 -1
- package/dist/public/assets/SourceEditor-D3dXest3.js +0 -1
- package/dist/public/assets/config-provider-CZ_6SNHv.js +0 -5
- package/dist/public/assets/i18n-iRTrMKQI.js +0 -1
- package/dist/public/assets/navigation-targets-BhdJAW-R.js +0 -1
- package/dist/public/assets/prop-types-CvU-2DkU.js +0 -1
- package/dist/repair-skills-Cl53MdUh.mjs +0 -1
- package/dist/server-lock-C5RpbiEy.mjs +0 -1
- package/dist/server-lock-DQ_whZyH.mjs +0 -2
- package/dist/src-BPPzfDas.mjs +0 -2032
- package/dist/src-CWRDxPCK.mjs +0 -1
- package/dist/src-DpX6KBvU.mjs +0 -1
- package/dist/start-BhtWVSU0.mjs +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./messages-B-LUKCxb.js","./chunk-CYidjpOJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{n as i}from"./dist-PQ5KMVDh.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{$t as o,Ar as s,Ca as c,Do as l,Jr as u,Ko as d,Pr as f,Sa as ee,Wr as te,Yo as ne,Zt as re,ba as ie,oo as ae,xa as oe,yo as se}from"./dist-TVrIGknK2.js";import{t as ce}from"./dist-DoS8xGN6.js";import{n as le}from"./dist-Bkx5dDHT2.js";import{f as ue,p as de,r as fe,s as pe}from"./use-apply-config-color-theme-Cd_bVm8F.js";import"./i18n-iRTrMKQI.js";import{r as me}from"./client-version-BbTOZkhQ.js";var he=a(),p=e(r(),1),ge=null,m=new Set;function _e(){return ge}function ve(e){let t=e!==null&&e.length>0?e:null;if(t!==ge){ge=t;for(let e of m)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ye(e){return m.add(e),()=>{m.delete(e)}}function be(){return(0,p.useSyncExternalStore)(ye,_e,_e)}var h=()=>new Map,xe=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Se=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Ce=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_=()=>new Set,we=e=>e[e.length-1],Te=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},v=Array.from,Ee=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},De=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Oe=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},y=Array.isArray,ke=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,_).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 v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},Ae=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,_).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 v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},b=Math.floor,je=Math.abs,Me=(e,t)=>e<t?e:t,Ne=(e,t)=>e>t?e:t;Number.isNaN;var Pe=e=>e===0?1/e<0:e<0,Fe=1<<17,Ie=1<<18,Le=1<<19,Re=1<<20,ze=1<<21,Be=1<<22,Ve=1<<23,He=1<<24,Ue=1<<25,We=1<<26,Ge=1<<27,Ke=1<<28,qe=1<<29;Fe-1,Ie-1,Le-1,Re-1,ze-1,Be-1,Ve-1,He-1,Ue-1,We-1,Ge-1,Ke-1,qe-1;var Je=2**53-1,Ye=-(2**53-1),Xe=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&b(e)===e);Number.isNaN,Number.parseInt;var Ze=String.fromCharCode;String.fromCodePoint,Ze(65535);var Qe=e=>e.toLowerCase(),$e=/^\s*/g,et=e=>e.replace($e,``),tt=/([A-Z])/g,nt=(e,t)=>et(e.replace(tt,e=>`${t}${Qe(e)}`)),rt=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},it=typeof TextEncoder<`u`?new TextEncoder:null,at=it?e=>it.encode(e):rt,ot=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});ot&&ot.decode(new Uint8Array).length===1&&(ot=null);var st=(e,t)=>Oe(t,()=>e).join(``),ct=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},lt=()=>new ct,ut=e=>{let t=lt();return e(t),x(t)},dt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},x=e=>{let t=new Uint8Array(dt(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},ft=(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(Ne(n,t)*2),e.cpos=0)},S=(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},pt=S,C=(e,t)=>{for(;t>127;)S(e,128|127&t),t=b(t/128);S(e,127&t)},mt=(e,t)=>{let n=Pe(t);for(n&&(t=-t),S(e,(t>63?128:0)|(n?64:0)|63&t),t=b(t/64);t>0;)S(e,(t>127?128:0)|127&t),t=b(t/128)},ht=new Uint8Array(3e4),gt=ht.length/3,_t=it&&it.encodeInto?(e,t)=>{if(t.length<gt){let n=it.encodeInto(t,ht).written||0;C(e,n);for(let t=0;t<n;t++)S(e,ht[t])}else w(e,at(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;C(e,r);for(let t=0;t<r;t++)S(e,n.codePointAt(t))},vt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Me(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(Ne(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},w=(e,t)=>{C(e,t.byteLength),vt(e,t)},yt=(e,t)=>{ft(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},bt=(e,t)=>yt(e,4).setFloat32(0,t,!1),xt=(e,t)=>yt(e,8).setFloat64(0,t,!1),St=(e,t)=>yt(e,8).setBigInt64(0,t,!1),Ct=new DataView(new ArrayBuffer(4)),wt=e=>(Ct.setFloat32(0,e),Ct.getFloat32(0)===e),Tt=(e,t)=>{switch(typeof t){case`string`:S(e,119),_t(e,t);break;case`number`:Xe(t)&&je(t)<=2147483647?(S(e,125),mt(e,t)):wt(t)?(S(e,124),bt(e,t)):(S(e,123),xt(e,t));break;case`bigint`:S(e,122),St(e,t);break;case`object`:if(t===null)S(e,126);else if(y(t)){S(e,117),C(e,t.length);for(let n=0;n<t.length;n++)Tt(e,t[n])}else if(t instanceof Uint8Array)S(e,116),w(e,t);else{S(e,118);let n=Object.keys(t);C(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];_t(e,i),Tt(e,t[i])}}break;case`boolean`:S(e,t?120:121);break;default:S(e,127)}},Et=class extends ct{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&C(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Dt=e=>{e.count>0&&(mt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&C(e.encoder,e.count-2))},Ot=class{constructor(){this.encoder=new ct,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Dt(this),this.count=1,this.s=e)}toUint8Array(){return Dt(this),x(this.encoder)}},kt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);mt(e.encoder,t),e.count>1&&C(e.encoder,e.count-2)}},At=class{constructor(){this.encoder=new ct,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(kt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return kt(this),x(this.encoder)}},jt=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Ot}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 ct;return this.sarr.push(this.s),this.s=``,_t(e,this.sarr.join(``)),vt(e,this.lensE.toUint8Array()),x(e)}},T=e=>Error(e),E=()=>{throw T(`Method unimplemented`)},D=()=>{throw T(`Unexpected case`)},Mt=T(`Unexpected end of array`),Nt=T(`Integer out of Range`),Pt=class{constructor(e){this.arr=e,this.pos=0}},Ft=e=>new Pt(e),It=e=>e.pos!==e.arr.length,Lt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},O=e=>Lt(e,k(e)),Rt=e=>e.arr[e.pos++],k=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>Je)throw Nt}throw Mt},zt=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>Je)throw Nt}throw Mt},Bt=ot?e=>ot.decode(O(e)):e=>{let t=k(e);if(t===0)return``;{let n=String.fromCodePoint(Rt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Rt(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))}},Vt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Ht=[e=>void 0,e=>null,zt,e=>Vt(e,4).getFloat32(0,!1),e=>Vt(e,8).getFloat64(0,!1),e=>Vt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Bt,e=>{let t=k(e),n={};for(let r=0;r<t;r++){let t=Bt(e);n[t]=Ut(e)}return n},e=>{let t=k(e),n=[];for(let r=0;r<t;r++)n.push(Ut(e));return n},O],Ut=e=>Ht[127-Rt(e)](e),Wt=class extends Pt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),It(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}},Gt=class extends Pt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=zt(this);let e=Pe(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}},Kt=class extends Pt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=zt(this),t=e&1;this.diff=b(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},qt=class{constructor(e){this.decoder=new Gt(e),this.str=Bt(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 Jt=crypto.getRandomValues.bind(crypto),Yt=Math.random,Xt=()=>Jt(new Uint32Array(1))[0],Zt=e=>e[b(Yt()*e.length)],Qt=`10000000-1000-4000-8000-100000000000`,$t=()=>Qt.replace(/[018]/g,e=>(e^Xt()&15>>e/4).toString(16)),en=Date.now,tn=e=>new Promise(e);Promise.all.bind(Promise);var nn=e=>e===void 0?null:e,rn=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&&(rn=localStorage)}catch{}var an=rn,on=Symbol(`Equality`),sn=(e,t)=>e===t||!!e?.[on]?.(t)||!1,cn=e=>typeof e==`object`,ln=Object.assign,un=Object.keys,dn=(e,t)=>{for(let n in e)t(e[n],n)},fn=e=>un(e).length,pn=e=>{for(let t in e)return!1;return!0},mn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},hn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),gn=(e,t)=>e===t||fn(e)===fn(t)&&mn(e,(e,n)=>(e!==void 0||hn(t,n))&&sn(t[n],e)),_n=Object.freeze,vn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&vn(e[t])}return _n(e)},yn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&yn(e,t,n+1)}},bn=e=>e,xn=(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[on]!=null)return e[on](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)||!xn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(fn(e)!==fn(t))return!1;for(let n in e)if(!hn(e,n)||!xn(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(!xn(e[n],t[n]))return!1;break;default:return!1}return!0},Sn=(e,t)=>t.includes(e),Cn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,wn=typeof window<`u`&&typeof document<`u`&&!Cn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var A,Tn=[],En=()=>{if(A===void 0)if(Cn){A=h();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&A.set(t,``),t=r):t===null?Tn.push(r):(A.set(t,r),t=null)}t!==null&&A.set(t,``)}else typeof location==`object`?(A=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);A.set(`--${nt(t,`-`)}`,n),A.set(`-${nt(t,`-`)}`,n)}})):A=h();return A},Dn=e=>En().has(e),On=e=>nn(Cn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:an.getItem(e)),kn=e=>Dn(`--`+e)||On(e)!==null,An=kn(`production`),jn=Cn&&Sn({}.FORCE_COLOR,[`true`,`1`,`2`])||!Dn(`--no-colors`)&&!kn(`no-color`)&&(!Cn||process.stdout.isTTY)&&(!Cn||Dn(`--color`)||On(`COLORTERM`)!==null||(On(`TERM`)||``).includes(`color`)),Mn=e=>new Uint8Array(e),Nn=wn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ze(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Pn=e=>{let t=Mn(e.byteLength);return t.set(e),t},Fn=e=>ut(t=>Tt(t,e)),In=class{constructor(e,t){this.left=e,this.right=t}},j=(e,t)=>new In(e,t),Ln=(e,t)=>e.forEach(e=>t(e.left,e.right)),Rn=e=>e.next()>=.5,zn=(e,t,n)=>b(e.next()*(n+1-t)+t),Bn=(e,t,n)=>b(e.next()*(n+1-t)+t),Vn=(e,t,n)=>Bn(e,t,n),Hn=e=>Ze(Vn(e,97,122)),Un=(e,t=0,n=20)=>{let r=Vn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Hn(e);return i},Wn=(e,t)=>t[Vn(e,0,t.length-1)],Gn=Symbol(`0schema`),Kn=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(st(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
|
-
`)}},qn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[on]?sn(e,t):y(e)?Ee(e,e=>De(t,t=>qn(e,t))):cn(e)?mn(e,(e,n)=>qn(e,t[n])):!1,M=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),qn(t,n)}equals(e){return this.constructor===e.constructor&&xn(this.shape,e.shape)}[Gn](){return!0}[on](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){E()}get nullable(){return wr(this,zr)}get optional(){return new nr(this)}cast(e){return Ur(e,this),e}expect(e){return Ur(e,this),e}},Jn=class extends M{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}},N=(e,t=null)=>new Jn(e,t);N(Jn);var Yn=class extends M{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}},P=e=>new Yn(e);N(Yn);var Xn=class extends M{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}},Zn=(...e)=>new Xn(e),Qn=N(Xn),$n=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),er=e=>{if(Pr.check(e))return[$n(e)];if(Qn.check(e))return e.shape.map(e=>e+``);if(Nr.check(e))return[`[+-]?\\d+.?\\d*`];if(Fr.check(e))return[`.*`];if(Tr.check(e))return e.shape.map(er).flat(1);D()};N(class extends M{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(er).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 tr=Symbol(`optional`),nr=class extends M{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[tr](){return!0}},rr=N(nr),ir=class extends M{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new ir,N(ir);var ar=class e extends M{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):mn(this.shape,(n,r)=>{let i=this._isPartial&&!hn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},or=e=>new ar(e),sr=N(ar),cr=P(e=>e!=null&&(e.constructor===Object||e.constructor==null)),lr=class extends M{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&mn(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)})}},ur=(e,t)=>new lr(e,t),dr=N(lr),fr=class extends M{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&mn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},pr=(...e)=>new fr(e);N(fr);var mr=class extends M{constructor(e){super(),this.shape=e.length===1?e[0]:new Cr(e)}check(e,t){let n=y(e)&&Ee(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},hr=(...e)=>new mr(e),gr=N(mr),_r=P(e=>y(e)),vr=class extends M{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}},yr=(e,t=null)=>new vr(e,t);N(vr);var br=yr(M),xr=N(class extends M{constructor(e){super(),this.len=e.length-1,this.args=pr(...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}}),Sr=P(e=>typeof e==`function`);N(class extends M{constructor(e){super(),this.shape=e}check(e,t){let n=Ee(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Cr=class extends M{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=De(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},wr=(...e)=>e.findIndex(e=>Tr.check(e))>=0?wr(...e.map(e=>Hr(e)).map(e=>Tr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Cr(e),Tr=N(Cr),Er=()=>!0,Dr=P(Er),Or=N(Yn,e=>e.shape===Er),kr=P(e=>typeof e==`bigint`),Ar=P(e=>e===kr),jr=P(e=>typeof e==`symbol`);P(e=>e===jr);var Mr=P(e=>typeof e==`number`),Nr=P(e=>e===Mr),Pr=P(e=>typeof e==`string`),Fr=P(e=>e===Pr),Ir=P(e=>typeof e==`boolean`),Lr=P(e=>e===Ir),Rr=Zn(void 0);N(Xn,e=>e.shape.length===1&&e.shape[0]===void 0),Zn(void 0);var zr=Zn(null),Br=N(Xn,e=>e.shape.length===1&&e.shape[0]===null);N(Uint8Array),N(Jn,e=>e.shape===Uint8Array);var Vr=wr(Mr,Pr,zr,Rr,kr,Ir,jr);(()=>{let e=hr(Dr),t=ur(Pr,Dr),n=wr(Mr,Pr,zr,Ir,e,t);return e.shape=n,t.shape.values=n,n})();var Hr=e=>{if(br.check(e))return e;if(cr.check(e)){let t={};for(let n in e)t[n]=Hr(e[n]);return or(t)}else if(_r.check(e))return wr(...e.map(Hr));else if(Vr.check(e))return Zn(e);else if(Sr.check(e))return N(e);D()},Ur=An?()=>{}:(e,t)=>{let n=new Kn;if(!t.check(e,n))throw T(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Wr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Hr(e),h:t}),this}else(e){return this.if(Dr,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 T(`Unhandled pattern`)}}},Gr=(e=>new Wr(e))(Dr).if(Nr,(e,t)=>zn(t,Ye,Je)).if(Fr,(e,t)=>Un(t)).if(Lr,(e,t)=>Rn(t)).if(Ar,(e,t)=>BigInt(zn(t,Ye,Je))).if(Tr,(e,t)=>Kr(t,Wn(t,e.shape))).if(sr,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(rr.check(i)){if(Rn(t))continue;i=i.shape}n[r]=Gr(i,t)}return n}).if(gr,(e,t)=>{let n=[],r=Bn(t,0,42);for(let i=0;i<r;i++)n.push(Kr(t,e.shape));return n}).if(Qn,(e,t)=>Wn(t,e.shape)).if(Br,(e,t)=>null).if(xr,(e,t)=>{let n=Kr(t,e.res);return()=>n}).if(Or,(e,t)=>Kr(t,Wn(t,[Mr,Pr,zr,Rr,kr,Ir,hr(Mr),ur(wr(`a`,`b`,`c`),Mr)]))).if(dr,(e,t)=>{let n={},r=zn(t,0,3);for(let i=0;i<r;i++){let r=Kr(t,e.shape.keys);n[r]=Kr(t,e.shape.values)}return n}).done(),Kr=(e,t)=>Gr(Hr(t),e),F=typeof document<`u`?document:{},qr=e=>F.createElement(e),Jr=()=>F.createDocumentFragment();P(e=>e.nodeType===oi);var Yr=e=>F.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Xr=(e,t)=>(Ln(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Zr=e=>{let t=Jr();for(let n=0;n<e.length;n++)ni(t,e[n]);return t},Qr=(e,t)=>(ni(e,Zr(t)),e),$r=(e,t=[],n=[])=>Qr(Xr(qr(e),t),n);P(e=>e.nodeType===ri);var ei=Yr;P(e=>e.nodeType===ii);var ti=e=>Se(e,(e,t)=>`${t}:${e};`).join(``),ni=(e,t)=>e.appendChild(t),ri=F.ELEMENT_NODE,ii=F.TEXT_NODE;F.CDATA_SECTION_NODE,F.COMMENT_NODE;var ai=F.DOCUMENT_NODE;F.DOCUMENT_TYPE_NODE;var oi=F.DOCUMENT_FRAGMENT_NODE;P(e=>e.nodeType===ai);var si=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),ci=(e,t)=>new si(setTimeout(t,e)),I=Symbol,li=I(),ui=I(),di=I(),fi=I(),pi=I(),mi=I(),hi=I(),gi=I(),_i=I(),vi=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};en();var yi={[li]:j(`font-weight`,`bold`),[ui]:j(`font-weight`,`normal`),[di]:j(`color`,`blue`),[pi]:j(`color`,`green`),[fi]:j(`color`,`grey`),[mi]:j(`color`,`red`),[hi]:j(`color`,`purple`),[gi]:j(`color`,`orange`),[_i]:j(`color`,`black`)},bi=jn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=h(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=yi[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=ti(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}:vi,xi=(...e)=>{console.log(...bi(e)),Ci.forEach(t=>t.print(e))},Si=(...e)=>{console.warn(...bi(e)),e.unshift(gi),Ci.forEach(t=>t.print(e))},Ci=_(),wi=e=>({[Symbol.iterator](){return this},next:e}),Ti=(e,t)=>wi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Ei=(e,t)=>wi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Di=class{constructor(e,t){this.clock=e,this.len=t}},Oi=class{constructor(){this.clients=new Map}},ki=(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])Wa(e,i,o.clock,o.len,n)}}),Ai=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=b((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},ji=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ai(n,t.clock)!==null},Mi=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 Di(r.clock,Ne(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Ni=e=>{let t=new Oi;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++)Te(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Mi(t),t},Pi=(e,t,n,r)=>{g(e.clients,t,()=>[]).push(new Di(n,r))},Fi=()=>new Oi,Ii=e=>{let t=Fi();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 Di(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Li=(e,t)=>{C(e.restEncoder,t.clients.size),v(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),C(e.restEncoder,t);let r=n.length;C(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ri=e=>{let t=new Oi,n=k(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=k(e.restDecoder),r=k(e.restDecoder);if(r>0){let i=g(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Di(e.readDsClock(),e.readDsLen()))}}return t},zi=(e,t,n)=>{let r=new Oi,i=k(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=k(e.restDecoder),a=k(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&&Pi(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,nc(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,nc(t,c,a-c.id.clock)),c.delete(t))}else Pi(r,i,n,a-n)}}if(r.clients.size>0){let e=new Yi;return C(e.restEncoder,0),Li(e,r),e.toUint8Array()}return null},Bi=Xt,Vi=class e extends ke{constructor({guid:e=$t(),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=Bi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new La,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=tn(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>tn(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(v(this.subdocs).map(e=>e.guid))}transact(e,t=null){return V(this,e,t)}get(e,t=U){let n=g(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,qo)}getText(e=``){return this.get(e,ms)}getMap(e=``){return this.get(e,Xo)}getXmlElement(e=``){return this.get(e,ys)}getXmlFragment(e=``){return this.get(e,_s)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,v(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()}},Hi=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}},Ui=class extends Hi{readLeftID(){return L(k(this.restDecoder),k(this.restDecoder))}readRightID(){return L(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Rt(this.restDecoder)}readString(){return Bt(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Ut(this.restDecoder)}readBuf(){return Pn(O(this.restDecoder))}readJSON(){return JSON.parse(Bt(this.restDecoder))}readKey(){return Bt(this.restDecoder)}},Wi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){let e=k(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Gi=class extends Wi{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Kt(O(e)),this.clientDecoder=new Gt(O(e)),this.leftClockDecoder=new Kt(O(e)),this.rightClockDecoder=new Kt(O(e)),this.infoDecoder=new Wt(O(e),Rt),this.stringDecoder=new qt(O(e)),this.parentInfoDecoder=new Wt(O(e),Rt),this.typeRefDecoder=new Gt(O(e)),this.lenDecoder=new Gt(O(e))}readLeftID(){return new va(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new va(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 Ut(this.restDecoder)}readBuf(){return O(this.restDecoder)}readJSON(){return Ut(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}}},Ki=class{constructor(){this.restEncoder=lt()}toUint8Array(){return x(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){C(this.restEncoder,e)}writeDsLen(e){C(this.restEncoder,e)}},qi=class extends Ki{writeLeftID(e){C(this.restEncoder,e.client),C(this.restEncoder,e.clock)}writeRightID(e){C(this.restEncoder,e.client),C(this.restEncoder,e.clock)}writeClient(e){C(this.restEncoder,e)}writeInfo(e){pt(this.restEncoder,e)}writeString(e){_t(this.restEncoder,e)}writeParentInfo(e){C(this.restEncoder,+!!e)}writeTypeRef(e){C(this.restEncoder,e)}writeLen(e){C(this.restEncoder,e)}writeAny(e){Tt(this.restEncoder,e)}writeBuf(e){w(this.restEncoder,e)}writeJSON(e){_t(this.restEncoder,JSON.stringify(e))}writeKey(e){_t(this.restEncoder,e)}},Ji=class{constructor(){this.restEncoder=lt(),this.dsCurrVal=0}toUint8Array(){return x(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,C(this.restEncoder,t)}writeDsLen(e){e===0&&D(),C(this.restEncoder,e-1),this.dsCurrVal+=e}},Yi=class extends Ji{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new At,this.clientEncoder=new Ot,this.leftClockEncoder=new At,this.rightClockEncoder=new At,this.infoEncoder=new Et(pt),this.stringEncoder=new jt,this.parentInfoEncoder=new Et(pt),this.typeRefEncoder=new Ot,this.lenEncoder=new Ot}toUint8Array(){let e=lt();return C(e,0),w(e,this.keyClockEncoder.toUint8Array()),w(e,this.clientEncoder.toUint8Array()),w(e,this.leftClockEncoder.toUint8Array()),w(e,this.rightClockEncoder.toUint8Array()),w(e,x(this.infoEncoder)),w(e,this.stringEncoder.toUint8Array()),w(e,x(this.parentInfoEncoder)),w(e,this.typeRefEncoder.toUint8Array()),w(e,this.lenEncoder.toUint8Array()),vt(e,x(this.restEncoder)),x(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){Tt(this.restEncoder,e)}writeBuf(e){w(this.restEncoder,e)}writeJSON(e){Tt(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)}},Xi=(e,t,n,r)=>{r=Ne(r,t[0].id.clock);let i=z(t,r);C(e.restEncoder,t.length-i),e.writeClient(n),C(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)},Zi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{R(t,n)>e&&r.set(n,e)}),Ra(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),C(e.restEncoder,r.size),v(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Xi(e,t.clients.get(n),n,r)})},Qi=(e,t)=>{let n=h(),r=k(e.restDecoder);for(let i=0;i<r;i++){let r=k(e.restDecoder),i=Array(r),a=e.readClient(),o=k(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=k(e.restDecoder);i[n]=new J(L(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new q(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,ac(e,r));i[n]=c,o+=c.length}}}}return n},$i=(e,t,n)=>{let r=[],i=v(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 La,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!==J){let i=g(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 Yi;return Zi(e,s,new Map),C(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},ea=(e,t)=>Zi(e,t.doc.store,t.beforeState),ta=(e,t,n,r=new Gi(e))=>V(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=$i(e,i,Qi(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=so([o.update,a.update])}}else i.pendingStructs=a;let s=zi(r,e,i);if(i.pendingDs){let t=new Gi(Ft(i.pendingDs));k(t.restDecoder);let n=zi(t,e,i);s&&n?i.pendingDs=so([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,na(e.doc,t)}},n,!1),na=(e,t,n,r=Gi)=>{let i=Ft(t);ta(i,e,n,new r(i))},ra=(e,t,n)=>na(e,t,n,Ui),ia=(e,t,n=new Map)=>{Zi(e,t.store,n),Li(e,Ii(t.store))},aa=(e,t=new Uint8Array([0]),n=new Yi)=>{ia(n,e,ca(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(co(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===qi)return ao(r.map((e,t)=>t===0?e:mo(e)));if(n.constructor===Yi)return so(r)}return r[0]},oa=(e,t)=>aa(e,t,new qi),sa=e=>{let t=new Map,n=k(e.restDecoder);for(let r=0;r<n;r++){let n=k(e.restDecoder),r=k(e.restDecoder);t.set(n,r)}return t},ca=e=>sa(new Hi(Ft(e))),la=(e,t)=>(C(e.restEncoder,t.size),v(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{C(e.restEncoder,t),C(e.restEncoder,n)}),e),ua=(e,t)=>la(e,Ra(t.store)),da=(e,t=new Ji)=>(e instanceof Map?la(t,e):ua(t,e),t.toUint8Array()),fa=e=>da(e,new Ki),pa=class{constructor(){this.l=[]}},ma=()=>new pa,ha=(e,t)=>e.l.push(t),ga=(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.`)},_a=(e,t,n)=>yn(e.l,[t,n]),va=class{constructor(e,t){this.client=e,this.clock=t}},ya=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,L=(e,t)=>new va(e,t),ba=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw D()},xa=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Sa=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Ca=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},wa=e=>new Sa(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),Ta=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Ea=(e,t,n=0)=>new Ta(e,t,n),Da=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ba(e):r=L(e._item.id.client,e._item.id.clock),new Sa(r,i,t,n)},Oa=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Da(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Da(e,L(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Da(e,r.lastId,n);r=r.right}return Da(e,null,n)},ka=(e,t)=>{let n=Ba(e,t);return{item:n,diff:t.clock-n.id.clock}},Aa=(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?ec(r,i):ka(r,i),t=e.item;if(!(t instanceof q))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?ec(r,a):{item:Ba(r,a)};if(e instanceof q&&e.content instanceof K)c=e.content.type;else return null}else throw D();l=s>=0?c._length:0}return Ea(c,l,e.assoc)},ja=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&ya(e.item,t.item)&&ya(e.type,t.type)&&e.assoc===t.assoc,Ma=class{constructor(e,t){this.ds=e,this.sv=t}},Na=(e,t)=>new Ma(e,t);Na(Fi(),new Map);var Pa=e=>Na(Ii(e.store),Ra(e.store)),Fa=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!ji(t.ds,e.id),Ia=(e,t)=>{let n=g(e.meta,Ia,_),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<R(r,n)&&B(e,L(n,t))}),ki(e,t.ds,e=>{}),n.add(t))},La=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ra=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},za=(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 D()}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=b(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=b((n+r)/2)}throw D()},Ba=(e,t)=>{let n=e.clients.get(t.client);return n[z(n,t.clock)]},Va=(e,t,n)=>{let r=z(t,n),i=t[r];return i.id.clock<n&&i instanceof q?(t.splice(r+1,0,nc(e,i,n-i.id.clock)),r+1):r},B=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Va(e,n,t.clock)]},Ha=(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,nc(e,a,n.clock-a.id.clock+1)),a},Ua=(e,t,n)=>{let r=e.clients.get(t.id.client);r[z(r,t.id.clock)]=n},Wa=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Va(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Va(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ga=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Oi,this.beforeState=Ra(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}},Ka=(e,t)=>t.deleteSet.clients.size===0&&!Ce(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Mi(t.deleteSet),ea(e,t),Li(e,t.deleteSet),!0),qa=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&g(e.changed,t,_).add(n)},Ja=(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 q&&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},Ya=(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 q&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Xa=(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=Me(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+Ja(r,e)}})},Za=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Mi(a),n.afterState=Ra(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(()=>{_a(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&ds(n)})}),yn(e,[])}finally{r.gc&&Ya(a,i,r.gcFilter),Xa(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Ne(z(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ja(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&&Ja(r,a+1)>1||a>0&&Ja(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(xi(gi,li,`[yjs] `,ui,mi,`Changed the client-id because another client seems to be using it.`),r.clientID=Bi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new qi;Ka(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Yi;Ka(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])):Za(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 Ga(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&&Za(i,0)}}return o},Qa=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},$a=(e,t,n)=>{ki(e,n.deletions,n=>{n instanceof q&&t.scope.some(t=>t===e.doc||xa(t,n))&&tc(n,!1)})},eo=(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;ki(n,o.insertions,e=>{if(e instanceof q){if(e.redone!==null){let{item:t,diff:i}=ec(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||xa(t,e))&&c.push(e)}}),ki(n,o.deletions,e=>{e instanceof q&&a.some(t=>t===n.doc||xa(t,e))&&!ji(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=ic(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},to=class extends ke{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=y(e)?e[0].doc:e instanceof Vi?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 Oi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Pi(i,n,r,a)});let a=en(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Ni([t.deletions,e.deleteSet]),t.insertions=Ni([t.insertions,i])}else r.push(new Qa(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),ki(e,e.deleteSet,t=>{t instanceof q&&this.scope.some(n=>n===e.doc||xa(n,t))&&tc(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=y(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof U?e.doc!==this.doc:e!==this.doc)&&Si(`[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=>$a(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>$a(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=eo(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=eo(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*no(e){let t=k(e.restDecoder);for(let n=0;n<t;n++){let t=k(e.restDecoder),n=e.readClient(),r=k(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=k(e.restDecoder);yield new J(L(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new q(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,ac(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new W(L(n,r),t),r+=t}}}}var ro=class{constructor(e,t){this.gen=no(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===J);return this.curr}},io=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},ao=e=>so(e,Ui,qi),oo=(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===J){let{client:n,clock:r}=e.id;return new J(L(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new q(L(r,i+t),null,L(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},so=(e,t=Gi,n=Yi)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ft(e))),i=r.map(e=>new ro(e,!0)),a=null,o=new n,s=new io(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===J?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)uo(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===J)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{uo(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new J(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===J?a.struct.length-=t:n=oo(n,t)),a.struct.mergeWith(n)||(uo(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!==J;n=e.next())uo(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(uo(s,a.struct,a.offset),a=null),fo(s),Li(o,Ni(r.map(e=>Ri(e)))),o.toUint8Array()},co=(e,t,n=Gi,r=Yi)=>{let i=ca(t),a=new r,o=new io(a),s=new n(Ft(e)),c=new ro(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===J){c.next();continue}if(e.id.clock+e.length>n)for(uo(o,e,Ne(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)uo(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 fo(o),Li(a,Ri(s)),a.toUint8Array()},lo=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:x(e.encoder.restEncoder)}),e.encoder.restEncoder=lt(),e.written=0)},uo=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&lo(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),C(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},fo=e=>{lo(e);let t=e.encoder.restEncoder;C(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];C(t,r.written),vt(t,r.restEncoder)}},po=(e,t,n,r)=>{let i=new n(Ft(e)),a=new ro(i,!1),o=new r,s=new io(o);for(let e=a.curr;e!==null;e=a.next())uo(s,t(e),0);return fo(s),Li(o,Ri(i)),o.toUint8Array()},mo=e=>po(e,bn,Gi,qi),ho=`You must not compute changes after the event-handler fired.`,go=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||=_o(this.currentTarget,this.target)}deletes(e){return ji(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw T(ho);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=we(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=we(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=we(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 T(ho);let t=this.target,n=_(),r=_(),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}},_o=(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=()=>{Si(`Invalid access: Add Yjs type to a document before reading data.`)},vo=80,yo=0,bo=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=yo++}},xo=e=>{e.timestamp=yo++},So=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=yo++},Co=(e,t,n)=>{if(e.length>=vo){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return So(r,t,n),r}else{let r=new bo(t,n);return e.push(r),r}},wo=(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)=>je(t-e.index)<je(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,xo(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&&je(n.index-i)<r.parent.length/vo?(So(n,r,i),n):Co(e._searchMarker,r,i)},To=(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=Ne(t,i.index+n))}},Eo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;g(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;_a(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=ma(),this._dEH=ma(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw E()}clone(){throw E()}_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){ha(this._eH,e)}observeDeep(e){ha(this._dEH,e)}unobserve(e){ga(this._eH,e)}unobserveDeep(e){ga(this._dEH,e)}toJSON(){}},Do=(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},Oo=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},ko=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Fa(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Ao=(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}},jo=(e,t)=>{let n=[];return Ao(e,(r,i)=>{n.push(t(r,i,e))}),n},Mo=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}}}},No=(e,t)=>{e.doc??H();let n=wo(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}},Po=(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 q(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Vs(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 q(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Os(new Uint8Array(n))),i.integrate(e,0);break;case Vi:i=new q(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ns(n)),i.integrate(e,0);break;default:if(n instanceof U)i=new q(L(o,R(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new K(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Fo=()=>T(`Length exceeded!`),Io=(e,t,n,r)=>{if(n>t._length)throw Fo();if(n===0)return t._searchMarker&&To(t._searchMarker,n,r.length),Po(e,t,null,r);let i=n,a=wo(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&&To(t._searchMarker,i,r.length),Po(e,t,o,r)},Lo=(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 Po(e,t,r,n)},Ro=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=wo(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 Fo();t._searchMarker&&To(t._searchMarker,i,-a+r)},zo=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Bo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Vs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Vs([r]);break;case Uint8Array:s=new Os(r);break;case Vi:s=new Ns(r);break;default:if(r instanceof U)s=new K(r);else throw Error(`Unexpected content type`)}new q(L(o,R(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Vo=(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},Ho=e=>{let t={};return e.doc??H(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Uo=(e,t)=>{e.doc??H();let n=e._map.get(t);return n!==void 0&&!n.deleted},Wo=(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&&Fa(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Go=e=>(e.doc??H(),Ti(e._map.entries(),e=>!e[1].deleted)),Ko=class extends go{},qo=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),Eo(this,e,new Ko(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):V(this.doc,n=>{Io(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):V(this.doc,t=>{Lo(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=>{Ro(n,this,e,t)})}get(e){return No(this,e)}toArray(){return Oo(this)}slice(e=0,t=this.length){return Do(this,e,t)}toJSON(){return this.map(e=>e instanceof U?e.toJSON():e)}map(e){return jo(this,e)}forEach(e){Ao(this,e)}[Symbol.iterator](){return Mo(this)}_write(e){e.writeTypeRef(Ks)}},Jo=e=>new qo,Yo=class extends go{constructor(e,t,n){super(e,t),this.keysChanged=n}},Xo=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){Eo(this,e,new Yo(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[...Go(this)].length}keys(){return Ei(Go(this),e=>e[0])}values(){return Ei(Go(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ei(Go(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=>{zo(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):V(this.doc,n=>{Bo(n,this,e,t)}),t}get(e){return Vo(this,e)}has(e){return Uo(this,e)}clear(){this.doc===null?this._prelimContent.clear():V(this.doc,e=>{this.forEach(function(t,n,r){zo(e,r,n)})})}_write(e){e.writeTypeRef(qs)}},Zo=e=>new Xo,Qo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&gn(e,t),$o=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&D(),this.right.content.constructor){case G:this.right.deleted||rs(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}},es=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case G:t.right.deleted||rs(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},ts=(e,t,n,r)=>{let i=new Map,a=r?wo(t,n):null;return a?es(e,new $o(a.p.left,a.p,a.index,i),n-a.index):es(e,new $o(null,t._start,0,i),n)},ns=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===G&&Qo(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 q(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()})},rs=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},is=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===G&&Qo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},as=(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(!Qo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new q(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},os=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;is(n,i);let s=as(e,t,n,i),c=r.constructor===String?new Us(r):r instanceof U?new K(r):new Fs(r),{left:l,right:u,index:d}=n;t._searchMarker&&To(t._searchMarker,n.index,c.getLength()),u=new q(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(),ns(e,t,n,s)},ss=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;is(n,i);let s=as(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(Qo(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+=`
|
|
4
|
-
`;n.right=new q(L(o,R(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Us(i)),n.right.integrate(e,0),n.forward()}ns(e,t,n,s)},cs=(e,t,n,r,i)=>{let a=t,o=h();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&&rs(i,n);break}}}t=t.right}return s},ls=(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}},us=e=>{let t=0;return V(e.doc,n=>{let r=e._start,i=e._start,a=h(),o=xe(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case G:rs(o,i.content);break;default:t+=cs(n,r,i,a,o),a=xe(o),r=i;break}i=i.right}}),t},ds=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&&Wa(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=>{ki(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):ls(n,e)});for(let e of t)us(e)})},fs=(e,t,n)=>{let r=n,i=xe(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case K:case Fs:case Us: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&&cs(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&To(o._searchMarker,t.index,-r+n),t},ps=class extends go{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},pn(o)||(e.attributes=ln({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case K:case Fs: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 Us: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)||(Qo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Qo(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;Qo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Qo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),rs(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}},ms=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 ps(this,e,t);Eo(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===Us&&(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 $o(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)===`
|
|
5
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&os(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&fs(n,r,a.delete):ss(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(Fa(s,e)||t!==void 0&&Fa(s,t))switch(s.content.constructor){case Us:{let r=i.get(`ychange`);e!==void 0&&!Fa(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&&!Fa(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 K:case Fs:{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:Fa(s,e)&&(c(),rs(i,s.content));break}s=s.right}c()};return e||t?V(a,n=>{e&&Ia(n,e),t&&Ia(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=ts(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),os(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=ts(r,this,e,!n);os(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=>{fs(n,ts(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=ts(r,this,e,!1);i.right!==null&&ss(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):V(this.doc,t=>{zo(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):V(this.doc,n=>{Bo(n,this,e,t)})}getAttribute(e){return Vo(this,e)}getAttributes(){return Ho(this)}_write(e){e.writeTypeRef(Js)}},hs=e=>new ms,gs=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===ys||t.constructor===_s)&&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})}},_s=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 gs(this,e)}querySelector(e){e=e.toUpperCase();let t=new gs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),v(new gs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Eo(this,e,new xs(this,t,e))}toString(){return jo(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),Ao(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=>{Io(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)V(this.doc,n=>{let r=e&&e instanceof U?e._item:e;Po(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 T(`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=>{Ro(n,this,e,t)})}toArray(){return Oo(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return No(this,e)}slice(e=0,t=this.length){return Do(this,e,t)}forEach(e){Ao(this,e)}_write(e){e.writeTypeRef(Xs)}},vs=e=>new _s,ys=class e extends _s{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 dn(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=>{zo(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):V(this.doc,n=>{Bo(n,this,e,t)})}getAttribute(e){return Vo(this,e)}hasAttribute(e){return Uo(this,e)}getAttributes(e){return e?Wo(this,e):Ho(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 Ao(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ys),e.writeKey(this.nodeName)}},bs=e=>new ys(e.readKey()),xs=class extends go{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)})}},Ss=class e extends Xo{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)}},Cs=e=>new Ss(e.readKey()),ws=class e extends ms{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(Qs)}},Ts=e=>new ws,Es=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw E()}mergeWith(e){return!1}write(e,t,n){throw E()}integrate(e,t){throw E()}},Ds=0,W=class extends Es{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),za(e.doc.store,this)}write(e,t){e.writeInfo(Ds),e.writeLen(this.length-t)}getMissing(e,t){return null}},Os=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 E()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},ks=e=>new Os(e.readBuf()),As=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){Pi(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}},js=e=>new As(e.readLen()),Ms=(e,t)=>new Vi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Ns=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(Ms(this.doc.guid,this.opts))}splice(e){throw E()}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}},Ps=e=>new Ns(Ms(e.readString(),e.readAny())),Fs=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 E()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Is=e=>new Fs(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 E()}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}},Ls=e=>new G(e.readKey(),e.readJSON()),Rs=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}},zs=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 Rs(n)},Bs=On(`node_env`)===`development`,Vs=class e{constructor(e){this.arr=e,Bs&&vn(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}},Hs=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Vs(n)},Us=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}},Ws=e=>new Us(e.readString()),Gs=[Jo,Zo,hs,bs,vs,Cs,Ts],Ks=0,qs=1,Js=2,Ys=3,Xs=4,Zs=5,Qs=6,K=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 E()}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}},$s=e=>new K(Gs[e.readTypeRef()](e)),ec=(e,t)=>{let n=t,r=0,i;do r>0&&(n=L(n.client,n.clock+r)),i=Ba(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof q);return{item:i,diff:r}},tc=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},nc=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new q(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},rc=(e,t)=>De(e,e=>ji(e.deletions,t)),ic=(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)||ic(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||ji(r,d.right.id)||rc(a.undoStack,d.right.id)||rc(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;d!==null&&d.parent._item!==u&&(d=ee._map.get(t.parentSub)||null)}let te=L(c,R(s,c)),ne=new q(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,tc(ne,!0),ne.integrate(e,0),ne},q=class e extends Es{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===va&&this.id.client!==this.parent.client&&this.parent.clock>=R(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Ha(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===va){let e=Ba(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=Ha(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),ya(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ya(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ba(e.doc.store,n.origin)))r.has(Ba(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),za(e.doc.store,this),this.content.integrate(e,this),qa(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&&ya(e.origin,this.lastId)&&this.right===e&&ya(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(),Pi(e.deleteSet,this.id.client,this.id.clock,this.length),qa(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw D();this.content.gc(e),t?Ua(e,this,new W(this.id,this.length)):this.content=new As(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=ba(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===va?(e.writeParentInfo(!1),e.writeLeftID(t)):D();i!==null&&e.writeString(i)}this.content.write(e,t)}},ac=(e,t)=>oc[t&31](e),oc=[()=>{D()},js,zs,ks,Ws,Is,Ls,$s,Hs,Ps,()=>{D()}],sc=10,J=class extends Es{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){D()}write(e,t){e.writeInfo(sc),C(e.restEncoder,this.length-t)}getMissing(e,t){return null}},cc=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},lc=`__ $YJS$ __`;cc[lc]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),cc[lc]=!0;var uc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),dc=(e,t)=>{C(e,uc.Token),_t(e,t)},fc=(e,t,n,r)=>{switch(k(e)){case uc.Token:t();break;case uc.PermissionDenied:n(Bt(e));break;case uc.Authenticated:r(Bt(e));break;default:}},pc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),mc=`\0`;function hc(e,t){return e+mc+t}function gc(e){let t=e.indexOf(mc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var _c=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 vc(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 yc(e){return new Promise(t=>setTimeout(t,e))}function bc(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 xc(e,t){let n=vc(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||bc;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 yc(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 yc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await yc(e)}return a()}var Sc=Math.floor,Cc=(e,t)=>e<t?e:t,wc=(e,t)=>e>t?e:t;Number.isNaN;var Tc=64,Ec=128,Dc=1<<17,Oc=1<<18,kc=1<<19,Ac=1<<20,jc=1<<21,Mc=1<<22,Nc=1<<23,Pc=1<<24,Fc=1<<25,Ic=1<<26,Lc=1<<27,Rc=1<<28,zc=1<<29,Bc=1<<30,Vc=63,Hc=127;Dc-1,Oc-1,kc-1,Ac-1,jc-1,Mc-1,Nc-1,Pc-1,Fc-1,Ic-1,Lc-1,Rc-1,zc-1,Bc-1;var Uc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Wc=()=>new Set,Gc=Array.from;Array.isArray;var Kc=String.fromCharCode;String.fromCodePoint,Kc(65535);var qc=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},Jc=typeof TextEncoder<`u`?new TextEncoder:null,Yc=Jc?e=>Jc.encode(e):qc,Xc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Xc&&Xc.decode(new Uint8Array).length===1&&(Xc=null);var Zc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Qc=()=>new Zc,$c=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},el=e=>{let t=new Uint8Array($c(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},tl=(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},Y=(e,t)=>{for(;t>Hc;)tl(e,Ec|Hc&t),t=Sc(t/128);tl(e,Hc&t)},nl=new Uint8Array(3e4),rl=nl.length/3,X=Jc&&Jc.encodeInto?(e,t)=>{if(t.length<rl){let n=Jc.encodeInto(t,nl).written||0;Y(e,n);for(let t=0;t<n;t++)tl(e,nl[t])}else al(e,Yc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Y(e,r);for(let t=0;t<r;t++)tl(e,n.codePointAt(t))},il=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Cc(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(wc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},al=(e,t)=>{Y(e,t.byteLength),il(e,t)},ol=e=>Error(e),sl=ol(`Unexpected end of array`),cl=ol(`Integer out of Range`),ll=class{constructor(e){this.arr=e,this.pos=0}},ul=e=>new ll(e),dl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},fl=e=>dl(e,Z(e)),pl=e=>e.arr[e.pos++],Z=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Hc)*n,n*=128,r<Ec)return t;if(t>Uc)throw cl}throw sl},ml=e=>{let t=e.arr[e.pos++],n=t&Vc,r=64,i=(t&Tc)>0?-1:1;if((t&Ec)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Hc)*r,r*=128,t<Ec)return i*n;if(n>Uc)throw cl}throw sl},hl=Xc?e=>Xc.decode(fl(e)):e=>{let t=Z(e);if(t===0)return``;{let n=String.fromCodePoint(pl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(pl(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=hl(e);return e.pos=t,n},_l=Date.now,vl=()=>new Map,yl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},bl=class{constructor(){this._observers=vl()}on(e,t){yl(this._observers,e,Wc).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 Gc((this._observers.get(e)||vl()).values()).forEach(e=>e(...t))}destroy(){this._observers=vl()}},xl=Symbol(`Equality`),Sl=Object.keys,Cl=e=>Sl(e).length,wl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Tl=(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)||!Tl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Cl(e)!==Cl(t))return!1;for(let n in e)if(!wl(e,n)||!Tl(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(!Tl(e[n],t[n]))return!1;break;default:return!1}return!0},El=3e4,Dl=class extends bl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=_l();this.getLocalState()!==null&&El/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&El<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Ol(this,t,`timeout`)},Sc(El/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:_l()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Tl(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}},Ol=(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:_l()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},kl=(e,t,n=e.states)=>{let r=t.length,i=Qc();Y(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;Y(i,r),Y(i,s),X(i,JSON.stringify(o))}return el(i)},Al=(e,t,n)=>{let r=ul(t),i=_l(),a=[],o=[],s=[],c=[],l=Z(r);for(let t=0;t<l;t++){let t=Z(r),n=Z(r),l=JSON.parse(hl(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&&(Tl(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])},jl=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={}}},Ml=class{constructor(e){this.data=e,this.encoder=Qc(),this.decoder=ul(new Uint8Array(this.data))}peekVarString(){return gl(this.decoder)}readVarUint(){return Z(this.decoder)}readVarString(){return hl(this.decoder)}readVarUint8Array(){return fl(this.decoder)}writeVarUint(e){return Y(this.encoder,e)}writeVarString(e){return X(this.encoder,e)}writeVarUint8Array(e){return al(this.encoder,e)}length(){return $c(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}({}),Nl=class{constructor(){this.encoder=Qc()}get(e){return e.encoder}toUint8Array(){return el(this.encoder)}},Pl=class extends Nl{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return X(this.encoder,e.documentName),Y(this.encoder,this.type),this.encoder}},Fl=class e extends jl{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(Pl,{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:xc(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=_l();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new Ml(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=Qc();Y(e,Q.Pong),this.send(el(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>=_l()-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=ul(e);return{documentName:hl(t),messageType:Z(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===_c.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()}},Il=0,Ll=1,Rl=2,zl=(e,t)=>{Y(e,Il),al(e,fa(t))},Bl=(e,t,n)=>{Y(e,Ll),al(e,oa(t,n))},Vl=(e,t,n)=>Bl(t,n,fl(e)),Hl=(e,t,n,r)=>{try{ra(t,fl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Ul=(e,t)=>{Y(e,Rl),al(e,t)},Wl=Hl,Gl=(e,t,n,r,i)=>{let a=Z(e);switch(a){case Il:Vl(e,t,n);break;case Ll:Hl(e,n,r,i);break;case Rl:Wl(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Kl=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(hl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,ml(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:hl(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(Nl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=Gl(n.decoder,n.encoder,e.document,e);t&&r===Ll&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Al(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;fc(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(kl(e.awareness,Array.from(e.awareness.getStates().keys())))}},ql=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return el(this.encoder)}send(e){e?.send(this.create())}},Jl=`4.0.0-rc.1`,Yl=class extends Nl{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 X(this.encoder,e.documentName),Y(this.encoder,this.type),dc(this.encoder,e.token),X(this.encoder,Jl),this.encoder}},Xl=class extends Nl{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`);X(this.encoder,e.documentName),Y(this.encoder,this.type);let t;return t=e.states===void 0?kl(e.awareness,e.clients):kl(e.awareness,e.clients,e.states),al(this.encoder,t),this.encoder}},Zl=class extends Nl{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return X(this.encoder,e.documentName),Y(this.encoder,this.type),X(this.encoder,e.payload??``),this.encoder}},Ql=class extends Nl{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 X(this.encoder,e.documentName),Y(this.encoder,this.type),zl(this.encoder,e.document),this.encoder}},$l=class extends Nl{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return X(this.encoder,e.documentName),Y(this.encoder,this.type),Ul(this.encoder,e.update),this.encoder}},eu=class extends Error{constructor(...e){super(...e),this.code=1001}},tu=class extends jl{get effectiveName(){return this.configuration.sessionAwareness?hc(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 Vi,this.configuration.awareness=e.awareness===void 0?new Dl(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:pc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:pc(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 Fl(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(Ql,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Ol(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Zl,{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(Yl,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send($l,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Xl,{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(Ql,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Xl,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new ql(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Ml(e.data),{documentName:n}=gc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Ml(e.data)}),new Kl(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Ol(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&&(Ol(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 eu(`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)}};function nu(e,t,n=null,r=null){let i={...me()};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 ru(e,t,n){let r=(0,he.c)(5),i,a;r[0]!==e||r[1]!==t||r[2]!==n?(i=()=>{!e||!n||typeof e.setLanguagePreference==`function`&&e.setLanguagePreference(t??`system`).catch(e=>{console.warn(JSON.stringify({event:`language-preference-push-failed`,preference:t??`system`,error:e instanceof Error?e.message:String(e)}))})},a=[e,t,n],r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,p.useEffect)(i,a)}function iu(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e.trim())?.[1];if(t===void 0)return null;let n=t.split(/[\s,/]+/).filter(Boolean);if(n.length<3)return null;let r=`#`;for(let e=0;e<3;e++){let t=Math.round(Number(n[e]));if(!Number.isFinite(t)||t<0||t>255)return null;r+=t.toString(16).padStart(2,`0`)}return r}function au(e){if(typeof document>`u`)return null;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return null;t.fillStyle=`#000000`,t.fillStyle=e;let n=t.fillStyle;return t.fillStyle=`#ffffff`,t.fillStyle=e,t.fillStyle===n&&typeof n==`string`&&/^#[0-9a-f]{6}$/i.test(n)?n.toLowerCase():null}function ou(e){return au(e)??iu(e)}function su(e){let t=document.createElement(`span`);t.style.display=`none`,t.style.backgroundColor=`var(${e})`,document.body.appendChild(t);try{let e=getComputedStyle(t).backgroundColor;return!e||e===`rgba(0, 0, 0, 0)`||e.includes(`var(`)?null:ou(e)}finally{t.remove()}}function cu(){if(!(typeof document>`u`))try{let e=su(`--sidebar`),t=su(`--sidebar-foreground`);return!e||!t?void 0:{bg:e,symbol:t}}catch{return}}function lu(e,t,n){let r=(0,he.c)(10),i;r[0]!==e||r[1]!==t?(i=()=>{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,chrome:cu()})}),()=>{n=!0}},r[0]=e,r[1]=t,r[2]=i):i=r[2];let a;r[3]!==e||r[4]!==n||r[5]!==t?(a=[e,t,n],r[3]=e,r[4]=n,r[5]=t,r[6]=a):a=r[6],(0,p.useEffect)(i,a);let o,s;r[7]===e?(o=r[8],s=r[9]):(o=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches,chrome:cu()})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},s=[e],r[7]=e,r[8]=o,r[9]=s),(0,p.useEffect)(o,s)}var uu={en:()=>t(()=>import(`./messages-B-LUKCxb.js`).then(e=>e.n),__vite__mapDeps([0,1]),import.meta.url),"zh-Hans":()=>t(()=>import(`./messages-CkanzrCR.js`),[],import.meta.url),"zh-Hant":()=>t(()=>import(`./messages-52Q73NDn.js`),[],import.meta.url),hi:()=>t(()=>import(`./messages-CGjveR2E.js`),[],import.meta.url),es:()=>t(()=>import(`./messages-Cy75Ipbk.js`),[],import.meta.url),ar:()=>t(()=>import(`./messages-s-nrsPLp.js`),[],import.meta.url),fr:()=>t(()=>import(`./messages-BzwBNPDu.js`),[],import.meta.url),bn:()=>t(()=>import(`./messages-Bjt29O_q.js`),[],import.meta.url),"pt-BR":()=>t(()=>import(`./messages-D8H0FnV4.js`),[],import.meta.url),id:()=>t(()=>import(`./messages-Dl7JEKLk.js`),[],import.meta.url),ur:()=>t(()=>import(`./messages-D2UntltU.js`),[],import.meta.url)},du=new Set([`en`]),fu=`en`;async function pu(e){if(fu=e,!du.has(e)){let{default:t}=await uu[e]();ce.load(e,t.messages),du.add(e)}fu===e&&ce.activate(e)}function mu(){return!1}async function hu(){}var gu=`ok-locale-load-failed`;function _u(){window.location.reload()}function vu({locale:e,reload:t=_u}){let n=new Intl.DisplayNames([ce.locale],{type:`language`}).of(e)??e;le.error(ce._({id:`loE6tM`,values:{language:n}}),{id:gu,description:ce._({id:`GtPGNJ`}),duration:1/0,action:{label:ce._({id:`HpK_8d`}),onClick:t}})}function yu(){le.dismiss(gu)}var bu=`ok-language-v1`;function xu({preference:e,locale:t}){if(typeof document>`u`)return;let n=s(t),r=document.documentElement;r.lang=t,r.dir=n;try{localStorage.setItem(bu,JSON.stringify({pref:e,locale:t,dir:n}))}catch{}}function Su(e){return e===`system`?`system`:se.includes(e)?e:void 0}function Cu(){if(!(typeof localStorage>`u`))try{let e=localStorage.getItem(bu);return e===null?void 0:Su(JSON.parse(e).pref)}catch{return}}function wu(e){let t=(0,he.c)(4),{preference:n,userConfigSynced:r}=e,i,a;t[0]!==n||t[1]!==r?(i=()=>{if(mu()){hu().catch(Tu);return}if(!r)return;let{locale:e}=u({override:void 0,storedPreference:n,preferenceList:te(),supportedLocales:se,autoDetectableLocales:ae}),t=!1;return pu(e).then(()=>{t||(yu(),xu({preference:n??`system`,locale:e}))}).catch(n=>{console.warn(JSON.stringify({event:`ok-locale-activate-failed`,locale:e,error:String(n)})),!t&&vu({locale:e})}),()=>{t=!0}},a=[n,r],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,p.useEffect)(i,a)}function Tu(e){console.warn(JSON.stringify({event:`ok-pseudo-locale-activate-failed`,error:String(e)}))}function Eu(e){let t=(0,he.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 Du=n();function Ou(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function ku(e,t,n,r){let i=new Vi,a=new tu({url:e,name:t,document:i,token:nu(null,r,null),onDisconnect:({event:e})=>Ou(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Ou(`config-provider`,t,`close`,e)}),o=re(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function Au(e,t){let n=new Vi,r=new tu({url:e,name:ie,document:n,token:nu(null,t,null),onDisconnect:({event:e})=>Ou(`okignore-provider`,ie,`disconnect`,e),onClose:({event:e})=>Ou(`okignore-provider`,ie,`close`,e)}),i=o(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function ju(e){let t=(0,he.c)(20),{collabUrl:n,children:r}=e,a=be(),{systemTheme:o}=i(),s=o===`dark`,[u,te]=(0,p.useState)(null),[re,ie]=(0,p.useState)(null),[ae,se]=(0,p.useState)(null),[ce,le]=(0,p.useState)(null),me,ge;t[0]!==n||t[1]!==a?(me=()=>{if(n===null)return;let e=ku(n,c,`user`,a),t=ku(n,oe,`project`,a),r=ku(n,ee,`project-local`,a),i=Au(n,a);te({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),ie({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),se({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),le({binding:i.binding,synced:!1});let o=e.binding.subscribe(t=>{te(n=>n?.binding===e.binding?{...n,config:t}:n)}),s=e.binding.subscribeSynced(()=>{te(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),l=t.binding.subscribe(e=>{ie(n=>n?.binding===t.binding?{...n,config:e}:n)}),u=t.binding.subscribeSynced(()=>{ie(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),d=r.binding.subscribe(e=>{se(t=>t?.binding===r.binding?{...t,config:e}:t)}),f=r.binding.subscribeSynced(()=>{se(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),ne=()=>{le(e=>e?.binding===i.binding?{...e,synced:!0}:e)};return i.provider.on(`synced`,ne),()=>{o(),s(),l(),u(),d(),f(),i.provider.off(`synced`,ne);for(let n of[e,t,r,i])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}te(t=>t?.binding===e.binding?null:t),ie(e=>e?.binding===t.binding?null:e),se(e=>e?.binding===r.binding?null:e),le(e=>e?.binding===i.binding?null:e)}},ge=[n,a],t[0]=n,t[1]=a,t[2]=me,t[3]=ge):(me=t[2],ge=t[3]),(0,p.useEffect)(me,ge);let m=u&&re?f(u.config,re.config,ae?.config):null,_e=m?.appearance?.theme,ve=m?.appearance?.customTheme,ye=m?.appearance?.colorThemeEnabled!==!1,h=d(m?.appearance),xe=ne(_e,s),g=ye?h[xe]:`default`,Se=g===`custom`?pe(ue(ve)):l(g)??_e;Eu(Se),fe({selection:h,modePreference:_e,slotMode:xe,customSeed:ve,enabled:ye}),wu({preference:m?.appearance?.language,userConfigSynced:u?.synced??!1}),ru(typeof window<`u`?window.okDesktop:void 0,m?.appearance?.language,u?.synced??!1),lu(typeof window<`u`?window.okDesktop:void 0,Se??`system`,`${g}:${g===`custom`?JSON.stringify(ve??null):``}`);let Ce=u?.binding??null,_=u?.synced??!1,we=re?.binding??null,Te=ae?.binding??null,v=ce?.binding??null,Ee=ce?.synced??!1,De=u?.config??null,Oe=re?.config??null,y=re?.synced??!1,ke=ae?.config??null,Ae=ae?.synced??!1,b;t[4]!==m||t[5]!==Oe||t[6]!==y||t[7]!==ke||t[8]!==Ae||t[9]!==Ce||t[10]!==_||t[11]!==we||t[12]!==Te||t[13]!==v||t[14]!==Ee||t[15]!==De?(b={userBinding:Ce,userSynced:_,projectBinding:we,projectLocalBinding:Te,okignoreBinding:v,okignoreSynced:Ee,userConfig:De,projectConfig:Oe,projectSynced:y,projectLocalConfig:ke,projectLocalSynced:Ae,merged:m},t[4]=m,t[5]=Oe,t[6]=y,t[7]=ke,t[8]=Ae,t[9]=Ce,t[10]=_,t[11]=we,t[12]=Te,t[13]=v,t[14]=Ee,t[15]=De,t[16]=b):b=t[16];let je=b,Me;return t[17]!==r||t[18]!==je?(Me=(0,Du.jsx)(de,{value:je,children:r}),t[17]=r,t[18]=je,t[19]=Me):Me=t[19],Me}export{E as $,fa as A,ci as B,Fi as C,Na as D,Oa as E,ki as F,Fn as G,$r as H,Ca as I,mn as J,Nn as K,Pa as L,ba as M,ji as N,ca as O,xa as P,T as Q,V as R,Aa as S,wa as T,ei as U,F as V,j as W,tn as X,un as Y,Zt as Z,ys as _,lu as a,_ as at,na as b,G as c,ve as ct,Vi as d,D as et,q as f,ms as g,to as h,wu as i,Ae as it,z as j,oa as k,Us as l,Ma as m,Su as n,Ne as nt,nu as o,h as ot,Sa as p,wn as q,Cu as r,Me as rt,tu as s,g as st,ju as t,qe as tt,K as u,ws as v,L as w,ja as x,ra as y,ko as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-TVrIGknK2.js";import{t as e}from"./dist-DoS8xGN6.js";import{t}from"./messages-B-LUKCxb.js";e.load(`en`,t.messages),e.activate(`en`);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Aa as e,E as t,Fo as n,Ga as r,Ja as i,Ka as a,No as o,Qa as s,Ua as c,Xa as l,Ya as u,Za as d,hr as f,ka as p,to as m,ui as h,zo as g}from"./dist-TVrIGknK2.js";import{l as ee,o as te,r as ne}from"./doc-paths-BKAhPn1c.js";import{o as re,r as ie}from"./file-tree-utils-Cx1c51Ql.js";import{o as ae}from"./skill-scope-CwmLPgmT.js";var _=null,oe=new Set;function v(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function se(e,t){return e===null?!1:e===t?!0:v(e.pages,t.pages)&&v(e.folderPaths,t.folderPaths)&&v(e.assetPaths??new Set,t.assetPaths??new Set)&&v(e.filePaths??new Set,t.filePaths??new Set)&&ce(e.pageIcons,t.pageIcons)}function ce(e,t){if(e===t)return!0;let n=e?.size??0;if(n!==(t?.size??0))return!1;if(n===0)return!0;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0}function le(e,t){let n=new Map;for(let r of e){let e=t(r);e&&!n.has(e)&&n.set(e,r)}return n}function ue(e,t){let n=new Map,r=[...e].sort((e,t)=>e.localeCompare(t));for(let e of r){let r=e.lastIndexOf(`/`),i=t(r===-1?e:e.slice(r+1));i&&!n.has(i)&&n.set(i,e)}return n}function de(e){let t=new Map;for(let[n,r]of e){let e=r.icon;typeof e==`string`&&e.trim()!==``&&t.set(n,e)}return t}function fe(){return _}function pe(e){if(!se(_,e)){_=e;for(let t of Array.from(oe))try{t(e)}catch(e){console.error(`[page-list-cache] subscriber threw:`,e)}}}function me(e){if(oe.add(e),_!==null)try{e(_)}catch(e){console.error(`[page-list-cache] subscriber threw on replay:`,e)}return()=>{oe.delete(e)}}function he(e,t){let n=e.replace(/^\/+|\/+$/g,``);return`${p}${n?`${n}/`:``}${t}`}function ge(e){return e.scope===`project`?m(e.path):s(e.scope,e.name)}function _e(e,t){return e.scope===`project`?`${e.path.replace(/\/SKILL\.mdx?$/i,``)}/${m(t)}`:d(e.scope,e.name,t)}function y(e){let t=u(e);return t?.kind===`skill`?t.name:null}var b=`pane-main`;function x(e){return w(e)&&!e.includes(`\0doc-tab:`)}function S(e){return e.startsWith(`\0`)}function C(e){return typeof e==`string`&&!!e}function w(e){return typeof e==`string`&&!!e}function T(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function ve(e,t=new Set){if(!Array.isArray(e))return[];let n=new Set,r=[];for(let i of e)!x(i)||n.has(i)||!S(i)&&t.has(i)||(n.add(i),S(i)||t.add(i),r.push(i));return r}function ye(e,t){if(!Array.isArray(e))return[];let n=new Set(t),r=new Set,i=[];for(let t of e)!w(t)||!n.has(t)||r.has(t)||(r.add(t),i.push(t));return i}function be(e,t){return w(t)&&e.includes(t)?t:null}function xe(e,t,n){if(!t||!n.has(t))return t;let r=e.indexOf(t);for(let t=r+1;t<e.length;t++)if(!n.has(e[t]))return e[t]??null;for(let t=r-1;t>=0;t--)if(!n.has(e[t]))return e[t]??null;return null}function Se(e,t=new Set){if(!C(e.id))return null;let n=ve(e.openTabs,t),r=Array.isArray(e.newTabIds)?e.newTabIds.filter(e=>w(e)&&!n.includes(e)):[],i=be(n,e.activeTabId),a=w(e.activeNewTabId)&&r.includes(e.activeNewTabId)?e.activeNewTabId:null,o=i??(a===null?n[0]??null:null),s=o===null?a??r[0]??null:null,c=ye(e.pinnedTabIds,n),l=x(e.previewTabId)&&n.includes(e.previewTabId)&&!c.includes(e.previewTabId)?e.previewTabId:null;return{id:e.id,openTabs:n,pinnedTabIds:c,activeTabId:o,previewTabId:l,newTabIds:r,activeNewTabId:s,activeTarget:o!==null&&o===i?e.activeTarget??null:null,size:T(e.size)?e.size:1}}function E(e){if(e.length===0)return[];let t=e.reduce((e,t)=>e+(T(t.size)?t.size:0),0);if(t<=0){let t=100/e.length;return e.map(e=>({...e,size:t}))}return e.map(e=>({...e,size:(T(e.size)?e.size:0)/t*100}))}function D(e,t=100){return{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null,size:t}}function O(e=()=>b){let t=D(e());return{panes:[t],focusedPaneId:t.id}}function Ce(e){let t=e.panes.map(e=>({...e,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null}));return{panes:t,focusedPaneId:t.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:t[0]?.id??b}}function we(e){let t=k(e);return{panes:t.panes.map(({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})=>({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})),focusedPaneId:t.focusedPaneId}}function Te(e,t=()=>b){let n=()=>{let e=t();return{panes:[{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,size:100}],focusedPaneId:e}};if(typeof e!=`object`||!e)return n();let r=e;if(!Array.isArray(r.panes))return n();let i=new Set,a=[];for(let[e,t]of r.panes.entries()){if(typeof t!=`object`||!t)continue;let n=t;!C(n.id)||i.has(n.id)||(i.add(n.id),a.push({pane:n,id:n.id,visualIndex:e}))}if(a.length===0)return n();let o=C(r.focusedPaneId)?r.focusedPaneId:null,s=[...a].sort((e,t)=>e.id===o?-1:t.id===o?1:e.visualIndex-t.visualIndex),c=new Set,l=new Map;for(let{pane:e,id:t}of s){let n=ve(e.openTabs,c),r=be(n,e.activeTabId);l.set(t,{id:t,openTabs:n,pinnedTabIds:ye(e.pinnedTabIds,n),activeTabId:r??n[0]??null,size:T(e.size)?e.size:1})}let u=a.flatMap(({id:e})=>{let t=l.get(e);return t&&t.openTabs.length>0?[t]:[]});if(u.length===0)return n();let d=E(u);return{panes:d,focusedPaneId:o&&d.some(e=>e.id===o)?o:d[0].id}}function k(e){let t=new Set,n=new Set,r=e.panes.flatMap(e=>{if(!C(e.id)||t.has(e.id))return[];let r=Se(e,n);return r?(t.add(r.id),[r]):[]});if(r.length===0)return O();let i=E(r);return{panes:i,focusedPaneId:i.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:i[0].id}}function Ee(e){return e.panes.find(t=>t.id===e.focusedPaneId)??e.panes[0]??D(b)}function A(e,t){return e.panes.some(e=>e.id===t)?{...e,focusedPaneId:t}:e}function j(e,t){let n=e.panes.find(t=>t.id===e.focusedPaneId);return n?.openTabs.includes(t)||n?.newTabIds.includes(t)?n:e.panes.find(e=>e.openTabs.includes(t)||e.newTabIds.includes(t))??null}function De(e,t){return x(t)?j(e,t):null}function Oe(e){return e.panes.flatMap(e=>e.openTabs)}function ke(e){let t=new Set(Oe(e));return e.panes.flatMap(e=>e.pinnedTabIds.filter(e=>t.has(e)))}function M(e,t,n){return{...e,panes:e.panes.map(e=>e.id===t?n(e):e)}}function Ae(e,t,n,r){let i=e.panes.find(e=>e.id===t);if(!i)return e;let a=new Set(i.openTabs),o=n.filter(e=>a.has(e));for(let e of i.openTabs)o.includes(e)||o.push(e);let s=new Set(i.pinnedTabIds),c=o.indexOf(r),l=c>=0&&c<i.pinnedTabIds.length,u=i.openTabs.includes(r)?o.filter(e=>e===r?l:s.has(e)):i.pinnedTabIds;return M(e,t,e=>({...e,openTabs:o,pinnedTabIds:u,previewTabId:e.previewTabId===r?null:e.previewTabId}))}function N(e,t){let n=e.newTabIds.indexOf(t);if(n>=0){let r=e.newTabIds.filter(e=>e!==t),i=e.activeNewTabId===t,a=i?r[n]??r[n-1]??null:e.activeNewTabId,o=i&&a===null?e.openTabs[e.openTabs.length-1]??null:e.activeTabId;return{...e,newTabIds:r,activeNewTabId:a,activeTabId:o,activeTarget:a===null&&o===e.activeTabId?e.activeTarget:null}}if(e.openTabs.indexOf(t)<0)return e;let r=new Set([t]),i=xe(e.openTabs,e.activeTabId,r),a=e.activeTabId===t&&i===null?e.activeNewTabId??e.newTabIds[e.newTabIds.length-1]??null:e.activeNewTabId;return{...e,openTabs:e.openTabs.filter(e=>e!==t),pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t),activeTabId:i,activeNewTabId:a,previewTabId:e.previewTabId===t?null:e.previewTabId,activeTarget:a===null&&i===e.activeTabId?e.activeTarget:null}}function P(e){let t=e.panes.filter(e=>e.openTabs.length||e.newTabIds.length);if(t.length===0)return O(()=>e.focusedPaneId||b);let n=E(t);return{panes:n,focusedPaneId:n.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:n[0].id}}function je(e,t){let n=e.panes.flatMap(e=>{let n=new Set([...e.openTabs,...e.newTabIds]),r=(t.get(e.id)??[]).filter((e,t,r)=>n.has(e)&&r.indexOf(e)===t);if(r.length===0)return[];let i=new Set(r),a=e.openTabs.filter(e=>i.has(e)),o=e.newTabIds.filter(e=>i.has(e)),s=(e.activeTabId&&i.has(e.activeTabId)?e.activeTabId:null)??(e.activeNewTabId&&i.has(e.activeNewTabId)?e.activeNewTabId:null)??r[0],c=a.includes(s)?s:null,l=o.includes(s)?s:null;return[{...e,openTabs:a,pinnedTabIds:e.pinnedTabIds.filter(e=>i.has(e)),activeTabId:c,previewTabId:e.previewTabId&&i.has(e.previewTabId)?e.previewTabId:null,newTabIds:o,activeNewTabId:l,activeTarget:c===e.activeTabId?e.activeTarget:null}]});if(n.length===0)return O(()=>e.focusedPaneId||b);let r=E(n);return{panes:r,focusedPaneId:r.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:r[0].id}}function Me(e,t,n){let r=new Set(t),i=Math.max(0,Math.min(n,e.length)),a=0;for(let t=0;t<i;t+=1){let n=e[t];n&&r.has(n)&&(a+=1)}return a}function Ne(e,t,n,r){let i=j(e,t),a=e.panes.find(e=>e.id===n);if(!i||!a)return e;let o=i.newTabIds.includes(t);if(i.id===a.id){if(o){let a=i.newTabIds.filter(e=>e!==t),o=Math.max(0,Math.min(r,a.length));return M(e,n,e=>({...e,newTabIds:[...a.slice(0,o),t,...a.slice(o)],activeNewTabId:t,activeTabId:null,activeTarget:null}))}let a=i.openTabs.filter(e=>e!==t),s=Math.max(0,Math.min(r,a.length));return Ae(e,n,[...a.slice(0,s),t,...a.slice(s)],t)}let s=i.pinnedTabIds.includes(t),c=N(i,t),l=Math.max(0,Math.min(r,o?a.newTabIds.length:a.openTabs.length)),u=o?{...a,newTabIds:[...a.newTabIds.slice(0,l),t,...a.newTabIds.slice(l)],activeNewTabId:t,activeTabId:null,activeTarget:null}:{...a,openTabs:[...a.openTabs.slice(0,l),t,...a.openTabs.slice(l)],pinnedTabIds:s?[...a.pinnedTabIds,t]:a.pinnedTabIds,activeNewTabId:null,activeTabId:t,activeTarget:null},d=e.panes.map(e=>e.id===i.id?c:e.id===a.id?u:e);return A(P({...e,panes:d}),a.id)}function Pe(e,t,n,r,i){let a=j(e,t),o=e.panes.find(e=>e.id===n);if(!a||!o)return e;if(a.id===o.id&&a.openTabs.length+a.newTabIds.length===1)return A(e,a.id);let s=i();if(!C(s)||e.panes.some(e=>e.id===s))return e;let c=a.pinnedTabIds.includes(t),l=N(a,t),u=a.id===o.id?l:o,d=u.size/2,f={...u,size:d},p=a.newTabIds.includes(t),m={...D(s,d),openTabs:p?[]:[t],pinnedTabIds:c&&!p?[t]:[],activeTabId:p?null:t,previewTabId:null,newTabIds:p?[t]:[],activeNewTabId:p?t:null},h=e.panes.map(e=>e.id===a.id?l:e),g=h.findIndex(e=>e.id===o.id);if(g<0)return e;h[g]=f;let ee=r===`left`?g:g+1,te=[...h.slice(0,ee),m,...h.slice(ee)];return A(P({...e,panes:te}),s)}function Fe(e,t,n){let r=new Set(n),i=e.panes.find(e=>e.id===t);if(!i||r.size===0)return e;let a=xe(i.openTabs,i.activeTabId,r);return P(M(e,t,e=>{let t={...e,openTabs:e.openTabs.filter(e=>!r.has(e)),pinnedTabIds:e.pinnedTabIds.filter(e=>!r.has(e)),activeTabId:a,previewTabId:e.previewTabId&&r.has(e.previewTabId)?null:e.previewTabId,activeTarget:a===e.activeTabId?e.activeTarget:null};return e.newTabIds.reduce((e,t)=>r.has(t)?N(e,t):e,t)}))}function Ie(e,t){let n=new Map,r=new Set;for(let i of e.panes)for(let e of i.openTabs){let a=t(e),o=x(a)?a:null;n.set(e,o),o&&!S(o)&&i.pinnedTabIds.includes(e)&&r.add(o)}let i=new Set,a=e.panes.map(e=>{let t=new Map,a=new Set,o=[];for(let r of e.openTabs){let e=n.get(r);!e||a.has(e)||!S(e)&&i.has(e)||(a.add(e),S(e)||i.add(e),t.set(r,e),o.push(e))}let s=new Set(e.pinnedTabIds.flatMap(e=>t.get(e)??[])),c=o.filter(e=>S(e)?s.has(e):r.has(e)),l=e.activeTabId?t.get(e.activeTabId)??null:null,u=e.previewTabId&&t.get(e.previewTabId)===e.previewTabId?e.previewTabId:null;return{...e,openTabs:o,pinnedTabIds:c,activeTabId:l,previewTabId:u&&!c.includes(u)?u:null,activeTarget:l!==null&&l===e.activeTabId?e.activeTarget:null}});return P({...e,panes:a})}function Le(e,t){return Ie(e,e=>t(e)?e:null)}function F(e){return{workspace:e,openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}}function I(e,t={openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}){return{workspace:k(e),...t}}function Re(e,t,n){let r=e.panes.find(e=>e.id===t);return r?r.newTabIds.includes(n)?A(M(e,t,e=>({...e,activeTabId:null,activeNewTabId:n,activeTarget:null})),t):r.openTabs.includes(n)?A(M(e,t,e=>({...e,activeTabId:n,activeNewTabId:null,activeTarget:e.activeTabId===n?e.activeTarget:null})),t):e:e}function ze(e,t){switch(t.type){case`open-target`:{if(!x(t.tabId))return F(e);let n=e.panes.find(e=>e.id===t.paneId);if(!n)return F(e);let r=t.consumeActiveNewTab&&n.activeNewTabId?n.activeNewTabId:null,i=r===null?e:M(e,n.id,e=>N(e,r)),a=i.panes.find(e=>e.id===t.paneId&&e.openTabs.includes(t.tabId))??j(i,t.tabId),o=a!==null&&a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`&&S(t.tabId);if(a&&!o)return a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`?(i=Ne(i,t.tabId,t.paneId,n.openTabs.length),i=M(i,t.paneId,e=>({...e,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),I(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r})):(i=M(i,a.id,e=>({...e,activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),i=A(i,a.id),i=P(i),I(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r}));let s=i.panes.find(e=>e.id===t.paneId);if(!s)return F(e);let c=t.disposition===`preview`?s.previewTabId:null;return i=M(i,t.paneId,e=>{let n=c?e.openTabs.indexOf(c):-1,r=c?e.openTabs.filter(e=>e!==c):e.openTabs,i=n<0?[...r,t.tabId]:[...r.slice(0,n),t.tabId,...r.slice(n)];return{...e,openTabs:i,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==c),activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`preview`?t.tabId:e.previewTabId}}),i=A(i,t.paneId),I(i,{openedTabId:t.tabId,replacedPreviewTabId:c,consumedNewTabId:r})}case`activate-tab`:return I(Re(e,t.paneId,t.tabId));case`promote-preview`:return I(M(e,t.paneId,e=>({...e,previewTabId:e.previewTabId===t.tabId?null:e.previewTabId})));case`promote-all-previews`:return I({...e,panes:e.panes.map(e=>({...e,previewTabId:null}))});case`open-new-tab`:{if(!w(t.tabId))return F(e);let n=j(e,t.tabId);return n?I(Re(e,n.id,t.tabId)):e.panes.some(e=>e.id===t.paneId)?I(A(M(e,t.paneId,e=>({...e,newTabIds:[...e.newTabIds,t.tabId],activeTabId:null,activeNewTabId:t.tabId,activeTarget:null})),t.paneId)):F(e)}case`close-tabs`:return I(Fe(e,t.paneId,t.tabIds));case`pin-tab`:return I(M(e,t.paneId,e=>e.openTabs.includes(t.tabId)?{...e,pinnedTabIds:e.pinnedTabIds.includes(t.tabId)?e.pinnedTabIds:[...e.pinnedTabIds,t.tabId],previewTabId:e.previewTabId===t.tabId?null:e.previewTabId}:e));case`unpin-tab`:return I(M(e,t.paneId,e=>({...e,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t.tabId)})));case`reorder-tabs`:return I(Ae(e,t.paneId,t.tabIds,t.draggedTabId));case`move-tab`:return I(Ne(e,t.tabId,t.paneId,t.index));case`split-tab`:return I(Pe(e,t.tabId,t.paneId,t.side,()=>t.newPaneId));case`resize-panes`:return t.sizes.length!==e.panes.length||t.sizes.some(e=>!T(e))?F(e):I({...e,panes:e.panes.map((e,n)=>({...e,size:t.sizes[n]??e.size}))});case`remap-tabs`:return I(Ie(e,t.remap));case`prune-tabs`:return I(Le(e,t.keep));default:return F(e)}}function Be(e,t,n=25){return!C(t.paneId)||!w(t.tabId)||n<=0?[...e]:[t,...e.filter(e=>e.tabId!==t.tabId)].slice(0,n)}function Ve(t){return e.includes(t)}function He(e,t,n){return typeof e!=`string`||!n.includes(e)?null:tt(e)===(t===`skills`)?e:null}function L(){return $(Te(null),null,{})}var Ue=`ok-editor-tabs-v1:`,R=`\0folder:`,z=`\0asset:`,B=`\0skill-file:`,V=`\0skill-preview:`,H=/\.(md|mdx)$/i;function U(e){return H.test(e)?e.replace(H,``):null}function W(e){if(typeof e!=`string`||e.length===0||e.includes(`\0doc-tab:`))return!1;let t=e;return t.startsWith(R)?t.length>8:t.startsWith(z)?t.length>7:t.startsWith(B)?Ke(t)!==null:t.startsWith(V)?Ye(t)!==null:!0}var We=`:`;function Ge(e){let t=e.host===void 0?e.name:`${e.name}${We}${e.host}`;return`${B}${e.scope}/${t}/${e.path}`}function Ke(e){if(!e.startsWith(B))return null;let t=e.slice(12).split(`/`);if(t.length<3)return null;let[n,r,...i]=t,a=i.join(`/`);if(!n||!r||!a||!Ve(n))return null;let o=r.indexOf(We),s=o===-1?r:r.slice(0,o),c=o===-1?void 0:r.slice(o+1);return s?{scope:n,name:s,path:a,...c?{host:c}:{}}:null}function qe(e){return`${V}${ee(e)}`}function Je(e,t,n,r){for(let i of e){let e=J(i);if(e.kind===`skill-preview`&&e.flavor===t&&e.name===n&&e.level===r)return i}return null}function Ye(e){return e.startsWith(V)?te(e.slice(15)):null}function G(e){return e}function K(e){return`${R}${e}`}function q(e){return`${z}${e}`}function Xe(e,t){let n=y(e);if(n){let e=ae(n);return{baseName:e,extension:``,label:e,prefix:``}}let r=a(e);if(r){let e=r.rel?r.rel.split(`/`).pop()??r.rel:ae(r.name);return{baseName:e,extension:``,label:e,prefix:``}}let i=e.lastIndexOf(`/`),o=i<0?e:e.slice(i+1),s=H.test(t)&&H.test(o)?``:t,c=`${o}${s}`;return i<0?{baseName:o,extension:s,label:c,prefix:``}:{baseName:o,extension:s,label:c,prefix:`${e.slice(0,i)}/`}}function Ze(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return G(e.docName);case`folder`:return K(e.folderPath);case`missing`:return G(e.target);case`asset`:return q(e.assetPath);case`skill-file`:return Ge(e);case`skills`:return null;case`skill-preview`:return qe(e)}}function J(e){let t=e;if(t.startsWith(R))return{kind:`folder`,folderPath:t.slice(8)};if(t.startsWith(z))return{kind:`asset`,assetPath:t.slice(7)};let n=Ye(t);if(n)return{kind:`skill-preview`,...n};let r=Ke(t);return r?{kind:`skill-file`,...r}:{kind:`doc`,docName:t}}function Qe(e){let t=J(e);return t.kind===`doc`?t.docName:null}function $e(e,t){return e||t>0}function Y(e){return u(e)!=null||i(e)?.kind===`skill`||a(e)!=null}var et=/(?:^|\/)skills\/[^/]+\/(?:SKILL|references\/.+)$/;function X(e){return et.test(e)}function tt(e){let t=J(e);return t.kind===`skill-file`||t.kind===`skill-preview`||t.kind===`doc`&&(Y(t.docName)||X(t.docName))}function Z(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(W(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function nt(e,t,n){if(t<=0)return[];let r=new Set(Z(n,2**53-1)),i=Z(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function rt(e,t){let n=new Set(Z(t,2**53-1));return Z(e,2**53-1).filter(e=>!n.has(e))}function it(e,t,n){let r=Z(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function at(e,{pages:t,folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:a=null,keepHashDocName:o=null}){return Z(e,2**53-1).filter(e=>{let s=J(e);if(s.kind===`folder`)return n.has(s.folderPath);if(s.kind===`asset`)return r.has(s.assetPath)||i?.has(s.assetPath)===!0;if(s.kind===`skill-file`||s.kind===`skill-preview`)return!0;let l=U(s.docName);return t.has(s.docName)||l!==null&&t.has(l)||c(s.docName)||s.docName===a||s.docName===o})}function ot(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return Z(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=U(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=U(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>ct(Q(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?q(r):t},d=e=>{let t=c.get(e);return t?G(t):q(l(e))},f=[],p=new Set;for(let t of e){if(!W(t))continue;let e=J(t),a=e.kind===`doc`?u(e.docName,t):e.kind===`folder`?K(Q(e.folderPath,r)):e.kind===`asset`?d(e.assetPath):t;if(!p.has(a)&&(p.add(a),f.push(a),i.length===0&&f.length>=n))break}return i.length===0?f:nt(f,n,i.flatMap(e=>{if(!W(e))return[];let t=J(e);return[t.kind===`doc`?u(t.docName,e):t.kind===`folder`?K(Q(t.folderPath,r)):t.kind===`asset`?d(t.assetPath):e]}))}function st(e,t,n=[],r=[]){return ot(e,t,2**53-1,n,[],r)}function Q(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function ct(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function lt(e){if(typeof e!=`object`||!e)return L();let t=e;if(!Array.isArray(t.panes))return L();let n=typeof t.activeTabByMode==`object`&&t.activeTabByMode!==null&&!Array.isArray(t.activeTabByMode)?t.activeTabByMode:{};return $(Te(t),typeof t.updatedAt==`string`?t.updatedAt:null,n)}function $(e,t,n){let r=e.panes.flatMap(e=>e.openTabs);return{activeTabByMode:{files:He(n.files,`files`,r),skills:He(n.skills,`skills`,r)},updatedAt:t,panes:e.panes,focusedPaneId:e.focusedPaneId}}function ut(e,t={files:null,skills:null},n=()=>new Date){return $(we(e),n().toISOString(),t)}function dt(e){return`${Ue}${e}`}function ft(e,t){if(!e)return L();try{let n=e.getItem(t);return n?lt(JSON.parse(n)):L()}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),L()}}function pt(e,t,n){if(e)try{e.setItem(t,JSON.stringify(lt(n)))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}function mt(e){return e?e.kind===`skills`||e.kind===`skill-file`||e.kind===`skill-preview`?!0:e.kind===`doc`&&(Y(e.docName)||X(e.docName)):!1}function ht(e){let t=e.trim();return{normalizedTarget:t.replace(/^\.\/+/,``).replace(/^\/+/,``).replace(/\/+$/g,``),expectsFolder:/\/+$/.test(t)}}function gt(e){return ne(e).replace(/\/+$/g,``)}function _t(e){let t=new Set;for(let n of e)for(let e of ie(n))t.add(e);return t}function vt(e,t){if(!t)return;let n=h(e);if(n)return t.get(n)}function yt(e,t){if(!t||e.includes(`/`))return;let n=h(e);if(n)return t.get(n)}function bt(e,t){return t?`${e}${t}`:(e.split(`/`).pop()??``).lastIndexOf(`.`)>0?e:`${e}.md`}function xt(e,t){if(!re(e))return null;let n=r(e);if(n)return{kind:`doc`,target:n,docName:n};if(t.pages.has(e))return null;let i=bt(e,t.docExt);return{kind:`asset`,target:i,assetPath:i,mediaKind:g(i.slice(i.lastIndexOf(`.`)+1))}}function St(e,t){if(c(e)){let t=i(e);if(t?.kind===`skill`&&t.scope===`project`){let e=l(t.name);return{kind:`doc`,target:e,docName:e}}return{kind:`doc`,target:e,docName:e}}if(y(e))return{kind:`doc`,target:e,docName:e};let a=r(e);if(a)return{kind:`doc`,target:a,docName:a};let{normalizedTarget:s,expectsFolder:u}=ht(e);if(!s)return{kind:`missing`,target:s};if(!u&&(n(s)||o(s)))return{kind:`doc`,target:s,docName:s};let d=gt(e);if(!u&&t.pages.has(s))return{kind:`doc`,target:s,docName:s};if(!u&&d!==s&&t.pages.has(d))return{kind:`doc`,target:d,docName:d};if(!u){let e=vt(d,t.pagesBySlug);if(e)return{kind:`doc`,target:e,docName:e}}let f=`${d}/index`;if(t.pages.has(f))return{kind:`folder-index`,target:d,folderPath:d,docName:f,noteKind:`canonical-index`};let p=d.split(`/`).pop(),m=p?`${d}/${p}`:null;if(m&&t.pages.has(m))return{kind:`folder-index`,target:d,folderPath:d,docName:m,noteKind:`legacy-folder-note`};if(!u){let e=yt(d,t.pagesByBasename);if(e)return{kind:`doc`,target:e,docName:e}}if((t.folderPaths??_t(t.pages)).has(d))return{kind:`folder`,target:d,folderPath:d};if(!u){let e=xt(s,t);if(e)return e}return{kind:`missing`,target:d||s}}function Ct(e){return e.kind===`folder-index`?{kind:`folder`,target:e.folderPath,folderPath:e.folderPath}:e}function wt(e,n,r=t){return typeof n!=`number`||!f(n,r)?null:{kind:`large-file`,target:e,docName:e,size:n,limit:r}}function Tt(e,n,r=t){return e.kind!==`doc`&&e.kind!==`folder-index`?e:wt(e.docName,n.get(e.docName)?.size,r)??e}function Et(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return e.docName;case`missing`:return e.target;case`asset`:case`skill-file`:case`skills`:case`skill-preview`:case`folder`:return null}}export{fe as $,qe as A,k as B,ft as C,st as D,Q as E,ke as F,M as G,Be as H,Oe as I,ge as J,y as K,A as L,Xe as M,pt as N,$e as O,De as P,le as Q,Ee as R,lt as S,ot as T,Me as U,je as V,ze as W,de as X,he as Y,ue as Z,X as _,wt as a,dt as b,Tt as c,Qe as d,pe as et,G as f,K as g,Je as h,mt as i,Ze as j,Ge as k,q as l,at as m,Et as n,xt as o,rt as p,_e as q,Ct as r,St as s,_t as t,me as tt,ut as u,Y as v,it as w,J as x,tt as y,Ce as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,t}from"./chunk-CYidjpOJ.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{ui as a}from"./dist-TVrIGknK2.js";import{t as o}from"./dist-DoS8xGN6.js";import{d as s}from"./documents-events-B6nWdFan.js";import{t as c}from"./parse-api-error-Mgtc4OJu.js";import{t as l}from"./createLucideIcon-BcLKHslE.js";import{Q as ee,X as te,Z as ne,et as re,t as ie}from"./navigation-targets-BhdJAW-R.js";import{t as u}from"./documents-fetch-B8A9IAH3.js";import{r as ae}from"./startup-marks-BPO-vrjH.js";var d=l(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),f=l(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),p=e(r(),1),oe=i();function m(e,t){let n=!1,r=!1,i=!1;async function a(){if(!i){n=!0;try{await e()}finally{n=!1,i?r=!1:r&&(r=!1,a())}}}return{request(){if(!i){if(n){r=!0,t?.();return}a()}},dispose(){i=!0,r=!1,t?.()}}}var se=n(),h=(0,p.createContext)(null);function ce(e,t){if(t.size===0)return new Set(e);let n=new Set(e);for(let e of t)n.add(e);return n}function le(e,t){if(e.size===0)return new Set;let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function ue(e,t){let n=new Map(e);for(let e of t)n.has(e)||n.set(e,e);return n}async function g(){let e=await fetch(`/api/pages`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(c(t)??`/api/pages responded with ${e.status}`)}let t=await e.json();return Array.isArray(t.pages)?t.pages:[]}async function _(){let{ok:e,status:t,body:n}=await u();if(!e)throw Error(c(n)??`/api/documents responded with ${t}`);let r=n??{};return Array.isArray(r.documents)?{assetPaths:r.documents.filter(e=>e.kind===`asset`&&typeof e.path==`string`&&e.path.length>0).map(e=>e.path),folderPaths:r.documents.filter(e=>e.kind===`folder`&&typeof e.path==`string`&&e.path.length>0).map(e=>e.path),filePaths:r.documents.filter(e=>e.kind===`file`&&typeof e.path==`string`&&e.path.length>0).map(e=>e.path)}:{assetPaths:[],folderPaths:[],filePaths:[]}}function de(e){console.error(`[PageListContext] Failed to load pages:`,e)}function v(e){console.warn(`[PageListContext] Failed to load referenced assets:`,e)}function y(e){let t=(0,oe.c)(54),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Set,t[0]=r):r=t[0];let[i,c]=(0,p.useState)(r),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Map,t[1]=l):l=t[1];let[u,d]=(0,p.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Map,t[2]=f):f=t[2];let[v,y]=(0,p.useState)(f),b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=new Set,t[3]=b):b=t[3];let[x,S]=(0,p.useState)(b),C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=new Set,t[4]=C):C=t[4];let[w,ge]=(0,p.useState)(C),T;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[5]=T):T=t[5];let[E,_e]=(0,p.useState)(T),D;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=new Set,t[6]=D):D=t[6];let[O,k]=(0,p.useState)(D),[A,ve]=(0,p.useState)(!0),[j,M]=(0,p.useState)(null),N=(0,p.useRef)(0),P;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(P=function(){let e=N.current+=1;return Promise.all([g(),_().catch(he)]).then(t=>{let[n,r]=t;if(e!==N.current)return;let i=new Set(n.map(me));c(i),d(new Map(n.map(pe))),y(new Map(n.map(fe))),S(new Set(r.assetPaths)),ge(new Set(r.folderPaths)),_e(new Set(r.filePaths)),k(e=>le(e,i)),M(null),ae()}).catch(t=>{e===N.current&&(de(t),M(t instanceof Error?t.message:o._({id:`9Y6cCI`})))}).finally(()=>{e===N.current&&ve(!1)})},t[7]=P):P=t[7];let F=P,I;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){k(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n}),M(null)},t[8]=I):I=t[8];let ye=I,L,R;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{let e=m(F);e.request();let t=null,n=()=>{document.visibilityState===`visible`&&e.request()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=s(n=>{n.includes(`files`)&&t===null&&(t=setTimeout(()=>{t=null,e.request()},300))});return()=>{t!==null&&clearTimeout(t),e.dispose(),window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},R=[],t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,p.useEffect)(L,R);let z,B,V,H,U,W,G,K;if(t[11]!==O||t[12]!==x||t[13]!==E||t[14]!==w||t[15]!==v||t[16]!==u||t[17]!==i){W=ce(i,O);let e;t[26]!==O||t[27]!==u?(e=ue(u,O),t[26]=O,t[27]=u,t[28]=e):e=t[28],U=e,H=v,z=x,B=E,V=new Set([...ie(W),...w]),G=ee(W,a),K=ne(W,a),t[11]=O,t[12]=x,t[13]=E,t[14]=w,t[15]=v,t[16]=u,t[17]=i,t[18]=z,t[19]=B,t[20]=V,t[21]=H,t[22]=U,t[23]=W,t[24]=G,t[25]=K}else z=t[18],B=t[19],V=t[20],H=t[21],U=t[22],W=t[23],G=t[24],K=t[25];let q=K,J;t[29]===v?J=t[30]:(J=te(v),t[29]=v,t[30]=J);let Y=J,X,Z;t[31]!==z||t[32]!==B||t[33]!==V||t[34]!==Y||t[35]!==W||t[36]!==q||t[37]!==G?(X=()=>{re({pages:W,folderPaths:V,pagesBySlug:G,pagesByBasename:q,assetPaths:z,filePaths:B,pageIcons:Y})},Z=[W,V,G,q,z,B,Y],t[31]=z,t[32]=B,t[33]=V,t[34]=Y,t[35]=W,t[36]=q,t[37]=G,t[38]=X,t[39]=Z):(X=t[38],Z=t[39]),(0,p.useEffect)(X,Z);let Q;t[40]!==z||t[41]!==j||t[42]!==B||t[43]!==V||t[44]!==A||t[45]!==H||t[46]!==U||t[47]!==W||t[48]!==q||t[49]!==G?(Q={pages:W,pagesBySlug:G,pagesByBasename:q,pageTitles:U,pageMeta:H,folderPaths:V,assetPaths:z,filePaths:B,loading:A,error:j,refetch:F,addPage:ye},t[40]=z,t[41]=j,t[42]=B,t[43]=V,t[44]=A,t[45]=H,t[46]=U,t[47]=W,t[48]=q,t[49]=G,t[50]=Q):Q=t[50];let $;return t[51]!==n||t[52]!==Q?($=(0,se.jsx)(h,{value:Q,children:n}),t[51]=n,t[52]=Q,t[53]=$):$=t[53],$}function fe(e){return[e.docName,{size:e.size,modified:e.modified,docExt:e.docExt,icon:e.icon}]}function pe(e){return[e.docName,e.title]}function me(e){return e.docName}function he(e){return v(e),{assetPaths:[],folderPaths:[],filePaths:[]}}function b(){let e=(0,p.use)(h);if(!e)throw Error(`usePageList must be used within <PageListProvider />`);return e}function x(){return(0,p.use)(h)}var S=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),C=t(((e,t)=>{var n=S();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),w=t(((e,t)=>{t.exports=C()()}));export{m as a,b as i,y as n,f as o,x as r,d as s,w as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./repair-skills-DwcUYwoH.mjs";export{e as repairSkills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,o as t,r as n}from"./server-lock-DQ_whZyH.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./src-Cb3i1kcm.mjs";import{r as e}from"./logger-DFxEUjvj.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>G({lockName:t,lockDir:n}),updatePort:e=>B({lockName:t,lockDir:n,port:e})}}function B(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=k(n,t);if(!o(a)){D.warn({lockPath:a},`${i} Lock file missing at ${a} during port update — skipping`);return}let s;try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:a},`${i} Corrupt lock at ${a} during port update — skipping`);return}s=e}catch{D.warn({lockPath:a},`${i} Unreadable lock at ${a} during port update — skipping`);return}if(s.pid===process.pid&&N(s)){s.port=r;try{d(a,JSON.stringify(s,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function V(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function H(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function U(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function W(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>H({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function G(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){V({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var K=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function q(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new K(e.existing,e.lockPath):e}}function J(e,t){B({lockName:`server`,lockDir:e,port:t})}function Y(e){return H({lockName:`server`,lockDir:e})}function X(e,t){G({lockName:`server`,lockDir:e,...t})}function Z(e){V({lockName:`server`,lockDir:e})}function Q(e,t){return W({lockName:`server`,lockDir:e,...t})}export{_ as S,E as _,X as a,v as b,O as c,V as d,H as f,T as g,B as h,Y as i,R as l,G as m,q as n,J as o,U as p,Z as r,Q as s,K as t,k as u,C as v,g as x,y};
|
|
2
|
-
//# sourceMappingURL=server-lock-DQ_whZyH.mjs.map
|