@inkeep/open-knowledge 0.49.0-beta.24 → 0.49.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/{acp-harness-probe-BUSbhOih.mjs → acp-harness-probe-B0G2vBqc.mjs} +2 -2
  2. package/dist/cli.mjs +7 -7
  3. package/dist/constants-BmQL4YFQ.mjs +2 -0
  4. package/dist/index.mjs +1 -1
  5. package/dist/init-BxgXDSU4.mjs +1 -0
  6. package/dist/{init-MCgaljSF.mjs → init-CYSajZiN.mjs} +3 -3
  7. package/dist/{launch-json-removal-BmDsNwPt.mjs → launch-json-removal-A5wdTNlW.mjs} +2 -2
  8. package/dist/{loader-ekJmDLtT.mjs → loader-C6XP6nLE.mjs} +2 -2
  9. package/dist/loader-p4V6ECAK.mjs +1 -0
  10. package/dist/{open-browser-CxnOIVsL.mjs → open-browser-mQ1Bw0J9.mjs} +2 -2
  11. package/dist/{preview-DO6-cA5G.mjs → preview-B2oumDjf.mjs} +2 -2
  12. package/dist/preview-CE8DJNiF.mjs +1 -0
  13. package/dist/public/assets/{ActivityModeContent-C08FYohG.js → ActivityModeContent-BFBUhXcI.js} +1 -1
  14. package/dist/public/assets/{AgentDiffPane-T499-ugv.js → AgentDiffPane-DmgRhD8e.js} +1 -1
  15. package/dist/public/assets/{AgentThreadClientBinder-BlMGv16y.js → AgentThreadClientBinder-GZjGixuH.js} +1 -1
  16. package/dist/public/assets/{ChangedOutsideBadge-GeQfL_b-.js → ChangedOutsideBadge-Cv8USc43.js} +1 -1
  17. package/dist/public/assets/{CodeMirrorPropInput-3TWUbzXY.js → CodeMirrorPropInput-9fhI0VAh.js} +1 -1
  18. package/dist/public/assets/{DocumentContext-C-Lo65-_.js → DocumentContext-nOyI-2M0.js} +1 -1
  19. package/dist/public/assets/{EditorModeToggle-BjgmECAn.js → EditorModeToggle-EYwVSG70.js} +1 -1
  20. package/dist/public/assets/{EnableSyncConfirmDialog-B1Eo_sVE.js → EnableSyncConfirmDialog-FrOsl5aY.js} +1 -1
  21. package/dist/public/assets/FeedbackForm-D16BkoQE.js +1 -0
  22. package/dist/public/assets/{GraphPanel-CxJeFUDp.js → GraphPanel-DQgAv5_k.js} +1 -1
  23. package/dist/public/assets/{ImportSkillDialog-ChsGV6eb.js → ImportSkillDialog-CinhDL2g.js} +1 -1
  24. package/dist/public/assets/{LintConfigEditor-3f4-NF1O.js → LintConfigEditor-4QoUjlwb.js} +1 -1
  25. package/dist/public/assets/{ManagedArtifactProperties-B1ZA0ofn.js → ManagedArtifactProperties-BuTvoOYp.js} +1 -1
  26. package/dist/public/assets/ManagedArtifactProperties-CJlBCe1z.js +1 -0
  27. package/dist/public/assets/{McpConsentDialogBody-CG5af4os.js → McpConsentDialogBody-BhdzxOuS.js} +1 -1
  28. package/dist/public/assets/{MermaidDocEditor-C30-UfMg.js → MermaidDocEditor-DPGHm2Yf.js} +1 -1
  29. package/dist/public/assets/{ReportBugDialogBody-BUGec7jk.js → ReportBugDialogBody-CvNxkq80.js} +1 -1
  30. package/dist/public/assets/{SchemaConfigEditor-DPK5XbMd.js → SchemaConfigEditor-BBs-2qkk.js} +1 -1
  31. package/dist/public/assets/{SessionsHost-BobZkNwc.js → SessionsHost-CQB30dyD.js} +2 -2
  32. package/dist/public/assets/{SettingsDialogBody-COTbFRqi.js → SettingsDialogBody-DK9ene5l.js} +1 -1
  33. package/dist/public/assets/{ShareBranchSwitchDialog-C0mAHHVQ.js → ShareBranchSwitchDialog-CAU-Xs7K.js} +1 -1
  34. package/dist/public/assets/{ShareReceiveDialog-Coi9tYAP.js → ShareReceiveDialog-rO_ziJDn.js} +1 -1
  35. package/dist/public/assets/{ShareReceiveMissDialog-B03ClkaE.js → ShareReceiveMissDialog-CFLSBeL-.js} +1 -1
  36. package/dist/public/assets/{SkillEditBanner-C7z-32HN.js → SkillEditBanner-B1IKLW6K.js} +1 -1
  37. package/dist/public/assets/{SkillOriginInline-DgWSnmXH.js → SkillOriginInline-E7JFoq0I.js} +1 -1
  38. package/dist/public/assets/{SkillToolbarControls-PvRY_LHn.js → SkillToolbarControls-BIhmBwAB.js} +1 -1
  39. package/dist/public/assets/{SlidesToolbarControls-8TzXHMwI.js → SlidesToolbarControls-BQi6RLi_.js} +1 -1
  40. package/dist/public/assets/{SourceEditor-Duqpede9.js → SourceEditor-Cp6BtgMs.js} +1 -1
  41. package/dist/public/assets/{TerminalPanel-Bl3bWVA_.js → TerminalPanel-BAOlww8F.js} +1 -1
  42. package/dist/public/assets/{TerminalWindowApp-CgWp2eC-.js → TerminalWindowApp-CJOysYRr.js} +1 -1
  43. package/dist/public/assets/{TextDocEditor-CHDC5byq.js → TextDocEditor-Cso3mcp-.js} +1 -1
  44. package/dist/public/assets/ThreadView-DeyKw79l.js +10 -0
  45. package/dist/public/assets/{TimelineDiffPane-DnaRcvCk.js → TimelineDiffPane-e_19duLF.js} +1 -1
  46. package/dist/public/assets/{agent-diff-store-B7oQn7l7.js → agent-diff-store-CIXjntcw.js} +1 -1
  47. package/dist/public/assets/{agent-visibility-CHYjRInm.js → agent-visibility-CvZ8XtPP.js} +1 -1
  48. package/dist/public/assets/{auth-state-cache-BUYyIMUZ.js → auth-state-cache-rhnmn74G.js} +1 -1
  49. package/dist/public/assets/{client-version-DfXcf1Qf.js → client-version-CyKndMN4.js} +1 -1
  50. package/dist/public/assets/{comment-chips-BhvfCPCk.js → comment-chips-DTSyL-J1.js} +1 -1
  51. package/dist/public/assets/{config-context-DNY4at5d.js → config-context-Dqp-CwnJ.js} +1 -1
  52. package/dist/public/assets/{config-provider-B7dMDFNr.js → config-provider-CA7jSjm6.js} +1 -1
  53. package/dist/public/assets/{dist-PVtTd_Sj2.js → dist-CQI6-1xM2.js} +1 -1
  54. package/dist/public/assets/{doc-paths-CH8QyanF.js → doc-paths-D1ML_anF.js} +1 -1
  55. package/dist/public/assets/{documents-events-COSAPFkC.js → documents-events-CU1SZlDl.js} +1 -1
  56. package/dist/public/assets/{file-tree-adapter-B9dmiTPy.js → file-tree-adapter-NC64LhE5.js} +1 -1
  57. package/dist/public/assets/{file-tree-utils-CvsKsHRh.js → file-tree-utils-CBnjZ8_a.js} +1 -1
  58. package/dist/public/assets/{folder-config-api-IGZhtkRo.js → folder-config-api-9eU9a8Vx.js} +1 -1
  59. package/dist/public/assets/{follow-file-CWSsUd-S.js → follow-file-w7JbrzZs.js} +1 -1
  60. package/dist/public/assets/i18n-CYjCal_m.js +1 -0
  61. package/dist/public/assets/{index-Dmlpu4P1.js → index-Cq2BuWd2.js} +8 -8
  62. package/dist/public/assets/{lint-config-client-DkwFMG_T.js → lint-config-client-jktoVBJd.js} +1 -1
  63. package/dist/public/assets/{markdownlint-rule-browser-DY5CRVFm.js → markdownlint-rule-browser-CQrGdMTS.js} +1 -1
  64. package/dist/public/assets/{navigation-targets-DKe7BSku.js → navigation-targets-D-iDEja4.js} +1 -1
  65. package/dist/public/assets/{open-managed-artifact-tab-DGO7syz6.js → open-managed-artifact-tab-DZXqJ_0k.js} +1 -1
  66. package/dist/public/assets/{pending-receive-nav-store-SZ8w-xKW.js → pending-receive-nav-store-Bejjl_ZT.js} +1 -1
  67. package/dist/public/assets/{prop-types-DoONHMUn.js → prop-types-DyYLLIQb.js} +1 -1
  68. package/dist/public/assets/{receive-store-BvkW9HUo.js → receive-store-Czac8zm1.js} +1 -1
  69. package/dist/public/assets/{selection-context-CSP8zK1H.js → selection-context-Ct27KvHm.js} +1 -1
  70. package/dist/public/assets/{skill-actions-98H3SnCL.js → skill-actions-DwpN3-eB.js} +1 -1
  71. package/dist/public/assets/{skill-scope-Dr7iwSW3.js → skill-scope-78Suy4sY.js} +1 -1
  72. package/dist/public/assets/{skills-api-qDbnaMmu.js → skills-api-Dx4VSQB1.js} +1 -1
  73. package/dist/public/assets/{src-VcUCSe0b.js → src-BpRmnvw-.js} +1 -1
  74. package/dist/public/assets/{tag-pill-input-pBac7WXR.js → tag-pill-input-Co95yrR6.js} +1 -1
  75. package/dist/public/assets/{target-navigation-intent-DAyeqt__.js → target-navigation-intent-B3yXl8AI.js} +1 -1
  76. package/dist/public/assets/{terminal-launch-events-CIULxHeu.js → terminal-launch-events-94aIhofY.js} +1 -1
  77. package/dist/public/assets/{terminal-telemetry-CqkILJJU.js → terminal-telemetry-C9J9jNy9.js} +1 -1
  78. package/dist/public/assets/{typing-burst-detector-BOmjXV-P.js → typing-burst-detector-Biw0Buk7.js} +1 -1
  79. package/dist/public/assets/{uninstall-36twrq5C.js → uninstall-CVh8r8q2.js} +1 -1
  80. package/dist/public/assets/{use-activity-panel-BwANCYjg.js → use-activity-panel-Pw2Xigrl.js} +1 -1
  81. package/dist/public/assets/{use-collab-url-TKpnPAW8.js → use-collab-url-CxpQAoZ0.js} +1 -1
  82. package/dist/public/assets/{use-live-xterm-theme-B8OPZLR3.js → use-live-xterm-theme-CcaaVudK.js} +1 -1
  83. package/dist/public/assets/{use-open-skill-DCSEJ3jJ.js → use-open-skill-DhFbugcf.js} +1 -1
  84. package/dist/public/assets/{use-settings-route-CKMxexs3.js → use-settings-route-DMLcMwjw.js} +1 -1
  85. package/dist/public/assets/{use-skill-directory-D9S5f8By.js → use-skill-directory-Bb59gISE.js} +1 -1
  86. package/dist/public/assets/{use-skill-origin-8_nwflm6.js → use-skill-origin-DWkOs5ts.js} +1 -1
  87. package/dist/public/assets/{use-skills-D5kEHDif.js → use-skills-Cl0nsUBm.js} +1 -1
  88. package/dist/public/assets/{use-terminal-enabled-Ctosnrg_.js → use-terminal-enabled-BHdXkRUU.js} +1 -1
  89. package/dist/public/assets/{use-timeline-entry-diff-CB_cI1yy.js → use-timeline-entry-diff-C8Tw_gvv.js} +1 -1
  90. package/dist/public/assets/{use-workspace--QTATo27.js → use-workspace-C2xbCdck.js} +1 -1
  91. package/dist/public/index.html +44 -44
  92. package/dist/public/uninstall.html +3 -3
  93. package/dist/{repair-launch-json-BWUKaV3g.mjs → repair-launch-json-aFmED0c2.mjs} +2 -2
  94. package/dist/{repair-mcp-configs-Bmgf-Fxv.mjs → repair-mcp-configs--aCpb3hv.mjs} +2 -2
  95. package/dist/repair-skills-DERbFdPf.mjs +1 -0
  96. package/dist/{repair-skills-CkZZbtNk.mjs → repair-skills-pwgCyOxg.mjs} +2 -2
  97. package/dist/{skill-teardown-CZnemDLF.mjs → skill-teardown-CdEzylv3.mjs} +2 -2
  98. package/dist/{src-h5dDPK2z.mjs → src-Cbll3h9C.mjs} +1 -1
  99. package/dist/{src-9I3GiOoK.mjs → src-CyIFaiha.mjs} +394 -394
  100. package/dist/src-D6BRXZY1.mjs +20 -0
  101. package/dist/start-Cn6o3oS6.mjs +1 -0
  102. package/dist/{start-QAIJ6Ttm.mjs → start-gQp2nx2w.mjs} +3 -3
  103. package/dist/{write-project-skill-WXZSbQlg.mjs → write-project-skill-BT83YFFS.mjs} +2 -2
  104. package/package.json +5 -5
  105. package/dist/constants-D3YZBBb9.mjs +0 -2
  106. package/dist/init-UTjBgomo.mjs +0 -1
  107. package/dist/loader-B98DqiVc.mjs +0 -1
  108. package/dist/preview-CUoBkJzj.mjs +0 -1
  109. package/dist/public/assets/FeedbackForm-CmdTz11F.js +0 -1
  110. package/dist/public/assets/ManagedArtifactProperties-B_ecuboX.js +0 -1
  111. package/dist/public/assets/ThreadView-VqdgemBS.js +0 -10
  112. package/dist/public/assets/i18n-CIRn0AvV.js +0 -1
  113. package/dist/repair-skills-l9Id0gzv.mjs +0 -1
  114. package/dist/src-D9aX2_QH.mjs +0 -20
  115. package/dist/start-C6P7_3_m.mjs +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./messages-CzRXVtjz.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-PVtTd_Sj2.js";import{n as ce}from"./dist-CEwo98ia.js";import{t as p}from"./dist-C7IFraT6.js";import"./i18n-CIRn0AvV.js";import{r as le}from"./client-version-DfXcf1Qf.js";import{h as ue,o as de,t as fe,u as pe}from"./config-context-DNY4at5d.js";var me=a(),m=e(r(),1),he=null,h=new Set;function ge(){return he}function _e(e){let t=e!==null&&e.length>0?e:null;if(t!==he){he=t;for(let e of h)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ve(e){return h.add(e),()=>{h.delete(e)}}function ye(){return(0,m.useSyncExternalStore)(ve,ge,ge)}var g=()=>new Map,be=e=>{let t=g();return e.forEach((e,n)=>{t.set(n,e)}),t},_=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},xe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Se=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},v=()=>new Set,Ce=e=>e[e.length-1],we=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},y=Array.from,Te=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ee=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},De=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},b=Array.isArray,Oe=class{constructor(){this._observers=g()}on(e,t){return _(this._observers,e,v).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 y((this._observers.get(e)||g()).values()).forEach(e=>e(...t))}destroy(){this._observers=g()}},ke=class{constructor(){this._observers=g()}on(e,t){_(this._observers,e,v).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 y((this._observers.get(e)||g()).values()).forEach(e=>e(...t))}destroy(){this._observers=g()}},x=Math.floor,Ae=Math.abs,je=(e,t)=>e<t?e:t,Me=(e,t)=>e>t?e:t;Number.isNaN;var Ne=e=>e===0?1/e<0:e<0,Pe=1<<17,Fe=1<<18,Ie=1<<19,Le=1<<20,Re=1<<21,ze=1<<22,Be=1<<23,Ve=1<<24,He=1<<25,Ue=1<<26,We=1<<27,Ge=1<<28,Ke=1<<29;Pe-1,Fe-1,Ie-1,Le-1,Re-1,ze-1,Be-1,Ve-1,He-1,Ue-1,We-1,Ge-1,Ke-1;var qe=2**53-1,Je=-(2**53-1),Ye=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&x(e)===e);Number.isNaN,Number.parseInt;var Xe=String.fromCharCode;String.fromCodePoint,Xe(65535);var Ze=e=>e.toLowerCase(),Qe=/^\s*/g,$e=e=>e.replace(Qe,``),et=/([A-Z])/g,tt=(e,t)=>$e(e.replace(et,e=>`${t}${Ze(e)}`)),nt=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},rt=typeof TextEncoder<`u`?new TextEncoder:null,it=rt?e=>rt.encode(e):nt,at=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});at&&at.decode(new Uint8Array).length===1&&(at=null);var ot=(e,t)=>De(t,()=>e).join(``),st=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ct=()=>new st,lt=e=>{let t=ct();return e(t),S(t)},ut=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array(ut(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},dt=(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(Me(n,t)*2),e.cpos=0)},C=(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},ft=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=x(t/128);C(e,127&t)},pt=(e,t)=>{let n=Ne(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=x(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=x(t/128)},mt=new Uint8Array(3e4),ht=mt.length/3,gt=rt&&rt.encodeInto?(e,t)=>{if(t.length<ht){let n=rt.encodeInto(t,mt).written||0;w(e,n);for(let t=0;t<n;t++)C(e,mt[t])}else T(e,it(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},_t=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=je(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(Me(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),_t(e,t)},vt=(e,t)=>{dt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},yt=(e,t)=>vt(e,4).setFloat32(0,t,!1),bt=(e,t)=>vt(e,8).setFloat64(0,t,!1),xt=(e,t)=>vt(e,8).setBigInt64(0,t,!1),St=new DataView(new ArrayBuffer(4)),Ct=e=>(St.setFloat32(0,e),St.getFloat32(0)===e),wt=(e,t)=>{switch(typeof t){case`string`:C(e,119),gt(e,t);break;case`number`:Ye(t)&&Ae(t)<=2147483647?(C(e,125),pt(e,t)):Ct(t)?(C(e,124),yt(e,t)):(C(e,123),bt(e,t));break;case`bigint`:C(e,122),xt(e,t);break;case`object`:if(t===null)C(e,126);else if(b(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)wt(e,t[n])}else if(t instanceof Uint8Array)C(e,116),T(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];gt(e,i),wt(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},Tt=class extends st{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Et=e=>{e.count>0&&(pt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},Dt=class{constructor(){this.encoder=new st,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Et(this),this.count=1,this.s=e)}toUint8Array(){return Et(this),S(this.encoder)}},Ot=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);pt(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},kt=class{constructor(){this.encoder=new st,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ot(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ot(this),S(this.encoder)}},At=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Dt}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 st;return this.sarr.push(this.s),this.s=``,gt(e,this.sarr.join(``)),_t(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},jt=E(`Unexpected end of array`),Mt=E(`Integer out of Range`),Nt=class{constructor(e){this.arr=e,this.pos=0}},Pt=e=>new Nt(e),Ft=e=>e.pos!==e.arr.length,It=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>It(e,A(e)),Lt=e=>e.arr[e.pos++],A=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>qe)throw Mt}throw jt},Rt=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>qe)throw Mt}throw jt},zt=at?e=>at.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(Lt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Lt(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))}},Bt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Vt=[e=>void 0,e=>null,Rt,e=>Bt(e,4).getFloat32(0,!1),e=>Bt(e,8).getFloat64(0,!1),e=>Bt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,zt,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=zt(e);n[t]=Ht(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(Ht(e));return n},k],Ht=e=>Vt[127-Lt(e)](e),Ut=class extends Nt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ft(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},Wt=class extends Nt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Rt(this);let e=Ne(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Gt=class extends Nt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Rt(this),t=e&1;this.diff=x(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Kt=class{constructor(e){this.decoder=new Wt(e),this.str=zt(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 qt=crypto.getRandomValues.bind(crypto),Jt=Math.random,Yt=()=>qt(new Uint32Array(1))[0],Xt=e=>e[x(Jt()*e.length)],Zt=`10000000-1000-4000-8000-100000000000`,Qt=()=>Zt.replace(/[018]/g,e=>(e^Yt()&15>>e/4).toString(16)),$t=Date.now,en=e=>new Promise(e);Promise.all.bind(Promise);var tn=e=>e===void 0?null:e,nn=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&&(nn=localStorage)}catch{}var rn=nn,an=Symbol(`Equality`),on=(e,t)=>e===t||!!e?.[an]?.(t)||!1,sn=e=>typeof e==`object`,cn=Object.assign,ln=Object.keys,un=(e,t)=>{for(let n in e)t(e[n],n)},dn=e=>ln(e).length,fn=e=>{for(let t in e)return!1;return!0},pn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},mn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hn=(e,t)=>e===t||dn(e)===dn(t)&&pn(e,(e,n)=>(e!==void 0||mn(t,n))&&on(t[n],e)),gn=Object.freeze,_n=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&_n(e[t])}return gn(e)},vn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&vn(e,t,n+1)}},yn=e=>e,bn=(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[an]!=null)return e[an](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)||!bn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(dn(e)!==dn(t))return!1;for(let n in e)if(!mn(e,n)||!bn(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(!bn(e[n],t[n]))return!1;break;default:return!1}return!0},xn=(e,t)=>t.includes(e),Sn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Cn=typeof window<`u`&&typeof document<`u`&&!Sn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var j,wn=[],Tn=()=>{if(j===void 0)if(Sn){j=g();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&j.set(t,``),t=r):t===null?wn.push(r):(j.set(t,r),t=null)}t!==null&&j.set(t,``)}else typeof location==`object`?(j=g(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);j.set(`--${tt(t,`-`)}`,n),j.set(`-${tt(t,`-`)}`,n)}})):j=g();return j},En=e=>Tn().has(e),Dn=e=>tn(Sn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:rn.getItem(e)),On=e=>En(`--`+e)||Dn(e)!==null,kn=On(`production`),An=Sn&&xn({}.FORCE_COLOR,[`true`,`1`,`2`])||!En(`--no-colors`)&&!On(`no-color`)&&(!Sn||process.stdout.isTTY)&&(!Sn||En(`--color`)||Dn(`COLORTERM`)!==null||(Dn(`TERM`)||``).includes(`color`)),jn=e=>new Uint8Array(e),Mn=Cn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Xe(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Nn=e=>{let t=jn(e.byteLength);return t.set(e),t},Pn=e=>lt(t=>wt(t,e)),Fn=class{constructor(e,t){this.left=e,this.right=t}},M=(e,t)=>new Fn(e,t),In=(e,t)=>e.forEach(e=>t(e.left,e.right)),Ln=e=>e.next()>=.5,Rn=(e,t,n)=>x(e.next()*(n+1-t)+t),zn=(e,t,n)=>x(e.next()*(n+1-t)+t),Bn=(e,t,n)=>zn(e,t,n),Vn=e=>Xe(Bn(e,97,122)),Hn=(e,t=0,n=20)=>{let r=Bn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Vn(e);return i},Un=(e,t)=>t[Bn(e,0,t.length-1)],Wn=Symbol(`0schema`),Gn=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(ot(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
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-CQI6-1xM2.js";import{n as ce}from"./dist-CEwo98ia.js";import{t as p}from"./dist-C7IFraT6.js";import"./i18n-CYjCal_m.js";import{r as le}from"./client-version-CyKndMN4.js";import{h as ue,o as de,t as fe,u as pe}from"./config-context-Dqp-CwnJ.js";var me=a(),m=e(r(),1),he=null,h=new Set;function ge(){return he}function _e(e){let t=e!==null&&e.length>0?e:null;if(t!==he){he=t;for(let e of h)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ve(e){return h.add(e),()=>{h.delete(e)}}function ye(){return(0,m.useSyncExternalStore)(ve,ge,ge)}var g=()=>new Map,be=e=>{let t=g();return e.forEach((e,n)=>{t.set(n,e)}),t},_=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},xe=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Se=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},v=()=>new Set,Ce=e=>e[e.length-1],we=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},y=Array.from,Te=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ee=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},De=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},b=Array.isArray,Oe=class{constructor(){this._observers=g()}on(e,t){return _(this._observers,e,v).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 y((this._observers.get(e)||g()).values()).forEach(e=>e(...t))}destroy(){this._observers=g()}},ke=class{constructor(){this._observers=g()}on(e,t){_(this._observers,e,v).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 y((this._observers.get(e)||g()).values()).forEach(e=>e(...t))}destroy(){this._observers=g()}},x=Math.floor,Ae=Math.abs,je=(e,t)=>e<t?e:t,Me=(e,t)=>e>t?e:t;Number.isNaN;var Ne=e=>e===0?1/e<0:e<0,Pe=1<<17,Fe=1<<18,Ie=1<<19,Le=1<<20,Re=1<<21,ze=1<<22,Be=1<<23,Ve=1<<24,He=1<<25,Ue=1<<26,We=1<<27,Ge=1<<28,Ke=1<<29;Pe-1,Fe-1,Ie-1,Le-1,Re-1,ze-1,Be-1,Ve-1,He-1,Ue-1,We-1,Ge-1,Ke-1;var qe=2**53-1,Je=-(2**53-1),Ye=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&x(e)===e);Number.isNaN,Number.parseInt;var Xe=String.fromCharCode;String.fromCodePoint,Xe(65535);var Ze=e=>e.toLowerCase(),Qe=/^\s*/g,$e=e=>e.replace(Qe,``),et=/([A-Z])/g,tt=(e,t)=>$e(e.replace(et,e=>`${t}${Ze(e)}`)),nt=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},rt=typeof TextEncoder<`u`?new TextEncoder:null,it=rt?e=>rt.encode(e):nt,at=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});at&&at.decode(new Uint8Array).length===1&&(at=null);var ot=(e,t)=>De(t,()=>e).join(``),st=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ct=()=>new st,lt=e=>{let t=ct();return e(t),S(t)},ut=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array(ut(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},dt=(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(Me(n,t)*2),e.cpos=0)},C=(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},ft=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=x(t/128);C(e,127&t)},pt=(e,t)=>{let n=Ne(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=x(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=x(t/128)},mt=new Uint8Array(3e4),ht=mt.length/3,gt=rt&&rt.encodeInto?(e,t)=>{if(t.length<ht){let n=rt.encodeInto(t,mt).written||0;w(e,n);for(let t=0;t<n;t++)C(e,mt[t])}else T(e,it(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},_t=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=je(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(Me(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),_t(e,t)},vt=(e,t)=>{dt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},yt=(e,t)=>vt(e,4).setFloat32(0,t,!1),bt=(e,t)=>vt(e,8).setFloat64(0,t,!1),xt=(e,t)=>vt(e,8).setBigInt64(0,t,!1),St=new DataView(new ArrayBuffer(4)),Ct=e=>(St.setFloat32(0,e),St.getFloat32(0)===e),wt=(e,t)=>{switch(typeof t){case`string`:C(e,119),gt(e,t);break;case`number`:Ye(t)&&Ae(t)<=2147483647?(C(e,125),pt(e,t)):Ct(t)?(C(e,124),yt(e,t)):(C(e,123),bt(e,t));break;case`bigint`:C(e,122),xt(e,t);break;case`object`:if(t===null)C(e,126);else if(b(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)wt(e,t[n])}else if(t instanceof Uint8Array)C(e,116),T(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];gt(e,i),wt(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},Tt=class extends st{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Et=e=>{e.count>0&&(pt(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},Dt=class{constructor(){this.encoder=new st,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Et(this),this.count=1,this.s=e)}toUint8Array(){return Et(this),S(this.encoder)}},Ot=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);pt(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},kt=class{constructor(){this.encoder=new st,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ot(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ot(this),S(this.encoder)}},At=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Dt}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 st;return this.sarr.push(this.s),this.s=``,gt(e,this.sarr.join(``)),_t(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},jt=E(`Unexpected end of array`),Mt=E(`Integer out of Range`),Nt=class{constructor(e){this.arr=e,this.pos=0}},Pt=e=>new Nt(e),Ft=e=>e.pos!==e.arr.length,It=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>It(e,A(e)),Lt=e=>e.arr[e.pos++],A=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>qe)throw Mt}throw jt},Rt=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>qe)throw Mt}throw jt},zt=at?e=>at.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(Lt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Lt(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))}},Bt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Vt=[e=>void 0,e=>null,Rt,e=>Bt(e,4).getFloat32(0,!1),e=>Bt(e,8).getFloat64(0,!1),e=>Bt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,zt,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=zt(e);n[t]=Ht(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(Ht(e));return n},k],Ht=e=>Vt[127-Lt(e)](e),Ut=class extends Nt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ft(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},Wt=class extends Nt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Rt(this);let e=Ne(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Gt=class extends Nt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Rt(this),t=e&1;this.diff=x(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Kt=class{constructor(e){this.decoder=new Wt(e),this.str=zt(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 qt=crypto.getRandomValues.bind(crypto),Jt=Math.random,Yt=()=>qt(new Uint32Array(1))[0],Xt=e=>e[x(Jt()*e.length)],Zt=`10000000-1000-4000-8000-100000000000`,Qt=()=>Zt.replace(/[018]/g,e=>(e^Yt()&15>>e/4).toString(16)),$t=Date.now,en=e=>new Promise(e);Promise.all.bind(Promise);var tn=e=>e===void 0?null:e,nn=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&&(nn=localStorage)}catch{}var rn=nn,an=Symbol(`Equality`),on=(e,t)=>e===t||!!e?.[an]?.(t)||!1,sn=e=>typeof e==`object`,cn=Object.assign,ln=Object.keys,un=(e,t)=>{for(let n in e)t(e[n],n)},dn=e=>ln(e).length,fn=e=>{for(let t in e)return!1;return!0},pn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},mn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hn=(e,t)=>e===t||dn(e)===dn(t)&&pn(e,(e,n)=>(e!==void 0||mn(t,n))&&on(t[n],e)),gn=Object.freeze,_n=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&_n(e[t])}return gn(e)},vn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&vn(e,t,n+1)}},yn=e=>e,bn=(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[an]!=null)return e[an](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)||!bn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(dn(e)!==dn(t))return!1;for(let n in e)if(!mn(e,n)||!bn(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(!bn(e[n],t[n]))return!1;break;default:return!1}return!0},xn=(e,t)=>t.includes(e),Sn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Cn=typeof window<`u`&&typeof document<`u`&&!Sn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var j,wn=[],Tn=()=>{if(j===void 0)if(Sn){j=g();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&j.set(t,``),t=r):t===null?wn.push(r):(j.set(t,r),t=null)}t!==null&&j.set(t,``)}else typeof location==`object`?(j=g(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);j.set(`--${tt(t,`-`)}`,n),j.set(`-${tt(t,`-`)}`,n)}})):j=g();return j},En=e=>Tn().has(e),Dn=e=>tn(Sn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:rn.getItem(e)),On=e=>En(`--`+e)||Dn(e)!==null,kn=On(`production`),An=Sn&&xn({}.FORCE_COLOR,[`true`,`1`,`2`])||!En(`--no-colors`)&&!On(`no-color`)&&(!Sn||process.stdout.isTTY)&&(!Sn||En(`--color`)||Dn(`COLORTERM`)!==null||(Dn(`TERM`)||``).includes(`color`)),jn=e=>new Uint8Array(e),Mn=Cn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Xe(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Nn=e=>{let t=jn(e.byteLength);return t.set(e),t},Pn=e=>lt(t=>wt(t,e)),Fn=class{constructor(e,t){this.left=e,this.right=t}},M=(e,t)=>new Fn(e,t),In=(e,t)=>e.forEach(e=>t(e.left,e.right)),Ln=e=>e.next()>=.5,Rn=(e,t,n)=>x(e.next()*(n+1-t)+t),zn=(e,t,n)=>x(e.next()*(n+1-t)+t),Bn=(e,t,n)=>zn(e,t,n),Vn=e=>Xe(Bn(e,97,122)),Hn=(e,t=0,n=20)=>{let r=Bn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Vn(e);return i},Un=(e,t)=>t[Bn(e,0,t.length-1)],Wn=Symbol(`0schema`),Gn=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(ot(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
3
3
  `)}},Kn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[an]?on(e,t):b(e)?Te(e,e=>Ee(t,t=>Kn(e,t))):sn(e)?pn(e,(e,n)=>Kn(e,t[n])):!1,N=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Kn(t,n)}equals(e){return this.constructor===e.constructor&&bn(this.shape,e.shape)}[Wn](){return!0}[an](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){D()}get nullable(){return Cr(this,Rr)}get optional(){return new tr(this)}cast(e){return Hr(e,this),e}expect(e){return Hr(e,this),e}},qn=class extends N{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}},P=(e,t=null)=>new qn(e,t);P(qn);var Jn=class extends N{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}},F=e=>new Jn(e);P(Jn);var Yn=class extends N{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}},Xn=(...e)=>new Yn(e),Zn=P(Yn),Qn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),$n=e=>{if(Nr.check(e))return[Qn(e)];if(Zn.check(e))return e.shape.map(e=>e+``);if(Mr.check(e))return[`[+-]?\\d+.?\\d*`];if(Pr.check(e))return[`.*`];if(wr.check(e))return e.shape.map($n).flat(1);O()};P(class extends N{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map($n).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 er=Symbol(`optional`),tr=class extends N{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[er](){return!0}},nr=P(tr),rr=class extends N{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new rr,P(rr);var ir=class e extends N{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):pn(this.shape,(n,r)=>{let i=this._isPartial&&!mn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},ar=e=>new ir(e),or=P(ir),sr=F(e=>e!=null&&(e.constructor===Object||e.constructor==null)),cr=class extends N{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&pn(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)})}},lr=(e,t)=>new cr(e,t),ur=P(cr),dr=class extends N{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&pn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},fr=(...e)=>new dr(e);P(dr);var pr=class extends N{constructor(e){super(),this.shape=e.length===1?e[0]:new Sr(e)}check(e,t){let n=b(e)&&Te(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},mr=(...e)=>new pr(e),hr=P(pr),gr=F(e=>b(e)),_r=class extends N{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}},vr=(e,t=null)=>new _r(e,t);P(_r);var yr=vr(N),br=P(class extends N{constructor(e){super(),this.len=e.length-1,this.args=fr(...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}}),xr=F(e=>typeof e==`function`);P(class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=Te(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Sr=class extends N{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Ee(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Cr=(...e)=>e.findIndex(e=>wr.check(e))>=0?Cr(...e.map(e=>Vr(e)).map(e=>wr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Sr(e),wr=P(Sr),Tr=()=>!0,Er=F(Tr),Dr=P(Jn,e=>e.shape===Tr),Or=F(e=>typeof e==`bigint`),kr=F(e=>e===Or),Ar=F(e=>typeof e==`symbol`);F(e=>e===Ar);var jr=F(e=>typeof e==`number`),Mr=F(e=>e===jr),Nr=F(e=>typeof e==`string`),Pr=F(e=>e===Nr),Fr=F(e=>typeof e==`boolean`),Ir=F(e=>e===Fr),Lr=Xn(void 0);P(Yn,e=>e.shape.length===1&&e.shape[0]===void 0),Xn(void 0);var Rr=Xn(null),zr=P(Yn,e=>e.shape.length===1&&e.shape[0]===null);P(Uint8Array),P(qn,e=>e.shape===Uint8Array);var Br=Cr(jr,Nr,Rr,Lr,Or,Fr,Ar);(()=>{let e=mr(Er),t=lr(Nr,Er),n=Cr(jr,Nr,Rr,Fr,e,t);return e.shape=n,t.shape.values=n,n})();var Vr=e=>{if(yr.check(e))return e;if(sr.check(e)){let t={};for(let n in e)t[n]=Vr(e[n]);return ar(t)}else if(gr.check(e))return Cr(...e.map(Vr));else if(Br.check(e))return Xn(e);else if(xr.check(e))return P(e);O()},Hr=kn?()=>{}:(e,t)=>{let n=new Gn;if(!t.check(e,n))throw E(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Ur=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Vr(e),h:t}),this}else(e){return this.if(Er,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 E(`Unhandled pattern`)}}},Wr=(e=>new Ur(e))(Er).if(Mr,(e,t)=>Rn(t,Je,qe)).if(Pr,(e,t)=>Hn(t)).if(Ir,(e,t)=>Ln(t)).if(kr,(e,t)=>BigInt(Rn(t,Je,qe))).if(wr,(e,t)=>Gr(t,Un(t,e.shape))).if(or,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(nr.check(i)){if(Ln(t))continue;i=i.shape}n[r]=Wr(i,t)}return n}).if(hr,(e,t)=>{let n=[],r=zn(t,0,42);for(let i=0;i<r;i++)n.push(Gr(t,e.shape));return n}).if(Zn,(e,t)=>Un(t,e.shape)).if(zr,(e,t)=>null).if(br,(e,t)=>{let n=Gr(t,e.res);return()=>n}).if(Dr,(e,t)=>Gr(t,Un(t,[jr,Nr,Rr,Lr,Or,Fr,mr(jr),lr(Cr(`a`,`b`,`c`),jr)]))).if(ur,(e,t)=>{let n={},r=Rn(t,0,3);for(let i=0;i<r;i++){let r=Gr(t,e.shape.keys);n[r]=Gr(t,e.shape.values)}return n}).done(),Gr=(e,t)=>Wr(Vr(t),e),I=typeof document<`u`?document:{},Kr=e=>I.createElement(e),qr=()=>I.createDocumentFragment();F(e=>e.nodeType===ai);var Jr=e=>I.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Yr=(e,t)=>(In(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Xr=e=>{let t=qr();for(let n=0;n<e.length;n++)ti(t,e[n]);return t},Zr=(e,t)=>(ti(e,Xr(t)),e),Qr=(e,t=[],n=[])=>Zr(Yr(Kr(e),t),n);F(e=>e.nodeType===ni);var $r=Jr;F(e=>e.nodeType===ri);var ei=e=>xe(e,(e,t)=>`${t}:${e};`).join(``),ti=(e,t)=>e.appendChild(t),ni=I.ELEMENT_NODE,ri=I.TEXT_NODE;I.CDATA_SECTION_NODE,I.COMMENT_NODE;var ii=I.DOCUMENT_NODE;I.DOCUMENT_TYPE_NODE;var ai=I.DOCUMENT_FRAGMENT_NODE;F(e=>e.nodeType===ii);var oi=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),si=(e,t)=>new oi(setTimeout(t,e)),L=Symbol,ci=L(),li=L(),ui=L(),di=L(),fi=L(),pi=L(),mi=L(),hi=L(),gi=L(),_i=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};$t();var vi={[ci]:M(`font-weight`,`bold`),[li]:M(`font-weight`,`normal`),[ui]:M(`color`,`blue`),[fi]:M(`color`,`green`),[di]:M(`color`,`grey`),[pi]:M(`color`,`red`),[mi]:M(`color`,`purple`),[hi]:M(`color`,`orange`),[gi]:M(`color`,`black`)},yi=An?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=g(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=vi[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=ei(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}:_i,bi=(...e)=>{console.log(...yi(e)),Si.forEach(t=>t.print(e))},xi=(...e)=>{console.warn(...yi(e)),e.unshift(hi),Si.forEach(t=>t.print(e))},Si=v(),Ci=e=>({[Symbol.iterator](){return this},next:e}),wi=(e,t)=>Ci(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Ti=(e,t)=>Ci(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Ei=class{constructor(e,t){this.clock=e,this.len=t}},Di=class{constructor(){this.clients=new Map}},Oi=(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])Ua(e,i,o.clock,o.len,n)}}),ki=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=x((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},Ai=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&ki(n,t.clock)!==null},ji=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 Ei(r.clock,Me(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Mi=e=>{let t=new Di;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++)we(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return ji(t),t},Ni=(e,t,n,r)=>{_(e.clients,t,()=>[]).push(new Ei(n,r))},Pi=()=>new Di,Fi=e=>{let t=Pi();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 Ei(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Ii=(e,t)=>{w(e.restEncoder,t.clients.size),y(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),w(e.restEncoder,t);let r=n.length;w(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Li=e=>{let t=new Di,n=A(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=A(e.restDecoder),r=A(e.restDecoder);if(r>0){let i=_(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Ei(e.readDsClock(),e.readDsLen()))}}return t},Ri=(e,t,n)=>{let r=new Di,i=A(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=A(e.restDecoder),a=A(e.restDecoder),o=n.clients.get(i)||[],s=z(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Ni(r,i,s,a-s);let e=B(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,tc(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,tc(t,c,a-c.id.clock)),c.delete(t))}else Ni(r,i,n,a-n)}}if(r.clients.size>0){let e=new Ji;return w(e.restEncoder,0),Ii(e,r),e.toUint8Array()}return null},zi=Yt,Bi=class e extends Oe{constructor({guid:e=Qt(),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=zi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ia,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=en(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>en(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&&H(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(y(this.subdocs).map(e=>e.guid))}transact(e,t=null){return H(this,e,t)}get(e,t=W){let n=_(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==W&&r!==t)if(r===W){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,Ko)}getText(e=``){return this.get(e,ps)}getMap(e=``){return this.get(e,Yo)}getXmlElement(e=``){return this.get(e,vs)}getXmlFragment(e=``){return this.get(e,gs)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,y(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,H(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()}},Vi=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return A(this.restDecoder)}readDsLen(){return A(this.restDecoder)}},Hi=class extends Vi{readLeftID(){return R(A(this.restDecoder),A(this.restDecoder))}readRightID(){return R(A(this.restDecoder),A(this.restDecoder))}readClient(){return A(this.restDecoder)}readInfo(){return Lt(this.restDecoder)}readString(){return zt(this.restDecoder)}readParentInfo(){return A(this.restDecoder)===1}readTypeRef(){return A(this.restDecoder)}readLen(){return A(this.restDecoder)}readAny(){return Ht(this.restDecoder)}readBuf(){return Nn(k(this.restDecoder))}readJSON(){return JSON.parse(zt(this.restDecoder))}readKey(){return zt(this.restDecoder)}},Ui=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=A(this.restDecoder),this.dsCurrVal}readDsLen(){let e=A(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Wi=class extends Ui{constructor(e){super(e),this.keys=[],A(e),this.keyClockDecoder=new Gt(k(e)),this.clientDecoder=new Wt(k(e)),this.leftClockDecoder=new Gt(k(e)),this.rightClockDecoder=new Gt(k(e)),this.infoDecoder=new Ut(k(e),Lt),this.stringDecoder=new Kt(k(e)),this.parentInfoDecoder=new Ut(k(e),Lt),this.typeRefDecoder=new Wt(k(e)),this.lenDecoder=new Wt(k(e))}readLeftID(){return new _a(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new _a(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 Ht(this.restDecoder)}readBuf(){return k(this.restDecoder)}readJSON(){return Ht(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}}},Gi=class{constructor(){this.restEncoder=ct()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},Ki=class extends Gi{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){ft(this.restEncoder,e)}writeString(e){gt(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){wt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){gt(this.restEncoder,JSON.stringify(e))}writeKey(e){gt(this.restEncoder,e)}},qi=class{constructor(){this.restEncoder=ct(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){e===0&&O(),w(this.restEncoder,e-1),this.dsCurrVal+=e}},Ji=class extends qi{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new kt,this.clientEncoder=new Dt,this.leftClockEncoder=new kt,this.rightClockEncoder=new kt,this.infoEncoder=new Tt(ft),this.stringEncoder=new At,this.parentInfoEncoder=new Tt(ft),this.typeRefEncoder=new Dt,this.lenEncoder=new Dt}toUint8Array(){let e=ct();return w(e,0),T(e,this.keyClockEncoder.toUint8Array()),T(e,this.clientEncoder.toUint8Array()),T(e,this.leftClockEncoder.toUint8Array()),T(e,this.rightClockEncoder.toUint8Array()),T(e,S(this.infoEncoder)),T(e,this.stringEncoder.toUint8Array()),T(e,S(this.parentInfoEncoder)),T(e,this.typeRefEncoder.toUint8Array()),T(e,this.lenEncoder.toUint8Array()),_t(e,S(this.restEncoder)),S(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){wt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){wt(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)}},Yi=(e,t,n,r)=>{r=Me(r,t[0].id.clock);let i=B(t,r);w(e.restEncoder,t.length-i),e.writeClient(n),w(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)},Xi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{z(t,n)>e&&r.set(n,e)}),La(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),y(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Yi(e,t.clients.get(n),n,r)})},Zi=(e,t)=>{let n=g(),r=A(e.restDecoder);for(let i=0;i<r;i++){let r=A(e.restDecoder),i=Array(r),a=e.readClient(),o=A(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 G(R(a,o),t),o+=t;break}case 10:{let t=A(e.restDecoder);i[n]=new Y(R(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(R(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,ic(e,r));i[n]=c,o+=c.length}}}}return n},Qi=(e,t,n)=>{let r=[],i=y(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 Ia,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Y){let i=_(d,u.id.client,()=>z(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,z(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 Ji;return Xi(e,s,new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},$i=(e,t)=>Xi(e,t.doc.store,t.beforeState),ea=(e,t,n,r=new Wi(e))=>H(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Qi(e,i,Zi(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<z(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=oo([o.update,a.update])}}else i.pendingStructs=a;let s=Ri(r,e,i);if(i.pendingDs){let t=new Wi(Pt(i.pendingDs));A(t.restDecoder);let n=Ri(t,e,i);s&&n?i.pendingDs=oo([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,ta(e.doc,t)}},n,!1),ta=(e,t,n,r=Wi)=>{let i=Pt(t);ea(i,e,n,new r(i))},na=(e,t,n)=>ta(e,t,n,Hi),ra=(e,t,n=new Map)=>{Xi(e,t.store,n),Ii(e,Fi(t.store))},ia=(e,t=new Uint8Array([0]),n=new Ji)=>{ra(n,e,sa(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(so(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Ki)return io(r.map((e,t)=>t===0?e:po(e)));if(n.constructor===Ji)return oo(r)}return r[0]},aa=(e,t)=>ia(e,t,new Ki),oa=e=>{let t=new Map,n=A(e.restDecoder);for(let r=0;r<n;r++){let n=A(e.restDecoder),r=A(e.restDecoder);t.set(n,r)}return t},sa=e=>oa(new Vi(Pt(e))),ca=(e,t)=>(w(e.restEncoder,t.size),y(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),la=(e,t)=>ca(e,La(t.store)),ua=(e,t=new qi)=>(e instanceof Map?ca(t,e):la(t,e),t.toUint8Array()),da=e=>ua(e,new Gi),fa=class{constructor(){this.l=[]}},pa=()=>new fa,ma=(e,t)=>e.l.push(t),ha=(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.`)},ga=(e,t,n)=>vn(e.l,[t,n]),_a=class{constructor(e,t){this.client=e,this.clock=t}},va=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,R=(e,t)=>new _a(e,t),ya=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw O()},ba=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},xa=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Sa=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},Ca=e=>new xa(e.type==null?null:R(e.type.client,e.type.clock),e.tname??null,e.item==null?null:R(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),wa=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Ta=(e,t,n=0)=>new wa(e,t,n),Ea=(e,t,n)=>{let r=null,i=null;return e._item===null?i=ya(e):r=R(e._item.id.client,e._item.id.clock),new xa(r,i,t,n)},Da=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Ea(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Ea(e,R(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Ea(e,r.lastId,n);r=r.right}return Ea(e,null,n)},Oa=(e,t)=>{let n=za(e,t);return{item:n,diff:t.clock-n.id.clock}},ka=(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(z(r,i.client)<=i.clock)return null;let e=n?$s(r,i):Oa(r,i),t=e.item;if(!(t instanceof J))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(z(r,a.client)<=a.clock)return null;let{item:e}=n?$s(r,a):{item:za(r,a)};if(e instanceof J&&e.content instanceof q)c=e.content.type;else return null}else throw O();l=s>=0?c._length:0}return Ta(c,l,e.assoc)},Aa=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&va(e.item,t.item)&&va(e.type,t.type)&&e.assoc===t.assoc,ja=class{constructor(e,t){this.ds=e,this.sv=t}},Ma=(e,t)=>new ja(e,t);Ma(Pi(),new Map);var Na=e=>Ma(Fi(e.store),La(e.store)),Pa=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Ai(t.ds,e.id),Fa=(e,t)=>{let n=_(e.meta,Fa,v),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<z(r,n)&&V(e,R(n,t))}),Oi(e,t.ds,e=>{}),n.add(t))},Ia=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},La=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},z=(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},Ra=(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 O()}n.push(t)},B=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=x(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=x((n+r)/2)}throw O()},za=(e,t)=>{let n=e.clients.get(t.client);return n[B(n,t.clock)]},Ba=(e,t,n)=>{let r=B(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,tc(e,i,n-i.id.clock)),r+1):r},V=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ba(e,n,t.clock)]},Va=(e,t,n)=>{let r=t.clients.get(n.client),i=B(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==G&&r.splice(i+1,0,tc(e,a,n.clock-a.id.clock+1)),a},Ha=(e,t,n)=>{let r=e.clients.get(t.id.client);r[B(r,t.id.clock)]=n},Ua=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Ba(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Ba(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Wa=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Di,this.beforeState=La(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}},Ga=(e,t)=>t.deleteSet.clients.size===0&&!Se(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(ji(t.deleteSet),$i(e,t),Ii(e,t.deleteSet),!0),Ka=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&_(e.changed,t,v).add(n)},qa=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Ja=(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=B(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ya=(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=je(r.length-1,1+B(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+qa(r,e)}})},Xa=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{ji(a),n.afterState=La(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(()=>{ga(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&us(n)})}),vn(e,[])}finally{r.gc&&Ja(a,i,r.gcFilter),Ya(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Me(B(e,r),1);for(let t=e.length-1;t>=n;)t-=1+qa(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=B(r,n);a+1<r.length&&qa(r,a+1)>1||a>0&&qa(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(bi(hi,ci,`[yjs] `,li,pi,`Changed the client-id because another client seems to be using it.`),r.clientID=zi()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Ki;Ga(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Ji;Ga(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])):Xa(e,t+1)}}},H=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Wa(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&&Xa(i,0)}}return o},Za=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Qa=(e,t,n)=>{Oi(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||ba(t,n))&&ec(n,!1)})},$a=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;H(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Oi(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=$s(r,e.id);i>0&&(t=V(n,R(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||ba(t,e))&&c.push(e)}}),Oi(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||ba(t,e))&&!Ai(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=rc(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},eo=class extends Oe{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=b(e)?e[0].doc:e instanceof Bi?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 Di;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Ni(i,n,r,a)});let a=$t(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Mi([t.deletions,e.deleteSet]),t.insertions=Mi([t.insertions,i])}else r.push(new Za(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Oi(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||ba(n,t))&&ec(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=b(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof W?e.doc!==this.doc:e!==this.doc)&&xi(`[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=>Qa(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Qa(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=$a(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=$a(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*to(e){let t=A(e.restDecoder);for(let n=0;n<t;n++){let t=A(e.restDecoder),n=e.readClient(),r=A(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=A(e.restDecoder);yield new Y(R(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(R(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,ic(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new G(R(n,r),t),r+=t}}}}var no=class{constructor(e,t){this.gen=to(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Y);return this.curr}},ro=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},io=e=>oo(e,Hi,Ki),ao=(e,t)=>{if(e.constructor===G){let{client:n,clock:r}=e.id;return new G(R(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(R(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(R(r,i+t),null,R(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},oo=(e,t=Wi,n=Ji)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Pt(e))),i=r.map(e=>new no(e,!0)),a=null,o=new n,s=new ro(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Y?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)lo(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{lo(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(R(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Y?a.struct.length-=t:n=ao(n,t)),a.struct.mergeWith(n)||(lo(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Y;n=e.next())lo(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(lo(s,a.struct,a.offset),a=null),uo(s),Ii(o,Mi(r.map(e=>Li(e)))),o.toUint8Array()},so=(e,t,n=Wi,r=Ji)=>{let i=sa(t),a=new r,o=new ro(a),s=new n(Pt(e)),c=new no(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for(lo(o,e,Me(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)lo(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 uo(o),Ii(a,Li(s)),a.toUint8Array()},co=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=ct(),e.written=0)},lo=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&co(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},uo=e=>{co(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];w(t,r.written),_t(t,r.restEncoder)}},fo=(e,t,n,r)=>{let i=new n(Pt(e)),a=new no(i,!1),o=new r,s=new ro(o);for(let e=a.curr;e!==null;e=a.next())lo(s,t(e),0);return uo(s),Ii(o,Li(i)),o.toUint8Array()},po=e=>fo(e,yn,Wi,Ki),mo=`You must not compute changes after the event-handler fired.`,ho=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||=go(this.currentTarget,this.target)}deletes(e){return Ai(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(mo);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=Ce(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Ce(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Ce(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 E(mo);let t=this.target,n=v(),r=v(),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}},go=(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},U=()=>{xi(`Invalid access: Add Yjs type to a document before reading data.`)},_o=80,vo=0,yo=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=vo++}},bo=e=>{e.timestamp=vo++},xo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=vo++},So=(e,t,n)=>{if(e.length>=_o){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return xo(r,t,n),r}else{let r=new yo(t,n);return e.push(r),r}},Co=(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)=>Ae(t-e.index)<Ae(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,bo(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&&Ae(n.index-i)<r.parent.length/_o?(xo(n,r,i),n):So(e._searchMarker,r,i)},wo=(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=Me(t,i.index+n))}},To=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;_(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ga(r._eH,n,t)},W=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=pa(),this._dEH=pa(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw D()}clone(){throw D()}_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){ma(this._eH,e)}observeDeep(e){ma(this._dEH,e)}unobserve(e){ha(this._eH,e)}unobserveDeep(e){ha(this._dEH,e)}toJSON(){}},Eo=(e,t,n)=>{e.doc??U(),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},Do=e=>{e.doc??U();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},Oo=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Pa(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},ko=(e,t)=>{let n=0,r=e._start;for(e.doc??U();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}},Ao=(e,t)=>{let n=[];return ko(e,(r,i)=>{n.push(t(r,i,e))}),n},jo=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}}}},Mo=(e,t)=>{e.doc??U();let n=Co(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}},No=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Bs(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ds(new Uint8Array(n))),i.integrate(e,0);break;case Bi:i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ms(n)),i.integrate(e,0);break;default:if(n instanceof W)i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new q(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Po=()=>E(`Length exceeded!`),Fo=(e,t,n,r)=>{if(n>t._length)throw Po();if(n===0)return t._searchMarker&&wo(t._searchMarker,n,r.length),No(e,t,null,r);let i=n,a=Co(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&&V(e,R(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&wo(t._searchMarker,i,r.length),No(e,t,o,r)},Io=(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 No(e,t,r,n)},Lo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Co(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&&V(e,R(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&V(e,R(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Po();t._searchMarker&&wo(t._searchMarker,i,-a+r)},Ro=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},zo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Bs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Bs([r]);break;case Uint8Array:s=new Ds(r);break;case Bi:s=new Ms(r);break;default:if(r instanceof W)s=new q(r);else throw Error(`Unexpected content type`)}new J(R(o,z(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Bo=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Vo=e=>{let t={};return e.doc??U(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Ho=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted},Uo=(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&&Pa(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Wo=e=>(e.doc??U(),wi(e._map.entries(),e=>!e[1].deleted)),Go=class extends ho{},Ko=class e extends W{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 W?e.clone():e)),t}get length(){return this.doc??U(),this._length}_callObserver(e,t){super._callObserver(e,t),To(this,e,new Go(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{Fo(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):H(this.doc,t=>{Io(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{Lo(n,this,e,t)})}get(e){return Mo(this,e)}toArray(){return Do(this)}slice(e=0,t=this.length){return Eo(this,e,t)}toJSON(){return this.map(e=>e instanceof W?e.toJSON():e)}map(e){return Ao(this,e)}forEach(e){ko(this,e)}[Symbol.iterator](){return jo(this)}_write(e){e.writeTypeRef(Gs)}},qo=e=>new Ko,Jo=class extends ho{constructor(e,t,n){super(e,t),this.keysChanged=n}},Yo=class e extends W{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 W?e.clone():e)}),t}_callObserver(e,t){To(this,e,new Jo(this,e,t))}toJSON(){this.doc??U();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof W?r.toJSON():r}}),e}get size(){return[...Wo(this)].length}keys(){return Ti(Wo(this),e=>e[0])}values(){return Ti(Wo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ti(Wo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??U(),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):H(this.doc,t=>{Ro(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):H(this.doc,n=>{zo(n,this,e,t)}),t}get(e){return Bo(this,e)}has(e){return Ho(this,e)}clear(){this.doc===null?this._prelimContent.clear():H(this.doc,e=>{this.forEach(function(t,n,r){Ro(e,r,n)})})}_write(e){e.writeTypeRef(Ks)}},Xo=e=>new Yo,Zo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&hn(e,t),Qo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&O(),this.right.content.constructor){case K:this.right.deleted||ns(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}},$o=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case K:t.right.deleted||ns(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&V(e,R(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},es=(e,t,n,r)=>{let i=new Map,a=r?Co(t,n):null;return a?$o(e,new Qo(a.p.left,a.p,a.index,i),n-a.index):$o(e,new Qo(null,t._start,0,i),n)},ts=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===K&&Zo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J(R(a,z(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new K(o,r));l.integrate(e,0),n.right=l,n.forward()})},ns=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},rs=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===K&&Zo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},is=(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(!Zo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(R(a,z(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new K(s,c)),n.right.integrate(e,0),n.forward()}}return o},as=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;rs(n,i);let s=is(e,t,n,i),c=r.constructor===String?new Hs(r):r instanceof W?new q(r):new Ps(r),{left:l,right:u,index:d}=n;t._searchMarker&&wo(t._searchMarker,n.index,c.getLength()),u=new J(R(o,z(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(),ts(e,t,n,s)},os=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;rs(n,i);let s=is(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===K));){if(!n.right.deleted)switch(n.right.content.constructor){case K:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Zo(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&&V(e,R(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
4
  `;n.right=new J(R(o,z(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Hs(i)),n.right.integrate(e,0),n.forward()}ts(e,t,n,s)},ss=(e,t,n,r,i)=>{let a=t,o=g();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===K){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 K:{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&&ns(i,n);break}}}t=t.right}return s},cs=(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===K){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},ls=e=>{let t=0;return H(e.doc,n=>{let r=e._start,i=e._start,a=g(),o=be(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case K:ns(o,i.content);break;default:t+=ss(n,r,i,a,o),a=be(o),r=i;break}i=i.right}}),t},us=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&&Ua(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===K&&e.constructor!==G&&t.add(e.parent)})}H(n,n=>{Oi(e,e.deleteSet,e=>{if(e instanceof G||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===K?t.add(r):cs(n,e)});for(let e of t)ls(e)})},ds=(e,t,n)=>{let r=n,i=be(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case Ps:case Hs:n<t.right.length&&V(e,R(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&ss(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&wo(o._searchMarker,t.index,-r+n),t},fs=class extends ho{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=[];H(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},fn(o)||(e.attributes=cn({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case q:case Ps: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 Hs: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 K:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Zo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Zo(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;Zo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Zo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),ns(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}},ps=class e extends W{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??U(),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 fs(this,e,t);To(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??U();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Hs&&(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)):H(this.doc,n=>{let r=new Qo(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
5
  `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&as(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&ds(n,r,a.delete):os(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??U();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(Pa(s,e)||t!==void 0&&Pa(s,t))switch(s.content.constructor){case Hs:{let r=i.get(`ychange`);e!==void 0&&!Pa(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&&!Pa(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case q:case Ps:{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 K:Pa(s,e)&&(c(),ns(i,s.content));break}s=s.right}c()};return e||t?H(a,n=>{e&&Fa(n,e),t&&Fa(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)):H(r,r=>{let i=es(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),as(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):H(r,r=>{let i=es(r,this,e,!n);as(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)):H(n,n=>{ds(n,es(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)):H(r,r=>{let i=es(r,this,e,!1);i.right!==null&&os(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):H(this.doc,t=>{Ro(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):H(this.doc,n=>{zo(n,this,e,t)})}getAttribute(e){return Bo(this,e)}getAttributes(){return Vo(this)}_write(e){e.writeTypeRef(qs)}},ms=e=>new ps,hs=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??U()}[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===vs||t.constructor===gs)&&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})}},gs=class e extends W{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 W?e.clone():e)),t}get length(){return this.doc??U(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new hs(this,e)}querySelector(e){e=e.toUpperCase();let t=new hs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),y(new hs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){To(this,e,new bs(this,t,e))}toString(){return Ao(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),ko(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{Fo(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)H(this.doc,n=>{let r=e&&e instanceof W?e._item:e;No(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 E(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{Lo(n,this,e,t)})}toArray(){return Do(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Mo(this,e)}slice(e=0,t=this.length){return Eo(this,e,t)}forEach(e){ko(this,e)}_write(e){e.writeTypeRef(Ys)}},_s=e=>new gs,vs=class e extends gs{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 un(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof W?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):H(this.doc,t=>{Ro(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):H(this.doc,n=>{zo(n,this,e,t)})}getAttribute(e){return Bo(this,e)}hasAttribute(e){return Ho(this,e)}getAttributes(e){return e?Uo(this,e):Vo(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 ko(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Js),e.writeKey(this.nodeName)}},ys=e=>new vs(e.readKey()),bs=class extends ho{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)})}},xs=class e extends Yo{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(Xs),e.writeKey(this.hookName)}},Ss=e=>new xs(e.readKey()),Cs=class e extends ps{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(Zs)}},ws=e=>new Cs,Ts=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw D()}mergeWith(e){return!1}write(e,t,n){throw D()}integrate(e,t){throw D()}},Es=0,G=class extends Ts{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),Ra(e.doc.store,this)}write(e,t){e.writeInfo(Es),e.writeLen(this.length-t)}getMissing(e,t){return null}},Ds=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 D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Os=e=>new Ds(e.readBuf()),ks=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){Ni(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}},As=e=>new ks(e.readLen()),js=(e,t)=>new Bi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Ms=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(js(this.doc.guid,this.opts))}splice(e){throw D()}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}},Ns=e=>new Ms(js(e.readString(),e.readAny())),Ps=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 D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Fs=e=>new Ps(e.readJSON()),K=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 D()}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}},Is=e=>new K(e.readKey(),e.readJSON()),Ls=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}},Rs=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 Ls(n)},zs=Dn(`node_env`)===`development`,Bs=class e{constructor(e){this.arr=e,zs&&_n(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}},Vs=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Bs(n)},Hs=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}},Us=e=>new Hs(e.readString()),Ws=[qo,Xo,ms,ys,_s,Ss,ws],Gs=0,Ks=1,qs=2,Js=3,Ys=4,Xs=5,Zs=6,q=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw D()}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}},Qs=e=>new q(Ws[e.readTypeRef()](e)),$s=(e,t)=>{let n=t,r=0,i;do r>0&&(n=R(n.client,n.clock+r)),i=za(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},ec=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},tc=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(R(r,i+n),t,R(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=R(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},nc=(e,t)=>Ee(e,e=>Ai(e.deletions,t)),rc=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return V(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||rc(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=V(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:V(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:V(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||Ai(r,d.right.id)||nc(a.undoStack,d.right.id)||nc(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=V(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=R(c,z(s,c)),ne=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,ec(ne,!0),ne.integrate(e,0),ne},J=class e extends Ts{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>=z(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=z(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===_a&&this.id.client!==this.parent.client&&this.parent.clock>=z(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Va(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=V(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===G||this.right&&this.right.constructor===G)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===_a){let e=za(n,this.parent);e.constructor===G?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Va(e,e.doc.store,R(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),va(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(va(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(za(e.doc.store,n.origin)))r.has(za(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),Ra(e.doc.store,this),this.content.integrate(e,this),Ka(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new G(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:R(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&va(e.origin,this.lastId)&&this.right===e&&va(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(),Ni(e.deleteSet,this.id.client,this.id.clock,this.length),Ka(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw O();this.content.gc(e),t?Ha(e,this,new G(this.id,this.length)):this.content=new ks(this.length)}write(e,t){let n=t>0?R(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=ya(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===_a?(e.writeParentInfo(!1),e.writeLeftID(t)):O();i!==null&&e.writeString(i)}this.content.write(e,t)}},ic=(e,t)=>ac[t&31](e),ac=[()=>{O()},As,Rs,Os,Us,Fs,Is,Qs,Vs,Ns,()=>{O()}],oc=10,Y=class extends Ts{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){O()}write(e,t){e.writeInfo(oc),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}},sc=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},cc=`__ $YJS$ __`;sc[cc]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),sc[cc]=!0;var lc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),uc=(e,t)=>{w(e,lc.Token),gt(e,t)},dc=(e,t,n,r)=>{switch(A(e)){case lc.Token:t();break;case lc.PermissionDenied:n(zt(e));break;case lc.Authenticated:r(zt(e));break;default:}},fc=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),pc=`\0`;function mc(e,t){return e+pc+t}function hc(e){let t=e.indexOf(pc);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var gc=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function _c(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 vc(e){return new Promise(t=>setTimeout(t,e))}function yc(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 bc(e,t){let n=_c(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||yc;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 vc(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 vc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await vc(e)}return a()}var xc=Math.floor,Sc=(e,t)=>e<t?e:t,Cc=(e,t)=>e>t?e:t;Number.isNaN;var wc=64,Tc=128,Ec=1<<17,Dc=1<<18,Oc=1<<19,kc=1<<20,Ac=1<<21,jc=1<<22,Mc=1<<23,Nc=1<<24,Pc=1<<25,Fc=1<<26,Ic=1<<27,Lc=1<<28,Rc=1<<29,zc=1<<30,Bc=63,Vc=127;Ec-1,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;var Hc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Uc=()=>new Set,Wc=Array.from;Array.isArray;var Gc=String.fromCharCode;String.fromCodePoint,Gc(65535);var Kc=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},qc=typeof TextEncoder<`u`?new TextEncoder:null,Jc=qc?e=>qc.encode(e):Kc,Yc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Yc&&Yc.decode(new Uint8Array).length===1&&(Yc=null);var Xc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Zc=()=>new Xc,Qc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},$c=e=>{let t=new Uint8Array(Qc(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},el=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},X=(e,t)=>{for(;t>Vc;)el(e,Tc|Vc&t),t=xc(t/128);el(e,Vc&t)},tl=new Uint8Array(3e4),nl=tl.length/3,Z=qc&&qc.encodeInto?(e,t)=>{if(t.length<nl){let n=qc.encodeInto(t,tl).written||0;X(e,n);for(let t=0;t<n;t++)el(e,tl[t])}else il(e,Jc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)el(e,n.codePointAt(t))},rl=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Sc(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(Cc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},il=(e,t)=>{X(e,t.byteLength),rl(e,t)},al=e=>Error(e),ol=al(`Unexpected end of array`),sl=al(`Integer out of Range`),cl=class{constructor(e){this.arr=e,this.pos=0}},ll=e=>new cl(e),ul=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},dl=e=>ul(e,pl(e)),fl=e=>e.arr[e.pos++],pl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Vc)*n,n*=128,r<Tc)return t;if(t>Hc)throw sl}throw ol},ml=e=>{let t=e.arr[e.pos++],n=t&Bc,r=64,i=(t&wc)>0?-1:1;if((t&Tc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Vc)*r,r*=128,t<Tc)return i*n;if(n>Hc)throw sl}throw ol},hl=Yc?e=>Yc.decode(dl(e)):e=>{let t=pl(e);if(t===0)return``;{let n=String.fromCodePoint(fl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(fl(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,Uc).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 Wc((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`)},xc(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=Zc();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return $c(i)},Al=(e,t,n)=>{let r=ll(t),i=_l(),a=[],o=[],s=[],c=[],l=pl(r);for(let t=0;t<l;t++){let t=pl(r),n=pl(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=Zc(),this.decoder=ll(new Uint8Array(this.data))}peekVarString(){return gl(this.decoder)}readVarUint(){return pl(this.decoder)}readVarString(){return hl(this.decoder)}readVarUint8Array(){return dl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return il(this.encoder,e)}length(){return Qc(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=Zc()}get(e){return e.encoder}toUint8Array(){return $c(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 Z(this.encoder,e.documentName),X(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:bc(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=Zc();X(e,Q.Pong),this.send($c(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=ll(e);return{documentName:hl(t),messageType:pl(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===gc.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},Il=0,Ll=1,Rl=2,zl=(e,t)=>{X(e,Il),il(e,da(t))},Bl=(e,t,n)=>{X(e,Ll),il(e,aa(t,n))},Vl=(e,t,n)=>Bl(t,n,dl(e)),Hl=(e,t,n,r)=>{try{na(t,dl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Ul=(e,t)=>{X(e,Rl),il(e,t)},Wl=Hl,Gl=(e,t,n,r,i)=>{let a=pl(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;dc(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 $c(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 Z(this.encoder,e.documentName),X(this.encoder,this.type),uc(this.encoder,e.token),Z(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`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?kl(e.awareness,e.clients):kl(e.awareness,e.clients,e.states),il(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 Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(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 Z(this.encoder,e.documentName),X(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 Z(this.encoder,e.documentName),X(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?mc(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 Bi,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:fc(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:fc(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}=hc(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={...le()};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,me.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,m.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,me.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,m.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,m.useEffect)(o,s)}var uu={en:()=>t(()=>import(`./messages-CzRXVtjz.js`).then(e=>e.n),__vite__mapDeps([0,1]),import.meta.url),"zh-Hans":()=>t(()=>import(`./messages-CQFityfC.js`),[],import.meta.url),"zh-Hant":()=>t(()=>import(`./messages-BeOM8jWl.js`),[],import.meta.url),hi:()=>t(()=>import(`./messages-CCWKIebo.js`),[],import.meta.url),es:()=>t(()=>import(`./messages-DohtKbKM.js`),[],import.meta.url),ar:()=>t(()=>import(`./messages-BOXmrfhw.js`),[],import.meta.url),fr:()=>t(()=>import(`./messages-Db5U-G1d.js`),[],import.meta.url),bn:()=>t(()=>import(`./messages-DYiuNk7y.js`),[],import.meta.url),"pt-BR":()=>t(()=>import(`./messages-6Fd7I7zn.js`),[],import.meta.url),id:()=>t(()=>import(`./messages-WWFblTuV.js`),[],import.meta.url),ur:()=>t(()=>import(`./messages-BJIB1I1L.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]();p.load(e,t.messages),du.add(e)}fu===e&&p.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([p.locale],{type:`language`}).of(e)??e;ce.error(p._({id:`loE6tM`,values:{language:n}}),{id:gu,description:p._({id:`GtPGNJ`}),duration:1/0,action:{label:p._({id:`HpK_8d`}),onClick:t}})}function yu(){ce.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,me.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,m.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,me.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,m.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 Bi,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 Bi,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,me.c)(20),{collabUrl:n,children:r}=e,a=ye(),{systemTheme:o}=i(),s=o===`dark`,[u,te]=(0,m.useState)(null),[re,ie]=(0,m.useState)(null),[ae,se]=(0,m.useState)(null),[ce,p]=(0,m.useState)(null),le,he;t[0]!==n||t[1]!==a?(le=()=>{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()}),p({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=()=>{p(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),p(e=>e?.binding===i.binding?null:e)}},he=[n,a],t[0]=n,t[1]=a,t[2]=le,t[3]=he):(le=t[2],he=t[3]),(0,m.useEffect)(le,he);let h=u&&re?f(u.config,re.config,ae?.config):null,ge=h?.appearance?.theme,_e=h?.appearance?.customTheme,ve=h?.appearance?.colorThemeEnabled!==!1,g=d(h?.appearance),be=ne(ge,s),_=ve?g[be]:`default`,xe=_===`custom`?pe(ue(_e)):l(_)??ge;Eu(xe),de({selection:g,modePreference:ge,slotMode:be,customSeed:_e,enabled:ve}),wu({preference:h?.appearance?.language,userConfigSynced:u?.synced??!1}),ru(typeof window<`u`?window.okDesktop:void 0,h?.appearance?.language,u?.synced??!1),lu(typeof window<`u`?window.okDesktop:void 0,xe??`system`,`${_}:${_===`custom`?JSON.stringify(_e??null):``}`);let Se=u?.binding??null,v=u?.synced??!1,Ce=re?.binding??null,we=ae?.binding??null,y=ce?.binding??null,Te=ce?.synced??!1,Ee=u?.config??null,De=re?.config??null,b=re?.synced??!1,Oe=ae?.config??null,ke=ae?.synced??!1,x;t[4]!==h||t[5]!==De||t[6]!==b||t[7]!==Oe||t[8]!==ke||t[9]!==Se||t[10]!==v||t[11]!==Ce||t[12]!==we||t[13]!==y||t[14]!==Te||t[15]!==Ee?(x={userBinding:Se,userSynced:v,projectBinding:Ce,projectLocalBinding:we,okignoreBinding:y,okignoreSynced:Te,userConfig:Ee,projectConfig:De,projectSynced:b,projectLocalConfig:Oe,projectLocalSynced:ke,merged:h},t[4]=h,t[5]=De,t[6]=b,t[7]=Oe,t[8]=ke,t[9]=Se,t[10]=v,t[11]=Ce,t[12]=we,t[13]=y,t[14]=Te,t[15]=Ee,t[16]=x):x=t[16];let Ae=x,je;return t[17]!==r||t[18]!==Ae?(je=(0,Du.jsx)(fe,{value:Ae,children:r}),t[17]=r,t[18]=Ae,t[19]=je):je=t[19],je}export{D as $,da as A,si as B,Pi as C,Ma as D,Da as E,Oi as F,Pn as G,Qr as H,Sa as I,pn as J,Mn as K,Na as L,ya as M,Ai as N,sa as O,ba as P,E as Q,H as R,ka as S,Ca as T,$r as U,I as V,M as W,en as X,ln as Y,Xt as Z,vs as _,lu as a,v as at,ta as b,K as c,_e as ct,Bi as d,O as et,J as f,ps as g,eo as h,wu as i,ke as it,B as j,aa as k,Hs as l,ja as m,Su as n,Me as nt,nu as o,g as ot,xa as p,Cn as q,Cu as r,je as rt,tu as s,_ as st,ju as t,Ke as tt,q as u,Cs as v,R as w,Aa as x,na as y,Oo as z};
@@ -168,7 +168,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
168
168
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
169
169
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Du(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(Su(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=Eu(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Su(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(wu(t.key)&&!Su(t.sep,`newline`)){let e=Eu(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Su(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Su(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Du(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Su(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=Eu(Tu(t));Ou(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
170
170
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
171
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Eu(Tu(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Eu(Tu(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Au(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new xu||null,prettyErrors:t}}function ju(e,t={}){let{lineCounter:n,prettyErrors:r}=Au(t),i=new ku(n?.addNewLine),a=new su(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Cl(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Tl(e,n)),o.warnings.forEach(Tl(e,n))),o}function Mu(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=ju(e,n);if(!i)return null;if(i.warnings.forEach(e=>ac(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var Nu=[`off`,`follow`,`full`],Pu=[`follow`,`full`],Fu=`pull`,Iu=[`off`,`follow`,`full`,Fu],Lu=[`follow`,`full`,Fu];function Ru(e){return e===Fu?`follow`:zu(e)?e:null}function zu(e){return typeof e==`string`&&Nu.includes(e)}function Bu(e){return typeof e==`string`&&Pu.includes(e)}function Vu(e){let t=e?.resumeMode;return t===Fu?`follow`:Bu(t)?t:null}function Hu(e){return qu(e)===`off`&&Vu(e)!==null}function Uu(e){let t=qu(e);return t===`follow`||t===`full`||Hu(e)}function Wu(e){let t=qu(e);return Bu(t)?t:Vu(e)??`full`}function Gu(e){return e===!0?`full`:e===!1?`off`:null}function Ku(e){return e===!0?`full`:e===!1?`off`:Ru(e)}function qu(e){let t=Ru(e?.mode);return t===null?Gu(e?.enabled):t}var Ju={sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,feature:`gherkin`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`},Yu=new Set(Object.keys(Ju));function Xu(e){return Ju[e.toLowerCase().replace(/^\./,``)]??null}var Zu=new Set([`md`,`mdx`,`mmd`,`mermaid`]),Qu=new Set([...Yu,`txt`,`text`,`csv`,`tsv`,`log`,`toml`,`html`,`htm`,`svg`,`vue`,`svelte`,`astro`,`lock`].filter(e=>!Zu.has(e))),$u={html:`html`,htm:`html`,svg:`xml`,vue:`html`,svelte:`html`,astro:`html`,lock:`yaml`};function ed(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:Qu.has(t.slice(n+1).toLowerCase())}var td=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],nd=[`video/mp4`,`video/webm`,`video/ogg`],rd=[`audio/mpeg`,`audio/wav`,`audio/ogg`],id=[`application/pdf`],ad=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),od=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),sd=new Set([`pdf`]),cd=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),ld=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),ud=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),dd=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),fd=`wikiembed`,pd=`toast`,md=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),hd=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],gd=[`mp4`,`webm`,`mov`,`m4v`],_d=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],vd=[`pdf`],yd=[`json`,`toml`,`lock`];function bd(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}bd(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,hd,ad),bd(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,gd,od),bd(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,_d,cd),bd(`SIDEBAR_PDF_ASSET_EXTENSIONS`,vd,sd),bd(`FILE_ATTACHMENT_EXTENSIONS`,[...ld],md),bd(`WIKI_EMBED_EXTENSIONS`,[...md],ud);var xd=new Set(hd),Sd=new Set(gd),Cd=new Set(_d),wd=new Set(vd),Td=new Set(yd);bd(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...hd,...gd,..._d,...vd,...yd])],dd);var Ed=new Set([`base`,`canvas`]),Dd=new Set([`mmd`,`mermaid`]);function Od(e){let t=e.lastIndexOf(`.`);return t<0?!1:Dd.has(e.slice(t+1).toLowerCase())}new Set([...ud,...Ed,...Dd]);function kd(e){let t=e.toLowerCase().replace(/^\./,``);return xd.has(t)?`image`:Sd.has(t)?`video`:Cd.has(t)?`audio`:wd.has(t)?`pdf`:Td.has(t)||Ed.has(t)?`text`:Dd.has(t)?`mermaid`:Yu.has(t)?`text`:null}var Ad=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`ar`,`fr`,`bn`,`pt-BR`,`id`,`ur`],jd=[`en`,`es`,`zh-Hans`],Md=new Set([`ar`,`ur`]),Nd=Ad.filter(e=>!Md.has(e)),Pd=[`off`,`warning`,`error`],Fd=`warning`,Id=[`error`,`warning`],Ld=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],Rd={base00:`default background`,base01:`alt background — cards, popovers, sidebar`,base02:`selection background, borders`,base03:`comments, invisibles`,base04:`secondary text`,base05:`default foreground`,base06:`light foreground`,base07:`lightest foreground`,base08:`red — variables, tags, diff deleted`,base09:`orange — numbers, constants`,base0A:`yellow — classes, search highlight`,base0B:`green — strings, diff inserted`,base0C:`cyan — support, escapes, quotes`,base0D:`blue — functions, headings, accent`,base0E:`magenta — keywords, storage`,base0F:`deprecated markers, embedded tags`},zd=/^#[0-9a-fA-F]{6}$/;function Bd(e){return typeof e==`string`&&zd.test(e)}function Vd(e){let t=e.palette;return{background:t.base00,foreground:t.base05,card:t.base01,"card-foreground":t.base05,popover:t.base01,"popover-foreground":t.base05,primary:t.base0D,"primary-foreground":t.base00,secondary:t.base01,"secondary-foreground":t.base05,muted:t.base01,"muted-foreground":t.base04,accent:t.base02,"accent-foreground":t.base05,destructive:t.base08,border:t.base02,input:t.base02,ring:t.base0D,"selection-soft":t.base02,"chart-1":t.base0D,"chart-2":t.base0B,"chart-3":t.base0A,"chart-4":t.base0E,"chart-5":t.base08,sidebar:t.base01,"sidebar-foreground":t.base05,"sidebar-primary":t.base0D,"sidebar-primary-foreground":t.base00,"sidebar-accent":t.base02,"sidebar-accent-foreground":t.base0D,"sidebar-hover":t.base02,"sidebar-border":t.base02,"sidebar-ring":t.base0D,"syntax-keyword":t.base0E,"syntax-tag":t.base08,"syntax-attr":t.base0D,"syntax-string":t.base0B,"syntax-number":t.base09,"syntax-atom":t.base0C,"syntax-comment":t.base03,"syntax-func":t.base0D,"syntax-var":t.base08,"syntax-type":t.base0A,"syntax-operator":t.base05,"syntax-meta":t.base0F,"syntax-bg":t.base01,"link-color":t.base0D,"broken-link-color":t.base08,"lint-warning-color":t.base0A,"lint-error-color":t.base08,"diff-added":t.base0B,"diff-removed":t.base08,"callout-note-color":t.base0D,"callout-info-color":t.base0D,"callout-todo-color":t.base0D,"callout-abstract-color":t.base0C,"callout-tip-color":t.base0B,"callout-success-color":t.base0B,"callout-important-color":t.base0E,"callout-example-color":t.base0E,"callout-question-color":t.base0E,"callout-warning-color":t.base0A,"callout-caution-color":t.base09,"callout-danger-color":t.base09,"callout-failure-color":t.base08,"callout-bug-color":t.base08,"callout-quote-color":t.base03,...Wd(t)}}var Hd={black:`base00`,red:`base08`,green:`base0B`,yellow:`base0A`,blue:`base0D`,magenta:`base0E`,cyan:`base0C`,white:`base05`,brightBlack:`base03`,brightRed:`base08`,brightGreen:`base0B`,brightYellow:`base0A`,brightBlue:`base0D`,brightMagenta:`base0E`,brightCyan:`base0C`,brightWhite:`base07`},Ud=Object.keys(Hd);function Wd(e){let t={};for(let n of Ud)t[`ansi-${Gd(n)}`]=e[Hd[n]];return t}function Gd(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function Kd(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function qd(e){return`${[`system: "base16"`,`name: ${Kd(e.name)}`,...e.author?[`author: ${Kd(e.author)}`]:[],`variant: ${Kd(e.variant)}`,`palette:`,...Ld.map(t=>` ${t}: ${Kd(e.palette[t])}`)].join(`
171
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Eu(Tu(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Eu(Tu(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Au(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new xu||null,prettyErrors:t}}function ju(e,t={}){let{lineCounter:n,prettyErrors:r}=Au(t),i=new ku(n?.addNewLine),a=new su(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Cl(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Tl(e,n)),o.warnings.forEach(Tl(e,n))),o}function Mu(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=ju(e,n);if(!i)return null;if(i.warnings.forEach(e=>ac(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var Nu=[`off`,`follow`,`full`],Pu=[`follow`,`full`],Fu=`pull`,Iu=[`off`,`follow`,`full`,Fu],Lu=[`follow`,`full`,Fu];function Ru(e){return e===Fu?`follow`:zu(e)?e:null}function zu(e){return typeof e==`string`&&Nu.includes(e)}function Bu(e){return typeof e==`string`&&Pu.includes(e)}function Vu(e){let t=e?.resumeMode;return t===Fu?`follow`:Bu(t)?t:null}function Hu(e){return qu(e)===`off`&&Vu(e)!==null}function Uu(e){let t=qu(e);return t===`follow`||t===`full`||Hu(e)}function Wu(e){let t=qu(e);return Bu(t)?t:Vu(e)??`full`}function Gu(e){return e===!0?`full`:e===!1?`off`:null}function Ku(e){return e===!0?`full`:e===!1?`off`:Ru(e)}function qu(e){let t=Ru(e?.mode);return t===null?Gu(e?.enabled):t}var Ju={sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,feature:`gherkin`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`},Yu=new Set(Object.keys(Ju));function Xu(e){return Ju[e.toLowerCase().replace(/^\./,``)]??null}var Zu=new Set([`md`,`mdx`,`mmd`,`mermaid`]),Qu=new Set([...Yu,`txt`,`text`,`csv`,`tsv`,`log`,`toml`,`html`,`htm`,`svg`,`vue`,`svelte`,`astro`,`lock`].filter(e=>!Zu.has(e))),$u={html:`html`,htm:`html`,svg:`xml`,vue:`html`,svelte:`html`,astro:`html`,lock:`yaml`};function ed(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:Qu.has(t.slice(n+1).toLowerCase())}var td=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],nd=[`video/mp4`,`video/webm`,`video/ogg`],rd=[`audio/mpeg`,`audio/wav`,`audio/ogg`],id=[`application/pdf`],ad=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),od=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),sd=new Set([`pdf`]),cd=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),ld=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),ud=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),dd=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),fd=`wikiembed`,pd=`toast`,md=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),hd=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],gd=[`mp4`,`webm`,`mov`,`m4v`],_d=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],vd=[`pdf`],yd=[`json`,`toml`,`lock`];function bd(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}bd(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,hd,ad),bd(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,gd,od),bd(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,_d,cd),bd(`SIDEBAR_PDF_ASSET_EXTENSIONS`,vd,sd),bd(`FILE_ATTACHMENT_EXTENSIONS`,[...ld],md),bd(`WIKI_EMBED_EXTENSIONS`,[...md],ud);var xd=new Set(hd),Sd=new Set(gd),Cd=new Set(_d),wd=new Set(vd),Td=new Set(yd);bd(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...hd,...gd,..._d,...vd,...yd])],dd);var Ed=new Set([`base`,`canvas`]),Dd=new Set([`mmd`,`mermaid`]);function Od(e){let t=e.lastIndexOf(`.`);return t<0?!1:Dd.has(e.slice(t+1).toLowerCase())}new Set([...ud,...Ed,...Dd]);function kd(e){let t=e.toLowerCase().replace(/^\./,``);return xd.has(t)?`image`:Sd.has(t)?`video`:Cd.has(t)?`audio`:wd.has(t)?`pdf`:Td.has(t)||Ed.has(t)?`text`:Dd.has(t)?`mermaid`:Yu.has(t)?`text`:null}var Ad=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`ar`,`fr`,`bn`,`pt-BR`,`id`,`ur`],jd=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`fr`,`bn`,`pt-BR`,`id`],Md=new Set([`ar`,`ur`]),Nd=Ad.filter(e=>!Md.has(e)),Pd=[`off`,`warning`,`error`],Fd=`warning`,Id=[`error`,`warning`],Ld=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],Rd={base00:`default background`,base01:`alt background — cards, popovers, sidebar`,base02:`selection background, borders`,base03:`comments, invisibles`,base04:`secondary text`,base05:`default foreground`,base06:`light foreground`,base07:`lightest foreground`,base08:`red — variables, tags, diff deleted`,base09:`orange — numbers, constants`,base0A:`yellow — classes, search highlight`,base0B:`green — strings, diff inserted`,base0C:`cyan — support, escapes, quotes`,base0D:`blue — functions, headings, accent`,base0E:`magenta — keywords, storage`,base0F:`deprecated markers, embedded tags`},zd=/^#[0-9a-fA-F]{6}$/;function Bd(e){return typeof e==`string`&&zd.test(e)}function Vd(e){let t=e.palette;return{background:t.base00,foreground:t.base05,card:t.base01,"card-foreground":t.base05,popover:t.base01,"popover-foreground":t.base05,primary:t.base0D,"primary-foreground":t.base00,secondary:t.base01,"secondary-foreground":t.base05,muted:t.base01,"muted-foreground":t.base04,accent:t.base02,"accent-foreground":t.base05,destructive:t.base08,border:t.base02,input:t.base02,ring:t.base0D,"selection-soft":t.base02,"chart-1":t.base0D,"chart-2":t.base0B,"chart-3":t.base0A,"chart-4":t.base0E,"chart-5":t.base08,sidebar:t.base01,"sidebar-foreground":t.base05,"sidebar-primary":t.base0D,"sidebar-primary-foreground":t.base00,"sidebar-accent":t.base02,"sidebar-accent-foreground":t.base0D,"sidebar-hover":t.base02,"sidebar-border":t.base02,"sidebar-ring":t.base0D,"syntax-keyword":t.base0E,"syntax-tag":t.base08,"syntax-attr":t.base0D,"syntax-string":t.base0B,"syntax-number":t.base09,"syntax-atom":t.base0C,"syntax-comment":t.base03,"syntax-func":t.base0D,"syntax-var":t.base08,"syntax-type":t.base0A,"syntax-operator":t.base05,"syntax-meta":t.base0F,"syntax-bg":t.base01,"link-color":t.base0D,"broken-link-color":t.base08,"lint-warning-color":t.base0A,"lint-error-color":t.base08,"diff-added":t.base0B,"diff-removed":t.base08,"callout-note-color":t.base0D,"callout-info-color":t.base0D,"callout-todo-color":t.base0D,"callout-abstract-color":t.base0C,"callout-tip-color":t.base0B,"callout-success-color":t.base0B,"callout-important-color":t.base0E,"callout-example-color":t.base0E,"callout-question-color":t.base0E,"callout-warning-color":t.base0A,"callout-caution-color":t.base09,"callout-danger-color":t.base09,"callout-failure-color":t.base08,"callout-bug-color":t.base08,"callout-quote-color":t.base03,...Wd(t)}}var Hd={black:`base00`,red:`base08`,green:`base0B`,yellow:`base0A`,blue:`base0D`,magenta:`base0E`,cyan:`base0C`,white:`base05`,brightBlack:`base03`,brightRed:`base08`,brightGreen:`base0B`,brightYellow:`base0A`,brightBlue:`base0D`,brightMagenta:`base0E`,brightCyan:`base0C`,brightWhite:`base07`},Ud=Object.keys(Hd);function Wd(e){let t={};for(let n of Ud)t[`ansi-${Gd(n)}`]=e[Hd[n]];return t}function Gd(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function Kd(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function qd(e){return`${[`system: "base16"`,`name: ${Kd(e.name)}`,...e.author?[`author: ${Kd(e.author)}`]:[],`variant: ${Kd(e.variant)}`,`palette:`,...Ld.map(t=>` ${t}: ${Kd(e.palette[t])}`)].join(`
172
172
  `)}\n`}function Jd(e){let t;try{t=Mu(e,{schema:`failsafe`})}catch(e){let t=e?.linePos;return{ok:!1,error:{kind:`unparseable`,line:typeof t?.[0]?.line==`number`?t[0].line:void 0}}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,error:{kind:`not-a-scheme`}};let n=t,r=n.palette,i=r&&typeof r==`object`&&!Array.isArray(r)?r:n,a={},o=[],s=[];for(let e of Ld){let t=i[e]??i[e.toLowerCase()];if(t==null){o.push(e);continue}let n=Yd(t);if(!n){s.push(e);continue}a[e]=n}return o.length?{ok:!1,error:{kind:`missing-slots`,slots:o}}:s.length?{ok:!1,error:{kind:`bad-hex`,slots:s}}:{ok:!0,scheme:{name:typeof n.name==`string`&&n.name.trim()?n.name.trim():`Imported`,author:typeof n.author==`string`&&n.author.trim()?n.author.trim():void 0,variant:n.variant===`light`||n.variant===`dark`?n.variant:Qd(a),palette:a}}}function Yd(e){if(typeof e!=`string`)return null;let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),/^#[0-9a-fA-F]{3}$/.test(t)&&(t=`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`),zd.test(t)?t.toLowerCase():null}function Xd(e,t,n){let r=Bd(e)?e:`#000000`,i=Bd(t)?t:`#000000`,a=Math.min(1,Math.max(0,n)),o=`#`;for(let e=0;e<3;e++){let t=Number.parseInt(r.slice(1+e*2,3+e*2),16),n=Number.parseInt(i.slice(1+e*2,3+e*2),16);o+=Math.round(t+(n-t)*a).toString(16).padStart(2,`0`)}return o}function Zd(e){let t=Bd(e)?e:`#000000`,n=e=>{let n=Number.parseInt(t.slice(1+e*2,3+e*2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(1)+.0722*n(2)}function Qd(e){return Zd(e.base00)<Zd(e.base05)?`dark`:`light`}var $d={name:`Dracula`,author:`clach04 (https://github.com/clach04)`,variant:`dark`,palette:{base00:`#282a36`,base01:`#21222c`,base02:`#44475a`,base03:`#6272a4`,base04:`#9ea8c7`,base05:`#f8f8f2`,base06:`#f8f8f2`,base07:`#ffffff`,base08:`#ff5555`,base09:`#ffb86c`,base0A:`#f1fa8c`,base0B:`#50fa7b`,base0C:`#8be9fd`,base0D:`#bd93f9`,base0E:`#ff79c6`,base0F:`#993333`}},ef={name:`Catppuccin Frappé`,author:`https://github.com/catppuccin/catppuccin`,variant:`dark`,palette:{base00:`#303446`,base01:`#292c3c`,base02:`#414559`,base03:`#51576d`,base04:`#626880`,base05:`#c6d0f5`,base06:`#f2d5cf`,base07:`#babbf1`,base08:`#e78284`,base09:`#ef9f76`,base0A:`#e5c890`,base0B:`#a6d189`,base0C:`#81c8be`,base0D:`#8caaee`,base0E:`#ca9ee6`,base0F:`#eebebe`}},tf={name:`Catppuccin Latte`,author:`https://github.com/catppuccin/catppuccin`,variant:`light`,palette:{base00:`#eff1f5`,base01:`#e6e9ef`,base02:`#ccd0da`,base03:`#bcc0cc`,base04:`#acb0be`,base05:`#4c4f69`,base06:`#dc8a78`,base07:`#7287fd`,base08:`#d20f39`,base09:`#fe640b`,base0A:`#df8e1d`,base0B:`#40a02b`,base0C:`#179299`,base0D:`#1e66f5`,base0E:`#8839ef`,base0F:`#dd7878`}},nf={name:`Monokai`,author:`Wimer Hazenberg (http://www.monokai.nl)`,variant:`dark`,palette:{base00:`#272822`,base01:`#383830`,base02:`#49483e`,base03:`#75715e`,base04:`#a59f85`,base05:`#f8f8f2`,base06:`#f5f4f1`,base07:`#f9f8f5`,base08:`#f92672`,base09:`#fd971f`,base0A:`#f4bf75`,base0B:`#a6e22e`,base0C:`#a1efe4`,base0D:`#66d9ef`,base0E:`#ae81ff`,base0F:`#cc6633`}},rf={name:`Gruvbox dark, medium`,author:`Dawid Kurek, morhetz (https://github.com/morhetz/gruvbox)`,variant:`dark`,palette:{base00:`#282828`,base01:`#3c3836`,base02:`#504945`,base03:`#665c54`,base04:`#bdae93`,base05:`#d5c4a1`,base06:`#ebdbb2`,base07:`#fbf1c7`,base08:`#fb4934`,base09:`#fe8019`,base0A:`#fabd2f`,base0B:`#b8bb26`,base0C:`#8ec07c`,base0D:`#83a598`,base0E:`#d3869b`,base0F:`#d65d0e`}},af={name:`Solarized Dark`,author:`Ethan Schoonover (modified by aramisgithub)`,variant:`dark`,palette:{base00:`#002b36`,base01:`#073642`,base02:`#586e75`,base03:`#657b83`,base04:`#839496`,base05:`#93a1a1`,base06:`#eee8d5`,base07:`#fdf6e3`,base08:`#dc322f`,base09:`#cb4b16`,base0A:`#b58900`,base0B:`#859900`,base0C:`#2aa198`,base0D:`#268bd2`,base0E:`#6c71c4`,base0F:`#d33682`}};function of(e,t,n){return{id:e,label:t,kind:n.variant,scheme:n,toTokens:()=>Vd(n)}}function sf(e,t){return{id:e,label:t,kind:`system`}}var cf=[sf(`default`,`Default`),of(`dracula`,`Dracula`,$d),of(`catppuccin-frappe`,`Catppuccin Frappé`,ef),of(`catppuccin-latte`,`Catppuccin Latte`,tf),of(`monokai`,`Monokai`,nf),of(`gruvbox`,`Gruvbox`,rf),of(`solarized`,`Solarized`,af),sf(`custom`,`Custom`)],lf=cf.map(e=>e.id),uf=new Map(cf.map(e=>[e.id,e]));function df(e){return e&&uf.get(e)||cf[0]}function ff(e){let t=df(e).kind;return t===`system`?void 0:t}function pf(e){return typeof e==`string`&&uf.has(e)}function mf(e){let t=e?.colorTheme,n=pf(t)?t:cf[0].id,r=e=>pf(e)?e:n;return{light:r(e?.colorThemeLight),dark:r(e?.colorThemeDark)}}function hf(e,t){return e===`light`||e===`dark`?e:t?`dark`:`light`}function gf(e,t,n){return`${e} {\n color-scheme: ${t};\n${Object.entries(n).map(([e,t])=>` --${e}: ${t};`).join(`
173
173
  `)}\n}`}var _f=Symbol.for(`@inkeep/open-knowledge/field-registry`),vf=globalThis;vf[_f]===void 0&&(vf[_f]=Rr());var H=vf[_f];function yf(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=bf(t)?H.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function bf(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}function xf(){return Object.fromEntries(Ld.map(e=>[e,N().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${Rd[e]}, as a #rrggbb hex string.`}).optional()]))}function Sf(){return lf.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var Cf=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),wf=52428800,Tf=26214400,Ef=12582912,Df=`https://api.openai.com/v1`,Of=`text-embedding-3-small`;function kf(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function Af(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&kf(e)?null:`insecure-scheme`}function jf(e){let t=e.trim();return t===``?`./`:t}function Mf(e){let t=jf(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}var Nf=R({content:R({dir:N().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore.`}).default(`.`),attachmentFolderPath:N().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(Mf,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:R({theme:z([`light`,`dark`,`system`]).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:z([`system`,...Ad]).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:z(lf).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), or one of ${Sf()}. A personal preference (user scope) — not shared with the project.`}).optional(),colorThemeDark:z(lf).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), or one of ${Sf()}. A personal preference (user scope) — not shared with the project.`}).optional(),colorTheme:z(lf).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A personal preference (user scope) — not shared with the project.`}).optional(),colorThemeEnabled:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:R({name:N().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:N().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:z([`dark`,`light`]).register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...xf()}).optional(),preview:R({autoOpen:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:R({showHiddenFiles:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:R({wordWrap:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:R({autoApproveOkTools:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:R({mode:z(Iu).register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`How this machine syncs this project with its git remote: 'off' (no sync), 'follow' (one-directional — pull remote changes, never push your own; 'pull' is accepted as a legacy alias), or 'full' (bidirectional pull and push). null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:z(Lu).register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),default:mo([F(),z(Iu)]).register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),terminal:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),slides:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:R({localSink:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(wf)}).default({maxBytes:wf}),logs:R({maxBytes:P().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Tf)}).default({maxBytes:Tf}),attributeDenylist:I(N()).register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...Cf])}).default({enabled:!0,spans:{maxBytes:wf},logs:{maxBytes:Tf},attributeDenylist:[...Cf]}),skillInstallReports:R({enabled:F().register(H,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:wf},logs:{maxBytes:Tf},attributeDenylist:[...Cf]},skillInstallReports:{enabled:!0}}),lossCapture:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:P().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(Ef)}).default({enabled:!0,maxBytes:Ef}),bridge:R({backgroundThrottle:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:R({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:R({semantic:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:N().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (`~/.ok/secrets.yml`); it is sent to whichever endpoint this names."}).default(Df),model:N().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(Of),dimensions:P().int().positive().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:P().min(0).max(1).register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Df,model:Of})}).default({semantic:{enabled:!1,baseUrl:Df,model:Of}}),contentRules:R({markdownlint:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:L({enabled:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:I(L({appliesTo:mo([N(),I(N())]).optional(),file:N(),enabled:F().optional()})).register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]}}),validation:R({links:z(Pd).register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(Fd),fileTreeIndicators:F().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0)}).default({links:Fd,fileTreeIndicators:!0}),linkPreviews:R({enabled:F().register(H,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),remote:R({url:N().register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Public URL your tunnel gives you, e.g. https://myproject.ngrok.app. Used only with `ok start --remote` (config alone never enables remote access); its host is admitted through the Host-header allowlist. There is no server-side auth, so restrict access at the tunnel (ngrok OAuth, Cloudflare Access, Tailscale ACLs)."}).optional(),port:P().int().min(1).max(65535).register(H,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`TCP port the server binds when remote access is enabled (default 24550). Fixed so the tunnel's port mapping survives restarts. Set it only on a conflict. An explicit --port still wins; the PORT env var is ignored in remote mode.`}).default(24550)}).default({port:24550})}),Pf=`open-knowledge-config`;function Ff(e,t,n){let r=c.getTracer(Pf),i=t?{attributes:t}:{};return r.startActiveSpan(e,i,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:s.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function If(e,t){let n=c.getActiveSpan();n&&n.addEvent(e,t)}function Lf(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Rf(e,t){let n=e;for(let e of t){n=Lf(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function zf(e,t){let n=Rf(e,t);if(n!==void 0)return yf(n)}function Bf(e,t){return e===`either`?!0:e===t}function Vf(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=zf(Nf,i);a?.scope!==void 0&&(Bf(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Hf(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&(fs(e.getIn(r,!0))||e.deleteIn(r))}}function Uf(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Hf(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Hf(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function Wf(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var Gf=L({file:N(),line:P().int().min(1),column:P().int().min(1),snippet:N().optional()}),Kf=L({path:I(mo([N(),P()])),message:N(),issueCode:N(),params:bo(N(),so()).optional(),source:Gf.optional()}),qf=z([`user`,`project`,`project-local`,`either`]),Jf=z([`user`,`project`,`project-local`]),Yf=L({code:B(`YAML_PARSE`),detail:N()}),Xf=L({code:B(`UNREADABLE`),detail:N()}),Zf=L({code:B(`SCHEMA_INVALID`),issues:I(Kf)}),Qf=L({code:B(`REMOVED_KEY`),path:I(N()),redirect:N(),source:Gf.optional()}),$f=go(`code`,[Yf,Zf,Xf,L({code:B(`SCOPE_VIOLATION`),path:I(N()),expectedScope:qf,actualScope:Jf}),L({code:B(`NOT_AGENT_SETTABLE`),path:I(N())}),L({code:B(`MIXED_SCOPE`),paths:I(L({path:I(N()),scope:Jf}))}),Qf,L({code:B(`WRITE_ERROR`),detail:N()}),L({code:B(`OKIGNORE_INVALID`),detail:N(),lineNumber:P().int().min(1).optional()}),L({code:B(`UNKNOWN`),message:N().optional()})]);go(`code`,[Qf,Yf,Zf,Xf]),L({diagnostics:I(go(`code`,[L({code:B(`REMOVED_KEY`),scope:Jf,file:N(),path:I(N()),redirect:N()}),L({code:B(`YAML_PARSE`),scope:Jf,file:N()}),L({code:B(`SCHEMA_INVALID`),scope:Jf,file:N()}),L({code:B(`UNREADABLE`),scope:Jf,file:N()})]))});var ep=new Set($f.options.map(e=>e.shape.code.value)),tp=mo([$f,R({code:N(),message:N().optional()})]);function np(e){return ep.has(e.code)}function rp(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function ip(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function ap(e){if(!np(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`UNREADABLE`:return`Could not read the file: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
174
174
  `))n.push(` ${e}`)}else n.push(` ${r}: ${t.message}`)}}return n.join(`
@@ -1 +1 @@
1
- import{Aa as e}from"./dist-PVtTd_Sj2.js";function t(t){return e.includes(t)}function n(e){if(e.startsWith(h)||e.startsWith(y)||e.startsWith(b)||e.startsWith(C)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=g(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function r(e){if(e.startsWith(h)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}function i(e,t){let n=`#/${e}`;return t?`${n}#${encodeURIComponent(t)}`:n}var a=`__okHashHistoryEntry`;function o(e){return{...typeof e==`object`&&e?e:{},[a]:!0}}function s(e){return typeof e==`object`&&!!e&&e[a]===!0}function c(){s(window.history.state)||window.history.replaceState(o(window.history.state),``)}function l(e){let{pathname:t,search:n}=window.location;window.history.replaceState(o(window.history.state),``,`${t}${n}${e}`)}function u(e){if(window.location.hash===e)return;let{pathname:t,search:n}=window.location;window.history.pushState(o(window.history.state),``,`${t}${n}${e}`)}function d(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function f(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${n}/`:`#/`;return t?`${r}#${encodeURIComponent(t)}`:r}function p(e,t,n){if(e===`folder`)return f(t);let r=`#/${encodeURIComponent(t)}`;return n==null||n===``?r:`${r}?branch=${encodeURIComponent(n)}`}function m(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var h=`#/__asset__/`;function g(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function _(e){if(!e.startsWith(h))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function v(e){return`${h}${e.split(`/`).map(encodeURIComponent).join(`/`)}`}var y=`#/__skill-file__/`,b=`#/__skills__`;function x(){return b}function S(e){return e===b||e.startsWith(`${b}/`)}var C=`#/__skill-preview__/`,w=[`explore`,`detected`,`builtin`,`foreign`];function T(e){return e!==void 0&&w.includes(e)}var E=`project`;function D(e){return[e.flavor,e.source,e.name,e.subtitle,e.level??E].map(encodeURIComponent).join(`/`)}function O(e){if(!e)return null;let n;try{n=e.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<4||n.length>6)return null;let[r,i,a,o,s,c]=n;return!T(r)||!i||!a?null:{flavor:r,source:i,name:a,subtitle:o??``,...s&&t(s)?{level:s}:{},...c?{path:c}:{}}}function k(e){let t=D(e);return e.path&&(t+=`/${encodeURIComponent(e.path)}`),`${C}${t}`}function A(e){return e.startsWith(C)?O(e.slice(20)):null}var j=`:`;function M(e){let t=e.host===void 0?e.name:`${e.name}${j}${e.host}`;return`${y}${[e.scope,t].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function N(e){if(!e.startsWith(y))return null;let n=e.slice(17);if(!n)return null;let r;try{r=n.split(`/`).map(decodeURIComponent)}catch{return null}if(r.length<3)return null;let[i,a,...o]=r,s=o.join(`/`);if(!i||!a||!s||!t(i))return null;let c=a.indexOf(j),l=c===-1?a:a.slice(0,c),u=c===-1?void 0:a.slice(c+1);return l?{scope:i,name:l,path:s,...u?{host:u}:{}}:null}var P=/\.(md|mdx)$/i;function F(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function I(e){return F(e).replace(P,``)}function L(e){let t=F(e);return t?P.test(t)?t:`${t}.md`:`untitled.md`}function R(e){let t=I(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}export{S as C,A as S,m as _,_ as a,l as b,p as c,v as d,i as f,x as g,k as h,r as i,D as l,M as m,L as n,O as o,f as p,I as r,n as s,R as t,d as u,c as v,N as x,u as y};
1
+ import{Aa as e}from"./dist-CQI6-1xM2.js";function t(t){return e.includes(t)}function n(e){if(e.startsWith(h)||e.startsWith(y)||e.startsWith(b)||e.startsWith(C)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=g(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function r(e){if(e.startsWith(h)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}function i(e,t){let n=`#/${e}`;return t?`${n}#${encodeURIComponent(t)}`:n}var a=`__okHashHistoryEntry`;function o(e){return{...typeof e==`object`&&e?e:{},[a]:!0}}function s(e){return typeof e==`object`&&!!e&&e[a]===!0}function c(){s(window.history.state)||window.history.replaceState(o(window.history.state),``)}function l(e){let{pathname:t,search:n}=window.location;window.history.replaceState(o(window.history.state),``,`${t}${n}${e}`)}function u(e){if(window.location.hash===e)return;let{pathname:t,search:n}=window.location;window.history.pushState(o(window.history.state),``,`${t}${n}${e}`)}function d(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function f(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${n}/`:`#/`;return t?`${r}#${encodeURIComponent(t)}`:r}function p(e,t,n){if(e===`folder`)return f(t);let r=`#/${encodeURIComponent(t)}`;return n==null||n===``?r:`${r}?branch=${encodeURIComponent(n)}`}function m(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var h=`#/__asset__/`;function g(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function _(e){if(!e.startsWith(h))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function v(e){return`${h}${e.split(`/`).map(encodeURIComponent).join(`/`)}`}var y=`#/__skill-file__/`,b=`#/__skills__`;function x(){return b}function S(e){return e===b||e.startsWith(`${b}/`)}var C=`#/__skill-preview__/`,w=[`explore`,`detected`,`builtin`,`foreign`];function T(e){return e!==void 0&&w.includes(e)}var E=`project`;function D(e){return[e.flavor,e.source,e.name,e.subtitle,e.level??E].map(encodeURIComponent).join(`/`)}function O(e){if(!e)return null;let n;try{n=e.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<4||n.length>6)return null;let[r,i,a,o,s,c]=n;return!T(r)||!i||!a?null:{flavor:r,source:i,name:a,subtitle:o??``,...s&&t(s)?{level:s}:{},...c?{path:c}:{}}}function k(e){let t=D(e);return e.path&&(t+=`/${encodeURIComponent(e.path)}`),`${C}${t}`}function A(e){return e.startsWith(C)?O(e.slice(20)):null}var j=`:`;function M(e){let t=e.host===void 0?e.name:`${e.name}${j}${e.host}`;return`${y}${[e.scope,t].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function N(e){if(!e.startsWith(y))return null;let n=e.slice(17);if(!n)return null;let r;try{r=n.split(`/`).map(decodeURIComponent)}catch{return null}if(r.length<3)return null;let[i,a,...o]=r,s=o.join(`/`);if(!i||!a||!s||!t(i))return null;let c=a.indexOf(j),l=c===-1?a:a.slice(0,c),u=c===-1?void 0:a.slice(c+1);return l?{scope:i,name:l,path:s,...u?{host:u}:{}}:null}var P=/\.(md|mdx)$/i;function F(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function I(e){return F(e).replace(P,``)}function L(e){let t=F(e);return t?P.test(t)?t:`${t}.md`:`untitled.md`}function R(e){let t=I(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}export{S as C,A as S,m as _,_ as a,l as b,p as c,v as d,i as f,x as g,k as h,r as i,D as l,M as m,L as n,O as o,f as p,I as r,n as s,R as t,d as u,c as v,N as x,u as y};
@@ -1 +1 @@
1
- import{k as e}from"./dist-PVtTd_Sj2.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var o=`open-knowledge:doc-persisted`;function s(e){window.dispatchEvent(new CustomEvent(o,{detail:{docName:e}}))}function c(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail?.docName;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)}var l=`open-knowledge:branch-changed`;function u(e){window.dispatchEvent(new CustomEvent(l,{detail:{branch:e}}))}function d(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(l,t),()=>window.removeEventListener(l,t)}var f=`open-knowledge:templates-changed`;function p(){window.dispatchEvent(new CustomEvent(f))}function m(e){let t=()=>e();return window.addEventListener(f,t),()=>window.removeEventListener(f,t)}var h=`open-knowledge:skills-changed`;function g(){window.dispatchEvent(new CustomEvent(h))}function _(e){let t=()=>e();return window.addEventListener(h,t),()=>window.removeEventListener(h,t)}var v=new Set,y=(e,t)=>`${e}\u0000${t}`;function b(e,t){v.add(y(e,t)),g()}function x(e,t){v.delete(y(e,t))&&g()}function S(e){return v.size===0?e:e.filter(e=>!v.has(y(e.scope,e.name)))}export{i as a,x as c,a as d,_ as f,s as i,d as l,b as n,g as o,m as p,u as r,p as s,S as t,c as u};
1
+ import{k as e}from"./dist-CQI6-1xM2.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var o=`open-knowledge:doc-persisted`;function s(e){window.dispatchEvent(new CustomEvent(o,{detail:{docName:e}}))}function c(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail?.docName;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)}var l=`open-knowledge:branch-changed`;function u(e){window.dispatchEvent(new CustomEvent(l,{detail:{branch:e}}))}function d(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(l,t),()=>window.removeEventListener(l,t)}var f=`open-knowledge:templates-changed`;function p(){window.dispatchEvent(new CustomEvent(f))}function m(e){let t=()=>e();return window.addEventListener(f,t),()=>window.removeEventListener(f,t)}var h=`open-knowledge:skills-changed`;function g(){window.dispatchEvent(new CustomEvent(h))}function _(e){let t=()=>e();return window.addEventListener(h,t),()=>window.removeEventListener(h,t)}var v=new Set,y=(e,t)=>`${e}\u0000${t}`;function b(e,t){v.add(y(e,t)),g()}function x(e,t){v.delete(y(e,t))&&g()}function S(e){return v.size===0?e:e.filter(e=>!v.has(y(e.scope,e.name)))}export{i as a,x as c,a as d,_ as f,s as i,d as l,b as n,g as o,m as p,u as r,p as s,S as t,c as u};
@@ -1 +1 @@
1
- import{Fo as e,No as t,zo as n}from"./dist-PVtTd_Sj2.js";import{d as r,f as i,p as a}from"./doc-paths-CH8QyanF.js";import{t as o}from"./file-tree-rename-validation-CEz8MVWM.js";import{c as s,l as c,s as l}from"./file-tree-utils-CvsKsHRh.js";import{a as u}from"./navigation-targets-DKe7BSku.js";var d=`application/x-open-knowledge-sidebar-item+json`,f={image:!0,video:!0,audio:!0,pdf:!0,text:!0,mermaid:!0};function p(e){return JSON.stringify(e)}function m(e){return e?Array.from(e.types).includes(d):!1}function ee(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:a(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:r(e.assetPath)}:{target:u(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:i(e.docName)}}function h(e){if(!e||!m(e))return null;let t=e.getData(d);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!g(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!_(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _(e){return typeof e==`string`&&Object.hasOwn(f,e)}var v=`.md`,y=/\.(md|mdx)$/i;function b(n,r=v){return y.test(n)||e(n)||t(n)?n:`${n}${r}`}function x(e){return $(e).replace(y,``)}function S(e,t){let n=$(e),r=k(t),i=t.find(e=>s(e)&&A(e,r)===n)??t.find(e=>s(e)&&w(e)===n);if(i)return i.docName;let a=x(n);return t.find(e=>{let t=w(e);return t!==n&&y.test(t)&&x(t)===a})&&y.test(n)?n:a}function C(e,t){let n=k(t);return t.find(t=>A(t,n)===e)??t.find(t=>w(t)===e)}function w(e){return c(e)?D(e.path):l(e)?e.path:b(e.docName,e.docExt)}function T(e){let t=$(e).match(y);return t?`.${t[1].toLowerCase()}`:void 0}function E(e){return $(e)}function D(e){let t=$(e.trim());return t?`${t}/`:``}function O(e){return e.endsWith(`/`)?E(e):x(e)}function k(e){let t=new Map;for(let n of e){if(!s(n))continue;let e=n.docName.match(y);if(!e)continue;let r=n.docName.slice(0,-e[0].length),i=t.get(r);i?i.add(e[0]):t.set(r,new Set([e[0]]))}return t}function A(e,t){let n=w(e);if(!s(e))return n;let r=e.docName.match(y);if(!r)return n;let i=e.docName.slice(0,-r[0].length);return(t.get(i)?.size??0)>1?n:`${e.docName}${e.docExt??v}`}function j(e){let t=k(e),n=new Set,r=[];for(let i of e){let e=A(i,t);n.has(e)||(n.add(e),r.push(e))}return r}function M(e){return[...e].sort().join(`\0`)}function N(e){return M(j(e))}function P(e,t={}){let n=new Set;for(let r of e){let e=(c(r)||l(r)?r.path:r.docName).split(`/`).filter(Boolean);if(!t.includeOkFolders&&e.includes(`.ok`))continue;if(c(r)){let e=D(r.path);e&&n.add(e)}let i=c(r)?e.length:e.length-1;for(let t=1;t<=i;t++)n.add(`${e.slice(0,t).join(`/`)}/`)}return[...n].sort()}function F(e){if(!e)return[];let t=$(e.replace(y,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function I(e,t,n){let r=T(e);if(r)return r;let i=n.find(e=>s(e)&&e.docName===t);return i?i.docExt??v:Q(e).includes(`.`)?void 0:v}function L(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!l(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function R(e,t,n){if(T(e))return null;let r=n.find(e=>l(e)&&e.path===t);return r?r.path:Q(e).includes(`.`)?t:L(t,n)}function z(e,t){let n=e.kind===`directory`,r=n?E(e.path):S(e.path,t);if(n)return{kind:`folder`,name:$(Q(e.path)).replace(y,``),path:r,treePath:V(e.path,!0)};let i=R(e.path,r,t);if(i)return{kind:`asset`,name:$(Q(i)),path:i,treePath:i};let a=I(e.path,r,t);return{kind:`file`,name:$(Q(e.path)).replace(y,``),path:r,treePath:V(e.path,!1),docExt:a}}function B(e){return e.kind===`directory`?E(e.path):e.path}function V(e,t){return t?D(e):y.test(e)?e:`${e}${v}`}function H(e,t,n){let r=D(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${v}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function U(e,t){return e===`file`?V(t,!1):`${E(t)}/index${v}`}function W(e,t){return t.kind===`root`||t.directoryPath==null?Q(e):`${t.directoryPath}${Q(e)}`}function G(e,t){if(t)return E(D(e));let n=x(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function K(e,t){let n=E(D(e));return n?`${n}/${t}`:t}function q(e,t,n){e.append(`parentDocName`,K(t,n)),e.append(`placement`,`parent-dir`)}function J(e,t){return(t.path??K(e,t.src)).replace(/^\/+/,``)}function Y(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function X(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Z(e,t){let r=o(e).toLowerCase();if(r===``)return null;let i=new Date().toISOString();if(r===`.md`||r===`.mdx`)return{kind:`document`,docName:x(e),docExt:r,modified:i,size:t.size};let a=r.startsWith(`.`)?r.slice(1):r;return{kind:`asset`,path:e,assetExt:a,mediaKind:n(a),modified:i,size:t.size}}function Q(e){let t=$(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function $(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{h as A,z as C,d as D,J as E,m as O,S,O as T,G as _,U as a,E as b,j as c,w as d,X as f,V as g,Y as h,W as i,p as j,ee as k,N as l,D as m,P as n,H as o,C as p,F as r,b as s,q as t,Z as u,B as v,M as w,x,L as y};
1
+ import{Fo as e,No as t,zo as n}from"./dist-CQI6-1xM2.js";import{d as r,f as i,p as a}from"./doc-paths-D1ML_anF.js";import{t as o}from"./file-tree-rename-validation-CEz8MVWM.js";import{c as s,l as c,s as l}from"./file-tree-utils-CBnjZ8_a.js";import{a as u}from"./navigation-targets-D-iDEja4.js";var d=`application/x-open-knowledge-sidebar-item+json`,f={image:!0,video:!0,audio:!0,pdf:!0,text:!0,mermaid:!0};function p(e){return JSON.stringify(e)}function m(e){return e?Array.from(e.types).includes(d):!1}function ee(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:a(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:r(e.assetPath)}:{target:u(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:i(e.docName)}}function h(e){if(!e||!m(e))return null;let t=e.getData(d);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!g(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!_(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _(e){return typeof e==`string`&&Object.hasOwn(f,e)}var v=`.md`,y=/\.(md|mdx)$/i;function b(n,r=v){return y.test(n)||e(n)||t(n)?n:`${n}${r}`}function x(e){return $(e).replace(y,``)}function S(e,t){let n=$(e),r=k(t),i=t.find(e=>s(e)&&A(e,r)===n)??t.find(e=>s(e)&&w(e)===n);if(i)return i.docName;let a=x(n);return t.find(e=>{let t=w(e);return t!==n&&y.test(t)&&x(t)===a})&&y.test(n)?n:a}function C(e,t){let n=k(t);return t.find(t=>A(t,n)===e)??t.find(t=>w(t)===e)}function w(e){return c(e)?D(e.path):l(e)?e.path:b(e.docName,e.docExt)}function T(e){let t=$(e).match(y);return t?`.${t[1].toLowerCase()}`:void 0}function E(e){return $(e)}function D(e){let t=$(e.trim());return t?`${t}/`:``}function O(e){return e.endsWith(`/`)?E(e):x(e)}function k(e){let t=new Map;for(let n of e){if(!s(n))continue;let e=n.docName.match(y);if(!e)continue;let r=n.docName.slice(0,-e[0].length),i=t.get(r);i?i.add(e[0]):t.set(r,new Set([e[0]]))}return t}function A(e,t){let n=w(e);if(!s(e))return n;let r=e.docName.match(y);if(!r)return n;let i=e.docName.slice(0,-r[0].length);return(t.get(i)?.size??0)>1?n:`${e.docName}${e.docExt??v}`}function j(e){let t=k(e),n=new Set,r=[];for(let i of e){let e=A(i,t);n.has(e)||(n.add(e),r.push(e))}return r}function M(e){return[...e].sort().join(`\0`)}function N(e){return M(j(e))}function P(e,t={}){let n=new Set;for(let r of e){let e=(c(r)||l(r)?r.path:r.docName).split(`/`).filter(Boolean);if(!t.includeOkFolders&&e.includes(`.ok`))continue;if(c(r)){let e=D(r.path);e&&n.add(e)}let i=c(r)?e.length:e.length-1;for(let t=1;t<=i;t++)n.add(`${e.slice(0,t).join(`/`)}/`)}return[...n].sort()}function F(e){if(!e)return[];let t=$(e.replace(y,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function I(e,t,n){let r=T(e);if(r)return r;let i=n.find(e=>s(e)&&e.docName===t);return i?i.docExt??v:Q(e).includes(`.`)?void 0:v}function L(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),a=t.filter(e=>{if(!l(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return a.length===1?a[0].path:null}function R(e,t,n){if(T(e))return null;let r=n.find(e=>l(e)&&e.path===t);return r?r.path:Q(e).includes(`.`)?t:L(t,n)}function z(e,t){let n=e.kind===`directory`,r=n?E(e.path):S(e.path,t);if(n)return{kind:`folder`,name:$(Q(e.path)).replace(y,``),path:r,treePath:V(e.path,!0)};let i=R(e.path,r,t);if(i)return{kind:`asset`,name:$(Q(i)),path:i,treePath:i};let a=I(e.path,r,t);return{kind:`file`,name:$(Q(e.path)).replace(y,``),path:r,treePath:V(e.path,!1),docExt:a}}function B(e){return e.kind===`directory`?E(e.path):e.path}function V(e,t){return t?D(e):y.test(e)?e:`${e}${v}`}function H(e,t,n){let r=D(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${v}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function U(e,t){return e===`file`?V(t,!1):`${E(t)}/index${v}`}function W(e,t){return t.kind===`root`||t.directoryPath==null?Q(e):`${t.directoryPath}${Q(e)}`}function G(e,t){if(t)return E(D(e));let n=x(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function K(e,t){let n=E(D(e));return n?`${n}/${t}`:t}function q(e,t,n){e.append(`parentDocName`,K(t,n)),e.append(`placement`,`parent-dir`)}function J(e,t){return(t.path??K(e,t.src)).replace(/^\/+/,``)}function Y(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function X(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function Z(e,t){let r=o(e).toLowerCase();if(r===``)return null;let i=new Date().toISOString();if(r===`.md`||r===`.mdx`)return{kind:`document`,docName:x(e),docExt:r,modified:i,size:t.size};let a=r.startsWith(`.`)?r.slice(1):r;return{kind:`asset`,path:e,assetExt:a,mediaKind:n(a),modified:i,size:t.size}}function Q(e){let t=$(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function $(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{h as A,z as C,d as D,J as E,m as O,S,O as T,G as _,U as a,E as b,j as c,w as d,X as f,V as g,Y as h,W as i,p as j,ee as k,N as l,D as m,P as n,H as o,C as p,F as r,b as s,q as t,Z as u,B as v,M as w,x,L as y};
@@ -1 +1 @@
1
- import{Cr as e,Ua as t,vr as n}from"./dist-PVtTd_Sj2.js";function r(e){return e.kind===`asset`}function i(e){return e.kind===`document`}function a(e){return e.kind===`folder`}function o(e){let t=[],n=0;for(let r of e)switch(r.kind){case`document`:if(r.docName===void 0){n+=1;break}t.push({kind:`document`,docName:r.docName,docExt:r.docExt,size:r.size,modified:r.modified,isSymlink:r.isSymlink,canonicalDocName:r.canonicalDocName,targetPath:r.targetPath});break;case`asset`:if(r.path===void 0||r.assetExt===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt,mediaKind:r.mediaKind??null,size:r.size,modified:r.modified,referencedBy:r.referencedBy});break;case`file`:if(r.path===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt??s(r.path),mediaKind:null,size:r.size,modified:r.modified,referencedBy:[]});break;case`folder`:if(r.path===void 0){n+=1;break}t.push({kind:`folder`,path:r.path,size:r.size,modified:r.modified,hasChildren:r.hasChildren,isSymlink:r.isSymlink,targetPath:r.targetPath});break;default:r.kind;break}return n>0&&console.warn(`[file-tree-utils] dropped ${n} listing entries missing variant identity fields`),t}function s(e){let t=e.includes(`/`)?e.split(`/`).pop()??e:e,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():t.startsWith(`.`)&&t.length>1?t.slice(1).toLowerCase():`file`}function c(e){if(!e)return[];let t=e.split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function l(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):``}function u(e){return e.split(`/`).some(e=>e.toLowerCase()===`.ok`)}function d(e,t){return t&&e!==`document`&&e!==`folder`}function f(e,t){return!t&&n(e)}function p(t,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1,showOkFolders:o=!1}=r;return t.filter(t=>{let r=t.docName??t.path??``;if(r===``||d(t.kind,a))return!1;let s=r.split(`/`),c=s.indexOf(`.ok`);if(c!==-1){if(!o)return!1;let e=s.slice(0,c).join(`/`);return i||e===``||!n(e)}return e(r)?!1:!f(r,i)})}function m(n,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1}=r,o=n.docName??n.path??``;return o===``||t(o)||e(o)||u(o)?{hiddenFiles:!1,onlyMarkdownFiles:!1}:{hiddenFiles:f(o,i),onlyMarkdownFiles:d(n.kind,a)}}function h(e){let{visibility:t={},unfilteredRootEntryCount:n,knownPageCount:r}=e;return(n>0||r>0)&&(t.showOnlyMarkdownFiles??!1)?`filtered-to-zero`:`true-empty`}export{p as a,i as c,o as d,l as i,a as l,h as n,u as o,c as r,r as s,m as t,s as u};
1
+ import{Cr as e,Ua as t,vr as n}from"./dist-CQI6-1xM2.js";function r(e){return e.kind===`asset`}function i(e){return e.kind===`document`}function a(e){return e.kind===`folder`}function o(e){let t=[],n=0;for(let r of e)switch(r.kind){case`document`:if(r.docName===void 0){n+=1;break}t.push({kind:`document`,docName:r.docName,docExt:r.docExt,size:r.size,modified:r.modified,isSymlink:r.isSymlink,canonicalDocName:r.canonicalDocName,targetPath:r.targetPath});break;case`asset`:if(r.path===void 0||r.assetExt===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt,mediaKind:r.mediaKind??null,size:r.size,modified:r.modified,referencedBy:r.referencedBy});break;case`file`:if(r.path===void 0){n+=1;break}t.push({kind:`asset`,path:r.path,assetExt:r.assetExt??s(r.path),mediaKind:null,size:r.size,modified:r.modified,referencedBy:[]});break;case`folder`:if(r.path===void 0){n+=1;break}t.push({kind:`folder`,path:r.path,size:r.size,modified:r.modified,hasChildren:r.hasChildren,isSymlink:r.isSymlink,targetPath:r.targetPath});break;default:r.kind;break}return n>0&&console.warn(`[file-tree-utils] dropped ${n} listing entries missing variant identity fields`),t}function s(e){let t=e.includes(`/`)?e.split(`/`).pop()??e:e,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():t.startsWith(`.`)&&t.length>1?t.slice(1).toLowerCase():`file`}function c(e){if(!e)return[];let t=e.split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function l(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):``}function u(e){return e.split(`/`).some(e=>e.toLowerCase()===`.ok`)}function d(e,t){return t&&e!==`document`&&e!==`folder`}function f(e,t){return!t&&n(e)}function p(t,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1,showOkFolders:o=!1}=r;return t.filter(t=>{let r=t.docName??t.path??``;if(r===``||d(t.kind,a))return!1;let s=r.split(`/`),c=s.indexOf(`.ok`);if(c!==-1){if(!o)return!1;let e=s.slice(0,c).join(`/`);return i||e===``||!n(e)}return e(r)?!1:!f(r,i)})}function m(n,r={}){let{showHiddenFiles:i=!1,showOnlyMarkdownFiles:a=!1}=r,o=n.docName??n.path??``;return o===``||t(o)||e(o)||u(o)?{hiddenFiles:!1,onlyMarkdownFiles:!1}:{hiddenFiles:f(o,i),onlyMarkdownFiles:d(n.kind,a)}}function h(e){let{visibility:t={},unfilteredRootEntryCount:n,knownPageCount:r}=e;return(n>0||r>0)&&(t.showOnlyMarkdownFiles??!1)?`filtered-to-zero`:`true-empty`}export{p as a,i as c,o as d,l as i,a as l,h as n,u as o,c as r,r as s,m as t,s as u};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-BbftclCc.js";import{t}from"./parse-api-error-Cyn4P6OR.js";import{s as n}from"./documents-events-COSAPFkC.js";var r=e(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]);async function i(e){return t(await e.json().catch(()=>null))??`HTTP ${e.status}`}async function a(e,t){try{let n=await fetch(`/api/folder-config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e,frontmatter:t})});return n.ok?{ok:!0}:{ok:!1,error:await i(n)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function o(e){try{let t=await fetch(`/api/template`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function s(e,t){try{let r=`?folder=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,a=await fetch(`/api/template${r}`,{method:`DELETE`});if(!a.ok)return{ok:!1,error:await i(a)};let o=await a.json().catch(()=>null);return n(),{ok:!0,existed:o?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function c(e){try{let t=await fetch(`/api/template`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,committed:r?.committed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function l(e){try{let t=await fetch(`/api/template/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,path:r?.path??``,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}export{o as a,a as i,l as n,r as o,c as r,s as t};
1
+ import{t as e}from"./createLucideIcon-BbftclCc.js";import{t}from"./parse-api-error-Cyn4P6OR.js";import{s as n}from"./documents-events-CU1SZlDl.js";var r=e(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]);async function i(e){return t(await e.json().catch(()=>null))??`HTTP ${e.status}`}async function a(e,t){try{let n=await fetch(`/api/folder-config`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e,frontmatter:t})});return n.ok?{ok:!0}:{ok:!1,error:await i(n)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function o(e){try{let t=await fetch(`/api/template`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function s(e,t){try{let r=`?folder=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,a=await fetch(`/api/template${r}`,{method:`DELETE`});if(!a.ok)return{ok:!1,error:await i(a)};let o=await a.json().catch(()=>null);return n(),{ok:!0,existed:o?.existed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function c(e){try{let t=await fetch(`/api/template`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,committed:r?.committed??!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function l(e){try{let t=await fetch(`/api/template/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{ok:!1,error:await i(t)};let r=await t.json().catch(()=>null);return n(),{ok:!0,path:r?.path??``,created:r?.created??!1,warnings:r?.warnings??[]}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}export{o as a,a as i,l as n,r as o,c as r,s as t};