@inkeep/open-knowledge 0.47.0-beta.14 → 0.47.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-Bzpi4D-5.mjs → acp-harness-probe-Bnts6rTj.mjs} +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/constants-C60h_U5-.mjs +2 -0
- package/dist/git-handle-CPdkNcKW.mjs +1 -0
- package/dist/{git-handle-I4Wo1xI2.mjs → git-handle-DZ99-PGe.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-CAm3g_m2.mjs +1 -0
- package/dist/{init-p3FBT6M-.mjs → init-CUaIjiMo.mjs} +3 -3
- package/dist/{launch-json-removal-DkXEI_E-.mjs → launch-json-removal-B_v3c67x.mjs} +2 -2
- package/dist/{loader-C9P23H2V.mjs → loader-CkZ6CTb2.mjs} +2 -2
- package/dist/loader-D0fOaLys.mjs +1 -0
- package/dist/md-manager-AQqN3Gpb.mjs +2 -0
- package/dist/{open-browser-Bc_3nD-8.mjs → open-browser-CWvpqBNK.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-Cuq6GZ9t.mjs → preview-BwiH8Ec6.mjs} +2 -2
- package/dist/preview-Dg3j3UKT.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DnZx_iOU.js → ActivityModeContent-D5TfDRam.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-DJ2-UsWA.js → AgentDiffPane-DzyTBPWr.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-BnfaxmYs.js → AgentThreadClientBinder-BctQyzUb.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-B7Nb_Prz.js → ChangedOutsideBadge-D8PLhT3b.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BPC_zQgZ.js → CodeMirrorPropInput-C_Ul6LEF.js} +1 -1
- package/dist/public/assets/{DocumentContext-anJxeK9i.js → DocumentContext-BSUVMRPR.js} +6 -6
- package/dist/public/assets/{EditorModeToggle-C9BKN-yE.js → EditorModeToggle-DyKtsJ5u.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-DIz2gorY.js → EnableSyncConfirmDialog-DEjR8RoN.js} +1 -1
- package/dist/public/assets/FeedbackForm-CwKlgOyH.js +1 -0
- package/dist/public/assets/{GraphPanel-BVeL-7D5.js → GraphPanel-DkwBXcDT.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BSa0kpLo.js → ImportSkillDialog-B9L3IH3D.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BprWEWXR.js → LintConfigEditor-BpXnpZd0.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-B6Rxdr9G.js → ManagedArtifactProperties-DQ-jFLHF.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-Zkro4AtJ.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-CxKa0U9E.js → McpConsentDialogBody-Di0dc0Tq.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-Bzd-2Jzs.js → MermaidDocEditor-Dpg12Tki.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody--l9pSfnw.js → ReportBugDialogBody-CTRJuYcL.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DeGW895c.js → SchemaConfigEditor-DMhtLwRw.js} +1 -1
- package/dist/public/assets/{SessionsHost-D5UkI7-p.js → SessionsHost-oNyYvi5z.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-IFOvZZqr.js → SettingsDialogBody-CDbFtTdS.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-BIi10Y8l.js → ShareBranchSwitchDialog-CaXs87VY.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-CKAMTDsZ.js → ShareReceiveDialog-0sIjLwpR.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-B0ferX65.js → ShareReceiveMissDialog-B5FxAhNW.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-B34nvuqh.js → SkillEditBanner-Dp8Hkers.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-u1OYA4fd.js → SkillOriginInline-D6Vqhr21.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-1YGkO2th.js → SkillToolbarControls-G3pICno5.js} +1 -1
- package/dist/public/assets/{SourceEditor-HVX16YXz.js → SourceEditor-DmNElH6G.js} +1 -1
- package/dist/public/assets/{TerminalPanel-CJod-Zrx.js → TerminalPanel-CbtOMei5.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-Dwk2DcF6.js → TerminalWindowApp-L5dPQ7lv.js} +1 -1
- package/dist/public/assets/{TextDocEditor-C5J4jgjO.js → TextDocEditor-Dmf7TTiA.js} +1 -1
- package/dist/public/assets/{ThreadView-h4TbdkA3.js → ThreadView-CER4InFQ.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-CNiUuVNQ.js → TimelineDiffPane-uqxXdU23.js} +1 -1
- package/dist/public/assets/{agent-diff-store-BeaPLwYM.js → agent-diff-store-bHo6Kh5a.js} +1 -1
- package/dist/public/assets/{agent-visibility-DOI-aRe5.js → agent-visibility-D8P2aHAW.js} +1 -1
- package/dist/public/assets/{auth-state-cache-1bfEn7hj.js → auth-state-cache-pFBbLky5.js} +1 -1
- package/dist/public/assets/{client-version-CVk8TXQL.js → client-version-DvKMLhnr.js} +1 -1
- package/dist/public/assets/{config-context-BlTWIu0S.js → config-context-CAqXUmYZ.js} +1 -1
- package/dist/public/assets/{config-provider-VpKVpqSK.js → config-provider-C9bLBOvA.js} +1 -1
- package/dist/public/assets/{dist-Dp50RPBY2.js → dist-BU8JCBqy2.js} +1 -1
- package/dist/public/assets/{doc-paths-DGWtnOSZ.js → doc-paths-D9KdMECm.js} +1 -1
- package/dist/public/assets/{documents-events-BMvnact8.js → documents-events-Dg32OM79.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DGfCX-aq.js → file-tree-adapter-CdI4HnMo.js} +1 -1
- package/dist/public/assets/{file-tree-utils-Cawb-Fht.js → file-tree-utils-B9qjWixz.js} +1 -1
- package/dist/public/assets/{folder-config-api-Rk-XVk8n.js → folder-config-api-Bigw9oyp.js} +1 -1
- package/dist/public/assets/{globals-DpKvVzNS.js → globals-ChLmp8Vo.js} +1 -1
- package/dist/public/assets/{index-B7kLMpFo.js → index-CA7fa9Ef.js} +7 -7
- package/dist/public/assets/{lint-config-client-DQhrbuBD.js → lint-config-client-CaqOCeCX.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-CXXfZ7AS.js → markdownlint-rule-browser-afLnTSOU.js} +1 -1
- package/dist/public/assets/{navigation-targets-_6Iwr-fQ.js → navigation-targets-BDEX1Jzv.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-C9oj9rmC.js → open-managed-artifact-tab-D0ob9Lcy.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-DsY7F3C7.js → pending-receive-nav-store-6GSwpITy.js} +1 -1
- package/dist/public/assets/{prop-types-cgBDAKXT.js → prop-types-BU2yOBBY.js} +1 -1
- package/dist/public/assets/{receive-store-V-894b3Q.js → receive-store-Cd4Hbr5L.js} +1 -1
- package/dist/public/assets/{selection-context-B-KMAXq0.js → selection-context-rElDeSYS.js} +1 -1
- package/dist/public/assets/{skill-actions-DgfuLyh3.js → skill-actions-BC2N04TN.js} +1 -1
- package/dist/public/assets/{skill-scope-B08uDTjW.js → skill-scope-DmJyA019.js} +1 -1
- package/dist/public/assets/{skills-api-BRPaZddc.js → skills-api-CIrx9VYh.js} +1 -1
- package/dist/public/assets/{src-CQwTZt_9.js → src-UZsyoffN.js} +1 -1
- package/dist/public/assets/{tag-pill-input-Diwtyypb.js → tag-pill-input-CC-dmF2y.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-KPxzHOsd.js → target-navigation-intent-9V6vp_PY.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-oqilDUow.js → terminal-launch-events-t5eziTRM.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-DyhaSTn5.js → terminal-telemetry-C5CXQZFf.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BK0ARuUX.js → typing-burst-detector-B00fsp8R.js} +1 -1
- package/dist/public/assets/{uninstall-DN3K5-qU.js → uninstall-roTqJpdJ.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DfWrpNMe.js → use-activity-panel-C8Bsa4Wh.js} +1 -1
- package/dist/public/assets/{use-collab-url-D0OTAOCR.js → use-collab-url-DE27_qfd.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-7QgVqT2i.js → use-live-xterm-theme-Bs8i6uIk.js} +1 -1
- package/dist/public/assets/{use-open-skill-NV7rKurq.js → use-open-skill-CwFa389s.js} +1 -1
- package/dist/public/assets/{use-settings-route-DAGaZ39q.js → use-settings-route-BxF_KhIQ.js} +1 -1
- package/dist/public/assets/{use-skill-directory-Ju1ZmlKr.js → use-skill-directory-B_aFh-rY.js} +1 -1
- package/dist/public/assets/{use-skill-origin-C-FHHNBF.js → use-skill-origin-18USFBF8.js} +1 -1
- package/dist/public/assets/{use-skills-CeXXLoHf.js → use-skills-p2WuQJcF.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-B9EaAD2q.js → use-terminal-enabled-DycT8EtH.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-CDiv4XcE.js → use-timeline-entry-diff-AqVeS9gC.js} +1 -1
- package/dist/public/assets/{use-workspace-7rqwaYpi.js → use-workspace-XD6JgiN8.js} +1 -1
- package/dist/public/index.html +42 -42
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-CHIF7tq1.mjs → repair-launch-json-HoVxof_u.mjs} +2 -2
- package/dist/{repair-mcp-configs-DRpP5X6l.mjs → repair-mcp-configs-CaWo5lPQ.mjs} +2 -2
- package/dist/{repair-skills-BFS9VdJG.mjs → repair-skills-BTZ4p2eR.mjs} +2 -2
- package/dist/repair-skills-DG80TYra.mjs +1 -0
- package/dist/server-lock-1g24bWxY.mjs +1 -0
- package/dist/{server-lock-CG7HATY5.mjs → server-lock-Iwha6Mev.mjs} +2 -2
- package/dist/{src-Cd48emEJ.mjs → src-D7ue1-zj.mjs} +2 -2
- package/dist/{src-DTDFcMVx.mjs → src-DSW-Uq2t.mjs} +1 -1
- package/dist/{src-C_Slu4-t.mjs → src-aLMPCjd_.mjs} +2 -2
- package/dist/{src-DbA3hkai.mjs → src-d3vC7Yq4.mjs} +8 -8
- package/dist/{start-TlV2KNW-.mjs → start-B3hIo1zn.mjs} +3 -3
- package/dist/start-E1o1cIg-.mjs +1 -0
- package/dist/{write-project-skill-BERngm0S.mjs → write-project-skill-49lx5BFR.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-t6bITiHu.mjs +0 -2
- package/dist/git-handle-Bt16fZHs.mjs +0 -1
- package/dist/init-Br0-eR8k.mjs +0 -1
- package/dist/loader-uo1bqPoI.mjs +0 -1
- package/dist/md-manager-5iZyY6ma.mjs +0 -2
- package/dist/preview-BOkS5aPh.mjs +0 -1
- package/dist/public/assets/FeedbackForm-lsEggh84.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-Cf1VOAl2.js +0 -1
- package/dist/repair-skills-FfuWyfMq.mjs +0 -1
- package/dist/server-lock-D7O44--l.mjs +0 -1
- package/dist/start-DHRkxHgT.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{Lo as a,Or as o,Po as s,Qt as c,Xt as l,da as u,fa as d,ho as f,ma as ee,pa as te}from"./dist-Dp50RPBY2.js";import{r as p}from"./client-version-CVk8TXQL.js";import{h as ne,o as re,t as ie,u as ae}from"./config-context-BlTWIu0S.js";var oe=i(),m=e(n(),1),se=null,ce=new Set;function le(){return se}function ue(e){let t=e!==null&&e.length>0?e:null;if(t!==se){se=t;for(let e of ce)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function de(e){return ce.add(e),()=>{ce.delete(e)}}function fe(){return(0,m.useSyncExternalStore)(de,le,le)}var h=()=>new Map,pe=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},me=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},he=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_=()=>new Set,ge=e=>e[e.length-1],_e=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},v=Array.from,ve=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ye=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},be=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},y=Array.isArray,xe=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,_).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},Se=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,_).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},b=Math.floor,Ce=Math.abs,we=(e,t)=>e<t?e:t,x=(e,t)=>e>t?e:t;Number.isNaN;var Te=e=>e===0?1/e<0:e<0,Ee=1<<17,De=1<<18,Oe=1<<19,ke=1<<20,Ae=1<<21,je=1<<22,Me=1<<23,Ne=1<<24,Pe=1<<25,Fe=1<<26,Ie=1<<27,Le=1<<28,Re=1<<29;Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1,Ie-1,Le-1,Re-1;var ze=2**53-1,Be=-(2**53-1),Ve=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&b(e)===e);Number.isNaN,Number.parseInt;var He=String.fromCharCode;String.fromCodePoint,He(65535);var Ue=e=>e.toLowerCase(),We=/^\s*/g,Ge=e=>e.replace(We,``),Ke=/([A-Z])/g,qe=(e,t)=>Ge(e.replace(Ke,e=>`${t}${Ue(e)}`)),Je=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},Ye=typeof TextEncoder<`u`?new TextEncoder:null,Xe=Ye?e=>Ye.encode(e):Je,Ze=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Ze&&Ze.decode(new Uint8Array).length===1&&(Ze=null);var Qe=(e,t)=>be(t,()=>e).join(``),$e=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},et=()=>new $e,tt=e=>{let t=et();return e(t),S(t)},nt=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(nt(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},rt=(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(x(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},it=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=b(t/128);C(e,127&t)},at=(e,t)=>{let n=Te(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=b(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=b(t/128)},ot=new Uint8Array(3e4),st=ot.length/3,ct=Ye&&Ye.encodeInto?(e,t)=>{if(t.length<st){let n=Ye.encodeInto(t,ot).written||0;w(e,n);for(let t=0;t<n;t++)C(e,ot[t])}else T(e,Xe(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))},lt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=we(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(x(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),lt(e,t)},ut=(e,t)=>{rt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},dt=(e,t)=>ut(e,4).setFloat32(0,t,!1),ft=(e,t)=>ut(e,8).setFloat64(0,t,!1),pt=(e,t)=>ut(e,8).setBigInt64(0,t,!1),mt=new DataView(new ArrayBuffer(4)),ht=e=>(mt.setFloat32(0,e),mt.getFloat32(0)===e),gt=(e,t)=>{switch(typeof t){case`string`:C(e,119),ct(e,t);break;case`number`:Ve(t)&&Ce(t)<=2147483647?(C(e,125),at(e,t)):ht(t)?(C(e,124),dt(e,t)):(C(e,123),ft(e,t));break;case`bigint`:C(e,122),pt(e,t);break;case`object`:if(t===null)C(e,126);else if(y(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)gt(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];ct(e,i),gt(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},_t=class extends $e{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)}},vt=e=>{e.count>0&&(at(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},yt=class{constructor(){this.encoder=new $e,this.s=0,this.count=0}write(e){this.s===e?this.count++:(vt(this),this.count=1,this.s=e)}toUint8Array(){return vt(this),S(this.encoder)}},bt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);at(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},xt=class{constructor(){this.encoder=new $e,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(bt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return bt(this),S(this.encoder)}},St=class{constructor(){this.sarr=[],this.s=``,this.lensE=new yt}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 $e;return this.sarr.push(this.s),this.s=``,ct(e,this.sarr.join(``)),lt(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},Ct=E(`Unexpected end of array`),wt=E(`Integer out of Range`),Tt=class{constructor(e){this.arr=e,this.pos=0}},Et=e=>new Tt(e),Dt=e=>e.pos!==e.arr.length,Ot=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>Ot(e,A(e)),kt=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>ze)throw wt}throw Ct},At=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>ze)throw wt}throw Ct},jt=Ze?e=>Ze.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(kt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(kt(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))}},Mt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Nt=[e=>void 0,e=>null,At,e=>Mt(e,4).getFloat32(0,!1),e=>Mt(e,8).getFloat64(0,!1),e=>Mt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,jt,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=jt(e);n[t]=Pt(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(Pt(e));return n},k],Pt=e=>Nt[127-kt(e)](e),Ft=class extends Tt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Dt(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},It=class extends Tt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=At(this);let e=Te(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Lt=class extends Tt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=At(this),t=e&1;this.diff=b(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Rt=class{constructor(e){this.decoder=new It(e),this.str=jt(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 zt=crypto.getRandomValues.bind(crypto),Bt=Math.random,Vt=()=>zt(new Uint32Array(1))[0],Ht=e=>e[b(Bt()*e.length)],Ut=`10000000-1000-4000-8000-100000000000`,Wt=()=>Ut.replace(/[018]/g,e=>(e^Vt()&15>>e/4).toString(16)),Gt=Date.now,Kt=e=>new Promise(e);Promise.all.bind(Promise);var qt=e=>e===void 0?null:e,Jt=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&&(Jt=localStorage)}catch{}var Yt=Jt,Xt=Symbol(`Equality`),Zt=(e,t)=>e===t||!!e?.[Xt]?.(t)||!1,Qt=e=>typeof e==`object`,$t=Object.assign,en=Object.keys,tn=(e,t)=>{for(let n in e)t(e[n],n)},nn=e=>en(e).length,rn=e=>{for(let t in e)return!1;return!0},an=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},on=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),sn=(e,t)=>e===t||nn(e)===nn(t)&&an(e,(e,n)=>(e!==void 0||on(t,n))&&Zt(t[n],e)),cn=Object.freeze,ln=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&ln(e[t])}return cn(e)},un=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&un(e,t,n+1)}},dn=e=>e,fn=(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[Xt]!=null)return e[Xt](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)||!fn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(nn(e)!==nn(t))return!1;for(let n in e)if(!on(e,n)||!fn(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(!fn(e[n],t[n]))return!1;break;default:return!1}return!0},pn=(e,t)=>t.includes(e),mn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,hn=typeof window<`u`&&typeof document<`u`&&!mn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var j,gn=[],_n=()=>{if(j===void 0)if(mn){j=h();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?gn.push(r):(j.set(t,r),t=null)}t!==null&&j.set(t,``)}else typeof location==`object`?(j=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);j.set(`--${qe(t,`-`)}`,n),j.set(`-${qe(t,`-`)}`,n)}})):j=h();return j},vn=e=>_n().has(e),yn=e=>qt(mn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Yt.getItem(e)),bn=e=>vn(`--`+e)||yn(e)!==null,xn=bn(`production`),Sn=mn&&pn({}.FORCE_COLOR,[`true`,`1`,`2`])||!vn(`--no-colors`)&&!bn(`no-color`)&&(!mn||process.stdout.isTTY)&&(!mn||vn(`--color`)||yn(`COLORTERM`)!==null||(yn(`TERM`)||``).includes(`color`)),Cn=e=>new Uint8Array(e),wn=hn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=He(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Tn=e=>{let t=Cn(e.byteLength);return t.set(e),t},En=e=>tt(t=>gt(t,e)),Dn=class{constructor(e,t){this.left=e,this.right=t}},M=(e,t)=>new Dn(e,t),On=(e,t)=>e.forEach(e=>t(e.left,e.right)),kn=e=>e.next()>=.5,An=(e,t,n)=>b(e.next()*(n+1-t)+t),jn=(e,t,n)=>b(e.next()*(n+1-t)+t),Mn=(e,t,n)=>jn(e,t,n),Nn=e=>He(Mn(e,97,122)),Pn=(e,t=0,n=20)=>{let r=Mn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Nn(e);return i},Fn=(e,t)=>t[Mn(e,0,t.length-1)],In=Symbol(`0schema`),Ln=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(Qe(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{Lo as a,Or as o,Po as s,Qt as c,Xt as l,da as u,fa as d,ho as f,ma as ee,pa as te}from"./dist-BU8JCBqy2.js";import{r as p}from"./client-version-DvKMLhnr.js";import{h as ne,o as re,t as ie,u as ae}from"./config-context-CAqXUmYZ.js";var oe=i(),m=e(n(),1),se=null,ce=new Set;function le(){return se}function ue(e){let t=e!==null&&e.length>0?e:null;if(t!==se){se=t;for(let e of ce)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function de(e){return ce.add(e),()=>{ce.delete(e)}}function fe(){return(0,m.useSyncExternalStore)(de,le,le)}var h=()=>new Map,pe=e=>{let t=h();return e.forEach((e,n)=>{t.set(n,e)}),t},g=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},me=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},he=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_=()=>new Set,ge=e=>e[e.length-1],_e=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},v=Array.from,ve=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ye=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},be=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},y=Array.isArray,xe=class{constructor(){this._observers=h()}on(e,t){return g(this._observers,e,_).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},Se=class{constructor(){this._observers=h()}on(e,t){g(this._observers,e,_).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return v((this._observers.get(e)||h()).values()).forEach(e=>e(...t))}destroy(){this._observers=h()}},b=Math.floor,Ce=Math.abs,we=(e,t)=>e<t?e:t,x=(e,t)=>e>t?e:t;Number.isNaN;var Te=e=>e===0?1/e<0:e<0,Ee=1<<17,De=1<<18,Oe=1<<19,ke=1<<20,Ae=1<<21,je=1<<22,Me=1<<23,Ne=1<<24,Pe=1<<25,Fe=1<<26,Ie=1<<27,Le=1<<28,Re=1<<29;Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1,Fe-1,Ie-1,Le-1,Re-1;var ze=2**53-1,Be=-(2**53-1),Ve=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&b(e)===e);Number.isNaN,Number.parseInt;var He=String.fromCharCode;String.fromCodePoint,He(65535);var Ue=e=>e.toLowerCase(),We=/^\s*/g,Ge=e=>e.replace(We,``),Ke=/([A-Z])/g,qe=(e,t)=>Ge(e.replace(Ke,e=>`${t}${Ue(e)}`)),Je=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},Ye=typeof TextEncoder<`u`?new TextEncoder:null,Xe=Ye?e=>Ye.encode(e):Je,Ze=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Ze&&Ze.decode(new Uint8Array).length===1&&(Ze=null);var Qe=(e,t)=>be(t,()=>e).join(``),$e=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},et=()=>new $e,tt=e=>{let t=et();return e(t),S(t)},nt=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(nt(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},rt=(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(x(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},it=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=b(t/128);C(e,127&t)},at=(e,t)=>{let n=Te(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=b(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=b(t/128)},ot=new Uint8Array(3e4),st=ot.length/3,ct=Ye&&Ye.encodeInto?(e,t)=>{if(t.length<st){let n=Ye.encodeInto(t,ot).written||0;w(e,n);for(let t=0;t<n;t++)C(e,ot[t])}else T(e,Xe(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))},lt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=we(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(x(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),lt(e,t)},ut=(e,t)=>{rt(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},dt=(e,t)=>ut(e,4).setFloat32(0,t,!1),ft=(e,t)=>ut(e,8).setFloat64(0,t,!1),pt=(e,t)=>ut(e,8).setBigInt64(0,t,!1),mt=new DataView(new ArrayBuffer(4)),ht=e=>(mt.setFloat32(0,e),mt.getFloat32(0)===e),gt=(e,t)=>{switch(typeof t){case`string`:C(e,119),ct(e,t);break;case`number`:Ve(t)&&Ce(t)<=2147483647?(C(e,125),at(e,t)):ht(t)?(C(e,124),dt(e,t)):(C(e,123),ft(e,t));break;case`bigint`:C(e,122),pt(e,t);break;case`object`:if(t===null)C(e,126);else if(y(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)gt(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];ct(e,i),gt(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},_t=class extends $e{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)}},vt=e=>{e.count>0&&(at(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},yt=class{constructor(){this.encoder=new $e,this.s=0,this.count=0}write(e){this.s===e?this.count++:(vt(this),this.count=1,this.s=e)}toUint8Array(){return vt(this),S(this.encoder)}},bt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);at(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},xt=class{constructor(){this.encoder=new $e,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(bt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return bt(this),S(this.encoder)}},St=class{constructor(){this.sarr=[],this.s=``,this.lensE=new yt}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 $e;return this.sarr.push(this.s),this.s=``,ct(e,this.sarr.join(``)),lt(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},Ct=E(`Unexpected end of array`),wt=E(`Integer out of Range`),Tt=class{constructor(e){this.arr=e,this.pos=0}},Et=e=>new Tt(e),Dt=e=>e.pos!==e.arr.length,Ot=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>Ot(e,A(e)),kt=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>ze)throw wt}throw Ct},At=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>ze)throw wt}throw Ct},jt=Ze?e=>Ze.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(kt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(kt(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))}},Mt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Nt=[e=>void 0,e=>null,At,e=>Mt(e,4).getFloat32(0,!1),e=>Mt(e,8).getFloat64(0,!1),e=>Mt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,jt,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=jt(e);n[t]=Pt(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(Pt(e));return n},k],Pt=e=>Nt[127-kt(e)](e),Ft=class extends Tt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Dt(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},It=class extends Tt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=At(this);let e=Te(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Lt=class extends Tt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=At(this),t=e&1;this.diff=b(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},Rt=class{constructor(e){this.decoder=new It(e),this.str=jt(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 zt=crypto.getRandomValues.bind(crypto),Bt=Math.random,Vt=()=>zt(new Uint32Array(1))[0],Ht=e=>e[b(Bt()*e.length)],Ut=`10000000-1000-4000-8000-100000000000`,Wt=()=>Ut.replace(/[018]/g,e=>(e^Vt()&15>>e/4).toString(16)),Gt=Date.now,Kt=e=>new Promise(e);Promise.all.bind(Promise);var qt=e=>e===void 0?null:e,Jt=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&&(Jt=localStorage)}catch{}var Yt=Jt,Xt=Symbol(`Equality`),Zt=(e,t)=>e===t||!!e?.[Xt]?.(t)||!1,Qt=e=>typeof e==`object`,$t=Object.assign,en=Object.keys,tn=(e,t)=>{for(let n in e)t(e[n],n)},nn=e=>en(e).length,rn=e=>{for(let t in e)return!1;return!0},an=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},on=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),sn=(e,t)=>e===t||nn(e)===nn(t)&&an(e,(e,n)=>(e!==void 0||on(t,n))&&Zt(t[n],e)),cn=Object.freeze,ln=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&ln(e[t])}return cn(e)},un=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&un(e,t,n+1)}},dn=e=>e,fn=(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[Xt]!=null)return e[Xt](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)||!fn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(nn(e)!==nn(t))return!1;for(let n in e)if(!on(e,n)||!fn(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(!fn(e[n],t[n]))return!1;break;default:return!1}return!0},pn=(e,t)=>t.includes(e),mn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,hn=typeof window<`u`&&typeof document<`u`&&!mn;typeof navigator<`u`&&/Mac/.test(navigator.platform);var j,gn=[],_n=()=>{if(j===void 0)if(mn){j=h();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?gn.push(r):(j.set(t,r),t=null)}t!==null&&j.set(t,``)}else typeof location==`object`?(j=h(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);j.set(`--${qe(t,`-`)}`,n),j.set(`-${qe(t,`-`)}`,n)}})):j=h();return j},vn=e=>_n().has(e),yn=e=>qt(mn?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Yt.getItem(e)),bn=e=>vn(`--`+e)||yn(e)!==null,xn=bn(`production`),Sn=mn&&pn({}.FORCE_COLOR,[`true`,`1`,`2`])||!vn(`--no-colors`)&&!bn(`no-color`)&&(!mn||process.stdout.isTTY)&&(!mn||vn(`--color`)||yn(`COLORTERM`)!==null||(yn(`TERM`)||``).includes(`color`)),Cn=e=>new Uint8Array(e),wn=hn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=He(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Tn=e=>{let t=Cn(e.byteLength);return t.set(e),t},En=e=>tt(t=>gt(t,e)),Dn=class{constructor(e,t){this.left=e,this.right=t}},M=(e,t)=>new Dn(e,t),On=(e,t)=>e.forEach(e=>t(e.left,e.right)),kn=e=>e.next()>=.5,An=(e,t,n)=>b(e.next()*(n+1-t)+t),jn=(e,t,n)=>b(e.next()*(n+1-t)+t),Mn=(e,t,n)=>jn(e,t,n),Nn=e=>He(Mn(e,97,122)),Pn=(e,t=0,n=20)=>{let r=Mn(e,t,n),i=``;for(let t=0;t<r;t++)i+=Nn(e);return i},Fn=(e,t)=>t[Mn(e,0,t.length-1)],In=Symbol(`0schema`),Ln=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(Qe(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
2
|
`)}},Rn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Xt]?Zt(e,t):y(e)?ve(e,e=>ye(t,t=>Rn(e,t))):Qt(e)?an(e,(e,n)=>Rn(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]),Rn(t,n)}equals(e){return this.constructor===e.constructor&&fn(this.shape,e.shape)}[In](){return!0}[Xt](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){D()}get nullable(){return hr(this,Ar)}get optional(){return new qn(this)}cast(e){return Pr(e,this),e}expect(e){return Pr(e,this),e}},zn=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 zn(e,t);P(zn);var Bn=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 Bn(e);P(Bn);var Vn=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}},Hn=(...e)=>new Vn(e),Un=P(Vn),Wn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Gn=e=>{if(Tr.check(e))return[Wn(e)];if(Un.check(e))return e.shape.map(e=>e+``);if(wr.check(e))return[`[+-]?\\d+.?\\d*`];if(Er.check(e))return[`.*`];if(gr.check(e))return e.shape.map(Gn).flat(1);O()};P(class extends N{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Gn).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 Kn=Symbol(`optional`),qn=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[Kn](){return!0}},Jn=P(qn),Yn=class extends N{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Yn,P(Yn);var Xn=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):an(this.shape,(n,r)=>{let i=this._isPartial&&!on(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Zn=e=>new Xn(e),Qn=P(Xn),$n=F(e=>e!=null&&(e.constructor===Object||e.constructor==null)),er=class extends N{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&an(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)})}},tr=(e,t)=>new er(e,t),nr=P(er),rr=class extends N{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&an(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},ir=(...e)=>new rr(e);P(rr);var ar=class extends N{constructor(e){super(),this.shape=e.length===1?e[0]:new mr(e)}check(e,t){let n=y(e)&&ve(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},or=(...e)=>new ar(e),sr=P(ar),cr=F(e=>y(e)),lr=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}},ur=(e,t=null)=>new lr(e,t);P(lr);var dr=ur(N),fr=P(class extends N{constructor(e){super(),this.len=e.length-1,this.args=ir(...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}}),pr=F(e=>typeof e==`function`);P(class extends N{constructor(e){super(),this.shape=e}check(e,t){let n=ve(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var mr=class extends N{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=ye(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},hr=(...e)=>e.findIndex(e=>gr.check(e))>=0?hr(...e.map(e=>Nr(e)).map(e=>gr.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new mr(e),gr=P(mr),_r=()=>!0,vr=F(_r),yr=P(Bn,e=>e.shape===_r),br=F(e=>typeof e==`bigint`),xr=F(e=>e===br),Sr=F(e=>typeof e==`symbol`);F(e=>e===Sr);var Cr=F(e=>typeof e==`number`),wr=F(e=>e===Cr),Tr=F(e=>typeof e==`string`),Er=F(e=>e===Tr),Dr=F(e=>typeof e==`boolean`),Or=F(e=>e===Dr),kr=Hn(void 0);P(Vn,e=>e.shape.length===1&&e.shape[0]===void 0),Hn(void 0);var Ar=Hn(null),jr=P(Vn,e=>e.shape.length===1&&e.shape[0]===null);P(Uint8Array),P(zn,e=>e.shape===Uint8Array);var Mr=hr(Cr,Tr,Ar,kr,br,Dr,Sr);(()=>{let e=or(vr),t=tr(Tr,vr),n=hr(Cr,Tr,Ar,Dr,e,t);return e.shape=n,t.shape.values=n,n})();var Nr=e=>{if(dr.check(e))return e;if($n.check(e)){let t={};for(let n in e)t[n]=Nr(e[n]);return Zn(t)}else if(cr.check(e))return hr(...e.map(Nr));else if(Mr.check(e))return Hn(e);else if(pr.check(e))return P(e);O()},Pr=xn?()=>{}:(e,t)=>{let n=new Ln;if(!t.check(e,n))throw E(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Fr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Nr(e),h:t}),this}else(e){return this.if(vr,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`)}}},Ir=(e=>new Fr(e))(vr).if(wr,(e,t)=>An(t,Be,ze)).if(Er,(e,t)=>Pn(t)).if(Or,(e,t)=>kn(t)).if(xr,(e,t)=>BigInt(An(t,Be,ze))).if(gr,(e,t)=>Lr(t,Fn(t,e.shape))).if(Qn,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Jn.check(i)){if(kn(t))continue;i=i.shape}n[r]=Ir(i,t)}return n}).if(sr,(e,t)=>{let n=[],r=jn(t,0,42);for(let i=0;i<r;i++)n.push(Lr(t,e.shape));return n}).if(Un,(e,t)=>Fn(t,e.shape)).if(jr,(e,t)=>null).if(fr,(e,t)=>{let n=Lr(t,e.res);return()=>n}).if(yr,(e,t)=>Lr(t,Fn(t,[Cr,Tr,Ar,kr,br,Dr,or(Cr),tr(hr(`a`,`b`,`c`),Cr)]))).if(nr,(e,t)=>{let n={},r=An(t,0,3);for(let i=0;i<r;i++){let r=Lr(t,e.shape.keys);n[r]=Lr(t,e.shape.values)}return n}).done(),Lr=(e,t)=>Ir(Nr(t),e),I=typeof document<`u`?document:{},Rr=e=>I.createElement(e),zr=()=>I.createDocumentFragment();F(e=>e.nodeType===Zr);var Br=e=>I.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Vr=(e,t)=>(On(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Hr=e=>{let t=zr();for(let n=0;n<e.length;n++)qr(t,e[n]);return t},Ur=(e,t)=>(qr(e,Hr(t)),e),Wr=(e,t=[],n=[])=>Ur(Vr(Rr(e),t),n);F(e=>e.nodeType===Jr);var Gr=Br;F(e=>e.nodeType===Yr);var Kr=e=>me(e,(e,t)=>`${t}:${e};`).join(``),qr=(e,t)=>e.appendChild(t),Jr=I.ELEMENT_NODE,Yr=I.TEXT_NODE;I.CDATA_SECTION_NODE,I.COMMENT_NODE;var Xr=I.DOCUMENT_NODE;I.DOCUMENT_TYPE_NODE;var Zr=I.DOCUMENT_FRAGMENT_NODE;F(e=>e.nodeType===Xr);var Qr=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),$r=(e,t)=>new Qr(setTimeout(t,e)),L=Symbol,ei=L(),ti=L(),ni=L(),ri=L(),ii=L(),ai=L(),oi=L(),si=L(),ci=L(),li=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};Gt();var ui={[ei]:M(`font-weight`,`bold`),[ti]:M(`font-weight`,`normal`),[ni]:M(`color`,`blue`),[ii]:M(`color`,`green`),[ri]:M(`color`,`grey`),[ai]:M(`color`,`red`),[oi]:M(`color`,`purple`),[si]:M(`color`,`orange`),[ci]:M(`color`,`black`)},di=Sn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=h(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=ui[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=Kr(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}:li,fi=(...e)=>{console.log(...di(e)),mi.forEach(t=>t.print(e))},pi=(...e)=>{console.warn(...di(e)),e.unshift(si),mi.forEach(t=>t.print(e))},mi=_(),hi=e=>({[Symbol.iterator](){return this},next:e}),gi=(e,t)=>hi(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),_i=(e,t)=>hi(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),vi=class{constructor(e,t){this.clock=e,this.len=t}},yi=class{constructor(){this.clients=new Map}},bi=(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])Fa(e,i,o.clock,o.len,n)}}),xi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=b((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Si=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&xi(n,t.clock)!==null},Ci=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 vi(r.clock,x(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},wi=e=>{let t=new yi;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++)_e(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Ci(t),t},Ti=(e,t,n,r)=>{g(e.clients,t,()=>[]).push(new vi(n,r))},Ei=()=>new yi,Di=e=>{let t=Ei();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 vi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Oi=(e,t)=>{w(e.restEncoder,t.clients.size),v(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)}})},ki=e=>{let t=new yi,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=g(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new vi(e.readDsClock(),e.readDsLen()))}}return t},Ai=(e,t,n)=>{let r=new yi,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&&Ti(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,qs(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,qs(t,c,a-c.id.clock)),c.delete(t))}else Ti(r,i,n,a-n)}}if(r.clients.size>0){let e=new Bi;return w(e.restEncoder,0),Oi(e,r),e.toUint8Array()}return null},ji=Vt,Mi=class e extends xe{constructor({guid:e=Wt(),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=ji(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Oa,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=Kt(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Kt(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(v(this.subdocs).map(e=>e.guid))}transact(e,t=null){return H(this,e,t)}get(e,t=W){let n=g(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,Ro)}getText(e=``){return this.get(e,as)}getMap(e=``){return this.get(e,Vo)}getXmlElement(e=``){return this.get(e,us)}getXmlFragment(e=``){return this.get(e,cs)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,v(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,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()}},Ni=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return A(this.restDecoder)}readDsLen(){return A(this.restDecoder)}},Pi=class extends Ni{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 kt(this.restDecoder)}readString(){return jt(this.restDecoder)}readParentInfo(){return A(this.restDecoder)===1}readTypeRef(){return A(this.restDecoder)}readLen(){return A(this.restDecoder)}readAny(){return Pt(this.restDecoder)}readBuf(){return Tn(k(this.restDecoder))}readJSON(){return JSON.parse(jt(this.restDecoder))}readKey(){return jt(this.restDecoder)}},Fi=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}},Ii=class extends Fi{constructor(e){super(e),this.keys=[],A(e),this.keyClockDecoder=new Lt(k(e)),this.clientDecoder=new It(k(e)),this.leftClockDecoder=new Lt(k(e)),this.rightClockDecoder=new Lt(k(e)),this.infoDecoder=new Ft(k(e),kt),this.stringDecoder=new Rt(k(e)),this.parentInfoDecoder=new Ft(k(e),kt),this.typeRefDecoder=new It(k(e)),this.lenDecoder=new It(k(e))}readLeftID(){return new la(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new la(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 Pt(this.restDecoder)}readBuf(){return k(this.restDecoder)}readJSON(){return Pt(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}}},Li=class{constructor(){this.restEncoder=et()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},Ri=class extends Li{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){it(this.restEncoder,e)}writeString(e){ct(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){gt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){ct(this.restEncoder,JSON.stringify(e))}writeKey(e){ct(this.restEncoder,e)}},zi=class{constructor(){this.restEncoder=et(),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}},Bi=class extends zi{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new xt,this.clientEncoder=new yt,this.leftClockEncoder=new xt,this.rightClockEncoder=new xt,this.infoEncoder=new _t(it),this.stringEncoder=new St,this.parentInfoEncoder=new _t(it),this.typeRefEncoder=new yt,this.lenEncoder=new yt}toUint8Array(){let e=et();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()),lt(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){gt(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){gt(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)}},Vi=(e,t,n,r)=>{r=x(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)},Hi=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{z(t,n)>e&&r.set(n,e)}),ka(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),v(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Vi(e,t.clients.get(n),n,r)})},Ui=(e,t)=>{let n=h(),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,Xs(e,r));i[n]=c,o+=c.length}}}}return n},Wi=(e,t,n)=>{let r=[],i=v(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Oa,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=g(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 Bi;return Hi(e,s,new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Gi=(e,t)=>Hi(e,t.doc.store,t.beforeState),Ki=(e,t,n,r=new Ii(e))=>H(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Wi(e,i,Ui(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=Qa([o.update,a.update])}}else i.pendingStructs=a;let s=Ai(r,e,i);if(i.pendingDs){let t=new Ii(Et(i.pendingDs));A(t.restDecoder);let n=Ai(t,e,i);s&&n?i.pendingDs=Qa([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,qi(e.doc,t)}},n,!1),qi=(e,t,n,r=Ii)=>{let i=Et(t);Ki(i,e,n,new r(i))},Ji=(e,t,n)=>qi(e,t,n,Pi),Yi=(e,t,n=new Map)=>{Hi(e,t.store,n),Oi(e,Di(t.store))},Xi=(e,t=new Uint8Array([0]),n=new Bi)=>{Yi(n,e,$i(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push($a(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Ri)return Xa(r.map((e,t)=>t===0?e:io(e)));if(n.constructor===Bi)return Qa(r)}return r[0]},Zi=(e,t)=>Xi(e,t,new Ri),Qi=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},$i=e=>Qi(new Ni(Et(e))),ea=(e,t)=>(w(e.restEncoder,t.size),v(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),ta=(e,t)=>ea(e,ka(t.store)),na=(e,t=new zi)=>(e instanceof Map?ea(t,e):ta(t,e),t.toUint8Array()),ra=e=>na(e,new Li),ia=class{constructor(){this.l=[]}},aa=()=>new ia,oa=(e,t)=>e.l.push(t),sa=(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.`)},ca=(e,t,n)=>un(e.l,[t,n]),la=class{constructor(e,t){this.client=e,this.clock=t}},ua=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,R=(e,t)=>new la(e,t),da=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw O()},fa=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},pa=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ma=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},ha=e=>new pa(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),ga=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},_a=(e,t,n=0)=>new ga(e,t,n),va=(e,t,n)=>{let r=null,i=null;return e._item===null?i=da(e):r=R(e._item.id.client,e._item.id.clock),new pa(r,i,t,n)},ya=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return va(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return va(e,R(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return va(e,r.lastId,n);r=r.right}return va(e,null,n)},ba=(e,t)=>{let n=ja(e,t);return{item:n,diff:t.clock-n.id.clock}},xa=(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?Gs(r,i):ba(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?Gs(r,a):{item:ja(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 _a(c,l,e.assoc)},Sa=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&ua(e.item,t.item)&&ua(e.type,t.type)&&e.assoc===t.assoc,Ca=class{constructor(e,t){this.ds=e,this.sv=t}},wa=(e,t)=>new Ca(e,t);wa(Ei(),new Map);var Ta=e=>wa(Di(e.store),ka(e.store)),Ea=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Si(t.ds,e.id),Da=(e,t)=>{let n=g(e.meta,Da,_),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<z(r,n)&&V(e,R(n,t))}),bi(e,t.ds,e=>{}),n.add(t))},Oa=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},ka=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},Aa=(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=b(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=b((n+r)/2)}throw O()},ja=(e,t)=>{let n=e.clients.get(t.client);return n[B(n,t.clock)]},Ma=(e,t,n)=>{let r=B(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,qs(e,i,n-i.id.clock)),r+1):r},V=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ma(e,n,t.clock)]},Na=(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,qs(e,a,n.clock-a.id.clock+1)),a},Pa=(e,t,n)=>{let r=e.clients.get(t.id.client);r[B(r,t.id.clock)]=n},Fa=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Ma(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Ma(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ia=class{constructor(e,t,n){this.doc=e,this.deleteSet=new yi,this.beforeState=ka(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}},La=(e,t)=>t.deleteSet.clients.size===0&&!he(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Ci(t.deleteSet),Gi(e,t),Oi(e,t.deleteSet),!0),Ra=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&g(e.changed,t,_).add(n)},za=(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},Ba=(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)}}}},Va=(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=we(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+za(r,e)}})},Ha=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Ci(a),n.afterState=ka(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(()=>{ca(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&ns(n)})}),un(e,[])}finally{r.gc&&Ba(a,i,r.gcFilter),Va(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=x(B(e,r),1);for(let t=e.length-1;t>=n;)t-=1+za(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&&za(r,a+1)>1||a>0&&za(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(fi(si,ei,`[yjs] `,ti,ai,`Changed the client-id because another client seems to be using it.`),r.clientID=ji()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Ri;La(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Bi;La(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])):Ha(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 Ia(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&&Ha(i,0)}}return o},Ua=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Wa=(e,t,n)=>{bi(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||fa(t,n))&&Ks(n,!1)})},Ga=(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;bi(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=Gs(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||fa(t,e))&&c.push(e)}}),bi(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||fa(t,e))&&!Si(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Ys(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},Ka=class extends xe{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=y(e)?e[0].doc:e instanceof Mi?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 yi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Ti(i,n,r,a)});let a=Gt(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=wi([t.deletions,e.deleteSet]),t.insertions=wi([t.insertions,i])}else r.push(new Ua(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),bi(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||fa(n,t))&&Ks(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=y(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof W?e.doc!==this.doc:e!==this.doc)&&pi(`[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=>Wa(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Wa(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=Ga(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ga(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*qa(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,Xs(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new G(R(n,r),t),r+=t}}}}var Ja=class{constructor(e,t){this.gen=qa(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}},Ya=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Xa=e=>Qa(e,Pi,Ri),Za=(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))}},Qa=(e,t=Ii,n=Bi)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Et(e))),i=r.map(e=>new Ja(e,!0)),a=null,o=new n,s=new Ya(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)to(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{to(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=Za(n,t)),a.struct.mergeWith(n)||(to(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())to(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(to(s,a.struct,a.offset),a=null),no(s),Oi(o,wi(r.map(e=>ki(e)))),o.toUint8Array()},$a=(e,t,n=Ii,r=Bi)=>{let i=$i(t),a=new r,o=new Ya(a),s=new n(Et(e)),c=new Ja(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(to(o,e,x(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)to(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 no(o),Oi(a,ki(s)),a.toUint8Array()},eo=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=et(),e.written=0)},to=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&eo(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++},no=e=>{eo(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),lt(t,r.restEncoder)}},ro=(e,t,n,r)=>{let i=new n(Et(e)),a=new Ja(i,!1),o=new r,s=new Ya(o);for(let e=a.curr;e!==null;e=a.next())to(s,t(e),0);return no(s),Oi(o,ki(i)),o.toUint8Array()},io=e=>ro(e,dn,Ii,Ri),ao=`You must not compute changes after the event-handler fired.`,oo=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||=so(this.currentTarget,this.target)}deletes(e){return Si(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(ao);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=ge(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=ge(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=ge(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(ao);let t=this.target,n=_(),r=_(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},so=(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=()=>{pi(`Invalid access: Add Yjs type to a document before reading data.`)},co=80,lo=0,uo=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=lo++}},fo=e=>{e.timestamp=lo++},po=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=lo++},mo=(e,t,n)=>{if(e.length>=co){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return po(r,t,n),r}else{let r=new uo(t,n);return e.push(r),r}},ho=(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)=>Ce(t-e.index)<Ce(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,fo(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&&Ce(n.index-i)<r.parent.length/co?(po(n,r,i),n):mo(e._searchMarker,r,i)},go=(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=x(t,i.index+n))}},_o=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;g(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ca(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=aa(),this._dEH=aa(),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){oa(this._eH,e)}observeDeep(e){oa(this._dEH,e)}unobserve(e){sa(this._eH,e)}unobserveDeep(e){sa(this._dEH,e)}toJSON(){}},vo=(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},yo=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},bo=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ea(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},xo=(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}},So=(e,t)=>{let n=[];return xo(e,(r,i)=>{n.push(t(r,i,e))}),n},Co=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}}}},wo=(e,t)=>{e.doc??U();let n=ho(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}},To=(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 Ms(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 ys(new Uint8Array(n))),i.integrate(e,0);break;case Mi:i=new J(R(o,z(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ws(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()},Eo=()=>E(`Length exceeded!`),Do=(e,t,n,r)=>{if(n>t._length)throw Eo();if(n===0)return t._searchMarker&&go(t._searchMarker,n,r.length),To(e,t,null,r);let i=n,a=ho(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&&go(t._searchMarker,i,r.length),To(e,t,o,r)},Oo=(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 To(e,t,r,n)},ko=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=ho(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 Eo();t._searchMarker&&go(t._searchMarker,i,-a+r)},Ao=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},jo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Ms([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Ms([r]);break;case Uint8Array:s=new ys(r);break;case Mi:s=new ws(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)},Mo=(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},No=e=>{let t={};return e.doc??U(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Po=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted},Fo=(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&&Ea(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Io=e=>(e.doc??U(),gi(e._map.entries(),e=>!e[1].deleted)),Lo=class extends oo{},Ro=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),_o(this,e,new Lo(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{Do(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):H(this.doc,t=>{Oo(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=>{ko(n,this,e,t)})}get(e){return wo(this,e)}toArray(){return yo(this)}slice(e=0,t=this.length){return vo(this,e,t)}toJSON(){return this.map(e=>e instanceof W?e.toJSON():e)}map(e){return So(this,e)}forEach(e){xo(this,e)}[Symbol.iterator](){return Co(this)}_write(e){e.writeTypeRef(Ls)}},zo=e=>new Ro,Bo=class extends oo{constructor(e,t,n){super(e,t),this.keysChanged=n}},Vo=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){_o(this,e,new Bo(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[...Io(this)].length}keys(){return _i(Io(this),e=>e[0])}values(){return _i(Io(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return _i(Io(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=>{Ao(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):H(this.doc,n=>{jo(n,this,e,t)}),t}get(e){return Mo(this,e)}has(e){return Po(this,e)}clear(){this.doc===null?this._prelimContent.clear():H(this.doc,e=>{this.forEach(function(t,n,r){Ao(e,r,n)})})}_write(e){e.writeTypeRef(Rs)}},Ho=e=>new Vo,Uo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&sn(e,t),Wo=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||Jo(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}},Go=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case K:t.right.deleted||Jo(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},Ko=(e,t,n,r)=>{let i=new Map,a=r?ho(t,n):null;return a?Go(e,new Wo(a.p.left,a.p,a.index,i),n-a.index):Go(e,new Wo(null,t._start,0,i),n)},qo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===K&&Uo(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()})},Jo=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Yo=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===K&&Uo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Xo=(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(!Uo(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},Zo=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Yo(n,i);let s=Xo(e,t,n,i),c=r.constructor===String?new Ps(r):r instanceof W?new q(r):new Es(r),{left:l,right:u,index:d}=n;t._searchMarker&&go(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(),qo(e,t,n,s)},Qo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Yo(n,i);let s=Xo(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(Uo(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+=`
|
|
3
3
|
`;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 Ps(i)),n.right.integrate(e,0),n.forward()}qo(e,t,n,s)},$o=(e,t,n,r,i)=>{let a=t,o=h();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&&Jo(i,n);break}}}t=t.right}return s},es=(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}},ts=e=>{let t=0;return H(e.doc,n=>{let r=e._start,i=e._start,a=h(),o=pe(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case K:Jo(o,i.content);break;default:t+=$o(n,r,i,a,o),a=pe(o),r=i;break}i=i.right}}),t},ns=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&&Fa(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=>{bi(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):es(n,e)});for(let e of t)ts(e)})},rs=(e,t,n)=>{let r=n,i=pe(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case q:case Es:case Ps: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&&$o(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&go(o._searchMarker,t.index,-r+n),t},is=class extends oo{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},rn(o)||(e.attributes=$t({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case q:case Es: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 Ps: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)||(Uo(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Uo(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;Uo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Uo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Jo(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}},as=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 is(this,e,t);_o(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===Ps&&(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 Wo(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
4
4
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Zo(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&rs(n,r,a.delete):Qo(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(Ea(s,e)||t!==void 0&&Ea(s,t))switch(s.content.constructor){case Ps:{let r=i.get(`ychange`);e!==void 0&&!Ea(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&&!Ea(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 Es:{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:Ea(s,e)&&(c(),Jo(i,s.content));break}s=s.right}c()};return e||t?H(a,n=>{e&&Da(n,e),t&&Da(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=Ko(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Zo(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=Ko(r,this,e,!n);Zo(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=>{rs(n,Ko(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=Ko(r,this,e,!1);i.right!==null&&Qo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):H(this.doc,t=>{Ao(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):H(this.doc,n=>{jo(n,this,e,t)})}getAttribute(e){return Mo(this,e)}getAttributes(){return No(this)}_write(e){e.writeTypeRef(zs)}},os=e=>new as,ss=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===us||t.constructor===cs)&&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})}},cs=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 ss(this,e)}querySelector(e){e=e.toUpperCase();let t=new ss(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),v(new ss(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){_o(this,e,new fs(this,t,e))}toString(){return So(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),xo(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=>{Do(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)H(this.doc,n=>{let r=e&&e instanceof W?e._item:e;To(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=>{ko(n,this,e,t)})}toArray(){return yo(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return wo(this,e)}slice(e=0,t=this.length){return vo(this,e,t)}forEach(e){xo(this,e)}_write(e){e.writeTypeRef(Vs)}},ls=e=>new cs,us=class e extends cs{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 tn(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=>{Ao(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):H(this.doc,n=>{jo(n,this,e,t)})}getAttribute(e){return Mo(this,e)}hasAttribute(e){return Po(this,e)}getAttributes(e){return e?Fo(this,e):No(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 xo(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Bs),e.writeKey(this.nodeName)}},ds=e=>new us(e.readKey()),fs=class extends oo{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)})}},ps=class e extends Vo{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(Hs),e.writeKey(this.hookName)}},ms=e=>new ps(e.readKey()),hs=class e extends as{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(Us)}},gs=e=>new hs,_s=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()}},vs=0,G=class extends _s{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),Aa(e.doc.store,this)}write(e,t){e.writeInfo(vs),e.writeLen(this.length-t)}getMissing(e,t){return null}},ys=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}},bs=e=>new ys(e.readBuf()),xs=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){Ti(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}},Ss=e=>new xs(e.readLen()),Cs=(e,t)=>new Mi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),ws=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(Cs(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}},Ts=e=>new ws(Cs(e.readString(),e.readAny())),Es=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}},Ds=e=>new Es(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}},Os=e=>new K(e.readKey(),e.readJSON()),ks=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}},As=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 ks(n)},js=yn(`node_env`)===`development`,Ms=class e{constructor(e){this.arr=e,js&&ln(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}},Ns=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Ms(n)},Ps=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}},Fs=e=>new Ps(e.readString()),Is=[zo,Ho,os,ds,ls,ms,gs],Ls=0,Rs=1,zs=2,Bs=3,Vs=4,Hs=5,Us=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}},Ws=e=>new q(Is[e.readTypeRef()](e)),Gs=(e,t)=>{let n=t,r=0,i;do r>0&&(n=R(n.client,n.clock+r)),i=ja(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},Ks=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},qs=(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},Js=(e,t)=>ye(e,e=>Si(e.deletions,t)),Ys=(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)||Ys(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||Si(r,d.right.id)||Js(a.undoStack,d.right.id)||Js(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)),p=new J(te,d,d&&d.lastId,f,f&&f.id,ee,t.parentSub,t.content.copy());return t.redone=te,Ks(p,!0),p.integrate(e,0),p},J=class e extends _s{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===la&&this.id.client!==this.parent.client&&this.parent.clock>=z(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Na(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===la){let e=ja(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=Na(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),ua(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ua(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(ja(e.doc.store,n.origin)))r.has(ja(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),Aa(e.doc.store,this),this.content.integrate(e,this),Ra(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&&ua(e.origin,this.lastId)&&this.right===e&&ua(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(),Ti(e.deleteSet,this.id.client,this.id.clock,this.length),Ra(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw O();this.content.gc(e),t?Pa(e,this,new G(this.id,this.length)):this.content=new xs(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=da(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===la?(e.writeParentInfo(!1),e.writeLeftID(t)):O();i!==null&&e.writeString(i)}this.content.write(e,t)}},Xs=(e,t)=>Zs[t&31](e),Zs=[()=>{O()},Ss,As,bs,Fs,Ds,Os,Ws,Ns,Ts,()=>{O()}],Qs=10,Y=class extends _s{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(Qs),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}},$s=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},ec=`__ $YJS$ __`;$s[ec]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),$s[ec]=!0;var tc=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),nc=(e,t)=>{w(e,tc.Token),ct(e,t)},rc=(e,t,n,r)=>{switch(A(e)){case tc.Token:t();break;case tc.PermissionDenied:n(jt(e));break;case tc.Authenticated:r(jt(e));break;default:}},ic=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),ac=`\0`;function oc(e,t){return e+ac+t}function sc(e){let t=e.indexOf(ac);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var cc=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 lc(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 uc(e){return new Promise(t=>setTimeout(t,e))}function dc(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 fc(e,t){let n=lc(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||dc;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 uc(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 uc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await uc(e)}return a()}var pc=Math.floor,mc=(e,t)=>e<t?e:t,hc=(e,t)=>e>t?e:t;Number.isNaN;var gc=64,_c=128,vc=1<<17,yc=1<<18,bc=1<<19,xc=1<<20,Sc=1<<21,Cc=1<<22,wc=1<<23,Tc=1<<24,Ec=1<<25,Dc=1<<26,Oc=1<<27,kc=1<<28,Ac=1<<29,jc=1<<30,Mc=63,Nc=127;vc-1,yc-1,bc-1,xc-1,Sc-1,Cc-1,wc-1,Tc-1,Ec-1,Dc-1,Oc-1,kc-1,Ac-1,jc-1;var Pc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Fc=()=>new Set,Ic=Array.from;Array.isArray;var Lc=String.fromCharCode;String.fromCodePoint,Lc(65535);var Rc=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},zc=typeof TextEncoder<`u`?new TextEncoder:null,Bc=zc?e=>zc.encode(e):Rc,Vc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Vc&&Vc.decode(new Uint8Array).length===1&&(Vc=null);var Hc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Uc=()=>new Hc,Wc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Gc=e=>{let t=new Uint8Array(Wc(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},Kc=(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>Nc;)Kc(e,_c|Nc&t),t=pc(t/128);Kc(e,Nc&t)},qc=new Uint8Array(3e4),Jc=qc.length/3,Z=zc&&zc.encodeInto?(e,t)=>{if(t.length<Jc){let n=zc.encodeInto(t,qc).written||0;X(e,n);for(let t=0;t<n;t++)Kc(e,qc[t])}else Xc(e,Bc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)Kc(e,n.codePointAt(t))},Yc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=mc(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(hc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Xc=(e,t)=>{X(e,t.byteLength),Yc(e,t)},Zc=e=>Error(e),Qc=Zc(`Unexpected end of array`),$c=Zc(`Integer out of Range`),el=class{constructor(e){this.arr=e,this.pos=0}},tl=e=>new el(e),nl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},rl=e=>nl(e,al(e)),il=e=>e.arr[e.pos++],al=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Nc)*n,n*=128,r<_c)return t;if(t>Pc)throw $c}throw Qc},ol=e=>{let t=e.arr[e.pos++],n=t&Mc,r=64,i=(t&gc)>0?-1:1;if((t&_c)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Nc)*r,r*=128,t<_c)return i*n;if(n>Pc)throw $c}throw Qc},sl=Vc?e=>Vc.decode(rl(e)):e=>{let t=al(e);if(t===0)return``;{let n=String.fromCodePoint(il(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(il(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))}},cl=e=>{let t=e.pos,n=sl(e);return e.pos=t,n},ll=Date.now,ul=()=>new Map,dl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},fl=class{constructor(){this._observers=ul()}on(e,t){dl(this._observers,e,Fc).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 Ic((this._observers.get(e)||ul()).values()).forEach(e=>e(...t))}destroy(){this._observers=ul()}},pl=Symbol(`Equality`),ml=Object.keys,hl=e=>ml(e).length,gl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_l=(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[pl]!=null)return e[pl](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)||!_l(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(hl(e)!==hl(t))return!1;for(let n in e)if(!gl(e,n)||!_l(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(!_l(e[n],t[n]))return!1;break;default:return!1}return!0},vl=3e4,yl=class extends fl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=ll();this.getLocalState()!==null&&vl/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&vl<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&bl(this,t,`timeout`)},pc(vl/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:ll()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),_l(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}},bl=(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:ll()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},xl=(e,t,n=e.states)=>{let r=t.length,i=Uc();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 Gc(i)},Sl=(e,t,n)=>{let r=tl(t),i=ll(),a=[],o=[],s=[],c=[],l=al(r);for(let t=0;t<l;t++){let t=al(r),n=al(r),l=JSON.parse(sl(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&&(_l(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])},Cl=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={}}},wl=class{constructor(e){this.data=e,this.encoder=Uc(),this.decoder=tl(new Uint8Array(this.data))}peekVarString(){return cl(this.decoder)}readVarUint(){return al(this.decoder)}readVarString(){return sl(this.decoder)}readVarUint8Array(){return rl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return Xc(this.encoder,e)}length(){return Wc(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}({}),Tl=class{constructor(){this.encoder=Uc()}get(e){return e.encoder}toUint8Array(){return Gc(this.encoder)}},El=class extends Tl{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}},Dl=class e extends Cl{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(El,{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:fc(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=ll();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new wl(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=Uc();X(e,Q.Pong),this.send(Gc(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>=ll()-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=tl(e);return{documentName:sl(t),messageType:al(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===cc.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()}},Ol=0,kl=1,Al=2,jl=(e,t)=>{X(e,Ol),Xc(e,ra(t))},Ml=(e,t,n)=>{X(e,kl),Xc(e,Zi(t,n))},Nl=(e,t,n)=>Ml(t,n,rl(e)),Pl=(e,t,n,r)=>{try{Ji(t,rl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Fl=(e,t)=>{X(e,Al),Xc(e,t)},Il=Pl,Ll=(e,t,n,r,i)=>{let a=al(e);switch(a){case Ol:Nl(e,t,n);break;case kl:Pl(e,n,r,i);break;case Al:Il(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Rl=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(sl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,ol(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:sl(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(Tl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=Ll(n.decoder,n.encoder,e.document,e);t&&r===kl&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Sl(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;rc(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(xl(e.awareness,Array.from(e.awareness.getStates().keys())))}},zl=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Gc(this.encoder)}send(e){e?.send(this.create())}},Bl=`4.0.0-rc.1`,Vl=class extends Tl{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),nc(this.encoder,e.token),Z(this.encoder,Bl),this.encoder}},Hl=class extends Tl{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?xl(e.awareness,e.clients):xl(e.awareness,e.clients,e.states),Xc(this.encoder,t),this.encoder}},Ul=class extends Tl{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}},Wl=class extends Tl{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),jl(this.encoder,e.document),this.encoder}},Gl=class extends Tl{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),Fl(this.encoder,e.update),this.encoder}},Kl=class extends Error{constructor(...e){super(...e),this.code=1001}},ql=class extends Cl{get effectiveName(){return this.configuration.sessionAwareness?oc(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 Mi,this.configuration.awareness=e.awareness===void 0?new yl(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:ic(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:ic(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 Dl(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(Wl,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&bl(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Ul,{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(Vl,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(Gl,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Hl,{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(Wl,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Hl,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new zl(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new wl(e.data),{documentName:n}=sc(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new wl(e.data)}),new Rl(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&bl(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&&(bl(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 Kl(`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 Jl(e,t,n=null,r=null){let i={...p()};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 Yl(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 Xl(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 Zl(e){return Xl(e)??Yl(e)}function Ql(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:Zl(e)}finally{t.remove()}}function $l(){if(!(typeof document>`u`))try{let e=Ql(`--sidebar`),t=Ql(`--sidebar-foreground`);return!e||!t?void 0:{bg:e,symbol:t}}catch{return}}function eu(e,t,n){let r=(0,oe.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:$l()})}),()=>{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:$l()})};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)}function tu(e){let t=(0,oe.c)(5),{setTheme:n}=r(),i;t[0]!==n||t[1]!==e?(i=()=>{(e===`light`||e===`dark`||e===`system`)&&n(e)},t[0]=n,t[1]=e,t[2]=i):i=t[2];let a;t[3]===e?a=t[4]:(a=[e],t[3]=e,t[4]=a),(0,m.useEffect)(i,a)}var nu=t();function ru(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function iu(e,t,n,r){let i=new Mi,a=new ql({url:e,name:t,document:i,token:Jl(null,r,null),onDisconnect:({event:e})=>ru(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>ru(`config-provider`,t,`close`,e)}),o=l(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function au(e,t){let n=new Mi,r=new ql({url:e,name:u,document:n,token:Jl(null,t,null),onDisconnect:({event:e})=>ru(`okignore-provider`,u,`disconnect`,e),onClose:({event:e})=>ru(`okignore-provider`,u,`close`,e)}),i=c(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function ou(e){let t=(0,oe.c)(20),{collabUrl:n,children:i}=e,c=fe(),{systemTheme:l}=r(),u=l===`dark`,[p,se]=(0,m.useState)(null),[ce,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)(null),[h,pe]=(0,m.useState)(null),g,me;t[0]!==n||t[1]!==c?(g=()=>{if(n===null)return;let e=iu(n,ee,`user`,c),t=iu(n,d,`project`,c),r=iu(n,te,`project-local`,c),i=au(n,c);se({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),le({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),de({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),pe({binding:i.binding,synced:!1});let a=e.binding.subscribe(t=>{se(n=>n?.binding===e.binding?{...n,config:t}:n)}),o=e.binding.subscribeSynced(()=>{se(t=>t?.binding===e.binding?{...t,synced:!0}:t)}),s=t.binding.subscribe(e=>{le(n=>n?.binding===t.binding?{...n,config:e}:n)}),l=t.binding.subscribeSynced(()=>{le(e=>e?.binding===t.binding?{...e,synced:!0}:e)}),u=r.binding.subscribe(e=>{de(t=>t?.binding===r.binding?{...t,config:e}:t)}),f=r.binding.subscribeSynced(()=>{de(e=>e?.binding===r.binding?{...e,synced:!0}:e)}),p=()=>{pe(e=>e?.binding===i.binding?{...e,synced:!0}:e)};return i.provider.on(`synced`,p),()=>{a(),o(),s(),l(),u(),f(),i.provider.off(`synced`,p);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)}))}se(t=>t?.binding===e.binding?null:t),le(e=>e?.binding===t.binding?null:e),de(e=>e?.binding===r.binding?null:e),pe(e=>e?.binding===i.binding?null:e)}},me=[n,c],t[0]=n,t[1]=c,t[2]=g,t[3]=me):(g=t[2],me=t[3]),(0,m.useEffect)(g,me);let he=p&&ce?o(p.config,ce.config,ue?.config):null,_=he?.appearance?.theme,ge=he?.appearance?.customTheme,_e=he?.appearance?.colorThemeEnabled!==!1,v=s(he?.appearance),ve=a(_,u),ye=_e?v[ve]:`default`,be=ye===`custom`?ae(ne(ge)):f(ye)??_;tu(be),re({selection:v,modePreference:_,slotMode:ve,customSeed:ge,enabled:_e}),eu(typeof window<`u`?window.okDesktop:void 0,be??`system`,`${ye}:${ye===`custom`?JSON.stringify(ge??null):``}`);let y=p?.binding??null,xe=p?.synced??!1,Se=ce?.binding??null,b=ue?.binding??null,Ce=h?.binding??null,we=h?.synced??!1,x=p?.config??null,Te=ce?.config??null,Ee=ce?.synced??!1,De=ue?.config??null,Oe=ue?.synced??!1,ke;t[4]!==he||t[5]!==Te||t[6]!==Ee||t[7]!==De||t[8]!==Oe||t[9]!==y||t[10]!==xe||t[11]!==Se||t[12]!==b||t[13]!==Ce||t[14]!==we||t[15]!==x?(ke={userBinding:y,userSynced:xe,projectBinding:Se,projectLocalBinding:b,okignoreBinding:Ce,okignoreSynced:we,userConfig:x,projectConfig:Te,projectSynced:Ee,projectLocalConfig:De,projectLocalSynced:Oe,merged:he},t[4]=he,t[5]=Te,t[6]=Ee,t[7]=De,t[8]=Oe,t[9]=y,t[10]=xe,t[11]=Se,t[12]=b,t[13]=Ce,t[14]=we,t[15]=x,t[16]=ke):ke=t[16];let Ae=ke,je;return t[17]!==i||t[18]!==Ae?(je=(0,nu.jsx)(ie,{value:Ae,children:i}),t[17]=i,t[18]=Ae,t[19]=je):je=t[19],je}export{x as $,Si as A,Gr as B,ya as C,ra as D,Zi as E,H as F,an as G,En as H,bo as I,Ht as J,en as K,$r as L,bi as M,ma as N,B as O,Ta as P,Re as Q,I as R,ha as S,$i as T,wn as U,M as V,hn as W,D as X,E as Y,O as Z,qi as _,K as a,ue as at,Ei as b,Mi as c,Ca as d,we as et,Ka as f,Ji as g,hs as h,ql as i,g as it,fa as j,da as k,J as l,us as m,eu as n,_ as nt,Ps as o,as as p,Kt as q,Jl as r,h as rt,q as s,ou as t,Se as tt,pa as u,Sa as v,wa as w,R as x,xa as y,Wr as z};
|
|
@@ -505,7 +505,7 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
505
505
|
`);for(let e=0;e<r.length;e++)r[e]&&t.push({type:`text`,value:r[e]??``}),e<r.length-1&&t.push({type:`element`,tagName:`br`,properties:{},children:[]})}e.children=t}function u0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){e.children=e.children.filter(e=>e.type===`comment`?!o0.test(String(e.value??``)):!0);for(let t of e.children)t.type===`element`&&u0(t)}}var d0=new Set([`Apple-tab-span`,`Apple-converted-space`,`Apple-style-span`]),f0=()=>e=>{p0(e)};function p0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&p0(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return m0(t)?[]:h0(t)?t.children:[t]})}}function m0(e){if(e.tagName!==`meta`)return!1;let t=e.properties?.name,n=e.properties?.content;return t===`Generator`&&typeof n==`string`&&/Cocoa/i.test(n)}function h0(e){if(e.tagName!==`span`)return!1;let t=e.properties?.className;return Array.isArray(t)?t.length>0&&t.every(e=>d0.has(String(e))):!1}var g0=`docs-internal-guid-`;function _0(e,t){let n=e.children[t];!n||n.type!==`element`||e.children.splice(t,1,...n.children)}var v0=()=>e=>{y0(e)};function y0(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&y0(t);let t=0;for(;t<e.children.length;){let n=e.children[t];if(!n||n.type!==`element`){t++;continue}let r=n;if(b0(r)||x0(r)){_0(e,t);continue}t++}}function b0(e){if(e.tagName!==`b`)return!1;let t=e.properties?.id;return typeof t==`string`&&t.startsWith(g0)}function x0(e){if(e.tagName!==`div`||e.properties?.dir!==`ltr`)return!1;let t=e.children.filter(e=>e.type===`element`);return t.length===1?t[0]?.tagName===`table`:!1}var S0=new Set([`commit-link`,`user-mention`,`team-mention`,`issue-link`]),C0=()=>e=>{w0(e)};function w0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&w0(t);for(let t of e.children)t.type===`element`&&T0(t)}}function T0(e){if(!e.properties)return;for(let t of Object.keys(e.properties))t.startsWith(`dataHovercard`)&&delete e.properties[t];let t=e.properties.className;if(Array.isArray(t)){let n=t.filter(e=>!S0.has(String(e)));n.length===0?delete e.properties.className:e.properties.className=n}}var E0=/^gmail_/,D0=()=>e=>{O0(e)};function O0(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&O0(t);let t=0;for(;t<e.children.length;){let n=e.children[t];if(n.type!==`element`){t++;continue}let r=n;if(r.tagName===`div`&&k0(r,`gmail_quote`)&&(r.tagName=`blockquote`),A0(r),j0(r)){e.children.splice(t,1,...r.children);continue}t++}}function k0(e,t){let n=e.properties?.className;return Array.isArray(n)?n.some(e=>String(e)===t):!1}function A0(e){let t=e.properties?.className;if(!Array.isArray(t))return;let n=t.filter(e=>!E0.test(String(e)));n.length===0?delete e.properties?.className:e.properties&&(e.properties.className=n)}function j0(e){if(e.tagName!==`div`||e.properties?.dir!==`ltr`)return!1;let t=e.properties?.className;return t!=null&&!(Array.isArray(t)&&t.length===0)?!1:e.children.filter(e=>e.type===`element`).length<=1}var M0=()=>e=>{N0(e)};function N0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&N0(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return t.tagName===`google-sheets-html-origin`?t.children:t.tagName===`style`?[]:(P0(t),[t])})}}function P0(e){if(e.properties)for(let t of Object.keys(e.properties))t.startsWith(`dataSheets`)&&delete e.properties[t]}var F0=[`o:`,`w:`,`m:`,`v:`,`u1:`],I0=/^Mso[A-Z]/,L0=/^\s*\[if\s+[^\]]*\]/,R0=()=>e=>{z0(e)};function z0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&z0(t);e.children=e.children.flatMap(e=>{if(e.type===`comment`){let t=String(e.value??``);return L0.test(t)?[]:[e]}if(e.type!==`element`)return[e];let t=e;return B0(t)?[]:(V0(t),[t])})}}function B0(e){return F0.some(t=>e.tagName.startsWith(t))}function V0(e){let t=e.properties;if(!t)return;let n=t.className;if(Array.isArray(n)){let e=n.filter(e=>typeof e==`string`&&!I0.test(e));e.length===0?delete t.className:t.className=e}else typeof n==`string`&&I0.test(n)&&delete t.className;let r=t.style;typeof r==`string`&&/mso-/i.test(r)&&delete t.style;for(let e of Object.keys(t))if(e.startsWith(`xmlns:`)){let n=e.slice(6);F0.some(e=>e===`${n}:`)&&delete t[e]}}var H0=/^c-(message_kit__|message__|compose|timestamp)/,U0=()=>e=>{W0(e)};function W0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&W0(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return G0(t)?[]:(K0(t),[t])})}}function G0(e){let t=e.properties?.className;return Array.isArray(t)?t.some(e=>String(e)===`c-timestamp`||String(e).startsWith(`c-timestamp`)):!1}function K0(e){let t=e.properties?.className;if(!Array.isArray(t))return;let n=t.filter(e=>!H0.test(String(e)));n.length===0?delete e.properties?.className:e.properties&&(e.properties.className=n)}var q0=()=>e=>{J0(e)};function J0(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&J0(t);for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.type!==`element`)continue;let r=n;Y0(r)&&(e.children[t]=Z0(r))}}}function Y0(e){if(e.tagName!==`div`)return!1;let t=e.children.filter(e=>e.type===`element`&&e.tagName===`div`);return t.length<2?!1:t.some(e=>X0(e))}function X0(e){for(let t of e.children){if(t.type!==`element`)continue;let e=t,n=e.properties?.style;if(typeof n==`string`&&/color\s*:/i.test(n)||X0(e))return!0}return!1}function Z0(e){return{type:`element`,tagName:`pre`,properties:{},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:e.children.filter(e=>e.type===`element`&&e.tagName===`div`).map(e=>Q0(e)).join(`
|
|
506
506
|
`)}]}]}}function Q0(e){let t=``;for(let n of e.children)n.type===`text`?t+=n.value??``:n.type===`element`&&(t+=Q0(n));return t}var $0=new Set([`break`,`delete`,`emphasis`,`footnoteReference`,`html`,`image`,`imageReference`,`inlineCode`,`link`,`linkReference`,`strong`,`text`]);function e2(e){let t=e.children;Array.isArray(t)&&t.forEach((e,n)=>{if(e.type===`break`){t[n]={type:`html`,value:`<br />`};return}e2(e)})}function t2(e){let t=e.children;if(Array.isArray(t))for(let e of t)(e.type===`inlineCode`||e.type===`html`)&&(e.value.includes(`
|
|
507
507
|
`)&&(e.value=e.value.replace(/[ \t]*\n[ \t]*/g,` `)),e.type===`html`&&e.value.includes(`|`)&&(e.value=e.value.replace(/\|/g,`\\|`))),t2(e)}function n2(e){D(e,`tableCell`,e=>{e.children.some(e=>!$0.has(e.type))&&(e.children=r2(e.children)),e2(e),t2(e)})}function r2(e){let t=[],n=0,r=()=>{t.length>0&&(n+=1)},i=e=>{for(;n>0;)t.push({type:`break`}),--n;t.push(e)},a=e=>{e.split(`
|
|
508
|
-
`).forEach((e,t)=>{t>0&&r(),e.length>0&&i({type:`text`,value:e})})},o=e=>{let t=e.ordered===!0,n=typeof e.start==`number`?e.start:1,a=e.data,o=typeof a?.bulletMarker==`string`?a.bulletMarker:`-`,c=typeof a?.listMarkerDelimiter==`string`?a.listMarkerDelimiter:`.`;e.children.forEach((e,a)=>{a>0&&r(),i({type:`text`,value:t?`${n+a}${c} `:`${o} `}),e.children.forEach((e,t)=>{t>0&&r(),s(e)})})},s=e=>{switch(e.type){case`paragraph`:case`heading`:e.children.forEach(i);return;case`list`:o(e);return;case`code`:case`html`:a(e.value);return;case`thematicBreak`:i({type:`text`,value:e.data?.sourceRaw??`---`});return;default:{let t=e;if(Array.isArray(t.children)&&t.children.length>0){t.children.forEach((e,t)=>{t>0&&r(),s(e)});return}let n=e;if(typeof n.value==`string`){a(n.value);return}console.warn(JSON.stringify({event:`table-cell-flatten-dropped-block`,nodeType:e.type}))}}};return e.forEach((e,t)=>{t>0&&r(),s(e)}),t}var i2=class extends Error{htmlBytes;maxBytes;constructor(e,t){super(`HTML payload (${e} bytes) exceeds htmlToMdast ceiling (${t} bytes); falling through to plain text`),this.name=`HtmlPayloadTooLargeError`,this.htmlBytes=e,this.maxBytes=t}},a2=[v0,R0,f0,D0,s0,q0,M0,U0,C0];function o2(e){D(e,e=>{e.type===`strong`?(e.data??={},e.data.sourceDelimiter=`**`):e.type===`emphasis`?(e.data??={},e.data.sourceDelimiter=`*`):e.type===`inlineCode`?(e.data??={},e.data.sourceFenceChar="`",e.data.sourceFenceLength=1):e.type===`code`&&(e.data??={},e.data.sourceFenceChar="`",e.data.sourceFenceLength=3)})}function s2(e){D(e,`list`,e=>{for(let t of e.children){let e=t.children.filter(e=>e.type!==`list`).length;t.spread=t.spread===!0&&e>1}e.spread=e.children.some(e=>e.spread===!0)})}var c2={u:u2(`u`),ins:u2(`ins`)},l2=`okUnderlineForm`;function u2(e){return(t,n)=>{let r={type:`emphasis`,children:t.all(n),data:{[l2]:e}};return t.patch(n,r),r}}function d2(e){let t=e=>{if(!Array.isArray(e.children))return;for(let n of e.children)t(n);let n=[];for(let t of e.children){let e=t.data?.[l2],r=t.children;if((e===`u`||e===`ins`)&&Array.isArray(r)){n.push({type:`html`,value:`<${e}>`}),n.push(...r),n.push({type:`html`,value:`</${e}>`});continue}n.push(t)}e.children=n};t(e)}function f2(e,t){let n=t?.maxBytes??5242880;if(e.length>n)throw new i2(e.length,n);let r=le().use(Pj,{fragment:!0});for(let e of a2)r.use(e);for(let e of t?.additionalCleanupPlugins??[])r.use(e);r.use(ZN,{handlers:c2});let i=r.parse(e),a=r.runSync(i);return s2(a),d2(a),o2(a),a}function p2(e){return n2(e),String(le().use(ue).use(wP,{bullet:`-`,rule:`-`,fences:!0}).stringify(e))}function m2(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}var h2=new Set([`sourceRaw`,`sourceDirty`,`position`]),g2=new Set([`jsxComponent`,`table`,`tableRow`,`tableCell`,`tableHeader`,`list`,`listItem`,`blockquote`,`codeBlock`,`heading`]),_2={type:`__br__`},v2=/^<br\s*\/?>$/i;function y2(e){let t=w2(e,y2);return(t.type===`tableCell`||t.type===`tableHeader`)&&t.content?{...t,content:b2(t.content)}:t}function b2(e){let t=[];for(let n of e){let e=x2(n);e.length!==0&&(t.length>0&&t.push(_2),t.push(...e))}return t}function x2(e){return e.text!==void 0||e.type===`hardBreak`||e.type===`jsxInline`?[e]:!e.content||e.content.length===0?[]:e.content.some(e=>e.text===void 0&&e.type!==`hardBreak`&&e.type!==`jsxInline`&&!!e.content)?b2(e.content):e.content}function S2(e){return e.type===`hardBreak`||e.type===_2.type||e.text!==void 0&&v2.test(e.text.trim())?_2:w2(e,S2)}var C2=[{label:`table-cell-block-flatten`,severity:`pm-model-caused`,rationale:`GFM table cells have no block spelling; a block placed in a cell is flattened to inline on serialize, so a cell-with-blocks and a cell-with-inline describe the same persisted document.`,proofPointer:`markdown/table-cell-flatten.ts flattenCellBlocks (table-cell-flatten-dropped-block event)`,canonicalize:y2},{label:`void-hardbreak-br`,severity:`serializer-caused`,rationale:`A void hardBreak inside a table cell or heading serializes to a literal <br /> that a fresh parse keeps as text; the node form and the literal form are the same break.`,proofPointer:`markdown/void-br-promoter.ts + markdown/to-markdown-handlers.ts break handler`,canonicalize:S2}];function w2(e,t){return e.content?{...e,content:e.content.map(t)}:e}function T2(e,t){let n={};e.type!==void 0&&(n.type=e.type),e.text!==void 0&&(n.text=e.text);let r=E2(e.attrs,t);return r&&(n.attrs=r),e.marks&&e.marks.length>0&&(n.marks=[...e.marks].map(e=>({type:e.type,attrs:E2(e.attrs,t)})).sort((e,t)=>O2(e).localeCompare(O2(t)))),e.content&&e.content.length>0&&(n.content=e.content.map(e=>T2(e,t))),n}function E2(e,t){if(!e)return null;let n={};for(let r of Object.keys(e).sort()){if(h2.has(r)||t?.(r))continue;let i=e[r];i!=null&&(n[r]=t?D2(i,t):i)}return Object.keys(n).length>0?n:null}function D2(e,t){if(Array.isArray(e))return e.map(e=>D2(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))t(r)||(n[r]=D2(i,t));return n}return e}function O2(e){return JSON.stringify(e,(e,t)=>{if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n of Object.keys(t).sort())e[n]=t[n];return e}return t})}function k2(e){let t=``,n=e=>{if(e.text!==void 0&&(t+=e.text),e.content)for(let t of e.content)n(t)};return n(e),t.replace(/\s+/g,``)}function A2(e){let t=[],n=e=>{if(e.type&&g2.has(e.type)){let n=e.type===`jsxComponent`?String(e.attrs?.componentName??``):``;t.push(n?`${e.type}:${n}`:e.type)}if(e.content)for(let t of e.content)n(t)};return n(e),t.sort()}function j2(e){let t=e,n=[];for(let e of C2){let r=O2(t),i=e.canonicalize(t);O2(i)!==r&&n.push(e.label),t=i}return{normalized:t,fired:n}}function M2(e,t,n={}){let r=j2(e),i=j2(t),a=[...new Set([...r.fired,...i.fired])];if(!m2(k2(r.normalized),k2(i.normalized)))return{equivalent:!1,level:`L1`,reason:`content-loss`,appliedDegrades:a,detail:`authored text did not survive the round-trip`};let o=A2(r.normalized),s=A2(i.normalized);if(O2(o)!==O2(s))return{equivalent:!1,level:`L1`,reason:`structural-shatter`,appliedDegrades:a,detail:`container multiset diverged: [${o.join(`, `)}] vs [${s.join(`, `)}]`};let c=T2(r.normalized,n.ignoreAttrs),l=T2(i.normalized,n.ignoreAttrs);return O2(c)===O2(l)?{equivalent:!0,level:a.length>0?`L2`:`L1`,appliedDegrades:a}:{equivalent:!1,level:`L2`,reason:`structural-divergence`,appliedDegrades:a,detail:N2(c,l)}}function N2(e,t,n=`doc`){let r=e,i=t;if(!r||!i)return`${n}: node presence differs`;if(r.type!==i.type)return`${n}: type ${String(r.type)} vs ${String(i.type)}`;let a=r.content??[],o=i.content??[];if(a.length!==o.length)return`${n}(${String(r.type)}): child count ${a.length} vs ${o.length}`;for(let e=0;e<a.length;e++)if(O2(a[e])!==O2(o[e]))return N2(a[e],o[e],`${n}>${String(r.type)}[${e}]`);return`${n}(${String(r.type)}): attrs or marks differ`}function P2(e,t,n){return!M2(e,t,{ignoreAttrs:n}).equivalent}var F2=new Set([`src`,`href`,`size`]),I2=new Set([`WikiEmbedImage`,`WikiEmbedVideo`,`WikiEmbedAudio`,`WikiEmbedFile`]);function L2(e){if(Array.isArray(e))return e.map(e=>L2(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))F2.has(n)||(t[n]=L2(r));return t}return e}function R2(e){return e.type===`jsxComponent`&&typeof e.attrs?.componentName==`string`&&I2.has(e.attrs.componentName)?L2(e):e.content?{...e,content:e.content.map(R2)}:e}function z2(e){if(Array.isArray(e))return e.map(e=>z2(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))n!==`position`&&(t[n]=z2(r));return t}return e}function B2(e){if(e.type===`jsxComponent`)return e;if(e.content)for(let t of e.content){let e=B2(t);if(e)return e}}function V2(e){let t=e.cacheLimit??2048,n=new Map,r=r=>{let i=n.get(r);if(i!==void 0)return i;let a=B2(e.parse(r)),o=a?R2(z2(a)):null;if(n.size>=t){let e=n.keys().next().value;e!==void 0&&n.delete(e)}return n.set(r,o),o};return{isDiverged(e){if(e.type!==`jsxComponent`||!e.attrs||e.attrs.kind===`expression`)return!1;let t=e.attrs.sourceRaw;if(typeof t!=`string`||t.length===0)return!1;let n=r(t);return n?P2(n,R2(z2(e))):!1}}}function H2(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}if(r>=0){let e=n[r];if(e.type===`mdxJsxAttribute`&&e.value!=null&&typeof e.value==`object`&&e.value.type===`mdxJsxAttributeValueExpression`&&U2(e.value.value,t))continue}let o=W2(e,t);r>=0?n[r]=o:n.push(o)}return n}function U2(e,t){try{return JSON.stringify(JSON.parse(e))===JSON.stringify(t)}catch{return!1}}function W2(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function G2(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:H2(t,r),children:n.all(t),data:{}}}function K2(e,t,n){let r=t.attrs.props?.children;return{type:`mdxJsxTextElement`,name:e,attributes:H2(t,n),children:typeof r==`string`&&r!==``?[{type:`text`,value:r}]:[],data:{}}}var q2=/^[A-Za-z0-9]{20,}$/,J2=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Y2(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function X2(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return q2.test(n)?n:null}function Z2(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Y2(t.hostname))return null;let n=X2(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&J2.test(r)?r:null}}function Q2(e){return Z2(e)!==null}function $2(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function e4(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:$2(t.hostname)}var t4=/^[A-Za-z0-9_-]{11}$/;function n4(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function r4(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function i4(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return t4.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return t4.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function a4(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!n4(t.hostname))return null;let n=i4(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?r4(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}var o4=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],s4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:td,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],c4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],l4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:nd,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:td,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&Q2(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(a4(e.src)!==null||e4(e.src)||Q2(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],u4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:rd,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],d4=[{name:`title`,type:`string`,required:!0,description:`Accordion heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the accordion renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],f4=[o4[0],o4[1],o4[4],o4[5],o4[6]],p4=[s4[0],s4[1],s4[7]],m4=[d4[0],d4[1],d4[4],d4[5]],h4=[{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`,`justify`],required:!1,defaultValue:`center`,description:"Block alignment from the `<div align>` attribute."},{name:`tag`,type:`string`,required:!1,defaultValue:`div`,hidden:!0,description:`Source wrapper tag (div or center).`},{name:`sourceAttrs`,type:`string`,required:!1,defaultValue:``,hidden:!0,description:`Raw opener-tag attribute bytes preserved for round-trip.`}],g4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],_4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],v4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],y4=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],b4=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],x4=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],S4=[x4[0]],C4=[x4[0]],w4=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],T4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],E4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],D4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:id,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],O4=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],k4=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function A4(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function j4(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function M4(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:a,data:{target:n,anchor:i,alias:r},children:[{type:`text`,value:a}]}}var N4=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:o4,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>G2(`Callout`,e,t,o4)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:s4,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>G2(`img`,e,t,s4)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:l4,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>G2(`video`,e,t,l4)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:u4,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>G2(`audio`,e,t,u4)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:D4,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>G2(`Pdf`,e,t,D4)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:E4,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>G2(`File`,e,t,E4)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:c4,icon:`AppWindow`,category:`media`,displayName:`Embed`,description:'Inline web embed (iframe) — drop a URL, get a resizable preview pane. For YouTube / Vimeo / Loom prefer `<video src="…">` (player props, click-facade); `<Embed>` auto-rewrites watch URLs as a fallback.',searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>G2(`Embed`,e,t,c4)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:d4,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`toggle`,`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>G2(`Accordion`,e,t,d4)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:y4,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
|
|
508
|
+
`).forEach((e,t)=>{t>0&&r(),e.length>0&&i({type:`text`,value:e})})},o=e=>{let t=e.ordered===!0,n=typeof e.start==`number`?e.start:1,a=e.data,o=typeof a?.bulletMarker==`string`?a.bulletMarker:`-`,c=typeof a?.listMarkerDelimiter==`string`?a.listMarkerDelimiter:`.`;e.children.forEach((e,a)=>{a>0&&r(),i({type:`text`,value:t?`${n+a}${c} `:`${o} `}),e.children.forEach((e,t)=>{t>0&&r(),s(e)})})},s=e=>{switch(e.type){case`paragraph`:case`heading`:e.children.forEach(i);return;case`list`:o(e);return;case`code`:case`html`:a(e.value);return;case`thematicBreak`:i({type:`text`,value:e.data?.sourceRaw??`---`});return;default:{let t=e;if(Array.isArray(t.children)&&t.children.length>0){t.children.forEach((e,t)=>{t>0&&r(),s(e)});return}let n=e;if(typeof n.value==`string`){a(n.value);return}console.warn(JSON.stringify({event:`table-cell-flatten-dropped-block`,nodeType:e.type}))}}};return e.forEach((e,t)=>{t>0&&r(),s(e)}),t}var i2=class extends Error{htmlBytes;maxBytes;constructor(e,t){super(`HTML payload (${e} bytes) exceeds htmlToMdast ceiling (${t} bytes); falling through to plain text`),this.name=`HtmlPayloadTooLargeError`,this.htmlBytes=e,this.maxBytes=t}},a2=[v0,R0,f0,D0,s0,q0,M0,U0,C0];function o2(e){D(e,e=>{e.type===`strong`?(e.data??={},e.data.sourceDelimiter=`**`):e.type===`emphasis`?(e.data??={},e.data.sourceDelimiter=`*`):e.type===`inlineCode`?(e.data??={},e.data.sourceFenceChar="`",e.data.sourceFenceLength=1):e.type===`code`&&(e.data??={},e.data.sourceFenceChar="`",e.data.sourceFenceLength=3)})}function s2(e){D(e,`list`,e=>{for(let t of e.children){let e=t.children.filter(e=>e.type!==`list`).length;t.spread=t.spread===!0&&e>1}e.spread=e.children.some(e=>e.spread===!0)})}var c2={u:u2(`u`),ins:u2(`ins`)},l2=`okUnderlineForm`;function u2(e){return(t,n)=>{let r={type:`emphasis`,children:t.all(n),data:{[l2]:e}};return t.patch(n,r),r}}function d2(e){let t=e=>{if(!Array.isArray(e.children))return;for(let n of e.children)t(n);let n=[];for(let t of e.children){let e=t.data?.[l2],r=t.children;if((e===`u`||e===`ins`)&&Array.isArray(r)){n.push({type:`html`,value:`<${e}>`}),n.push(...r),n.push({type:`html`,value:`</${e}>`});continue}n.push(t)}e.children=n};t(e)}function f2(e,t){let n=t?.maxBytes??5242880;if(e.length>n)throw new i2(e.length,n);let r=le().use(Pj,{fragment:!0});for(let e of a2)r.use(e);for(let e of t?.additionalCleanupPlugins??[])r.use(e);r.use(ZN,{handlers:c2});let i=r.parse(e),a=r.runSync(i);return s2(a),d2(a),o2(a),a}function p2(e){return n2(e),String(le().use(ue).use(wP,{bullet:`-`,rule:`-`,fences:!0}).stringify(e))}function m2(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}var h2=new Set([`sourceRaw`,`sourceDirty`,`position`]),g2=new Set([`jsxComponent`,`table`,`tableRow`,`tableCell`,`tableHeader`,`list`,`listItem`,`blockquote`,`codeBlock`,`heading`]),_2={type:`__br__`},v2=/^<br\s*\/?>$/i;function y2(e){let t=w2(e,y2);return(t.type===`tableCell`||t.type===`tableHeader`)&&t.content?{...t,content:b2(t.content)}:t}function b2(e){let t=[];for(let n of e){let e=x2(n);e.length!==0&&(t.length>0&&t.push(_2),t.push(...e))}return t}function x2(e){return e.text!==void 0||e.type===`hardBreak`||e.type===`jsxInline`?[e]:!e.content||e.content.length===0?[]:e.content.some(e=>e.text===void 0&&e.type!==`hardBreak`&&e.type!==`jsxInline`&&!!e.content)?b2(e.content):e.content}function S2(e){return e.type===`hardBreak`||e.type===_2.type||e.text!==void 0&&v2.test(e.text.trim())?_2:w2(e,S2)}var C2=[{label:`table-cell-block-flatten`,severity:`pm-model-caused`,rationale:`GFM table cells have no block spelling; a block placed in a cell is flattened to inline on serialize, so a cell-with-blocks and a cell-with-inline describe the same persisted document.`,proofPointer:`markdown/table-cell-flatten.ts flattenCellBlocks (table-cell-flatten-dropped-block event)`,canonicalize:y2},{label:`void-hardbreak-br`,severity:`serializer-caused`,rationale:`A void hardBreak inside a table cell or heading serializes to a literal <br /> that a fresh parse keeps as text; the node form and the literal form are the same break.`,proofPointer:`markdown/void-br-promoter.ts + markdown/to-markdown-handlers.ts break handler`,canonicalize:S2}];function w2(e,t){return e.content?{...e,content:e.content.map(t)}:e}function T2(e,t){let n={};e.type!==void 0&&(n.type=e.type),e.text!==void 0&&(n.text=e.text);let r=E2(e.attrs,t);return r&&(n.attrs=r),e.marks&&e.marks.length>0&&(n.marks=[...e.marks].map(e=>({type:e.type,attrs:E2(e.attrs,t)})).sort((e,t)=>O2(e).localeCompare(O2(t)))),e.content&&e.content.length>0&&(n.content=e.content.map(e=>T2(e,t))),n}function E2(e,t){if(!e)return null;let n={};for(let r of Object.keys(e).sort()){if(h2.has(r)||t?.(r))continue;let i=e[r];i!=null&&(n[r]=t?D2(i,t):i)}return Object.keys(n).length>0?n:null}function D2(e,t){if(Array.isArray(e))return e.map(e=>D2(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))t(r)||(n[r]=D2(i,t));return n}return e}function O2(e){return JSON.stringify(e,(e,t)=>{if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n of Object.keys(t).sort())e[n]=t[n];return e}return t})}function k2(e){let t=``,n=e=>{if(e.text!==void 0&&(t+=e.text),e.content)for(let t of e.content)n(t)};return n(e),t.replace(/\s+/g,``)}function A2(e){let t=[],n=e=>{if(e.type&&g2.has(e.type)){let n=e.type===`jsxComponent`?String(e.attrs?.componentName??``):``;t.push(n?`${e.type}:${n}`:e.type)}if(e.content)for(let t of e.content)n(t)};return n(e),t.sort()}function j2(e){let t=e,n=[];for(let e of C2){let r=O2(t),i=e.canonicalize(t);O2(i)!==r&&n.push(e.label),t=i}return{normalized:t,fired:n}}function M2(e,t,n={}){let r=j2(e),i=j2(t),a=[...new Set([...r.fired,...i.fired])];if(!m2(k2(r.normalized),k2(i.normalized)))return{equivalent:!1,level:`L1`,reason:`content-loss`,appliedDegrades:a,detail:`authored text did not survive the round-trip`};let o=A2(r.normalized),s=A2(i.normalized);if(O2(o)!==O2(s))return{equivalent:!1,level:`L1`,reason:`structural-shatter`,appliedDegrades:a,detail:`container multiset diverged: [${o.join(`, `)}] vs [${s.join(`, `)}]`};let c=T2(r.normalized,n.ignoreAttrs),l=T2(i.normalized,n.ignoreAttrs);return O2(c)===O2(l)?{equivalent:!0,level:a.length>0?`L2`:`L1`,appliedDegrades:a}:{equivalent:!1,level:`L2`,reason:`structural-divergence`,appliedDegrades:a,detail:N2(c,l)}}function N2(e,t,n=`doc`){let r=e,i=t;if(!r||!i)return`${n}: node presence differs`;if(r.type!==i.type)return`${n}: type ${String(r.type)} vs ${String(i.type)}`;let a=r.content??[],o=i.content??[];if(a.length!==o.length)return`${n}(${String(r.type)}): child count ${a.length} vs ${o.length}`;for(let e=0;e<a.length;e++)if(O2(a[e])!==O2(o[e]))return N2(a[e],o[e],`${n}>${String(r.type)}[${e}]`);return`${n}(${String(r.type)}): attrs or marks differ`}function P2(e,t,n){return!M2(e,t,{ignoreAttrs:n}).equivalent}var F2=new Set([`src`,`href`,`size`]),I2=new Set([`WikiEmbedImage`,`WikiEmbedVideo`,`WikiEmbedAudio`,`WikiEmbedFile`]);function L2(e){if(Array.isArray(e))return e.map(e=>L2(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))F2.has(n)||(t[n]=L2(r));return t}return e}function R2(e){return e.type===`jsxComponent`&&typeof e.attrs?.componentName==`string`&&I2.has(e.attrs.componentName)?L2(e):e.content?{...e,content:e.content.map(R2)}:e}function z2(e){if(Array.isArray(e))return e.map(e=>z2(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))n!==`position`&&(t[n]=z2(r));return t}return e}function B2(e){if(e.type===`jsxComponent`)return e;if(e.content)for(let t of e.content){let e=B2(t);if(e)return e}}function V2(e){let t=e.cacheLimit??2048,n=new Map,r=r=>{let i=n.get(r);if(i!==void 0)return i;let a=B2(e.parse(r)),o=a?R2(z2(a)):null;if(n.size>=t){let e=n.keys().next().value;e!==void 0&&n.delete(e)}return n.set(r,o),o};return{isDiverged(e){if(e.type!==`jsxComponent`||!e.attrs||e.attrs.kind===`expression`)return!1;let t=e.attrs.sourceRaw;if(typeof t!=`string`||t.length===0)return!1;let n=r(t);return n?P2(n,R2(z2(e))):!1}}}function H2(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}if(r>=0){let e=n[r];if(e.type===`mdxJsxAttribute`&&e.value!=null&&typeof e.value==`object`&&e.value.type===`mdxJsxAttributeValueExpression`&&U2(e.value.value,t))continue}let o=W2(e,t);r>=0?n[r]=o:n.push(o)}return n}function U2(e,t){try{return JSON.stringify(JSON.parse(e))===JSON.stringify(t)}catch{return!1}}function W2(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function G2(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:H2(t,r),children:n.all(t),data:{}}}function K2(e,t,n){let r=t.attrs.props?.children;return{type:`mdxJsxTextElement`,name:e,attributes:H2(t,n),children:typeof r==`string`&&r!==``?[{type:`text`,value:r}]:[],data:{}}}var q2=/^[A-Za-z0-9]{20,}$/,J2=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Y2(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function X2(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return q2.test(n)?n:null}function Z2(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Y2(t.hostname))return null;let n=X2(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&J2.test(r)?r:null}}function Q2(e){return Z2(e)!==null}function $2(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function e4(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:$2(t.hostname)}var t4=/^[A-Za-z0-9_-]{11}$/;function n4(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function r4(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function i4(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return t4.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return t4.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function a4(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!n4(t.hostname))return null;let n=i4(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?r4(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}var o4=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],s4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:td,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],c4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],l4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:nd,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:td,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&Q2(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(e4(e.src)||Q2(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(a4(e.src)!==null||e4(e.src)||Q2(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],u4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:rd,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],d4=[{name:`title`,type:`string`,required:!0,description:`Accordion heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the accordion renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],f4=[o4[0],o4[1],o4[4],o4[5],o4[6]],p4=[s4[0],s4[1],s4[7]],m4=[d4[0],d4[1],d4[4],d4[5]],h4=[{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`,`justify`],required:!1,defaultValue:`center`,description:"Block alignment from the `<div align>` attribute."},{name:`tag`,type:`string`,required:!1,defaultValue:`div`,hidden:!0,description:`Source wrapper tag (div or center).`},{name:`sourceAttrs`,type:`string`,required:!1,defaultValue:``,hidden:!0,description:`Raw opener-tag attribute bytes preserved for round-trip.`}],g4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],_4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],v4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],y4=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],b4=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],x4=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],S4=[x4[0]],C4=[x4[0]],w4=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],T4=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],E4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],D4=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:id,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],O4=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],k4=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function A4(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function j4(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function M4(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:a,data:{target:n,anchor:i,alias:r},children:[{type:`text`,value:a}]}}var N4=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:o4,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>G2(`Callout`,e,t,o4)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:s4,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>G2(`img`,e,t,s4)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:l4,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>G2(`video`,e,t,l4)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:u4,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>G2(`audio`,e,t,u4)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:D4,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>G2(`Pdf`,e,t,D4)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:E4,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>G2(`File`,e,t,E4)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:c4,icon:`AppWindow`,category:`media`,displayName:`Embed`,description:'Inline web embed (iframe) — drop a URL, get a resizable preview pane. For YouTube / Vimeo / Loom prefer `<video src="…">` (player props, click-facade); `<Embed>` auto-rewrites watch URLs as a fallback.',searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>G2(`Embed`,e,t,c4)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:d4,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>G2(`Accordion`,e,t,d4)},{name:`Toggle`,surface:`canonical`,hasChildren:!0,props:d4,icon:`ChevronRight`,category:`content`,displayName:`Toggle`,description:"Standalone expand/collapse block (Notion-style). Same render + props as `<Accordion>` — pick whichever vocabulary matches the vault.",searchTerms:[`toggle`,`collapsible`,`expand`,`details`,`disclosure`,`fold`],exampleBody:`Body content revealed when the toggle is expanded.`,serialize:(e,t)=>G2(`Toggle`,e,t,d4)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:y4,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
|
|
509
509
|
<Tab label="Two">Body of the second tab panel.</Tab>`,serialize:(e,t)=>G2(`Tabs`,e,t,y4)},{name:`Tab`,surface:`canonical`,hasChildren:!0,props:b4,icon:`PanelTop`,category:`content`,displayName:`Tab`,description:"A single tab panel inside a `<Tabs>` container — carries the strip label and the block-content body.",searchTerms:[`tab`,`panel`],exampleBody:"Panel content — must be nested inside a `<Tabs>` parent.",serialize:(e,t)=>G2(`Tab`,e,t,b4)},{name:`Math`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:x4,icon:`Sigma`,category:`content`,displayName:`Math`,description:`Block math equation rendered with KaTeX from a LaTeX source string`,searchTerms:[`math`,`latex`,`equation`,`formula`,`katex`,`tex`],serialize:(e,t)=>G2(`Math`,e,t,x4)},{name:`MermaidFence`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:w4,icon:`Workflow`,category:`content`,displayName:`Mermaid`,placeholder:{label:`Add a Mermaid diagram`},description:"Diagram rendered from Mermaid source (flowchart, sequence, class, state, ER, gantt, pie). Authored exclusively as ` ```mermaid ` fenced code.",searchTerms:[`mermaid`,`diagram`,`flowchart`,`graph`,`sequence`,`sequencediagram`,`class`,`state`,`er`,`erdiagram`,`gantt`,`pie`,`chart`],serialize:e=>({type:`code`,lang:`mermaid`,meta:null,value:e.attrs.props?.chart??``})},{name:`Mirror`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:O4,icon:`CopyPlus`,category:`content`,displayName:`Mirror`,description:"Render a read-only copy of a `<MirrorSource>` block from another doc. Use to keep the same content in sync across multiple docs without copy-paste — edits land at the source, every Mirror reflects the change.",searchTerms:[`mirror`,`sync`,`synced`,`transclude`,`embed`,`reference`,`shared block`],serialize:(e,t)=>G2(`Mirror`,e,t,O4)},{name:`MirrorSource`,surface:`canonical`,hasChildren:!0,props:k4,icon:`GitBranch`,category:`content`,displayName:`Mirror Source`,description:'Mark a block as the source of truth for content that appears in multiple docs. Wrap any block content; `<Mirror src="…" anchor="<id>">` references render this verbatim read-only at every call-site. Edit here, propagate everywhere.',searchTerms:[`mirror source`,`sync source`,`source block`,`master block`,`shared`],exampleBody:"Authoritative content lives inside this block — edits here propagate to every `<Mirror>` that references this id.",serialize:(e,t)=>G2(`MirrorSource`,e,t,k4)},{name:`GFMCallout`,surface:`compat`,hasChildren:!0,props:f4,icon:`MessageSquareWarning`,category:`content`,displayName:`GFM Callout`,description:"GFM blockquote alert (`> [!NOTE]`) — read-only compat. Preserves `> [!NOTE]` syntax on round-trip; insert a fresh Callout block for the full prop surface.",rendersAs:`Callout`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]),i=n?.type??`note`;return{type:`blockquote`,children:[{type:`html`,value:`[!${(r.has(i.toLowerCase())?i:`note`).toUpperCase()}]${n?.collapsible?n.defaultOpen===!1?`-`:`+`:``}${n?.title?` ${n.title}`:``}`},...t.all(e).filter(e=>{if(e.type!==`paragraph`)return!0;let t=e;return Array.isArray(t.children)&&t.children.length>0})]}}},{name:`CommonMarkImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:p4,icon:`Image`,category:`media`,displayName:`CommonMark Image`,description:'CommonMark image (``) — read-only compat. Preserves `` syntax on round-trip; insert a fresh Image block for the full HTML-native attribute surface (srcset, sizes, decoding, etc.).',rendersAs:`img`,translateProps:e=>e,serialize:e=>{let t=e.attrs.props;return{type:`paragraph`,children:[{type:`image`,url:t?.sourceUrl??t?.src??``,alt:t?.alt??``,title:t?.title??null}]}}},{name:`WikiEmbedImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:g4,icon:`ZoomIn`,category:`media`,displayName:`Wiki Embed Image`,description:"Obsidian-style `![[file.png]]` wiki-embed — read-only compat. Edit the alt-text via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`img`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,alt:t??n}},serialize:M4},{name:`WikiEmbedVideo`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:_4,icon:`Film`,category:`media`,displayName:`Wiki Embed Video`,description:"Obsidian-style `![[clip.mp4]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`video`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:M4},{name:`WikiEmbedAudio`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:v4,icon:`Volume2`,category:`media`,displayName:`Wiki Embed Audio`,description:"Obsidian-style `![[song.mp3]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`audio`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:M4},{name:`WikiEmbedFile`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:T4,icon:`Paperclip`,category:`media`,displayName:`Wiki Embed File`,description:"Obsidian-style `![[file.zip]]` wiki-embed — read-only compat for arbitrary downloadable attachments. Renders through the `File` canonical (inline row with file-up icon + bold name + optional dim size). Edit the display name via the alias slot.",rendersAs:`File`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.size==`string`&&e.size.length>0?e.size:null;return{src:e.src,name:t??void 0,size:n??void 0}},serialize:M4},{name:`HtmlDetailsAccordion`,surface:`compat`,hasChildren:!0,props:m4,icon:`ChevronRight`,category:`content`,displayName:`HTML5 Details`,description:"HTML5 `<details><summary>` collapsible — read-only compat. Preserves `<details>` syntax on round-trip; insert a fresh Accordion block for icon / description / group-name props.",rendersAs:`Accordion`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=n?.defaultOpen?` open`:``,i=n?.name?` name="${A4(n.name)}"`:``,a=n?.id?` id="${A4(n.id)}"`:``,o=n?.title?.trim(),s=o?`<summary>${j4(o)}</summary>`:``;return{type:`mdxJsxFlowElement`,name:`HtmlDetailsAccordion`,attributes:[],children:t.all(e),data:{htmlBoundary:{opener:`<details${r}${i}${a}>\n${s}`,closer:`</details>`}}}}},{name:`HtmlAlignBlock`,surface:`canonical`,hasChildren:!0,props:h4,icon:`AlignCenter`,category:`content`,displayName:`Align block`,description:"GitHub-style `<div align>` wrapper. Children render as normal blocks with the alignment applied; the `<div align>` syntax is preserved on round-trip.",searchTerms:[`align`,`center`,`centered`,`div`],serialize:(e,t)=>{let n=e.attrs.props,r=n?.tag===`center`?`center`:`div`,i=typeof n?.align==`string`&&n.align?n.align:null,a=typeof n?.sourceAttrs==`string`?n.sourceAttrs:``,o=/(\balign\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s"'<>]+)/i;return i!==null&&(r===`div`||i!==`center`)?a=o.test(a)?a.replace(o,`$1"${A4(i)}"`):`${a} align="${A4(i)}"`:(i===null||r===`center`&&i===`center`)&&(a=a.replace(RegExp(`\\s*${o.source}`,`i`),``)),{type:`mdxJsxFlowElement`,name:`HtmlAlignBlock`,attributes:[],children:t.all(e),data:{htmlBoundary:{opener:`<${r}${a}>`,closer:`</${r}>`}}}}},{name:`DollarMath`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:S4,icon:`Sigma`,category:`content`,displayName:`Dollar Math`,description:"Block math via `$$…$$` syntax — read-only compat. Preserves `$$…$$` form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`math`,value:e.attrs.props?.formula??``})},{name:`MathFence`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:C4,icon:`Sigma`,category:`content`,displayName:`Math Fence`,description:"Block math via ` ```math ` fenced code syntax — read-only compat. Preserves the fence form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`code`,lang:`math`,meta:null,value:e.attrs.props?.formula??``})}],P4={name:`*`,surface:`canonical`,hasChildren:!0,props:[],description:`Unregistered component — children editable as markdown`,serialize:(e,t)=>G2(e.attrs.componentName||`*`,e,t)};function F4(){let e=new Map;e.set(`*`,P4);for(let t of N4)e.set(t.name,t);return{get(t){return e.get(t)},getOrWildcard(t){return e.get(t)??e.get(`*`)},set(t,n){e.set(t,n)},has(t){return e.has(t)},entries(){return e.entries()}}}var I4={parseFallback:{blockLevel:0,wholeDoc:0,wholeDocBudget:0},jsxRenderFailure:{},jsxAutoConvertFailed:{},jsxAutoConvertSucceeded:{},jsxPropDropped:{},jsxMoveFailed:{},jsxStuckCopyFailed:{},jsxStuckDeleteFailed:{},jsxPopoverCloseRestoreFailed:{},jsxKeyboardDeleteFailed:{},blockGripClickSelectFailed:{},jsxArrowNodeSelectFailed:{}};function L4(){I4.parseFallback.blockLevel++}function R4(){I4.parseFallback.wholeDoc++}function z4(){I4.parseFallback.wholeDocBudget++}function B4(e){I4.jsxRenderFailure[e]=(I4.jsxRenderFailure[e]??0)+1}function V4(e){I4.jsxAutoConvertFailed[e]=(I4.jsxAutoConvertFailed[e]??0)+1}function H4(e){I4.jsxAutoConvertSucceeded[e]=(I4.jsxAutoConvertSucceeded[e]??0)+1}function U4(e){I4.jsxPropDropped[e]=(I4.jsxPropDropped[e]??0)+1}function W4(e){I4.jsxMoveFailed[e]=(I4.jsxMoveFailed[e]??0)+1}function G4(e){I4.jsxStuckCopyFailed[e]=(I4.jsxStuckCopyFailed[e]??0)+1}function K4(e){I4.jsxStuckDeleteFailed[e]=(I4.jsxStuckDeleteFailed[e]??0)+1}function q4(e){I4.jsxPopoverCloseRestoreFailed[e]=(I4.jsxPopoverCloseRestoreFailed[e]??0)+1}function J4(e){I4.jsxKeyboardDeleteFailed[e]=(I4.jsxKeyboardDeleteFailed[e]??0)+1}function Y4(e){I4.blockGripClickSelectFailed[e]=(I4.blockGripClickSelectFailed[e]??0)+1}function X4(e){I4.jsxArrowNodeSelectFailed[e]=(I4.jsxArrowNodeSelectFailed[e]??0)+1}var Z4=/^(`{3,}|~{3,})/gm;function Q4(e){let t=[],n=null;for(let r of e.matchAll(Z4)){let e=r[1],i=r.index;n?e[0]===n.marker[0]&&e.length>=n.marker.length&&(t.push([n.offset,i+r[0].length]),n=null):n={marker:e,offset:i}}return n&&t.push([n.offset,e.length]),t}function $4(e,t){return t.some(([t,n])=>e>=t&&e<n)}var e3=/`+/g;function t3(e){let t=[];e3.lastIndex=0;for(let n of e.matchAll(e3))t.push({offset:n.index,length:n[0].length});let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let i=e+1;i<t.length;i++){let a=t[i];if(a.length===r.length){n.push([r.offset,a.offset+a.length]),e=i;break}}}return n}var n3=/^[ \t]{0,3}\[([^\]]+)\]:\s*(\S+)(\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*$/gm;function r3(e){let t=Q4(e),n=[];for(let r of e.matchAll(n3))$4(r.index,t)||n.push(r[0].trimEnd());return n.length>0?`${n.join(`
|
|
510
510
|
`)}\n\n`:``}var i3=500,a3=1e3;function o3(e,t){let n={startMs:typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),calls:0};return u3(e,t.parse,0,n)}function s3(e){return e.calls>=a3?!0:(typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now())-e.startMs>=i3}var c3=500;function l3(e){return e instanceof Error?{name:e.name,message:e.message.slice(0,c3),stack:e.stack?.split(`
|
|
511
511
|
`).slice(0,4).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{xa as e}from"./dist-
|
|
1
|
+
import{xa as e}from"./dist-BU8JCBqy2.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`];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}function j(e,t){let n=A(e);if(n)return D(n)===D(t)?n.path:void 0}var M=`:`;function N(e){let t=e.host===void 0?e.name:`${e.name}${M}${e.host}`;return`${y}${[e.scope,t].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function P(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(M),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 F=/\.(md|mdx)$/i;function I(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function L(e){return I(e).replace(F,``)}function R(e){let t=I(e);return t?F.test(t)?t:`${t}.md`:`untitled.md`}function z(e){let t=L(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}export{P as C,j as S,S as T,m as _,_ as a,u as b,p as c,v as d,i as f,x as g,k as h,r as i,D as l,N as m,R as n,O as o,f as p,L as r,n as s,z as t,d as u,s as v,A as w,l as x,c as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as e}from"./dist-
|
|
1
|
+
import{k as e}from"./dist-BU8JCBqy2.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{Co as e,Do as t,xo as n}from"./dist-
|
|
1
|
+
import{Co as e,Do as t,xo as n}from"./dist-BU8JCBqy2.js";import{d as r,f as i,p as a}from"./doc-paths-D9KdMECm.js";import{t as o}from"./file-tree-rename-validation-1Yh3dC3l.js";import{c as s,l as c,s as l}from"./file-tree-utils-B9qjWixz.js";import{a as u}from"./navigation-targets-BDEX1Jzv.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.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||!Array.from(e.types).includes(`application/x-open-knowledge-sidebar-item+json`))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(t,r=v){return y.test(t)||e(t)||n(t)?t:`${t}${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,n){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:n.size};let a=r.startsWith(`.`)?r.slice(1):r;return{kind:`asset`,path:e,assetExt:a,mediaKind:t(a),modified:i,size:n.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{p 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,h 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};
|